]> source.dussan.org Git - poi.git/commitdiff
Fixed unused imports compiler warnings (and some others)
authorJosh Micich <josh@apache.org>
Tue, 18 Aug 2009 02:41:45 +0000 (02:41 +0000)
committerJosh Micich <josh@apache.org>
Tue, 18 Aug 2009 02:41:45 +0000 (02:41 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805262 13f79535-47bb-0310-9956-ffa450edef68

170 files changed:
src/java/org/apache/poi/hssf/dev/EFHSSF.java [deleted file]
src/java/org/apache/poi/hssf/model/CommentShape.java
src/java/org/apache/poi/hssf/model/Workbook.java
src/java/org/apache/poi/hssf/record/CFRuleRecord.java
src/java/org/apache/poi/hssf/record/ContinueRecord.java
src/java/org/apache/poi/hssf/record/RecordFactory.java
src/java/org/apache/poi/hssf/record/SelectionRecord.java
src/java/org/apache/poi/hssf/record/SubRecord.java
src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java
src/java/org/apache/poi/hssf/record/formula/RefPtgBase.java
src/java/org/apache/poi/hssf/record/formula/atp/ParityFunction.java
src/java/org/apache/poi/hssf/record/formula/atp/YearFrac.java
src/java/org/apache/poi/hssf/usermodel/HSSFChildAnchor.java
src/java/org/apache/poi/hssf/usermodel/HSSFCreationHelper.java
src/java/org/apache/poi/hssf/usermodel/HSSFDataFormatter.java
src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java
src/java/org/apache/poi/poifs/dev/POIFSLister.java
src/java/org/apache/poi/poifs/property/DirectoryProperty.java
src/java/org/apache/poi/poifs/property/PropertyTable.java
src/java/org/apache/poi/poifs/property/RootProperty.java
src/java/org/apache/poi/poifs/storage/BATBlock.java
src/java/org/apache/poi/poifs/storage/BlockAllocationTableReader.java
src/java/org/apache/poi/poifs/storage/BlockAllocationTableWriter.java
src/java/org/apache/poi/poifs/storage/BlockListImpl.java
src/java/org/apache/poi/poifs/storage/HeaderBlockConstants.java
src/java/org/apache/poi/poifs/storage/PropertyBlock.java
src/java/org/apache/poi/poifs/storage/SmallBlockTableReader.java
src/java/org/apache/poi/util/IntList.java
src/java/org/apache/poi/util/NullLogger.java
src/java/org/apache/poi/util/ShortList.java
src/ooxml/java/org/apache/poi/POIXMLDocument.java
src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java
src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
src/ooxml/testcases/org/apache/poi/xssf/io/TestLoadSaveXSSF.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPrintSetup.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
src/scratchpad/src/org/apache/poi/hdf/extractor/StyleSheet.java
src/scratchpad/src/org/apache/poi/hdf/model/HDFObjectFactory.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FileInformationBlock.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleSheet.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/CHPAbstractType.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/DOPAbstractType.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/FIBAbstractType.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/PAPAbstractType.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/SEPAbstractType.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/TAPAbstractType.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions/TCAbstractType.java
src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java
src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java
src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java
src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java
src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowDumper.java
src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java
src/scratchpad/src/org/apache/poi/hslf/dev/TextStyleListing.java
src/scratchpad/src/org/apache/poi/hslf/dev/UserEditAndPersistListing.java
src/scratchpad/src/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java
src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java
src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java
src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java
src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java
src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java
src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java
src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java
src/scratchpad/src/org/apache/poi/hslf/record/AnimationInfoAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/DocumentEncryptionAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/ExAviMovie.java
src/scratchpad/src/org/apache/poi/hslf/record/ExControl.java
src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlinkAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/ExMediaAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/InteractiveInfoAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/MainMaster.java
src/scratchpad/src/org/apache/poi/hslf/record/OEShapeAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
src/scratchpad/src/org/apache/poi/hslf/record/PPDrawingGroup.java
src/scratchpad/src/org/apache/poi/hslf/record/RoundTripHFPlaceholder12.java
src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java
src/scratchpad/src/org/apache/poi/hslf/record/SoundCollection.java
src/scratchpad/src/org/apache/poi/hslf/record/SoundData.java
src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
src/scratchpad/src/org/apache/poi/hwpf/model/DocumentProperties.java
src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java
src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java
src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/types/CHPAbstractType.java
src/scratchpad/src/org/apache/poi/hwpf/model/types/DOPAbstractType.java
src/scratchpad/src/org/apache/poi/hwpf/model/types/FIBAbstractType.java
src/scratchpad/src/org/apache/poi/hwpf/model/types/PAPAbstractType.java
src/scratchpad/src/org/apache/poi/hwpf/model/types/SEPAbstractType.java
src/scratchpad/src/org/apache/poi/hwpf/model/types/TAPAbstractType.java
src/scratchpad/src/org/apache/poi/hwpf/model/types/TCAbstractType.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmCompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmCompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmCompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/BorderCode.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/HWPFList.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/ParagraphProperties.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableIterator.java
src/scratchpad/testcases/org/apache/poi/hslf/TestEncryptedFile.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlinkAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjList.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjListAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjStg.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestInteractiveInfoAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestSound.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxInteractiveInfoAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSavedByTable.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestShapes.java
src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java
src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java
src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java
src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java
src/testcases/org/apache/poi/hssf/record/formula/AbstractPtgTestCase.java
src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java
src/testcases/org/apache/poi/hssf/record/formula/eval/TestCircularReferences.java
src/testcases/org/apache/poi/hssf/record/formula/functions/NumericFunctionInvoker.java
src/testcases/org/apache/poi/hssf/usermodel/TestCloneSheet.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
src/testcases/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java
src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java
src/testcases/org/apache/poi/poifs/filesystem/TestPropertySorter.java
src/testcases/org/apache/poi/poifs/storage/LocalRawDataBlockList.java
src/testcases/org/apache/poi/poifs/storage/TestBlockListImpl.java

diff --git a/src/java/org/apache/poi/hssf/dev/EFHSSF.java b/src/java/org/apache/poi/hssf/dev/EFHSSF.java
deleted file mode 100644 (file)
index 0c3ab00..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-
-
-package org.apache.poi.hssf.dev;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.hssf.record.*;
-import org.apache.poi.hssf.eventmodel.*;
-import org.apache.poi.hssf.eventusermodel.*;
-import org.apache.poi.hssf.usermodel.*;
-
-import org.apache.poi.hssf.eventusermodel.HSSFRequest;
-import org.apache.poi.hssf.eventusermodel.HSSFListener;
-import org.apache.poi.hssf.eventusermodel.HSSFEventFactory;
-
-/**
- * Event Factory version of HSSF test class.
- * @author  andy
- */
-//JMH
-//public class EFHSSF
-//{
-//    String       infile;
-//    String       outfile;
-//    HSSFWorkbook workbook = null;
-//    HSSFSheet    cursheet = null;
-//
-//    /** Creates a new instance of EFHSSF */
-//
-//    public EFHSSF()
-//    {
-//    }
-//
-//    public void setInputFile(String infile)
-//    {
-//        this.infile = infile;
-//    }
-//
-//    public void setOutputFile(String outfile)
-//    {
-//        this.outfile = outfile;
-//    }
-//
-//    public void run()
-//        throws IOException
-//    {
-//        FileInputStream fin   = new FileInputStream(infile);
-//        POIFSFileSystem poifs = new POIFSFileSystem(fin);
-//        InputStream     din   = poifs.createDocumentInputStream("Workbook");
-//        HSSFRequest     req   = new HSSFRequest();
-//
-//        req.addListenerForAllRecords(new EFHSSFListener(this));
-//        HSSFEventFactory factory = new HSSFEventFactory();
-//
-//        factory.processEvents(req, din);
-//        fin.close();
-//        din.close();
-//        FileOutputStream fout = new FileOutputStream(outfile);
-//
-//        workbook.write(fout);
-//        fout.close();
-//        System.out.println("done.");
-//    }
-//
-//    public void recordHandler(Record record)
-//    {
-//        HSSFRow  row      = null;
-//        HSSFCell cell     = null;
-//        int      sheetnum = -1;
-//
-//        switch (record.getSid())
-//        {
-//
-//            case BOFRecord.sid :
-//                BOFRecord bof = ( BOFRecord ) record;
-//
-//                if (bof.getType() == bof.TYPE_WORKBOOK)
-//                {
-//                    workbook = new HSSFWorkbook();
-//                }
-//                else if (bof.getType() == bof.TYPE_WORKSHEET)
-//                {
-//                    sheetnum++;
-//                    cursheet = workbook.getSheetAt(sheetnum);
-//                }
-//                break;
-//
-//            case BoundSheetRecord.sid :
-//                BoundSheetRecord bsr = ( BoundSheetRecord ) record;
-//
-//                workbook.createSheet(bsr.getSheetname());
-//                break;
-//
-//            case RowRecord.sid :
-//                RowRecord rowrec = ( RowRecord ) record;
-//
-//                cursheet.createRow(rowrec.getRowNumber());
-//                break;
-//
-//            case NumberRecord.sid :
-//                NumberRecord numrec = ( NumberRecord ) record;
-//
-//                row  = cursheet.getRow(numrec.getRow());
-//                cell = row.createCell(numrec.getColumn(),
-//                                      HSSFCell.CELL_TYPE_NUMERIC);
-//                cell.setCellValue(numrec.getValue());
-//                break;
-//
-//            case SSTRecord.sid :
-//                SSTRecord sstrec = ( SSTRecord ) record;
-//
-//                for (int k = 0; k < sstrec.getNumUniqueStrings(); k++)
-//                {
-//                    workbook.addSSTString(new UnicodeString(sstrec.getString(k)));
-//                }
-//                break;
-//
-//            case LabelSSTRecord.sid :
-//                LabelSSTRecord lrec = ( LabelSSTRecord ) record;
-//
-//                row  = cursheet.getRow(lrec.getRow());
-//                cell = row.createCell(lrec.getColumn(),
-//                                      HSSFCell.CELL_TYPE_STRING);
-//                cell.setCellValue(workbook.getSSTString(lrec.getSSTIndex()));
-//                break;
-//        }
-//    }
-//
-//    public static void main(String [] args)
-//    {
-//        if ((args.length < 2) || !args[ 0 ].equals("--help"))
-//        {
-//            try
-//            {
-//                EFHSSF viewer = new EFHSSF();
-//
-//                viewer.setInputFile(args[ 0 ]);
-//                viewer.setOutputFile(args[ 1 ]);
-//                viewer.run();
-//            }
-//            catch (IOException e)
-//            {
-//                e.printStackTrace();
-//            }
-//        }
-//        else
-//        {
-//            System.out.println("EFHSSF");
-//            System.out.println(
-//                "General testbed for HSSFEventFactory based testing and "
-//                + "Code examples");
-//            System.out.println("Usage: java org.apache.poi.hssf.dev.EFHSSF "
-//                               + "file1 file2");
-//            System.out.println(
-//                "   --will rewrite the file reading with the event api");
-//            System.out.println("and writing with the standard API");
-//        }
-//    }
-//}
-//
-//class EFHSSFListener
-//    implements HSSFListener
-//{
-//    EFHSSF efhssf;
-//
-//    public EFHSSFListener(EFHSSF efhssf)
-//    {
-//        this.efhssf = efhssf;
-//    }
-//
-//    public void processRecord(Record record)
-//    {
-//        efhssf.recordHandler(record);
-//    }
-//}
index 49f52e0e834e26ebc61da0fb5f762c9a3ba6c171..23242d56d86803f2fb84aa8a75bbbb25cecfa2d2 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hssf.model;
 
-import org.apache.poi.hssf.record.*;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.poi.ddf.EscherOptRecord;
+import org.apache.poi.ddf.EscherProperties;
+import org.apache.poi.ddf.EscherProperty;
+import org.apache.poi.ddf.EscherSimpleProperty;
+import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
+import org.apache.poi.hssf.record.NoteRecord;
+import org.apache.poi.hssf.record.NoteStructureSubRecord;
+import org.apache.poi.hssf.record.ObjRecord;
+import org.apache.poi.hssf.record.SubRecord;
 import org.apache.poi.hssf.usermodel.HSSFComment;
 import org.apache.poi.hssf.usermodel.HSSFShape;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.ddf.*;
-
-import java.util.List;
-import java.util.Iterator;
 
 /**
  * Represents a cell comment.
@@ -32,9 +39,9 @@ import java.util.Iterator;
  *
  * @author Yegor Kozlov
  */
-public class CommentShape extends TextboxShape {
+public final class CommentShape extends TextboxShape {
 
-    private NoteRecord note;
+    private NoteRecord _note;
 
     /**
      * Creates the low-level records for a comment.
@@ -46,10 +53,10 @@ public class CommentShape extends TextboxShape {
     {
         super(hssfShape, shapeId);
 
-        note = createNoteRecord(hssfShape, shapeId);
+        _note = createNoteRecord(hssfShape, shapeId);
 
         ObjRecord obj = getObjRecord();
-        List records = obj.getSubRecords();
+        List<SubRecord> records = obj.getSubRecords();
         int cmoIdx = 0;
         for (int i = 0; i < records.size(); i++) {
             Object r = records.get(i);
@@ -96,9 +103,9 @@ public class CommentShape extends TextboxShape {
         super.addStandardOptions(shape, opt);
 
         //remove unnecessary properties inherited from TextboxShape
-        java.util.List props = opt.getEscherProperties();
-        for ( Iterator iterator = props.iterator(); iterator.hasNext(); ) {
-            EscherProperty prop = (EscherProperty) iterator.next();
+        List<EscherProperty> props = opt.getEscherProperties();
+        for (Iterator<EscherProperty> iterator = props.iterator(); iterator.hasNext(); ) {
+            EscherProperty prop = iterator.next();
             switch (prop.getId()){
                 case EscherProperties.TEXT__TEXTLEFT:
                 case EscherProperties.TEXT__TEXTRIGHT:
@@ -127,7 +134,6 @@ public class CommentShape extends TextboxShape {
      */
     public NoteRecord getNoteRecord()
     {
-        return note;
+        return _note;
     }
-
 }
index 4378779cc4be83f30c68b3ba4df9d567c028d954..91cbaf4c6a794268f2f1e75728d86f0cb87a4a0d 100644 (file)
@@ -72,7 +72,6 @@ import org.apache.poi.hssf.record.StyleRecord;
 import org.apache.poi.hssf.record.SupBookRecord;
 import org.apache.poi.hssf.record.TabIdRecord;
 import org.apache.poi.hssf.record.UnicodeString;
-import org.apache.poi.hssf.record.UnknownRecord;
 import org.apache.poi.hssf.record.UseSelFSRecord;
 import org.apache.poi.hssf.record.WindowOneRecord;
 import org.apache.poi.hssf.record.WindowProtectRecord;
@@ -271,19 +270,19 @@ public final class Workbook implements Model {
                 case WindowOneRecord.sid:
                     if (log.check( POILogger.DEBUG ))
                         log.log(DEBUG, "found WindowOneRecord at " + k);
-                    retval.windowOne = (WindowOneRecord) rec; 
+                    retval.windowOne = (WindowOneRecord) rec;
                     break;
-                case WriteAccessRecord.sid: 
+                case WriteAccessRecord.sid:
                     if (log.check( POILogger.DEBUG ))
                         log.log(DEBUG, "found WriteAccess at " + k);
                     retval.writeAccess = (WriteAccessRecord) rec;
                     break;
-                case WriteProtectRecord.sid: 
+                case WriteProtectRecord.sid:
                     if (log.check( POILogger.DEBUG ))
                         log.log(DEBUG, "found WriteProtect at " + k);
                     retval.writeProtect = (WriteProtectRecord) rec;
                     break;
-                case FileSharingRecord.sid: 
+                case FileSharingRecord.sid:
                     if (log.check( POILogger.DEBUG ))
                         log.log(DEBUG, "found FileSharing at " + k);
                     retval.fileShare = (FileSharingRecord) rec;
@@ -296,7 +295,7 @@ public final class Workbook implements Model {
         //            retval.records.supbookpos = retval.records.bspos + 1;
         //            retval.records.namepos    = retval.records.supbookpos + 1;
         //        }
-        
+
         // Look for other interesting values that
         //  follow the EOFRecord
         for ( ; k < recs.size(); k++) {
@@ -307,7 +306,7 @@ public final class Workbook implements Model {
                     break;
             }
         }
-        
+
         if (retval.windowOne == null) {
             retval.windowOne = createWindowOne();
         }
@@ -388,7 +387,7 @@ public final class Workbook implements Model {
             retval.records.setBspos(records.size() - 1);
         }
         records.add( retval.createCountry() );
-        for ( int k = 0; k < nBoundSheets; k++ ) {   
+        for ( int k = 0; k < nBoundSheets; k++ ) {
             retval.getOrCreateLinkTable().checkExternSheet(k);
         }
         retval.sst = new SSTRecord();
@@ -452,7 +451,7 @@ public final class Workbook implements Model {
 
         return retval;
     }
-    
+
     /**
      * Retrieves the index of the given font
      */
@@ -468,7 +467,7 @@ public final class Workbook implements Model {
                 return i;
             }
         }
-        throw new IllegalArgumentException("Could not find that font!"); 
+        throw new IllegalArgumentException("Could not find that font!");
     }
 
     /**
@@ -487,10 +486,10 @@ public final class Workbook implements Model {
         numfonts++;
         return rec;
     }
-    
+
     /**
      * Removes the given font record from the
-     *  file's list. This will make all 
+     *  file's list. This will make all
      *  subsequent font indicies drop by one,
      *  so you'll need to update those yourself!
      */
@@ -553,7 +552,7 @@ public final class Workbook implements Model {
     }
 
     /**
-     * Determines whether a workbook contains the provided sheet name.  For the purpose of 
+     * Determines whether a workbook contains the provided sheet name.  For the purpose of
      * comparison, long names are truncated to 31 chars.
      *
      * @param name the name to test (case insensitive match)
@@ -580,18 +579,18 @@ public final class Workbook implements Model {
         }
         return false;
     }
-    
+
     /**
      * sets the order of appearance for a given sheet.
      *
      * @param sheetname the name of the sheet to reorder
      * @param pos the position that we want to insert the sheet into (0 based)
      */
-    
+
     public void setSheetOrder(String sheetname, int pos ) {
     int sheetNumber = getSheetIndex(sheetname);
     //remove the sheet that needs to be reordered and place it in the spot we want
-    boundsheets.add(pos, boundsheets.remove(sheetNumber));    
+    boundsheets.add(pos, boundsheets.remove(sheetNumber));
     }
 
     /**
@@ -606,7 +605,7 @@ public final class Workbook implements Model {
 
     /**
      * Gets the hidden flag for a given sheet.
-     * Note that a sheet could instead be 
+     * Note that a sheet could instead be
      *  set to be very hidden, which is different
      *  ({@link #isSheetVeryHidden(int)})
      *
@@ -619,8 +618,8 @@ public final class Workbook implements Model {
 
     /**
      * Gets the very hidden flag for a given sheet.
-     * This is different from the normal 
-     *  hidden flag 
+     * This is different from the normal
+     *  hidden flag
      *  ({@link #isSheetHidden(int)})
      *
      * @param sheetnum the sheet number (0 based)
@@ -632,20 +631,20 @@ public final class Workbook implements Model {
 
     /**
      * Hide or unhide a sheet
-     * 
+     *
      * @param sheetnum The sheet number
      * @param hidden True to mark the sheet as hidden, false otherwise
      */
     public void setSheetHidden(int sheetnum, boolean hidden) {
         getBoundSheetRec(sheetnum).setHidden(hidden);
     }
-    
+
     /**
      * Hide or unhide a sheet.
      *  0 = not hidden
      *  1 = hidden
      *  2 = very hidden.
-     * 
+     *
      * @param sheetnum The sheet number
      * @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden
      */
@@ -664,8 +663,8 @@ public final class Workbook implements Model {
         bsr.setHidden(h);
         bsr.setVeryHidden(vh);
     }
-    
-    
+
+
     /**
      * get the sheet's index
      * @param name  sheet name
@@ -713,18 +712,18 @@ public final class Workbook implements Model {
             boundsheets.remove(sheetIndex);
             fixTabIdRecord();
         }
-        
+
         // Within NameRecords, it's ok to have the formula
         //  part point at deleted sheets. It's also ok to
         //  have the ExternSheetNumber point at deleted
-        //  sheets. 
+        //  sheets.
         // However, the sheet index must be adjusted, or
         //  excel will break. (Sheet index is either 0 for
         //  global, or 1 based index to sheet)
         int sheetNum1Based = sheetIndex + 1;
         for(int i=0; i<getNumNames(); i++) {
             NameRecord nr = getNameRecord(i);
-            
+
             if(nr.getSheetNumber() == sheetNum1Based) {
                 // Excel re-writes these to point to no sheet
                 nr.setSheetNumber(0);
@@ -790,10 +789,10 @@ public final class Workbook implements Model {
 
         return retval;
     }
-    
+
     /**
      * Removes the given ExtendedFormatRecord record from the
-     *  file's list. This will make all 
+     *  file's list. This will make all
      *  subsequent font indicies drop by one,
      *  so you'll need to update those yourself!
      */
@@ -818,14 +817,14 @@ public final class Workbook implements Model {
         numxfs++;
         return xf;
     }
-    
+
     /**
      * Returns the StyleRecord for the given
      *  xfIndex, or null if that ExtendedFormat doesn't
      *  have a Style set.
      */
     public StyleRecord getStyleRecord(int xfIndex) {
-        // Style records always follow after 
+        // Style records always follow after
         //  the ExtendedFormat records
         for(int i=records.getXfpos(); i<records.size(); i++) {
             Record r = records.get(i);
@@ -848,11 +847,11 @@ public final class Workbook implements Model {
      *  records collection
      */
     public StyleRecord createStyleRecord(int xfIndex) {
-        // Style records always follow after 
+        // Style records always follow after
         //  the ExtendedFormat records
         StyleRecord newSR = new StyleRecord();
         newSR.setXFIndex(xfIndex);
-        
+
         // Find the spot
         int addAt = -1;
         for(int i=records.getXfpos(); i<records.size() &&
@@ -869,7 +868,7 @@ public final class Workbook implements Model {
             throw new IllegalStateException("No XF Records found!");
         }
         records.add(addAt, newSR);
-        
+
         return newSR;
     }
 
@@ -976,7 +975,7 @@ public final class Workbook implements Model {
             // Let's skip RECALCID records, as they are only use for optimization
             if ( record.getSid() != RecalcIdRecord.sid || ( (RecalcIdRecord) record ).isNeeded() )
             {
-                int len = 0; 
+                int len = 0;
                 if (record instanceof SSTRecord)
                 {
                     sst = (SSTRecord)record;
@@ -1090,7 +1089,7 @@ public final class Workbook implements Model {
     }
 
     /**
-     * creates the TabId record containing an array 
+     * creates the TabId record containing an array
      */
     private static TabIdRecord createTabId() {
         return new TabIdRecord();
@@ -1121,7 +1120,7 @@ public final class Workbook implements Model {
     private static ProtectRecord createProtect() {
         // by default even when we support it we won't
         // want it to be protected
-        return new ProtectRecord(false); 
+        return new ProtectRecord(false);
     }
 
     /**
@@ -1251,7 +1250,7 @@ public final class Workbook implements Model {
      * @param id    the number of the format record to create (meaning its position in
      *        a file as M$ Excel would create it.)
      */
-    private static FormatRecord createFormat(int id) {  
+    private static FormatRecord createFormat(int id) {
         // we'll need multiple editions for
         // the different formats
 
@@ -1674,7 +1673,7 @@ public final class Workbook implements Model {
     private static PaletteRecord createPalette() {
         return new PaletteRecord();
     }
-    
+
     /**
      * @return a new UseSelFS object with the use natural language flag set to 0 (false)
      */
@@ -1724,7 +1723,7 @@ public final class Workbook implements Model {
         retval.setNumStringsPerBucket(( short ) 0x8);
         return retval;
     }
-    
+
     /**
      * lazy initialization
      * Note - creating the link table causes creation of 1 EXTERNALBOOK and 1 EXTERNALSHEET record
@@ -1784,7 +1783,7 @@ public final class Workbook implements Model {
     public int getExternalSheetIndex(String workbookName, String sheetName) {
         return getOrCreateLinkTable().getExternalSheetIndex(workbookName, sheetName);
     }
-    
+
 
     /** gets the total number of names
      * @return number of names
@@ -1817,7 +1816,7 @@ public final class Workbook implements Model {
      */
     public NameRecord addName(NameRecord name)
     {
-        
+
         LinkTable linkTable = getOrCreateLinkTable();
         if(linkTable.nameAlreadyExists(name)) {
             throw new IllegalArgumentException(
@@ -1828,7 +1827,7 @@ public final class Workbook implements Model {
 
         return name;
     }
-    
+
     /**
      * Generates a NameRecord to represent a built-in region
      * @return a new NameRecord
@@ -1837,11 +1836,11 @@ public final class Workbook implements Model {
         if (sheetNumber < 0 || sheetNumber+1 > Short.MAX_VALUE) {
             throw new IllegalArgumentException("Sheet number ["+sheetNumber+"]is not valid ");
         }
-        
+
         NameRecord name = new NameRecord(builtInName, sheetNumber);
-        
+
         while(linkTable.nameAlreadyExists(name)) {
-            throw new RuntimeException("Builtin (" + builtInName 
+            throw new RuntimeException("Builtin (" + builtInName
                     + ") already exists for sheet (" + sheetNumber + ")");
         }
         addName(name);
@@ -1853,7 +1852,7 @@ public final class Workbook implements Model {
      * @param nameIndex name index
      */
     public void removeName(int nameIndex){
-        
+
         if (linkTable.getNumNames() > nameIndex) {
             int idx = findFirstRecordLocBySid(NameRecord.sid);
             records.remove(idx + nameIndex);
@@ -1912,7 +1911,7 @@ public final class Workbook implements Model {
         return maxformatid;
     }
 
-  
+
 
     /**
      * Returns the first occurance of a record matching a particular sid.
@@ -1920,7 +1919,7 @@ public final class Workbook implements Model {
     public Record findFirstRecordBySid(short sid) {
         for (Iterator iterator = records.iterator(); iterator.hasNext(); ) {
             Record record = ( Record ) iterator.next();
-            
+
             if (record.getSid() == sid) {
                 return record;
             }
@@ -1966,7 +1965,7 @@ public final class Workbook implements Model {
     {
         return hyperlinks;
     }
-    
+
     public List<Record> getRecords() {
         return records.getRecords();
     }
@@ -1980,7 +1979,7 @@ public final class Workbook implements Model {
     public boolean isUsing1904DateWindowing() {
         return uses1904datewindowing;
     }
-    
+
     /**
      * Returns the custom palette in use for this workbook; if a custom palette record
      * does not exist, then it is created.
@@ -2004,7 +2003,7 @@ public final class Workbook implements Model {
       }
       return palette;
     }
-    
+
     /**
      * Finds the primary drawing group, if one already exists
      */
@@ -2060,7 +2059,7 @@ public final class Workbook implements Model {
     }
 
     /**
-     * Creates a primary drawing group record.  If it already 
+     * Creates a primary drawing group record.  If it already
      *  exists then it's modified.
      */
     public void createDrawingGroup() {
@@ -2124,7 +2123,7 @@ public final class Workbook implements Model {
 
         }
     }
-    
+
     public WindowOneRecord getWindowOne() {
         return windowOne;
     }
@@ -2172,8 +2171,8 @@ public final class Workbook implements Model {
         if (writeProtect == null) {
            writeProtect = new WriteProtectRecord();
            int i = 0;
-           for (i = 0; 
-                i < records.size() && !(records.get(i) instanceof BOFRecord); 
+           for (i = 0;
+                i < records.size() && !(records.get(i) instanceof BOFRecord);
                 i++) {
            }
            records.add(i+1, writeProtect);
@@ -2185,8 +2184,8 @@ public final class Workbook implements Model {
         if (writeAccess == null) {
            writeAccess = createWriteAccess();
            int i = 0;
-           for (i = 0; 
-                i < records.size() && !(records.get(i) instanceof InterfaceEndRecord); 
+           for (i = 0;
+                i < records.size() && !(records.get(i) instanceof InterfaceEndRecord);
                 i++) {
            }
            records.add(i+1, writeAccess);
@@ -2198,15 +2197,15 @@ public final class Workbook implements Model {
         if (fileShare == null) {
            fileShare = new FileSharingRecord();
            int i = 0;
-           for (i = 0; 
-                i < records.size() && !(records.get(i) instanceof WriteAccessRecord); 
+           for (i = 0;
+                i < records.size() && !(records.get(i) instanceof WriteAccessRecord);
                 i++) {
            }
            records.add(i+1, fileShare);
         }
         return fileShare;
     }
-    
+
     /**
      * is the workbook protected with a password (not encrypted)?
      */
index 040b45c29769cac01b98545dcbc58dc965927429..8bf669d81a3df2cf21752e75021feb6461b64ee4 100644 (file)
@@ -22,7 +22,6 @@ 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.record.formula.Ptg;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.ss.formula.Formula;
 import org.apache.poi.ss.formula.FormulaType;
@@ -32,7 +31,7 @@ import org.apache.poi.util.LittleEndianOutput;
 
 /**
  * Conditional Formatting Rule Record (0x01B1).<br/>
- * 
+ *
  * @author Dmitriy Kumshayev
  */
 public final class CFRuleRecord extends StandardRecord {
@@ -101,10 +100,10 @@ public final class CFRuleRecord extends StandardRecord {
        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)
        {
@@ -124,9 +123,9 @@ public final class CFRuleRecord extends StandardRecord {
                field_17_formula1=Formula.create(Ptg.EMPTY_PTG_ARRAY);
                field_18_formula2=Formula.create(Ptg.EMPTY_PTG_ARRAY);
        }
-       
+
        private CFRuleRecord(byte conditionType, byte comparisonOperation, Ptg[] formula1, Ptg[] formula2) {
-               this(conditionType, comparisonOperation); 
+               this(conditionType, comparisonOperation);
                field_17_formula1 = Formula.create(formula1);
                field_18_formula2 = Formula.create(formula2);
        }
@@ -199,7 +198,7 @@ public final class CFRuleRecord extends StandardRecord {
                        return null;
                }
        }
-       
+
        public boolean containsAlignFormattingBlock()
        {
                return getOptionFlag(align);
@@ -208,7 +207,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                setOptionFlag(false,align);
        }
-       
+
        public boolean containsBorderFormattingBlock()
        {
                return getOptionFlag(bord);
@@ -229,7 +228,7 @@ public final class CFRuleRecord extends StandardRecord {
                        return null;
                }
        }
-       
+
        public boolean containsPatternFormattingBlock()
        {
                return getOptionFlag(patt);
@@ -250,7 +249,7 @@ public final class CFRuleRecord extends StandardRecord {
                        return null;
                }
        }
-       
+
        public boolean containsProtectionFormattingBlock()
        {
                return getOptionFlag(prot);
@@ -259,7 +258,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                setOptionFlag(false,prot);
        }
-       
+
        public void setComparisonOperation(byte operation)
        {
                field_2_comparison_operator = operation;
@@ -269,7 +268,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                return field_2_comparison_operator;
        }
-       
+
 
        /**
         * get the option flags
@@ -279,7 +278,7 @@ public final class CFRuleRecord extends StandardRecord {
        public int getOptions()
        {
                return field_5_options;
-       }       
+       }
 
        private boolean isModified(BitField field)
        {
@@ -290,7 +289,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                field_5_options = field.setBoolean(field_5_options, !modified);
        }
-       
+
        public boolean isLeftBorderModified()
        {
                return isModified(bordLeft);
@@ -300,7 +299,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                setModified(modified,bordLeft);
        }
-       
+
        public boolean isRightBorderModified()
        {
                return isModified(bordRight);
@@ -310,7 +309,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                setModified(modified,bordRight);
        }
-       
+
        public boolean isTopBorderModified()
        {
                return isModified(bordTop);
@@ -320,7 +319,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                setModified(modified,bordTop);
        }
-       
+
        public boolean isBottomBorderModified()
        {
                return isModified(bordBot);
@@ -330,7 +329,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                setModified(modified,bordBot);
        }
-       
+
        public boolean isTopLeftBottomRightBorderModified()
        {
                return isModified(bordTlBr);
@@ -340,7 +339,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                setModified(modified,bordTlBr);
        }
-       
+
        public boolean isBottomLeftTopRightBorderModified()
        {
                return isModified(bordBlTr);
@@ -350,7 +349,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                setModified(modified,bordBlTr);
        }
-       
+
        public boolean isPatternStyleModified()
        {
                return isModified(pattStyle);
@@ -360,7 +359,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                setModified(modified,pattStyle);
        }
-       
+
        public boolean isPatternColorModified()
        {
                return isModified(pattCol);
@@ -370,7 +369,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                setModified(modified,pattCol);
        }
-       
+
        public boolean isPatternBackgroundColorModified()
        {
                return isModified(pattBgCol);
@@ -380,7 +379,7 @@ public final class CFRuleRecord extends StandardRecord {
        {
                setModified(modified,pattBgCol);
        }
-       
+
        private boolean getOptionFlag(BitField field)
        {
                return field.isSet(field_5_options);
@@ -390,12 +389,12 @@ public final class CFRuleRecord extends StandardRecord {
        {
                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 
+        * this method can return null is we are unable to create Ptgs from
         *       existing excel file
         * callers should check for null!
         */
@@ -432,7 +431,7 @@ public final class CFRuleRecord extends StandardRecord {
        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
@@ -441,30 +440,30 @@ public final class CFRuleRecord extends StandardRecord {
         * @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);
        }
@@ -499,7 +498,7 @@ public final class CFRuleRecord extends StandardRecord {
                }
                return buffer.toString();
        }
-       
+
        public Object clone() {
                CFRuleRecord rec = new CFRuleRecord(field_1_condition_type, field_2_comparison_operator);
                rec.field_5_options = field_5_options;
@@ -524,7 +523,7 @@ public final class CFRuleRecord extends StandardRecord {
         * 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) {
index cbf28b5800eb5f095fb6d28591e61520a57d5303..d43df86c64a1d251a66107cb01b5e2556883147b 100644 (file)
@@ -18,7 +18,6 @@
 package org.apache.poi.hssf.record;
 
 import org.apache.poi.util.HexDump;
-import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianOutput;
 
 /**
index f933d4bcdb71c6253495e8f0c76c41624dbd6062..904ed17e4ac6d9e3577bda846d8ab7122c8f0dad 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hssf.record;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
index 2a74992687a1d20b23350b83472244386d1f5511..3539ba57d52e251fad3c2ca8c6dcbf15c9451a65 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hssf.record;
 
 import org.apache.poi.hssf.util.CellRangeAddress8Bit;
 import org.apache.poi.util.HexDump;
-import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianOutput;
 
 /**
@@ -59,7 +58,7 @@ public final class SelectionRecord extends StandardRecord {
         field_3_col_active_cell = in.readShort();
         field_4_active_cell_ref_index = in.readShort();
         int field_5_num_refs    = in.readUShort();
-        
+
         field_6_refs = new CellRangeAddress8Bit[field_5_num_refs];
         for (int i = 0; i < field_6_refs.length; i++) {
             field_6_refs[i] = new CellRangeAddress8Bit(in);
@@ -141,7 +140,7 @@ public final class SelectionRecord extends StandardRecord {
         return sb.toString();
     }
     protected int getDataSize() {
-        return 9 // 1 byte + 4 shorts 
+        return 9 // 1 byte + 4 shorts
             + CellRangeAddress8Bit.getEncodedSize(field_6_refs.length);
     }
     public void serialize(LittleEndianOutput out) {
index 78bcb4eee2e697540cd4eb5c4d1b55895ad518b1..689e4fcd55754540873cc8d8a5303a04f453a930 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hssf.record;
 
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 
 import org.apache.poi.hssf.record.formula.Area3DPtg;
@@ -26,7 +25,6 @@ import org.apache.poi.hssf.record.formula.Ptg;
 import org.apache.poi.hssf.record.formula.Ref3DPtg;
 import org.apache.poi.hssf.record.formula.RefPtg;
 import org.apache.poi.util.HexDump;
-import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianByteArrayInputStream;
 import org.apache.poi.util.LittleEndianInput;
 import org.apache.poi.util.LittleEndianOutput;
@@ -37,6 +35,7 @@ import org.apache.poi.util.LittleEndianOutputStream;
  */
 public abstract class SubRecord {
        protected SubRecord() {
+               // no fields to initialise
        }
 
        public static SubRecord createSubRecord(LittleEndianInput in) {
@@ -78,8 +77,8 @@ public abstract class SubRecord {
 
        public abstract void serialize(LittleEndianOutput out);
        public abstract Object clone();
-       
-       
+
+
        private static final class UnknownSubRecord extends SubRecord {
 
                private final int _sid;
@@ -118,7 +117,7 @@ public abstract class SubRecord {
        private static final class LbsDataSubRecord extends SubRecord {
 
                public static final int sid = 0x0013;
-               
+
                private int _unknownShort1;
                private int _unknownInt4;
                private Ptg _linkPtg;
@@ -137,8 +136,8 @@ public abstract class SubRecord {
                        if (linkSize > 0) {
                                int formulaSize = in.readUShort();
                                _unknownInt4 = in.readInt();
-                               
-                               
+
+
                                byte[] buf = new byte[formulaSize];
                                in.readFully(buf);
                                _linkPtg = readRefPtg(buf);
@@ -152,7 +151,7 @@ public abstract class SubRecord {
                                        default:
                                                throw new RecordFormatException("Unexpected leftover bytes");
                                }
-                               
+
                        } else {
                                _unknownInt4 = 0;
                                _linkPtg = null;
@@ -165,11 +164,11 @@ public abstract class SubRecord {
                        _comboStyle = in.readUShort();
                        _lineCount = in.readUShort();
                        _unknownShort13 = in.readUShort();
-                       
+
                }
                protected int getDataSize() {
                        int result = 2; // 2 initial shorts
-                       
+
                        // optional link formula
                        if (_linkPtg != null) {
                                result += 2; // encoded Ptg size
index 7d4f65acd987aae65b6660404dbd48df949b072c..fd34081e6f5c04232139123a1f06ed37b9fda38b 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.hssf.record.UnicodeString;
 import org.apache.poi.hssf.record.constant.ConstantValueParser;
 import org.apache.poi.hssf.record.constant.ErrorConstant;
 import org.apache.poi.util.LittleEndianInput;
@@ -25,20 +24,20 @@ import org.apache.poi.util.LittleEndianOutput;
 
 /**
  * ArrayPtg - handles arrays
- * 
+ *
  * The ArrayPtg is a little weird, the size of the Ptg when parsing initially only
  * includes the Ptg sid and the reserved bytes. The next Ptg in the expression then follows.
  * It is only after the "size" of all the Ptgs is met, that the ArrayPtg data is actually
- * held after this. So Ptg.createParsedExpression keeps track of the number of 
+ * held after this. So Ptg.createParsedExpression keeps track of the number of
  * ArrayPtg elements and need to parse the data upto the FORMULA record size.
- *  
+ *
  * @author Jason Height (jheight at chariot dot net dot au)
  */
 public final class ArrayPtg extends Ptg {
        public static final byte sid  = 0x20;
 
        private static final int RESERVED_FIELD_LEN = 7;
-       /** 
+       /**
         * The size of the plain tArray token written within the standard formula tokens
         * (not including the data which comes after all formula tokens)
         */
@@ -48,7 +47,7 @@ public final class ArrayPtg extends Ptg {
 
        // TODO - fix up field visibility and subclasses
        private final byte[] field_1_reserved;
-       
+
        // data from these fields comes after the Ptg data of all tokens in current formula
        private int  token_1_columns;
        private short token_2_rows;
@@ -78,7 +77,7 @@ public final class ArrayPtg extends Ptg {
                                vv[getValueIndex(c, r)] = rowData[c];
                        }
                }
-               
+
                token_3_arrayValues = vv;
                field_1_reserved = DEFAULT_RESERVED_DATA;
        }
@@ -98,13 +97,13 @@ public final class ArrayPtg extends Ptg {
                }
                return result;
        }
-       
+
        public boolean isBaseToken() {
                return false;
        }
-       
-       /** 
-        * Read in the actual token (array) values. This occurs 
+
+       /**
+        * Read in the actual token (array) values. This occurs
         * AFTER the last Ptg in the expression.
         * See page 304-305 of Excel97-2007BinaryFileFormat(xls)Specification.pdf
         */
@@ -116,10 +115,10 @@ public final class ArrayPtg extends Ptg {
                //Which is not explicitly documented.
                nColumns++;
                nRows++;
-               
+
                token_1_columns = nColumns;
                token_2_rows = nRows;
-               
+
                int totalCount = nRows * nColumns;
                token_3_arrayValues = ConstantValueParser.parse(in, totalCount);
        }
@@ -143,11 +142,11 @@ public final class ArrayPtg extends Ptg {
         */
        /* package */ int getValueIndex(int colIx, int rowIx) {
                if(colIx < 0 || colIx >= token_1_columns) {
-                       throw new IllegalArgumentException("Specified colIx (" + colIx 
+                       throw new IllegalArgumentException("Specified colIx (" + colIx
                                        + ") is outside the allowed range (0.." + (token_1_columns-1) + ")");
                }
                if(rowIx < 0 || rowIx >= token_2_rows) {
-                       throw new IllegalArgumentException("Specified rowIx (" + rowIx 
+                       throw new IllegalArgumentException("Specified rowIx (" + rowIx
                                        + ") is outside the allowed range (0.." + (token_2_rows-1) + ")");
                }
                return rowIx * token_1_columns + colIx;
@@ -176,7 +175,7 @@ public final class ArrayPtg extends Ptg {
 
        /** This size includes the size of the array Ptg plus the Array Ptg Token value size*/
        public int getSize() {
-               return PLAIN_TOKEN_SIZE 
+               return PLAIN_TOKEN_SIZE
                        // data written after the all tokens:
                        + 1 + 2 // column, row
                        + ConstantValueParser.getEncodedSize(token_3_arrayValues);
@@ -200,7 +199,7 @@ public final class ArrayPtg extends Ptg {
                b.append("}");
                return b.toString();
        }
-       
+
        private static String getConstantText(Object o) {
 
                if (o == null) {
@@ -220,7 +219,7 @@ public final class ArrayPtg extends Ptg {
                }
                throw new IllegalArgumentException("Unexpected constant class (" + o.getClass().getName() + ")");
        }
-       
+
        public byte getDefaultOperandClass() {
                return Ptg.CLASS_ARRAY;
        }
index 1bef14d90e97709ba16c0b041234e3e91bbeade4..70ed4da87ac1d816609bcd4ebebb3da2f97facf5 100644 (file)
@@ -22,11 +22,10 @@ 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.ss.SpreadsheetVersion;
 
 /**
  * ReferencePtgBase - handles references (such as A1, A2, IA4)
- * 
+ *
  * @author Andrew C. Oliver (acoliver@apache.org)
  * @author Jason Height (jheight at chariot dot net dot au)
  */
index 602710e98468095c59d4296ee3fd91940d48fd9c..9235d15b1ce6a42cec1354681c380d5d43ace425 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hssf.record.formula.atp;
 
 import org.apache.poi.hssf.record.formula.eval.BoolEval;
 import org.apache.poi.hssf.record.formula.eval.ErrorEval;
-import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.hssf.record.formula.eval.EvaluationException;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
index baab17991a48d2e36ec7362ba0523521ca250d28..4b2ba89071d66f4e66b5ce0df717d9a583d61c02 100644 (file)
@@ -22,15 +22,14 @@ import java.util.GregorianCalendar;
 import java.util.regex.Pattern;
 
 import org.apache.poi.hssf.record.formula.eval.ErrorEval;
-import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.hssf.record.formula.eval.EvaluationException;
 import org.apache.poi.hssf.record.formula.eval.NumberEval;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
 import org.apache.poi.hssf.record.formula.eval.StringEval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.hssf.record.formula.functions.FreeRefFunction;
-import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.ss.formula.EvaluationWorkbook;
+import org.apache.poi.ss.usermodel.DateUtil;
 /**
  * Implementation of Excel 'Analysis ToolPak' function YEARFRAC()<br/>
  *
index e8e13bb63e4e4d9a2ffa0fb335da1fb6f9d9af1e..513ac619f4f1c8a7851d5dadb8e1ed4e98ab4383 100644 (file)
 
 package org.apache.poi.hssf.usermodel;
 
-import org.apache.poi.ddf.EscherRecord;
-import org.apache.poi.ddf.EscherClientAnchorRecord;
-import org.apache.poi.ddf.EscherChildAnchorRecord;
 
-public class HSSFChildAnchor
-        extends HSSFAnchor
-{
+public final class HSSFChildAnchor extends HSSFAnchor {
     public HSSFChildAnchor()
     {
     }
@@ -50,5 +45,4 @@ public class HSSFChildAnchor
     {
         return dy1 > dy2;
     }
-
 }
index 569ad6ff0eb060f8de7af542a18cf9cc42c778ba..faee42b83f57b0c01bf2dcde3ccfb81a458c5123 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hssf.usermodel;
 
 import org.apache.poi.ss.usermodel.CreationHelper;
-import org.apache.poi.ss.usermodel.Sheet;
 
 public class HSSFCreationHelper implements CreationHelper {
        private HSSFWorkbook workbook;
-       private HSSFDataFormat dataFormat; 
-       
+       private HSSFDataFormat dataFormat;
+
        HSSFCreationHelper(HSSFWorkbook wb) {
                workbook = wb;
-               
+
                // Create the things we only ever need one of
                dataFormat = new HSSFDataFormat(workbook.getWorkbook());
        }
-       
-    /**
-     * Creates a new HSSFRichTextString for you.
-     */
+
        public HSSFRichTextString createRichTextString(String text) {
                return new HSSFRichTextString(text);
        }
-       
+
        public HSSFDataFormat createDataFormat() {
                return dataFormat;
        }
-       
+
        public HSSFHyperlink createHyperlink(int type) {
                return new HSSFHyperlink(type);
        }
 
-    /**
-     * Creates a HSSFFormulaEvaluator, the object that evaluates formula cells.
-     *
-     * @return a HSSFFormulaEvaluator instance
-     */
-    public HSSFFormulaEvaluator createFormulaEvaluator(){
-        return new HSSFFormulaEvaluator(workbook);
-    }
-
-    /**
-     * Creates a HSSFClientAnchor. Use this object to position drawing object in a sheet
-     *
-     * @return a HSSFClientAnchor instance
-     * @see org.apache.poi.ss.usermodel.Drawing
-     */
-    public HSSFClientAnchor createClientAnchor(){
-        return new HSSFClientAnchor();
-    }
+       /**
+        * Creates a HSSFFormulaEvaluator, the object that evaluates formula cells.
+        *
+        * @return a HSSFFormulaEvaluator instance
+        */
+       public HSSFFormulaEvaluator createFormulaEvaluator(){
+               return new HSSFFormulaEvaluator(workbook);
+       }
 
+       /**
+        * Creates a HSSFClientAnchor. Use this object to position drawing object in a sheet
+        *
+        * @return a HSSFClientAnchor instance
+        * @see org.apache.poi.ss.usermodel.Drawing
+        */
+       public HSSFClientAnchor createClientAnchor(){
+               return new HSSFClientAnchor();
+       }
 }
index 4eead2a5b699f4b640a90f0c799edae32ac98009..6396492d8e9d60ce703a716b26bc7237c5fb6acf 100644 (file)
 
 package org.apache.poi.hssf.usermodel;
 
-import org.apache.poi.ss.usermodel.DataFormatter;
-
 import java.text.DecimalFormat;
-import java.text.FieldPosition;
 import java.text.Format;
-import java.text.ParsePosition;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+
+import org.apache.poi.ss.usermodel.DataFormatter;
 
 /**
  * HSSFDataFormatter contains methods for formatting the value stored in an
@@ -73,7 +63,6 @@ import java.util.regex.Pattern;
  * cell's data format string.
  *
  * @author James May (james dot may at fmr dot com)
- *
  */
 public final class HSSFDataFormatter extends DataFormatter {
 
index 34a5a15841f42c4886f751cb4b73e2742acae17d..2548bf5114065070da4d3606070b587f2d49340e 100644 (file)
@@ -19,9 +19,6 @@ package org.apache.poi.hssf.usermodel;
 
 import org.apache.poi.ss.usermodel.RichTextString;
 
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.BitFieldFactory;
-
 /**
  * A textbox is a shape that may hold a rich text string.
  *
index cdd9902c40ff3f675f9a44e37eaccb21821611be..691df5a0422d488a3665ccac58f592c8736dd4b6 100644 (file)
@@ -21,78 +21,69 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.Iterator;
 
-import org.apache.poi.poifs.filesystem.DirectoryEntry;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
-import org.apache.poi.poifs.filesystem.DocumentEntry;
 import org.apache.poi.poifs.filesystem.DocumentNode;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
 /**
  * A lister of the entries in POIFS files.
- * 
+ *
  * Much simpler than {@link POIFSViewer}
  */
 public class POIFSLister {
-    /**
-     * 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 IOException {
-        if (args.length == 0)
-        {
-            System.err.println("Must specify at least one file to view");
-            System.exit(1);
-        }
+       /**
+        * 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 IOException {
+               if (args.length == 0) {
+                       System.err.println("Must specify at least one file to view");
+                       System.exit(1);
+               }
 
-        boolean withSizes = false;
-        for (int j = 0; j < args.length; j++) {
-               if(args[j].equalsIgnoreCase("-size") || 
-                               args[j].equalsIgnoreCase("-sizes")) {
-                       withSizes = true;
-               } else {
-                       viewFile(args[j], withSizes);
-               }
-        }
-    }
+               boolean withSizes = false;
+               for (int j = 0; j < args.length; j++) {
+                       if (args[j].equalsIgnoreCase("-size") || args[j].equalsIgnoreCase("-sizes")) {
+                               withSizes = true;
+                       } else {
+                               viewFile(args[j], withSizes);
+                       }
+               }
+       }
 
-    public static void viewFile(final String filename, boolean withSizes) throws IOException
-    {
-       POIFSFileSystem fs = new POIFSFileSystem(
-                       new FileInputStream(filename)
-       );
-       displayDirectory(fs.getRoot(), "", withSizes);
-    }
-    
-    public static void displayDirectory(DirectoryNode dir, String indent, boolean withSizes) {
-       System.out.println(indent + dir.getName() + " -");
-       String newIndent = indent + "  ";
-       
-       boolean hadChildren = false;
-       for(Iterator it = dir.getEntries(); it.hasNext(); ) {
-               hadChildren = true;
-               Object entry = it.next();
-               if(entry instanceof DirectoryNode) {
-                       displayDirectory((DirectoryNode)entry, newIndent, withSizes);
-               } else {
-                       DocumentNode doc = (DocumentNode)entry;
-                       String name = doc.getName();
-                       String size = "";
-                       if(name.charAt(0) < 10) {
-                               String altname = "(0x0" + (int)name.charAt(0) + ")" + name.substring(1);
-                               name = name.substring(1) + " <" + altname + ">";
-                       }
-                       if(withSizes) {
-                               size = " [" +
-                                       doc.getSize() + " / 0x" +
-                                       Integer.toHexString(doc.getSize()) +
-                                       "]";
-                       }
-                       System.out.println(newIndent + name + size);
-               }
-       }
-       if(!hadChildren) {
-               System.out.println(newIndent + "(no children)");
-       }
-    }
-}
\ No newline at end of file
+       public static void viewFile(final String filename, boolean withSizes) throws IOException {
+               POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename));
+               displayDirectory(fs.getRoot(), "", withSizes);
+       }
+
+       public static void displayDirectory(DirectoryNode dir, String indent, boolean withSizes) {
+               System.out.println(indent + dir.getName() + " -");
+               String newIndent = indent + "  ";
+
+               boolean hadChildren = false;
+               for (Iterator it = dir.getEntries(); it.hasNext();) {
+                       hadChildren = true;
+                       Object entry = it.next();
+                       if (entry instanceof DirectoryNode) {
+                               displayDirectory((DirectoryNode) entry, newIndent, withSizes);
+                       } else {
+                               DocumentNode doc = (DocumentNode) entry;
+                               String name = doc.getName();
+                               String size = "";
+                               if (name.charAt(0) < 10) {
+                                       String altname = "(0x0" + (int) name.charAt(0) + ")" + name.substring(1);
+                                       name = name.substring(1) + " <" + altname + ">";
+                               }
+                               if (withSizes) {
+                                       size = " [" + doc.getSize() + " / 0x" + Integer.toHexString(doc.getSize())
+                                                       + "]";
+                               }
+                               System.out.println(newIndent + name + size);
+                       }
+               }
+               if (!hadChildren) {
+                       System.out.println(newIndent + "(no children)");
+               }
+       }
+}
index ece87efd4a931e5f178097e3160807a3c50ff241..f263419910acb884d78bfabf06e2584105b98947 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.property;
 
-import java.util.*;
-
 import java.io.IOException;
-
-import org.apache.poi.poifs.storage.SmallDocumentBlock;
+import java.util.*;
 
 /**
  * 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
-{
-
-    // List of Property instances
-    private List _children;
+    /** List of Property instances */
+    private List<Property> _children;
 
-    // set of children's names
-    private Set  _children_names;
+    /** set of children's names */
+    private Set<String>  _children_names;
 
     /**
      * Default constructor
      *
      * @param name the name of the directory
      */
-
     public DirectoryProperty(String name)
     {
         super();
-        _children       = new ArrayList();
-        _children_names = new HashSet();
+        _children       = new ArrayList<Property>();
+        _children_names = new HashSet<String>();
         setName(name);
         setSize(0);
         setPropertyType(PropertyConstants.DIRECTORY_TYPE);
@@ -67,13 +57,12 @@ public class DirectoryProperty
      * @param array byte data
      * @param offset offset into byte data
      */
-
     protected DirectoryProperty(final int index, final byte [] array,
                                 final int offset)
     {
         super(index, array, offset);
-        _children       = new ArrayList();
-        _children_names = new HashSet();
+        _children       = new ArrayList<Property>();
+        _children_names = new HashSet<String>();
     }
 
     /**
@@ -84,8 +73,7 @@ public class DirectoryProperty
      *
      * @return true if the name change could be made, else false
      */
-
-    public boolean changeName(final Property property, final String newName)
+    public boolean changeName(Property property, String newName)
     {
         boolean result;
         String  oldName = property.getName();
@@ -116,8 +104,7 @@ public class DirectoryProperty
      *
      * @return true if the Property could be deleted, else false
      */
-
-    public boolean deleteChild(final Property property)
+    public boolean deleteChild(Property property)
     {
         boolean result = _children.remove(property);
 
@@ -128,9 +115,7 @@ public class DirectoryProperty
         return result;
     }
 
-    public static class PropertyComparator
-        implements Comparator
-    {
+    public static class PropertyComparator implements Comparator<Property> {
 
         /**
          * Object equality, implemented as object identity
@@ -139,7 +124,6 @@ public class DirectoryProperty
          *
          * @return true if identical, else false
          */
-
         public boolean equals(Object o)
         {
             return this == o;
@@ -160,12 +144,11 @@ public class DirectoryProperty
          *         zero           if o1 == o2,
          *         positive value if o1 >  o2.
          */
-
-        public int compare(Object o1, Object o2)
+        public int compare(Property o1, Property o2)
         {
             String VBA_PROJECT = "_VBA_PROJECT";
-            String name1  = (( Property ) o1).getName();
-            String name2  = (( Property ) o2).getName();
+            String name1  = o1.getName();
+            String name2  = o2.getName();
             int  result = name1.length() - name2.length();
 
             if (result == 0)
@@ -200,14 +183,11 @@ public class DirectoryProperty
             }
             return result;
         }
-    }   // end private class PropertyComparator
-
-    /* ********** START extension of Property ********** */
+    }
 
     /**
      * @return true if a directory type Property
      */
-
     public boolean isDirectory()
     {
         return true;
@@ -217,13 +197,11 @@ public class DirectoryProperty
      * Perform whatever activities need to be performed prior to
      * writing
      */
-
     protected void preWrite()
     {
         if (_children.size() > 0)
         {
-            Property[] children =
-                ( Property [] ) _children.toArray(new Property[ 0 ]);
+            Property[] children = _children.toArray(new Property[ 0 ]);
 
             Arrays.sort(children, new PropertyComparator());
             int midpoint = children.length / 2;
@@ -259,17 +237,13 @@ public class DirectoryProperty
         }
     }
 
-    /* **********  END  extension of Property ********** */
-    /* ********** START implementation of Parent ********** */
-
     /**
      * Get an iterator over the children of this Parent; all elements
      * are instances of Property.
      *
      * @return Iterator of children; may refer to an empty collection
      */
-
-    public Iterator getChildren()
+    public Iterator<Property> getChildren()
     {
         return _children.iterator();
     }
@@ -282,7 +256,6 @@ public class DirectoryProperty
      * @exception IOException if we already have a child with the same
      *                        name
      */
-
     public void addChild(final Property property)
         throws IOException
     {
@@ -295,7 +268,4 @@ public class DirectoryProperty
         _children_names.add(name);
         _children.add(property);
     }
-
-    /* **********  END  implementation of Parent ********** */
-}   // end public class DirectoryProperty
-
+}
index 00b306b7923577f06e35ffe445987f44e0d09098..09e447b053e95538fc0babe02b72ca33befe82bd 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.property;
 
 import java.io.IOException;
 import java.io.OutputStream;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
 
 import org.apache.poi.poifs.common.POIFSConstants;
 import org.apache.poi.poifs.filesystem.BATManaged;
 import org.apache.poi.poifs.storage.BlockWritable;
 import org.apache.poi.poifs.storage.PropertyBlock;
-import org.apache.poi.poifs.storage.RawDataBlock;
 import org.apache.poi.poifs.storage.RawDataBlockList;
 
 /**
@@ -38,22 +36,15 @@ import org.apache.poi.poifs.storage.RawDataBlockList;
  *
  * @author Marc Johnson (mjohnson at apache dot org)
  */
-
-public class PropertyTable
-    implements BATManaged, BlockWritable
-{
+public final class PropertyTable implements BATManaged, BlockWritable {
     private int             _start_block;
-    private List            _properties;
+    private List<Property> _properties;
     private BlockWritable[] _blocks;
 
-    /**
-     * Default constructor
-     */
-
     public PropertyTable()
     {
         _start_block = POIFSConstants.END_OF_CHAIN;
-        _properties  = new ArrayList();
+        _properties  = new ArrayList<Property>();
         addProperty(new RootProperty());
         _blocks = null;
     }
@@ -69,7 +60,6 @@ public class PropertyTable
      * @exception IOException if anything goes wrong (which should be
      *            a result of the input being NFG)
      */
-
     public PropertyTable(final int startBlock,
                          final RawDataBlockList blockList)
         throws IOException
@@ -87,8 +77,7 @@ public class PropertyTable
      *
      * @param property the new Property to manage
      */
-
-    public void addProperty(final Property property)
+    public void addProperty(Property property)
     {
         _properties.add(property);
     }
@@ -98,7 +87,6 @@ public class PropertyTable
      *
      * @param property the Property to be removed
      */
-
     public void removeProperty(final Property property)
     {
         _properties.remove(property);
@@ -109,7 +97,6 @@ public class PropertyTable
      *
      * @return the root property
      */
-
     public RootProperty getRoot()
     {
 
@@ -120,11 +107,9 @@ public class PropertyTable
     /**
      * Prepare to be written
      */
-
     public void preWrite()
     {
-        Property[] properties =
-            ( Property [] ) _properties.toArray(new Property[ 0 ]);
+        Property[] properties = _properties.toArray(new Property[ 0 ]);
 
         // give each property its index
         for (int k = 0; k < properties.length; k++)
@@ -147,7 +132,6 @@ public class PropertyTable
      *
      * @return start block index
      */
-
     public int getStartBlock()
     {
         return _start_block;
@@ -164,12 +148,12 @@ public class PropertyTable
             // property has no children
             return;
         }
-        Stack children = new Stack();
+        Stack<Property> children = new Stack<Property>();
 
         children.push(_properties.get(index));
         while (!children.empty())
         {
-            Property property = ( Property ) children.pop();
+            Property property = children.pop();
 
             root.addChild(property);
             if (property.isDirectory())
@@ -189,14 +173,11 @@ public class PropertyTable
         }
     }
 
-    /* ********** START implementation of BATManaged ********** */
-
     /**
      * Return the number of BigBlock's this instance uses
      *
      * @return count of BigBlock instances
      */
-
     public int countBlocks()
     {
         return (_blocks == null) ? 0
@@ -209,15 +190,11 @@ public class PropertyTable
      * @param index index into the array of BigBlock instances making
      *              up the the filesystem
      */
-
     public void setStartBlock(final int index)
     {
         _start_block = index;
     }
 
-    /* **********  END  implementation of BATManaged ********** */
-    /* ********** START implementation of BlockWritable ********** */
-
     /**
      * Write the storage to an OutputStream
      *
@@ -227,7 +204,6 @@ public class PropertyTable
      * @exception IOException on problems writing to the specified
      *            stream
      */
-
     public void writeBlocks(final OutputStream stream)
         throws IOException
     {
@@ -239,7 +215,4 @@ public class PropertyTable
             }
         }
     }
-
-    /* **********  END  implementation of BlockWritable ********** */
-}   // end public class PropertyTable
-
+}
index afa82ed1a83f3216fcd721ccfc67ae9172fc3a85..cb4b66e61489f7c73d8fc70859ee44bcd1704039 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.property;
 
-import java.util.*;
-
-import java.io.IOException;
-
 import org.apache.poi.poifs.common.POIFSConstants;
 import org.apache.poi.poifs.storage.SmallDocumentBlock;
 
@@ -31,14 +25,7 @@ import org.apache.poi.poifs.storage.SmallDocumentBlock;
  *
  * @author Marc Johnson (mjohnson at apache dot org)
  */
-
-public class RootProperty
-    extends DirectoryProperty
-{
-
-    /**
-     * Default constructor
-     */
+public final class RootProperty extends DirectoryProperty {
 
     RootProperty()
     {
@@ -57,7 +44,6 @@ public class RootProperty
      * @param array byte data
      * @param offset offset into byte data
      */
-
     protected RootProperty(final int index, final byte [] array,
                            final int offset)
     {
@@ -69,10 +55,8 @@ public class RootProperty
      *
      * @param size size in terms of small blocks
      */
-
     public void setSize(int size)
     {
         super.setSize(SmallDocumentBlock.calcSize(size));
     }
-}   // end public class RootProperty
-
+}
index 5aa4678b60a252dd900a14f72b06f85360f381ac..949a5254a77539b4a1a55d06a15d8265d5e590d2 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.storage;
 
@@ -26,7 +24,6 @@ import java.util.Arrays;
 
 import org.apache.poi.poifs.common.POIFSConstants;
 import org.apache.poi.util.IntegerField;
-import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianConsts;
 
 /**
@@ -35,10 +32,7 @@ import org.apache.poi.util.LittleEndianConsts;
  *
  * @author Marc Johnson (mjohnson at apache dot org)
  */
-
-public class BATBlock
-    extends BigBlock
-{
+public final class BATBlock extends BigBlock {
     private static final int  _entries_per_block      =
         POIFSConstants.BIG_BLOCK_SIZE / LittleEndianConsts.INT_SIZE;
     private static final int  _entries_per_xbat_block = _entries_per_block
index 60ce199ee59a006bd4267a5246ee5048f58877cb..0fb3b4899575f70cce9bebcde732cddf57b98b83 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.storage;
 
@@ -43,9 +41,7 @@ import org.apache.poi.util.LittleEndianConsts;
  *
  * @author Marc Johnson (mjohnson at apache dot org)
  */
-
-public class BlockAllocationTableReader
-{
+public final class BlockAllocationTableReader {
     private IntList _entries;
 
     /**
@@ -154,12 +150,6 @@ public class BlockAllocationTableReader
         setEntries(blocks, raw_block_list);
     }
 
-    /**
-     * Constructor BlockAllocationTableReader
-     *
-     *
-     */
-
     BlockAllocationTableReader()
     {
         _entries = new IntList();
@@ -177,17 +167,16 @@ public class BlockAllocationTableReader
      *
      * @exception IOException if there is a problem acquiring the blocks
      */
-
     ListManagedBlock [] fetchBlocks(final int startBlock,
                                     final int headerPropertiesStartBlock,
                                     final BlockList blockList)
         throws IOException
     {
-        List blocks       = new ArrayList();
+        List<ListManagedBlock> blocks = new ArrayList<ListManagedBlock>();
         int  currentBlock = startBlock;
         boolean firstPass = true;
         ListManagedBlock dataBlock = null;
-        
+
         // Process the chain from the start to the end
         // Normally we have header, data, end
         // Sometimes we have data, header, end
@@ -216,9 +205,8 @@ public class BlockAllocationTableReader
                        }
                }
         }
-        
-        return ( ListManagedBlock [] ) blocks
-            .toArray(new ListManagedBlock[ blocks.size() ]);
+
+        return blocks.toArray(new ListManagedBlock[blocks.size()]);
     }
 
     // methods for debugging reader
@@ -230,7 +218,6 @@ public class BlockAllocationTableReader
      *
      * @return true if the specific block is used, else false
      */
-
     boolean isUsed(final int index)
     {
         boolean rval = false;
@@ -238,9 +225,8 @@ public class BlockAllocationTableReader
         try
         {
             rval = _entries.get(index) != -1;
-        }
-        catch (IndexOutOfBoundsException ignored)
-        {
+        } catch (IndexOutOfBoundsException e) {
+            // ignored
         }
         return rval;
     }
@@ -256,7 +242,6 @@ public class BlockAllocationTableReader
      *
      * @exception IOException if the current block is unused
      */
-
     int getNextBlockIndex(final int index)
         throws IOException
     {
@@ -264,10 +249,7 @@ public class BlockAllocationTableReader
         {
             return _entries.get(index);
         }
-        else
-        {
-            throw new IOException("index " + index + " is unused");
-        }
+        throw new IOException("index " + index + " is unused");
     }
 
     /**
@@ -276,10 +258,7 @@ public class BlockAllocationTableReader
      * @param blocks the array of blocks containing the indices
      * @param raw_blocks the list of blocks being managed. Unused
      *                   blocks will be eliminated from the list
-     *
-     * @exception IOException
      */
-
     private void setEntries(final ListManagedBlock [] blocks,
                             final BlockList raw_blocks)
         throws IOException
@@ -308,5 +287,4 @@ public class BlockAllocationTableReader
         }
         raw_blocks.setBAT(this);
     }
-}   // end class BlockAllocationTableReader
-
+}
index b2f6af2c638a05da71b172fbb0e2d0685920b145..e2adcb766fd9ce46e369eb8cc0116740acf6acad 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.storage;
 
 import java.io.IOException;
 import java.io.OutputStream;
 
-import java.util.*;
-
 import org.apache.poi.poifs.common.POIFSConstants;
 import org.apache.poi.poifs.filesystem.BATManaged;
 import org.apache.poi.util.IntList;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.LittleEndianConsts;
 
 /**
  * This class manages and creates the Block Allocation Table, which is
@@ -45,10 +39,7 @@ import org.apache.poi.util.LittleEndianConsts;
  *
  * @author Marc Johnson (mjohnson at apache dot org)
  */
-
-public class BlockAllocationTableWriter
-    implements BlockWritable, BATManaged
-{
+public final class BlockAllocationTableWriter implements BlockWritable, BATManaged {
     private IntList    _entries;
     private BATBlock[] _blocks;
     private int        _start_block;
@@ -56,7 +47,6 @@ public class BlockAllocationTableWriter
     /**
      * create a BlockAllocationTableWriter
      */
-
     public BlockAllocationTableWriter()
     {
         _start_block = POIFSConstants.END_OF_CHAIN;
@@ -69,7 +59,6 @@ public class BlockAllocationTableWriter
      *
      * @return start block index of BAT blocks
      */
-
     public int createBlocks()
     {
         int xbat_blocks = 0;
@@ -92,11 +81,8 @@ public class BlockAllocationTableWriter
                 // stable ... we're OK
                 break;
             }
-            else
-            {
-                bat_blocks  = calculated_bat_blocks;
-                xbat_blocks = calculated_xbat_blocks;
-            }
+            bat_blocks  = calculated_bat_blocks;
+            xbat_blocks = calculated_xbat_blocks;
         }
         int startBlock = allocateSpace(bat_blocks);
 
@@ -112,7 +98,6 @@ public class BlockAllocationTableWriter
      *
      * @return the starting index of the blocks
      */
-
     public int allocateSpace(final int blockCount)
     {
         int startBlock = _entries.size();
@@ -136,7 +121,6 @@ public class BlockAllocationTableWriter
      *
      * @return the starting block index
      */
-
     public int getStartBlock()
     {
         return _start_block;
@@ -145,14 +129,11 @@ public class BlockAllocationTableWriter
     /**
      * create the BATBlocks
      */
-
     void simpleCreateBlocks()
     {
         _blocks = BATBlock.createBATBlocks(_entries.toArray());
     }
 
-    /* ********** START implementation of BlockWritable ********** */
-
     /**
      * Write the storage to an OutputStream
      *
@@ -162,7 +143,6 @@ public class BlockAllocationTableWriter
      * @exception IOException on problems writing to the specified
      *            stream
      */
-
     public void writeBlocks(final OutputStream stream)
         throws IOException
     {
@@ -172,15 +152,11 @@ public class BlockAllocationTableWriter
         }
     }
 
-    /* **********  END  implementation of BlockWritable ********** */
-    /* ********** START implementation of BATManaged ********** */
-
     /**
      * Return the number of BigBlock's this instance uses
      *
      * @return count of BigBlock instances
      */
-
     public int countBlocks()
     {
         return _blocks.length;
@@ -188,15 +164,9 @@ public class BlockAllocationTableWriter
 
     /**
      * Set the start block for this instance
-     *
-     * @param start_block
      */
-
     public void setStartBlock(int start_block)
     {
         _start_block = start_block;
     }
-
-    /* **********  END  implementation of BATManaged ********** */
-}   // end class BlockAllocationTableWriter
-
+}
index a5472d35305b605ffc0fa831e2d466b8a040b946..df7de493a5ea9104cb6a4304dd8fffd046fd0fd7 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.storage;
 
-import java.io.*;
-
-import java.util.*;
+import java.io.IOException;
 
 /**
  * A simple implementation of BlockList
  *
  * @author Marc Johnson (mjohnson at apache dot org
  */
-
-class BlockListImpl
-    implements BlockList
-{
+abstract class BlockListImpl implements BlockList {
     private ListManagedBlock[]         _blocks;
     private BlockAllocationTableReader _bat;
 
-    /**
-     * Constructor BlockListImpl
-     */
-
     protected BlockListImpl()
     {
         _blocks = new ListManagedBlock[ 0 ];
@@ -50,21 +39,17 @@ class BlockListImpl
      *
      * @param blocks blocks to be managed
      */
-
     protected void setBlocks(final ListManagedBlock [] blocks)
     {
         _blocks = blocks;
     }
 
-    /* ********** START implementation of BlockList ********** */
-
     /**
      * remove the specified block from the list
      *
      * @param index the index of the specified block; if the index is
      *              out of range, that's ok
      */
-
     public void zap(final int index)
     {
         if ((index >= 0) && (index < _blocks.length))
@@ -72,13 +57,13 @@ class BlockListImpl
             _blocks[ index ] = null;
         }
     }
-    
+
     /**
      * Unit testing method. Gets, without sanity checks or
      *  removing.
      */
-    protected ListManagedBlock get(final int index) throws IOException {
-       return _blocks[index];
+    protected ListManagedBlock get(final int index) {
+        return _blocks[index];
     }
 
     /**
@@ -91,7 +76,6 @@ class BlockListImpl
      * @exception IOException if the index is out of range or has
      *            already been removed
      */
-
     public ListManagedBlock remove(final int index)
         throws IOException
     {
@@ -112,7 +96,7 @@ class BlockListImpl
         catch (ArrayIndexOutOfBoundsException ignored)
         {
             throw new IOException("Cannot remove block[ " + index
-                                  + " ]; out of range[ 0 - " + 
+                                  + " ]; out of range[ 0 - " +
                                   (_blocks.length-1) + " ]");
         }
         return result;
@@ -128,7 +112,6 @@ class BlockListImpl
      *
      * @exception IOException if blocks are missing
      */
-
     public ListManagedBlock [] fetchBlocks(final int startBlock, final int headerPropertiesStartBlock)
         throws IOException
     {
@@ -144,10 +127,7 @@ class BlockListImpl
      * set the associated BlockAllocationTable
      *
      * @param bat the associated BlockAllocationTable
-     *
-     * @exception IOException
      */
-
     public void setBAT(final BlockAllocationTableReader bat)
         throws IOException
     {
@@ -158,7 +138,4 @@ class BlockListImpl
         }
         _bat = bat;
     }
-
-    /* **********  END  implementation of BlockList ********** */
-}   // end package-scope class BlockListImpl
-
+}
index 075a224fa59c813f2e4ba398ab88b8c57acd016a..eebb504b4519d18c40a35e9b4edfcb06c5b45d33 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.storage;
 
 import org.apache.poi.poifs.common.POIFSConstants;
-import org.apache.poi.util.IntegerField;
-import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianConsts;
-import org.apache.poi.util.LongField;
-import org.apache.poi.util.ShortField;
 
 /**
  * Constants used in reading/writing the Header block
  *
  * @author Marc Johnson (mjohnson at apache dot org)
  */
-
 public interface HeaderBlockConstants
 {
     public static final long _signature               = 0xE11AB1A1E011CFD0L;
index 5dfaac5b76f8938e73536fe9ee87bfabdcdfb018..c0400a552aafeec57f8f97c5921a18b5695a29b8 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.storage;
 
-import java.io.*;
-
-import java.util.*;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
 
 import org.apache.poi.poifs.common.POIFSConstants;
 import org.apache.poi.poifs.property.Property;
-import org.apache.poi.util.IntegerField;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.LittleEndianConsts;
 
 /**
  * A block of Property instances
  *
  * @author Marc Johnson (mjohnson at apache dot org)
  */
-
-public class PropertyBlock
-    extends BigBlock
-{
+public final class PropertyBlock extends BigBlock {
     private static final int _properties_per_block =
         POIFSConstants.BIG_BLOCK_SIZE / POIFSConstants.PROPERTY_SIZE;
     private Property[]       _properties;
index 4da79e71f1e23071990504214e090c114c7e494b..c77b8fc1ade050cc78f2ee39ea1a3a4a5d51d746 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.storage;
 
-import org.apache.poi.poifs.property.RootProperty;
-
-import java.util.*;
+import java.io.IOException;
 
-import java.io.*;
+import org.apache.poi.poifs.property.RootProperty;
 
 /**
  * This class implements reading the small document block list from an
@@ -31,9 +27,7 @@ import java.io.*;
  *
  * @author Marc Johnson (mjohnson at apache dot org)
  */
-
-public class SmallBlockTableReader
-{
+public final class SmallBlockTableReader {
 
     /**
      * fetch the small document block list from an existing file
@@ -48,7 +42,6 @@ public class SmallBlockTableReader
      *
      * @exception IOException
      */
-
     public static BlockList getSmallDocumentBlocks(
             final RawDataBlockList blockList, final RootProperty root,
             final int sbatStart)
index 30498cf439b45a6f2662152db275d4e00d7d1db3..3fee8dd57297b3c3c8ef8506897eee61fe0dfe83 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.util;
 
-import java.util.*;
-
 /**
  * A List of int's; as full an implementation of the java.util.List
  * interface as possible, with an eye toward minimal creation of
@@ -47,7 +43,6 @@ import java.util.*;
  *
  * @author Marc Johnson
  */
-
 public class IntList
 {
     private int[]            _array;
@@ -62,14 +57,14 @@ public class IntList
     public IntList()
     {
         this(_default_size);
-    }    
+    }
 
     public IntList(final int initialCapacity)
     {
         this(initialCapacity,0);
     }
-    
-    
+
+
     /**
      * create a copy of an existing IntList
      *
@@ -94,17 +89,17 @@ public class IntList
         _array = new int[ initialCapacity ];
         if (fillval != 0) {
             fillval = fillvalue;
-            fillArray(fillval, _array, 0);        
+            fillArray(fillval, _array, 0);
         }
         _limit = 0;
     }
 
     private void fillArray(int val, int[] array, int index) {
       for (int k = index; k < array.length; k++) {
-        array[k] = val;   
+        array[k] = val;
       }
     }
-    
+
     /**
      * add the specfied value at the specified index
      *
@@ -653,11 +648,11 @@ public class IntList
         int   size      = (new_size == _array.length) ? new_size + 1
                                                       : new_size;
         int[] new_array = new int[ size ];
-        
+
         if (fillval != 0) {
-          fillArray(fillval, new_array, _array.length);                
+          fillArray(fillval, new_array, _array.length);
         }
-        
+
         System.arraycopy(_array, 0, new_array, 0, _limit);
         _array = new_array;
     }
index d58c9789ec092b4ba149a6951c2d594e2c430071..a2cdbf7866201b9a0d00ba99267ce5386e5365be 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.util;
 
-import java.util.*;
-
 /**
  * A logger class that strives to make it as easy as possible for
  * developers to write log calls, while simultaneously making those
@@ -31,14 +27,13 @@ import java.util.*;
  * @author Glen Stampoultzis (glens at apache.org)
  * @author Nicola Ken Barozzi (nicolaken at apache.org)
  */
-
 public class NullLogger extends POILogger
 {
     public void initialize(final String cat)
     {
-       //do nothing    
+       //do nothing
     }
-    
+
     /**
      * Log a message
      *
@@ -462,5 +457,5 @@ public class NullLogger extends POILogger
        //do nothing
     }
 
-} 
+}
 
index c06a9c714b9e7555e6d9ce435ddd136f3ee124b6..3a6cfb8d967824f3c28b17d95b368859b66c3c99 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.util;
 
-import java.util.*;
-
 /**
  * A List of short's; as full an implementation of the java.util.List
  * interface as possible, with an eye toward minimal creation of
index 9e716e4cc847950992525712025af6d2e2af8d1a..ee4bb53c7f37a49a64d88062860bb8e360a6a68b 100644 (file)
@@ -22,7 +22,6 @@ import java.util.*;
 import org.apache.poi.poifs.common.POIFSConstants;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.PackageHelper;
-import org.apache.xmlbeans.XmlException;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.*;
index 0844f45189a74ff915f909c8da33702154d44b57..0be0142d45f6e728f0307e80c2e0a149835a18dc 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Map.Entry;
 import org.apache.poi.ss.usermodel.FontFamily;
 import org.apache.poi.ss.usermodel.FontScheme;
 import org.apache.poi.ss.usermodel.BuiltinFormats;
-import org.apache.poi.ss.usermodel.Font;
 import org.apache.poi.xssf.usermodel.XSSFCellStyle;
 import org.apache.poi.xssf.usermodel.XSSFFont;
 import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
@@ -80,17 +79,17 @@ public class StylesTable extends POIXMLDocumentPart {
         * Create a new, empty StylesTable
         */
        public StylesTable() {
-        super();
+               super();
                doc = StyleSheetDocument.Factory.newInstance();
                doc.addNewStyleSheet();
                // Initialization required in order to make the document readable by MSExcel
                initialize();
        }
 
-    public StylesTable(PackagePart part, PackageRelationship rel) throws IOException {
-        super(part, rel);
-        readFrom(part.getInputStream());
-    }
+       public StylesTable(PackagePart part, PackageRelationship rel) throws IOException {
+               super(part, rel);
+               readFrom(part.getInputStream());
+       }
 
        /**
         * Read this shared styles table from an XML file.
@@ -107,13 +106,13 @@ public class StylesTable extends POIXMLDocumentPart {
                                numberFormats.put((int)nfmt.getNumFmtId(), nfmt.getFormatCode());
                        }
                        if(doc.getStyleSheet().getFonts() != null){
-                int idx = 0;
-                for (CTFont font : doc.getStyleSheet().getFonts().getFontArray()) {
-                    XSSFFont f = new XSSFFont(font, idx);
-                    fonts.add(f);
-                    idx++;
-                }
-            }
+                               int idx = 0;
+                               for (CTFont font : doc.getStyleSheet().getFonts().getFontArray()) {
+                                       XSSFFont f = new XSSFFont(font, idx);
+                                       fonts.add(f);
+                                       idx++;
+                               }
+                       }
                        if(doc.getStyleSheet().getFills() != null)
                        for (CTFill fill : doc.getStyleSheet().getFills().getFillArray()) {
                                fills.add(new XSSFCellFill(fill));
@@ -149,7 +148,7 @@ public class StylesTable extends POIXMLDocumentPart {
                return numberFormats.get(idx);
        }
 
-    public int putNumberFormat(String fmt) {
+       public int putNumberFormat(String fmt) {
                if (numberFormats.containsValue(fmt)) {
                        // Find the key, and return that
                        for(Integer key : numberFormats.keySet() ) {
@@ -174,12 +173,12 @@ public class StylesTable extends POIXMLDocumentPart {
        }
 
        public int putFont(XSSFFont font) {
-        int idx = fonts.indexOf(font);
-        if (idx != -1) {
-            return idx;
-        }
-        fonts.add(font);
-        return fonts.size() - 1;
+               int idx = fonts.indexOf(font);
+               if (idx != -1) {
+                       return idx;
+               }
+               fonts.add(font);
+               return fonts.size() - 1;
        }
 
        public XSSFCellStyle getStyleAt(int idx) {
@@ -205,42 +204,42 @@ public class StylesTable extends POIXMLDocumentPart {
                return borders.get(idx);
        }
 
-    public int putBorder(XSSFCellBorder border) {
-        int idx = borders.indexOf(border);
-        if (idx != -1) {
-            return idx;
-        }
-        borders.add(border);
-        return borders.size() - 1;
+       public int putBorder(XSSFCellBorder border) {
+               int idx = borders.indexOf(border);
+               if (idx != -1) {
+                       return idx;
+               }
+               borders.add(border);
+               return borders.size() - 1;
        }
 
-    public XSSFCellFill getFillAt(int idx) {
-        return fills.get(idx);
-    }
+       public XSSFCellFill getFillAt(int idx) {
+               return fills.get(idx);
+       }
 
-    public List<XSSFCellBorder> getBorders(){
-        return borders;
-    }
+       public List<XSSFCellBorder> getBorders(){
+               return borders;
+       }
 
-    public List<XSSFCellFill> getFills(){
-        return fills;
-    }
+       public List<XSSFCellFill> getFills(){
+               return fills;
+       }
 
-    public List<XSSFFont> getFonts(){
-        return fonts;
-    }
+       public List<XSSFFont> getFonts(){
+               return fonts;
+       }
 
-    public Map<Integer, String> getNumberFormats(){
-        return numberFormats;
-    }
+       public Map<Integer, String> getNumberFormats(){
+               return numberFormats;
+       }
 
-    public int putFill(XSSFCellFill fill) {
-        int idx = fills.indexOf(fill);
-        if (idx != -1) {
-            return idx;
-        }
-        fills.add(fill);
-        return fills.size() - 1;
+       public int putFill(XSSFCellFill fill) {
+               int idx = fills.indexOf(fill);
+               if (idx != -1) {
+                       return idx;
+               }
+               fills.add(fill);
+               return fills.size() - 1;
        }
 
        public CTXf getCellXfAt(int idx) {
@@ -315,31 +314,31 @@ public class StylesTable extends POIXMLDocumentPart {
                }
                doc.getStyleSheet().setNumFmts(formats);
 
-        int idx;
+               int idx;
                // Fonts
                CTFonts ctFonts = CTFonts.Factory.newInstance();
                ctFonts.setCount(fonts.size());
-        CTFont[] ctfnt = new CTFont[fonts.size()];
-        idx = 0;
-        for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
-        ctFonts.setFontArray(ctfnt);
+               CTFont[] ctfnt = new CTFont[fonts.size()];
+               idx = 0;
+               for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
+               ctFonts.setFontArray(ctfnt);
                doc.getStyleSheet().setFonts(ctFonts);
 
                // Fills
                CTFills ctFills = CTFills.Factory.newInstance();
                ctFills.setCount(fills.size());
-        CTFill[] ctf = new CTFill[fills.size()];
-        idx = 0;
-        for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill();
-        ctFills.setFillArray(ctf);
+               CTFill[] ctf = new CTFill[fills.size()];
+               idx = 0;
+               for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill();
+               ctFills.setFillArray(ctf);
                doc.getStyleSheet().setFills(ctFills);
 
                // Borders
                CTBorders ctBorders = CTBorders.Factory.newInstance();
                ctBorders.setCount(borders.size());
-        CTBorder[] ctb = new CTBorder[borders.size()];
-        idx = 0;
-        for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder();
+               CTBorder[] ctb = new CTBorder[borders.size()];
+               idx = 0;
+               for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder();
                ctBorders.setBorderArray(ctb);
                doc.getStyleSheet().setBorders(ctBorders);
 
@@ -376,13 +375,13 @@ public class StylesTable extends POIXMLDocumentPart {
                doc.save(out, options);
        }
 
-    @Override
-    protected void commit() throws IOException {
-        PackagePart part = getPackagePart();
-        OutputStream out = part.getOutputStream();
-        writeTo(out);
-        out.close();
-    }
+       @Override
+       protected void commit() throws IOException {
+               PackagePart part = getPackagePart();
+               OutputStream out = part.getOutputStream();
+               writeTo(out);
+               out.close();
+       }
 
        private void initialize() {
                //CTFont ctFont = createDefaultFont();
@@ -452,36 +451,35 @@ public class StylesTable extends POIXMLDocumentPart {
                return this.dxfs.size();
        }
 
-    public XSSFCellStyle createCellStyle() {
-        CTXf xf = CTXf.Factory.newInstance();
-        xf.setNumFmtId(0);
-        xf.setFontId(0);
-        xf.setFillId(0);
-        xf.setBorderId(0);
-        xf.setXfId(0);
-        int xfSize = styleXfs.size();
-        int indexXf = putCellXf(xf);
-        return new XSSFCellStyle(indexXf - 1, xfSize - 1, this);
-    }
-
-    /**
-     * Finds a font that matches the one with the supplied attributes
-     */
-    public XSSFFont findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) {
-        for (XSSFFont font : fonts) {
-            if (       (font.getBoldweight() == boldWeight)
-                    && font.getColor() == color
-                    && font.getFontHeight() == fontHeight
-                    && font.getFontName().equals(name)
-                    && font.getItalic() == italic
-                    && font.getStrikeout() == strikeout
-                    && font.getTypeOffset() == typeOffset
-                    && font.getUnderline() == underline)
-            {
-                return font;
-            }
-        }
-        return null;
-    }
+       public XSSFCellStyle createCellStyle() {
+               CTXf xf = CTXf.Factory.newInstance();
+               xf.setNumFmtId(0);
+               xf.setFontId(0);
+               xf.setFillId(0);
+               xf.setBorderId(0);
+               xf.setXfId(0);
+               int xfSize = styleXfs.size();
+               int indexXf = putCellXf(xf);
+               return new XSSFCellStyle(indexXf - 1, xfSize - 1, this);
+       }
 
+       /**
+        * Finds a font that matches the one with the supplied attributes
+        */
+       public XSSFFont findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) {
+               for (XSSFFont font : fonts) {
+                       if (    (font.getBoldweight() == boldWeight)
+                                       && font.getColor() == color
+                                       && font.getFontHeight() == fontHeight
+                                       && font.getFontName().equals(name)
+                                       && font.getItalic() == italic
+                                       && font.getStrikeout() == strikeout
+                                       && font.getTypeOffset() == typeOffset
+                                       && font.getUnderline() == underline)
+                       {
+                               return font;
+                       }
+               }
+               return null;
+       }
 }
index 88b9d9a87a6c9e7c1bf923dd53aa0d210a18b146..177cad89a93fa560a045b2b83df09b8c5e0b093a 100644 (file)
 package org.apache.poi.xssf.usermodel;
 
 import org.apache.poi.ss.usermodel.CreationHelper;
-import org.apache.poi.ss.usermodel.DataFormat;
-import org.apache.poi.ss.usermodel.Hyperlink;
-import org.apache.poi.ss.usermodel.RichTextString;
 
 public class XSSFCreationHelper implements CreationHelper {
        private XSSFWorkbook workbook;
+
        XSSFCreationHelper(XSSFWorkbook wb) {
                workbook = wb;
        }
-       
-    /**
-     * Creates a new XSSFRichTextString for you.
-     */
+
+       /**
+        * Creates a new XSSFRichTextString for you.
+        */
        public XSSFRichTextString createRichTextString(String text) {
-        XSSFRichTextString rt = new XSSFRichTextString(text);
-        rt.setStylesTableReference(workbook.getStylesSource());
-        return rt;
+               XSSFRichTextString rt = new XSSFRichTextString(text);
+               rt.setStylesTableReference(workbook.getStylesSource());
+               return rt;
        }
-       
+
        public XSSFDataFormat createDataFormat() {
                return workbook.createDataFormat();
        }
-       
+
        public XSSFHyperlink createHyperlink(int type) {
                return new XSSFHyperlink(type);
        }
 
-    /**
-     * Creates a XSSFFormulaEvaluator, the object that evaluates formula cells.
-     *
-     * @return a XSSFFormulaEvaluator instance
-     */
-    public XSSFFormulaEvaluator createFormulaEvaluator(){
-        return new XSSFFormulaEvaluator(workbook);
-    }
+       /**
+        * Creates a XSSFFormulaEvaluator, the object that evaluates formula cells.
+        *
+        * @return a XSSFFormulaEvaluator instance
+        */
+       public XSSFFormulaEvaluator createFormulaEvaluator() {
+               return new XSSFFormulaEvaluator(workbook);
+       }
 
-    /**
-     * Creates a XSSFClientAnchor. Use this object to position drawing object in a sheet
-     *
-     * @return a XSSFClientAnchor instance
-     * @see org.apache.poi.ss.usermodel.Drawing
-     */
-    public XSSFClientAnchor createClientAnchor(){
-        return new XSSFClientAnchor();
-    }
+       /**
+        * Creates a XSSFClientAnchor. Use this object to position drawing object in
+        * a sheet
+        *
+        * @return a XSSFClientAnchor instance
+        * @see org.apache.poi.ss.usermodel.Drawing
+        */
+       public XSSFClientAnchor createClientAnchor() {
+               return new XSSFClientAnchor();
+       }
 }
index 1daf33d52aa338dfab58790628688a715a3f6d4b..622104e8a59ecb913598099dbc7dfae04d14eae2 100644 (file)
@@ -53,7 +53,6 @@ import org.apache.poi.xssf.model.CalculationChain;
 import org.apache.poi.xssf.model.SharedStringsTable;
 import org.apache.poi.xssf.model.StylesTable;
 import org.apache.poi.xssf.model.MapInfo;
-import org.apache.poi.xssf.extractor.XSSFExportToXml;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
@@ -570,7 +569,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
             throw new IllegalStateException("There are no defined names in this workbook");
         }
         if (nameIndex < 0 || nameIndex > nNames) {
-            throw new IllegalArgumentException("Specified name index " + nameIndex 
+            throw new IllegalArgumentException("Specified name index " + nameIndex
                     + " is outside the allowable range (0.." + (nNames-1) + ").");
         }
         return namedRanges.get(nameIndex);
@@ -636,7 +635,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
      * @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
      * @return String Null if no print area has been defined
      */
-    public String getPrintArea(int sheetIndex) {    
+    public String getPrintArea(int sheetIndex) {
         XSSFName name = getBuiltInName(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
         if (name == null) return null;
         //adding one here because 0 indicates a global named region; doesnt make sense for print areas
@@ -975,7 +974,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
                 r = escapedName + "!$" + rowRef.getCellRefParts()[1] + ":$" + rowRef2.getCellRefParts()[1];
             }
         }
-        
+
         StringBuffer rng = new StringBuffer();
         rng.append(c);
         if(rng.length() > 0 && r.length() > 0) rng.append(',');
@@ -1243,7 +1242,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
         }
         return embedds;
     }
-    
+
     public boolean isHidden() {
         throw new RuntimeException("Not implemented yet");
     }
@@ -1280,7 +1279,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
      * Fired when a formula is deleted from this workbook,
      * for example when calling cell.setCellFormula(null)
      *
-     * @see XSSFCell#setCellFormula(String) 
+     * @see XSSFCell#setCellFormula(String)
      */
     protected void onDeleteFormula(XSSFCell cell){
         if(calcChain != null) {
@@ -1294,7 +1293,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
      * <p>
      *   The calculation chain object specifies the order in which the cells in a workbook were last calculated
      * </p>
-     * 
+     *
      * @return the <code>CalculationChain</code> object or <code>null</code> if not defined
      */
     public CalculationChain getCalculationChain(){
@@ -1302,19 +1301,19 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
     }
 
     /**
-     * 
+     *
      * @return a collection of custom XML mappings defined in this workbook
      */
     public Collection<XSSFMap> getCustomXMLMappings(){
         return mapInfo == null ? new ArrayList<XSSFMap>() : mapInfo.getAllXSSFMaps();
     }
-    
+
     /**
-     * 
+     *
      * @return the helper class used to query the custom XML mapping defined in this workbook
      */
     public MapInfo getMapInfo(){
        return mapInfo;
     }
-    
+
 }
index 32d9dc62aa7408517254be8ae56a23c2b3b363dd..9bf8243dd27b307e8e8848d4881041e734f93390 100644 (file)
 package org.apache.poi.xssf.usermodel.extensions;
 
 import org.apache.poi.ss.usermodel.HeaderFooter;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.helpers.HeaderFooterHelper;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
 
 /**
  * Parent class of all XSSF headers and footers.
- * 
- * For a list of all the different fields that can be
- *  placed into a header or footer, such as page number,
- *  bold, underline etc, see the follow formatting syntax
- *  
+ *
+ * For a list of all the different fields that can be placed into a header or
+ * footer, such as page number, bold, underline etc, see the follow formatting
+ * syntax
+ *
  *<b> Header/Footer Formatting Syntax</b>
  *<p>
- * There are a number of formatting codes that can be written inline with the actual header / footer text, which
- * affect the formatting in the header or footer.
+ * There are a number of formatting codes that can be written inline with the
+ * actual header / footer text, which affect the formatting in the header or
+ * footer.
  *</p>
  *
- * This example shows the text "Center Bold Header" on the first line (center section), and the date on the second
- * line (center section).
- * &CCenter &"-,Bold"Bold &"-,Regular"Header_x000A_&D
- * 
- * <b>General Rules:</b>
- * There is no required order in which these codes must appear.
- * The first occurrence of the following codes turns the formatting ON, the second occurrence turns it OFF again:
- * 
+ * This example shows the text "Center Bold Header" on the first line (center
+ * section), and the date on the second line (center section). &CCenter
+ * &"-,Bold"Bold &"-,Regular"Header_x000A_&D
+ *
+ * <b>General Rules:</b> There is no required order in which these codes must
+ * appear. The first occurrence of the following codes turns the formatting ON,
+ * the second occurrence turns it OFF again:
+ *
  * <dl>
- * <dt> &L </dt> <dd>code for "left section" (there are three header / footer locations, "left", "center", and "right"). When
- * two or more occurrences of this section marker exist, the contents from all markers are concatenated, in the
- * order of appearance, and placed into the left section.</dd>
- * <dt> &P </dt> <dd> code for "current page #"</dd>
- * <dt> &N </dt> <dd> code for "total pages"</dd>
- * <dt>&font size </dt> <dd> code for "text font size", where font size is a font size in points.</dd>
- * <dt> &K </dt> <dd> code for "text font color"
- * RGB Color is specified as RRGGBB
- * Theme Color is specifed as TTSNN where TT is the theme color Id, S is either "+" or "-" of the tint/shade
- * value, NN is the tint/shade value.</dd>
- * <dt> &S </dt> <dd> code for "text strikethrough" on / off</dd>
- * <dt> &X </dt> <dd> code for "text super script" on / off</dd>
- * <dt> &Y </dt> <dd> code for "text subscript" on / off</dd>
- * <dt> &C </dt> <dd> code for "center section". When two or more occurrences of this section marker exist, the contents
- * from all markers are concatenated, in the order of appearance, and placed into the center section.
- * SpreadsheetML Reference Material - Worksheets 1966</dd>
- * <dt> &D </dt> <dd> code for "date"</dd>
- * <dt> &T </dt> <dd> code for "time"</dd>
- * <dt> &G </dt> <dd> code for "picture as background"</dd>
- * <dt> &U </dt> <dd> code for "text single underline"</dd>
- * <dt> &E </dt> <dd> code for "double underline"</dd>
- * <dt> &R </dt> <dd> code for "right section". When two or more occurrences of this section marker exist, the contents
- * from all markers are concatenated, in the order of appearance, and placed into the right section.</dd>
- * <dt> &Z </dt> <dd> code for "this workbook's file path"</dd>
- * <dt> &F </dt> <dd> code for "this workbook's file name"</dd>
- * <dt> &A </dt> <dd> code for "sheet tab name"</dd>
- * <dt> &+ </dt> <dd> code for add to page #.</dd>
- * <dt> &- </dt> <dd> code for subtract from page #.</dd>
- * <dt> &"font name,font type" - code for "text font name" and "text font type", where font name and font type
- * are strings specifying the name and type of the font, separated by a comma. When a hyphen appears in font
- * name, it means "none specified". Both of font name and font type can be localized values.</dd>
- * <dt> &"-,Bold" </dt> <dd> code for "bold font style"</dd>
- * <dt> &B </dt> <dd> also means "bold font style"</dd>
- * <dt> &"-,Regular" </dt> <dd> code for "regular font style"</dd>
- * <dt> &"-,Italic" </dt> <dd> code for "italic font style"</dd>
- * <dt> &I </dt> <dd> also means "italic font style"</dd>
- * <dt> &"-,Bold Italic" </dt> <dd> code for "bold italic font style"</dd>
- * <dt> &O </dt> <dd> code for "outline style"</dd>
- * <dt> &H </dt> <dd> code for "shadow style"</dd>
+ * <dt>&L</dt>
+ * <dd>code for "left section" (there are three header / footer locations,
+ * "left", "center", and "right"). When two or more occurrences of this section
+ * marker exist, the contents from all markers are concatenated, in the order of
+ * appearance, and placed into the left section.</dd>
+ * <dt>&P</dt>
+ * <dd>code for "current page #"</dd>
+ * <dt>&N</dt>
+ * <dd>code for "total pages"</dd>
+ * <dt>&font size</dt>
+ * <dd>code for "text font size", where font size is a font size in points.</dd>
+ * <dt>&K</dt>
+ * <dd>code for "text font color" RGB Color is specified as RRGGBB Theme Color
+ * is specifed as TTSNN where TT is the theme color Id, S is either "+" or "-"
+ * of the tint/shade value, NN is the tint/shade value.</dd>
+ * <dt>&S</dt>
+ * <dd>code for "text strikethrough" on / off</dd>
+ * <dt>&X</dt>
+ * <dd>code for "text super script" on / off</dd>
+ * <dt>&Y</dt>
+ * <dd>code for "text subscript" on / off</dd>
+ * <dt>&C</dt>
+ * <dd>code for "center section". When two or more occurrences of this section
+ * marker exist, the contents from all markers are concatenated, in the order of
+ * appearance, and placed into the center section. SpreadsheetML Reference
+ * Material - Worksheets 1966</dd>
+ * <dt>&D</dt>
+ * <dd>code for "date"</dd>
+ * <dt>&T</dt>
+ * <dd>code for "time"</dd>
+ * <dt>&G</dt>
+ * <dd>code for "picture as background"</dd>
+ * <dt>&U</dt>
+ * <dd>code for "text single underline"</dd>
+ * <dt>&E</dt>
+ * <dd>code for "double underline"</dd>
+ * <dt>&R</dt>
+ * <dd>code for "right section". When two or more occurrences of this section
+ * marker exist, the contents from all markers are concatenated, in the order of
+ * appearance, and placed into the right section.</dd>
+ * <dt>&Z</dt>
+ * <dd>code for "this workbook's file path"</dd>
+ * <dt>&F</dt>
+ * <dd>code for "this workbook's file name"</dd>
+ * <dt>&A</dt>
+ * <dd>code for "sheet tab name"</dd>
+ * <dt>&+</dt>
+ * <dd>code for add to page #.</dd>
+ * <dt>&-</dt>
+ * <dd>code for subtract from page #.</dd>
+ * <dt>&"font name,font type" - code for "text font name" and "text font type",
+ * where font name and font type are strings specifying the name and type of the
+ * font, separated by a comma. When a hyphen appears in font name, it means
+ * "none specified". Both of font name and font type can be localized
+ * values.</dd>
+ * <dt>&"-,Bold"</dt>
+ * <dd>code for "bold font style"</dd>
+ * <dt>&B</dt>
+ * <dd>also means "bold font style"</dd>
+ * <dt>&"-,Regular"</dt>
+ * <dd>code for "regular font style"</dd>
+ * <dt>&"-,Italic"</dt>
+ * <dd>code for "italic font style"</dd>
+ * <dt>&I</dt>
+ * <dd>also means "italic font style"</dd>
+ * <dt>&"-,Bold Italic"</dt>
+ * <dd>code for "bold italic font style"</dd>
+ * <dt>&O</dt>
+ * <dd>code for "outline style"</dd>
+ * <dt>&H</dt>
+ * <dd>code for "shadow style"</dd>
  * </dl>
- *  
- *  
+ *
+ *
  */
 public abstract class XSSFHeaderFooter implements HeaderFooter {
-    private HeaderFooterHelper helper;
-    private CTHeaderFooter headerFooter;
+       private HeaderFooterHelper helper;
+       private CTHeaderFooter headerFooter;
 
        private boolean stripFields = false;
 
        /**
         * Create an instance of XSSFHeaderFooter from the supplied XML bean
+        *
         * @param headerFooter
         */
-    public XSSFHeaderFooter(CTHeaderFooter headerFooter) {
-       this.headerFooter = headerFooter;
-       this.helper = new HeaderFooterHelper();
-    }
-    
-    /**
-     * Returns the underlying CTHeaderFooter xml bean 
-     *
-     * @return the underlying CTHeaderFooter xml bean
-     */
-    public CTHeaderFooter getHeaderFooter() {
-        return this.headerFooter;
-    }
-
-    public String getValue() {
-        String value = getText();
-        if(value == null)
-               return "";
-        return value;
-    }
-    
-    
+       public XSSFHeaderFooter(CTHeaderFooter headerFooter) {
+               this.headerFooter = headerFooter;
+               this.helper = new HeaderFooterHelper();
+       }
+
+       /**
+        * Returns the underlying CTHeaderFooter xml bean
+        *
+        * @return the underlying CTHeaderFooter xml bean
+        */
+       public CTHeaderFooter getHeaderFooter() {
+               return this.headerFooter;
+       }
+
+       public String getValue() {
+               String value = getText();
+               if (value == null)
+                       return "";
+               return value;
+       }
+
        /**
-        * Are fields currently being stripped from
-        *  the text that this {@link XSSFHeaderFooter} returns?
-        *  Default is false, but can be changed
+        * Are fields currently being stripped from the text that this
+        * {@link XSSFHeaderFooter} returns? Default is false, but can be changed
         */
        public boolean areFieldsStripped() {
                return stripFields;
        }
+
        /**
-        * Should fields (eg macros) be stripped from
-        *  the text that this class returns?
-        * Default is not to strip.
+        * Should fields (eg macros) be stripped from the text that this class
+        * returns? Default is not to strip.
+        *
         * @param stripFields
         */
        public void setAreFieldsStripped(boolean stripFields) {
@@ -138,69 +170,66 @@ public abstract class XSSFHeaderFooter implements HeaderFooter {
        }
 
        /**
-        * Removes any fields (eg macros, page markers etc)
-        *  from the string.
-        * Normally used to make some text suitable for showing
-        *  to humans, and the resultant text should not normally
-        *  be saved back into the document!
+        * Removes any fields (eg macros, page markers etc) from the string.
+        * Normally used to make some text suitable for showing to humans, and the
+        * resultant text should not normally be saved back into the document!
         */
        public static String stripFields(String text) {
                return org.apache.poi.hssf.usermodel.HeaderFooter.stripFields(text);
        }
 
-    
-    public abstract String getText();
-    
-    protected abstract void setText(String text);
-
-    /**
-     * get the text representing the center part of this element
-     */
-    public String getCenter() {
-       String text = helper.getCenterSection(getText()); 
-       if(stripFields)
-               return stripFields(text);
-        return text;
-    }
-
-    /**
-     * get the text representing the left part of this element
-     */
-    public String getLeft() {
-        String text = helper.getLeftSection(getText());
-       if(stripFields)
-               return stripFields(text);
-        return text;
-    }
-
-    /**
-     * get the text representing the right part of this element
-     */
-    public String getRight() {
-        String text = helper.getRightSection(getText());
-       if(stripFields)
-               return stripFields(text);
-        return text;
-    }
-
-    /**
-     * set a centered string value for this element 
-     */
-    public void setCenter(String newCenter) {
-        setText(helper.setCenterSection(getText(), newCenter));
-    }
-
-    /**
-     * set a left string value for this element 
-     */
-    public void setLeft(String newLeft) {
-        setText(helper.setLeftSection(getText(), newLeft));
-    }
-
-    /**
-     * set a right string value for this element 
-     */
-    public void setRight(String newRight) {
-        setText(helper.setRightSection(getText(), newRight));
-    }
+       public abstract String getText();
+
+       protected abstract void setText(String text);
+
+       /**
+        * get the text representing the center part of this element
+        */
+       public String getCenter() {
+               String text = helper.getCenterSection(getText());
+               if (stripFields)
+                       return stripFields(text);
+               return text;
+       }
+
+       /**
+        * get the text representing the left part of this element
+        */
+       public String getLeft() {
+               String text = helper.getLeftSection(getText());
+               if (stripFields)
+                       return stripFields(text);
+               return text;
+       }
+
+       /**
+        * get the text representing the right part of this element
+        */
+       public String getRight() {
+               String text = helper.getRightSection(getText());
+               if (stripFields)
+                       return stripFields(text);
+               return text;
+       }
+
+       /**
+        * set a centered string value for this element
+        */
+       public void setCenter(String newCenter) {
+               setText(helper.setCenterSection(getText(), newCenter));
+       }
+
+       /**
+        * set a left string value for this element
+        */
+       public void setLeft(String newLeft) {
+               setText(helper.setLeftSection(getText(), newLeft));
+       }
+
+       /**
+        * set a right string value for this element
+        */
+       public void setRight(String newRight) {
+               setText(helper.setRightSection(getText(), newRight));
+       }
 }
index 90e7d54458b4b9227900d7193a9d601ab7ad4121..a4c813924f9d277e0d75327ad32476c444dd1920 100755 (executable)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.openxml4j.opc;
 
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -37,8 +36,6 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.opc.internal.ContentTypeManager;
 import org.apache.poi.openxml4j.opc.internal.FileHelper;
 import org.apache.poi.util.TempFile;
-import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogger;
 import org.dom4j.Document;
 import org.dom4j.DocumentHelper;
 import org.dom4j.Element;
@@ -64,19 +61,19 @@ public final class TestPackage extends TestCase {
                //ZipFileAssert.assertEquals(originalFile, targetFile);
                assertTrue(targetFile.delete());
        }
-       
+
        /**
         * Test that when we create a new Package, we give it
         *  the correct default content types
         */
        public void testCreateGetsContentTypes() throws Exception {
                File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestCreatePackageTMP.docx");
-               
+
                // Zap the target file, in case of an earlier run
                if(targetFile.exists()) targetFile.delete();
-               
+
                OPCPackage pkg = OPCPackage.create(targetFile);
-               
+
                // Check it has content types for rels and xml
                ContentTypeManager ctm = getContentTypeManager(pkg);
                assertEquals(
@@ -108,7 +105,7 @@ public final class TestPackage extends TestCase {
 
                // Zap the target file, in case of an earlier run
                if(targetFile.exists()) targetFile.delete();
-               
+
                // Create a package
                OPCPackage pkg = OPCPackage.create(targetFile);
                PackagePartName corePartName = PackagingURIHelper
@@ -142,7 +139,7 @@ public final class TestPackage extends TestCase {
                //ZipFileAssert.assertEquals(expectedFile, targetFile);
                assertTrue(targetFile.delete());
        }
-       
+
        /**
         * Tests that we can create a new package, add a core
         *  document and another part, save and re-load and
@@ -151,7 +148,7 @@ public final class TestPackage extends TestCase {
        public void testCreatePackageWithCoreDocument() throws Exception {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                OPCPackage pkg = OPCPackage.create(baos);
-               
+
                // Add a core document
         PackagePartName corePartName = PackagingURIHelper.createPartName("/xl/workbook.xml");
         // Create main part relationship
@@ -162,7 +159,7 @@ public final class TestPackage extends TestCase {
         OutputStream coreOut = corePart.getOutputStream();
         coreOut.write("<dummy-xml />".getBytes());
         coreOut.close();
-               
+
                // And another bit
         PackagePartName sheetPartName = PackagingURIHelper.createPartName("/xl/worksheets/sheet1.xml");
         PackageRelationship rel =
@@ -184,8 +181,8 @@ public final class TestPackage extends TestCase {
         assertEquals("/", coreRel.getSourceURI().toString());
         assertEquals("/xl/workbook.xml", coreRel.getTargetURI().toString());
         assertNotNull(pkg.getPart(coreRel));
-        
-        
+
+
         // Save and re-load
         pkg.close();
         File tmp = TempFile.createTempFile("testCreatePackageWithCoreDocument", ".zip");
@@ -290,7 +287,7 @@ public final class TestPackage extends TestCase {
                //ZipFileAssert.assertEquals(expectedFile, targetFile);
                assertTrue(targetFile.delete());
        }
-       
+
        /**
         * Checks that we can write a package to a simple
         *  OutputStream, in addition to the normal writing
@@ -318,15 +315,15 @@ public final class TestPackage extends TestCase {
         */
        public void testOpenFromInputStream() throws Exception {
                String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
-               
+
                FileInputStream finp = new FileInputStream(originalFile);
-               
+
                OPCPackage p = OPCPackage.open(finp);
-               
+
                assertNotNull(p);
                assertNotNull(p.getRelationships());
                assertEquals(12, p.getParts().size());
-               
+
                // Check it has the usual bits
                assertTrue(p.hasRelationships());
                assertTrue(p.containPart(PackagingURIHelper.createPartName("/_rels/.rels")));
@@ -407,7 +404,7 @@ public final class TestPackage extends TestCase {
                // Don't save modifications
                p.revert();
        }
-       
+
        public void testDeletePartRecursive() throws InvalidFormatException {
                TreeMap<PackagePartName, String> expectedValues;
                TreeMap<PackagePartName, String> values;
@@ -445,7 +442,7 @@ public final class TestPackage extends TestCase {
                // Don't save modifications
                p.revert();
        }
-       
+
        private static ContentTypeManager getContentTypeManager(OPCPackage pkg) throws Exception {
                Field f = OPCPackage.class.getDeclaredField("contentTypeManager");
                f.setAccessible(true);
index 94e8c090073d16a98a9a8709a36e9abad32e95df..0f739f750ee6872be0ecb5de35d54c99d32f28cb 100644 (file)
@@ -24,7 +24,6 @@ import junit.framework.TestCase;
 
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.PictureData;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -35,8 +34,8 @@ public class TestLoadSaveXSSF extends TestCase {
 
     String filename;
 
-    protected void setUp() throws Exception {
-        super.setUp();
+    protected void setUp() {
+
         System.setProperty("org.apache.poi.util.POILogger", org.apache.poi.util.CommonsLogger.class.getName());
         filename = System.getProperty("XSSF.testdata.path");
         if (filename == null) {
@@ -52,12 +51,12 @@ public class TestLoadSaveXSSF extends TestCase {
         Row row = sheet.getRow(0);
         Cell cell = row.getCell((short) 1);
         assertNotNull(cell);
-        assertEquals(111.0, cell.getNumericCellValue());
+        assertEquals(111.0, cell.getNumericCellValue(), 0.0);
         cell = row.getCell((short) 0);
         assertEquals("Lorem", cell.getRichStringCellValue().getString());
     }
 
-    // TODO filename string hard coded in XSSFWorkbook constructor in order to make ant test-ooxml target be successfull.
+    // TODO filename string hard coded in XSSFWorkbook constructor in order to make ant test-ooxml target be successful.
     public void testLoadStyles() throws Exception {
         XSSFWorkbook workbook = new XSSFWorkbook(new File(filename, "styles.xlsx").getAbsolutePath());
         Sheet sheet = workbook.getSheetAt(0);
@@ -67,11 +66,10 @@ public class TestLoadSaveXSSF extends TestCase {
         // assertNotNull(style);
     }
 
-    // TODO filename string hard coded in XSSFWorkbook constructor in order to make ant test-ooxml target be successfull.
+    // TODO filename string hard coded in XSSFWorkbook constructor in order to make ant test-ooxml target be successful.
     public void testLoadPictures() throws Exception {
         XSSFWorkbook workbook = new XSSFWorkbook(new File(filename, "picture.xlsx").getAbsolutePath());
         List<XSSFPictureData> pictures = workbook.getAllPictures();
         assertEquals(1, pictures.size());
     }
-
 }
index bda438994c29c3a8c997ca30fc9c026cd1d88c6d..ed4953b2cd628daee45f0f939b46057c2a65cf75 100644 (file)
 
 package org.apache.poi.xssf.usermodel;
 
-import java.io.File;
 import java.util.List;
 
-import junit.framework.TestCase;
-
-import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackagingURIHelper;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
-import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.apache.poi.xssf.XSSFTestDataSamples;
 
-public class TestXSSFBugs extends BaseTestBugzillaIssues {
+public final class TestXSSFBugs extends BaseTestBugzillaIssues {
     @Override
     protected XSSFITestDataProvider getTestDataProvider(){
         return XSSFITestDataProvider.getInstance();
index 5a8b0fb3abb7cbb188e913b92d01cb8f7b60888e..95cc8ac06636d9cea38986704842431668640608 100644 (file)
 
 package org.apache.poi.xssf.usermodel;
 
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFRichTextString;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.ITestDataProvider;
-import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.ss.usermodel.BaseTestDataFormat;
 import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
 
 /**
  * Tests for {@link XSSFDataFormat}
  *
  */
 public final class TestXSSFDataFormat extends BaseTestDataFormat {
-    
+
     @Override
     protected ITestDataProvider getTestDataProvider(){
         return XSSFITestDataProvider.getInstance();
index bb541e54cd147eefd75d5355324b4b9e86486ed5..288ffca69caf1fd594b83a8ad221c2b5127c1cbd 100755 (executable)
 
 package org.apache.poi.xssf.usermodel;
 
-import junit.framework.TestCase;
-
 import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.apache.poi.xssf.usermodel.XSSFColor;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBooleanProperty;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
@@ -38,14 +34,14 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignRun;
 
 public final class TestXSSFFont extends BaseTestFont{
 
-    @Override
-    protected XSSFITestDataProvider getTestDataProvider(){
-        return XSSFITestDataProvider.getInstance();
-    }
+       @Override
+       protected XSSFITestDataProvider getTestDataProvider() {
+               return XSSFITestDataProvider.getInstance();
+       }
 
-    public void testDefaultFont() {
-        baseTestDefaultFont("Calibri", (short)220, IndexedColors.BLACK.getIndex());
-    }
+       public void testDefaultFont() {
+               baseTestDefaultFont("Calibri", (short) 220, IndexedColors.BLACK.getIndex());
+       }
 
        public void testConstructor() {
                XSSFFont xssfFont=new XSSFFont();
@@ -160,7 +156,7 @@ public final class TestXSSFFont extends BaseTestFont{
                xssfFont.setUnderline(Font.U_DOUBLE);
                assertEquals(ctFont.getUArray().length,1);
                assertEquals(STUnderlineValues.DOUBLE,ctFont.getUArray(0).getVal());
-               
+
                xssfFont.setUnderline(FontUnderline.DOUBLE_ACCOUNTING);
                assertEquals(ctFont.getUArray().length,1);
                assertEquals(STUnderlineValues.DOUBLE_ACCOUNTING,ctFont.getUArray(0).getVal());
index f2e8ecddc8a014b0b0af43e4b186018aa6975eef..230dc50af5078b254527640f6658fd0618eea9be 100755 (executable)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import junit.framework.TestCase;
 import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.ss.usermodel.BaseTestNamedRange;
@@ -37,7 +36,7 @@ public final class TestXSSFName extends BaseTestNamedRange {
         // First test that setting RR&C for same sheet more than once only creates a
         // single  Print_Titles built-in record
         XSSFWorkbook wb = getTestDataProvider().createWorkbook();
-        XSSFSheet sheet = wb.createSheet("First Sheet");
+        wb.createSheet("First Sheet");
 
         wb.setRepeatingRowsAndColumns(0, -1, -1, -1, -1);
 
@@ -77,7 +76,7 @@ public final class TestXSSFName extends BaseTestNamedRange {
 
         // check that setting RR&C on a second sheet causes a new Print_Titles built-in
         // name to be created
-        sheet = nwb.createSheet("SecondSheet");
+        nwb.createSheet("SecondSheet");
         nwb.setRepeatingRowsAndColumns(1, 1, 2, 0, 0);
 
         assertEquals(2, nwb.getNumberOfNames());
@@ -88,6 +87,4 @@ public final class TestXSSFName extends BaseTestNamedRange {
 
         nwb.setRepeatingRowsAndColumns(1, -1, -1, -1, -1);
     }
-
-
 }
index 1aa6d8e119719516cbc5ecdf1d65f65190a93ee6..2437767bf1b3b46e966350f75c2c35e87186e393 100755 (executable)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import junit.framework.TestCase;
 import org.apache.poi.ss.usermodel.ClientAnchor;
 import org.apache.poi.ss.usermodel.BaseTestPicture;
 import org.apache.poi.xssf.XSSFITestDataProvider;
index 1fb96061bd52c30daaf43b4461d4f9f14d1daa0d..06868d8376eb48f4ca41b651a5bafd63573bbe09 100755 (executable)
 
 package org.apache.poi.xssf.usermodel;
 
+import java.util.Arrays;
+import java.util.List;
+
 import junit.framework.TestCase;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.POIXMLDocumentPart;
-import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing;
 
-import java.util.List;
-import java.util.Arrays;
-import java.io.IOException;
+import org.apache.poi.xssf.XSSFTestDataSamples;
 
 /**
  * @author Yegor Kozlov
index 599aa96d207ae728cd744bee227fde9abdd407dc..c3cee3953b75ba55369bb1171dcdb7eeb42a7fa9 100755 (executable)
@@ -187,13 +187,13 @@ public class TestXSSFPrintSetup extends TestCase {
         pMargins.setHeader(1.5);
         pMargins.setFooter(2);
         XSSFPrintSetup printSetup = new XSSFPrintSetup(worksheet);
-        assertEquals(1.5, printSetup.getHeaderMargin());
-        assertEquals(2.0, printSetup.getFooterMargin());
+        assertEquals(1.5, printSetup.getHeaderMargin(), 0.0);
+        assertEquals(2.0, printSetup.getFooterMargin(), 0.0);
 
         printSetup.setHeaderMargin(5);
         printSetup.setFooterMargin(3.5);
-        assertEquals(5.0, pMargins.getHeader());
-        assertEquals(3.5, pMargins.getFooter());
+        assertEquals(5.0, pMargins.getHeader(), 0.0);
+        assertEquals(3.5, pMargins.getFooter(), 0.0);
     }
 
     public void testSetGetCopies() {
index 4ae39fe217b5a093d66dd093fde399ae622ee48b..427a56ddddf808fe29a9e1dffecc29abea8302f2 100755 (executable)
 
 package org.apache.poi.xssf.usermodel;
 
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-
 import junit.framework.TestCase;
 
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.Comment;
-import org.apache.poi.ss.usermodel.CreationHelper;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.xssf.model.CommentsTable;
-import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
 
 /**
  * Tests functionality of the XSSFRichTextRun object
@@ -42,7 +28,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
  */
 public final class TestXSSFRichTextString extends TestCase {
 
-    public void testCreate() throws Exception {
+    public void testCreate() {
 
         XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
         assertEquals("Apache POI", rt.getString());
@@ -59,7 +45,7 @@ public final class TestXSSFRichTextString extends TestCase {
     }
 
 
-    public void testApplyFont() throws Exception {
+    public void testApplyFont() {
 
         XSSFRichTextString rt = new XSSFRichTextString();
         rt.append("123");
@@ -85,7 +71,7 @@ public final class TestXSSFRichTextString extends TestCase {
         assertEquals(1, rt.getLengthOfFormattingRun(3));
     }
 
-    public void testClearFormatting() throws Exception {
+    public void testClearFormatting() {
 
         XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
         assertEquals("Apache POI", rt.getString());
@@ -105,10 +91,9 @@ public final class TestXSSFRichTextString extends TestCase {
         rt.clearFormatting();
         assertEquals("Apache POI", rt.getString());
         assertEquals(0, rt.numFormattingRuns());
-
     }
 
-    public void testGetFonts() throws Exception {
+    public void testGetFonts() {
 
         XSSFRichTextString rt = new XSSFRichTextString();
 
@@ -129,6 +114,5 @@ public final class TestXSSFRichTextString extends TestCase {
         XSSFFont font2$ = rt.getFontOfFormattingRun(1);
         assertEquals(font2.getBold(), font2$.getBold());
         assertEquals(font2.getFontName(), font2$.getFontName());
-
     }
 }
index 11a430a47de9af6e8dd3521daf3dfd0a73de52e4..5ac850e6aa7e877e7d1a4fc600f575e4505a342b 100644 (file)
 
 package org.apache.poi.xssf.usermodel;
 
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.xssf.model.SharedStringsTable;
-import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.ss.usermodel.BaseTestRow;
 import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.usermodel.HSSFCell;
 
 /**
  * Tests for XSSFRow
index 487c9e968c355a40eb26f5a21cfae7ae8853a9a6..bebfe308267a39fa08a649c1996100c085224e93 100644 (file)
 package org.apache.poi.xssf.usermodel;
 
 import java.io.File;
-import java.util.Iterator;
 
-import junit.framework.TestCase;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestSheet;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.apache.poi.xssf.model.CommentsTable;
 import org.apache.poi.xssf.model.StylesTable;
-import org.apache.poi.xssf.model.CalculationChain;
 import org.apache.poi.xssf.usermodel.helpers.ColumnHelper;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
 
 
 public class TestXSSFSheet extends BaseTestSheet {
@@ -205,14 +209,14 @@ public class TestXSSFSheet extends BaseTestSheet {
         CTWorksheet ctWorksheet = sheet.getCTWorksheet();
 
         sheet.createFreezePane(2, 4);
-        assertEquals((double) 2, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit());
+        assertEquals(2.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit(), 0.0);
         assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
         sheet.createFreezePane(3, 6, 10, 10);
-        assertEquals((double) 3, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit());
+        assertEquals(3.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit(), 0.0);
         //     assertEquals(10, sheet.getTopRow());
         //     assertEquals(10, sheet.getLeftCol());
         sheet.createSplitPane(4, 8, 12, 12, 1);
-        assertEquals((double) 8, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getYSplit());
+        assertEquals(8.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getYSplit(), 0.0);
         assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
     }
 
@@ -375,15 +379,15 @@ public class TestXSSFSheet extends BaseTestSheet {
     public void testSetColumnGroupCollapsed(){
        Workbook wb = new XSSFWorkbook();
        XSSFSheet sheet1 =(XSSFSheet) wb.createSheet();
-       
+
        CTCols cols=sheet1.getCTWorksheet().getColsArray(0);
        assertEquals(0,cols.sizeOfColArray());
-       
+
        sheet1.groupColumn( (short)4, (short)7 );
        sheet1.groupColumn( (short)9, (short)12 );
 
        assertEquals(2,cols.sizeOfColArray());
-       
+
        assertEquals(false,cols.getColArray(0).isSetHidden());
        assertEquals(true, cols.getColArray(0).isSetCollapsed());
        assertEquals(5, cols.getColArray(0).getMin()); // 1 based
@@ -395,7 +399,7 @@ public class TestXSSFSheet extends BaseTestSheet {
 
        sheet1.groupColumn( (short)10, (short)11 );
        assertEquals(4,cols.sizeOfColArray());
-       
+
        assertEquals(false,cols.getColArray(0).isSetHidden());
        assertEquals(true, cols.getColArray(0).isSetCollapsed());
        assertEquals(5, cols.getColArray(0).getMin()); // 1 based
@@ -412,11 +416,11 @@ public class TestXSSFSheet extends BaseTestSheet {
        assertEquals(true, cols.getColArray(3).isSetCollapsed());
        assertEquals(13, cols.getColArray(3).getMin()); // 1 based
        assertEquals(13, cols.getColArray(3).getMax()); // 1 based
-       
+
        // collapse columns - 1
        sheet1.setColumnGroupCollapsed( (short)5, true );
        assertEquals(5,cols.sizeOfColArray());
-       
+
        assertEquals(true, cols.getColArray(0).isSetHidden());
        assertEquals(true, cols.getColArray(0).isSetCollapsed());
        assertEquals(5, cols.getColArray(0).getMin()); // 1 based
@@ -501,7 +505,7 @@ public class TestXSSFSheet extends BaseTestSheet {
        //outline level 2: the line under ==> collapsed==True
        assertEquals(2,cols.getColArray(3).getOutlineLevel());
        assertEquals(true,cols.getColArray(4).isSetCollapsed());
-       
+
        assertEquals(false,cols.getColArray(0).isSetHidden());
        assertEquals(true, cols.getColArray(0).isSetCollapsed());
        assertEquals(5, cols.getColArray(0).getMin()); // 1 based
@@ -610,7 +614,7 @@ public class TestXSSFSheet extends BaseTestSheet {
        sheet1.groupRow( 7, 14 );
        sheet1.groupRow( 16, 19 );
 
-       assertEquals(14,sheet1.getPhysicalNumberOfRows());      
+       assertEquals(14,sheet1.getPhysicalNumberOfRows());
        assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
        assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
        assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed());
@@ -625,7 +629,7 @@ public class TestXSSFSheet extends BaseTestSheet {
        assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden());
 
        //collapsed
-       sheet1.setRowGroupCollapsed( 7, true ); 
+       sheet1.setRowGroupCollapsed( 7, true );
 
        assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
        assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
@@ -698,7 +702,7 @@ public class TestXSSFSheet extends BaseTestSheet {
         // XML is 1 based, POI is 0 based
         assertEquals(2, col.getMin());
         assertEquals(2, col.getMax());
-        assertEquals(22.0, col.getWidth());
+        assertEquals(22.0, col.getWidth(), 0.0);
 
         // Now set another
         sheet.setColumnWidth(3, 33 * 256);
@@ -711,12 +715,11 @@ public class TestXSSFSheet extends BaseTestSheet {
         col = cols.getColArray(0);
         assertEquals(2, col.getMin()); // POI 1
         assertEquals(2, col.getMax());
-        assertEquals(22.0, col.getWidth());
+        assertEquals(22.0, col.getWidth(), 0.0);
 
         col = cols.getColArray(1);
         assertEquals(4, col.getMin()); // POI 3
         assertEquals(4, col.getMax());
-        assertEquals(33.0, col.getWidth());
+        assertEquals(33.0, col.getWidth(), 0.0);
     }
-
 }
index e2dbb27fa5f096a84ca477d1ef47d7430210d3c9..3014bcf9047f810579f5f76bc7176e3c0766ce43 100644 (file)
@@ -20,31 +20,26 @@ package org.apache.poi.xssf.usermodel;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
-import java.util.zip.CRC32;
 import java.util.List;
+import java.util.zip.CRC32;
 
-import junit.framework.TestCase;
-
+import org.apache.poi.POIXMLProperties;
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.apache.poi.xssf.model.StylesTable;
 import org.apache.poi.openxml4j.opc.*;
 import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.util.TempFile;
-import org.apache.poi.POIXMLProperties;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
+import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.xssf.model.StylesTable;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
 
 public final class TestXSSFWorkbook extends BaseTestWorkbook {
 
-    @Override
-    protected XSSFITestDataProvider getTestDataProvider(){
-        return XSSFITestDataProvider.getInstance();
-    }
+       @Override
+       protected XSSFITestDataProvider getTestDataProvider(){
+               return XSSFITestDataProvider.getInstance();
+       }
 
 
        /**
@@ -53,94 +48,94 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
        public void testSaveLoadNew() throws Exception {
                XSSFWorkbook workbook = new XSSFWorkbook();
 
-        //check that the default date system is set to 1900
-        CTWorkbookPr pr = workbook.getCTWorkbook().getWorkbookPr();
-        assertNotNull(pr);
-        assertTrue(pr.isSetDate1904());
-        assertFalse("XSSF must use the 1900 date system", pr.getDate1904());
+               //check that the default date system is set to 1900
+               CTWorkbookPr pr = workbook.getCTWorkbook().getWorkbookPr();
+               assertNotNull(pr);
+               assertTrue(pr.isSetDate1904());
+               assertFalse("XSSF must use the 1900 date system", pr.getDate1904());
 
-        Sheet sheet1 = workbook.createSheet("sheet1");
+               Sheet sheet1 = workbook.createSheet("sheet1");
                Sheet sheet2 = workbook.createSheet("sheet2");
                workbook.createSheet("sheet3");
-               
+
                RichTextString rts = workbook.getCreationHelper().createRichTextString("hello world");
-               
+
                sheet1.createRow(0).createCell((short)0).setCellValue(1.2);
                sheet1.createRow(1).createCell((short)0).setCellValue(rts);
                sheet2.createRow(0);
-               
+
                assertEquals(0, workbook.getSheetAt(0).getFirstRowNum());
                assertEquals(1, workbook.getSheetAt(0).getLastRowNum());
                assertEquals(0, workbook.getSheetAt(1).getFirstRowNum());
                assertEquals(0, workbook.getSheetAt(1).getLastRowNum());
                assertEquals(0, workbook.getSheetAt(2).getFirstRowNum());
                assertEquals(0, workbook.getSheetAt(2).getLastRowNum());
-               
+
                File file = TempFile.createTempFile("poi-", ".xlsx");
                OutputStream out = new FileOutputStream(file);
                workbook.write(out);
                out.close();
-               
+
                // Check the package contains what we'd expect it to
                OPCPackage pkg = OPCPackage.open(file.toString());
-               PackagePart wbRelPart = 
+               PackagePart wbRelPart =
                        pkg.getPart(PackagingURIHelper.createPartName("/xl/_rels/workbook.xml.rels"));
                assertNotNull(wbRelPart);
                assertTrue(wbRelPart.isRelationshipPart());
                assertEquals(ContentTypes.RELATIONSHIPS_PART, wbRelPart.getContentType());
-               
-               PackagePart wbPart = 
+
+               PackagePart wbPart =
                        pkg.getPart(PackagingURIHelper.createPartName("/xl/workbook.xml"));
                // Links to the three sheets, shared strings and styles
                assertTrue(wbPart.hasRelationships());
                assertEquals(5, wbPart.getRelationships().size());
-               
+
                // Load back the XSSFWorkbook
                workbook = new XSSFWorkbook(pkg);
                assertEquals(3, workbook.getNumberOfSheets());
                assertNotNull(workbook.getSheetAt(0));
                assertNotNull(workbook.getSheetAt(1));
                assertNotNull(workbook.getSheetAt(2));
-               
+
                assertNotNull(workbook.getSharedStringSource());
                assertNotNull(workbook.getStylesSource());
-               
+
                assertEquals(0, workbook.getSheetAt(0).getFirstRowNum());
                assertEquals(1, workbook.getSheetAt(0).getLastRowNum());
                assertEquals(0, workbook.getSheetAt(1).getFirstRowNum());
                assertEquals(0, workbook.getSheetAt(1).getLastRowNum());
                assertEquals(0, workbook.getSheetAt(2).getFirstRowNum());
                assertEquals(0, workbook.getSheetAt(2).getLastRowNum());
-               
+
                sheet1 = workbook.getSheetAt(0);
                assertEquals(1.2, sheet1.getRow(0).getCell(0).getNumericCellValue(), 0.0001);
                assertEquals("hello world", sheet1.getRow(1).getCell(0).getRichStringCellValue().getString());
        }
-       
+
        public void testExisting() throws Exception {
-               
+
                XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("Formatting.xlsx");
                assertNotNull(workbook.getSharedStringSource());
                assertNotNull(workbook.getStylesSource());
-               
+
                // And check a few low level bits too
                OPCPackage pkg = OPCPackage.open(HSSFTestDataSamples.openSampleFileStream("Formatting.xlsx"));
-               PackagePart wbPart = 
+               PackagePart wbPart =
                        pkg.getPart(PackagingURIHelper.createPartName("/xl/workbook.xml"));
-               
+
                // Links to the three sheets, shared, styles and themes
                assertTrue(wbPart.hasRelationships());
                assertEquals(6, wbPart.getRelationships().size());
 
        }
-       
+
        public void testGetCellStyleAt(){
                XSSFWorkbook workbook = new XSSFWorkbook();
                short i = 0;
                //get default style
                CellStyle cellStyleAt = workbook.getCellStyleAt(i);
                assertNotNull(cellStyleAt);
-               
+
                //get custom style
                StylesTable styleSource = workbook.getStylesSource();
                XSSFCellStyle customStyle = new XSSFCellStyle(styleSource);
@@ -149,9 +144,9 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
                customStyle.setFont(font);
                int x = styleSource.putStyle(customStyle);
                cellStyleAt = workbook.getCellStyleAt((short)x);
-               assertNotNull(cellStyleAt);             
+               assertNotNull(cellStyleAt);
        }
-       
+
        public void testGetFontAt(){
                XSSFWorkbook workbook = new XSSFWorkbook();
                StylesTable styleSource = workbook.getStylesSource();
@@ -159,7 +154,7 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
                //get default font
                Font fontAt = workbook.getFontAt(i);
                assertNotNull(fontAt);
-               
+
                //get customized font
                XSSFFont customFont = new XSSFFont();
                customFont.setItalic(true);
@@ -167,23 +162,23 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
                fontAt = workbook.getFontAt((short)x);
                assertNotNull(fontAt);
        }
-       
+
        public void testGetNumCellStyles(){
                XSSFWorkbook workbook = new XSSFWorkbook();
                short i = workbook.getNumCellStyles();
                //get default cellStyles
                assertEquals(1, i);
                //get wrong value
-               assertNotSame(2, i);            
+               assertNotSame(2, i);
        }
-       
+
        public void testLoadSave() {
                XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("Formatting.xlsx");
                assertEquals(3, workbook.getNumberOfSheets());
                assertEquals("dd/mm/yyyy", workbook.getSheetAt(0).getRow(1).getCell(0).getRichStringCellValue().getString());
                assertNotNull(workbook.getSharedStringSource());
                assertNotNull(workbook.getStylesSource());
-               
+
                // Write out, and check
                // Load up again, check all still there
                XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(workbook);
@@ -191,7 +186,7 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
                assertNotNull(wb2.getSheetAt(0));
                assertNotNull(wb2.getSheetAt(1));
                assertNotNull(wb2.getSheetAt(2));
-               
+
                assertEquals("dd/mm/yyyy", wb2.getSheetAt(0).getRow(1).getCell(0).getRichStringCellValue().getString());
                assertEquals("yyyy/mm/dd", wb2.getSheetAt(0).getRow(2).getCell(0).getRichStringCellValue().getString());
                assertEquals("yyyy-mm-dd", wb2.getSheetAt(0).getRow(3).getCell(0).getRichStringCellValue().getString());
@@ -199,14 +194,14 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
                assertNotNull(wb2.getSharedStringSource());
                assertNotNull(wb2.getStylesSource());
        }
-       
+
        public void testStyles() {
                XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("Formatting.xlsx");
-               
+
                StylesTable ss = workbook.getStylesSource();
                assertNotNull(ss);
                StylesTable st = ss;
-               
+
                // Has 8 number formats
                assertEquals(8, st._getNumberFormatSize());
                // Has 2 fonts
@@ -215,20 +210,20 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
                assertEquals(2, st.getFills().size());
                // Has 1 border
                assertEquals(1, st.getBorders().size());
-               
+
                // Add two more styles
-               assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8, 
+               assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
                                st.putNumberFormat("testFORMAT"));
-               assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8, 
+               assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 8,
                                st.putNumberFormat("testFORMAT"));
-               assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 9, 
+               assertEquals(StylesTable.FIRST_CUSTOM_STYLE_ID + 9,
                                st.putNumberFormat("testFORMAT2"));
                assertEquals(10, st._getNumberFormatSize());
-               
-               
+
+
                // Save, load back in again, and check
                workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
-               
+
                ss = workbook.getStylesSource();
                assertNotNull(ss);
 
@@ -238,77 +233,77 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
                assertEquals(1, st.getBorders().size());
        }
 
-    public void testIncrementSheetId() throws Exception {
-        XSSFWorkbook wb = getTestDataProvider().createWorkbook();
-        int sheetId = (int)wb.createSheet().sheet.getSheetId();
-        assertEquals(1, sheetId);
-        sheetId = (int)wb.createSheet().sheet.getSheetId();
-        assertEquals(2, sheetId);
-
-        //test file with gaps in the sheetId sequence
-        wb = getTestDataProvider().openSampleWorkbook("47089.xlsm");
-        int lastSheetId = (int)wb.getSheetAt(wb.getNumberOfSheets() - 1).sheet.getSheetId();
-        sheetId = (int)wb.createSheet().sheet.getSheetId();
-        assertEquals(lastSheetId+1, sheetId);
-    }
-
-    /**
-     *  Test setting of core properties such as Title and Author
-     */
-    public void testWorkbookProperties() throws Exception {
-        XSSFWorkbook workbook = new XSSFWorkbook();
-        POIXMLProperties props = workbook.getProperties();
-        assertNotNull(props);
-        //the Application property must be set for new workbooks, see Bugzilla #47559
-        assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());
-
-        PackagePropertiesPart opcProps = props.getCoreProperties().getUnderlyingProperties();
-        assertNotNull(opcProps);
-
-        opcProps.setTitleProperty("Testing Bugzilla #47460");
-        assertEquals("Apache POI", opcProps.getCreatorProperty().getValue());
-        opcProps.setCreatorProperty("poi-dev@poi.apache.org");
-
-        workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
-        assertEquals("Apache POI", workbook.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
-        opcProps = workbook.getProperties().getCoreProperties().getUnderlyingProperties();
-        assertEquals("Testing Bugzilla #47460", opcProps.getTitleProperty().getValue());
-        assertEquals("poi-dev@poi.apache.org", opcProps.getCreatorProperty().getValue());
-    }
-
-    /**
-     * Verify that the attached test data was not modified. If this test method
-     * fails, the test data is not working properly.
-     */
-    public void test47668() throws Exception {
-        XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("47668.xlsx");
-        List<XSSFPictureData> allPictures = workbook.getAllPictures();
-        assertEquals(2, allPictures.size());
-
-        PackagePartName imagePartName = PackagingURIHelper
-                .createPartName("/xl/media/image1.jpeg");
-        PackagePart imagePart = workbook.getPackage().getPart(imagePartName);
-        assertNotNull(imagePart);
-
-        for (XSSFPictureData pictureData : allPictures) {
-            PackagePart picturePart = pictureData.getPackagePart();
-            assertSame(imagePart, picturePart);
-        }
-
-        XSSFSheet sheet0 = workbook.getSheetAt(0);
-        XSSFDrawing drawing0 = sheet0.createDrawingPatriarch();
-        XSSFPictureData pictureData0 = (XSSFPictureData) drawing0.getRelations().get(0);
-        byte[] data0 = pictureData0.getData();
-        CRC32 crc0 = new CRC32();
-        crc0.update(data0);
-
-        XSSFSheet sheet1 = workbook.getSheetAt(1);
-        XSSFDrawing drawing1 = sheet1.createDrawingPatriarch();
-        XSSFPictureData pictureData1 = (XSSFPictureData) drawing1.getRelations().get(0);
-        byte[] data1 = pictureData1.getData();
-        CRC32 crc1 = new CRC32();
-        crc1.update(data1);
-
-        assertEquals(crc0.getValue(), crc1.getValue());
-    }
+       public void testIncrementSheetId() {
+               XSSFWorkbook wb = getTestDataProvider().createWorkbook();
+               int sheetId = (int)wb.createSheet().sheet.getSheetId();
+               assertEquals(1, sheetId);
+               sheetId = (int)wb.createSheet().sheet.getSheetId();
+               assertEquals(2, sheetId);
+
+               //test file with gaps in the sheetId sequence
+               wb = getTestDataProvider().openSampleWorkbook("47089.xlsm");
+               int lastSheetId = (int)wb.getSheetAt(wb.getNumberOfSheets() - 1).sheet.getSheetId();
+               sheetId = (int)wb.createSheet().sheet.getSheetId();
+               assertEquals(lastSheetId+1, sheetId);
+       }
+
+       /**
+        *  Test setting of core properties such as Title and Author
+        */
+       public void testWorkbookProperties() {
+               XSSFWorkbook workbook = new XSSFWorkbook();
+               POIXMLProperties props = workbook.getProperties();
+               assertNotNull(props);
+               //the Application property must be set for new workbooks, see Bugzilla #47559
+               assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());
+
+               PackagePropertiesPart opcProps = props.getCoreProperties().getUnderlyingProperties();
+               assertNotNull(opcProps);
+
+               opcProps.setTitleProperty("Testing Bugzilla #47460");
+               assertEquals("Apache POI", opcProps.getCreatorProperty().getValue());
+               opcProps.setCreatorProperty("poi-dev@poi.apache.org");
+
+               workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+               assertEquals("Apache POI", workbook.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
+               opcProps = workbook.getProperties().getCoreProperties().getUnderlyingProperties();
+               assertEquals("Testing Bugzilla #47460", opcProps.getTitleProperty().getValue());
+               assertEquals("poi-dev@poi.apache.org", opcProps.getCreatorProperty().getValue());
+       }
+
+       /**
+        * Verify that the attached test data was not modified. If this test method
+        * fails, the test data is not working properly.
+        */
+       public void test47668() throws Exception {
+               XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("47668.xlsx");
+               List<XSSFPictureData> allPictures = workbook.getAllPictures();
+               assertEquals(2, allPictures.size());
+
+               PackagePartName imagePartName = PackagingURIHelper
+                               .createPartName("/xl/media/image1.jpeg");
+               PackagePart imagePart = workbook.getPackage().getPart(imagePartName);
+               assertNotNull(imagePart);
+
+               for (XSSFPictureData pictureData : allPictures) {
+                       PackagePart picturePart = pictureData.getPackagePart();
+                       assertSame(imagePart, picturePart);
+               }
+
+               XSSFSheet sheet0 = workbook.getSheetAt(0);
+               XSSFDrawing drawing0 = sheet0.createDrawingPatriarch();
+               XSSFPictureData pictureData0 = (XSSFPictureData) drawing0.getRelations().get(0);
+               byte[] data0 = pictureData0.getData();
+               CRC32 crc0 = new CRC32();
+               crc0.update(data0);
+
+               XSSFSheet sheet1 = workbook.getSheetAt(1);
+               XSSFDrawing drawing1 = sheet1.createDrawingPatriarch();
+               XSSFPictureData pictureData1 = (XSSFPictureData) drawing1.getRelations().get(0);
+               byte[] data1 = pictureData1.getData();
+               CRC32 crc1 = new CRC32();
+               crc1.update(data1);
+
+               assertEquals(crc0.getValue(), crc1.getValue());
+       }
 }
index 099d268ab0abb03f648d200dcc562e1c78cc9fa9..64f43c4a75a8a33b31174e199309447cfe908470 100644 (file)
@@ -22,11 +22,10 @@ import java.util.Arrays;
 import junit.framework.TestCase;
 
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
 
 
-public class TestCTColComparator extends TestCase {
-    
+public final class TestCTColComparator extends TestCase {
+
     public void testCompare() {
         CTColComparator comparator = new CTColComparator();
         CTCol o1 = CTCol.Factory.newInstance();
@@ -44,7 +43,7 @@ public class TestCTColComparator extends TestCase {
         o4.setMax(80);
         assertEquals(-1, comparator.compare(o3, o4));
     }
-    
+
     public void testArraysSort() {
         CTColComparator comparator = new CTColComparator();
         CTCol o1 = CTCol.Factory.newInstance();
@@ -73,5 +72,4 @@ public class TestCTColComparator extends TestCase {
         assertEquals(8, cols[1].getMax());
         assertEquals(80, cols[2].getMax());
     }
-    
 }
index e7e90c447ef09f16c0375bf477e42a11a1a1dab7..f02135afacbcaab9713961cb8e0a1b8a6d79942d 100644 (file)
@@ -21,7 +21,7 @@ import java.math.BigInteger;
 
 import junit.framework.TestCase;
 
-import org.openxmlformats.schemas.officeDocument.x2006.math.STSpacingRule;
+import org.apache.poi.POIXMLDocument;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTInd;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc;
@@ -40,29 +40,27 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment;
 /**
  * Tests for XWPF Paragraphs
  */
-public class TestXWPFParagraph extends TestCase {
+public final class TestXWPFParagraph extends TestCase {
     /**
      * A simple file
      */
     private XWPFDocument xml;
-    private File file;
-/*
+
     protected void setUp() throws Exception {
         super.setUp();
 
-        file = new File(
+        File file = new File(
                 System.getProperty("HWPF.testdata.path") +
                 File.separator + "ThreeColHead.docx"
         );
         assertTrue(file.exists());
         xml = new XWPFDocument(POIXMLDocument.openPackage(file.toString()));
     }
-*/
+
     /**
      * Check that we get the right paragraph from the header
      */
-    /*
-    public void testHeaderParagraph() throws Exception {
+    public void disabled_testHeaderParagraph() {
         XWPFHeader hdr = xml.getHeaderFooterPolicy().getDefaultHeader();
         assertNotNull(hdr);
 
@@ -74,12 +72,11 @@ public class TestXWPFParagraph extends TestCase {
         assertEquals("First header column!\tMid header\tRight header!", p
                 .getText());
     }
-*/
+
     /**
      * Check that we get the right paragraphs from the document
      */
-    /*
-    public void testDocumentParagraph() throws Exception {
+    public void disabled_testDocumentParagraph() {
         XWPFParagraph[] ps = xml.getParagraphs();
         assertEquals(10, ps.length);
 
@@ -100,23 +97,23 @@ public class TestXWPFParagraph extends TestCase {
         assertFalse(ps[4].isEmpty());
         assertEquals("More on page one", ps[4].getText());
     }
-*/
+
     public void testSetGetBorderTop() {
         //new clean instance of paragraph
         XWPFDocument doc = new XWPFDocument();
         XWPFParagraph p = doc.createParagraph();
 
         assertEquals(STBorder.NONE.intValue(), p.getBorderTop().getValue());
-        
+
         CTP ctp = p.getCTP();
         CTPPr ppr = ctp.getPPr()== null? ctp.addNewPPr() : ctp.getPPr();
-        
+
         //bordi
         CTPBdr bdr = ppr.addNewPBdr();
         CTBorder borderTop = bdr.addNewTop();
         borderTop.setVal(STBorder.DOUBLE);
         bdr.setTop(borderTop);
-        
+
         assertEquals(Borders.DOUBLE, p.getBorderTop());
         p.setBorderTop(Borders.SINGLE);
         assertEquals(STBorder.SINGLE, borderTop.getVal());
@@ -128,7 +125,7 @@ public class TestXWPFParagraph extends TestCase {
         XWPFParagraph p = doc.createParagraph();
 
         assertEquals(STJc.LEFT.intValue(), p.getAlignment().getValue());
-        
+
         CTP ctp = p.getCTP();
         CTPPr ppr = ctp.getPPr()== null? ctp.addNewPPr() : ctp.getPPr();
 
@@ -140,7 +137,7 @@ public class TestXWPFParagraph extends TestCase {
         assertEquals(STJc.BOTH, ppr.getJc().getVal());
     }
 
-    
+
     public void testSetGetSpacing() {
         XWPFDocument doc = new XWPFDocument();
         XWPFParagraph p = doc.createParagraph();
@@ -149,7 +146,7 @@ public class TestXWPFParagraph extends TestCase {
         CTPPr ppr = ctp.getPPr()== null? ctp.addNewPPr() : ctp.getPPr();
 
         assertEquals(-1, p.getSpacingAfter());
-        
+
         CTSpacing spacing = ppr.addNewSpacing();
         spacing.setAfter(new BigInteger("10"));
         assertEquals(10, p.getSpacingAfter());
@@ -166,7 +163,7 @@ public class TestXWPFParagraph extends TestCase {
         CTPPr ppr = ctp.getPPr()== null? ctp.addNewPPr() : ctp.getPPr();
 
         assertEquals(STLineSpacingRule.INT_AUTO, p.getSpacingLineRule().getValue());
-        
+
         CTSpacing spacing = ppr.addNewSpacing();
         spacing.setLineRule(STLineSpacingRule.AT_LEAST);
         assertEquals(LineSpacingRule.AT_LEAST, p.getSpacingLineRule());
@@ -174,18 +171,18 @@ public class TestXWPFParagraph extends TestCase {
         p.setSpacingAfter(100);
         assertEquals(100, spacing.getAfter().intValue());
     }
-    
+
     public void testSetGetIndentation() {
         XWPFDocument doc = new XWPFDocument();
         XWPFParagraph p = doc.createParagraph();
 
         assertEquals(-1, p.getIndentationLeft());
-        
+
         CTP ctp = p.getCTP();
         CTPPr ppr = ctp.getPPr()== null? ctp.addNewPPr() : ctp.getPPr();
 
         assertEquals(-1, p.getIndentationLeft());
-        
+
         CTInd ind = ppr.addNewInd();
         ind.setLeft(new BigInteger("10"));
         assertEquals(10, p.getIndentationLeft());
@@ -193,7 +190,7 @@ public class TestXWPFParagraph extends TestCase {
         p.setIndentationLeft(100);
         assertEquals(100, ind.getLeft().intValue());
     }
-    
+
     public void testSetGetVerticalAlignment() {
         //new clean instance of paragraph
         XWPFDocument doc = new XWPFDocument();
@@ -240,6 +237,4 @@ public class TestXWPFParagraph extends TestCase {
         p.setPageBreak(true);
         assertEquals(STOnOff.TRUE, ppr.getPageBreakBefore().getVal());
     }
-
-
 }
index 751b03666f480e1bc930397817d7a2ddd71c070f..9dc5925e9a1ef46246d23a621724dbc7ebb24819 100644 (file)
 
 package org.apache.poi.hdf.extractor;
 
-import java.util.*;
-
 /**
  * Comment me
  *
  * @author Ryan Ackley
  */
-
-public final class StyleSheet
-{
+public final class StyleSheet {
 
   private static final int NIL_STYLE = 4095;
   private static final int PAP_TYPE = 1;
index f08bd0deb07dadcd882737e0a4de830b973a940a..1b61045d71eacc945808feb8210f12def26866e8 100644 (file)
 
 package org.apache.poi.hdf.model;
 
-
-//import java.io;
-
-import java.util.ArrayList;
-import java.io.InputStream;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.TreeSet;
-
 
-import org.apache.poi.hdf.model.hdftypes.*;
 import org.apache.poi.hdf.event.HDFLowLevelParsingListener;
-import org.apache.poi.hdf.model.util.BTreeSet;
+import org.apache.poi.hdf.model.hdftypes.*;
 import org.apache.poi.hdf.model.util.ParsingState;
-
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.poifs.filesystem.POIFSDocument;
 import org.apache.poi.poifs.filesystem.DocumentEntry;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.LittleEndian;
 
-
-
-
 /**
  * The Object Factory takes in a stream and creates the low level objects
  * that represent the data.
  * @author  andy
  */
-public final class HDFObjectFactory
-{
+public final class HDFObjectFactory {
 
     /** OLE stuff*/
     private POIFSFileSystem _filesystem;
@@ -193,36 +181,26 @@ public final class HDFObjectFactory
         {
             throw new IOException("The text piece table is corrupted");
         }
-        else
-        {
-            //parse out the text pieces
-            int pieceTableSize = LittleEndian.getInt(_tableBuffer, ++pos);
-            pos += 4;
-            int pieces = (pieceTableSize - 4) / 12;
-            for (int x = 0; x < pieces; x++)
-            {
-                int filePos = LittleEndian.getInt(_tableBuffer, pos + ((pieces + 1) * 4) + (x * 8) + 2);
-                boolean unicode = false;
-                if ((filePos & 0x40000000) == 0)
-                {
-                    unicode = true;
-                }
-                else
-                {
-                    unicode = false;
-                    filePos &= ~(0x40000000);//gives me FC in doc stream
-                    filePos /= 2;
-                }
-                int totLength = LittleEndian.getInt(_tableBuffer, pos + (x + 1) * 4) -
-                                LittleEndian.getInt(_tableBuffer, pos + (x * 4));
-
-                TextPiece piece = new TextPiece(filePos, totLength, unicode);
-                _listener.text(piece);
-
+        //parse out the text pieces
+        int pieceTableSize = LittleEndian.getInt(_tableBuffer, ++pos);
+        pos += 4;
+        int pieces = (pieceTableSize - 4) / 12;
+        for (int x = 0; x < pieces; x++) {
+            int filePos = LittleEndian.getInt(_tableBuffer, pos + ((pieces + 1) * 4) + (x * 8) + 2);
+            boolean unicode = false;
+            if ((filePos & 0x40000000) == 0) {
+                unicode = true;
+            } else {
+                unicode = false;
+                filePos &= ~(0x40000000);//gives me FC in doc stream
+                filePos /= 2;
             }
+            int totLength = LittleEndian.getInt(_tableBuffer, pos + (x + 1) * 4) -
+                    LittleEndian.getInt(_tableBuffer, pos + (x * 4));
 
+            TextPiece piece = new TextPiece(filePos, totLength, unicode);
+            _listener.text(piece);
         }
-
     }
     /**
      * initializes all of the formatting properties for a Word Document
@@ -532,10 +510,7 @@ public final class HDFObjectFactory
           {
             break;
           }
-          else
-          {
-            x++;
-          }
+          x++;
       }
       //do the header sections
       for (; x < arraySize; x++)// && sectionEnd <= end; x++)
index 23409b54787e7b4fefb1e1e8c20fec9f95841e78..bd3bfb326bf172f67ace4b5318d9c500b1e418b1 100644 (file)
@@ -17,9 +17,6 @@
 
 package org.apache.poi.hdf.model.hdftypes;
 
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.LittleEndian;
-
 
 import org.apache.poi.hdf.model.hdftypes.definitions.FIBAbstractType;
 
index 99607f837ce1f6262ab55ee015042e9512e6ed4f..1bee95245a61a446d3c5ff58531240d6f997db7f 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hdf.model.hdftypes;
 
-import java.util.*;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.hdf.model.hdftypes.definitions.TCAbstractType;
 
@@ -29,9 +28,7 @@ import org.apache.poi.hdf.model.hdftypes.definitions.TCAbstractType;
  *
  * @author Ryan Ackley
  */
-
-public final class StyleSheet implements HDFType
-{
+public final class StyleSheet implements HDFType {
 
   private static final int NIL_STYLE = 4095;
   private static final int PAP_TYPE = 1;
index d49c46f85f5a2bdcead1d9f300daa45f13d04080..12d5fd2ce36762d08932a71992f9ba5b5b659d95 100644 (file)
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
 
-
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
 import org.apache.poi.hdf.model.hdftypes.HDFType;
 
 /**
index 0853175e47c8bac6ee4395b4f62cb268382c8592..289300029dce2485d39d4d356928d260078eab49 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.poi.hdf.model.hdftypes.definitions;
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
 import org.apache.poi.util.HexDump;
 import org.apache.poi.hdf.model.hdftypes.HDFType;
 
index 6a0f92025b7e19a3fc69c91872053fe0a0ead983..f60221eeeaa64d093fb073196ed365a3b07a8a90 100644 (file)
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
 
-
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
 import org.apache.poi.util.HexDump;
 import org.apache.poi.hdf.model.hdftypes.HDFType;
 
index f0bb7b8569c4a9438d1b3ed0de866b8c6b3995ba..0d825e49fd24e26fbbca753bdaf01a745e5a2508 100644 (file)
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
 
-
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
 import org.apache.poi.hdf.model.hdftypes.HDFType;
 
 /**
index 3de980e7d5a54cdcfd0ab5d6160c88eca479a3c7..e790f8d3bd6889bc16868d76884ffe4268d26403 100644 (file)
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
 
-
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
 import org.apache.poi.hdf.model.hdftypes.HDFType;
 
 /**
index d7d189627006518524138b6e485e0c7901f7b418..512dd37614dabc951712fdbf7c637ed0b79d0a50 100644 (file)
 
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
-
-
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
 import org.apache.poi.hdf.model.hdftypes.HDFType;
 
 /**
index 014958afc338243482618d790134939ea00abf5a..a365d65e53cb23e307f8983628ac791e09fd3840 100644 (file)
 
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
-
-
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
 import org.apache.poi.hdf.model.hdftypes.HDFType;
 
 /**
index 05d85fe6e0be301d67f188dc50a454976e266e27..c5e01646a8d10278dd26c9faeee2bb267576ace7 100644 (file)
@@ -26,9 +26,6 @@ import org.apache.poi.hslf.record.PersistPtrHolder;
 import org.apache.poi.hslf.record.Record;
 import org.apache.poi.hslf.record.UserEditAtom;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.poifs.filesystem.DocumentEntry;
-import org.apache.poi.poifs.filesystem.DocumentInputStream;
-import org.apache.poi.util.LittleEndian;
 
 /**
  * This class provides helper functions for determining if a
@@ -95,7 +92,9 @@ public final class EncryptedSlideShow
                                                hss.getUnderlyingBytes(),
                                                (int)cua.getCurrentEditOffset()
                                );
-                       } catch(ArrayIndexOutOfBoundsException e) {}
+                       } catch (ArrayIndexOutOfBoundsException e) {
+                               return null;
+                       }
                        if(r == null) { return null; }
                        if(! (r instanceof UserEditAtom)) { return null; }
                        UserEditAtom uea = (UserEditAtom)r;
index 1f1b13370ac1f322f3a5e493434ffe0bd9879fa5..182e96a44e0d1e2aacdc54b3a90c8e6f77e4e1de 100644 (file)
@@ -26,7 +26,6 @@ import java.io.InputStream;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.zip.InflaterInputStream;
-import java.util.zip.DeflaterOutputStream;
 
 /**
  * Represents EMF (Windows Enhanced Metafile) picture data.
index 8a4d5aeb81f35bae494495c93482da325fced4f4..c05d19acb041b6ee98a12753ed27ae165f2ad56b 100644 (file)
@@ -23,7 +23,6 @@ import org.apache.poi.hslf.usermodel.PictureData;
 import java.awt.*;
 import java.io.*;
 import java.util.zip.DeflaterOutputStream;
-import java.util.zip.InflaterInputStream;
 
 /**
  * Represents a metafile picture which can be one of the following types: EMF, WMF, or PICT.
index 5fe6bccec91d224149d33782d2b1ce7acce3665d..0796db8555832cb677ab085e53b00b57810e9ad6 100644 (file)
 
 package org.apache.poi.hslf.blip;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.zip.InflaterInputStream;
+
+import org.apache.poi.hslf.exceptions.HSLFException;
 import org.apache.poi.hslf.model.Picture;
 import org.apache.poi.hslf.model.Shape;
-import org.apache.poi.hslf.exceptions.HSLFException;
-import org.apache.poi.util.LittleEndian;
-
-import java.io.*;
-import java.util.zip.InflaterInputStream;
-import java.util.zip.DeflaterOutputStream;
 
 /**
  * Represents Macintosh PICT picture data.
index acc74276ad01396a67f3afb4bfeccacc64eb120d..4400c95594bc4022fb4b370493c1d918bce180ab 100644 (file)
@@ -25,7 +25,6 @@ import org.apache.poi.hslf.exceptions.HSLFException;
 
 import java.io.*;
 import java.util.zip.InflaterInputStream;
-import java.util.zip.DeflaterOutputStream;
 
 /**
  * Represents a WMF (Windows Metafile) picture data.
index 30001632754536f54ac3ce5c4cb3f43a74061e32..d9c1a2ae910069a128c0fa313c307a23b3f8b3ee 100644 (file)
 
 package org.apache.poi.hslf.dev;
 
-import java.util.*;
 import java.io.*;
 
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.poifs.filesystem.POIFSDocument;
 import org.apache.poi.poifs.filesystem.DocumentEntry;
 
 import org.apache.poi.ddf.*;
index 87662adedaedba1bcd2d08fbb31f40910c877cd6..f2e7b36dc2ddbcb5236b7d5d480db657c37c94c9 100644 (file)
@@ -33,7 +33,6 @@ import org.apache.poi.hslf.record.EscherTextboxWrapper;
 import org.apache.poi.hslf.record.TextCharsAtom;
 import org.apache.poi.hslf.record.TextBytesAtom;
 import org.apache.poi.hslf.record.StyleTextPropAtom;
-import org.apache.poi.hslf.record.Record;
 
 /**
  * This class provides a way to view the contents of a powerpoint file.
index 0ee4fbd0df9c4c0a146e4bebc97904b510791156..a919f61cdded44cf6ba3d28bf5e56a67edf71134 100644 (file)
@@ -22,7 +22,6 @@ import org.apache.poi.hslf.model.textproperties.BitMaskTextProp;
 import org.apache.poi.hslf.model.textproperties.TextProp;
 import org.apache.poi.hslf.model.textproperties.TextPropCollection;
 import org.apache.poi.hslf.record.*;
-import org.apache.poi.hslf.record.StyleTextPropAtom.*;
 
 import java.util.LinkedList;
 
index 73fd29604d569d3bacc0ed38b0e00d5cae7790e4..2d93a0678a6cf6f21cc63a256f893f8e3543b998 100644 (file)
 
 package org.apache.poi.hslf.dev;
 
-import org.apache.poi.hslf.*;
-import org.apache.poi.hslf.record.*;
+import java.io.ByteArrayOutputStream;
+import java.util.Hashtable;
 
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.poifs.filesystem.POIFSDocument;
-import org.apache.poi.poifs.filesystem.DocumentEntry;
-import org.apache.poi.poifs.filesystem.DocumentInputStream;
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.record.*;
 import org.apache.poi.util.LittleEndian;
 
-import java.io.*;
-import java.util.Hashtable;
-
 /**
  * Uses record level code to locate UserEditAtom records, and other
  *  persistence related atoms. Tries to match them together, to help
index 9dfa6ce9d0c05f678285d72fa509984a435db80f..b2182edcd6e3520868822b952bbc72a285528871 100644 (file)
@@ -21,9 +21,7 @@ import java.io.*;
 import java.util.Vector;
 
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.poifs.filesystem.POIFSDocument;
 import org.apache.poi.poifs.filesystem.DocumentEntry;
-import org.apache.poi.poifs.filesystem.DocumentInputStream;
 import org.apache.poi.util.LittleEndian;
 
 import org.apache.poi.hslf.record.CString;
index 545ffdffe1029ad4ddf7c5284c05b71cda5efedf..302415068b92535cb498b0c8122d270eb5f2ff08 100755 (executable)
@@ -20,7 +20,6 @@ package org.apache.poi.hslf.model;
 import org.apache.poi.ddf.*;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogger;
-import org.apache.poi.util.HexDump;
 
 import java.awt.geom.*;
 import java.util.ArrayList;
index f3968448c402c01e0d73da495fe2324cc3af2e5a..c3cfaba90f13d76f66f9f88edf1ce340577fa926 100644 (file)
@@ -18,9 +18,6 @@
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.hslf.record.SheetContainer;
-import org.apache.poi.hslf.record.Record;
-import org.apache.poi.hslf.record.RecordTypes;
-import org.apache.poi.hslf.record.OEPlaceholderAtom;
 import org.apache.poi.hslf.model.textproperties.TextProp;
 
 /**
@@ -55,5 +52,4 @@ public abstract class MasterSheet extends Sheet {
         TextShape tx = (TextShape)shape;
         return tx.getPlaceholderAtom() != null;
     }
-
 }
index 72fcbd6af7e2e01b0d89773fe9db43c2dd3c4f4e..408dfc47e7ca3f7edd744ba13c105cc4f5aa4209 100644 (file)
@@ -28,13 +28,11 @@ import org.apache.poi.util.POILogger;
 import javax.imageio.ImageIO;
 import java.awt.image.BufferedImage;
 import java.awt.*;
-import java.awt.geom.Rectangle2D;
 import java.awt.geom.AffineTransform;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.List;
-import java.util.Arrays;
 
 
 /**
index 71716fe4b891ba465c8c97e23e39be3d69eaffe2..945d3195c4d4222e8532d8fbaff344ff38dfcc72 100644 (file)
@@ -21,7 +21,6 @@ import org.apache.poi.ddf.*;
 import org.apache.poi.hslf.record.OEPlaceholderAtom;
 import org.apache.poi.hslf.exceptions.HSLFException;
 
-import java.util.List;
 import java.io.ByteArrayOutputStream;
 
 /**
index 3971d5216db0ee0e49a847343ec00d2fb924f216..49cc01f64123f1963d5f0bf1d6e3aaa938bf042b 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
 import org.apache.poi.hslf.record.ColorSchemeAtom;
-import org.apache.poi.hslf.record.PPDrawing;
 import org.apache.poi.util.POILogger;
 import org.apache.poi.util.POILogFactory;
 
index 6ce6368e5141c415417f158bf200d70b7784c22e..f42eb8429c53c048b300bc407d703e4d77c8ab14 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.poi.hslf.model;
 import org.apache.poi.ddf.*;
 import org.apache.poi.hslf.record.*;
 import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.util.POILogger;
 
 import java.util.ArrayList;
 import java.util.Iterator;
index d8198283bdd634bfa98bb6cd754c114030abc9ed..d03fc1db199f5502b1a3e853db207942889e9bef 100755 (executable)
@@ -18,7 +18,6 @@
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.record.TextHeaderAtom;
 
 import java.awt.*;
 
index f297ff0263721a5e8f5f0019b674d99a098f5710..6ae2323927953acddfd06f08d6a3383d87354ff0 100755 (executable)
 
 package org.apache.poi.hslf.model;
 
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.record.TextRulerAtom;
-import org.apache.poi.util.POILogger;
-import org.apache.poi.util.POILogFactory;
-
-import java.text.AttributedString;
-import java.text.AttributedCharacterIterator;
-import java.text.BreakIterator;
-import java.awt.font.TextAttribute;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.font.FontRenderContext;
 import java.awt.font.LineBreakMeasurer;
+import java.awt.font.TextAttribute;
 import java.awt.font.TextLayout;
-import java.awt.font.FontRenderContext;
-import java.awt.*;
-import java.awt.geom.Rectangle2D;
 import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.text.AttributedCharacterIterator;
+import java.text.AttributedString;
 import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.poi.hslf.record.TextRulerAtom;
+import org.apache.poi.hslf.usermodel.RichTextRun;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 /**
  * Paint text into java.awt.Graphics2D
@@ -162,7 +164,7 @@ public final class TextPainter {
         int paragraphStart = it.getBeginIndex();
         int paragraphEnd = it.getEndIndex();
 
-        ArrayList lines = new ArrayList();
+        List<TextElement> lines = new ArrayList<TextElement>();
         LineBreakMeasurer measurer = new LineBreakMeasurer(it, frc);
         measurer.setPosition(paragraphStart);
         while (measurer.getPosition() < paragraphEnd) {
@@ -296,7 +298,7 @@ public final class TextPainter {
 
         //finally draw the text fragments
         TextElement[] elems = new TextElement[lines.size()];
-        return (TextElement[])lines.toArray(elems);
+        return lines.toArray(elems);
     }
 
     public static class TextElement {
index 6260c62cac0eb9a15ab01e633e7b25e7bcf4d171..aa24b6c3db678bfd0aca5be3b533ff783ed9ab11 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hslf.model;
 
 import java.util.LinkedList;
 import java.util.Vector;
-import java.util.List;
 
 import org.apache.poi.hslf.model.textproperties.TextPropCollection;
 import org.apache.poi.hslf.record.*;
index a4d823be55029b03f1e378307304684d1f62ba18..5724e270fa9ba610ade86f8a7d6ab431e2232b1e 100755 (executable)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -30,7 +29,6 @@ import java.awt.geom.AffineTransform;
 import java.awt.font.FontRenderContext;
 import java.awt.font.TextLayout;
 import java.io.IOException;
-import java.util.Iterator;
 
 /**
  * A common superclass of all shapes that can hold text.
@@ -88,7 +86,7 @@ public abstract class TextShape extends SimpleShape {
 
     /**
      * Create a TextBox object and initialize it from the supplied Record container.
-     * 
+     *
      * @param escherRecord       <code>EscherSpContainer</code> container which holds information about this shape
      * @param parent    the parent of the shape
      */
@@ -230,23 +228,23 @@ public abstract class TextShape extends SimpleShape {
         String fntname = rt.getFontName();
         Font font = new Font(fntname, style, size);
 
-        float width = 0, height = 0, leading = 0;        
-        String[] lines = txt.split("\n");        
+        float width = 0, height = 0, leading = 0;
+        String[] lines = txt.split("\n");
         for (int i = 0; i < lines.length; i++) {
             if(lines[i].length() == 0) continue;
-            
+
             TextLayout layout = new TextLayout(lines[i], font, _frc);
-            
-            leading = Math.max(leading, layout.getLeading());           
+
+            leading = Math.max(leading, layout.getLeading());
             width = Math.max(width, layout.getAdvance());
             height = Math.max(height, (height + (layout.getDescent() + layout.getAscent())));
-        }      
-       
+        }
+
         // add one character to width
-        Rectangle2D charBounds = font.getMaxCharBounds(_frc);                
+        Rectangle2D charBounds = font.getMaxCharBounds(_frc);
         width += getMarginLeft() + getMarginRight() + charBounds.getWidth();
-        
-        // add leading to height        
+
+        // add leading to height
         height += getMarginTop() + getMarginBottom() + leading;
 
         Rectangle2D anchor = getAnchor2D();
index 731a3b51c92669b3d5f9a96991846d2d6d4d4b7c..a2ed09c79a9dabed474543d549dad713471422fa 100755 (executable)
@@ -19,9 +19,7 @@ package org.apache.poi.hslf.record;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Date;
 
-import org.apache.poi.hslf.util.SystemTimeUtils;
 import org.apache.poi.util.LittleEndian;
 
 /**
@@ -29,8 +27,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Yegor Kozlov
  */
-public final class AnimationInfoAtom extends RecordAtom
-{
+public final class AnimationInfoAtom extends RecordAtom {
 
     /**
      * whether the animation plays in the reverse direction
index bf7860454a7189656c8e27c237bf84461f9d8bc8..c473feacea2b564e3a5397979ea9d18dd74df684 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hslf.record;
 
-import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.StringUtil;
 
 import java.io.IOException;
@@ -29,9 +28,7 @@ import java.io.OutputStream;
  *
  * @author Nick Burch
  */
-
-public final class DocumentEncryptionAtom extends RecordAtom
-{
+public final class DocumentEncryptionAtom extends RecordAtom {
        private byte[] _header;
        private static long _type = 12052l;
 
index 5d09e53a1989cd35ccd3bf6482556701050e14c7..62a5c4bbe36a3d027abd7078d823a621993623b0 100755 (executable)
 
 package org.apache.poi.hslf.record;
 
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
 
 /**
  * A container record that specifies information about a movie stored externally.
@@ -50,5 +45,4 @@ public final class ExAviMovie extends ExMCIMovie {
     public long getRecordType() {
         return RecordTypes.ExAviMovie.typeID;
     }
-
 }
index 7df5a903dbf6d03593a3a5c22399a85580b76fb1..2b0d1e2c37adc313b32a598e89f74b7bbbb54ace 100755 (executable)
 
 package org.apache.poi.hslf.record;
 
-import java.io.OutputStream;
-import java.io.IOException;
-
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
 
 /**
  * A container record that specifies information about an ActiveX control. It contains:
index 14c37076b515881a42ebbc047899ff7a8aefbca3..99deafdbf22f364f64e91e36a8b9bf3a01bb1893 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hslf.record;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Date;
 
-import org.apache.poi.hslf.util.SystemTimeUtils;
 import org.apache.poi.util.LittleEndian;
 
 /**
@@ -31,9 +28,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Nick Burch
  */
-
-public class ExHyperlinkAtom extends RecordAtom
-{
+public final class ExHyperlinkAtom extends RecordAtom {
     /**
      * Record header.
      */
@@ -53,7 +48,7 @@ public class ExHyperlinkAtom extends RecordAtom
 
         LittleEndian.putShort(_header, 2, (short)getRecordType());
         LittleEndian.putInt(_header, 4, _data.length);
-        
+
         // It is fine for the other values to be zero
     }
 
@@ -69,11 +64,11 @@ public class ExHyperlinkAtom extends RecordAtom
         // Get the header.
         _header = new byte[8];
         System.arraycopy(source,start,_header,0,8);
-        
+
         // Get the record data.
         _data = new byte[len-8];
         System.arraycopy(source,start+8,_data,0,len-8);
-        
+
         // Must be at least 4 bytes long
         if(_data.length < 4) {
                throw new IllegalArgumentException("The length of the data for a ExHyperlinkAtom must be at least 4 bytes, but was only " + _data.length);
@@ -96,7 +91,7 @@ public class ExHyperlinkAtom extends RecordAtom
     public void setNumber(int number) {
         LittleEndian.putInt(_data,0,number);
     }
-    
+
     /**
      * Gets the record type.
      * @return the record type.
index ee38bece75ac83a0aa536ceeb58195cda636470d..058f27ea5c2421c8d167fd0d062b23b6a60bd8ad 100755 (executable)
@@ -19,9 +19,7 @@ package org.apache.poi.hslf.record;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Date;
 
-import org.apache.poi.hslf.util.SystemTimeUtils;
 import org.apache.poi.util.LittleEndian;
 
 /**
index 54284e028f7ab5e24a543ac447a33535841842f8..40ddc569b961a711f4bfcd4f5ead9f53b9339fe9 100644 (file)
@@ -18,7 +18,6 @@
 package org.apache.poi.hslf.record;
 
 import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
index 0ee8cd883f5f607b937912f0ecc58a1cfe45a9b4..6dd8fccf6bf729a95f98a78899a454c1bbacdb4a 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hslf.record;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Date;
 
-import org.apache.poi.hslf.util.SystemTimeUtils;
 import org.apache.poi.util.LittleEndian;
 
 /**
@@ -32,9 +29,7 @@ import org.apache.poi.util.LittleEndian;
  * @author Nick Burch
  * @author Yegor Kozlov
  */
-
-public class InteractiveInfoAtom extends RecordAtom
-{
+public class InteractiveInfoAtom extends RecordAtom {
 
     /**
      * Action Table
@@ -92,7 +87,7 @@ public class InteractiveInfoAtom extends RecordAtom
 
         LittleEndian.putShort(_header, 2, (short)getRecordType());
         LittleEndian.putInt(_header, 4, _data.length);
-        
+
         // It is fine for the other values to be zero
     }
 
@@ -108,16 +103,16 @@ public class InteractiveInfoAtom extends RecordAtom
         // Get the header.
         _header = new byte[8];
         System.arraycopy(source,start,_header,0,8);
-        
+
         // Get the record data.
         _data = new byte[len-8];
         System.arraycopy(source,start+8,_data,0,len-8);
-        
+
         // Must be at least 16 bytes long
         if(_data.length < 16) {
                throw new IllegalArgumentException("The length of the data for a InteractiveInfoAtom must be at least 16 bytes, but was only " + _data.length);
         }
-        
+
         // First 4 bytes - no idea, normally 0
         // Second 4 bytes - the id of the link (from 1 onwards)
         // Third 4 bytes - no idea, normally 4
@@ -141,7 +136,7 @@ public class InteractiveInfoAtom extends RecordAtom
     public void setHyperlinkID(int number) {
         LittleEndian.putInt(_data,4,number);
     }
-    
+
     /**
      * a reference to a sound in the sound collection.
      */
index 0c1f02b389703bb96d9a446df01276617fa1fedb..4424e2db75e8c2cb762eaf5941b590287f6d22bc 100644 (file)
@@ -21,25 +21,21 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
 
-import org.apache.poi.util.LittleEndian;
-
 /**
  * Master slide
  *
  * @author Yegor Kozlov
  */
-
-public final class MainMaster extends SheetContainer
-{
+public final class MainMaster extends SheetContainer {
        private byte[] _header;
        private static long _type = 1016;
 
        // Links to our more interesting children
        private SlideAtom slideAtom;
        private PPDrawing ppDrawing;
-    private TxMasterStyleAtom[] txmasters;
-    private ColorSchemeAtom[] clrscheme;
-    private ColorSchemeAtom _colorScheme;
+       private TxMasterStyleAtom[] txmasters;
+       private ColorSchemeAtom[] clrscheme;
+       private ColorSchemeAtom _colorScheme;
 
        /**
         * Returns the SlideAtom of this Slide
@@ -52,9 +48,9 @@ public final class MainMaster extends SheetContainer
         */
        public PPDrawing getPPDrawing() { return ppDrawing; }
 
-    public TxMasterStyleAtom[] getTxMasterStyleAtoms() { return txmasters; }
+       public TxMasterStyleAtom[] getTxMasterStyleAtoms() { return txmasters; }
 
-    public ColorSchemeAtom[] getColorSchemeAtoms() { return clrscheme; }
+       public ColorSchemeAtom[] getColorSchemeAtoms() { return clrscheme; }
 
        /**
         * Set things up, and find our more interesting children
@@ -67,27 +63,27 @@ public final class MainMaster extends SheetContainer
                // Find our children
                _children = Record.findChildRecords(source,start+8,len-8);
 
-        ArrayList tx = new ArrayList();
-        ArrayList clr = new ArrayList();
+               ArrayList tx = new ArrayList();
+               ArrayList clr = new ArrayList();
                // Find the interesting ones in there
                for(int i=0; i<_children.length; i++) {
                        if(_children[i] instanceof SlideAtom) {
                                slideAtom = (SlideAtom)_children[i];
                        } else if(_children[i] instanceof PPDrawing) {
                                ppDrawing = (PPDrawing)_children[i];
-            } else if(_children[i] instanceof TxMasterStyleAtom) {
-                tx.add(_children[i]);
-            } else if(_children[i] instanceof ColorSchemeAtom) {
-                clr.add(_children[i]);
+                       } else if(_children[i] instanceof TxMasterStyleAtom) {
+                               tx.add(_children[i]);
+                       } else if(_children[i] instanceof ColorSchemeAtom) {
+                               clr.add(_children[i]);
                        }
 
-            if(ppDrawing != null && _children[i] instanceof ColorSchemeAtom) {
-                _colorScheme = (ColorSchemeAtom)_children[i];
-            }
+                       if(ppDrawing != null && _children[i] instanceof ColorSchemeAtom) {
+                               _colorScheme = (ColorSchemeAtom)_children[i];
+                       }
 
                }
-        txmasters = (TxMasterStyleAtom[])tx.toArray(new TxMasterStyleAtom[tx.size()]);
-        clrscheme = (ColorSchemeAtom[])clr.toArray(new ColorSchemeAtom[clr.size()]);
+               txmasters = (TxMasterStyleAtom[])tx.toArray(new TxMasterStyleAtom[tx.size()]);
+               clrscheme = (ColorSchemeAtom[])clr.toArray(new ColorSchemeAtom[clr.size()]);
        }
 
        /**
@@ -103,8 +99,7 @@ public final class MainMaster extends SheetContainer
                writeOut(_header[0],_header[1],_type,_children,out);
        }
 
-    public ColorSchemeAtom getColorScheme(){
-        return _colorScheme;
-    }
-
+       public ColorSchemeAtom getColorScheme(){
+               return _colorScheme;
+       }
 }
index f0975a152ebe83f36a0812dbc15c04acf4dd400e..00b873f6de5e32eb914fc5e60e5255b32496ed36 100755 (executable)
@@ -19,9 +19,7 @@ package org.apache.poi.hslf.record;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Date;
 
-import org.apache.poi.hslf.util.SystemTimeUtils;
 import org.apache.poi.util.LittleEndian;
 
 /**
index 519154c5b54a7b8412e66a7ae8bbd35c09216dfc..b77be59c26af3c764a59ac3e07a516faadc3d79d 100644 (file)
@@ -22,7 +22,6 @@ import org.apache.poi.util.POILogger;
 
 import org.apache.poi.ddf.*;
 import org.apache.poi.hslf.model.ShapeTypes;
-import org.apache.poi.hslf.model.Shape;
 
 import java.io.IOException;
 import java.io.OutputStream;
@@ -44,16 +43,15 @@ import java.util.Iterator;
 
 // For now, pretending to be an atom. Might not always be, but that
 //  would require a wrapping class
-public final class PPDrawing extends RecordAtom
-{
+public final class PPDrawing extends RecordAtom {
        private byte[] _header;
        private long _type;
 
        private EscherRecord[] childRecords;
        private EscherTextboxWrapper[] textboxWrappers;
 
-    //cached EscherDgRecord
-    private EscherDgRecord dg;
+       //cached EscherDgRecord
+       private EscherDgRecord dg;
 
        /**
         * Get access to the underlying Escher Records
@@ -110,7 +108,7 @@ public final class PPDrawing extends RecordAtom
        public PPDrawing(){
                _header = new byte[8];
                LittleEndian.putUShort(_header, 0, 15);
-               LittleEndian.putUShort(_header, 2, (int)RecordTypes.PPDrawing.typeID);
+               LittleEndian.putUShort(_header, 2, RecordTypes.PPDrawing.typeID);
                LittleEndian.putInt(_header, 4, 0);
 
                textboxWrappers = new EscherTextboxWrapper[]{};
@@ -122,7 +120,7 @@ public final class PPDrawing extends RecordAtom
         */
        private void findEscherChildren(DefaultEscherRecordFactory erf, byte[] source, int startPos, int lenToGo, Vector found) {
 
-        int escherBytes = LittleEndian.getInt( source, startPos + 4 ) + 8;
+               int escherBytes = LittleEndian.getInt( source, startPos + 4 ) + 8;
 
                // Find the record
                EscherRecord r = erf.createRecord(source,startPos);
@@ -137,16 +135,16 @@ public final class PPDrawing extends RecordAtom
                        logger.log(POILogger.WARN, "Hit short DDF record at " + startPos + " - " + size);
                }
 
-        /**
-         * Sanity check. Always advance the cursor by the correct value.
-         *
-         * getRecordSize() must return exatcly the same number of bytes that was written in fillFields.
-         * Sometimes it is not so, see an example in bug #44770. Most likely reason is that one of ddf records calculates wrong size.
-         */
-        if(size != escherBytes){
-            logger.log(POILogger.WARN, "Record length=" + escherBytes + " but getRecordSize() returned " + r.getRecordSize() + "; record: " + r.getClass());
-            size = escherBytes;
-        }
+               /**
+                * Sanity check. Always advance the cursor by the correct value.
+                *
+                * getRecordSize() must return exatcly the same number of bytes that was written in fillFields.
+                * Sometimes it is not so, see an example in bug #44770. Most likely reason is that one of ddf records calculates wrong size.
+                */
+               if(size != escherBytes){
+                       logger.log(POILogger.WARN, "Record length=" + escherBytes + " but getRecordSize() returned " + r.getRecordSize() + "; record: " + r.getClass());
+                       size = escherBytes;
+               }
                startPos += size;
                lenToGo -= size;
                if(lenToGo >= 8) {
@@ -163,13 +161,13 @@ public final class PPDrawing extends RecordAtom
                                EscherTextboxRecord tbr = (EscherTextboxRecord)toSearch[i];
                                EscherTextboxWrapper w = new EscherTextboxWrapper(tbr);
                                found.add(w);
-                for (int j = i; j >= 0; j--) {
-                    if(toSearch[j] instanceof EscherSpRecord){
-                        EscherSpRecord sp = (EscherSpRecord)toSearch[j];
-                        w.setShapeId(sp.getShapeId());
-                        break;
-                    }
-                }
+                               for (int j = i; j >= 0; j--) {
+                                       if(toSearch[j] instanceof EscherSpRecord){
+                                               EscherSpRecord sp = (EscherSpRecord)toSearch[j];
+                                               w.setShapeId(sp.getShapeId());
+                                               break;
+                                       }
+                               }
                        } else {
                                // If it has children, walk them
                                if(toSearch[i].isContainerRecord()) {
@@ -297,23 +295,22 @@ public final class PPDrawing extends RecordAtom
                textboxWrappers = tw;
        }
 
-    /**
-     * Return EscherDgRecord which keeps track of the number of shapes and shapeId in this drawing group
-     *
-     * @return EscherDgRecord
-     */
-    public EscherDgRecord getEscherDgRecord(){
-        if(dg == null){
-            EscherContainerRecord dgContainer = (EscherContainerRecord)childRecords[0];
-            for(Iterator<EscherRecord> it = dgContainer.getChildIterator(); it.hasNext();){
-                EscherRecord r = it.next();
-                if(r instanceof EscherDgRecord){
-                    dg = (EscherDgRecord)r;
-                    break;
-                }
-            }
-        }
-        return dg;
-    }
-
+       /**
+        * Return EscherDgRecord which keeps track of the number of shapes and shapeId in this drawing group
+        *
+        * @return EscherDgRecord
+        */
+       public EscherDgRecord getEscherDgRecord(){
+               if(dg == null){
+                       EscherContainerRecord dgContainer = (EscherContainerRecord)childRecords[0];
+                       for(Iterator<EscherRecord> it = dgContainer.getChildIterator(); it.hasNext();){
+                               EscherRecord r = it.next();
+                               if(r instanceof EscherDgRecord){
+                                       dg = (EscherDgRecord)r;
+                                       break;
+                               }
+                       }
+               }
+               return dg;
+       }
 }
index 08d523c3e1106144bba5e2b275c9b98e078e2d4e..ee414bba9b4b89656e4998e407a579c415e46a51 100644 (file)
@@ -23,7 +23,6 @@ import org.apache.poi.util.LittleEndian;
 import java.io.OutputStream;
 import java.io.IOException;
 import java.io.ByteArrayOutputStream;
-import java.util.List;
 import java.util.Iterator;
 
 /**
index 26b9e95f17bc339a35b0c86d5efeb634c6acedfb..412beb1fc2819c5a5b14844c70952ec22c77d3d4 100644 (file)
@@ -19,10 +19,6 @@ package org.apache.poi.hslf.record;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Date;
-
-import org.apache.poi.hslf.util.SystemTimeUtils;
-import org.apache.poi.util.LittleEndian;
 
 /**
  * An atom record that specifies that a shape is a header or footer placeholder shape
@@ -30,9 +26,7 @@ import org.apache.poi.util.LittleEndian;
  * @since  PowerPoint 2007
  * @author Yegor Kozlov
  */
-
-public final class RoundTripHFPlaceholder12 extends RecordAtom
-{
+public final class RoundTripHFPlaceholder12 extends RecordAtom {
     /**
      * Record header.
      */
index 11bd4752c7d0c10f465e2715fc861b270aaca95e..45fbd724793b5450cb1bee2ff1736fdef87cb209 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hslf.record;
 
-import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.LittleEndian;
 
 import java.io.IOException;
@@ -46,26 +45,25 @@ import java.util.Vector;
  */
 
 // For now, pretend to be an atom
-public final class SlideListWithText extends RecordContainer
-{
-
-    /**
-     * Instance filed of the record header indicates that this SlideListWithText stores
-     * references to slides
-     */
-    public static final int SLIDES = 0;
-    /**
-     * Instance filed of the record header indicates that this SlideListWithText stores
-     * references to master slides
-     */
-    public static final int MASTER = 1;
-    /**
-     * Instance filed of the record header indicates that this SlideListWithText stores
-     * references to notes
-     */
-    public static final int NOTES = 2;
-
-    private byte[] _header;
+public final class SlideListWithText extends RecordContainer {
+
+       /**
+        * Instance filed of the record header indicates that this SlideListWithText stores
+        * references to slides
+        */
+       public static final int SLIDES = 0;
+       /**
+        * Instance filed of the record header indicates that this SlideListWithText stores
+        * references to master slides
+        */
+       public static final int MASTER = 1;
+       /**
+        * Instance filed of the record header indicates that this SlideListWithText stores
+        * references to notes
+        */
+       public static final int NOTES = 2;
+
+       private byte[] _header;
        private static long _type = 4080;
 
        private SlideAtomsSet[] slideAtomsSets;
@@ -148,23 +146,23 @@ public final class SlideListWithText extends RecordContainer
                slideAtomsSets = sas;
        }
 
-    public int getInstance(){
-        return LittleEndian.getShort(_header, 0) >> 4;
-    }
+       public int getInstance(){
+               return LittleEndian.getShort(_header, 0) >> 4;
+       }
 
-    public void setInstance(int inst){
-        LittleEndian.putShort(_header, (short)((inst << 4) | 0xF));
-    }
+       public void setInstance(int inst){
+               LittleEndian.putShort(_header, (short)((inst << 4) | 0xF));
+       }
 
-    /**
+       /**
         * Get access to the SlideAtomsSets of the children of this record
         */
        public SlideAtomsSet[] getSlideAtomsSets() { return slideAtomsSets; }
 
-    /**
-    * Get access to the SlideAtomsSets of the children of this record
-    */
-    public void setSlideAtomsSets( SlideAtomsSet[] sas ) { slideAtomsSets = sas; }
+       /**
+       * Get access to the SlideAtomsSets of the children of this record
+       */
+       public void setSlideAtomsSets( SlideAtomsSet[] sas ) { slideAtomsSets = sas; }
 
        /**
         * Return the value we were given at creation
index 8d86b175e7196bfdf74b181822fe3cf1d928fbcb..abea3887f0d5f97819f30beb272cb4ad930df1d6 100755 (executable)
@@ -17,8 +17,6 @@
 
 package org.apache.poi.hslf.record;
 
-import org.apache.poi.util.POILogger;
-
 import java.io.OutputStream;
 import java.io.IOException;
 
index 6492d0175cba467742c4a8c5f4814f1f14329f79..32aa9592d39fa8d88a15cba7aa8f02122abd321f 100755 (executable)
 
 package org.apache.poi.hslf.record;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.zip.InflaterInputStream;
 
 import org.apache.poi.util.LittleEndian;
 
index 052126e1278644a63015139baef28b5b513cfa88..84f03b47246328b60542f5262cddc907e67d4c3e 100755 (executable)
 
 package org.apache.poi.hslf.record;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.zip.InflaterInputStream;
 
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogger;
index b456798bae989779fbc29a424b42bd7e84805078..8399e4899013b4beebbcf33504a378f4b724e12f 100644 (file)
@@ -38,220 +38,212 @@ import org.apache.poi.hslf.model.Notes;
 import org.apache.poi.hslf.model.Slide;
 import org.apache.poi.hslf.record.*;
 import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
-import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 
 /**
  * This class is a friendly wrapper on top of the more scary HSLFSlideShow.
  *
- * TODO:
- *  - figure out how to match notes to their correct sheet
- *    (will involve understanding DocSlideList and DocNotesList)
- *  - handle Slide creation cleaner
+ * TODO: - figure out how to match notes to their correct sheet (will involve
+ * understanding DocSlideList and DocNotesList) - handle Slide creation cleaner
  *
  * @author Nick Burch
  * @author Yegor kozlov
  */
 public final class SlideShow {
-  // What we're based on
-  private HSLFSlideShow _hslfSlideShow;
-
-  // Low level contents, as taken from HSLFSlideShow
-  private Record[] _records;
-
-  // Pointers to the most recent versions of the core records
-  //  (Document, Notes, Slide etc)
-  private Record[] _mostRecentCoreRecords;
-  // Lookup between the PersitPtr "sheet" IDs, and the position
-  //  in the mostRecentCoreRecords array
-  private Hashtable _sheetIdToCoreRecordsLookup;
-
-  // Records that are interesting
-  private Document _documentRecord;
-
-  // Friendly objects for people to deal with
-  private SlideMaster[] _masters;
-  private TitleMaster[] _titleMasters;
-  private Slide[] _slides;
-  private Notes[] _notes;
-  private FontCollection _fonts;
-
-  // For logging
-    private POILogger logger = POILogFactory.getLogger(this.getClass());
-
-
-  /* ===============================================================
-   *                       Setup Code
-   * ===============================================================
-   */
-
-
-  /**
-   * Constructs a Powerpoint document from the underlying
-   * HSLFSlideShow object. Finds the model stuff from this
-   *
-   * @param hslfSlideShow the HSLFSlideShow to base on
-   */
-  public SlideShow(HSLFSlideShow hslfSlideShow) {
+       // What we're based on
+       private HSLFSlideShow _hslfSlideShow;
+
+       // Low level contents, as taken from HSLFSlideShow
+       private Record[] _records;
+
+       // Pointers to the most recent versions of the core records
+       // (Document, Notes, Slide etc)
+       private Record[] _mostRecentCoreRecords;
+       // Lookup between the PersitPtr "sheet" IDs, and the position
+       // in the mostRecentCoreRecords array
+       private Hashtable _sheetIdToCoreRecordsLookup;
+
+       // Records that are interesting
+       private Document _documentRecord;
+
+       // Friendly objects for people to deal with
+       private SlideMaster[] _masters;
+       private TitleMaster[] _titleMasters;
+       private Slide[] _slides;
+       private Notes[] _notes;
+       private FontCollection _fonts;
+
+       // For logging
+       private POILogger logger = POILogFactory.getLogger(this.getClass());
+
+
+       /* ===============================================================
+        *                       Setup Code
+        * ===============================================================
+        */
+
+
+       /**
+        * Constructs a Powerpoint document from the underlying
+        * HSLFSlideShow object. Finds the model stuff from this
+        *
+        * @param hslfSlideShow the HSLFSlideShow to base on
+        */
+       public SlideShow(HSLFSlideShow hslfSlideShow) {
        // Get useful things from our base slideshow
-    _hslfSlideShow = hslfSlideShow;
-       _records = _hslfSlideShow.getRecords();
+       _hslfSlideShow = hslfSlideShow;
+               _records = _hslfSlideShow.getRecords();
 
-       // Handle Parent-aware Reocrds
-       for(int i=0; i<_records.length; i++) {
-               handleParentAwareRecords(_records[i]);
+               // Handle Parent-aware Reocrds
+               for (int i = 0; i < _records.length; i++) {
+                       handleParentAwareRecords(_records[i]);
+               }
+
+               // Find the versions of the core records we'll want to use
+               findMostRecentCoreRecords();
+
+               // Build up the model level Slides and Notes
+               buildSlidesAndNotes();
        }
 
-       // Find the versions of the core records we'll want to use
-       findMostRecentCoreRecords();
-
-       // Build up the model level Slides and Notes
-       buildSlidesAndNotes();
-  }
-
-  /**
-   * Constructs a new, empty, Powerpoint document.
-   */
-  public SlideShow() {
-       this(HSLFSlideShow.create());
-  }
-
-    /**
-     * Constructs a Powerpoint document from an input stream.
-     */
-    public SlideShow(InputStream inputStream) throws IOException {
-      this(new HSLFSlideShow(inputStream));
-    }
-
-  /**
-   * Find the records that are parent-aware, and tell them
-   *  who their parent is
-   */
-  private void handleParentAwareRecords(Record baseRecord) {
-         // Only need to do something if this is a container record
-         if(baseRecord instanceof RecordContainer) {
-               RecordContainer br = (RecordContainer)baseRecord;
-               Record[] childRecords = br.getChildRecords();
-
-               // Loop over child records, looking for interesting ones
-               for(int i=0; i<childRecords.length; i++) {
-                       Record record = childRecords[i];
-                       // Tell parent aware records of their parent
-                       if(record instanceof ParentAwareRecord) {
-                               ((ParentAwareRecord)record).setParentRecord(br);
-                       }
-                       // Walk on down for the case of container records
-                       if(record instanceof RecordContainer) {
-                               handleParentAwareRecords(record);
+       /**
+        * Constructs a new, empty, Powerpoint document.
+        */
+       public SlideShow() {
+               this(HSLFSlideShow.create());
+       }
+
+       /**
+        * Constructs a Powerpoint document from an input stream.
+        */
+       public SlideShow(InputStream inputStream) throws IOException {
+               this(new HSLFSlideShow(inputStream));
+       }
+
+       /**
+        * Find the records that are parent-aware, and tell them who their parent is
+        */
+       private void handleParentAwareRecords(Record baseRecord) {
+               // Only need to do something if this is a container record
+               if (baseRecord instanceof RecordContainer) {
+                       RecordContainer br = (RecordContainer) baseRecord;
+                       Record[] childRecords = br.getChildRecords();
+
+                       // Loop over child records, looking for interesting ones
+                       for (int i = 0; i < childRecords.length; i++) {
+                               Record record = childRecords[i];
+                               // Tell parent aware records of their parent
+                               if (record instanceof ParentAwareRecord) {
+                                       ((ParentAwareRecord) record).setParentRecord(br);
+                               }
+                               // Walk on down for the case of container records
+                               if (record instanceof RecordContainer) {
+                                       handleParentAwareRecords(record);
+                               }
                        }
                }
-         }
-  }
-
-
-  /**
-   * Use the PersistPtrHolder entries to figure out what is
-   *  the "most recent" version of all the core records
-   *  (Document, Notes, Slide etc), and save a record of them.
-   * Do this by walking from the oldest PersistPtr to the newest,
-   *  overwriting any references found along the way with newer ones
-   */
-  private void findMostRecentCoreRecords() {
-       // To start with, find the most recent in the byte offset domain
-       Hashtable mostRecentByBytes = new Hashtable();
-       for(int i=0; i<_records.length; i++) {
-               if(_records[i] instanceof PersistPtrHolder) {
-                       PersistPtrHolder pph = (PersistPtrHolder)_records[i];
-
-                       // If we've already seen any of the "slide" IDs for this
-                       //  PersistPtr, remove their old positions
-                       int[] ids = pph.getKnownSlideIDs();
-                       for(int j=0; j<ids.length; j++) {
-                               Integer id = new Integer(ids[j]);
-                               if( mostRecentByBytes.containsKey(id)) {
-                                       mostRecentByBytes.remove(id);
+       }
+
+       /**
+        * Use the PersistPtrHolder entries to figure out what is the "most recent"
+        * version of all the core records (Document, Notes, Slide etc), and save a
+        * record of them. Do this by walking from the oldest PersistPtr to the
+        * newest, overwriting any references found along the way with newer ones
+        */
+       private void findMostRecentCoreRecords() {
+               // To start with, find the most recent in the byte offset domain
+               Hashtable mostRecentByBytes = new Hashtable();
+               for (int i = 0; i < _records.length; i++) {
+                       if (_records[i] instanceof PersistPtrHolder) {
+                               PersistPtrHolder pph = (PersistPtrHolder) _records[i];
+
+                               // If we've already seen any of the "slide" IDs for this
+                               // PersistPtr, remove their old positions
+                               int[] ids = pph.getKnownSlideIDs();
+                               for (int j = 0; j < ids.length; j++) {
+                                       Integer id = new Integer(ids[j]);
+                                       if (mostRecentByBytes.containsKey(id)) {
+                                               mostRecentByBytes.remove(id);
+                                       }
                                }
-                       }
 
-                       // Now, update the byte level locations with their latest values
-                       Hashtable thisSetOfLocations = pph.getSlideLocationsLookup();
-                       for(int j=0; j<ids.length; j++) {
-                               Integer id = new Integer(ids[j]);
-                               mostRecentByBytes.put(id, thisSetOfLocations.get(id));
+                               // Now, update the byte level locations with their latest values
+                               Hashtable thisSetOfLocations = pph.getSlideLocationsLookup();
+                               for (int j = 0; j < ids.length; j++) {
+                                       Integer id = new Integer(ids[j]);
+                                       mostRecentByBytes.put(id, thisSetOfLocations.get(id));
+                               }
                        }
                }
-       }
 
-       // We now know how many unique special records we have, so init
-       //  the array
-       _mostRecentCoreRecords = new Record[mostRecentByBytes.size()];
-
-       // We'll also want to be able to turn the slide IDs into a position
-       //  in this array
-       _sheetIdToCoreRecordsLookup = new Hashtable();
-       int[] allIDs = new int[_mostRecentCoreRecords.length];
-       Enumeration ids = mostRecentByBytes.keys();
-       for(int i=0; i<allIDs.length; i++) {
-               Integer id = (Integer)ids.nextElement();
-               allIDs[i] = id.intValue();
-       }
-       Arrays.sort(allIDs);
-       for(int i=0; i<allIDs.length; i++) {
-               _sheetIdToCoreRecordsLookup.put(new Integer(allIDs[i]), new Integer(i));
-       }
+               // We now know how many unique special records we have, so init
+               // the array
+               _mostRecentCoreRecords = new Record[mostRecentByBytes.size()];
+
+               // We'll also want to be able to turn the slide IDs into a position
+               // in this array
+               _sheetIdToCoreRecordsLookup = new Hashtable();
+               int[] allIDs = new int[_mostRecentCoreRecords.length];
+               Enumeration ids = mostRecentByBytes.keys();
+               for (int i = 0; i < allIDs.length; i++) {
+                       Integer id = (Integer) ids.nextElement();
+                       allIDs[i] = id.intValue();
+               }
+               Arrays.sort(allIDs);
+               for (int i = 0; i < allIDs.length; i++) {
+                       _sheetIdToCoreRecordsLookup.put(new Integer(allIDs[i]), new Integer(i));
+               }
 
-       // Now convert the byte offsets back into record offsets
-       for(int i=0; i<_records.length; i++) {
-               if(_records[i] instanceof PositionDependentRecord) {
-                       PositionDependentRecord pdr = (PositionDependentRecord)_records[i];
-                       Integer recordAt = new Integer(pdr.getLastOnDiskOffset());
-
-                       // Is it one we care about?
-                       for(int j=0; j<allIDs.length; j++) {
-                               Integer thisID = new Integer(allIDs[j]);
-                               Integer thatRecordAt = (Integer)mostRecentByBytes.get(thisID);
-
-                               if(thatRecordAt.equals(recordAt)) {
-                                       // Bingo. Now, where do we store it?
-                                       Integer storeAtI =
-                                               (Integer)_sheetIdToCoreRecordsLookup.get(thisID);
-                                       int storeAt = storeAtI.intValue();
-
-                                       // Tell it its Sheet ID, if it cares
-                                       if(pdr instanceof PositionDependentRecordContainer) {
-                                               PositionDependentRecordContainer pdrc =
-                                                       (PositionDependentRecordContainer)_records[i];
-                                               pdrc.setSheetId(thisID.intValue());
+               // Now convert the byte offsets back into record offsets
+               for (int i = 0; i < _records.length; i++) {
+                       if (_records[i] instanceof PositionDependentRecord) {
+                               PositionDependentRecord pdr = (PositionDependentRecord) _records[i];
+                               Integer recordAt = new Integer(pdr.getLastOnDiskOffset());
+
+                               // Is it one we care about?
+                               for (int j = 0; j < allIDs.length; j++) {
+                                       Integer thisID = new Integer(allIDs[j]);
+                                       Integer thatRecordAt = (Integer) mostRecentByBytes.get(thisID);
+
+                                       if (thatRecordAt.equals(recordAt)) {
+                                               // Bingo. Now, where do we store it?
+                                               Integer storeAtI = (Integer) _sheetIdToCoreRecordsLookup.get(thisID);
+                                               int storeAt = storeAtI.intValue();
+
+                                               // Tell it its Sheet ID, if it cares
+                                               if (pdr instanceof PositionDependentRecordContainer) {
+                                                       PositionDependentRecordContainer pdrc = (PositionDependentRecordContainer) _records[i];
+                                                       pdrc.setSheetId(thisID.intValue());
+                                               }
+
+                                               // Finally, save the record
+                                               _mostRecentCoreRecords[storeAt] = _records[i];
                                        }
-
-                                       // Finally, save the record
-                                       _mostRecentCoreRecords[storeAt] = _records[i];
                                }
                        }
                }
-       }
 
-       // Now look for the interesting records in there
-       for(int i=0; i<_mostRecentCoreRecords.length; i++) {
-               // Check there really is a record at this number
-               if(_mostRecentCoreRecords[i] != null) {
-                       // Find the Document, and interesting things in it
-                       if(_mostRecentCoreRecords[i].getRecordType() == RecordTypes.Document.typeID) {
-                               _documentRecord = (Document)_mostRecentCoreRecords[i];
-                               _fonts = _documentRecord.getEnvironment().getFontCollection();
+               // Now look for the interesting records in there
+               for (int i = 0; i < _mostRecentCoreRecords.length; i++) {
+                       // Check there really is a record at this number
+                       if (_mostRecentCoreRecords[i] != null) {
+                               // Find the Document, and interesting things in it
+                               if (_mostRecentCoreRecords[i].getRecordType() == RecordTypes.Document.typeID) {
+                                       _documentRecord = (Document) _mostRecentCoreRecords[i];
+                                       _fonts = _documentRecord.getEnvironment().getFontCollection();
+                               }
+                       } else {
+                               // No record at this number
+                               // Odd, but not normally a problem
                        }
-               } else {
-                       // No record at this number
-                       // Odd, but not normally a problem
                }
        }
-  }
 
-       /**
-        * For a given SlideAtomsSet, return the core record, based on the refID from the
-        *  SlidePersistAtom
-        */
+       /**
+        * For a given SlideAtomsSet, return the core record, based on the refID
+        * from the SlidePersistAtom
+        */
        private Record getCoreRecordForSAS(SlideAtomsSet sas) {
                SlidePersistAtom spa = sas.getSlidePersistAtom();
                int refID = spa.getRefID();
@@ -259,223 +251,247 @@ public final class SlideShow {
        }
 
        /**
-        * For a given refID (the internal, 0 based numbering scheme), return the
-        *  core record
-        * @param refID the refID
+        * For a given refID (the internal, 0 based numbering scheme), return the
+        * core record
+        *
+        * @param refID
+        *            the refID
         */
        private Record getCoreRecordForRefID(int refID) {
-               Integer coreRecordId = (Integer)
-                       _sheetIdToCoreRecordsLookup.get(new Integer(refID));
-               if(coreRecordId != null) {
+               Integer coreRecordId = (Integer) _sheetIdToCoreRecordsLookup.get(new Integer(refID));
+               if (coreRecordId != null) {
                        Record r = _mostRecentCoreRecords[coreRecordId.intValue()];
                        return r;
                } else {
-                       logger.log(POILogger.ERROR, "We tried to look up a reference to a core record, but there was no core ID for reference ID " + refID);
+                       logger.log(POILogger.ERROR,
+                                       "We tried to look up a reference to a core record, but there was no core ID for reference ID "
+                                                       + refID);
                        return null;
                }
        }
 
-  /**
-   * Build up model level Slide and Notes objects, from the underlying
-   *  records.
-   */
-  private void buildSlidesAndNotes() {
-       // Ensure we really found a Document record earlier
-       // If we didn't, then the file is probably corrupt
-       if(_documentRecord == null) {
-               throw new CorruptPowerPointFileException("The PowerPoint file didn't contain a Document Record in its PersistPtr blocks. It is probably corrupt.");
-       }
-
-
-       // Fetch the SlideListWithTexts in the most up-to-date Document Record
-       //
-       // As far as we understand it:
-       //  * The first SlideListWithText will contain a SlideAtomsSet
-       //     for each of the master slides
-       //  * The second SlideListWithText will contain a SlideAtomsSet
-       //     for each of the slides, in their current order
-       //    These SlideAtomsSets will normally contain text
-       //  * The third SlideListWithText (if present), will contain a
-       //     SlideAtomsSet for each Notes
-       //    These SlideAtomsSets will not normally contain text
-       //
-       // Having indentified the masters, slides and notes + their orders,
-       //  we have to go and find their matching records
-       // We always use the latest versions of these records, and use the
-       //  SlideAtom/NotesAtom to match them with the StyleAtomSet
-
-       SlideListWithText masterSLWT = _documentRecord.getMasterSlideListWithText();
-       SlideListWithText slidesSLWT = _documentRecord.getSlideSlideListWithText();
-       SlideListWithText notesSLWT  = _documentRecord.getNotesSlideListWithText();
-
-    // Find master slides
-       // These can be MainMaster records, but oddly they can also be
-       //  Slides or Notes, and possibly even other odd stuff....
-       // About the only thing you can say is that the master details are in
-       //  the first SLWT.
-    SlideAtomsSet[] masterSets = new SlideAtomsSet[0];
-    if (masterSLWT != null){
-        masterSets = masterSLWT.getSlideAtomsSets();
-
-               ArrayList mmr = new ArrayList();
-        ArrayList tmr = new ArrayList();
-
-               for(int i=0; i<masterSets.length; i++) {
-                       Record r = getCoreRecordForSAS(masterSets[i]);
-            SlideAtomsSet sas = masterSets[i];
-            int sheetNo = sas.getSlidePersistAtom().getSlideIdentifier();
-                       if(r instanceof org.apache.poi.hslf.record.Slide) {
-                TitleMaster master = new TitleMaster((org.apache.poi.hslf.record.Slide)r, sheetNo);
-                master.setSlideShow(this);
-                tmr.add(master);
-                       } else if(r instanceof org.apache.poi.hslf.record.MainMaster) {
-                SlideMaster master = new SlideMaster((org.apache.poi.hslf.record.MainMaster)r, sheetNo);
-                master.setSlideShow(this);
-                mmr.add(master);
-            }
+       /**
+        * Build up model level Slide and Notes objects, from the underlying
+        * records.
+        */
+       private void buildSlidesAndNotes() {
+               // Ensure we really found a Document record earlier
+               // If we didn't, then the file is probably corrupt
+               if (_documentRecord == null) {
+                       throw new CorruptPowerPointFileException(
+                                       "The PowerPoint file didn't contain a Document Record in its PersistPtr blocks. It is probably corrupt.");
                }
 
-        _masters = new SlideMaster[mmr.size()];
-        mmr.toArray(_masters);
-
-        _titleMasters = new TitleMaster[tmr.size()];
-        tmr.toArray(_titleMasters);
-
-    }
+               // Fetch the SlideListWithTexts in the most up-to-date Document Record
+               //
+               // As far as we understand it:
+               // * The first SlideListWithText will contain a SlideAtomsSet
+               // for each of the master slides
+               // * The second SlideListWithText will contain a SlideAtomsSet
+               // for each of the slides, in their current order
+               // These SlideAtomsSets will normally contain text
+               // * The third SlideListWithText (if present), will contain a
+               // SlideAtomsSet for each Notes
+               // These SlideAtomsSets will not normally contain text
+               //
+               // Having indentified the masters, slides and notes + their orders,
+               // we have to go and find their matching records
+               // We always use the latest versions of these records, and use the
+               // SlideAtom/NotesAtom to match them with the StyleAtomSet
+
+               SlideListWithText masterSLWT = _documentRecord.getMasterSlideListWithText();
+               SlideListWithText slidesSLWT = _documentRecord.getSlideSlideListWithText();
+               SlideListWithText notesSLWT = _documentRecord.getNotesSlideListWithText();
+
+               // Find master slides
+               // These can be MainMaster records, but oddly they can also be
+               // Slides or Notes, and possibly even other odd stuff....
+               // About the only thing you can say is that the master details are in
+               // the first SLWT.
+               SlideAtomsSet[] masterSets = new SlideAtomsSet[0];
+               if (masterSLWT != null) {
+                       masterSets = masterSLWT.getSlideAtomsSets();
+
+                       ArrayList mmr = new ArrayList();
+                       ArrayList tmr = new ArrayList();
+
+                       for (int i = 0; i < masterSets.length; i++) {
+                               Record r = getCoreRecordForSAS(masterSets[i]);
+                               SlideAtomsSet sas = masterSets[i];
+                               int sheetNo = sas.getSlidePersistAtom().getSlideIdentifier();
+                               if (r instanceof org.apache.poi.hslf.record.Slide) {
+                                       TitleMaster master = new TitleMaster((org.apache.poi.hslf.record.Slide) r,
+                                                       sheetNo);
+                                       master.setSlideShow(this);
+                                       tmr.add(master);
+                               } else if (r instanceof org.apache.poi.hslf.record.MainMaster) {
+                                       SlideMaster master = new SlideMaster((org.apache.poi.hslf.record.MainMaster) r,
+                                                       sheetNo);
+                                       master.setSlideShow(this);
+                                       mmr.add(master);
+                               }
+                       }
 
+                       _masters = new SlideMaster[mmr.size()];
+                       mmr.toArray(_masters);
 
-       // Having sorted out the masters, that leaves the notes and slides
+                       _titleMasters = new TitleMaster[tmr.size()];
+                       tmr.toArray(_titleMasters);
 
+               }
 
-       // Start by finding the notes records to go with the entries in
-       //  notesSLWT
-       org.apache.poi.hslf.record.Notes[] notesRecords;
-       SlideAtomsSet[] notesSets = new SlideAtomsSet[0];
-       Hashtable slideIdToNotes = new Hashtable();
-       if(notesSLWT == null) {
-               // None
-               notesRecords = new org.apache.poi.hslf.record.Notes[0];
-       } else {
-               // Match up the records and the SlideAtomSets
-               notesSets = notesSLWT.getSlideAtomsSets();
-               ArrayList notesRecordsL = new ArrayList();
-               for(int i=0; i<notesSets.length; i++) {
-                       // Get the right core record
-                       Record r = getCoreRecordForSAS(notesSets[i]);
+               // Having sorted out the masters, that leaves the notes and slides
 
-                       // Ensure it really is a notes record
-                       if(r instanceof org.apache.poi.hslf.record.Notes) {
-                org.apache.poi.hslf.record.Notes notesRecord = (org.apache.poi.hslf.record.Notes)r;
-                               notesRecordsL.add( notesRecord );
+               // Start by finding the notes records to go with the entries in
+               // notesSLWT
+               org.apache.poi.hslf.record.Notes[] notesRecords;
+               SlideAtomsSet[] notesSets = new SlideAtomsSet[0];
+               Hashtable slideIdToNotes = new Hashtable();
+               if (notesSLWT == null) {
+                       // None
+                       notesRecords = new org.apache.poi.hslf.record.Notes[0];
+               } else {
+                       // Match up the records and the SlideAtomSets
+                       notesSets = notesSLWT.getSlideAtomsSets();
+                       ArrayList notesRecordsL = new ArrayList();
+                       for (int i = 0; i < notesSets.length; i++) {
+                               // Get the right core record
+                               Record r = getCoreRecordForSAS(notesSets[i]);
+
+                               // Ensure it really is a notes record
+                               if (r instanceof org.apache.poi.hslf.record.Notes) {
+                                       org.apache.poi.hslf.record.Notes notesRecord = (org.apache.poi.hslf.record.Notes) r;
+                                       notesRecordsL.add(notesRecord);
+
+                                       // Record the match between slide id and these notes
+                                       SlidePersistAtom spa = notesSets[i].getSlidePersistAtom();
+                                       Integer slideId = new Integer(spa.getSlideIdentifier());
+                                       slideIdToNotes.put(slideId, new Integer(i));
+                               } else {
+                                       logger.log(POILogger.ERROR, "A Notes SlideAtomSet at " + i
+                                                       + " said its record was at refID "
+                                                       + notesSets[i].getSlidePersistAtom().getRefID()
+                                                       + ", but that was actually a " + r);
+                               }
+                       }
+                       notesRecords = new org.apache.poi.hslf.record.Notes[notesRecordsL.size()];
+                       notesRecords = (org.apache.poi.hslf.record.Notes[]) notesRecordsL.toArray(notesRecords);
+               }
 
-                               // Record the match between slide id and these notes
-                SlidePersistAtom spa = notesSets[i].getSlidePersistAtom();
-                Integer slideId = new Integer(spa.getSlideIdentifier());
-                slideIdToNotes.put(slideId, new Integer(i));
-                       } else {
-                               logger.log(POILogger.ERROR, "A Notes SlideAtomSet at " + i + " said its record was at refID " + notesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r);
+               // Now, do the same thing for our slides
+               org.apache.poi.hslf.record.Slide[] slidesRecords;
+               SlideAtomsSet[] slidesSets = new SlideAtomsSet[0];
+               if (slidesSLWT == null) {
+                       // None
+                       slidesRecords = new org.apache.poi.hslf.record.Slide[0];
+               } else {
+                       // Match up the records and the SlideAtomSets
+                       slidesSets = slidesSLWT.getSlideAtomsSets();
+                       slidesRecords = new org.apache.poi.hslf.record.Slide[slidesSets.length];
+                       for (int i = 0; i < slidesSets.length; i++) {
+                               // Get the right core record
+                               Record r = getCoreRecordForSAS(slidesSets[i]);
+
+                               // Ensure it really is a slide record
+                               if (r instanceof org.apache.poi.hslf.record.Slide) {
+                                       slidesRecords[i] = (org.apache.poi.hslf.record.Slide) r;
+                               } else {
+                                       logger.log(POILogger.ERROR, "A Slide SlideAtomSet at " + i
+                                                       + " said its record was at refID "
+                                                       + slidesSets[i].getSlidePersistAtom().getRefID()
+                                                       + ", but that was actually a " + r);
+                               }
                        }
                }
-               notesRecords = new org.apache.poi.hslf.record.Notes[notesRecordsL.size()];
-               notesRecords = (org.apache.poi.hslf.record.Notes[])
-                       notesRecordsL.toArray(notesRecords);
-       }
 
-       // Now, do the same thing for our slides
-       org.apache.poi.hslf.record.Slide[] slidesRecords;
-       SlideAtomsSet[] slidesSets = new SlideAtomsSet[0];
-       if(slidesSLWT == null) {
-               // None
-               slidesRecords = new org.apache.poi.hslf.record.Slide[0];
-       } else {
-               // Match up the records and the SlideAtomSets
-               slidesSets = slidesSLWT.getSlideAtomsSets();
-               slidesRecords = new org.apache.poi.hslf.record.Slide[slidesSets.length];
-               for(int i=0; i<slidesSets.length; i++) {
-                       // Get the right core record
-                       Record r = getCoreRecordForSAS(slidesSets[i]);
-
-                       // Ensure it really is a slide record
-                       if(r instanceof org.apache.poi.hslf.record.Slide) {
-                               slidesRecords[i] = (org.apache.poi.hslf.record.Slide)r;
-                       } else {
-                               logger.log(POILogger.ERROR, "A Slide SlideAtomSet at " + i + " said its record was at refID " + slidesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r);
+               // Finally, generate model objects for everything
+               // Notes first
+               _notes = new Notes[notesRecords.length];
+               for (int i = 0; i < _notes.length; i++) {
+                       _notes[i] = new Notes(notesRecords[i]);
+                       _notes[i].setSlideShow(this);
+               }
+               // Then slides
+               _slides = new Slide[slidesRecords.length];
+               for (int i = 0; i < _slides.length; i++) {
+                       SlideAtomsSet sas = slidesSets[i];
+                       int slideIdentifier = sas.getSlidePersistAtom().getSlideIdentifier();
+
+                       // Do we have a notes for this?
+                       Notes notes = null;
+                       // Slide.SlideAtom.notesId references the corresponding notes slide.
+                       // 0 if slide has no notes.
+                       int noteId = slidesRecords[i].getSlideAtom().getNotesID();
+                       if (noteId != 0) {
+                               Integer notesPos = (Integer) slideIdToNotes.get(new Integer(noteId));
+                               if (notesPos != null)
+                                       notes = _notes[notesPos.intValue()];
+                               else
+                                       logger.log(POILogger.ERROR, "Notes not found for noteId=" + noteId);
                        }
+
+                       // Now, build our slide
+                       _slides[i] = new Slide(slidesRecords[i], notes, sas, slideIdentifier, (i + 1));
+                       _slides[i].setSlideShow(this);
                }
        }
 
-       // Finally, generate model objects for everything
-       // Notes first
-       _notes = new Notes[notesRecords.length];
-       for(int i=0; i<_notes.length; i++) {
-               _notes[i] = new Notes(notesRecords[i]);
-               _notes[i].setSlideShow(this);
-       }
-       // Then slides
-       _slides = new Slide[slidesRecords.length];
-       for(int i=0; i<_slides.length; i++) {
-               SlideAtomsSet sas = slidesSets[i];
-               int slideIdentifier = sas.getSlidePersistAtom().getSlideIdentifier();
-
-               // Do we have a notes for this?
-               Notes notes = null;
-        //Slide.SlideAtom.notesId references the corresponding notes slide. 0 if slide has no notes.
-        int noteId = slidesRecords[i].getSlideAtom().getNotesID();
-        if (noteId != 0){
-            Integer notesPos = (Integer)slideIdToNotes.get(new Integer(noteId));
-            if (notesPos != null) notes = _notes[notesPos.intValue()];
-            else logger.log(POILogger.ERROR, "Notes not found for noteId=" + noteId);
-        }
-
-               // Now, build our slide
-               _slides[i] = new Slide(slidesRecords[i], notes, sas, slideIdentifier, (i+1));
-               _slides[i].setSlideShow(this);
+       /**
+        * Writes out the slideshow file the is represented by an instance of this
+        * class
+        *
+        * @param out
+        *            The OutputStream to write to.
+        * @throws IOException
+        *             If there is an unexpected IOException from the passed in
+        *             OutputStream
+        */
+       public void write(OutputStream out) throws IOException {
+               _hslfSlideShow.write(out);
        }
-  }
-
-  /**
-   * Writes out the slideshow file the is represented by an instance of
-   *  this class
-   * @param out The OutputStream to write to.
-   *  @throws IOException If there is an unexpected IOException from the passed
-   *            in OutputStream
-   */
-   public void write(OutputStream out) throws IOException {
-       _hslfSlideShow.write(out);
-   }
-
-
-   /* ===============================================================
-    *                       Accessor Code
-    * ===============================================================
-    */
 
+       /*
+        * ===============================================================
+        *                         Accessor Code
+        * ===============================================================
+        */
 
        /**
         * Returns an array of the most recent version of all the interesting
-        *  records
+        * records
         */
-       public Record[] getMostRecentCoreRecords() { return _mostRecentCoreRecords; }
+       public Record[] getMostRecentCoreRecords() {
+               return _mostRecentCoreRecords;
+       }
 
        /**
         * Returns an array of all the normal Slides found in the slideshow
         */
-       public Slide[] getSlides() { return _slides; }
+       public Slide[] getSlides() {
+               return _slides;
+       }
 
        /**
         * Returns an array of all the normal Notes found in the slideshow
         */
-       public Notes[] getNotes() { return _notes; }
+       public Notes[] getNotes() {
+               return _notes;
+       }
 
        /**
-     * Returns an array of all the normal Slide Masters found in the slideshow
+        * Returns an array of all the normal Slide Masters found in the slideshow
         */
-    public SlideMaster[] getSlidesMasters() { return _masters; }
+       public SlideMaster[] getSlidesMasters() {
+               return _masters;
+       }
+
+       /**
+        * Returns an array of all the normal Title Masters found in the slideshow
+        */
+       public TitleMaster[] getTitleMasters() {
+               return _titleMasters;
+       }
 
-    /**
-     * Returns an array of all the normal Title Masters found in the slideshow
-     */
-    public TitleMaster[] getTitleMasters() { return _titleMasters; }
        /**
         * Returns the data of all the pictures attached to the SlideShow
         */
@@ -483,561 +499,598 @@ public final class SlideShow {
                return _hslfSlideShow.getPictures();
        }
 
-    /**
-     * Returns the data of all the embedded OLE object in the SlideShow
-     */
-    public ObjectData[] getEmbeddedObjects() {
-        return _hslfSlideShow.getEmbeddedObjects();
-    }
+       /**
+        * Returns the data of all the embedded OLE object in the SlideShow
+        */
+       public ObjectData[] getEmbeddedObjects() {
+               return _hslfSlideShow.getEmbeddedObjects();
+       }
 
-    /**
-     * Returns the data of all the embedded sounds in the SlideShow
-     */
-    public SoundData[] getSoundData() {
-        return SoundData.find(_documentRecord);
-    }
+       /**
+        * Returns the data of all the embedded sounds in the SlideShow
+        */
+       public SoundData[] getSoundData() {
+               return SoundData.find(_documentRecord);
+       }
 
        /**
         * Return the current page size
         */
-       public Dimension getPageSize(){
+       public Dimension getPageSize() {
                DocumentAtom docatom = _documentRecord.getDocumentAtom();
-               int pgx = (int)docatom.getSlideSizeX()*Shape.POINT_DPI/Shape.MASTER_DPI;
-               int pgy = (int)docatom.getSlideSizeY()*Shape.POINT_DPI/Shape.MASTER_DPI;
+               int pgx = (int) docatom.getSlideSizeX() * Shape.POINT_DPI / Shape.MASTER_DPI;
+               int pgy = (int) docatom.getSlideSizeY() * Shape.POINT_DPI / Shape.MASTER_DPI;
                return new Dimension(pgx, pgy);
        }
 
        /**
         * Change the current page size
         *
-        * @param pgsize page size (in points)
+        * @param pgsize
+        *            page size (in points)
         */
-       public void setPageSize(Dimension pgsize){
+       public void setPageSize(Dimension pgsize) {
                DocumentAtom docatom = _documentRecord.getDocumentAtom();
-               docatom.setSlideSizeX(pgsize.width*Shape.MASTER_DPI/Shape.POINT_DPI);
-               docatom.setSlideSizeY(pgsize.height*Shape.MASTER_DPI/Shape.POINT_DPI);
+               docatom.setSlideSizeX(pgsize.width * Shape.MASTER_DPI / Shape.POINT_DPI);
+               docatom.setSlideSizeY(pgsize.height * Shape.MASTER_DPI / Shape.POINT_DPI);
        }
 
        /**
         * Helper method for usermodel: Get the font collection
         */
-       protected FontCollection getFontCollection() { return _fonts; }
+       protected FontCollection getFontCollection() {
+               return _fonts;
+       }
+
        /**
         * Helper method for usermodel and model: Get the document record
         */
-       public Document getDocumentRecord() { return _documentRecord; }
-
+       public Document getDocumentRecord() {
+               return _documentRecord;
+       }
 
-       /* ===============================================================
-        *                       Re-ordering Code
+       /*
+        * ===============================================================
+        * Re-ordering Code
         * ===============================================================
         */
 
-
        /**
         * Re-orders a slide, to a new position.
-        * @param oldSlideNumber The old slide number (1 based)
-        * @param newSlideNumber The new slide number (1 based)
+        *
+        * @param oldSlideNumber
+        *            The old slide number (1 based)
+        * @param newSlideNumber
+        *            The new slide number (1 based)
         */
        public void reorderSlide(int oldSlideNumber, int newSlideNumber) {
                // Ensure these numbers are valid
-               if(oldSlideNumber < 1 || newSlideNumber < 1) {
+               if (oldSlideNumber < 1 || newSlideNumber < 1) {
                        throw new IllegalArgumentException("Old and new slide numbers must be greater than 0");
                }
-               if(oldSlideNumber > _slides.length || newSlideNumber > _slides.length) {
-                       throw new IllegalArgumentException("Old and new slide numbers must not exceed the number of slides (" + _slides.length + ")");
+               if (oldSlideNumber > _slides.length || newSlideNumber > _slides.length) {
+                       throw new IllegalArgumentException(
+                                       "Old and new slide numbers must not exceed the number of slides ("
+                                                       + _slides.length + ")");
                }
 
-        //  The order of slides is defined by the order of slide atom sets in the SlideListWithText container.
-        SlideListWithText slwt = _documentRecord.getSlideSlideListWithText();
-        SlideAtomsSet[] sas = slwt.getSlideAtomsSets();
-
-        SlideAtomsSet tmp = sas[oldSlideNumber-1];
-        sas[oldSlideNumber-1] = sas[newSlideNumber-1];
-        sas[newSlideNumber-1] = tmp;
-
-        ArrayList lst = new ArrayList();
-        for (int i = 0; i < sas.length; i++) {
-            lst.add(sas[i].getSlidePersistAtom());
-            Record[] r = sas[i].getSlideRecords();
-            for (int j = 0; j < r.length; j++) {
-                lst.add(r[j]);
-            }
-            _slides[i].setSlideNumber(i+1);
-        }
-        Record[] r = (Record[])lst.toArray(new Record[lst.size()]);
-        slwt.setChildRecord(r);
+               // The order of slides is defined by the order of slide atom sets in the
+               // SlideListWithText container.
+               SlideListWithText slwt = _documentRecord.getSlideSlideListWithText();
+               SlideAtomsSet[] sas = slwt.getSlideAtomsSets();
+
+               SlideAtomsSet tmp = sas[oldSlideNumber - 1];
+               sas[oldSlideNumber - 1] = sas[newSlideNumber - 1];
+               sas[newSlideNumber - 1] = tmp;
+
+               ArrayList lst = new ArrayList();
+               for (int i = 0; i < sas.length; i++) {
+                       lst.add(sas[i].getSlidePersistAtom());
+                       Record[] r = sas[i].getSlideRecords();
+                       for (int j = 0; j < r.length; j++) {
+                               lst.add(r[j]);
+                       }
+                       _slides[i].setSlideNumber(i + 1);
+               }
+               Record[] r = (Record[]) lst.toArray(new Record[lst.size()]);
+               slwt.setChildRecord(r);
        }
 
-    /**
-     * Removes the slide at the given index (0-based).
-     * <p>Shifts any subsequent slides to the left (subtracts one from their slide numbers).</p>
-     *
-     * @param index the index of the slide to remove (0-based)
-     * @return the slide that was removed from the slide show.
-     */
-    public Slide removeSlide(int index) {
-        int lastSlideIdx = _slides.length - 1;
-        if(index < 0 || index > lastSlideIdx) {
-            throw new IllegalArgumentException("Slide index ("
-                    + index +") is out of range (0.." +  lastSlideIdx + ")");
-        }
-
-        SlideListWithText slwt = _documentRecord.getSlideSlideListWithText();
-        SlideAtomsSet[] sas = slwt.getSlideAtomsSets();
-
-        Slide removedSlide = null;
-        ArrayList<Record> records = new ArrayList<Record>();
-        ArrayList<SlideAtomsSet> sa = new ArrayList<SlideAtomsSet>();
-        ArrayList<Slide> sl = new ArrayList<Slide>();
-
-        ArrayList<Notes> nt = new ArrayList<Notes>();
-        for(Notes notes : getNotes()) nt.add(notes);
-
-        for (int i = 0, num = 0; i < _slides.length; i++){
-            if(i != index) {
-                sl.add(_slides[i]);
-                sa.add(sas[i]);
-                _slides[i].setSlideNumber(num++);
-                records.add(sas[i].getSlidePersistAtom());
-                records.addAll(Arrays.asList(sas[i].getSlideRecords()));
-            } else {
-                removedSlide = _slides[i];
-                nt.remove(_slides[i].getNotesSheet());
-            }
-        }
-        if(sa.size() == 0){
-            _documentRecord.removeSlideListWithText(slwt);
-        } else {
-            slwt.setSlideAtomsSets( sa.toArray(new SlideAtomsSet[sa.size()]) );
-            slwt.setChildRecord(records.toArray(new Record[records.size()]));
-        }
-        _slides = sl.toArray(new Slide[sl.size()]);
-
-        //if the removed slide had notes - remove references to them too
-
-        if(removedSlide != null){
-             int notesId = removedSlide.getSlideRecord().getSlideAtom().getNotesID();
-            if(notesId != 0){
-                SlideListWithText nslwt = _documentRecord.getNotesSlideListWithText();
-                records = new ArrayList<Record>();
-                ArrayList<SlideAtomsSet> na = new ArrayList<SlideAtomsSet>();
-                for (SlideAtomsSet ns : nslwt.getSlideAtomsSets()){
-                    if(ns.getSlidePersistAtom().getSlideIdentifier() != notesId) {
-                        na.add(ns);
-                        records.add(ns.getSlidePersistAtom());
-                        if(ns.getSlideRecords() != null) records.addAll(Arrays.asList(ns.getSlideRecords()));
-                    }
-                }
-                if(na.size() == 0){
-                    _documentRecord.removeSlideListWithText(nslwt);
-                } else {
-                    nslwt.setSlideAtomsSets( na.toArray(new SlideAtomsSet[na.size()]) );
-                    nslwt.setChildRecord(records.toArray(new Record[records.size()]));
-                }
-
-            }
-        }
-        _notes = nt.toArray(new Notes[nt.size()]);
-
-        return removedSlide;
-    }
-
-    /* ===============================================================
-        *                       Addition Code
-        * ===============================================================
+       /**
+        * Removes the slide at the given index (0-based).
+        * <p>
+        * Shifts any subsequent slides to the left (subtracts one from their slide
+        * numbers).
+        * </p>
+        *
+        * @param index
+        *            the index of the slide to remove (0-based)
+        * @return the slide that was removed from the slide show.
         */
+       public Slide removeSlide(int index) {
+               int lastSlideIdx = _slides.length - 1;
+               if (index < 0 || index > lastSlideIdx) {
+                       throw new IllegalArgumentException("Slide index (" + index + ") is out of range (0.."
+                                       + lastSlideIdx + ")");
+               }
 
+               SlideListWithText slwt = _documentRecord.getSlideSlideListWithText();
+               SlideAtomsSet[] sas = slwt.getSlideAtomsSets();
+
+               Slide removedSlide = null;
+               ArrayList<Record> records = new ArrayList<Record>();
+               ArrayList<SlideAtomsSet> sa = new ArrayList<SlideAtomsSet>();
+               ArrayList<Slide> sl = new ArrayList<Slide>();
+
+               ArrayList<Notes> nt = new ArrayList<Notes>();
+               for (Notes notes : getNotes())
+                       nt.add(notes);
+
+               for (int i = 0, num = 0; i < _slides.length; i++) {
+                       if (i != index) {
+                               sl.add(_slides[i]);
+                               sa.add(sas[i]);
+                               _slides[i].setSlideNumber(num++);
+                               records.add(sas[i].getSlidePersistAtom());
+                               records.addAll(Arrays.asList(sas[i].getSlideRecords()));
+                       } else {
+                               removedSlide = _slides[i];
+                               nt.remove(_slides[i].getNotesSheet());
+                       }
+               }
+               if (sa.size() == 0) {
+                       _documentRecord.removeSlideListWithText(slwt);
+               } else {
+                       slwt.setSlideAtomsSets(sa.toArray(new SlideAtomsSet[sa.size()]));
+                       slwt.setChildRecord(records.toArray(new Record[records.size()]));
+               }
+               _slides = sl.toArray(new Slide[sl.size()]);
+
+               // if the removed slide had notes - remove references to them too
+
+               if (removedSlide != null) {
+                       int notesId = removedSlide.getSlideRecord().getSlideAtom().getNotesID();
+                       if (notesId != 0) {
+                               SlideListWithText nslwt = _documentRecord.getNotesSlideListWithText();
+                               records = new ArrayList<Record>();
+                               ArrayList<SlideAtomsSet> na = new ArrayList<SlideAtomsSet>();
+                               for (SlideAtomsSet ns : nslwt.getSlideAtomsSets()) {
+                                       if (ns.getSlidePersistAtom().getSlideIdentifier() != notesId) {
+                                               na.add(ns);
+                                               records.add(ns.getSlidePersistAtom());
+                                               if (ns.getSlideRecords() != null)
+                                                       records.addAll(Arrays.asList(ns.getSlideRecords()));
+                                       }
+                               }
+                               if (na.size() == 0) {
+                                       _documentRecord.removeSlideListWithText(nslwt);
+                               } else {
+                                       nslwt.setSlideAtomsSets(na.toArray(new SlideAtomsSet[na.size()]));
+                                       nslwt.setChildRecord(records.toArray(new Record[records.size()]));
+                               }
+
+                       }
+               }
+               _notes = nt.toArray(new Notes[nt.size()]);
+
+               return removedSlide;
+       }
+
+       /*
+        * ===============================================================
+        *  Addition Code
+        * ===============================================================
+        */
 
        /**
         * Create a blank <code>Slide</code>.
         *
-        * @return  the created <code>Slide</code>
+        * @return the created <code>Slide</code>
         */
-       public Slide createSlide() {
-               SlideListWithText slist = null;
-
-               // We need to add the records to the SLWT that deals
-               //  with Slides.
-               // Add it, if it doesn't exist
-               slist = _documentRecord.getSlideSlideListWithText();
-               if(slist == null) {
-                       // Need to add a new one
-                       slist = new SlideListWithText();
-                       slist.setInstance(SlideListWithText.SLIDES);
-            _documentRecord.addSlideListWithText(slist);
-               }
-
-               // Grab the SlidePersistAtom with the highest Slide Number.
-               // (Will stay as null if no SlidePersistAtom exists yet in
-               //  the slide, or only master slide's ones do)
-               SlidePersistAtom prev = null;
+       public Slide createSlide() {
+               SlideListWithText slist = null;
+
+               // We need to add the records to the SLWT that deals
+               // with Slides.
+               // Add it, if it doesn't exist
+               slist = _documentRecord.getSlideSlideListWithText();
+               if (slist == null) {
+                       // Need to add a new one
+                       slist = new SlideListWithText();
+                       slist.setInstance(SlideListWithText.SLIDES);
+                       _documentRecord.addSlideListWithText(slist);
+               }
+
+               // Grab the SlidePersistAtom with the highest Slide Number.
+               // (Will stay as null if no SlidePersistAtom exists yet in
+               // the slide, or only master slide's ones do)
+               SlidePersistAtom prev = null;
                SlideAtomsSet[] sas = slist.getSlideAtomsSets();
-               for(int j=0; j<sas.length; j++) {
-                       SlidePersistAtom spa = sas[j].getSlidePersistAtom();
-                       if(spa.getSlideIdentifier() < 0) {
-                               // This is for a master slide
-                               // Odd, since we only deal with the Slide SLWT
-                       } else {
+               for (int j = 0; j < sas.length; j++) {
+                       SlidePersistAtom spa = sas[j].getSlidePersistAtom();
+                       if (spa.getSlideIdentifier() < 0) {
+                               // This is for a master slide
+                               // Odd, since we only deal with the Slide SLWT
+                       } else {
                                // Must be for a real slide
-                               if(prev == null) { prev = spa; }
-                               if(prev.getSlideIdentifier() < spa.getSlideIdentifier()) {
-                                       prev = spa;
-                               }
-                       }
-               }
-
-               // Set up a new  SlidePersistAtom for this slide
-               SlidePersistAtom sp = new SlidePersistAtom();
-
-               // First slideId is always 256
-               sp.setSlideIdentifier(prev == null ? 256 : (prev.getSlideIdentifier() + 1));
-
-               // Add this new SlidePersistAtom to the SlideListWithText
-               slist.addSlidePersistAtom(sp);
-
-
-               // Create a new Slide
-               Slide slide = new Slide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length+1);
-        slide.setSlideShow(this);
-        slide.onCreate();
-
-               // Add in to the list of Slides
-               Slide[] s = new Slide[_slides.length+1];
-               System.arraycopy(_slides, 0, s, 0, _slides.length);
-               s[_slides.length] = slide;
-               _slides = s;
-               logger.log(POILogger.INFO, "Added slide " + _slides.length + " with ref " + sp.getRefID() + " and identifier " + sp.getSlideIdentifier());
-
-               // Add the core records for this new Slide to the record tree
-               org.apache.poi.hslf.record.Slide slideRecord = slide.getSlideRecord();
-               int slideRecordPos = _hslfSlideShow.appendRootLevelRecord(slideRecord);
-               _records = _hslfSlideShow.getRecords();
-
-
-               // Add the new Slide into the PersistPtr stuff
-               int offset = 0;
-               int slideOffset = 0;
-               PersistPtrHolder ptr = null;
-               UserEditAtom usr = null;
-               for (int i = 0; i < _records.length; i++) {
-                       Record record = _records[i];
-                       ByteArrayOutputStream out = new ByteArrayOutputStream();
-                       try {
-                record.writeOut(out);
-            } catch (IOException e){
-                throw new HSLFException(e);
-            }
-
-              // Grab interesting records as they come past
-                       if(_records[i].getRecordType() == RecordTypes.PersistPtrIncrementalBlock.typeID){
-                               ptr = (PersistPtrHolder)_records[i];
-                       }
-                       if(_records[i].getRecordType() == RecordTypes.UserEditAtom.typeID) {
-                               usr = (UserEditAtom)_records[i];
-                       }
-
-                       if(i == slideRecordPos) {
-                               slideOffset = offset;
-                       }
-                       offset += out.size();
-               }
-
-        // persist ID is UserEditAtom.maxPersistWritten + 1
-        int psrId = usr.getMaxPersistWritten() + 1;
-        sp.setRefID(psrId);
-        slideRecord.setSheetId(psrId);
-
-        // Last view is now of the slide
-        usr.setLastViewType((short)UserEditAtom.LAST_VIEW_SLIDE_VIEW);
-        usr.setMaxPersistWritten(psrId);    //increment the number of persit objects
+                               if (prev == null) {
+                                       prev = spa;
+                               }
+                               if (prev.getSlideIdentifier() < spa.getSlideIdentifier()) {
+                                       prev = spa;
+                               }
+                       }
+               }
+
+               // Set up a new SlidePersistAtom for this slide
+               SlidePersistAtom sp = new SlidePersistAtom();
+
+               // First slideId is always 256
+               sp.setSlideIdentifier(prev == null ? 256 : (prev.getSlideIdentifier() + 1));
+
+               // Add this new SlidePersistAtom to the SlideListWithText
+               slist.addSlidePersistAtom(sp);
+
+               // Create a new Slide
+               Slide slide = new Slide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length + 1);
+               slide.setSlideShow(this);
+               slide.onCreate();
+
+               // Add in to the list of Slides
+               Slide[] s = new Slide[_slides.length + 1];
+               System.arraycopy(_slides, 0, s, 0, _slides.length);
+               s[_slides.length] = slide;
+               _slides = s;
+               logger.log(POILogger.INFO, "Added slide " + _slides.length + " with ref " + sp.getRefID()
+                               + " and identifier " + sp.getSlideIdentifier());
+
+               // Add the core records for this new Slide to the record tree
+               org.apache.poi.hslf.record.Slide slideRecord = slide.getSlideRecord();
+               int slideRecordPos = _hslfSlideShow.appendRootLevelRecord(slideRecord);
+               _records = _hslfSlideShow.getRecords();
+
+               // Add the new Slide into the PersistPtr stuff
+               int offset = 0;
+               int slideOffset = 0;
+               PersistPtrHolder ptr = null;
+               UserEditAtom usr = null;
+               for (int i = 0; i < _records.length; i++) {
+                       Record record = _records[i];
+                       ByteArrayOutputStream out = new ByteArrayOutputStream();
+                       try {
+                               record.writeOut(out);
+                       } catch (IOException e) {
+                               throw new HSLFException(e);
+                       }
+
+                       // Grab interesting records as they come past
+                       if (_records[i].getRecordType() == RecordTypes.PersistPtrIncrementalBlock.typeID) {
+                               ptr = (PersistPtrHolder) _records[i];
+                       }
+                       if (_records[i].getRecordType() == RecordTypes.UserEditAtom.typeID) {
+                               usr = (UserEditAtom) _records[i];
+                       }
+
+                       if (i == slideRecordPos) {
+                               slideOffset = offset;
+                       }
+                       offset += out.size();
+               }
+
+               // persist ID is UserEditAtom.maxPersistWritten + 1
+               int psrId = usr.getMaxPersistWritten() + 1;
+               sp.setRefID(psrId);
+               slideRecord.setSheetId(psrId);
+
+               // Last view is now of the slide
+               usr.setLastViewType((short) UserEditAtom.LAST_VIEW_SLIDE_VIEW);
+               usr.setMaxPersistWritten(psrId); // increment the number of persit
+                                                                                // objects
 
                // Add the new slide into the last PersistPtr
-               // (Also need to tell it where it is)
+               // (Also need to tell it where it is)
                slideRecord.setLastOnDiskOffset(slideOffset);
                ptr.addSlideLookup(sp.getRefID(), slideOffset);
                logger.log(POILogger.INFO, "New slide ended up at " + slideOffset);
 
-        slide.setMasterSheet(_masters[0]);
-          // All done and added
-               return slide;
+               slide.setMasterSheet(_masters[0]);
+               // All done and added
+               return slide;
+       }
+
+       /**
+        * Adds a picture to this presentation and returns the associated index.
+        *
+        * @param data
+        *            picture data
+        * @param format
+        *            the format of the picture. One of constans defined in the
+        *            <code>Picture</code> class.
+        * @return the index to this picture (1 based).
+        */
+       public int addPicture(byte[] data, int format) throws IOException {
+               byte[] uid = PictureData.getChecksum(data);
+
+               EscherContainerRecord bstore;
+
+               EscherContainerRecord dggContainer = _documentRecord.getPPDrawingGroup().getDggContainer();
+               bstore = (EscherContainerRecord) Shape.getEscherChild(dggContainer,
+                               EscherContainerRecord.BSTORE_CONTAINER);
+               if (bstore == null) {
+                       bstore = new EscherContainerRecord();
+                       bstore.setRecordId(EscherContainerRecord.BSTORE_CONTAINER);
+
+                       dggContainer.addChildBefore(bstore, EscherOptRecord.RECORD_ID);
+               } else {
+                       Iterator<EscherRecord> iter = bstore.getChildIterator();
+                       for (int i = 0; iter.hasNext(); i++) {
+                               EscherBSERecord bse = (EscherBSERecord) iter.next();
+                               if (Arrays.equals(bse.getUid(), uid)) {
+                                       return i + 1;
+                               }
+                       }
+               }
+
+               PictureData pict = PictureData.create(format);
+               pict.setData(data);
+
+               int offset = _hslfSlideShow.addPicture(pict);
+
+               EscherBSERecord bse = new EscherBSERecord();
+               bse.setRecordId(EscherBSERecord.RECORD_ID);
+               bse.setOptions((short) (0x0002 | (format << 4)));
+               bse.setSize(pict.getRawData().length + 8);
+               bse.setUid(uid);
+
+               bse.setBlipTypeMacOS((byte) format);
+               bse.setBlipTypeWin32((byte) format);
+
+               if (format == Picture.EMF)
+                       bse.setBlipTypeMacOS((byte) Picture.PICT);
+               else if (format == Picture.WMF)
+                       bse.setBlipTypeMacOS((byte) Picture.PICT);
+               else if (format == Picture.PICT)
+                       bse.setBlipTypeWin32((byte) Picture.WMF);
+
+               bse.setRef(0);
+               bse.setOffset(offset);
+               bse.setRemainingData(new byte[0]);
+
+               bstore.addChildRecord(bse);
+               int count = bstore.getChildRecords().size();
+               bstore.setOptions((short) ((count << 4) | 0xF));
+
+               return count;
        }
 
-    /**
-     * Adds a picture to this presentation and returns the associated index.
-     *
-     * @param data      picture data
-     * @param format    the format of the picture.  One of constans defined in the <code>Picture</code> class.
-     * @return          the index to this picture (1 based).
-     */
-    public int addPicture(byte[] data, int format) throws IOException {
-        byte[] uid = PictureData.getChecksum(data);
-
-        EscherContainerRecord bstore;
-
-        EscherContainerRecord dggContainer = _documentRecord.getPPDrawingGroup().getDggContainer();
-        bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
-        if (bstore == null){
-            bstore = new EscherContainerRecord();
-            bstore.setRecordId( EscherContainerRecord.BSTORE_CONTAINER);
-
-            dggContainer.addChildBefore(bstore, EscherOptRecord.RECORD_ID);
-        } else {
-            Iterator<EscherRecord> iter = bstore.getChildIterator();
-            for (int i = 0; iter.hasNext(); i++) {
-                EscherBSERecord bse = (EscherBSERecord) iter.next();
-                if (Arrays.equals(bse.getUid(), uid)){
-                    return i + 1;
-                }
-             }
-        }
-
-        PictureData pict = PictureData.create(format);
-        pict.setData(data);
-
-        int offset = _hslfSlideShow.addPicture(pict);
-
-        EscherBSERecord bse = new EscherBSERecord();
-        bse.setRecordId(EscherBSERecord.RECORD_ID);
-        bse.setOptions( (short) ( 0x0002 | ( format << 4 ) ) );
-        bse.setSize(pict.getRawData().length + 8);
-        bse.setUid(uid);
-
-        bse.setBlipTypeMacOS((byte)format);
-        bse.setBlipTypeWin32((byte)format);
-
-        if (format == Picture.EMF) bse.setBlipTypeMacOS((byte)Picture.PICT);
-        else if (format == Picture.WMF) bse.setBlipTypeMacOS((byte)Picture.PICT);
-        else if (format == Picture.PICT) bse.setBlipTypeWin32((byte)Picture.WMF);
-
-        bse.setRef(0);
-        bse.setOffset(offset);
-        bse.setRemainingData( new byte[0] );
-
-        bstore.addChildRecord(bse);
-        int count = bstore.getChildRecords().size();
-        bstore.setOptions((short)( (count << 4) | 0xF ));
-
-        return count;
-    }
-
-    /**
-     * Adds a picture to this presentation and returns the associated index.
-     *
-     * @param pict       the file containing the image to add
-     * @param format    the format of the picture.  One of constans defined in the <code>Picture</code> class.
-     * @return          the index to this picture (1 based).
-     */
-    public int addPicture(File pict, int format) throws IOException {
-        int length = (int)pict.length();
-        byte[] data = new byte[length];
-        try {
-            FileInputStream is = new FileInputStream(pict);
-            is.read(data);
-            is.close();
-        } catch (IOException e){
-            throw new HSLFException(e);
-        }
-        return addPicture(data, format);
-    }
-
-    /**
-     * Add a font in this presentation
-     *
-     * @param font the font to add
-     * @return 0-based index of the font
-     */
-    public int addFont(PPFont font) {
-        FontCollection fonts = getDocumentRecord().getEnvironment().getFontCollection();
-        int idx = fonts.getFontIndex(font.getFontName());
-        if(idx == -1){
-            idx = fonts.addFont(font.getFontName(), font.getCharSet(), font.getFontFlags(), font.getFontType(), font.getPitchAndFamily());
-        }
-        return idx;
-    }
-
-    /**
-     * Get a font by index
-     *
-     * @param idx 0-based index of the font
-     * @return of an instance of <code>PPFont</code> or <code>null</code> if not found
-     */
-    public PPFont getFont(int idx) {
-        PPFont font = null;
-        FontCollection fonts = getDocumentRecord().getEnvironment().getFontCollection();
-        Record[] ch = fonts.getChildRecords();
-        for (int i = 0; i < ch.length; i++) {
-            if(ch[i] instanceof FontEntityAtom) {
-                FontEntityAtom atom = (FontEntityAtom)ch[i];
-                if(atom.getFontIndex() == idx){
-                    font = new PPFont(atom);
-                    break;
-                }
-            }
-        }
-        return font;
-    }
-
-    /**
-     * get the number of fonts in the presentation
-     *
-     * @return number of fonts
-     */
-    public int getNumberOfFonts() {
-        return getDocumentRecord().getEnvironment().getFontCollection().getNumberOfFonts();
-    }
-
-    /**
-     * Return  Header / Footer settings for slides
-     *
-     * @return Header / Footer settings for slides
-     */
-    public HeadersFooters getSlideHeadersFooters(){
-        //detect if this ppt was saved in Office2007
-        String tag = getSlidesMasters()[0].getProgrammableTag();
-        boolean ppt2007 = "___PPT12".equals(tag);
-
-        HeadersFootersContainer hdd = null;
-        Record[] ch = _documentRecord.getChildRecords();
-        for (int i = 0; i < ch.length; i++) {
-            if(ch[i] instanceof HeadersFootersContainer &&
-                    ((HeadersFootersContainer)ch[i]).getOptions() == HeadersFootersContainer.SlideHeadersFootersContainer){
-                hdd = (HeadersFootersContainer)ch[i];
-                break;
-            }
-        }
-        boolean newRecord = false;
-        if(hdd == null) {
-            hdd = new HeadersFootersContainer(HeadersFootersContainer.SlideHeadersFootersContainer);
-            newRecord = true;
-        }
-        return new HeadersFooters(hdd, this, newRecord, ppt2007);
-    }
-
-    /**
-     * Return  Header / Footer settings for notes
-     *
-     * @return Header / Footer settings for notes
-     */
-    public HeadersFooters getNotesHeadersFooters(){
-        //detect if this ppt was saved in Office2007
-        String tag = getSlidesMasters()[0].getProgrammableTag();
-        boolean ppt2007 = "___PPT12".equals(tag);
-
-        HeadersFootersContainer hdd = null;
-        Record[] ch = _documentRecord.getChildRecords();
-        for (int i = 0; i < ch.length; i++) {
-            if(ch[i] instanceof HeadersFootersContainer &&
-                    ((HeadersFootersContainer)ch[i]).getOptions() == HeadersFootersContainer.NotesHeadersFootersContainer){
-                hdd = (HeadersFootersContainer)ch[i];
-                break;
-           }
-        }
-        boolean newRecord = false;
-        if(hdd == null) {
-            hdd = new HeadersFootersContainer(HeadersFootersContainer.NotesHeadersFootersContainer);
-            newRecord = true;
-        }
-        if(ppt2007 && _notes.length > 0){
-            return new HeadersFooters(hdd, _notes[0], newRecord, ppt2007);
-        } else {
-            return new HeadersFooters(hdd, this, newRecord, ppt2007);
-        }
-    }
-
-    /**
-     * Add a movie in this presentation
-     *
-     * @param path the path or url to the movie
-     * @return 0-based index of the movie
-     */
-    public int addMovie(String path, int type) {
-        ExObjList lst = (ExObjList)_documentRecord.findFirstOfType(RecordTypes.ExObjList.typeID);
-        if(lst == null){
-            lst = new ExObjList();
-            _documentRecord.addChildAfter(lst, _documentRecord.getDocumentAtom());
-        }
-
-        ExObjListAtom objAtom = lst.getExObjListAtom();
-        //increment the object ID seed
-        int objectId = (int)objAtom.getObjectIDSeed() + 1;
-        objAtom.setObjectIDSeed(objectId);
-        ExMCIMovie mci;
-        switch (type){
-            case MovieShape.MOVIE_MPEG:
-                mci = new ExMCIMovie();
-                break;
-            case MovieShape.MOVIE_AVI:
-                mci = new ExAviMovie();
-                break;
-            default:
-                throw new IllegalArgumentException("Unsupported Movie: " + type);
-        }
-
-        lst.appendChildRecord(mci);
-        ExVideoContainer exVideo = mci.getExVideo();
-        exVideo.getExMediaAtom().setObjectId(objectId);
-        exVideo.getExMediaAtom().setMask(0xE80000);
-        exVideo.getPathAtom().setText(path);
-        return objectId;
-    }
-
-    /**
-     * Add a control in this presentation
-     *
-     * @param name   name of the control, e.g. "Shockwave Flash Object"
-     * @param progId OLE Programmatic Identifier, e.g. "ShockwaveFlash.ShockwaveFlash.9"
-     * @return 0-based index of the control
-     */
-    public int addControl(String name, String progId) {
-        ExObjList lst = (ExObjList)_documentRecord.findFirstOfType(RecordTypes.ExObjList.typeID);
-        if (lst == null) {
-            lst = new ExObjList();
-            _documentRecord.addChildAfter(lst, _documentRecord.getDocumentAtom());
-        }
-        ExObjListAtom objAtom = lst.getExObjListAtom();
-        //increment the object ID seed
-        int objectId = (int) objAtom.getObjectIDSeed() + 1;
-        objAtom.setObjectIDSeed(objectId);
-        ExControl ctrl = new ExControl();
-        ExOleObjAtom oleObj = ctrl.getExOleObjAtom();
-        oleObj.setObjID(objectId);
-        oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
-        oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
-        oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
-
-        ctrl.setProgId(progId);
-        ctrl.setMenuName(name);
-        ctrl.setClipboardName(name);
-        lst.addChildAfter(ctrl, objAtom);
-
-        return objectId;
-    }
-
-    /**
-     * Add a hyperlink to this presentation
-     *
-     * @return 0-based index of the hyperlink
-     */
-    public int addHyperlink(Hyperlink link) {
-        ExObjList lst = (ExObjList)_documentRecord.findFirstOfType(RecordTypes.ExObjList.typeID);
-        if (lst == null) {
-            lst = new ExObjList();
-            _documentRecord.addChildAfter(lst, _documentRecord.getDocumentAtom());
-        }
-        ExObjListAtom objAtom = lst.getExObjListAtom();
-        //increment the object ID seed
-        int objectId = (int) objAtom.getObjectIDSeed() + 1;
-        objAtom.setObjectIDSeed(objectId);
-
-        ExHyperlink ctrl = new ExHyperlink();
-        ExHyperlinkAtom obj = ctrl.getExHyperlinkAtom();
-        obj.setNumber(objectId);
-        ctrl.setLinkURL(link.getAddress());
-        ctrl.setLinkTitle(link.getTitle());
-        lst.addChildAfter(ctrl, objAtom);
-        link.setId(objectId);
-
-        return objectId;
-    }
+       /**
+        * Adds a picture to this presentation and returns the associated index.
+        *
+        * @param pict
+        *            the file containing the image to add
+        * @param format
+        *            the format of the picture. One of constans defined in the
+        *            <code>Picture</code> class.
+        * @return the index to this picture (1 based).
+        */
+       public int addPicture(File pict, int format) throws IOException {
+               int length = (int) pict.length();
+               byte[] data = new byte[length];
+               try {
+                       FileInputStream is = new FileInputStream(pict);
+                       is.read(data);
+                       is.close();
+               } catch (IOException e) {
+                       throw new HSLFException(e);
+               }
+               return addPicture(data, format);
+       }
+
+       /**
+        * Add a font in this presentation
+        *
+        * @param font
+        *            the font to add
+        * @return 0-based index of the font
+        */
+       public int addFont(PPFont font) {
+               FontCollection fonts = getDocumentRecord().getEnvironment().getFontCollection();
+               int idx = fonts.getFontIndex(font.getFontName());
+               if (idx == -1) {
+                       idx = fonts.addFont(font.getFontName(), font.getCharSet(), font.getFontFlags(), font
+                                       .getFontType(), font.getPitchAndFamily());
+               }
+               return idx;
+       }
+
+       /**
+        * Get a font by index
+        *
+        * @param idx
+        *            0-based index of the font
+        * @return of an instance of <code>PPFont</code> or <code>null</code> if not
+        *         found
+        */
+       public PPFont getFont(int idx) {
+               PPFont font = null;
+               FontCollection fonts = getDocumentRecord().getEnvironment().getFontCollection();
+               Record[] ch = fonts.getChildRecords();
+               for (int i = 0; i < ch.length; i++) {
+                       if (ch[i] instanceof FontEntityAtom) {
+                               FontEntityAtom atom = (FontEntityAtom) ch[i];
+                               if (atom.getFontIndex() == idx) {
+                                       font = new PPFont(atom);
+                                       break;
+                               }
+                       }
+               }
+               return font;
+       }
+
+       /**
+        * get the number of fonts in the presentation
+        *
+        * @return number of fonts
+        */
+       public int getNumberOfFonts() {
+               return getDocumentRecord().getEnvironment().getFontCollection().getNumberOfFonts();
+       }
+
+       /**
+        * Return Header / Footer settings for slides
+        *
+        * @return Header / Footer settings for slides
+        */
+       public HeadersFooters getSlideHeadersFooters() {
+               // detect if this ppt was saved in Office2007
+               String tag = getSlidesMasters()[0].getProgrammableTag();
+               boolean ppt2007 = "___PPT12".equals(tag);
+
+               HeadersFootersContainer hdd = null;
+               Record[] ch = _documentRecord.getChildRecords();
+               for (int i = 0; i < ch.length; i++) {
+                       if (ch[i] instanceof HeadersFootersContainer
+                                       && ((HeadersFootersContainer) ch[i]).getOptions() == HeadersFootersContainer.SlideHeadersFootersContainer) {
+                               hdd = (HeadersFootersContainer) ch[i];
+                               break;
+                       }
+               }
+               boolean newRecord = false;
+               if (hdd == null) {
+                       hdd = new HeadersFootersContainer(HeadersFootersContainer.SlideHeadersFootersContainer);
+                       newRecord = true;
+               }
+               return new HeadersFooters(hdd, this, newRecord, ppt2007);
+       }
+
+       /**
+        * Return Header / Footer settings for notes
+        *
+        * @return Header / Footer settings for notes
+        */
+       public HeadersFooters getNotesHeadersFooters() {
+               // detect if this ppt was saved in Office2007
+               String tag = getSlidesMasters()[0].getProgrammableTag();
+               boolean ppt2007 = "___PPT12".equals(tag);
+
+               HeadersFootersContainer hdd = null;
+               Record[] ch = _documentRecord.getChildRecords();
+               for (int i = 0; i < ch.length; i++) {
+                       if (ch[i] instanceof HeadersFootersContainer
+                                       && ((HeadersFootersContainer) ch[i]).getOptions() == HeadersFootersContainer.NotesHeadersFootersContainer) {
+                               hdd = (HeadersFootersContainer) ch[i];
+                               break;
+                       }
+               }
+               boolean newRecord = false;
+               if (hdd == null) {
+                       hdd = new HeadersFootersContainer(HeadersFootersContainer.NotesHeadersFootersContainer);
+                       newRecord = true;
+               }
+               if (ppt2007 && _notes.length > 0) {
+                       return new HeadersFooters(hdd, _notes[0], newRecord, ppt2007);
+               } else {
+                       return new HeadersFooters(hdd, this, newRecord, ppt2007);
+               }
+       }
+
+       /**
+        * Add a movie in this presentation
+        *
+        * @param path
+        *            the path or url to the movie
+        * @return 0-based index of the movie
+        */
+       public int addMovie(String path, int type) {
+               ExObjList lst = (ExObjList) _documentRecord.findFirstOfType(RecordTypes.ExObjList.typeID);
+               if (lst == null) {
+                       lst = new ExObjList();
+                       _documentRecord.addChildAfter(lst, _documentRecord.getDocumentAtom());
+               }
+
+               ExObjListAtom objAtom = lst.getExObjListAtom();
+               // increment the object ID seed
+               int objectId = (int) objAtom.getObjectIDSeed() + 1;
+               objAtom.setObjectIDSeed(objectId);
+               ExMCIMovie mci;
+               switch (type) {
+                       case MovieShape.MOVIE_MPEG:
+                               mci = new ExMCIMovie();
+                               break;
+                       case MovieShape.MOVIE_AVI:
+                               mci = new ExAviMovie();
+                               break;
+                       default:
+                               throw new IllegalArgumentException("Unsupported Movie: " + type);
+               }
+
+               lst.appendChildRecord(mci);
+               ExVideoContainer exVideo = mci.getExVideo();
+               exVideo.getExMediaAtom().setObjectId(objectId);
+               exVideo.getExMediaAtom().setMask(0xE80000);
+               exVideo.getPathAtom().setText(path);
+               return objectId;
+       }
+
+       /**
+        * Add a control in this presentation
+        *
+        * @param name
+        *            name of the control, e.g. "Shockwave Flash Object"
+        * @param progId
+        *            OLE Programmatic Identifier, e.g.
+        *            "ShockwaveFlash.ShockwaveFlash.9"
+        * @return 0-based index of the control
+        */
+       public int addControl(String name, String progId) {
+               ExObjList lst = (ExObjList) _documentRecord.findFirstOfType(RecordTypes.ExObjList.typeID);
+               if (lst == null) {
+                       lst = new ExObjList();
+                       _documentRecord.addChildAfter(lst, _documentRecord.getDocumentAtom());
+               }
+               ExObjListAtom objAtom = lst.getExObjListAtom();
+               // increment the object ID seed
+               int objectId = (int) objAtom.getObjectIDSeed() + 1;
+               objAtom.setObjectIDSeed(objectId);
+               ExControl ctrl = new ExControl();
+               ExOleObjAtom oleObj = ctrl.getExOleObjAtom();
+               oleObj.setObjID(objectId);
+               oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+               oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
+               oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
+
+               ctrl.setProgId(progId);
+               ctrl.setMenuName(name);
+               ctrl.setClipboardName(name);
+               lst.addChildAfter(ctrl, objAtom);
+
+               return objectId;
+       }
+
+       /**
+        * Add a hyperlink to this presentation
+        *
+        * @return 0-based index of the hyperlink
+        */
+       public int addHyperlink(Hyperlink link) {
+               ExObjList lst = (ExObjList) _documentRecord.findFirstOfType(RecordTypes.ExObjList.typeID);
+               if (lst == null) {
+                       lst = new ExObjList();
+                       _documentRecord.addChildAfter(lst, _documentRecord.getDocumentAtom());
+               }
+               ExObjListAtom objAtom = lst.getExObjListAtom();
+               // increment the object ID seed
+               int objectId = (int) objAtom.getObjectIDSeed() + 1;
+               objAtom.setObjectIDSeed(objectId);
+
+               ExHyperlink ctrl = new ExHyperlink();
+               ExHyperlinkAtom obj = ctrl.getExHyperlinkAtom();
+               obj.setNumber(objectId);
+               ctrl.setLinkURL(link.getAddress());
+               ctrl.setLinkTitle(link.getTitle());
+               lst.addChildAfter(ctrl, objAtom);
+               link.setId(objectId);
+
+               return objectId;
+       }
 }
index fed2e0643df97183bc7deb515618f3f7f23c3ccd..489b35af5d2bbd8e8012c12ee4865bc954711d66 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hwpf.model;
 
-import org.apache.poi.util.LittleEndian;
 import org.apache.poi.hwpf.model.types.DOPAbstractType;
 
 /**
@@ -25,13 +24,10 @@ import org.apache.poi.hwpf.model.types.DOPAbstractType;
  *
  * @author Ryan Ackley
  */
+public final class DocumentProperties extends DOPAbstractType {
 
-public final class DocumentProperties extends DOPAbstractType
-{
 
-
-  public DocumentProperties(byte[] tableStream, int offset)
-  {
-    super.fillFields(tableStream, offset);
-  }
+       public DocumentProperties(byte[] tableStream, int offset) {
+               super.fillFields(tableStream, offset);
+       }
 }
index 755c37b40746c4d5d74e2cdf442c158474b246bb..37f5e129b4c25f798128028f06c36ef62f9156a8 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hwpf.model;
 
-import org.apache.poi.poifs.common.POIFSConstants;
 import org.apache.poi.util.LittleEndian;
 
 import java.util.ArrayList;
@@ -40,8 +39,7 @@ import java.util.Arrays;
  *
  * @author Ryan Ackley
  */
-public final class PAPFormattedDiskPage extends FormattedDiskPage
-{
+public final class PAPFormattedDiskPage extends FormattedDiskPage {
 
     private static final int BX_SIZE = 13;
     private static final int FC_SIZE = 4;
index e8a161073989786166aa2a7467f4422ea59ccc67..c0a6a029aa66cc60f234a8f327cc2696edc4b3f5 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hwpf.model;
 
-import java.util.*;
 import java.io.IOException;
 
 import org.apache.poi.util.LittleEndian;
@@ -35,9 +34,7 @@ import org.apache.poi.hwpf.sprm.CharacterSprmUncompressor;
  *
  * @author Ryan Ackley
  */
-
-public final class StyleSheet implements HDFType
-{
+public final class StyleSheet implements HDFType {
 
   public static final int NIL_STYLE = 4095;
   private static final int PAP_TYPE = 1;
index 16dd648c7cce42940afe279db2ec0d6e6e45724f..65dc9e19135c6b9ae58171e97caa67cb02fcf7ec 100644 (file)
 
 package org.apache.poi.hwpf.model;
 
-
 import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.poifs.common.POIFSConstants;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 
 /**
- * The piece table for matching up character positions
- *  to bits of text.
- * This mostly works in bytes, but the TextPieces
- *  themselves work in characters. This does the icky
- *  convertion.
+ * The piece table for matching up character positions to bits of text. This
+ * mostly works in bytes, but the TextPieces themselves work in characters. This
+ * does the icky convertion.
+ *
  * @author Ryan Ackley
  */
-public final class TextPieceTable implements CharIndexTranslator
-{
-  protected ArrayList _textPieces = new ArrayList();
-  //int _multiple;
-  int _cpMin;
-
-  public TextPieceTable() {
-  }
-
-  public TextPieceTable(byte[] documentStream, byte[] tableStream, int offset,
-                        int size, int fcMin)
-    throws UnsupportedEncodingException
-  {
-    // get our plex of PieceDescriptors
-    PlexOfCps pieceTable = new PlexOfCps(tableStream, offset, size, PieceDescriptor.getSizeInBytes());
-
-    int length = pieceTable.length();
-    PieceDescriptor[] pieces = new PieceDescriptor[length];
-
-    // iterate through piece descriptors raw bytes and create
-    // PieceDescriptor objects
-    for (int x = 0; x < length; x++)
-    {
-      GenericPropertyNode node = pieceTable.getProperty(x);
-      pieces[x] = new PieceDescriptor(node.getBytes(), 0);
-    }
-
-
-    // Figure out the cp of the earliest text piece
-    // Note that text pieces don't have to be stored in order!
-    _cpMin = pieces[0].getFilePosition() - fcMin;
-    for (int x = 0; x < pieces.length; x++) {
-       int start = pieces[x].getFilePosition() - fcMin;
-       if(start < _cpMin) {
-               _cpMin = start;
-       }
-    }
-
-
-    // using the PieceDescriptors, build our list of TextPieces.
-    for (int x = 0; x < pieces.length; x++)
-    {
-      int start = pieces[x].getFilePosition();
-      PropertyNode node = pieceTable.getProperty(x);
-
-      // Grab the start and end, which are in characters
-      int nodeStartChars = node.getStart();
-      int nodeEndChars = node.getEnd();
-
-      // What's the relationship between bytes and characters?
-      boolean unicode = pieces[x].isUnicode();
-      int multiple = 1;
-      if (unicode) {
-        multiple = 2;
-      }
-
-      // Figure out the length, in bytes and chars
-      int textSizeChars = (nodeEndChars - nodeStartChars);
-      int textSizeBytes = textSizeChars * multiple;
-
-      // Grab the data that makes up the piece
-      byte[] buf = new byte[textSizeBytes];
-      System.arraycopy(documentStream, start, buf, 0, textSizeBytes);
-
-      // And now build the piece
-      _textPieces.add(new TextPiece(nodeStartChars, nodeEndChars, buf, pieces[x], node.getStart()));
-    }
-
-    // In the interest of our sanity, now sort the text pieces
-    //  into order, if they're not already
-    TextPiece[] tp = (TextPiece[])
-       _textPieces.toArray(new TextPiece[_textPieces.size()]);
-    Arrays.sort(tp);
-    for(int i=0; i<tp.length; i++) {
-       _textPieces.set(i, tp[i]);
-    }
-  }
-
-  public int getCpMin()
-  {
-    return _cpMin;
-  }
-
-  public List getTextPieces()
-  {
-    return _textPieces;
-  }
-
-  /**
-   * Is the text at the given Character offset
-   *  unicode, or plain old ascii?
-   * In a very evil fashion, you have to actually
-   *  know this to make sense of character and
-   *  paragraph properties :(
-   * @param cp The character offset to check about
-   */
-  public boolean isUnicodeAtCharOffset(int cp) {
-         boolean lastWas = false;
-
-         Iterator it = _textPieces.iterator();
-         while(it.hasNext()) {
-                 TextPiece tp = (TextPiece)it.next();
-                 // If the text piece covers the character, all good
-                 if(tp.getStart() <= cp && tp.getEnd() >= cp) {
-                         return tp.isUnicode();
-                 }
-                 // Otherwise keep track for the last one
-                 lastWas = tp.isUnicode();
-         }
-
-         // If they ask off the end, just go with the last one...
-         return lastWas;
-  }
-
-  public boolean isUnicodeAtByteOffset(int bytePos) {
-         boolean lastWas = false;
-        
-
-         Iterator it = _textPieces.iterator();
-         while(it.hasNext()) {
-                 TextPiece tp = (TextPiece)it.next();
-                 int curByte = tp.getPieceDescriptor().getFilePosition();
-                 int pieceEnd = curByte + tp.bytesLength();
-
-                 // If the text piece covers the character, all good
-                 if(curByte <= bytePos && pieceEnd > bytePos) {
-                         return tp.isUnicode();
-                 }
-                 // Otherwise keep track for the last one
-                 lastWas = tp.isUnicode();
-                 // Move along
-                 curByte = pieceEnd;
-         }
-
-         // If they ask off the end, just go with the last one...
-         return lastWas;
-  }
-
-  public byte[] writeTo(HWPFOutputStream docStream)
-    throws IOException
-  {
-
-    PlexOfCps textPlex = new PlexOfCps(PieceDescriptor.getSizeInBytes());
-    //int fcMin = docStream.getOffset();
-
-    int size = _textPieces.size();
-    for (int x = 0; x < size; x++)
-    {
-      TextPiece next = (TextPiece)_textPieces.get(x);
-      PieceDescriptor pd = next.getPieceDescriptor();
-
-      int offset = docStream.getOffset();
-      int mod = (offset % POIFSConstants.BIG_BLOCK_SIZE);
-      if (mod != 0)
-      {
-        mod = POIFSConstants.BIG_BLOCK_SIZE - mod;
-        byte[] buf = new byte[mod];
-        docStream.write(buf);
-      }
-
-
-      // set the text piece position to the current docStream offset.
-      pd.setFilePosition(docStream.getOffset());
-
-      // write the text to the docstream and save the piece descriptor to the
-      // plex which will be written later to the tableStream.
-      docStream.write(next.getRawBytes());
-
-      // The TextPiece is already in characters, which
-      //  makes our life much easier
-      int nodeStart = next.getStart();
-      int nodeEnd = next.getEnd();
-      textPlex.addProperty(new GenericPropertyNode(nodeStart, nodeEnd,
-        pd.toByteArray()));
-    }
-
-    return textPlex.toByteArray();
-
-  }
-
-  /**
-   * Adjust all the text piece after inserting
-   *  some text into one of them
-   * @param listIndex The TextPiece that had characters inserted into
-   * @param length The number of characters inserted
-   */
-  public int adjustForInsert(int listIndex, int length) {
-    int size = _textPieces.size();
-
-    TextPiece tp = (TextPiece)_textPieces.get(listIndex);
-
-    // Update with the new end
-    tp.setEnd(tp.getEnd() + length);
-
-    // Now change all subsequent ones
-    for (int x = listIndex + 1; x < size; x++)
-    {
-      tp = (TextPiece)_textPieces.get(x);
-      tp.setStart(tp.getStart() + length);
-      tp.setEnd(tp.getEnd() + length);
-    }
-
-    // All done
-    return length;
-  }
-
-
-  public boolean equals(Object o)
-  {
-    TextPieceTable tpt = (TextPieceTable)o;
-
-    int size = tpt._textPieces.size();
-    if (size == _textPieces.size())
-    {
-      for (int x = 0; x < size; x++)
-      {
-        if (!tpt._textPieces.get(x).equals(_textPieces.get(x)))
-        {
-          return false;
-        }
-      }
-      return true;
-    }
-    return false;
-  }
-       /* (non-Javadoc)
-        * @see org.apache.poi.hwpf.model.CharIndexTranslator#getLengthInChars(int)
+public final class TextPieceTable implements CharIndexTranslator {
+       protected ArrayList _textPieces = new ArrayList();
+       // int _multiple;
+       int _cpMin;
+
+       public TextPieceTable() {
+       }
+
+       public TextPieceTable(byte[] documentStream, byte[] tableStream, int offset, int size, int fcMin) {
+               // get our plex of PieceDescriptors
+               PlexOfCps pieceTable = new PlexOfCps(tableStream, offset, size, PieceDescriptor
+                               .getSizeInBytes());
+
+               int length = pieceTable.length();
+               PieceDescriptor[] pieces = new PieceDescriptor[length];
+
+               // iterate through piece descriptors raw bytes and create
+               // PieceDescriptor objects
+               for (int x = 0; x < length; x++) {
+                       GenericPropertyNode node = pieceTable.getProperty(x);
+                       pieces[x] = new PieceDescriptor(node.getBytes(), 0);
+               }
+
+               // Figure out the cp of the earliest text piece
+               // Note that text pieces don't have to be stored in order!
+               _cpMin = pieces[0].getFilePosition() - fcMin;
+               for (int x = 0; x < pieces.length; x++) {
+                       int start = pieces[x].getFilePosition() - fcMin;
+                       if (start < _cpMin) {
+                               _cpMin = start;
+                       }
+               }
+
+               // using the PieceDescriptors, build our list of TextPieces.
+               for (int x = 0; x < pieces.length; x++) {
+                       int start = pieces[x].getFilePosition();
+                       PropertyNode node = pieceTable.getProperty(x);
+
+                       // Grab the start and end, which are in characters
+                       int nodeStartChars = node.getStart();
+                       int nodeEndChars = node.getEnd();
+
+                       // What's the relationship between bytes and characters?
+                       boolean unicode = pieces[x].isUnicode();
+                       int multiple = 1;
+                       if (unicode) {
+                               multiple = 2;
+                       }
+
+                       // Figure out the length, in bytes and chars
+                       int textSizeChars = (nodeEndChars - nodeStartChars);
+                       int textSizeBytes = textSizeChars * multiple;
+
+                       // Grab the data that makes up the piece
+                       byte[] buf = new byte[textSizeBytes];
+                       System.arraycopy(documentStream, start, buf, 0, textSizeBytes);
+
+                       // And now build the piece
+                       _textPieces.add(new TextPiece(nodeStartChars, nodeEndChars, buf, pieces[x], node
+                                       .getStart()));
+               }
+
+               // In the interest of our sanity, now sort the text pieces
+               // into order, if they're not already
+               TextPiece[] tp = (TextPiece[]) _textPieces.toArray(new TextPiece[_textPieces.size()]);
+               Arrays.sort(tp);
+               for (int i = 0; i < tp.length; i++) {
+                       _textPieces.set(i, tp[i]);
+               }
+       }
+
+       public int getCpMin() {
+               return _cpMin;
+       }
+
+       public List getTextPieces() {
+               return _textPieces;
+       }
+
+       /**
+        * Is the text at the given Character offset unicode, or plain old ascii? In
+        * a very evil fashion, you have to actually know this to make sense of
+        * character and paragraph properties :(
+        *
+        * @param cp
+        *            The character offset to check about
+        */
+       public boolean isUnicodeAtCharOffset(int cp) {
+               boolean lastWas = false;
+
+               Iterator it = _textPieces.iterator();
+               while (it.hasNext()) {
+                       TextPiece tp = (TextPiece) it.next();
+                       // If the text piece covers the character, all good
+                       if (tp.getStart() <= cp && tp.getEnd() >= cp) {
+                               return tp.isUnicode();
+                       }
+                       // Otherwise keep track for the last one
+                       lastWas = tp.isUnicode();
+               }
+
+               // If they ask off the end, just go with the last one...
+               return lastWas;
+       }
+
+       public boolean isUnicodeAtByteOffset(int bytePos) {
+               boolean lastWas = false;
+
+               Iterator it = _textPieces.iterator();
+               while (it.hasNext()) {
+                       TextPiece tp = (TextPiece) it.next();
+                       int curByte = tp.getPieceDescriptor().getFilePosition();
+                       int pieceEnd = curByte + tp.bytesLength();
+
+                       // If the text piece covers the character, all good
+                       if (curByte <= bytePos && pieceEnd > bytePos) {
+                               return tp.isUnicode();
+                       }
+                       // Otherwise keep track for the last one
+                       lastWas = tp.isUnicode();
+                       // Move along
+                       curByte = pieceEnd;
+               }
+
+               // If they ask off the end, just go with the last one...
+               return lastWas;
+       }
+
+       public byte[] writeTo(HWPFOutputStream docStream) throws IOException {
+
+               PlexOfCps textPlex = new PlexOfCps(PieceDescriptor.getSizeInBytes());
+               // int fcMin = docStream.getOffset();
+
+               int size = _textPieces.size();
+               for (int x = 0; x < size; x++) {
+                       TextPiece next = (TextPiece) _textPieces.get(x);
+                       PieceDescriptor pd = next.getPieceDescriptor();
+
+                       int offset = docStream.getOffset();
+                       int mod = (offset % POIFSConstants.BIG_BLOCK_SIZE);
+                       if (mod != 0) {
+                               mod = POIFSConstants.BIG_BLOCK_SIZE - mod;
+                               byte[] buf = new byte[mod];
+                               docStream.write(buf);
+                       }
+
+                       // set the text piece position to the current docStream offset.
+                       pd.setFilePosition(docStream.getOffset());
+
+                       // write the text to the docstream and save the piece descriptor to
+                       // the
+                       // plex which will be written later to the tableStream.
+                       docStream.write(next.getRawBytes());
+
+                       // The TextPiece is already in characters, which
+                       // makes our life much easier
+                       int nodeStart = next.getStart();
+                       int nodeEnd = next.getEnd();
+                       textPlex.addProperty(new GenericPropertyNode(nodeStart, nodeEnd, pd.toByteArray()));
+               }
+
+               return textPlex.toByteArray();
+
+       }
+
+       /**
+        * Adjust all the text piece after inserting some text into one of them
+        *
+        * @param listIndex
+        *            The TextPiece that had characters inserted into
+        * @param length
+        *            The number of characters inserted
         */
+       public int adjustForInsert(int listIndex, int length) {
+               int size = _textPieces.size();
+
+               TextPiece tp = (TextPiece) _textPieces.get(listIndex);
+
+               // Update with the new end
+               tp.setEnd(tp.getEnd() + length);
+
+               // Now change all subsequent ones
+               for (int x = listIndex + 1; x < size; x++) {
+                       tp = (TextPiece) _textPieces.get(x);
+                       tp.setStart(tp.getStart() + length);
+                       tp.setEnd(tp.getEnd() + length);
+               }
+
+               // All done
+               return length;
+       }
+
+       public boolean equals(Object o) {
+               TextPieceTable tpt = (TextPieceTable) o;
+
+               int size = tpt._textPieces.size();
+               if (size == _textPieces.size()) {
+                       for (int x = 0; x < size; x++) {
+                               if (!tpt._textPieces.get(x).equals(_textPieces.get(x))) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               }
+               return false;
+       }
+
        public int getCharIndex(int bytePos) {
                int charCount = 0;
 
@@ -272,15 +247,14 @@ public final class TextPieceTable implements CharIndexTranslator
                while (it.hasNext()) {
                        TextPiece tp = (TextPiece) it.next();
                        int pieceStart = tp.getPieceDescriptor().getFilePosition();
-                       if(pieceStart >= bytePos) {
+                       if (pieceStart >= bytePos) {
                                break;
                        }
-                       
+
                        int bytesLength = tp.bytesLength();
                        int pieceEnd = pieceStart + bytesLength;
 
-                       int toAdd = bytePos > pieceEnd ? bytesLength : bytesLength
-                                       - (pieceEnd - bytePos);
+                       int toAdd = bytePos > pieceEnd ? bytesLength : bytesLength - (pieceEnd - bytePos);
 
                        if (tp.isUnicode()) {
                                charCount += toAdd / 2;
@@ -291,5 +265,5 @@ public final class TextPieceTable implements CharIndexTranslator
 
                return charCount;
        }
-       
+
 }
index fad6c7e462507e31a6789577e6db4649095c356e..de5896ea400d04f73bbae906e25a287c8ed384f6 100644 (file)
@@ -19,13 +19,12 @@ package org.apache.poi.hwpf.model.types;
 
 
 
+import org.apache.poi.hdf.model.hdftypes.HDFType;
+import org.apache.poi.hwpf.usermodel.BorderCode;
+import org.apache.poi.hwpf.usermodel.DateAndTime;
+import org.apache.poi.hwpf.usermodel.ShadingDescriptor;
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
-import org.apache.poi.hdf.model.hdftypes.HDFType;
-import org.apache.poi.hwpf.usermodel.*;
 
 /**
  * Character Properties.
index 9f7b04c95a80db7581edb40583cb0c156f2f4d96..d7530196abf9b6e965702c8f0ea38ba4d2f39023 100644 (file)
 package org.apache.poi.hwpf.model.types;
 
 
-
+import org.apache.poi.hdf.model.hdftypes.HDFType;
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
-import org.apache.poi.hdf.model.hdftypes.HDFType;
-import org.apache.poi.hwpf.usermodel.*;
 
 /**
  * Document Properties.
  * NOTE: This source is automatically generated please do not modify this file.  Either subclass or
  *       remove the record in src/records/definitions.
-
+ *
  * @author S. Ryan Ackley
  */
-public abstract class DOPAbstractType
-    implements HDFType
-{
+public abstract class DOPAbstractType implements HDFType {
 
     protected  byte field_1_formatFlags;
         private static BitField  fFacingPages = BitFieldFactory.getInstance(0x01);
index 554d342acee35d8184e4fbb58288dc32798efa12..eebde482686a87bdf6262e04c43b72f55a3aa4e3 100644 (file)
 package org.apache.poi.hwpf.model.types;
 
 
-
+import org.apache.poi.hdf.model.hdftypes.HDFType;
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
-import org.apache.poi.hdf.model.hdftypes.HDFType;
-import org.apache.poi.hwpf.usermodel.*;
 
 /**
  * Base part of the File information Block (FibBase). Holds the core part of the FIB, from the first 32 bytes.
  * NOTE: This source is automatically generated please do not modify this file.  Either subclass or
  *       remove the record in src/records/definitions.
-
+ *
  * @author Andrew C. Oliver
  */
-public abstract class FIBAbstractType
-    implements HDFType
-{
+public abstract class FIBAbstractType implements HDFType {
 
     protected  int field_1_wIdent;
     protected  int field_2_nFib;
index 70460caaca4c790ef68191d507e77c1a392f39c3..158edb34e93475e3a81623aa576891ec2eda3d6a 100644 (file)
 package org.apache.poi.hwpf.model.types;
 
 
-
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.BitFieldFactory;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
 import org.apache.poi.hdf.model.hdftypes.HDFType;
 import org.apache.poi.hwpf.usermodel.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
 
 /**
  * Paragraph Properties.
  * NOTE: This source is automatically generated please do not modify this file.  Either subclass or
  *       remove the record in src/records/definitions.
-
+ *
  * @author S. Ryan Ackley
  */
-public abstract class PAPAbstractType
-    implements HDFType
-{
+public abstract class PAPAbstractType implements HDFType {
 
     protected  int field_1_istd;
     protected  byte field_2_jc;
index d1548f73b8a44292931d355381b2de364d937ce6..b1856cd5c291d57c6d0b389efb5219168eaecd9d 100644 (file)
 package org.apache.poi.hwpf.model.types;
 
 
-
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
 import org.apache.poi.hdf.model.hdftypes.HDFType;
-import org.apache.poi.hwpf.usermodel.*;
+import org.apache.poi.hwpf.usermodel.BorderCode;
+import org.apache.poi.hwpf.usermodel.DateAndTime;
 
 /**
  * Section Properties.
  * NOTE: This source is automatically generated please do not modify this file.  Either subclass or
  *       remove the record in src/records/definitions.
-
+ *
  * @author S. Ryan Ackley
  */
-public abstract class SEPAbstractType
-    implements HDFType
-{
+public abstract class SEPAbstractType implements HDFType {
 
     protected  byte field_1_bkc;
     protected  boolean field_2_fTitlePage;
index f1de3e114b198fc39088996b7f19faa09a086a12..2230b4816be6b25e761dfeea953c5867cff64bf7 100644 (file)
 package org.apache.poi.hwpf.model.types;
 
 
-
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
 import org.apache.poi.hdf.model.hdftypes.HDFType;
-import org.apache.poi.hwpf.usermodel.*;
+import org.apache.poi.hwpf.usermodel.BorderCode;
+import org.apache.poi.hwpf.usermodel.ShadingDescriptor;
+import org.apache.poi.hwpf.usermodel.TableCellDescriptor;
 
 /**
  * Table Properties.
  * NOTE: This source is automatically generated please do not modify this file.  Either subclass or
  *       remove the record in src/records/definitions.
-
+ *
  * @author S. Ryan Ackley
  */
-public abstract class TAPAbstractType
-    implements HDFType
-{
+public abstract class TAPAbstractType implements HDFType {
 
     protected  int field_1_jc;
     protected  int field_2_dxaGapHalf;
index e7b97ee4ffd8e964f958f8025c2240925949d617..d5a993566b6f63c2b9b0882bd66037de17551e24 100644 (file)
 package org.apache.poi.hwpf.model.types;
 
 
-
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.HexDump;
 import org.apache.poi.hdf.model.hdftypes.HDFType;
 import org.apache.poi.hwpf.usermodel.*;
 
@@ -34,9 +31,7 @@ import org.apache.poi.hwpf.usermodel.*;
 
  * @author S. Ryan Ackley
  */
-public abstract class TCAbstractType
-    implements HDFType
-{
+public abstract class TCAbstractType implements HDFType {
 
     protected  short field_1_rgf;
         private static BitField  fFirstMerged = BitFieldFactory.getInstance(0x0001);
index 2938df8ab66683385bc900ca4a7c321df500fb01..9f65d0d485a273dcfd229a481169cf348e35afb7 100644 (file)
@@ -18,8 +18,6 @@
 package org.apache.poi.hwpf.sprm;
 
 import java.util.ArrayList;
-import java.util.List;
-import java.util.Arrays;
 
 import org.apache.poi.hwpf.usermodel.CharacterProperties;
 import org.apache.poi.util.LittleEndian;
index aa989209661c0130a0623c455f8dc975922c4a9d..7dabf810f98786597b3615081d7213eb28c3c3b5 100644 (file)
@@ -21,7 +21,6 @@ import org.apache.poi.hwpf.usermodel.CharacterProperties;
 import org.apache.poi.hwpf.usermodel.DateAndTime;
 import org.apache.poi.hwpf.usermodel.BorderCode;
 import org.apache.poi.hwpf.usermodel.ShadingDescriptor;
-import org.apache.poi.hwpf.model.StyleSheet;
 import org.apache.poi.util.LittleEndian;
 
 public final class CharacterSprmUncompressor
index c3e48d522691ac612917e5b58e560f987ae6d070..67af3ecca0071a9dfa4165bfaf23508731c9a68a 100644 (file)
@@ -34,7 +34,7 @@ public final class ParagraphSprmCompressor
   public static byte[] compressParagraphProperty(ParagraphProperties newPAP,
                                                  ParagraphProperties oldPAP)
   {
-    ArrayList sprmList = new ArrayList();
+    List sprmList = new ArrayList();
     int size = 0;
 
     if (newPAP.getJc() != oldPAP.getJc())
index 235f435c2cce8a0e77107cf8d32561384417ed4e..e8de893a2e7c4f46748f5ffdbf23ef63d001ef4f 100644 (file)
@@ -26,7 +26,6 @@ import org.apache.poi.hwpf.usermodel.DropCapSpecifier;
 import org.apache.poi.util.LittleEndian;
 
 import java.util.HashMap;
-import java.util.Set;
 import java.util.Iterator;
 import java.util.Collections;
 import java.util.ArrayList;
index ad47cdfdc0e3a0dc84403e26f2b6755d43318380..aa7502a41e018c0f5cb6ba71dcad61bf8609b86f 100644 (file)
 
 package org.apache.poi.hwpf.sprm;
 
-//
-//import java.util.ArrayList;
-//import java.util.Arrays;
-//
-//import org.apache.poi.hwpf.model.types.SEPAbstractType;
-//import org.apache.poi.hwpf.usermodel.SectionProperties;
-//import org.apache.poi.util.LittleEndian;
-//
-//
-//public class SectionSprmCompressor
-//{
-//  private final static SectionProperties DEFAULT_SEP = new SectionProperties();
-//  public SectionSprmCompressor()
-//  {
-//  }
-//  public static byte[] compressSectionProperty(SectionProperties newSEP,
-//                                               SectionProperties oldSEP)
-//  {
-//    int size = 0;
-//    ArrayList sprmList = new ArrayList();
-//
-//    if (newSEP.getCnsPgn() != DEFAULT_SEP.getCnsPgn())
-//    {
-//      size += SprmUtils.addSprm((short)0x3000, newSEP.getCnsPgn(), null, sprmList);
-//    }
-//    if (newSEP.getIHeadingPgn() != DEFAULT_SEP.getIHeadingPgn())
-//    {
-//      size += SprmUtils.addSprm((short)0x3001, newSEP.getIHeadingPgn(), null, sprmList);
-//    }
-//    if (!Arrays.equals(newSEP.getOlstAnm(), DEFAULT_SEP.getOlstAnm()))
-//    {
-//      size += SprmUtils.addSprm((short)0xD202, 0, newSEP.getOlstAnm(), sprmList);
-//    }
-//    if (newSEP.getFEvenlySpaced() != DEFAULT_SEP.getFEvenlySpaced())
-//    {
-//      size += SprmUtils.addSprm((short)0x3005, newSEP.getFEvenlySpaced() ? 1 : 0, null, sprmList);
-//    }
-//    if (newSEP.getFUnlocked() != DEFAULT_SEP.getFUnlocked())
-//    {
-//      size += SprmUtils.addSprm((short)0x3006, newSEP.getFUnlocked() ? 1 :0, null, sprmList);
-//    }
-//    if (newSEP.getDmBinFirst() != DEFAULT_SEP.getDmBinFirst())
-//    {
-//      size += SprmUtils.addSprm((short)0x5007, newSEP.getDmBinFirst(), null, sprmList);
-//    }
-//    if (newSEP.getDmBinOther() != DEFAULT_SEP.getDmBinOther())
-//    {
-//      size += SprmUtils.addSprm((short)0x5008, newSEP.getDmBinOther(), null, sprmList);
-//    }
-//    if (newSEP.getBkc() != DEFAULT_SEP.getBkc())
-//    {
-//      size += SprmUtils.addSprm((short)0x3009, newSEP.getBkc(), null, sprmList);
-//    }
-//    if (newSEP.getFTitlePage() != DEFAULT_SEP.getFTitlePage())
-//    {
-//      size += SprmUtils.addSprm((short)0x300A, newSEP.getFTitlePage() ? 1 : 0, null, sprmList);
-//    }
-//    if (newSEP.getCcolM1() != DEFAULT_SEP.getCcolM1())
-//    {
-//      size += SprmUtils.addSprm((short)0x500B, newSEP.getCcolM1(), null, sprmList);
-//    }
-//    if (newSEP.getDxaColumns() != DEFAULT_SEP.getDxaColumns())
-//    {
-//      size += SprmUtils.addSprm((short)0x900C, newSEP.getDxaColumns(), null, sprmList);
-//    }
-//    if (newSEP.getFAutoPgn() != DEFAULT_SEP.getFAutoPgn())
-//    {
-//      size += SprmUtils.addSprm((short)0x300D, newSEP.getFAutoPgn() ? 1 : 0, null, sprmList);
-//    }
-//    if (newSEP.getNfcPgn() != DEFAULT_SEP.getNfcPgn())
-//    {
-//      size += SprmUtils.addSprm((short)0x300E, newSEP.getNfcPgn(), null, sprmList);
-//    }
-//    if (newSEP.getDyaPgn() != DEFAULT_SEP.getDyaPgn())
-//    {
-//      size += SprmUtils.addSprm((short)0xB00F, newSEP.getDyaPgn(), null, sprmList);
-//    }
-//    if (newSEP.getDxaPgn() != DEFAULT_SEP.getDxaPgn())
-//    {
-//      size += SprmUtils.addSprm((short)0xB010, newSEP.getDxaPgn(), null, sprmList);
-//    }
-//    if (newSEP.getFPgnRestart() != DEFAULT_SEP.getFPgnRestart())
-//    {
-//      size += SprmUtils.addSprm((short)0x3011, newSEP.getFPgnRestart() ? 1 : 0, null, sprmList);
-//    }
-//    if (newSEP.getFEndNote() != DEFAULT_SEP.getFEndNote())
-//    {
-//      size += SprmUtils.addSprm((short)0x3012, newSEP.getFEndNote() ? 1 : 0, null, sprmList);
-//    }
-//    if (newSEP.getLnc() != DEFAULT_SEP.getLnc())
-//    {
-//      size += SprmUtils.addSprm((short)0x3013, newSEP.getLnc(), null, sprmList);
-//    }
-//    if (newSEP.getGrpfIhdt() != DEFAULT_SEP.getGrpfIhdt())
-//    {
-//      size += SprmUtils.addSprm((short)0x3014, newSEP.getGrpfIhdt(), null, sprmList);
-//    }
-//    if (newSEP.getNLnnMod() != DEFAULT_SEP.getNLnnMod())
-//    {
-//      size += SprmUtils.addSprm((short)0x5015, newSEP.getNLnnMod(), null, sprmList);
-//    }
-//    if (newSEP.getDxaLnn() != DEFAULT_SEP.getDxaLnn())
-//    {
-//      size += SprmUtils.addSprm((short)0x9016, newSEP.getDxaLnn(), null, sprmList);
-//    }
-//    if (newSEP.getDyaHdrTop() != DEFAULT_SEP.getDyaHdrTop())
-//    {
-//      size += SprmUtils.addSprm((short)0xB017, newSEP.getDyaHdrTop(), null, sprmList);
-//    }
-//    if (newSEP.getDyaHdrBottom() != DEFAULT_SEP.getDyaHdrBottom())
-//    {
-//      size += SprmUtils.addSprm((short)0xB018, newSEP.getDyaHdrBottom(), null, sprmList);
-//    }
-//    if (newSEP.getFLBetween() != DEFAULT_SEP.getFLBetween())
-//    {
-//      size += SprmUtils.addSprm((short)0x3019, newSEP.getFLBetween() ? 1 : 0, null, sprmList);
-//    }
-//    if (newSEP.getVjc() != DEFAULT_SEP.getVjc())
-//    {
-//      size += SprmUtils.addSprm((short)0x301A, newSEP.getVjc(), null, sprmList);
-//    }
-//    if (newSEP.getLnnMin() != DEFAULT_SEP.getLnnMin())
-//    {
-//      size += SprmUtils.addSprm((short)0x501B, newSEP.getLnnMin(), null, sprmList);
-//    }
-//    if (newSEP.getPgnStart() != DEFAULT_SEP.getPgnStart())
-//    {
-//      size += SprmUtils.addSprm((short)0x501C, newSEP.getPgnStart(), null, sprmList);
-//    }
-//    if (newSEP.getDmOrientPage() != DEFAULT_SEP.getDmOrientPage())
-//    {
-//      size += SprmUtils.addSprm((short)0x301D, newSEP.getDmOrientPage(), null, sprmList);
-//    }
-//    if (newSEP.getXaPage() != DEFAULT_SEP.getXaPage())
-//    {
-//      size += SprmUtils.addSprm((short)0xB01F, newSEP.getXaPage(), null, sprmList);
-//    }
-//    if (newSEP.getYaPage() != DEFAULT_SEP.getYaPage())
-//    {
-//      size += SprmUtils.addSprm((short)0xB020, newSEP.getYaPage(), null, sprmList);
-//    }
-//    if (newSEP.getDxaLeft() != DEFAULT_SEP.getDxaLeft())
-//    {
-//      size += SprmUtils.addSprm((short)0xB021, newSEP.getDxaLeft(), null, sprmList);
-//    }
-//    if (newSEP.getDxaRight() != DEFAULT_SEP.getDxaRight())
-//    {
-//      size += SprmUtils.addSprm((short)0xB022, newSEP.getDxaRight(), null, sprmList);
-//    }
-//    if (newSEP.getDyaTop() != DEFAULT_SEP.getDyaTop())
-//    {
-//      size += SprmUtils.addSprm((short)0x9023, newSEP.getDyaTop(), null, sprmList);
-//    }
-//    if (newSEP.getDyaBottom() != DEFAULT_SEP.getDyaBottom())
-//    {
-//      size += SprmUtils.addSprm((short)0x9024, newSEP.getDyaBottom(), null, sprmList);
-//    }
-//    if (newSEP.getDzaGutter() != DEFAULT_SEP.getDzaGutter())
-//    {
-//      size += SprmUtils.addSprm((short)0xB025, newSEP.getDzaGutter(), null, sprmList);
-//    }
-//    if (newSEP.getDmPaperReq() != DEFAULT_SEP.getDmPaperReq())
-//    {
-//      size += SprmUtils.addSprm((short)0x5026, newSEP.getDmPaperReq(), null, sprmList);
-//    }
-//    if (newSEP.getFPropMark() != DEFAULT_SEP.getFPropMark() ||
-//        newSEP.getIbstPropRMark() != DEFAULT_SEP.getIbstPropRMark() ||
-//        newSEP.getDttmPropRMark() != DEFAULT_SEP.getDttmPropRMark())
-//    {
-//      byte[] buf = new byte[7];
-//      buf[0] = (byte)(newSEP.getFPropMark() ? 1 : 0);
-//      int offset = LittleEndian.BYTE_SIZE;
-//      LittleEndian.putShort(buf, (short)newSEP.getIbstPropRMark());
-//      offset += LittleEndian.SHORT_SIZE;
-//      LittleEndian.putInt(buf, newSEP.getDttmPropRMark());
-//      size += SprmUtils.addSprm((short)0xD227, -1, buf, sprmList);
-//    }
-//    if (!Arrays.equals(newSEP.getBrcTop(), DEFAULT_SEP.getBrcTop()))
-//    {
-//      size += SprmUtils.addSprm((short)0x702B, SprmUtils.convertBrcToInt(newSEP.getBrcTop()), null, sprmList);
-//    }
-//    if (!Arrays.equals(newSEP.getBrcLeft(), DEFAULT_SEP.getBrcLeft()))
-//    {
-//      size += SprmUtils.addSprm((short)0x702C, SprmUtils.convertBrcToInt(newSEP.getBrcLeft()), null, sprmList);
-//    }
-//    if (!Arrays.equals(newSEP.getBrcBottom(), DEFAULT_SEP.getBrcBottom()))
-//    {
-//      size += SprmUtils.addSprm((short)0x702D, SprmUtils.convertBrcToInt(newSEP.getBrcBottom()), null, sprmList);
-//    }
-//    if (!Arrays.equals(newSEP.getBrcRight(), DEFAULT_SEP.getBrcRight()))
-//    {
-//      size += SprmUtils.addSprm((short)0x702E, SprmUtils.convertBrcToInt(newSEP.getBrcRight()), null, sprmList);
-//    }
-//    if (newSEP.getPgbProp() != DEFAULT_SEP.getPgbProp())
-//    {
-//      size += SprmUtils.addSprm((short)0x522F, newSEP.getPgbProp(), null, sprmList);
-//    }
-//    if (newSEP.getDxtCharSpace() != DEFAULT_SEP.getDxtCharSpace())
-//    {
-//      size += SprmUtils.addSprm((short)0x7030, newSEP.getDxtCharSpace(), null, sprmList);
-//    }
-//    if (newSEP.getDyaLinePitch() != DEFAULT_SEP.getDyaLinePitch())
-//    {
-//      size += SprmUtils.addSprm((short)0x9031, newSEP.getDyaLinePitch(), null, sprmList);
-//    }
-//    if (newSEP.getClm() != DEFAULT_SEP.getClm())
-//    {
-//      size += SprmUtils.addSprm((short)0x5032, newSEP.getClm(), null, sprmList);
-//    }
-//    if (newSEP.getWTextFlow() != DEFAULT_SEP.getWTextFlow())
-//    {
-//      size += SprmUtils.addSprm((short)0x5033, newSEP.getWTextFlow(), null, sprmList);
-//    }
-//
-//    return SprmUtils.getGrpprl(sprmList, size);
-//  }
-//}
-
-
 import java.util.ArrayList;
 import java.util.Arrays;
 
-import org.apache.poi.hwpf.model.types.SEPAbstractType;
 import org.apache.poi.hwpf.usermodel.SectionProperties;
 import org.apache.poi.util.LittleEndian;
 
index 13580fa090ed645f4fdae27da603d5aa935954d2..65af98fae4e65c7e03a9e86c99ae75e3d7777111 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.poi.hwpf.sprm;
 import org.apache.poi.hwpf.usermodel.TableProperties;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.hwpf.usermodel.TableCellDescriptor;
-import org.apache.poi.hwpf.usermodel.ShadingDescriptor;
 import org.apache.poi.hwpf.usermodel.BorderCode;
 
 import java.util.ArrayList;
index ff5191e781dadf4e36c7e5457ae1b4daa76cfa0a..52747c17e62cc64279bf1b2db45115f039f66e13 100644 (file)
 
 package org.apache.poi.hwpf.usermodel;
 
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
 
-public final class BorderCode
-  implements Cloneable
-{
+public final class BorderCode implements Cloneable {
   public static final int SIZE = 4;
   private short _info;
   private short _info2;
index 91c993fd7a0f46d556cffb79e7ff9e90b356d664..a9a95c6b4f166fc05fde6277bf93a88f9e1dfc4d 100644 (file)
@@ -17,8 +17,6 @@
 
 package org.apache.poi.hwpf.usermodel;
 
-import org.apache.poi.hwpf.HWPFDocument;
-import org.apache.poi.hwpf.model.ListTables;
 import org.apache.poi.hwpf.model.ListLevel;
 import org.apache.poi.hwpf.model.ListData;
 import org.apache.poi.hwpf.model.ListFormatOverride;
@@ -43,8 +41,7 @@ import org.apache.poi.hwpf.sprm.ParagraphSprmCompressor;
  *
  * @author Ryan Ackley
  */
-public final class HWPFList
-{
+public final class HWPFList {
   private ListData _listData;
   private ListFormatOverride _override;
   private boolean _registered;
index 167d0837d4a18d0215f8b3670baa24c0a667f948..8944eb06005429c9496ca1e23df8e36050e1dfe9 100644 (file)
 package org.apache.poi.hwpf.usermodel;
 
 import org.apache.poi.hwpf.model.types.PAPAbstractType;
-import org.apache.poi.hwpf.model.StyleDescription;
 
-import org.apache.poi.hwpf.sprm.SprmBuffer;
-
-public final class ParagraphProperties
-  extends PAPAbstractType
-    implements Cloneable
-{
+public final class ParagraphProperties extends PAPAbstractType implements Cloneable {
 
   public ParagraphProperties()
   {
@@ -313,14 +307,14 @@ public final class ParagraphProperties
   {
     ParagraphProperties pp = (ParagraphProperties)super.clone();
     pp.field_21_lspd = (LineSpacingDescriptor)field_21_lspd.clone();
-    pp.field_24_phe = (byte[])field_24_phe.clone();
+    pp.field_24_phe = field_24_phe.clone();
     pp.field_46_brcTop = (BorderCode)field_46_brcTop.clone();
     pp.field_47_brcLeft = (BorderCode)field_47_brcLeft.clone();
     pp.field_48_brcBottom = (BorderCode)field_48_brcBottom.clone();
     pp.field_49_brcRight = (BorderCode)field_49_brcRight.clone();
     pp.field_50_brcBetween = (BorderCode)field_50_brcBetween.clone();
     pp.field_51_brcBar = (BorderCode)field_51_brcBar.clone();
-    pp.field_60_anld = (byte[])field_60_anld.clone();
+    pp.field_60_anld = field_60_anld.clone();
     return pp;
   }
 
index f19a340351d0ed481592191fb5113b06538419ef..9f2e208e766f265611ec617402413958d44548d1 100644 (file)
@@ -18,8 +18,6 @@
 package org.apache.poi.hwpf.usermodel;
 
 
-import java.util.ArrayList;
-
 public final class TableIterator
 {
   Range _range;
@@ -56,7 +54,6 @@ public final class TableIterator
   public Table next()
   {
     int numParagraphs = _range.numParagraphs();
-    int numRows = 0;
     int startIndex = _index;
     int endIndex = _index;
 
index 6daeab1b2050313b6b2f896c77fdbc1c6276237d..892cb81387c10d54c5af59c7a00b0d92d52c81eb 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.poi.hslf;
 import junit.framework.TestCase;
 
 import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
-import org.apache.poi.hslf.record.*;
 
 /**
  * Tests that HSLFSlideShow does the right thing with an encrypted file
@@ -39,41 +38,41 @@ public final class TestEncryptedFile extends TestCase {
        private String ss_56_e;
 
 
-    public TestEncryptedFile() throws Exception {
+       public TestEncryptedFile() {
                String dirname = System.getProperty("HSLF.testdata.path");
 
                ss_ne = dirname + "/basic_test_ppt_file.ppt";
                ss_e = dirname + "/Password_Protected-hello.ppt";
                ss_np_e = dirname + "/Password_Protected-np-hello.ppt";
                ss_56_e = dirname + "/Password_Protected-56-hello.ppt";
-    }
+       }
 
-    public void testLoadNonEncrypted() throws Exception {
-       HSLFSlideShow hss = new HSLFSlideShow(ss_ne);
+       public void testLoadNonEncrypted() throws Exception {
+               HSLFSlideShow hss = new HSLFSlideShow(ss_ne);
 
-       assertNotNull(hss);
-    }
+               assertNotNull(hss);
+       }
 
-    public void testLoadEncrypted() throws Exception {
-       try {
-               new HSLFSlideShow(ss_e);
-               fail();
-       } catch(EncryptedPowerPointFileException e) {
-               // Good
-       }
+       public void testLoadEncrypted() throws Exception {
+               try {
+                       new HSLFSlideShow(ss_e);
+                       fail();
+               } catch(EncryptedPowerPointFileException e) {
+                       // Good
+               }
 
-       try {
-               new HSLFSlideShow(ss_np_e);
-               fail();
-       } catch(EncryptedPowerPointFileException e) {
-               // Good
-       }
+               try {
+                       new HSLFSlideShow(ss_np_e);
+                       fail();
+               } catch(EncryptedPowerPointFileException e) {
+                       // Good
+               }
 
-       try {
-               new HSLFSlideShow(ss_56_e);
-               fail();
-       } catch(EncryptedPowerPointFileException e) {
-               // Good
-       }
-    }
+               try {
+                       new HSLFSlideShow(ss_56_e);
+                       fail();
+               } catch(EncryptedPowerPointFileException e) {
+                       // Good
+               }
+       }
 }
index 77a58844deefe775cb06b2aaf57ac1f6e8a833fb..73e31e5755a1bc78a025d3133a38aa3048b1c372 100755 (executable)
 
 package org.apache.poi.hslf.model;
 
+import java.awt.geom.Area;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+
 import junit.framework.TestCase;
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.HSLFSlideShow;
-
-import java.awt.*;
-import java.awt.Rectangle;
-import java.awt.geom.*;
-import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
 
 /**
  * Test Freeform object.
@@ -41,7 +34,7 @@ import java.util.ArrayList;
  */
 public final class TestFreeform extends TestCase {
 
-    public void testClosedPath() throws Exception {
+    public void testClosedPath() {
 
         GeneralPath path1 = new GeneralPath();
         path1.moveTo(100, 100);
@@ -57,7 +50,7 @@ public final class TestFreeform extends TestCase {
         assertTrue(new Area(path1).equals(new Area(path2)));
     }
 
-    public void testLine() throws Exception {
+    public void testLine() {
 
         GeneralPath path1 = new GeneralPath(new Line2D.Double(100, 100, 200, 100));
 
@@ -68,7 +61,7 @@ public final class TestFreeform extends TestCase {
         assertTrue(new Area(path1).equals(new Area(path2)));
     }
 
-    public void testRectangle() throws Exception {
+    public void testRectangle() {
 
         GeneralPath path1 = new GeneralPath(new Rectangle2D.Double(100, 100, 200, 50));
 
index b230679bd31dff8d0da87d270368517e1a93b698..9de8cad43ef06dff49e4415b491e69cebd17996a 100755 (executable)
 
 package org.apache.poi.hslf.model;
 
-import junit.framework.*;
+import java.awt.Graphics2D;
 
-import java.io.FileOutputStream;
-import java.io.File;
-import java.awt.*;
+import junit.framework.TestCase;
 
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.PictureData;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.blip.ImagePainter;
 import org.apache.poi.hslf.blip.BitmapPainter;
-import org.apache.poi.ddf.EscherBSERecord;
+import org.apache.poi.hslf.blip.ImagePainter;
+import org.apache.poi.hslf.usermodel.PictureData;
 
 /**
  * Test Picture shape.
@@ -37,22 +32,23 @@ import org.apache.poi.ddf.EscherBSERecord;
  */
 public final class TestImagePainter extends TestCase {
 
-    private static class CustomImagePainer implements ImagePainter{
+    private static class CustomImagePainter implements ImagePainter {
+        public CustomImagePainter() {
+            // no fields to initialise
+        }
         public void paint(Graphics2D graphics, PictureData pict, Picture parent){
             //do noting
         }
-
     }
 
-    public void testImagePainter() throws Exception {
+    public void testImagePainter() {
 
         ImagePainter pntr = PictureData.getImagePainter(Picture.PNG);
         assertTrue(PictureData.getImagePainter(Picture.PNG) instanceof BitmapPainter);
         assertTrue(PictureData.getImagePainter(Picture.JPEG) instanceof BitmapPainter);
         assertTrue(PictureData.getImagePainter(Picture.DIB) instanceof BitmapPainter);
 
-        PictureData.setImagePainter(Picture.WMF, new CustomImagePainer());
-        assertTrue(PictureData.getImagePainter(Picture.WMF) instanceof CustomImagePainer);
+        PictureData.setImagePainter(Picture.WMF, new CustomImagePainter());
+        assertTrue(PictureData.getImagePainter(Picture.WMF) instanceof CustomImagePainter);
     }
-
 }
index 7e7c5d3b3b60bc9cd1dc0c0b221bff7b74442e8c..735fa30466a6d42a9d14ec77eda934b40fc659f5 100644 (file)
 
 package org.apache.poi.hslf.model;
 
-import junit.framework.*;
+import java.awt.Color;
 
-import java.io.FileOutputStream;
-import java.awt.*;
+import junit.framework.TestCase;
 
 import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.HSLFSlideShow;
 
 /**
  * Test Line shape.
@@ -32,11 +30,7 @@ import org.apache.poi.hslf.HSLFSlideShow;
  */
 public final class TestLine extends TestCase {
 
-    public void setUp() throws Exception {
-
-    }
-
-    public void testCreateLines() throws Exception {
+    public void testCreateLines() {
         SlideShow ppt = new SlideShow();
 
         Slide slide = ppt.createSlide();
@@ -129,7 +123,5 @@ public final class TestLine extends TestCase {
         line.setLineStyle(Line.LINE_DOUBLE);
         line.setLineWidth(8.0);
         slide.addShape(line);
-
     }
-
 }
index 8555bce98302215e24fcb0cea49f278b496e885d..8d2f7045610509be6510181cdc0fdb13546519d9 100755 (executable)
 
 package org.apache.poi.hslf.model;
 
-import junit.framework.TestCase;
-
-import java.io.*;
-import java.awt.*;
 import java.awt.geom.Rectangle2D;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+
+import junit.framework.TestCase;
 
 import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.HSLFSlideShow;
 
 /**
  * Test <code>MovieShape</code> object.
@@ -61,7 +61,5 @@ public final class TestMovieShape extends TestCase {
         shape = (MovieShape)slide.getShapes()[0];
         assertEquals(path, shape.getPath());
         assertFalse(shape.isAutoPlay());
-
     }
-
 }
index b3f5942f39776375dfee2575dab67a331a743caf..9d80f7dc720c6041d9d84849335ec354bb0c504d 100755 (executable)
 
 package org.apache.poi.hslf.model;
 
-import junit.framework.*;
-
-import java.io.FileOutputStream;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.IOException;
-import java.awt.*;
-import java.awt.image.BufferedImage;
 
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.PictureData;
-import org.apache.poi.hslf.HSLFSlideShow;
+import junit.framework.TestCase;
+
 import org.apache.poi.ddf.EscherBSERecord;
+import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.usermodel.SlideShow;
 
 /**
  * Test Picture shape.
@@ -71,14 +70,13 @@ public final class TestPicture extends TestCase {
         EscherBSERecord bse3 = pict.getEscherBSERecord();
         assertSame(bse2, bse3);
         assertEquals(3, bse1.getRef());
-
     }
 
     /**
      * Picture#getEscherBSERecord threw NullPointerException if EscherContainerRecord.BSTORE_CONTAINER
      * was not found. The correct behaviour is to return null.
      */
-    public void test46122() throws IOException {
+    public void test46122() {
         SlideShow ppt = new SlideShow();
         Slide slide = ppt.createSlide();
 
@@ -90,8 +88,5 @@ public final class TestPicture extends TestCase {
         BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
         Graphics2D graphics = img.createGraphics();
         pict.draw(graphics);
-
-        assertTrue("no errors rendering Picture with null data", true);
     }
-
 }
index a6b17ec41c645974f92f5f6b3a8007f078478bbc..e39ca5a4d1f79283e3202abdf907484fee682aba 100644 (file)
@@ -19,10 +19,10 @@ package org.apache.poi.hslf.model;
 
 
 import junit.framework.TestCase;
-import org.apache.poi.hslf.*;
-import org.apache.poi.hslf.model.*;
-import org.apache.poi.hslf.usermodel.*;
+
+import org.apache.poi.hslf.HSLFSlideShow;
 import org.apache.poi.hslf.record.SlideAtom;
+import org.apache.poi.hslf.usermodel.SlideShow;
 
 /**
  * Tests that changing a slide's idea of what notes sheet is its works right
@@ -33,23 +33,23 @@ public final class TestSlideChangeNotes extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
 
-    public TestSlideChangeNotes() throws Exception {
+       public TestSlideChangeNotes() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
                String filename = dirname + "/basic_test_ppt_file.ppt";
                HSLFSlideShow hss = new HSLFSlideShow(filename);
                ss = new SlideShow(hss);
-    }
+       }
 
-    public void testSetToNone() throws Exception {
+       public void testSetToNone() {
                Slide slideOne = ss.getSlides()[0];
                SlideAtom sa = slideOne.getSlideRecord().getSlideAtom();
 
                slideOne.setNotes(null);
 
                assertEquals(0, sa.getNotesID());
-    }
+       }
 
-    public void testSetToSomething() throws Exception {
+       public void testSetToSomething() {
                Slide slideOne = ss.getSlides()[0];
                Notes notesOne = ss.getNotes()[1];
                SlideAtom sa = slideOne.getSlideRecord().getSlideAtom();
@@ -57,5 +57,5 @@ public final class TestSlideChangeNotes extends TestCase {
                slideOne.setNotes(notesOne);
 
                assertEquals(notesOne._getSheetNumber(), sa.getNotesID());
-    }
+       }
 }
index 9799eb0069ce70920af630356f881e75345bea00..20bdaa8a57a836510100b159de97bcd0e4e0b164 100644 (file)
 
 package org.apache.poi.hslf.model;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
 import junit.framework.TestCase;
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.RichTextRun;
+
 import org.apache.poi.hslf.HSLFSlideShow;
 import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp;
-import org.apache.poi.hslf.record.*;
-import org.apache.poi.hslf.record.StyleTextPropAtom.*;
-
-import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
-import java.awt.*;
+import org.apache.poi.hslf.record.Environment;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+import org.apache.poi.hslf.usermodel.RichTextRun;
+import org.apache.poi.hslf.usermodel.SlideShow;
 
 /**
  * Tests for SlideMaster
@@ -37,7 +37,7 @@ import java.awt.*;
 public final class TestSlideMaster extends TestCase{
     String home;
 
-    public void setUp() throws Exception {
+    public void setUp() {
         home = System.getProperty("HSLF.testdata.path");
     }
 
index d3c10cbea10106f6597f015c3efb8d99b626eb4e..e8f246bbd6f3fbbfc0a12b1c0155b10f7fdb9a98 100755 (executable)
 
 package org.apache.poi.hslf.model;
 
-import junit.framework.TestCase;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 
-import java.io.*;
-import java.awt.*;
-import java.awt.geom.Rectangle2D;
+import junit.framework.TestCase;
 
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.HSLFSlideShow;
 import org.apache.poi.hslf.record.TextHeaderAtom;
+import org.apache.poi.hslf.usermodel.SlideShow;
 
 /**
  * Test <code>Table</code> object.
@@ -90,13 +88,13 @@ public final class TestTable extends TestCase {
 
     public void testIllegalCOnstruction(){
         try {
-            Table tbl = new Table(0, 5);
+            new Table(0, 5);
             fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");
         } catch (IllegalArgumentException e){
 
         }
         try {
-            Table tbl = new Table(5, 0);
+            new Table(5, 0);
             fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");
         } catch (IllegalArgumentException e){
 
index a8402a333ababc546161be71cee7c19ae759b66a..c410e831c3a8355ede5f3ae9c07f7b9f42636866 100755 (executable)
@@ -22,8 +22,6 @@ import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
 import java.util.Arrays;
 
-import org.apache.poi.util.HexDump;
-
 /**
  * Tests that {@link HeadersFootersAtom} works properly
  *
@@ -43,7 +41,7 @@ public final class TestAnimationInfoAtom extends TestCase {
             0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
 
-    public void testRead() throws Exception {
+    public void testRead() {
         AnimationInfoAtom record = new AnimationInfoAtom(data, 0, data.length);
         assertEquals(RecordTypes.AnimationInfoAtom.typeID, record.getRecordType());
         assertTrue(record.getFlag(AnimationInfoAtom.Automatic));
@@ -84,5 +82,4 @@ public final class TestAnimationInfoAtom extends TestCase {
 
         assertTrue(Arrays.equals(data, b));
     }
-
 }
index 5d7355e585a6327d76847e31e0bedb0d42923d8d..8df159a32dff5ec0343a4c8fc231cb4802d0a43b 100644 (file)
@@ -22,12 +22,7 @@ import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
 import java.io.FileInputStream;
 import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
 
-import javax.imageio.stream.FileImageInputStream;
-
-import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
 import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
 import org.apache.poi.poifs.filesystem.DocumentEntry;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
index d559e542c32c164277dfcc0c36aa65f538ceefeb..18ae888ecd439788645fa6606aa3ef1bfbcc8407 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
 
-import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Date;
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
 
 import org.apache.poi.hslf.HSLFSlideShow;
 import org.apache.poi.hslf.usermodel.SlideShow;
@@ -36,52 +34,52 @@ import org.apache.poi.hslf.usermodel.SlideShow;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestExHyperlink extends TestCase {
+public final class TestExHyperlink extends TestCase {
        // From a real file
        private byte[] data_a = new byte[] {
                0x0F, 00, 0xD7-256, 0x0F, 0xA8-256, 00, 00, 00,
-               
-               00, 00, 0xD3-256, 0x0F, 04, 00, 00, 00, 
+
+               00, 00, 0xD3-256, 0x0F, 04, 00, 00, 00,
                03, 00, 00, 00,
-               
-               00, 00, 0xBA-256, 0x0F, 0x46, 00, 00, 00, 
+
+               00, 00, 0xBA-256, 0x0F, 0x46, 00, 00, 00,
                0x68, 00, 0x74, 00, 0x74, 00, 0x70, 00,
-               0x3A, 00, 0x2F, 00, 0x2F, 00, 0x6A, 00, 
+               0x3A, 00, 0x2F, 00, 0x2F, 00, 0x6A, 00,
                0x61, 00, 0x6B, 00, 0x61, 00, 0x72, 00,
                0x74, 00, 0x61, 00, 0x2E, 00, 0x61, 00,
                0x70, 00, 0x61, 00, 0x63, 00, 0x68, 00,
                0x65, 00, 0x2E, 00, 0x6F, 00, 0x72, 00,
                0x67, 00, 0x2F, 00, 0x70, 00, 0x6F, 00,
-               0x69, 00, 0x2F, 00, 0x68, 00, 0x73, 00, 
-               0x73, 00, 0x66, 00, 0x2F, 00, 
-               
+               0x69, 00, 0x2F, 00, 0x68, 00, 0x73, 00,
+               0x73, 00, 0x66, 00, 0x2F, 00,
+
                0x10, 00, 0xBA-256, 0x0F, 0x46, 00, 00, 00,
                0x68, 00, 0x74, 00, 0x74, 00, 0x70, 00,
-               0x3A, 00, 0x2F, 00, 0x2F, 00, 0x6A, 00, 
+               0x3A, 00, 0x2F, 00, 0x2F, 00, 0x6A, 00,
                0x61, 00, 0x6B, 00, 0x61, 00, 0x72, 00,
                0x74, 00, 0x61, 00, 0x2E, 00, 0x61, 00,
                0x70, 00, 0x61, 00, 0x63, 00, 0x68, 00,
                0x65, 00, 0x2E, 00, 0x6F, 00, 0x72, 00,
                0x67, 00, 0x2F, 00, 0x70, 00, 0x6F, 00,
-               0x69, 00, 0x2F, 00, 0x68, 00, 0x73, 00, 
-               0x73, 00, 0x66, 00, 0x2F, 00 
+               0x69, 00, 0x2F, 00, 0x68, 00, 0x73, 00,
+               0x73, 00, 0x66, 00, 0x2F, 00
        };
-       
-    public void testRecordType() throws Exception {
+
+    public void testRecordType() {
        ExHyperlink eh = new ExHyperlink(data_a, 0, data_a.length);
                assertEquals(4055l, eh.getRecordType());
        }
-    
-    public void testNumber() throws Exception {
+
+    public void testNumber() {
        ExHyperlink eh = new ExHyperlink(data_a, 0, data_a.length);
                assertEquals(3, eh.getExHyperlinkAtom().getNumber());
     }
-    
-       public void testLinkURL() throws Exception {
+
+       public void testLinkURL() {
        ExHyperlink eh = new ExHyperlink(data_a, 0, data_a.length);
        assertEquals("http://jakarta.apache.org/poi/hssf/", eh.getLinkURL());
        }
-       public void testDetails() throws Exception {
+       public void testDetails() {
        ExHyperlink eh = new ExHyperlink(data_a, 0, data_a.length);
        assertEquals("http://jakarta.apache.org/poi/hssf/", eh._getDetailsA());
        assertEquals("http://jakarta.apache.org/poi/hssf/", eh._getDetailsB());
@@ -98,12 +96,12 @@ public class TestExHyperlink extends TestCase {
                        assertEquals(data_a[i],b[i]);
                }
        }
-       
+
        public void testRealFile() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
                HSLFSlideShow hss = new HSLFSlideShow(dirname + File.separator + "WithLinks.ppt");
                SlideShow ss = new SlideShow(hss);
-               
+
                // Get the document
                Document doc = ss.getDocumentRecord();
                // Get the ExObjList
@@ -113,37 +111,40 @@ public class TestExHyperlink extends TestCase {
                                exObjList = (ExObjList)doc._children[i];
                        }
                }
-               assertNotNull(exObjList);
-               
+               if (exObjList == null) {
+                       throw new AssertionFailedError("exObjList must not be null");
+               }
+
                // Within that, grab out the Hyperlink atoms
-               ArrayList linksA = new ArrayList();
+               List<ExHyperlink> linksA = new ArrayList<ExHyperlink>();
                for(int i=0; i<exObjList._children.length; i++) {
-                       if(exObjList._children[i] instanceof ExHyperlink) {
-                               linksA.add(exObjList._children[i]);
+                       Record ch = exObjList._children[i];
+                       if(ch instanceof ExHyperlink) {
+                               linksA.add((ExHyperlink) ch);
                        }
                }
-               
+
                // Should be 4 of them
                assertEquals(4, linksA.size());
                ExHyperlink[] links = new ExHyperlink[linksA.size()];
                linksA.toArray(links);
-               
+
                assertEquals(4, exObjList.getExHyperlinks().length);
-               
+
                // Check the other way
-               
+
                // Check they have what we expect in them
                assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
                assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
-               
+
                assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
                assertEquals("http://slashdot.org/", links[1].getLinkURL());
-               
+
                assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
                assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
-               
+
                assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
                assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
-               
+
        }
 }
index 4e1b335f175ba87a5518898c259fe1651f86e9d9..ee6c5586cb3aad952fba9f4e378c027d406ab475 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
 
 import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
 
 /**
  * Tests that ExHyperlinkAtom works properly.
@@ -37,24 +32,24 @@ public class TestExHyperlinkAtom extends TestCase {
                00, 00, 0xD3-256, 0x0F, 04, 00, 00, 00,
                01, 00, 00, 00
        };
-       private byte[] data_b = new byte[] { 
+       private byte[] data_b = new byte[] {
                00, 00, 0xD3-256, 0x0F, 04, 00, 00, 00,
                04, 00, 00, 00
        };
-       
-    public void testRecordType() throws Exception {
+
+    public void testRecordType() {
        ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
                assertEquals(4051l, eha.getRecordType());
        }
-    
-    public void testGetNumber() throws Exception {
+
+    public void testGetNumber() {
        ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
        ExHyperlinkAtom ehb = new ExHyperlinkAtom(data_b, 0, data_b.length);
-               
+
                assertEquals(1, eha.getNumber());
                assertEquals(4, ehb.getNumber());
     }
-    
+
        public void testWrite() throws Exception {
        ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -68,35 +63,35 @@ public class TestExHyperlinkAtom extends TestCase {
        }
 
        // Create A from scratch
-    public void testCreate() throws Exception {
-       ExHyperlinkAtom eha = new ExHyperlinkAtom();
-       
-       // Set value
-       eha.setNumber(1);
-       
+       public void testCreate() throws Exception {
+               ExHyperlinkAtom eha = new ExHyperlinkAtom();
+
+               // Set value
+               eha.setNumber(1);
+
                // Check it's now the same as a
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                eha.writeOut(baos);
                byte[] b = baos.toByteArray();
-               
+
                assertEquals(data_a.length, b.length);
                for(int i=0; i<data_a.length; i++) {
                        assertEquals(data_a[i],b[i]);
                }
-    }
+       }
 
        // Try to turn a into b
        public void testChange() throws Exception {
-       ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
+               ExHyperlinkAtom eha = new ExHyperlinkAtom(data_a, 0, data_a.length);
 
                // Change the number
                eha.setNumber(4);
-               
+
                // Check bytes are now the same
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                eha.writeOut(baos);
                byte[] b = baos.toByteArray();
-               
+
                // Should now be the same
                assertEquals(data_b.length, b.length);
                for(int i=0; i<data_b.length; i++) {
index 784482c620687ab50a9b773c5e650fb4bd2e717f..b2bf2d70655721461a9041c32fd72beb86372b3c 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
 
-import junit.framework.TestCase;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
+
+import junit.framework.TestCase;
 
 import org.apache.poi.hslf.HSLFSlideShow;
 import org.apache.poi.hslf.usermodel.SlideShow;
@@ -41,36 +35,36 @@ public class TestExObjList extends TestCase {
                String dirname = System.getProperty("HSLF.testdata.path");
                HSLFSlideShow hss = new HSLFSlideShow(dirname + File.separator + "WithLinks.ppt");
                SlideShow ss = new SlideShow(hss);
-               
+
                // Get the document
                Document doc = ss.getDocumentRecord();
                // Get the ExObjList
                ExObjList exObjList = doc.getExObjList();
                assertNotNull(exObjList);
                assertEquals(1033l, exObjList.getRecordType());
-               
+
                // Check the atom
                assertNotNull(exObjList.getExObjListAtom());
                assertEquals(4, exObjList.getExObjListAtom().getObjectIDSeed());
-               
+
                // Check the Hyperlinks
                assertEquals(4, exObjList.getExHyperlinks().length);
-               
+
                // Check the contents
                ExHyperlink[] links = exObjList.getExHyperlinks();
-               
+
                // Check they have what we expect in them
                assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
                assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
-               
+
                assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
                assertEquals("http://slashdot.org/", links[1].getLinkURL());
-               
+
                assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
                assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
-               
+
                assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
                assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
-               
+
        }
 }
index d847bf6a9e613cf8977909a0ae110734b6d01127..e978f37e4c95509c7409a658621164f1218caa06 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
 
 import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
 
 /**
  * Tests that ExObjListAtom works properly.
@@ -37,26 +32,26 @@ public class TestExObjListAtom extends TestCase {
                00, 00, 0x0A, 0x04, 04, 00, 00, 00,
                01, 00, 00, 00
        };
-       private byte[] data_b = new byte[] { 
+       private byte[] data_b = new byte[] {
                00, 00, 0x0A, 0x04, 04, 00, 00, 00,
                04, 00, 00, 00
        };
-       
-    public void testRecordType() throws Exception {
-       ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+
+       public void testRecordType() {
+               ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
                assertEquals(1034l, eoa.getRecordType());
        }
-    
-    public void testGetSeed() throws Exception {
-       ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
-       ExObjListAtom eob = new ExObjListAtom(data_b, 0, data_b.length);
-               
+
+       public void testGetSeed() {
+               ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+               ExObjListAtom eob = new ExObjListAtom(data_b, 0, data_b.length);
+
                assertEquals(1, eoa.getObjectIDSeed());
                assertEquals(4, eob.getObjectIDSeed());
-    }
-    
+       }
+
        public void testWrite() throws Exception {
-       ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+               ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                eoa.writeOut(baos);
                byte[] b = baos.toByteArray();
@@ -68,35 +63,35 @@ public class TestExObjListAtom extends TestCase {
        }
 
        // Create A from scratch
-    public void testCreate() throws Exception {
-       ExObjListAtom eoa = new ExObjListAtom();
-       
-       // Set seed
-       eoa.setObjectIDSeed(1);
-       
+       public void testCreate() throws Exception {
+               ExObjListAtom eoa = new ExObjListAtom();
+
+               // Set seed
+               eoa.setObjectIDSeed(1);
+
                // Check it's now the same as a
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                eoa.writeOut(baos);
                byte[] b = baos.toByteArray();
-               
+
                assertEquals(data_a.length, b.length);
                for(int i=0; i<data_a.length; i++) {
                        assertEquals(data_a[i],b[i]);
                }
-    }
+       }
 
        // Try to turn a into b
        public void testChange() throws Exception {
-       ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
+               ExObjListAtom eoa = new ExObjListAtom(data_a, 0, data_a.length);
 
                // Change the number
                eoa.setObjectIDSeed(4);
-               
+
                // Check bytes are now the same
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                eoa.writeOut(baos);
                byte[] b = baos.toByteArray();
-               
+
                // Should now be the same
                assertEquals(data_b.length, b.length);
                for(int i=0; i<data_b.length; i++) {
index 1365691d41cf6a4aa86bcf1ed6af350f9cc1844b..8e5179c61684f476da9e7667b0dc6766cc8b2f0d 100755 (executable)
@@ -20,13 +20,11 @@ package org.apache.poi.hslf.record;
 
 import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
-import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.IOException;
 import java.util.Arrays;
 
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.DocumentEntry;
 
 /**
index df945f5a22a21a198b47bccb4d57d87628270fd2..7a5992193666b931094bad317e587045b5fc3a2c 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
 
 import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
 
 /**
  * Tests that InteractiveInfoAtom works properly.
@@ -33,44 +28,44 @@ import java.util.Date;
  */
 public class TestInteractiveInfoAtom extends TestCase {
        // From a real file
-       private byte[] data_a = new byte[] { 
+       private byte[] data_a = new byte[] {
                00, 00, 0xF3-256, 0x0F, 0x10, 00, 00, 00,
                00, 00, 00, 00, 01, 00, 00, 00,
                04, 00, 00, 00, 8, 00, 00, 00
        };
-       private byte[] data_b = new byte[] { 
+       private byte[] data_b = new byte[] {
                00, 00, 0xF3-256, 0x0F, 0x10, 00, 00, 00,
                00, 00, 00, 00, 04, 00, 00, 00,
                04, 00, 00, 00, 8, 00, 00, 00
        };
-       
-    public void testRecordType() throws Exception {
+
+       public void testRecordType() {
                InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
                assertEquals(4083l, ia.getRecordType());
        }
-    
-    public void testGetNumber() throws Exception {
+
+       public void testGetNumber() {
                InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
                InteractiveInfoAtom ib = new InteractiveInfoAtom(data_b, 0, data_b.length);
-               
+
                assertEquals(1, ia.getHyperlinkID());
                assertEquals(4, ib.getHyperlinkID());
-    }
-    
-    public void testGetRest() throws Exception {
+       }
+
+       public void testGetRest() {
                InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
                InteractiveInfoAtom ib = new InteractiveInfoAtom(data_b, 0, data_b.length);
-               
+
                assertEquals(0, ia.getSoundRef());
                assertEquals(0, ib.getSoundRef());
-               
+
                assertEquals(4, ia.getAction());
                assertEquals(4, ib.getAction());
-               
+
                assertEquals(8, ia.getHyperlinkType());
                assertEquals(8, ib.getHyperlinkType());
-    }
-    
+       }
+
        public void testWrite() throws Exception {
                InteractiveInfoAtom ia = new InteractiveInfoAtom(data_a, 0, data_a.length);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -84,25 +79,25 @@ public class TestInteractiveInfoAtom extends TestCase {
        }
 
        // Create A from scratch
-    public void testCreate() throws Exception {
-       InteractiveInfoAtom ia = new InteractiveInfoAtom();
-       
-       // Set values
-       ia.setHyperlinkID(1);
-       ia.setSoundRef(0);
-       ia.setAction((byte)4);
-       ia.setHyperlinkType((byte)8);
-       
+       public void testCreate() throws Exception {
+               InteractiveInfoAtom ia = new InteractiveInfoAtom();
+
+               // Set values
+               ia.setHyperlinkID(1);
+               ia.setSoundRef(0);
+               ia.setAction((byte)4);
+               ia.setHyperlinkType((byte)8);
+
                // Check it's now the same as a
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ia.writeOut(baos);
                byte[] b = baos.toByteArray();
-               
+
                assertEquals(data_a.length, b.length);
                for(int i=0; i<data_a.length; i++) {
                        assertEquals(data_a[i],b[i]);
                }
-    }
+       }
 
        // Try to turn a into b
        public void testChange() throws Exception {
@@ -110,12 +105,12 @@ public class TestInteractiveInfoAtom extends TestCase {
 
                // Change the number
                ia.setHyperlinkID(4);
-               
+
                // Check bytes are now the same
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ia.writeOut(baos);
                byte[] b = baos.toByteArray();
-               
+
                // Should now be the same
                assertEquals(data_b.length, b.length);
                for(int i=0; i<data_b.length; i++) {
index 056cbaac9cb0b023fa3638c26869c84a7674403b..0884a41a08cd9b4d7403df35b31c12b74dc9c1de 100755 (executable)
 
 package org.apache.poi.hslf.record;
 
-
-import junit.framework.TestCase;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
 import java.util.Arrays;
 
-import org.apache.poi.hslf.HSLFSlideShow;
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
 import org.apache.poi.hslf.usermodel.SlideShow;
 
 /**
- * Tests Sound-related records: SoundCollection(2020), Sound(2022) and SoundData(2023)).
+ * Tests Sound-related records: SoundCollection(2020), Sound(2022) and
+ * SoundData(2023)).
  *
  * @author Yegor Kozlov
  */
@@ -44,40 +41,43 @@ public final class TestSound extends TestCase {
 
                // Get the document
                Document doc = ppt.getDocumentRecord();
-        SoundCollection soundCollection = null;
-        Record[] doc_ch = doc.getChildRecords();
-        for (int i = 0; i < doc_ch.length; i++) {
-            if(doc_ch[i] instanceof SoundCollection){
-                soundCollection = (SoundCollection)doc_ch[i];
-                break;
-            }
-        }
-        assertNotNull(soundCollection);
-
-        Sound sound = null;
-        Record[] sound_ch = soundCollection.getChildRecords();
-        int k = 0;
-        for (int i = 0; i < sound_ch.length; i++) {
-            if(sound_ch[i] instanceof Sound){
-                sound = (Sound)sound_ch[i];
-                k++;
-            }
-        }
-        assertNotNull(sound);
-        assertEquals(1, k);
+               SoundCollection soundCollection = null;
+               Record[] doc_ch = doc.getChildRecords();
+               for (int i = 0; i < doc_ch.length; i++) {
+                       if (doc_ch[i] instanceof SoundCollection) {
+                               soundCollection = (SoundCollection) doc_ch[i];
+                               break;
+                       }
+               }
+               if (soundCollection == null) {
+                       throw new AssertionFailedError("soundCollection must not be null");
+               }
 
-        assertEquals("ringin.wav", sound.getSoundName());
-        assertEquals(".WAV", sound.getSoundType());
-        assertNotNull(sound.getSoundData());
+               Sound sound = null;
+               Record[] sound_ch = soundCollection.getChildRecords();
+               int k = 0;
+               for (int i = 0; i < sound_ch.length; i++) {
+                       if (sound_ch[i] instanceof Sound) {
+                               sound = (Sound) sound_ch[i];
+                               k++;
+                       }
+               }
+               if (sound == null) {
+                       throw new AssertionFailedError("sound must not be null");
+               }
+               assertEquals(1, k);
 
-        File f = new File(cwd, "ringin.wav");
-        int length = (int)f.length();
-        byte[] ref_data = new byte[length];
-        is = new FileInputStream(f);
-        is.read(ref_data);
-        is.close();
+               assertEquals("ringin.wav", sound.getSoundName());
+               assertEquals(".WAV", sound.getSoundType());
+               assertNotNull(sound.getSoundData());
 
-        assertTrue(Arrays.equals(ref_data, sound.getSoundData()));
+               File f = new File(cwd, "ringin.wav");
+               int length = (int) f.length();
+               byte[] ref_data = new byte[length];
+               is = new FileInputStream(f);
+               is.read(ref_data);
+               is.close();
 
+               assertTrue(Arrays.equals(ref_data, sound.getSoundData()));
        }
 }
index 2e11d0d16b6aaa672797aa407b861756f02d49f3..2a4892319409a3c96b011506d6ca11f639efddd3 100644 (file)
 
 package org.apache.poi.hslf.record;
 
-import org.apache.poi.hslf.HSLFSlideShow;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.LinkedList;
+
+import junit.framework.TestCase;
+
 import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp;
 import org.apache.poi.hslf.model.textproperties.TextProp;
 import org.apache.poi.hslf.model.textproperties.TextPropCollection;
-import org.apache.poi.hslf.record.StyleTextPropAtom.*;
-import org.apache.poi.hslf.usermodel.SlideShow;
 import org.apache.poi.util.HexDump;
 
-import junit.framework.TestCase;
-import java.io.ByteArrayOutputStream;
-import java.util.LinkedList;
-import java.util.Arrays;
-
 /**
  * Tests that StyleTextPropAtom works properly
  *
@@ -164,7 +163,7 @@ public final class TestStyleTextPropAtom extends TestCase {
         assertEquals(5, stpb.getCharacterStyles().size());
     }
 
-    public void testParagraphStyleCounts() throws Exception {
+    public void testParagraphStyleCounts() {
         StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length);
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
 
@@ -179,7 +178,7 @@ public final class TestStyleTextPropAtom extends TestCase {
     }
 
 
-    public void testCharacterStyleLengths() throws Exception {
+    public void testCharacterStyleLengths() {
         StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length);
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
 
@@ -209,7 +208,7 @@ public final class TestStyleTextPropAtom extends TestCase {
     }
 
 
-    public void testCharacterPropOrdering() throws Exception {
+    public void testCharacterPropOrdering() {
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
         stpb.setParentTextSize(data_b_text_len);
 
@@ -263,7 +262,7 @@ public final class TestStyleTextPropAtom extends TestCase {
         assertEquals(24, tp_4_3.getValue());
     }
 
-    public void testParagraphProps() throws Exception {
+    public void testParagraphProps() {
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
         stpb.setParentTextSize(data_b_text_len);
 
@@ -315,7 +314,7 @@ public final class TestStyleTextPropAtom extends TestCase {
         assertEquals(80, tp_4_2.getValue());
     }
 
-    public void testCharacterProps() throws Exception {
+    public void testCharacterProps() {
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
         stpb.setParentTextSize(data_b_text_len);
 
@@ -647,37 +646,41 @@ public final class TestStyleTextPropAtom extends TestCase {
         }
     }
 
-    public void testWriteA() throws Exception {
+    public void testWriteA() {
         doReadWrite(data_a, -1);
     }
 
-    public void testLoadWriteA() throws Exception {
+    public void testLoadWriteA() {
         doReadWrite(data_b, data_b_text_len);
     }
 
 
-    public void testWriteB() throws Exception {
+    public void testWriteB() {
         doReadWrite(data_b, -1);
     }
 
-    public void testLoadWriteB() throws Exception {
+    public void testLoadWriteB() {
         doReadWrite(data_b, data_b_text_len);
     }
 
-    public void testLoadWriteC() throws Exception {
+    public void testLoadWriteC() {
         doReadWrite(data_c, data_c_text_len);
     }
 
-    public void testLoadWriteD() throws Exception {
+    public void testLoadWriteD() {
         doReadWrite(data_d, data_d_text_len);
     }
 
-    protected void doReadWrite(byte[] data, int textlen) throws Exception {
+    protected void doReadWrite(byte[] data, int textlen) {
         StyleTextPropAtom stpb = new StyleTextPropAtom(data, 0,data.length);
         if(textlen != -1) stpb.setParentTextSize(textlen);
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        stpb.writeOut(out);
+        try {
+            stpb.writeOut(out);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
         byte[] bytes = out.toByteArray();
 
         assertEquals(data.length, bytes.length);
@@ -689,7 +692,7 @@ public final class TestStyleTextPropAtom extends TestCase {
         }
     }
 
-    public void testNotEnoughDataProp() throws Exception {
+    public void testNotEnoughDataProp() {
         // We don't have enough data in the record to cover
         //  all the properties the mask says we have
         // Make sure we just do the best we can
@@ -702,7 +705,7 @@ public final class TestStyleTextPropAtom extends TestCase {
     /**
      * Check the test data for Bug 40143.
      */
-    public void testBug40143() throws Exception {
+    public void testBug40143() {
         StyleTextPropAtom atom = new StyleTextPropAtom(data_d, 0, data_d.length);
         atom.setParentTextSize(data_d_text_len);
 
@@ -724,7 +727,7 @@ public final class TestStyleTextPropAtom extends TestCase {
     /**
      * Check the test data for Bug 42677.
      */
-     public void test42677() throws Exception {
+     public void test42677() {
         int length = 18;
         byte[] data = {0x00, 0x00, (byte)0xA1, 0x0F, 0x28, 0x00, 0x00, 0x00,
                        0x13, 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , (byte)0xF1 , 0x20 , 0x00, 0x00 , 0x00 , 0x00 ,
@@ -748,7 +751,7 @@ public final class TestStyleTextPropAtom extends TestCase {
      *   00 00 00 01 18 00 00 01 18 01 00 00 00 01 1C 00 00 01 1C
      * </StyleTextPropAtom>
      */
-    public void test45815() throws Exception {
+    public void test45815() {
         int length = 19;
         byte[] data = {
                 0x00, 0x00, (byte)0xA1, 0x0F, 0x5E, 0x00, 0x00, 0x00, 0x14, 0x00,
index fa2f664e32a9c0302c8b80e732de401107e3d2a0..f9d1b835709616972bfa72f3b308e613a48938f6 100755 (executable)
 
 package org.apache.poi.hslf.record;
 
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp;
-import org.apache.poi.hslf.model.textproperties.TextProp;
-import org.apache.poi.hslf.model.textproperties.TextPropCollection;
-import org.apache.poi.hslf.record.StyleTextPropAtom.*;
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.util.HexDump;
-
-import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
-import java.util.LinkedList;
 import java.util.Arrays;
 
+import junit.framework.TestCase;
+
 /**
  * Tests TextRulerAtom
  *
@@ -37,53 +29,51 @@ import java.util.Arrays;
  */
 public final class TestTextRulerAtom extends TestCase {
 
-    //from a real file
+       //from a real file
        private byte[] data_1 = new byte[] {
                0x00, 0x00, (byte)0xA6, 0x0F, 0x18, 0x00, 0x00, 0x00,
-        (byte)0xF8, 0x1F, 0x00, 0x00, 0x75, 0x00, (byte)0xE2, 0x00, 0x59,
-        0x01, (byte)0xC3, 0x01, 0x1A, 0x03, (byte)0x87, 0x03, (byte)0xF8,
-        0x03, 0x69, 0x04, (byte)0xF6, 0x05, (byte)0xF6, 0x05
+               (byte)0xF8, 0x1F, 0x00, 0x00, 0x75, 0x00, (byte)0xE2, 0x00, 0x59,
+               0x01, (byte)0xC3, 0x01, 0x1A, 0x03, (byte)0x87, 0x03, (byte)0xF8,
+               0x03, 0x69, 0x04, (byte)0xF6, 0x05, (byte)0xF6, 0x05
        };
 
-    private byte[] data_2 = new byte[] {
-        0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00,
-        0x10, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01
-    };
+       private byte[] data_2 = new byte[] {
+               0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00,
+               0x10, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01
+       };
 
-    public void testReadRuler() throws Exception {
+       public void testReadRuler() {
                TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length);
-        assertEquals(ruler.getNumberOfLevels(), 0);
-        assertEquals(ruler.getDefaultTabSize(), 0);
+               assertEquals(ruler.getNumberOfLevels(), 0);
+               assertEquals(ruler.getDefaultTabSize(), 0);
 
-        int[] tabStops = ruler.getTabStops();
-        assertNull(tabStops);
+               int[] tabStops = ruler.getTabStops();
+               assertNull(tabStops);
 
-        int[] textOffsets = ruler.getTextOffsets();
-        assertTrue(Arrays.equals(new int[]{226, 451, 903, 1129, 1526}, textOffsets));
+               int[] textOffsets = ruler.getTextOffsets();
+               assertTrue(Arrays.equals(new int[]{226, 451, 903, 1129, 1526}, textOffsets));
 
-        int[] bulletOffsets = ruler.getBulletOffsets();
-        assertTrue(Arrays.equals(new int[]{117, 345, 794, 1016, 1526}, bulletOffsets));
+               int[] bulletOffsets = ruler.getBulletOffsets();
+               assertTrue(Arrays.equals(new int[]{117, 345, 794, 1016, 1526}, bulletOffsets));
 
        }
 
-    public void testWriteRuler() throws Exception {
+       public void testWriteRuler() throws Exception {
                TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length);
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        ruler.writeOut(out);
+               ByteArrayOutputStream out = new ByteArrayOutputStream();
+               ruler.writeOut(out);
 
-        byte[] result = out.toByteArray();
-        assertTrue(Arrays.equals(result, data_1));
+               byte[] result = out.toByteArray();
+               assertTrue(Arrays.equals(result, data_1));
        }
 
-    public void testRead2() throws Exception {
+       public void testRead2() throws Exception {
                TextRulerAtom ruler = TextRulerAtom.getParagraphInstance();
-        ruler.setParagraphIndent((short)249, (short)321);
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        ruler.writeOut(out);
-
-        byte[] result = out.toByteArray();
-        assertTrue(Arrays.equals(result, data_2));
+               ruler.setParagraphIndent((short)249, (short)321);
+               ByteArrayOutputStream out = new ByteArrayOutputStream();
+               ruler.writeOut(out);
 
+               byte[] result = out.toByteArray();
+               assertTrue(Arrays.equals(result, data_2));
        }
-
 }
index 62fb5ee285609bd5e1dfa9f4b6e06694d5657721..42626f5f418d62d709612f664210235c580c8adc 100755 (executable)
 
 package org.apache.poi.hslf.record;
 
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp;
-import org.apache.poi.hslf.model.textproperties.TextProp;
-import org.apache.poi.hslf.model.textproperties.TextPropCollection;
-import org.apache.poi.hslf.record.StyleTextPropAtom.*;
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.util.HexDump;
-
-import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
-import java.util.LinkedList;
 import java.util.Arrays;
 
+import junit.framework.TestCase;
+
 /**
  * Tests TextSpecInfoAtom
  *
@@ -38,17 +30,17 @@ import java.util.Arrays;
 public final class TestTextSpecInfoAtom extends TestCase {
 
     //from a real file
-       private byte[] data_1 = new byte[] {
+    private byte[] data_1 = new byte[] {
         0x00, 0x00, (byte)0xAA, 0x0F, 0x2C, 0x00, 0x00, 0x00,
         0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
         0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00,
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x01,
         0x00, 0x00, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-       };
+    };
 
 
-    public void testRead() throws Exception {
-               TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
+    public void testRead() {
+        TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
         TextSpecInfoAtom.TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();
         assertEquals(5, run.length);
 
index 9f3d575c22e79f55e8b558082f5de77c5218e7f7..4e3d07ade089643abe299ff92d5ebf1906acb7af 100644 (file)
@@ -20,8 +20,6 @@ package org.apache.poi.hslf.record;
 
 import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
 
 /**
  * Tests that TxInteractiveInfoAtom works properly.
@@ -35,24 +33,24 @@ public final class TestTxInteractiveInfoAtom extends TestCase {
                0x19, 00, 00, 00, 0x38, 00, 00, 00
        };
 
-    private byte[] data_b = new byte[] {
-        00, 00, (byte)0xDF, 0x0F, 0x08, 00, 00, 00,
-        0x39, 00, 00, 00, 0x4E, 00, 00, 00
-    };
+       private byte[] data_b = new byte[] {
+               00, 00, (byte)0xDF, 0x0F, 0x08, 00, 00, 00,
+               0x39, 00, 00, 00, 0x4E, 00, 00, 00
+       };
 
-    public void testRead() throws Exception {
-        TxInteractiveInfoAtom ia1 = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
+       public void testRead() {
+               TxInteractiveInfoAtom ia1 = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
 
-        assertEquals(4063, ia1.getRecordType());
+               assertEquals(4063, ia1.getRecordType());
                assertEquals(25, ia1.getStartIndex());
                assertEquals(56, ia1.getEndIndex());
 
-        TxInteractiveInfoAtom ia2 = new TxInteractiveInfoAtom(data_b, 0, data_b.length);
+               TxInteractiveInfoAtom ia2 = new TxInteractiveInfoAtom(data_b, 0, data_b.length);
 
-        assertEquals(4063, ia2.getRecordType());
+               assertEquals(4063, ia2.getRecordType());
                assertEquals(57, ia2.getStartIndex());
                assertEquals(78, ia2.getEndIndex());
-    }
+       }
 
        public void testWrite() throws Exception {
                TxInteractiveInfoAtom atom = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
@@ -67,12 +65,12 @@ public final class TestTxInteractiveInfoAtom extends TestCase {
        }
 
        // Create A from scratch
-    public void testCreate() throws Exception {
-       TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom();
+       public void testCreate() throws Exception {
+               TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom();
 
-       // Set values
-        ia.setStartIndex(25);
-       ia.setEndIndex(56);
+               // Set values
+               ia.setStartIndex(25);
+               ia.setEndIndex(56);
 
                // Check it's now the same as a
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -83,7 +81,7 @@ public final class TestTxInteractiveInfoAtom extends TestCase {
                for(int i=0; i<data_a.length; i++) {
                        assertEquals(data_a[i],b[i]);
                }
-    }
+       }
 
        // Try to turn a into b
        public void testChange() throws Exception {
@@ -91,7 +89,7 @@ public final class TestTxInteractiveInfoAtom extends TestCase {
 
                // Change the number
                ia.setStartIndex(57);
-        ia.setEndIndex(78);
+               ia.setEndIndex(78);
 
                // Check bytes are now the same
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
index 5072a30332d6c43a29a2ddcce792d84ec3b7b591..52bf6b2dc7fe1f83231a7b3a181fdb03ed24cd09 100644 (file)
 
 package org.apache.poi.hslf.record;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
-import org.apache.poi.hslf.usermodel.SlideShow;
+
 import org.apache.poi.hslf.model.textproperties.TextProp;
 import org.apache.poi.hslf.model.textproperties.TextPropCollection;
-import org.apache.poi.hslf.record.StyleTextPropAtom.*;
-
-import java.util.ArrayList;
+import org.apache.poi.hslf.usermodel.SlideShow;
 
 
 /**
@@ -36,9 +38,8 @@ import java.util.ArrayList;
 public final class TestTxMasterStyleAtom extends TestCase {
     protected SlideShow _ppt;
 
-    public void setUp() throws Exception{
+    public void setUp() {
         _ppt = new SlideShow();
-
     }
 
     public void testDefaultStyles()  {
@@ -199,23 +200,25 @@ public final class TestTxMasterStyleAtom extends TestCase {
      * There must be a TxMasterStyleAtom per each type of text defined in TextHeaderAtom
      */
     protected TxMasterStyleAtom[] getMasterStyles(){
-        ArrayList lst = new ArrayList();
+        List<TxMasterStyleAtom> lst = new ArrayList<TxMasterStyleAtom>();
 
-        Record[] core = _ppt.getMostRecentCoreRecords();
-        for (int i = 0; i < core.length; i++) {
-            if(core[i].getRecordType() == RecordTypes.MainMaster.typeID){
-                Record[] rec = core[i].getChildRecords();
+        Record[] coreRecs = _ppt.getMostRecentCoreRecords();
+        for (int i = 0; i < coreRecs.length; i++) {
+            Record coreRec = coreRecs[i];
+            if(coreRec.getRecordType() == RecordTypes.MainMaster.typeID){
+                Record[] recs = coreRec.getChildRecords();
                 int cnt = 0;
-                for (int j = 0; j < rec.length; j++) {
-                    if (rec[j] instanceof TxMasterStyleAtom) {
-                        lst.add(rec[j]);
+                for (int j = 0; j < recs.length; j++) {
+                    Record rec = recs[j];
+                    if (rec instanceof TxMasterStyleAtom) {
+                        lst.add((TxMasterStyleAtom) rec);
                         cnt++;
                     }
                 }
                 assertEquals("MainMaster must contain 7 TxMasterStyleAtoms ", 7, cnt);
-            } else if(core[i].getRecordType() == RecordTypes.Document.typeID){
+            } else if(coreRec.getRecordType() == RecordTypes.Document.typeID){
                 TxMasterStyleAtom txstyle = null;
-                Document doc = (Document)core[i];
+                Document doc = (Document)coreRec;
                 Record[] rec = doc.getEnvironment().getChildRecords();
                 for (int j = 0; j < rec.length; j++) {
                     if (rec[j] instanceof TxMasterStyleAtom) {
@@ -223,7 +226,9 @@ public final class TestTxMasterStyleAtom extends TestCase {
                         txstyle = (TxMasterStyleAtom)rec[j];
                     }
                 }
-                assertNotNull("TxMasterStyleAtom not found in Document.Environment", txstyle);
+                if (txstyle == null) {
+                    throw new AssertionFailedError("TxMasterStyleAtom not found in Document.Environment");
+                }
 
                 assertEquals("Document.Environment must contain TxMasterStyleAtom  with type=TextHeaderAtom.OTHER_TYPE",
                         TextHeaderAtom.OTHER_TYPE, txstyle.getTextType());
@@ -231,6 +236,6 @@ public final class TestTxMasterStyleAtom extends TestCase {
             }
         }
 
-        return (TxMasterStyleAtom[])lst.toArray(new TxMasterStyleAtom[lst.size()]);
+        return lst.toArray(new TxMasterStyleAtom[lst.size()]);
     }
 }
index 742131a9358fe1bbcb068abd912b85bc59e3d969..3ab57adcd3c1d60284776d212cd859ad84cf3dfe 100644 (file)
 
 package org.apache.poi.hslf.usermodel;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
+
 import org.apache.poi.hslf.HSLFSlideShow;
 import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
-import org.apache.poi.hslf.model.*;
+import org.apache.poi.hslf.model.Background;
+import org.apache.poi.hslf.model.Fill;
+import org.apache.poi.hslf.model.MasterSheet;
+import org.apache.poi.hslf.model.Notes;
+import org.apache.poi.hslf.model.Picture;
 import org.apache.poi.hslf.model.Shape;
-
-import java.io.*;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.awt.*;
+import org.apache.poi.hslf.model.ShapeGroup;
+import org.apache.poi.hslf.model.Slide;
+import org.apache.poi.hslf.model.SlideMaster;
+import org.apache.poi.hslf.model.TextBox;
+import org.apache.poi.hslf.model.TextRun;
+import org.apache.poi.hslf.model.TextShape;
+import org.apache.poi.hslf.model.TitleMaster;
 
 /**
  * Testcases for bugs entered in bugzilla
@@ -99,7 +115,7 @@ public final class TestBugs extends TestCase {
         SlideShow ppt = new SlideShow(hslf);
 
         //map slide number and starting phrase of its notes
-        HashMap notesMap = new HashMap();
+        Map<Integer, String> notesMap = new HashMap<Integer, String>();
         notesMap.put(new Integer(4), "For  decades before calculators");
         notesMap.put(new Integer(5), "Several commercial applications");
         notesMap.put(new Integer(6), "There are three variations of LNS that are discussed here");
@@ -113,7 +129,7 @@ public final class TestBugs extends TestCase {
             if (notesMap.containsKey(slideNumber)){
                 assertNotNull(notes);
                 String text = notes.getTextRuns()[0].getRawText();
-                String startingPhrase = (String)notesMap.get(slideNumber);
+                String startingPhrase = notesMap.get(slideNumber);
                 assertTrue("Notes for slide " + slideNumber + " must start with " +
                         startingPhrase , text.startsWith(startingPhrase));
             }
@@ -287,7 +303,7 @@ public final class TestBugs extends TestCase {
         TextRun[] runs = slide[0].getTextRuns();
         assertEquals(4, runs.length);
 
-        HashSet txt = new HashSet();
+        Set<String> txt = new HashSet<String>();
         txt.add("\u201CHAPPY BIRTHDAY SCOTT\u201D");
         txt.add("Have a HAPPY DAY");
         txt.add("PS Nobody is allowed to hassle Scott TODAY\u2026");
@@ -314,12 +330,14 @@ public final class TestBugs extends TestCase {
         Slide slide = ppt.getSlides()[0];
         TextRun[] tr1 = slide.getTextRuns();
 
-        ArrayList lst = new ArrayList();
+        List<TextRun> lst = new ArrayList<TextRun>();
         Shape[] shape = slide.getShapes();
         for (int i = 0; i < shape.length; i++) {
             if( shape[i] instanceof TextShape){
                 TextRun textRun = ((TextShape)shape[i]).getTextRun();
-                if(textRun != null) lst.add(textRun);
+                if(textRun != null) {
+                    lst.add(textRun);
+                }
             }
 
         }
@@ -356,10 +374,15 @@ public final class TestBugs extends TestCase {
      */
     public void test44770() throws Exception {
         FileInputStream is = new FileInputStream(new File(cwd, "44770.ppt"));
-        SlideShow ppt = new SlideShow(is);
+        try {
+            new SlideShow(is);
+        } catch (RuntimeException e) {
+            if (e.getMessage().equals("Couldn't instantiate the class for type with id 1036 on class class org.apache.poi.hslf.record.PPDrawing")) {
+                throw new AssertionFailedError("Identified bug 44770");
+            }
+            throw e;
+        }
         is.close();
-
-        assertTrue("No Exceptions while reading file", true);
     }
 
     /**
index c5f3063fe8e6a59e2cc611ebee1b63b127e39e34..da04a33d103a6c468026133f61c1c37e8810b5d4 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.poi.hslf.usermodel;
 
 import junit.framework.TestCase;
 import org.apache.poi.hslf.*;
-import org.apache.poi.hslf.model.*;
 import org.apache.poi.hslf.record.ParentAwareRecord;
 import org.apache.poi.hslf.record.Record;
 import org.apache.poi.hslf.record.RecordContainer;
index eea37695c478702990f90add5febd7ef1981c948..8b7c4c21f4047f518ef42f3d0a6f970f1ec09026 100755 (executable)
 
 package org.apache.poi.hslf.usermodel;
 
-import org.apache.poi.hslf.*;
-import org.apache.poi.hslf.exceptions.HSLFException;
-import org.apache.poi.hslf.blip.*;
-import org.apache.poi.hslf.model.*;
-import junit.framework.TestCase;
-
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
 import java.util.Arrays;
 
+import junit.framework.TestCase;
+
 /**
  * Test reading sound data from a ppt
  *
@@ -35,7 +32,7 @@ public final class TestSoundData extends TestCase{
 
     protected File cwd;
 
-    public void setUp() throws Exception {
+    public void setUp() {
         cwd = new File(System.getProperty("HSLF.testdata.path"));
     }
 
index c2607f1ac3ddcc8cf43e1ff935ec5348867fda01..bc36e0d40ca5a17b1abc5973ec93d2124a5ac875 100644 (file)
 package org.apache.poi.hwpf.model;
 
 import java.io.*;
-import java.util.*;
-import junit.framework.*;
+import java.util.Arrays;
+import java.util.List;
 
-import org.apache.poi.hwpf.*;
-import org.apache.poi.hwpf.model.*;
-import org.apache.poi.util.*;
+import junit.framework.TestCase;
+
+import org.apache.poi.hwpf.HWPFDocument;
 
 /**
  * Unit test for {@link SavedByTable} and {@link SavedByEntry}.
index 2dd669e7c3b3a4a3df02c658a49231ad8e2b126f..0f2034de4910d2fcbe5083e2e9d2f06ea94dc46d 100644 (file)
@@ -35,132 +35,128 @@ import org.apache.poi.util.LittleEndian;
 public final class TestPictures extends TestCase {
        private String dirname = System.getProperty("HWPF.testdata.path");
 
-    protected void setUp() throws Exception {
-    }
-
-    /**
-     * two jpegs
-     */
-    public void testTwoImages() throws Exception {
-       HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/two_images.doc"));
-       List pics = doc.getPicturesTable().getAllPictures();
-
-       assertNotNull(pics);
-       assertEquals(pics.size(), 2);
-       for(int i=0; i<pics.size(); i++) {
-               Object p = pics.get(i);
-               assertTrue(p instanceof Picture);
-
-               Picture pic = (Picture)p;
-               assertNotNull(pic.suggestFileExtension());
-               assertNotNull(pic.suggestFullFileName());
-       }
-
-       Picture picA = (Picture)pics.get(0);
-       Picture picB = (Picture)pics.get(1);
-       assertEquals("jpg", picA.suggestFileExtension());
-       assertEquals("jpg", picA.suggestFileExtension());
-    }
-
-    /**
-     * pngs and jpegs
-     */
-    public void testDifferentImages() throws Exception {
-       HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/testPictures.doc"));
-       List pics = doc.getPicturesTable().getAllPictures();
-
-       assertNotNull(pics);
-       assertEquals(7, pics.size());
-       for(int i=0; i<pics.size(); i++) {
-               Object p = pics.get(i);
-               assertTrue(p instanceof Picture);
-
-               Picture pic = (Picture)p;
-               assertNotNull(pic.suggestFileExtension());
-               assertNotNull(pic.suggestFullFileName());
-       }
-
-       assertEquals("jpg", ((Picture)pics.get(0)).suggestFileExtension());
-       assertEquals("jpg", ((Picture)pics.get(1)).suggestFileExtension());
-       assertEquals("png", ((Picture)pics.get(3)).suggestFileExtension());
-       assertEquals("png", ((Picture)pics.get(4)).suggestFileExtension());
-       assertEquals("wmf", ((Picture)pics.get(5)).suggestFileExtension());
-       assertEquals("jpg", ((Picture)pics.get(6)).suggestFileExtension());
-    }
-
-    /**
-     * emf image, nice and simple
-     */
-    public void testEmfImage() throws Exception {
-       HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/vector_image.doc"));
-       List pics = doc.getPicturesTable().getAllPictures();
-
-       assertNotNull(pics);
-       assertEquals(1, pics.size());
-
-       Picture pic = (Picture)pics.get(0);
-       assertNotNull(pic.suggestFileExtension());
-       assertNotNull(pic.suggestFullFileName());
-       assertTrue(pic.getSize() > 128);
-
-       // Check right contents
-       byte[] emf = loadImage("vector_image.emf");
-       byte[] pemf = pic.getContent();
-       assertEquals(emf.length, pemf.length);
-       for(int i=0; i<emf.length; i++) {
-               assertEquals(emf[i], pemf[i]);
-       }
-    }
-
-    /**
-     * emf image, with a crazy offset
-     */
-    public void testEmfComplexImage() throws Exception {
-       /*
-
-       Commenting out this test case temporarily. The file emf_2003_image does not contain any
-       pictures. Instead it has an office drawing object. Need to rewrite this test after
-       revisiting the implementation of office drawing objects.
-
-       HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/emf_2003_image.doc"));
-       List pics = doc.getPicturesTable().getAllPictures();
-
-       assertNotNull(pics);
-       assertEquals(1, pics.size());
-
-       Picture pic = (Picture)pics.get(0);
-       assertNotNull(pic.suggestFileExtension());
-       assertNotNull(pic.suggestFullFileName());
-
-       // This one's tricky
-       // TODO: Fix once we've sorted bug #41898
-       assertNotNull(pic.getContent());
-       assertNotNull(pic.getRawContent());
-
-       // These are probably some sort of offset, need to figure them out
-       assertEquals(4, pic.getSize());
-       assertEquals(0x80000000l, LittleEndian.getUInt(pic.getContent()));
-       assertEquals(0x80000000l, LittleEndian.getUInt(pic.getRawContent()));
-       */
-    }
-
-    public void testPicturesWithTable() throws Exception {
-       HWPFDocument doc = new HWPFDocument(new FileInputStream(
-                       new File(dirname, "Bug44603.doc")));
-
-       List pics = doc.getPicturesTable().getAllPictures();
-       assertEquals(pics.size(), 2);
-    }
-
-    private byte[] loadImage(String filename) throws Exception {
-       ByteArrayOutputStream b = new ByteArrayOutputStream();
-       FileInputStream fis = new FileInputStream(dirname + "/" + filename);
-
-       byte[] buf = new byte[4096];
-       int read = 0;
-       while( (read = fis.read(buf)) > -1 ) {
-               b.write(buf, 0, read);
-       }
-       return b.toByteArray();
-    }
+
+       /**
+        * two jpegs
+        */
+       public void testTwoImages() throws Exception {
+               HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/two_images.doc"));
+               List pics = doc.getPicturesTable().getAllPictures();
+
+               assertNotNull(pics);
+               assertEquals(pics.size(), 2);
+               for(int i=0; i<pics.size(); i++) {
+                       Object p = pics.get(i);
+                       assertTrue(p instanceof Picture);
+
+                       Picture pic = (Picture)p;
+                       assertNotNull(pic.suggestFileExtension());
+                       assertNotNull(pic.suggestFullFileName());
+               }
+
+               Picture picA = (Picture)pics.get(0);
+               Picture picB = (Picture)pics.get(1);
+               assertEquals("jpg", picA.suggestFileExtension());
+               assertEquals("jpg", picA.suggestFileExtension());
+       }
+
+       /**
+        * pngs and jpegs
+        */
+       public void testDifferentImages() throws Exception {
+               HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/testPictures.doc"));
+               List pics = doc.getPicturesTable().getAllPictures();
+
+               assertNotNull(pics);
+               assertEquals(7, pics.size());
+               for(int i=0; i<pics.size(); i++) {
+                       Object p = pics.get(i);
+                       assertTrue(p instanceof Picture);
+
+                       Picture pic = (Picture)p;
+                       assertNotNull(pic.suggestFileExtension());
+                       assertNotNull(pic.suggestFullFileName());
+               }
+
+               assertEquals("jpg", ((Picture)pics.get(0)).suggestFileExtension());
+               assertEquals("jpg", ((Picture)pics.get(1)).suggestFileExtension());
+               assertEquals("png", ((Picture)pics.get(3)).suggestFileExtension());
+               assertEquals("png", ((Picture)pics.get(4)).suggestFileExtension());
+               assertEquals("wmf", ((Picture)pics.get(5)).suggestFileExtension());
+               assertEquals("jpg", ((Picture)pics.get(6)).suggestFileExtension());
+       }
+
+       /**
+        * emf image, nice and simple
+        */
+       public void testEmfImage() throws Exception {
+               HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/vector_image.doc"));
+               List pics = doc.getPicturesTable().getAllPictures();
+
+               assertNotNull(pics);
+               assertEquals(1, pics.size());
+
+               Picture pic = (Picture)pics.get(0);
+               assertNotNull(pic.suggestFileExtension());
+               assertNotNull(pic.suggestFullFileName());
+               assertTrue(pic.getSize() > 128);
+
+               // Check right contents
+               byte[] emf = loadImage("vector_image.emf");
+               byte[] pemf = pic.getContent();
+               assertEquals(emf.length, pemf.length);
+               for(int i=0; i<emf.length; i++) {
+                       assertEquals(emf[i], pemf[i]);
+               }
+       }
+
+       /**
+        * emf image, with a crazy offset
+        */
+       public void disabled_testEmfComplexImage() throws Exception {
+
+               // Commenting out this test case temporarily. The file emf_2003_image does not contain any
+               // pictures. Instead it has an office drawing object. Need to rewrite this test after
+               // revisiting the implementation of office drawing objects.
+
+               HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/emf_2003_image.doc"));
+               List pics = doc.getPicturesTable().getAllPictures();
+
+               assertNotNull(pics);
+               assertEquals(1, pics.size());
+
+               Picture pic = (Picture)pics.get(0);
+               assertNotNull(pic.suggestFileExtension());
+               assertNotNull(pic.suggestFullFileName());
+
+               // This one's tricky
+               // TODO: Fix once we've sorted bug #41898
+               assertNotNull(pic.getContent());
+               assertNotNull(pic.getRawContent());
+
+               // These are probably some sort of offset, need to figure them out
+               assertEquals(4, pic.getSize());
+               assertEquals(0x80000000l, LittleEndian.getUInt(pic.getContent()));
+               assertEquals(0x80000000l, LittleEndian.getUInt(pic.getRawContent()));
+       }
+
+       public void testPicturesWithTable() throws Exception {
+               HWPFDocument doc = new HWPFDocument(new FileInputStream(
+                               new File(dirname, "Bug44603.doc")));
+
+               List pics = doc.getPicturesTable().getAllPictures();
+               assertEquals(pics.size(), 2);
+       }
+
+       private byte[] loadImage(String filename) throws Exception {
+               ByteArrayOutputStream b = new ByteArrayOutputStream();
+               FileInputStream fis = new FileInputStream(dirname + "/" + filename);
+
+               byte[] buf = new byte[4096];
+               int read = 0;
+               while( (read = fis.read(buf)) > -1 ) {
+                       b.write(buf, 0, read);
+               }
+               return b.toByteArray();
+       }
 }
index 7749e77224d0f91211174a137d41e558c37faf9e..b237da0ca33396dfe31105dc382ae917b5b936c8 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hwpf.usermodel;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
 import java.io.FileInputStream;
 import java.util.List;
 
@@ -33,11 +32,11 @@ import org.apache.poi.hwpf.HWPFDocument;
 public final class TestShapes extends TestCase {
        private String dirname = System.getProperty("HWPF.testdata.path");
 
-    /**
-     * two shapes, second is a group
-     */
-    public void testShapes() throws Exception {
-       HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/WithArtShapes.doc"));
+       /**
+        * two shapes, second is a group
+        */
+       public void testShapes() throws Exception {
+               HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/WithArtShapes.doc"));
 
                List shapes = doc.getShapesTable().getAllShapes();
                List vshapes = doc.getShapesTable().getVisibleShapes();
@@ -79,6 +78,5 @@ public final class TestShapes extends TestCase {
                assertEquals(4817, s2.getWidth());
                assertEquals(2164, s2.getHeight());
                assertEquals(true, s2.isWithinDocument());
-
-    }
+       }
 }
index a96ba84968b93a27565d322bb7e7f3567a4d2d0f..975a8b5ff7ff11b7794b5f8f2963846acc510de2 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 import junit.framework.TestCase;
 import org.apache.poi.util.HexRead;
 import org.apache.poi.util.HexDump;
 
-import java.io.IOException;
 import java.util.Arrays;
 
-public class TestEscherOptRecord extends TestCase
-{
+public final class TestEscherOptRecord extends TestCase {
 
     public void testFillFields() {
         checkFillFieldsSimple();
@@ -151,93 +148,93 @@ public class TestEscherOptRecord extends TestCase
     }
 
     /**
-     * Test serialisation of a particually complex example 
+     * Test serialisation of a particually complex example
      * This test is currently broken!
      */
     public void testComplexSerialise() {
        byte[] data = {
-               0x53, 0x01, 0x0B, 0xF0-256, 0x9C-256, 0x01, 0x00, 0x00, 
+               0x53, 0x01, 0x0B, 0xF0-256, 0x9C-256, 0x01, 0x00, 0x00,
                // Simple data follows
                0x42, 0x01,     0x49, 0x00, 0x00, 0x00,          // SP @ 8
                0x43, 0x01, 0x85-256, 0x00, 0x00, 0x00,      // SP @ 14
                0x44, 0x01, 0x04, 0x00, 0x00, 0x00,          // SP @ 20
                0x45, 0xC1-256, 0x88-256, 0x00, 0x00, 0x00,  // SP @ 26
                0x46, 0xC1-256, 0x90-256, 0x00, 0x00, 0x00,  // SP @ 32
-               0x7F, 0x01, 0x01, 0x00, 0x01, 0x00, 
-               0x80-256, 0x01, 0x00, 0x00, 0x00, 0x00, 
-               0x81-256, 0x01, 0x02, 0x00, 0x00, 0x08, 
-               0xBF-256, 0x01, 0x10, 0x00, 0x10, 0x00, 
-               0xC0-256, 0x01, 0x01, 0x00, 0x00, 0x08,      // SP 10 
+               0x7F, 0x01, 0x01, 0x00, 0x01, 0x00,
+               0x80-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+               0x81-256, 0x01, 0x02, 0x00, 0x00, 0x08,
+               0xBF-256, 0x01, 0x10, 0x00, 0x10, 0x00,
+               0xC0-256, 0x01, 0x01, 0x00, 0x00, 0x08,      // SP 10
                0xC1-256, 0x01, 0x00, 0x00, 0x01, 0x00,
-               0xC4-256, 0x01, 0x00, 0x00, 0x00, 0x00, 
-               0xCB-256, 0x01, 0x38, 0x63, 0x00, 0x00, 
-               0xCD-256, 0x01, 0x00, 0x00,     0x00, 0x00, 
+               0xC4-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+               0xCB-256, 0x01, 0x38, 0x63, 0x00, 0x00,
+               0xCD-256, 0x01, 0x00, 0x00,     0x00, 0x00,
                0xCE-256, 0x01, 0x00, 0x00, 0x00, 0x00,      // SP 15
-               0xD0-256, 0x01, 0x00, 0x00, 0x00, 0x00, 
-               0xD1-256, 0x01, 0x00, 0x00, 0x00, 0x00, 
-               0xD7-256, 0x01, 0x00, 0x00, 0x00, 0x00, 
+               0xD0-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+               0xD1-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+               0xD7-256, 0x01, 0x00, 0x00, 0x00, 0x00,
                0xFF-256, 0x01, 0x18, 0x00, 0x18, 0x00,
-               0x01, 0x02, 0x02, 0x00, 0x00, 0x08, 
+               0x01, 0x02, 0x02, 0x00, 0x00, 0x08,
                0x3F, 0x02, 0x00, 0x00, 0x02, 0x00,          // SP 21
-               
+
                // Complex data follows
-               
+
                // Complex data for Array #325
                // Array header
-               0x22, 0x00, 0x22, 0x00, 0xF0-256, 0xFF-256, 
+               0x22, 0x00, 0x22, 0x00, 0xF0-256, 0xFF-256,
                // Array data
-               0x18, 0x00, 0x28, 0x00, 0x04, 0x00, 0x34, 
+               0x18, 0x00, 0x28, 0x00, 0x04, 0x00, 0x34,
                0x00, 0x04, 0x00, 0x28, 0x00, 0x04, 0x00,
-               0x1C, 0x00, 0x04, 0x00, 0x10, 0x00, 0x04, 0x00, 0x04, 0x00, 0x10, 
+               0x1C, 0x00, 0x04, 0x00, 0x10, 0x00, 0x04, 0x00, 0x04, 0x00, 0x10,
                0x00, 0x00, 0x00, 0x1C, 0x00,
-               0x04, 0x00, 0x28, 0x00, 0x10, 0x00, 0x34, 0x00, 0x18, 0x00, 0x3C, 
+               0x04, 0x00, 0x28, 0x00, 0x10, 0x00, 0x34, 0x00, 0x18, 0x00, 0x3C,
                0x00, 0x24, 0x00, 0x44, 0x00,
-               0x30, 0x00, 0x48, 0x00, 0x3C, 0x00, 0x44, 0x00, 0x48, 0x00, 0x3C, 
+               0x30, 0x00, 0x48, 0x00, 0x3C, 0x00, 0x44, 0x00, 0x48, 0x00, 0x3C,
                0x00, 0x54, 0x00, 0x38, 0x00,
-               0x60, 0x00, 0x2C, 0x00, 0x70, 0x00, 0x20, 0x00, 0x78, 0x00, 
+               0x60, 0x00, 0x2C, 0x00, 0x70, 0x00, 0x20, 0x00, 0x78, 0x00,
                0x14, 0x00, 0x80-256, 0x00, 0x08, 0x00,
-               0x84-256, 0x00, 0x04, 0x00, 0x78, 0x00, 0x04, 0x00, 0x6C, 0x00, 
+               0x84-256, 0x00, 0x04, 0x00, 0x78, 0x00, 0x04, 0x00, 0x6C, 0x00,
                0x04, 0x00, 0x60, 0x00, 0x04, 0x00,
-               0x54, 0x00, 0x08, 0x00, 0x48, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0x0C, 
+               0x54, 0x00, 0x08, 0x00, 0x48, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0x0C,
                0x00, 0x30, 0x00, 0x08, 0x00,
-               0x3C, 0x00, 0x08, 0x00, 0x48, 0x00, 0x08, 0x00, 0x54, 0x00, 0x00, 
+               0x3C, 0x00, 0x08, 0x00, 0x48, 0x00, 0x08, 0x00, 0x54, 0x00, 0x00,
                0x00, 0x48, 0x00, 0x00, 0x00,
                0x3C, 0x00, 0x00, 0x00, 0x30, 0x00, 0x04, 0x00, 0x24, 0x00,
                // Complex data for Array #326
                // Array header
-               0x45, 0x00, 0x48, 0x00, 0x02, 0x00, 
+               0x45, 0x00, 0x48, 0x00, 0x02, 0x00,
                // Array data
-               0x00, 0x40, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 
+               0x00, 0x40, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
                0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
-               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 
+               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
                0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
-               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 
+               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
                0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
-               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 
+               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
                0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
-               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 
+               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
                0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
-               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 
+               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
                0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
-               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 
+               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
                0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
-               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 
+               0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
                0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
                0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x00, 0x80-256
        };
-       
+
        // Create the record
         EscherOptRecord r = new EscherOptRecord();
         int filled = r.fillFields( data, new DefaultEscherRecordFactory() );
-        
+
         // Check it's the right length
         assertEquals(data.length, filled);
         assertEquals(data.length, r.getRecordSize());
-        
+
         // Serialise it
         byte[] dest = new byte[data.length];
         int written = r.serialize(0, dest);
-        
+
         // Check it serialised it back to the same data
         assertEquals(data.length, written);
         for(int i=0; i<data.length; i++) {
index a920a09df6712578c29ccdbabd2426e931cef1dd..f207a0046d55d085a880f896b2688fd277625ae6 100755 (executable)
 
 package org.apache.poi.hssf.record;
 
-import junit.framework.TestCase;
-import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherSpRecord;
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.apache.poi.util.LittleEndianOutput;
-import org.apache.poi.util.LittleEndianOutputStream;
-import org.apache.poi.hssf.HSSFTestDataSamples;
-
-import java.io.*;
-import java.util.List;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
 
 public final class TestDrawingRecord extends TestCase {
 
@@ -68,4 +63,4 @@ public final class TestDrawingRecord extends TestCase {
 
     }
 
-}
\ No newline at end of file
+}
index 674279388c4a16b7c555236a2eb5bcddfadb1ad4..b14fd762cc71d0903ae69831e4a6ddfc50bf2acf 100644 (file)
@@ -18,8 +18,6 @@
 package org.apache.poi.hssf.record;
 
 
-import java.io.ByteArrayInputStream;
-
 import org.apache.poi.hssf.usermodel.HSSFRichTextString;
 import org.apache.poi.util.HexRead;
 
@@ -48,11 +46,11 @@ public final class TestTextObjectBaseRecord extends TestCase {
         "00 " + // unicode compressed
         "41 42 " + // 'AB'
         "3C 00 " + // ContinueRecord.sid
-        "10 00 " + // size 16 
+        "10 00 " + // size 16
         "00 00 18 00 00 00 00 00 " +
-        "02 00 00 00 00 00 00 00 " 
+        "02 00 00 00 00 00 00 00 "
     );
-    
+
 
     public void testLoad() {
         RecordInputStream in = TestcaseRecordInputStream.create(data);
index 8776214f144940cb0f43e56e9c84046e48d5022b..9f169cada8608af838e41f42bd60687dadb53b29 100644 (file)
@@ -17,9 +17,6 @@
 
 package org.apache.poi.hssf.record.aggregates;
 
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.Collection;
 import java.util.HashMap;
 
@@ -35,7 +32,7 @@ import org.apache.poi.hssf.usermodel.RecordInspector;
 
 /**
  * Tests for {@link SharedValueManager}
- * 
+ *
  * @author Josh Micich
  */
 public final class TestSharedValueManager extends TestCase {
@@ -46,19 +43,19 @@ public final class TestSharedValueManager extends TestCase {
         * The second sheet has two column shared formula ranges - one contained within the other.
         * These shared formula ranges were created by fill-dragging a single cell formula across the
         * desired region.  The larger shared formula ranges were placed first.<br/>
-        * 
+        *
         * There are probably many ways to produce similar effects, but it should be noted that Excel
         * is quite temperamental in this regard.  Slight variations in technique can cause the shared
         * formulas to spill out into plain formula records (which would make these tests pointless).
-        * 
+        *
         */
        private static final String SAMPLE_FILE_NAME = "overlapSharedFormula.xls";
        /**
-        * Some of these bugs are intermittent, and the test author couldn't think of a way to write 
+        * Some of these bugs are intermittent, and the test author couldn't think of a way to write
         * test code to hit them bug deterministically. The reason for the unpredictability is that
         * the bugs depended on the {@link SharedFormulaRecord}s being searched in a particular order.
-        * At the time of writing of the test, the order was being determined by the call to {@link 
-        * Collection#toArray(Object[])} on {@link HashMap#values()} where the items in the map were 
+        * At the time of writing of the test, the order was being determined by the call to {@link
+        * Collection#toArray(Object[])} on {@link HashMap#values()} where the items in the map were
         * using default {@link Object#hashCode()}<br/>
         */
        private static final int MAX_ATTEMPTS=5;
@@ -67,24 +64,24 @@ public final class TestSharedValueManager extends TestCase {
         * This bug happened when there were two or more shared formula ranges that overlapped.  POI
         * would sometimes associate formulas in the overlapping region with the wrong shared formula
         */
-       public void testPartiallyOverlappingRanges() throws IOException {
+       public void testPartiallyOverlappingRanges() {
                Record[] records;
 
                int attempt=1;
                do {
-               HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
-               
-               HSSFSheet sheet = wb.getSheetAt(0);
-               RecordInspector.getRecords(sheet, 0);
-               assertEquals("1+1", sheet.getRow(2).getCell(0).getCellFormula());
-               if ("1+1".equals(sheet.getRow(3).getCell(0).getCellFormula())) {
-                       throw new AssertionFailedError("Identified bug - wrong shared formula record chosen"
-                                       + " (attempt " + attempt + ")");
-               }
-               assertEquals("2+2", sheet.getRow(3).getCell(0).getCellFormula());
-               records = RecordInspector.getRecords(sheet, 0);
+                       HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
+
+                       HSSFSheet sheet = wb.getSheetAt(0);
+                       RecordInspector.getRecords(sheet, 0);
+                       assertEquals("1+1", sheet.getRow(2).getCell(0).getCellFormula());
+                       if ("1+1".equals(sheet.getRow(3).getCell(0).getCellFormula())) {
+                               throw new AssertionFailedError("Identified bug - wrong shared formula record chosen"
+                                               + " (attempt " + attempt + ")");
+                       }
+                       assertEquals("2+2", sheet.getRow(3).getCell(0).getCellFormula());
+                       records = RecordInspector.getRecords(sheet, 0);
                } while (attempt++ < MAX_ATTEMPTS);
-               
+
                int count=0;
                for (int i = 0; i < records.length; i++) {
                        if (records[i] instanceof SharedFormulaRecord) {
@@ -93,28 +90,28 @@ public final class TestSharedValueManager extends TestCase {
                }
                assertEquals(2, count);
        }
-       
+
        /**
         * This bug occurs for similar reasons to the bug in {@link #testPartiallyOverlappingRanges()}
         * but the symptoms are much uglier - serialization fails with {@link NullPointerException}.<br/>
         */
-       public void testCompletelyOverlappedRanges() throws IOException {
+       public void testCompletelyOverlappedRanges() {
                Record[] records;
 
                int attempt=1;
                do {
-               HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
-                       
-               HSSFSheet sheet = wb.getSheetAt(1);
-               try {
-                       records = RecordInspector.getRecords(sheet, 0);
-               } catch (NullPointerException e) {
-                       throw new AssertionFailedError("Identified bug " +
-                                       "- cannot reserialize completely overlapped shared formula"
-                                       + " (attempt " + attempt + ")");
-               }
+                       HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
+
+                       HSSFSheet sheet = wb.getSheetAt(1);
+                       try {
+                               records = RecordInspector.getRecords(sheet, 0);
+                       } catch (NullPointerException e) {
+                               throw new AssertionFailedError("Identified bug " +
+                                               "- cannot reserialize completely overlapped shared formula"
+                                               + " (attempt " + attempt + ")");
+                       }
                } while (attempt++ < MAX_ATTEMPTS);
-               
+
                int count=0;
                for (int i = 0; i < records.length; i++) {
                        if (records[i] instanceof SharedFormulaRecord) {
index db29380a9cc65abe794fddf8b7ab8748f7897e48..f2b7cd2e1454b82bfd6939b84417281828c704d7 100644 (file)
 
 package org.apache.poi.hssf.record.formula;
 
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
 import junit.framework.TestCase;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.model.Workbook;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
 /**
  * Convenient abstract class to reduce the amount of boilerplate code needed
index 5dab4cca141a10b14df175c217a46f65aea93efa..586fa6000370f3c32626274bb33fde82be6a3bcc 100644 (file)
@@ -19,26 +19,24 @@ package org.apache.poi.hssf.record.formula;
 
 import java.util.Arrays;
 
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.record.RecordInputStream;
 import org.apache.poi.hssf.record.TestcaseRecordInputStream;
-import org.apache.poi.hssf.record.UnicodeString;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.util.LittleEndianByteArrayOutputStream;
 import org.apache.poi.util.LittleEndianInput;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
 /**
  * Tests for <tt>ArrayPtg</tt>
- * 
+ *
  * @author Josh Micich
  */
 public final class TestArrayPtg extends TestCase {
 
        private static final byte[] ENCODED_PTG_DATA = {
                0x40,
-               0, 0, 0, 0, 0, 0, 0, 
+               0, 0, 0, 0, 0, 0, 0,
        };
        private static final byte[] ENCODED_CONSTANT_DATA = {
                2,    // 3 columns
@@ -52,28 +50,28 @@ public final class TestArrayPtg extends TestCase {
        };
 
        /**
-        * Lots of problems with ArrayPtg's encoding of 
+        * Lots of problems with ArrayPtg's encoding of
         */
        public void testReadWriteTokenValueBytes() {
-               
+
                ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createLittleEndian(ENCODED_PTG_DATA));
-               
+
                ptg.readTokenValues(TestcaseRecordInputStream.createLittleEndian(ENCODED_CONSTANT_DATA));
                assertEquals(3, ptg.getColumnCount());
                assertEquals(2, ptg.getRowCount());
                Object[][] values = ptg.getTokenArrayValues();
                assertEquals(2, values.length);
-               
-               
+
+
                assertEquals(Boolean.TRUE, values[0][0]);
                assertEquals("ABCD", values[0][1]);
                assertEquals(new Double(0), values[1][0]);
                assertEquals(Boolean.FALSE, values[1][1]);
                assertEquals("FG", values[1][2]);
-               
+
                byte[] outBuf = new byte[ENCODED_CONSTANT_DATA.length];
                ptg.writeTokenValueBytes(new LittleEndianByteArrayOutputStream(outBuf, 0));
-               
+
                if(outBuf[0] == 4) {
                        throw new AssertionFailedError("Identified bug 42564b");
                }
@@ -88,7 +86,7 @@ public final class TestArrayPtg extends TestCase {
                ptg.readTokenValues(TestcaseRecordInputStream.createLittleEndian(ENCODED_CONSTANT_DATA));
                assertEquals(3, ptg.getColumnCount());
                assertEquals(2, ptg.getRowCount());
-               
+
                assertEquals(0, ptg.getValueIndex(0, 0));
                assertEquals(1, ptg.getValueIndex(1, 0));
                assertEquals(2, ptg.getValueIndex(2, 0));
@@ -96,7 +94,7 @@ public final class TestArrayPtg extends TestCase {
                assertEquals(4, ptg.getValueIndex(1, 1));
                assertEquals(5, ptg.getValueIndex(2, 1));
        }
-       
+
        /**
         * Test for a bug which was temporarily introduced by the fix for bug 42564.
         * A spreadsheet was added to make the ordering clearer.
@@ -104,7 +102,7 @@ public final class TestArrayPtg extends TestCase {
        public void testElementOrderingInSpreadsheet() {
                HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex42564-elementOrder.xls");
 
-               // The formula has an array with 3 rows and 5 columns 
+               // The formula has an array with 3 rows and 5 columns
                String formula = wb.getSheetAt(0).getRow(0).getCell(0).getCellFormula();
                // TODO - These number literals should not have '.0'. Excel has different number rendering rules
 
@@ -116,9 +114,9 @@ public final class TestArrayPtg extends TestCase {
 
        public void testToFormulaString() {
                ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createLittleEndian(ENCODED_PTG_DATA));
-               
+
                ptg.readTokenValues(TestcaseRecordInputStream.createLittleEndian(ENCODED_CONSTANT_DATA));
-               
+
                String actualFormula;
                try {
                        actualFormula = ptg.toFormulaString();
@@ -130,7 +128,7 @@ public final class TestArrayPtg extends TestCase {
                }
                assertEquals("{TRUE,\"ABCD\",\"E\";0.0,FALSE,\"FG\"}", actualFormula);
        }
-       
+
        /**
         * worth checking since AttrPtg.sid=0x20 and Ptg.CLASS_* = (0x00, 0x20, and 0x40)
         */
@@ -145,11 +143,11 @@ public final class TestArrayPtg extends TestCase {
                System.arraycopy(ENCODED_PTG_DATA, 0, fullData, 0, ENCODED_PTG_DATA.length);
                System.arraycopy(ENCODED_CONSTANT_DATA, 0, fullData, ENCODED_PTG_DATA.length, ENCODED_CONSTANT_DATA.length);
 
-               // Force encoded operand class for tArray 
+               // Force encoded operand class for tArray
                fullData[0] = (byte) (ArrayPtg.sid + operandClass);
-               
+
                LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(fullData);
-               
+
                Ptg[] ptgs = Ptg.readTokens(ENCODED_PTG_DATA.length, in);
                assertEquals(1, ptgs.length);
                ArrayPtg aPtg = (ArrayPtg) ptgs[0];
index fb11b4c1b6709b1839247d9ef99b8cf9857d367e..878b7bdaec15a48bcf94602c3d964aa9e624874e 100755 (executable)
@@ -27,10 +27,9 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellValue;
-import org.apache.poi.ss.usermodel.ErrorConstants;
 /**
  * Tests HSSFFormulaEvaluator for its handling of cell formula circular references.
- * 
+ *
  * @author Josh Micich
  */
 public final class TestCircularReferences extends TestCase {
@@ -53,17 +52,17 @@ public final class TestCircularReferences extends TestCase {
                assertTrue(cellValue.getCellType() == HSSFCell.CELL_TYPE_ERROR);
                assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cellValue.getErrorValue());
        }
-       
-       
+
+
        /**
-        * ASF Bugzilla Bug 44413  
-        * "INDEX() formula cannot contain its own location in the data array range" 
+        * ASF Bugzilla Bug 44413
+        * "INDEX() formula cannot contain its own location in the data array range"
         */
        public void testIndexFormula() {
-               
+
                HSSFWorkbook wb = new HSSFWorkbook();
                HSSFSheet sheet = wb.createSheet("Sheet1");
-               
+
                int colB = 1;
                sheet.createRow(0).createCell(colB).setCellValue(1);
                sheet.createRow(1).createCell(colB).setCellValue(2);
@@ -73,13 +72,13 @@ public final class TestCircularReferences extends TestCase {
                // This formula should evaluate to the contents of B2,
                testCell.setCellFormula("INDEX(A1:B4,2,2)");
                // However the range A1:B4 also includes the current cell A4.  If the other parameters
-               // were 4 and 1, this would represent a circular reference.  Prior to v3.2 POI would 
+               // were 4 and 1, this would represent a circular reference.  Prior to v3.2 POI would
                // 'fully' evaluate ref arguments before invoking operators, which raised the possibility of
                // cycles / StackOverflowErrors.
-               
+
 
                CellValue cellValue = evaluateWithCycles(wb, testCell);
-               
+
                assertTrue(cellValue.getCellType() == HSSFCell.CELL_TYPE_NUMERIC);
                assertEquals(2, cellValue.getNumberValue(), 0);
        }
@@ -88,16 +87,16 @@ public final class TestCircularReferences extends TestCase {
         * Cell A1 has formula "=A1"
         */
        public void testSimpleCircularReference() {
-               
+
                HSSFWorkbook wb = new HSSFWorkbook();
                HSSFSheet sheet = wb.createSheet("Sheet1");
-               
+
                HSSFRow row = sheet.createRow(0);
                HSSFCell testCell = row.createCell(0);
                testCell.setCellFormula("A1");
 
                CellValue cellValue = evaluateWithCycles(wb, testCell);
-               
+
                confirmCycleErrorCode(cellValue);
        }
 
@@ -105,10 +104,10 @@ public final class TestCircularReferences extends TestCase {
         * A1=B1, B1=C1, C1=D1, D1=A1
         */
        public void testMultiLevelCircularReference() {
-               
+
                HSSFWorkbook wb = new HSSFWorkbook();
                HSSFSheet sheet = wb.createSheet("Sheet1");
-               
+
                HSSFRow row = sheet.createRow(0);
                row.createCell(0).setCellFormula("B1");
                row.createCell(1).setCellFormula("C1");
@@ -117,39 +116,39 @@ public final class TestCircularReferences extends TestCase {
                testCell.setCellFormula("A1");
 
                CellValue cellValue = evaluateWithCycles(wb, testCell);
-               
+
                confirmCycleErrorCode(cellValue);
        }
-       
+
        public void testIntermediateCircularReferenceResults_bug46898() {
                HSSFWorkbook wb = new HSSFWorkbook();
                HSSFSheet sheet = wb.createSheet("Sheet1");
-               
+
                HSSFRow row = sheet.createRow(0);
-               
+
                HSSFCell cellA1 = row.createCell(0);
                HSSFCell cellB1 = row.createCell(1);
                HSSFCell cellC1 = row.createCell(2);
                HSSFCell cellD1 = row.createCell(3);
                HSSFCell cellE1 = row.createCell(4);
-               
+
                cellA1.setCellFormula("IF(FALSE, 1+B1, 42)");
                cellB1.setCellFormula("1+C1");
                cellC1.setCellFormula("1+D1");
                cellD1.setCellFormula("1+E1");
                cellE1.setCellFormula("1+A1");
-               
+
                HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
                CellValue cv;
-               
-               // Happy day flow - evaluate A1 first 
+
+               // Happy day flow - evaluate A1 first
                cv = fe.evaluate(cellA1);
                assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
                assertEquals(42.0, cv.getNumberValue(), 0.0);
                cv = fe.evaluate(cellB1); // no circ-ref-error because A1 result is cached
                assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
                assertEquals(46.0, cv.getNumberValue(), 0.0);
-               
+
                // Show the bug - evaluate another cell from the loop first
                fe.clearAllCachedResultValues();
                cv = fe.evaluate(cellB1);
@@ -164,7 +163,7 @@ public final class TestCircularReferences extends TestCase {
                cv = fe.evaluate(cellE1);
                assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
                assertEquals(43.0, cv.getNumberValue(), 0.0);
-               
-               
+
+
        }
 }
index 694d679977d1ee3d9e8d1a5693ff46be623ba11b..31b45f622cee63a48ade8ab32544ebdf82523ba0 100755 (executable)
@@ -20,7 +20,6 @@ package org.apache.poi.hssf.record.formula.functions;
 import junit.framework.AssertionFailedError;
 
 import org.apache.poi.hssf.record.formula.eval.ErrorEval;
-import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
 import org.apache.poi.hssf.record.formula.eval.OperationEval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
index 4704b3ed84e1545ed23327950b49b3674fea1d43..1f276b77656b8995f403047845c2dcf7908eb7d8 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.usermodel;
 
 import junit.framework.TestCase;
 
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.util.Region;
 
 /**
- * Test the ability to clone a sheet. 
+ * Test the ability to clone a sheet.
  *  If adding new records that belong to a sheet (as opposed to a book)
- *  add that record to the sheet in the testCloneSheetBasic method. 
+ *  add that record to the sheet in the testCloneSheetBasic method.
  * @author  avik
  */
 public final class TestCloneSheet extends TestCase {
@@ -37,26 +34,25 @@ public final class TestCloneSheet extends TestCase {
                HSSFSheet s = b.createSheet("Test");
                s.addMergedRegion(new CellRangeAddress(0, 1, 0, 1));
                HSSFSheet clonedSheet = b.cloneSheet(0);
-               
+
                assertEquals("One merged area", 1, clonedSheet.getNumMergedRegions());
        }
 
-   /**
-    * Ensures that pagebreak cloning works properly
-    *
-    */
-   public void testPageBreakClones() {
-      HSSFWorkbook b = new HSSFWorkbook();
-      HSSFSheet s = b.createSheet("Test");
-      s.setRowBreak(3);
-      s.setColumnBreak((short)6);
-      
-      HSSFSheet clone = b.cloneSheet(0);
-      assertTrue("Row 3 not broken", clone.isRowBroken(3));
-      assertTrue("Column 6 not broken", clone.isColumnBroken((short)6));
-      
-      s.removeRowBreak(3);
-      
-      assertTrue("Row 3 still should be broken", clone.isRowBroken(3));
-   }
+       /**
+        * Ensures that pagebreak cloning works properly
+        */
+       public void testPageBreakClones() {
+               HSSFWorkbook b = new HSSFWorkbook();
+               HSSFSheet s = b.createSheet("Test");
+               s.setRowBreak(3);
+               s.setColumnBreak((short) 6);
+
+               HSSFSheet clone = b.cloneSheet(0);
+               assertTrue("Row 3 not broken", clone.isRowBroken(3));
+               assertTrue("Column 6 not broken", clone.isColumnBroken((short) 6));
+
+               s.removeRowBreak(3);
+
+               assertTrue("Row 3 still should be broken", clone.isRowBroken(3));
+       }
 }
index 5d0416fc7c9f90d566907f1fb2cbfa7b545d49f6..f4fa306cc212828993511bc082589e7233ff1769 100644 (file)
@@ -23,10 +23,9 @@ import junit.framework.TestCase;
 import org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator;
 import org.apache.poi.hssf.util.HSSFColor;
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.util.Region;
 
 /**
- * 
+ *
  * @author Dmitriy Kumshayev
  */
 public final class TestHSSFConditionalFormatting extends TestCase {
@@ -36,7 +35,7 @@ public final class TestHSSFConditionalFormatting extends TestCase {
                String formula = "7";
 
                HSSFSheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
-               
+
                HSSFConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule(formula);
                HSSFFontFormatting fontFmt = rule1.createFontFormatting();
                fontFmt.setFontStyle(true, false);
@@ -50,7 +49,7 @@ public final class TestHSSFConditionalFormatting extends TestCase {
                HSSFPatternFormatting patternFmt = rule1.createPatternFormatting();
                patternFmt.setFillBackgroundColor(HSSFColor.YELLOW.index);
 
-               
+
                HSSFConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule(ComparisonOperator.BETWEEN, "1", "2");
                HSSFConditionalFormattingRule [] cfRules =
                {
@@ -84,12 +83,12 @@ public final class TestHSSFConditionalFormatting extends TestCase {
                assertEquals(2, cf.getNumberOfRules());
 
                rule1 = cf.getRule(0);
-               assertEquals("7",rule1.getFormula1()); 
+               assertEquals("7",rule1.getFormula1());
                assertNull(rule1.getFormula2());
-               
+
                HSSFFontFormatting    r1fp = rule1.getFontFormatting();
                assertNotNull(r1fp);
-               
+
                assertTrue(r1fp.isItalic());
                assertFalse(r1fp.isBold());
 
@@ -102,13 +101,13 @@ public final class TestHSSFConditionalFormatting extends TestCase {
 
                HSSFPatternFormatting r1pf = rule1.getPatternFormatting();
                assertNotNull(r1pf);
-               assertEquals(HSSFColor.YELLOW.index,r1pf.getFillBackgroundColor());             
+               assertEquals(HSSFColor.YELLOW.index,r1pf.getFillBackgroundColor());
 
                rule2 = cf.getRule(1);
-               assertEquals("2",rule2.getFormula2()); 
-               assertEquals("1",rule2.getFormula1()); 
+               assertEquals("2",rule2.getFormula2());
+               assertEquals("1",rule2.getFormula1());
        }
-       
+
        public void testClone() {
 
                HSSFWorkbook wb = new HSSFWorkbook();
@@ -116,7 +115,7 @@ public final class TestHSSFConditionalFormatting extends TestCase {
                String formula = "7";
 
                HSSFSheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
-               
+
                HSSFConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule(formula);
                HSSFFontFormatting fontFmt = rule1.createFontFormatting();
                fontFmt.setFontStyle(true, false);
@@ -124,7 +123,7 @@ public final class TestHSSFConditionalFormatting extends TestCase {
                HSSFPatternFormatting patternFmt = rule1.createPatternFormatting();
                patternFmt.setFillBackgroundColor(HSSFColor.YELLOW.index);
 
-               
+
                HSSFConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule(ComparisonOperator.BETWEEN, "1", "2");
                HSSFConditionalFormattingRule [] cfRules =
                {
@@ -137,7 +136,7 @@ public final class TestHSSFConditionalFormatting extends TestCase {
                };
 
                sheetCF.addConditionalFormatting(regions, cfRules);
-                       
+
                try {
                        wb.cloneSheet(0);
                } catch (RuntimeException e) {
index a2b8cc50b38f6f2d23870cfc6b38734ad7715ea4..0f9c7ae0f1c4ca53c59c99cca25c1344a76407a9 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -442,7 +441,7 @@ public final class TestHSSFDateUtil extends TestCase {
      * Ensure that date values *with* a fractional portion get the right time of day
      */
     public void testConvertDateTime() {
-       // Excel day 30000 is date 18-Feb-1982 
+       // Excel day 30000 is date 18-Feb-1982
         // 0.7 corresponds to time 16:48:00
         Date actual = HSSFDateUtil.getJavaDate(30000.7);
         Date expected = createDate(1982, 1, 18, 16, 48, 0);
index f6ce14ca928b4c676ef5e03341af9c60095bdbef..83506544946a18882b5c288a5da8fdef649bc2da 100755 (executable)
 
 package org.apache.poi.hssf.usermodel;
 
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import junit.framework.AssertionFailedError;
 import org.apache.poi.hssf.HSSFITestDataProvider;
-import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.model.Sheet;
-import org.apache.poi.hssf.model.HSSFFormulaParser;
-import org.apache.poi.hssf.record.DBCellRecord;
-import org.apache.poi.hssf.record.FormulaRecord;
-import org.apache.poi.hssf.record.Record;
-import org.apache.poi.hssf.record.StringRecord;
-import org.apache.poi.hssf.record.formula.Ptg;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.util.AreaReference;
-import org.apache.poi.ss.util.CellReference;
-import org.apache.poi.ss.formula.FormulaType;
+import org.apache.poi.ss.usermodel.BaseTestFont;
+import org.apache.poi.ss.usermodel.Font;
 
 /**
  * Tests various functionality having to do with {@link org.apache.poi.ss.usermodel.Name}.
@@ -53,4 +36,4 @@ public final class TestHSSFFont extends BaseTestFont {
     public void testDefaultFont() {
         baseTestDefaultFont(HSSFFont.FONT_ARIAL, (short)200, Font.COLOR_NORMAL);
     }
-}
\ No newline at end of file
+}
index e54cd10ba435ae29af341a940e86c22683c37e72..fd41ed523125452ada6aad7f32acfe0d87630541 100644 (file)
 ==================================================================== */
 package org.apache.poi.hssf.usermodel;
 
-import org.apache.poi.hssf.model.Workbook;
-
 import junit.framework.TestCase;
 
-public class TestHSSFOptimiser extends TestCase {
-       public void testDoesNoHarmIfNothingToDo() throws Exception {
+public final class TestHSSFOptimiser extends TestCase {
+       public void testDoesNoHarmIfNothingToDo() {
                HSSFWorkbook wb = new HSSFWorkbook();
-               
+
                HSSFFont f = wb.createFont();
                f.setFontName("Testing");
                HSSFCellStyle s = wb.createCellStyle();
                s.setFont(f);
-               
+
                assertEquals(5, wb.getNumberOfFonts());
                assertEquals(22, wb.getNumCellStyles());
-               
+
                // Optimise fonts
                HSSFOptimiser.optimiseFonts(wb);
-               
+
                assertEquals(5, wb.getNumberOfFonts());
                assertEquals(22, wb.getNumCellStyles());
-               
+
                assertEquals(f, s.getFont(wb));
-               
+
                // Optimise styles
                HSSFOptimiser.optimiseCellStyles(wb);
-               
+
                assertEquals(5, wb.getNumberOfFonts());
                assertEquals(22, wb.getNumCellStyles());
-               
+
                assertEquals(f, s.getFont(wb));
        }
-       
-       public void testOptimiseFonts() throws Exception {
+
+       public void testOptimiseFonts() {
                HSSFWorkbook wb = new HSSFWorkbook();
-               
+
                // Add 6 fonts, some duplicates
                HSSFFont f1 = wb.createFont();
-               f1.setFontHeight((short)11);
+               f1.setFontHeight((short) 11);
                f1.setFontName("Testing");
-               
+
                HSSFFont f2 = wb.createFont();
-               f2.setFontHeight((short)22);
+               f2.setFontHeight((short) 22);
                f2.setFontName("Also Testing");
-               
+
                HSSFFont f3 = wb.createFont();
-               f3.setFontHeight((short)33);
+               f3.setFontHeight((short) 33);
                f3.setFontName("Unique");
-               
+
                HSSFFont f4 = wb.createFont();
-               f4.setFontHeight((short)11);
+               f4.setFontHeight((short) 11);
                f4.setFontName("Testing");
-               
+
                HSSFFont f5 = wb.createFont();
-               f5.setFontHeight((short)22);
+               f5.setFontHeight((short) 22);
                f5.setFontName("Also Testing");
-               
+
                HSSFFont f6 = wb.createFont();
-               f6.setFontHeight((short)66);
+               f6.setFontHeight((short) 66);
                f6.setFontName("Also Unique");
-               
-               
-               
+
                // Use all three of the four in cell styles
                assertEquals(21, wb.getNumCellStyles());
-               
+
                HSSFCellStyle cs1 = wb.createCellStyle();
                cs1.setFont(f1);
                assertEquals(5, cs1.getFontIndex());
-               
+
                HSSFCellStyle cs2 = wb.createCellStyle();
                cs2.setFont(f4);
                assertEquals(8, cs2.getFontIndex());
-               
+
                HSSFCellStyle cs3 = wb.createCellStyle();
                cs3.setFont(f5);
                assertEquals(9, cs3.getFontIndex());
-               
+
                HSSFCellStyle cs4 = wb.createCellStyle();
                cs4.setFont(f6);
                assertEquals(10, cs4.getFontIndex());
-               
+
                assertEquals(25, wb.getNumCellStyles());
-               
-               
+
                // And three in rich text
                HSSFSheet s = wb.createSheet();
                HSSFRow r = s.createRow(0);
-               
+
                HSSFRichTextString rtr1 = new HSSFRichTextString("Test");
                rtr1.applyFont(0, 2, f1);
                rtr1.applyFont(3, 4, f2);
                r.createCell(0).setCellValue(rtr1);
-               
+
                HSSFRichTextString rtr2 = new HSSFRichTextString("AlsoTest");
                rtr2.applyFont(0, 2, f3);
                rtr2.applyFont(3, 5, f5);
                rtr2.applyFont(6, 8, f6);
                r.createCell(1).setCellValue(rtr2);
-               
-               
+
                // Check what we have now
                assertEquals(10, wb.getNumberOfFonts());
                assertEquals(25, wb.getNumCellStyles());
-               
+
                // Optimise
                HSSFOptimiser.optimiseFonts(wb);
-               
+
                // Check font count
                assertEquals(8, wb.getNumberOfFonts());
                assertEquals(25, wb.getNumCellStyles());
-               
+
                // Check font use in cell styles
                assertEquals(5, cs1.getFontIndex());
                assertEquals(5, cs2.getFontIndex()); // duplicate of 1
                assertEquals(6, cs3.getFontIndex()); // duplicate of 2
                assertEquals(8, cs4.getFontIndex()); // two have gone
-               
-               
+
                // And in rich text
-               
-               // RTR 1 had f1 and f2, unchanged 
+
+               // RTR 1 had f1 and f2, unchanged
                assertEquals(5, r.getCell(0).getRichStringCellValue().getFontAtIndex(0));
                assertEquals(5, r.getCell(0).getRichStringCellValue().getFontAtIndex(1));
                assertEquals(6, r.getCell(0).getRichStringCellValue().getFontAtIndex(3));
                assertEquals(6, r.getCell(0).getRichStringCellValue().getFontAtIndex(4));
-               
+
                // RTR 2 had f3 (unchanged), f5 (=f2) and f6 (moved down)
                assertEquals(7, r.getCell(1).getRichStringCellValue().getFontAtIndex(0));
                assertEquals(7, r.getCell(1).getRichStringCellValue().getFontAtIndex(1));
@@ -151,54 +144,52 @@ public class TestHSSFOptimiser extends TestCase {
                assertEquals(8, r.getCell(1).getRichStringCellValue().getFontAtIndex(6));
                assertEquals(8, r.getCell(1).getRichStringCellValue().getFontAtIndex(7));
        }
-       
-       public void testOptimiseStyles() throws Exception {
+
+       public void testOptimiseStyles() {
                HSSFWorkbook wb = new HSSFWorkbook();
 
                // Two fonts
                assertEquals(4, wb.getNumberOfFonts());
-               
+
                HSSFFont f1 = wb.createFont();
-               f1.setFontHeight((short)11);
+               f1.setFontHeight((short) 11);
                f1.setFontName("Testing");
-               
+
                HSSFFont f2 = wb.createFont();
-               f2.setFontHeight((short)22);
+               f2.setFontHeight((short) 22);
                f2.setFontName("Also Testing");
 
                assertEquals(6, wb.getNumberOfFonts());
-       
-               
+
                // Several styles
                assertEquals(21, wb.getNumCellStyles());
-               
+
                HSSFCellStyle cs1 = wb.createCellStyle();
                cs1.setFont(f1);
-               
+
                HSSFCellStyle cs2 = wb.createCellStyle();
                cs2.setFont(f2);
-               
+
                HSSFCellStyle cs3 = wb.createCellStyle();
                cs3.setFont(f1);
-               
+
                HSSFCellStyle cs4 = wb.createCellStyle();
                cs4.setFont(f1);
-               cs4.setAlignment((short)22);
-               
+               cs4.setAlignment((short) 22);
+
                HSSFCellStyle cs5 = wb.createCellStyle();
                cs5.setFont(f2);
-               cs5.setAlignment((short)111);
-               
+               cs5.setAlignment((short) 111);
+
                HSSFCellStyle cs6 = wb.createCellStyle();
                cs6.setFont(f2);
-               
+
                assertEquals(27, wb.getNumCellStyles());
-               
-               
+
                // Use them
                HSSFSheet s = wb.createSheet();
                HSSFRow r = s.createRow(0);
-               
+
                r.createCell(0).setCellStyle(cs1);
                r.createCell(1).setCellStyle(cs2);
                r.createCell(2).setCellStyle(cs3);
@@ -207,20 +198,18 @@ public class TestHSSFOptimiser extends TestCase {
                r.createCell(5).setCellStyle(cs6);
                r.createCell(6).setCellStyle(cs1);
                r.createCell(7).setCellStyle(cs2);
-               
+
                assertEquals(21, r.getCell(0).getCellValueRecord().getXFIndex());
                assertEquals(26, r.getCell(5).getCellValueRecord().getXFIndex());
                assertEquals(21, r.getCell(6).getCellValueRecord().getXFIndex());
-               
-               
+
                // Optimise
                HSSFOptimiser.optimiseCellStyles(wb);
-               
-               
+
                // Check
                assertEquals(6, wb.getNumberOfFonts());
                assertEquals(25, wb.getNumCellStyles());
-               
+
                // cs1 -> 21
                assertEquals(21, r.getCell(0).getCellValueRecord().getXFIndex());
                // cs2 -> 22
index ab5cc95c150b55c8f2dd3a41fee34a286d3d9560..8f39857694bee887f750587d3c397aad7330ec47 100644 (file)
@@ -1,22 +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.hssf.usermodel;
+/* ====================================================================
+   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
 
-import junit.framework.TestCase;
+   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.HSSFTestDataSamples;
 import org.apache.poi.hssf.HSSFITestDataProvider;
index 3c5a0911c4e94c8bb56ba4cb6e0c244bf35b6e9c..31173bba2a525c93a8e22ef10d64bfdd742ca216 100644 (file)
@@ -18,9 +18,7 @@
 package org.apache.poi.hssf.usermodel;
 
 import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
 
-import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.record.BlankRecord;
 import org.apache.poi.hssf.record.RowRecord;
@@ -87,8 +85,8 @@ public final class TestHSSFRow extends BaseTestRow {
         assertEquals(-1, row.getLastCellNum());
         assertEquals(-1, row.getFirstCellNum());
         HSSFCell cellB2 = row.createCell(1);
-        HSSFCell cellB3 = row.createCell(2);
-        HSSFCell cellB4 = row.createCell(3);
+        row.createCell(2); // C2
+        row.createCell(3); // D2
 
         assertEquals(1, row.getFirstCellNum());
         assertEquals(4, row.getLastCellNum());
index 484ff70e18e208722dc2b9ba306d458f0c642681..ab7cca318683523cb7260917ba2195cf73b3ef44 100644 (file)
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.util.List;
 
 import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.HSSFITestDataProvider;
@@ -68,7 +67,7 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
             fail("WindowOneRecord in Workbook is probably not initialized");
         }
     }
-    
+
     /**
      * Tests for {@link HSSFWorkbook#isHidden()} etc
      */
index 98980fe19185442e9d857c6cbbcfd48738e2e415..feaf77b229b4c2b322a20360b54072ed876fa795 100644 (file)
@@ -19,8 +19,6 @@ package org.apache.poi.hssf.usermodel;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.InputStream;
 
 import junit.framework.TestCase;
index 786838122005a0f26a3a7bf736a744cd0b45c48f..15682a074b49991a235eff4a6fcceb0dec37befc 100644 (file)
@@ -32,7 +32,6 @@ import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.ss.util.Region;
 import org.apache.poi.util.TempFile;
 
 /**
@@ -428,7 +427,7 @@ public final class TestWorkbook extends TestCase {
         s.addMergedRegion(new CellRangeAddress(30, 40, 5, 15));
         sanityChecker.checkHSSFWorkbook(wb);
         wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
-        
+
         s  = wb.getSheetAt(0);
         CellRangeAddress r1 = s.getMergedRegion(0);
         CellRangeAddress r2 = s.getMergedRegion(1);
@@ -473,7 +472,7 @@ public final class TestWorkbook extends TestCase {
             }
         }
     }
-    
+
     /**
      * This tests is for bug [ #506658 ] Repeating output.
      *
index ecff6778a37e4cc0424610a7efc6b16048ff126c..2c30d1b12d47e7330f36209c6b55e98c2311accd 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -20,14 +19,13 @@ package org.apache.poi.poifs.filesystem;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.Iterator;
+import java.util.List;
 
 import junit.framework.ComparisonFailure;
 import junit.framework.TestCase;
@@ -62,7 +60,7 @@ public final class TestPropertySorter extends TestCase {
             throw new RuntimeException(e);
         }
     }
-    
+
     /**
      * Test sorting of properties in <code>DirectoryProperty</code>
      */
@@ -125,22 +123,22 @@ public final class TestPropertySorter extends TestCase {
         DirectoryNode vba = (DirectoryNode)vba_project.getEntry(VBA);
         DirectoryProperty  p = (DirectoryProperty)vba.getProperty();
 
-        ArrayList lst = new ArrayList();
-        for (Iterator it = p.getChildren(); it.hasNext();){
-            Property ch = (Property)it.next();
+        List<Property> lst = new ArrayList<Property>();
+        for (Iterator<Property> it = p.getChildren(); it.hasNext();){
+            Property ch = it.next();
             lst.add(ch);
         }
-        return (Property [])lst.toArray(new Property[ 0 ]);
+        return lst.toArray(new Property[ 0 ]);
     }
 
     /**
      * Old version of case-sensitive PropertyComparator to demonstrate the problem
      */
-    private static final Comparator OldCaseSensitivePropertyComparator = new Comparator() {
+    private static final Comparator<Property> OldCaseSensitivePropertyComparator = new Comparator<Property>() {
 
-        public int compare(Object o1, Object o2) {
-            String name1  = (( Property ) o1).getName();
-            String name2  = (( Property ) o2).getName();
+        public int compare(Property o1, Property o2) {
+            String name1  = o1.getName();
+            String name2  = o2.getName();
             int result = name1.length() - name2.length();
 
             if (result == 0) {
index 21049ebf1816bdc9c76475031a4bda4c886f457e..61bc943f58c540efd64e1e054b585cecc96b5d05 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.storage;
 
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.poi.poifs.common.POIFSConstants;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianConsts;
 
-import java.io.*;
-
-import java.util.*;
-
 /**
  * Class LocalRawDataBlockList
  *
  * @author Marc Johnson(mjohnson at apache dot org)
  */
-
-public class LocalRawDataBlockList
-    extends RawDataBlockList
-{
-    private List           _list;
+public final class LocalRawDataBlockList extends RawDataBlockList {
+    private List<RawDataBlock> _list;
     private RawDataBlock[] _array;
 
-    /**
-     * Constructor LocalRawDataBlockList
-     *
-     * @exception IOException
-     */
-
     public LocalRawDataBlockList()
         throws IOException
     {
         super(new ByteArrayInputStream(new byte[ 0 ]), POIFSConstants.BIG_BLOCK_SIZE);
-        _list  = new ArrayList();
+        _list  = new ArrayList<RawDataBlock>();
         _array = null;
     }
 
@@ -60,10 +49,7 @@ public class LocalRawDataBlockList
      * @param start index of first BAT block
      * @param end index of last BAT block
      * @param chain index of next XBAT block
-     *
-     * @exception IOException
      */
-
     public void createNewXBATBlock(final int start, final int end,
                                    final int chain)
         throws IOException
@@ -89,10 +75,7 @@ public class LocalRawDataBlockList
      * create a BAT block and add it to the list
      *
      * @param start_index initial index for the block list
-     *
-     * @exception IOException
      */
-
     public void createNewBATBlock(final int start_index)
         throws IOException
     {
@@ -124,10 +107,7 @@ public class LocalRawDataBlockList
      * fill the list with dummy blocks
      *
      * @param count of blocks
-     *
-     * @exception IOException
      */
-
     public void fill(final int count)
         throws IOException
     {
@@ -144,7 +124,6 @@ public class LocalRawDataBlockList
      *
      * @param block new block to add
      */
-
     public void add(RawDataBlock block)
     {
         _list.add(block);
@@ -156,10 +135,7 @@ public class LocalRawDataBlockList
      * @param index of block to be removed
      *
      * @return desired block
-     *
-     * @exception IOException
      */
-
     public ListManagedBlock remove(final int index)
         throws IOException
     {
@@ -189,7 +165,6 @@ public class LocalRawDataBlockList
      * @param index the index of the specified block; if the index is
      *              out of range, that's ok
      */
-
     public void zap(final int index)
     {
         ensureArrayExists();
@@ -203,7 +178,7 @@ public class LocalRawDataBlockList
     {
         if (_array == null)
         {
-            _array = ( RawDataBlock [] ) _list.toArray(new RawDataBlock[ 0 ]);
+            _array = _list.toArray(new RawDataBlock[ 0 ]);
         }
     }
 }
index 35715f65b15fd08435daa2e33f5780d4acb54d47..03f57c311232b17faedcc7b02a84a2435a1034e5 100644 (file)
@@ -34,9 +34,17 @@ import org.apache.poi.util.LittleEndianConsts;
  * @author Marc Johnson
  */
 public final class TestBlockListImpl extends TestCase {
+    private static final class BlockListTestImpl extends BlockListImpl {
+        public BlockListTestImpl() {
+            // no extra initialisation
+        }
+    }
+    private static BlockListImpl create() {
+        return new BlockListTestImpl();
+    }
 
     public void testZap() throws IOException {
-        BlockListImpl list = new BlockListImpl();
+        BlockListImpl list = create();
 
         // verify that you can zap anything
         for (int j = -2; j < 10; j++)
@@ -70,8 +78,9 @@ public final class TestBlockListImpl extends TestCase {
         }
     }
 
+
     public void testRemove() throws IOException {
-        BlockListImpl  list   = new BlockListImpl();
+        BlockListImpl  list   = create();
         RawDataBlock[] blocks = new RawDataBlock[ 5 ];
         byte[]         data   = new byte[ 512 * 5 ];
 
@@ -130,7 +139,7 @@ public final class TestBlockListImpl extends TestCase {
     }
 
     public void testSetBAT() throws IOException {
-        BlockListImpl list = new BlockListImpl();
+        BlockListImpl list = create();
 
         list.setBAT(null);
         list.setBAT(new BlockAllocationTableReader());
@@ -158,7 +167,7 @@ public final class TestBlockListImpl extends TestCase {
         // document, one that includes a reserved (BAT) block, one
         // that includes a reserved (XBAT) block, and one that
         // points off into space somewhere
-        BlockListImpl list       = new BlockListImpl();
+        BlockListImpl list       = create();
         List          raw_blocks = new ArrayList();
         byte[]        data       = new byte[ 512 ];
         int           offset     = 0;