]> source.dussan.org Git - poi.git/commitdiff
Changed CRLF to LF in scratchpad. Minor fixes for compiler warnings and formatting
authorJosh Micich <josh@apache.org>
Thu, 21 May 2009 18:12:22 +0000 (18:12 +0000)
committerJosh Micich <josh@apache.org>
Thu, 21 May 2009 18:12:22 +0000 (18:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@777204 13f79535-47bb-0310-9956-ffa450edef68

487 files changed:
src/scratchpad/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java
src/scratchpad/examples/src/org/apache/poi/hslf/examples/BulletsDemo.java
src/scratchpad/examples/src/org/apache/poi/hslf/examples/CreateHyperlink.java
src/scratchpad/examples/src/org/apache/poi/hslf/examples/DataExtraction.java
src/scratchpad/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java
src/scratchpad/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java
src/scratchpad/examples/src/org/apache/poi/hslf/examples/PPT2PNG.java
src/scratchpad/examples/src/org/apache/poi/hslf/examples/TableDemo.java
src/scratchpad/examples/src/org/apache/poi/hwpf/Word2Forrest.java
src/scratchpad/src/org/apache/poi/hdf/event/EventBridge.java
src/scratchpad/src/org/apache/poi/hdf/event/HDFLowLevelParsingListener.java
src/scratchpad/src/org/apache/poi/hdf/event/HDFParsingListener.java
src/scratchpad/src/org/apache/poi/hdf/extractor/CHP.java
src/scratchpad/src/org/apache/poi/hdf/extractor/FontTable.java
src/scratchpad/src/org/apache/poi/hdf/extractor/HeaderFooter.java
src/scratchpad/src/org/apache/poi/hdf/extractor/NewOleFile.java
src/scratchpad/src/org/apache/poi/hdf/extractor/PAP.java
src/scratchpad/src/org/apache/poi/hdf/extractor/PropertySet.java
src/scratchpad/src/org/apache/poi/hdf/extractor/SEP.java
src/scratchpad/src/org/apache/poi/hdf/extractor/StyleDescription.java
src/scratchpad/src/org/apache/poi/hdf/extractor/StyleSheet.java
src/scratchpad/src/org/apache/poi/hdf/extractor/TAP.java
src/scratchpad/src/org/apache/poi/hdf/extractor/TC.java
src/scratchpad/src/org/apache/poi/hdf/extractor/TableRow.java
src/scratchpad/src/org/apache/poi/hdf/extractor/TextPiece.java
src/scratchpad/src/org/apache/poi/hdf/extractor/Utils.java
src/scratchpad/src/org/apache/poi/hdf/extractor/WordDocument.java
src/scratchpad/src/org/apache/poi/hdf/extractor/data/DOP.java
src/scratchpad/src/org/apache/poi/hdf/extractor/data/LFO.java
src/scratchpad/src/org/apache/poi/hdf/extractor/data/LFOLVL.java
src/scratchpad/src/org/apache/poi/hdf/extractor/data/LST.java
src/scratchpad/src/org/apache/poi/hdf/extractor/data/LVL.java
src/scratchpad/src/org/apache/poi/hdf/extractor/data/ListTables.java
src/scratchpad/src/org/apache/poi/hdf/extractor/util/BTreeSet.java
src/scratchpad/src/org/apache/poi/hdf/extractor/util/ChpxNode.java
src/scratchpad/src/org/apache/poi/hdf/extractor/util/NumberFormatter.java
src/scratchpad/src/org/apache/poi/hdf/extractor/util/PapxNode.java
src/scratchpad/src/org/apache/poi/hdf/extractor/util/PropertyNode.java
src/scratchpad/src/org/apache/poi/hdf/extractor/util/SepxNode.java
src/scratchpad/src/org/apache/poi/hdf/model/HDFDocument.java
src/scratchpad/src/org/apache/poi/hdf/model/HDFObjectFactory.java
src/scratchpad/src/org/apache/poi/hdf/model/HDFObjectModel.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/CHPFormattedDiskPage.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/CharacterProperties.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ChpxNode.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/DocumentProperties.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FileInformationBlock.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FontTable.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/FormattedDiskPage.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/HDFType.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/HeaderFooter.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LFO.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LFOLVL.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LST.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/LVL.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ListTables.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PAPFormattedDiskPage.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PapxNode.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/ParagraphProperties.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PlexOfCps.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/PropertyNode.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/SectionProperties.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/SepxNode.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleDescription.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/StyleSheet.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TableCellDescriptor.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TableProperties.java
src/scratchpad/src/org/apache/poi/hdf/model/hdftypes/TextPiece.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/hdf/model/util/BTreeSet.java
src/scratchpad/src/org/apache/poi/hdf/model/util/NumberFormatter.java
src/scratchpad/src/org/apache/poi/hdf/model/util/ParsingState.java
src/scratchpad/src/org/apache/poi/hdgf/HDGFDiagram.java
src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java
src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java
src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeader.java
src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV11.java
src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV4V5.java
src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV6.java
src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkSeparator.java
src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkTrailer.java
src/scratchpad/src/org/apache/poi/hdgf/dev/VSDDumper.java
src/scratchpad/src/org/apache/poi/hdgf/exceptions/HDGFException.java
src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java
src/scratchpad/src/org/apache/poi/hdgf/pointers/Pointer.java
src/scratchpad/src/org/apache/poi/hdgf/pointers/PointerFactory.java
src/scratchpad/src/org/apache/poi/hdgf/pointers/PointerV6.java
src/scratchpad/src/org/apache/poi/hdgf/streams/ChunkStream.java
src/scratchpad/src/org/apache/poi/hdgf/streams/CompressedStreamStore.java
src/scratchpad/src/org/apache/poi/hdgf/streams/PointerContainingStream.java
src/scratchpad/src/org/apache/poi/hdgf/streams/Stream.java
src/scratchpad/src/org/apache/poi/hdgf/streams/StreamStore.java
src/scratchpad/src/org/apache/poi/hdgf/streams/StringsStream.java
src/scratchpad/src/org/apache/poi/hdgf/streams/TrailerStream.java
src/scratchpad/src/org/apache/poi/hdgf/streams/UnknownStream.java
src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java
src/scratchpad/src/org/apache/poi/hpbf/dev/HPBFDumper.java
src/scratchpad/src/org/apache/poi/hpbf/dev/PLCDumper.java
src/scratchpad/src/org/apache/poi/hpbf/extractor/PublisherTextExtractor.java
src/scratchpad/src/org/apache/poi/hpbf/model/EscherDelayStm.java
src/scratchpad/src/org/apache/poi/hpbf/model/EscherPart.java
src/scratchpad/src/org/apache/poi/hpbf/model/EscherStm.java
src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java
src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java
src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java
src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCBit.java
src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java
src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCTextBit.java
src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/UnknownQCBit.java
src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java
src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java
src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java
src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java
src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java
src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java
src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.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/PNG.java
src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java
src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java
src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java
src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java
src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java
src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.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/exceptions/CorruptPowerPointFileException.java
src/scratchpad/src/org/apache/poi/hslf/exceptions/EncryptedPowerPointFileException.java
src/scratchpad/src/org/apache/poi/hslf/exceptions/HSLFException.java
src/scratchpad/src/org/apache/poi/hslf/exceptions/InvalidRecordFormatException.java
src/scratchpad/src/org/apache/poi/hslf/extractor/ImageExtractor.java
src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java
src/scratchpad/src/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java
src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java
src/scratchpad/src/org/apache/poi/hslf/model/AutoShapes.java
src/scratchpad/src/org/apache/poi/hslf/model/Background.java
src/scratchpad/src/org/apache/poi/hslf/model/Comment.java
src/scratchpad/src/org/apache/poi/hslf/model/Fill.java
src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java
src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java
src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java
src/scratchpad/src/org/apache/poi/hslf/model/Line.java
src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java
src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java
src/scratchpad/src/org/apache/poi/hslf/model/Notes.java
src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java
src/scratchpad/src/org/apache/poi/hslf/model/PPFont.java
src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.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/Polygon.java
src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java
src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
src/scratchpad/src/org/apache/poi/hslf/model/ShapeOutline.java
src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java
src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java
src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java
src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java
src/scratchpad/src/org/apache/poi/hslf/model/Table.java
src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java
src/scratchpad/src/org/apache/poi/hslf/model/TextBox.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/TitleMaster.java
src/scratchpad/src/org/apache/poi/hslf/model/textproperties/ParagraphFlagsTextProp.java
src/scratchpad/src/org/apache/poi/hslf/record/AnimationInfo.java
src/scratchpad/src/org/apache/poi/hslf/record/AnimationInfoAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/CString.java
src/scratchpad/src/org/apache/poi/hslf/record/ColorSchemeAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/Comment2000.java
src/scratchpad/src/org/apache/poi/hslf/record/Comment2000Atom.java
src/scratchpad/src/org/apache/poi/hslf/record/Document.java
src/scratchpad/src/org/apache/poi/hslf/record/DocumentAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/DocumentEncryptionAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/DummyPositionSensitiveRecordWithChildren.java
src/scratchpad/src/org/apache/poi/hslf/record/DummyRecordWithChildren.java
src/scratchpad/src/org/apache/poi/hslf/record/Environment.java
src/scratchpad/src/org/apache/poi/hslf/record/EscherTextboxWrapper.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/ExControlAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/ExMCIMovie.java
src/scratchpad/src/org/apache/poi/hslf/record/ExMediaAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/ExVideoContainer.java
src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java
src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/HeadersFootersAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/HeadersFootersContainer.java
src/scratchpad/src/org/apache/poi/hslf/record/MainMaster.java
src/scratchpad/src/org/apache/poi/hslf/record/Notes.java
src/scratchpad/src/org/apache/poi/hslf/record/NotesAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/OEPlaceholderAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/OEShapeAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/OutlineTextRefAtom.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/ParentAwareRecord.java
src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
src/scratchpad/src/org/apache/poi/hslf/record/PersistRecord.java
src/scratchpad/src/org/apache/poi/hslf/record/PositionDependentRecord.java
src/scratchpad/src/org/apache/poi/hslf/record/PositionDependentRecordAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/PositionDependentRecordContainer.java
src/scratchpad/src/org/apache/poi/hslf/record/Record.java
src/scratchpad/src/org/apache/poi/hslf/record/RecordAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java
src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
src/scratchpad/src/org/apache/poi/hslf/record/RoundTripHFPlaceholder12.java
src/scratchpad/src/org/apache/poi/hslf/record/SheetContainer.java
src/scratchpad/src/org/apache/poi/hslf/record/Slide.java
src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java
src/scratchpad/src/org/apache/poi/hslf/record/SlidePersistAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/Sound.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/StyleTextPropAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java
src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java
src/scratchpad/src/org/apache/poi/hslf/util/MutableByteArrayOutputStream.java
src/scratchpad/src/org/apache/poi/hslf/util/SystemTimeUtils.java
src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunk.java
src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java
src/scratchpad/src/org/apache/poi/hsmf/datatypes/Types.java
src/scratchpad/src/org/apache/poi/hsmf/exceptions/ChunkNotFoundException.java
src/scratchpad/src/org/apache/poi/hsmf/exceptions/DirectoryChunkNotFoundException.java
src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFChart.java
src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
src/scratchpad/src/org/apache/poi/hwpf/QuickTest.java
src/scratchpad/src/org/apache/poi/hwpf/dev/HWPFLister.java
src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java
src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java
src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java
src/scratchpad/src/org/apache/poi/hwpf/model/CPSplitCalculator.java
src/scratchpad/src/org/apache/poi/hwpf/model/CachedPropertyNode.java
src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/DocumentProperties.java
src/scratchpad/src/org/apache/poi/hwpf/model/EscherRecordHolder.java
src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java
src/scratchpad/src/org/apache/poi/hwpf/model/FIBLongHandler.java
src/scratchpad/src/org/apache/poi/hwpf/model/FIBShortHandler.java
src/scratchpad/src/org/apache/poi/hwpf/model/FSPA.java
src/scratchpad/src/org/apache/poi/hwpf/model/FSPATable.java
src/scratchpad/src/org/apache/poi/hwpf/model/Ffn.java
src/scratchpad/src/org/apache/poi/hwpf/model/FieldDescriptor.java
src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java
src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/FormattedDiskPage.java
src/scratchpad/src/org/apache/poi/hwpf/model/GenericPropertyNode.java
src/scratchpad/src/org/apache/poi/hwpf/model/HDFType.java
src/scratchpad/src/org/apache/poi/hwpf/model/ListData.java
src/scratchpad/src/org/apache/poi/hwpf/model/ListFormatOverride.java
src/scratchpad/src/org/apache/poi/hwpf/model/ListFormatOverrideLevel.java
src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java
src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java
src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java
src/scratchpad/src/org/apache/poi/hwpf/model/ParagraphHeight.java
src/scratchpad/src/org/apache/poi/hwpf/model/PicturesTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/PieceDescriptor.java
src/scratchpad/src/org/apache/poi/hwpf/model/PlexOfCps.java
src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java
src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java
src/scratchpad/src/org/apache/poi/hwpf/model/SavedByEntry.java
src/scratchpad/src/org/apache/poi/hwpf/model/SavedByTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/SectionDescriptor.java
src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/ShapesTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/StyleDescription.java
src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java
src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java
src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/UPX.java
src/scratchpad/src/org/apache/poi/hwpf/model/UnhandledDataStructure.java
src/scratchpad/src/org/apache/poi/hwpf/model/io/HWPFFileSystem.java
src/scratchpad/src/org/apache/poi/hwpf/model/io/HWPFOutputStream.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/SectionSprmUncompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmIterator.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmUncompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmUtils.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmUncompressor.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/BorderCode.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterProperties.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/DateAndTime.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/DocumentPosition.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/DropCapSpecifier.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/HWPFList.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/HeaderStories.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/LineSpacingDescriptor.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/ListEntry.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/Paragraph.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/ParagraphProperties.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/Section.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/SectionProperties.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/ShadingDescriptor.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/Shape.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableCell.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableCellDescriptor.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableIterator.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableProperties.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java
src/scratchpad/src/org/apache/poi/sl/usermodel/AutoShape.java
src/scratchpad/src/org/apache/poi/sl/usermodel/Background.java
src/scratchpad/src/org/apache/poi/sl/usermodel/Fill.java
src/scratchpad/src/org/apache/poi/sl/usermodel/FontCollection.java
src/scratchpad/src/org/apache/poi/sl/usermodel/Hyperlink.java
src/scratchpad/src/org/apache/poi/sl/usermodel/Line.java
src/scratchpad/src/org/apache/poi/sl/usermodel/LineStyle.java
src/scratchpad/src/org/apache/poi/sl/usermodel/MasterSheet.java
src/scratchpad/src/org/apache/poi/sl/usermodel/Notes.java
src/scratchpad/src/org/apache/poi/sl/usermodel/Picture.java
src/scratchpad/src/org/apache/poi/sl/usermodel/PictureData.java
src/scratchpad/src/org/apache/poi/sl/usermodel/Resources.java
src/scratchpad/src/org/apache/poi/sl/usermodel/Shape.java
src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeContainer.java
src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java
src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeTypes.java
src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java
src/scratchpad/src/org/apache/poi/sl/usermodel/SimpleShape.java
src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java
src/scratchpad/src/org/apache/poi/sl/usermodel/SlideShow.java
src/scratchpad/src/org/apache/poi/sl/usermodel/TextBox.java
src/scratchpad/src/org/apache/poi/sl/usermodel/TextRun.java
src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java
src/scratchpad/testcases/org/apache/poi/hdf/model/TestHDFDocument.java
src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java
src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFLZW.java
src/scratchpad/testcases/org/apache/poi/hdgf/chunks/TestChunks.java
src/scratchpad/testcases/org/apache/poi/hdgf/extractor/TestVisioExtractor.java
src/scratchpad/testcases/org/apache/poi/hdgf/pointers/TestPointerFactory.java
src/scratchpad/testcases/org/apache/poi/hdgf/streams/StreamTest.java
src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBasics.java
src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java
src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java
src/scratchpad/testcases/org/apache/poi/hpbf/TestHPBFDocument.java
src/scratchpad/testcases/org/apache/poi/hpbf/extractor/TextPublisherTextExtractor.java
src/scratchpad/testcases/org/apache/poi/hpbf/model/TestEscherParts.java
src/scratchpad/testcases/org/apache/poi/hpbf/model/TestQuillContents.java
src/scratchpad/testcases/org/apache/poi/hslf/TestEncryptedFile.java
src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java
src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java
src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java
src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.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/TestOleEmbedding.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.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/TestSlides.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRun.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestAnimationInfoAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestCString.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000Atom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjStg.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestFontCollection.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordTypes.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.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/TestTextBytesAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextCharsAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextHeaderAtom.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/record/TestUserEditAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java
src/scratchpad/testcases/org/apache/poi/hslf/util/TestSystemTimeUtils.java
src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java
src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java
src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java
src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java
src/scratchpad/testcases/org/apache/poi/hwpf/AllTests.java
src/scratchpad/testcases/org/apache/poi/hwpf/HWPFDocFixture.java
src/scratchpad/testcases/org/apache/poi/hwpf/HWPFTestCase.java
src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFPictures.java
src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java
src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestDifferentRoutes.java
src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestDocumentProperties.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFileInformationBlock.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestListTables.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPlexOfCps.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSavedByTable.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestTextPieceTable.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHeaderStories.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRange.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeDelete.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeInsertion.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeProperties.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeReplacement.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestShapes.java

index 962349876a0736f1a7a6676fef4774c6b2441964..91621339b46ac7ea0bae78641048cef1d9c29068 100755 (executable)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.examples;\r
-\r
-import org.apache.poi.hslf.usermodel.*;\r
-import org.apache.poi.hslf.model.*;\r
-import org.apache.poi.hslf.record.TextHeaderAtom;\r
-\r
-import java.io.IOException;\r
-import java.io.FileOutputStream;\r
-import java.io.File;\r
-import java.awt.*;\r
-\r
-/**\r
- * Presentation for Fast Feather Track on ApacheconEU 2008\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class ApacheconEU08 {\r
-\r
-    public static void main(String[] args) throws IOException {\r
-        SlideShow ppt = new SlideShow();\r
-        ppt.setPageSize(new Dimension(720, 540));\r
-\r
-        slide1(ppt);\r
-        slide2(ppt);\r
-        slide3(ppt);\r
-        slide4(ppt);\r
-        slide5(ppt);\r
-        slide6(ppt);\r
-        slide7(ppt);\r
-        slide8(ppt);\r
-        slide9(ppt);\r
-        slide10(ppt);\r
-        slide11(ppt);\r
-        slide12(ppt);\r
-\r
-        FileOutputStream out = new FileOutputStream("apachecon_eu_08.ppt");\r
-        ppt.write(out);\r
-        out.close();\r
-\r
-    }\r
-\r
-    public static void slide1(SlideShow ppt) throws IOException {\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox box1 = new TextBox();\r
-        TextRun tr1 = box1.getTextRun();\r
-        tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);\r
-        tr1.setText("POI-HSLF");\r
-        box1.setAnchor(new Rectangle(54, 78, 612, 115));\r
-        slide.addShape(box1);\r
-\r
-        TextBox box2 = new TextBox();\r
-        TextRun tr2 = box2.getTextRun();\r
-        tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);\r
-        tr2.setText("Java API To Access Microsoft PowerPoint Format Files");\r
-        box2.setAnchor(new Rectangle(108, 204, 504, 138));\r
-        slide.addShape(box2);\r
-\r
-        TextBox box3 = new TextBox();\r
-        TextRun tr3 = box3.getTextRun();\r
-        tr3.getRichTextRuns()[0].setFontSize(32);\r
-        box3.setHorizontalAlignment(TextBox.AlignCenter);\r
-        tr3.setText(\r
-                "Yegor Kozlov\r" +\r
-                "yegor - apache - org");\r
-        box3.setAnchor(new Rectangle(206, 348, 310, 84));\r
-        slide.addShape(box3);\r
-    }\r
-\r
-    public static void slide2(SlideShow ppt) throws IOException {\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox box1 = new TextBox();\r
-        TextRun tr1 = box1.getTextRun();\r
-        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);\r
-        tr1.setText("What is HSLF?");\r
-        box1.setAnchor(new Rectangle(36, 21, 648, 90));\r
-        slide.addShape(box1);\r
-\r
-        TextBox box2 = new TextBox();\r
-        TextRun tr2 = box2.getTextRun();\r
-        tr2.setRunType(TextHeaderAtom.BODY_TYPE);\r
-        tr2.setText("HorribleSLideshowFormat is the POI Project's pure Java implementation " +\r
-                "of the Powerpoint binary file format. \r" +\r
-                "POI sub-project since 2005\r" +\r
-                "Started by Nick Birch, Yegor Kozlov joined soon after");\r
-        box2.setAnchor(new Rectangle(36, 126, 648, 356));\r
-        slide.addShape(box2);\r
-\r
-\r
-    }\r
-\r
-    public static void slide3(SlideShow ppt) throws IOException {\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox box1 = new TextBox();\r
-        TextRun tr1 = box1.getTextRun();\r
-        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);\r
-        tr1.setText("HSLF in a Nutshell");\r
-        box1.setAnchor(new Rectangle(36, 15, 648, 65));\r
-        slide.addShape(box1);\r
-\r
-        TextBox box2 = new TextBox();\r
-        TextRun tr2 = box2.getTextRun();\r
-        tr2.setRunType(TextHeaderAtom.BODY_TYPE);\r
-        tr2.setText(\r
-                "HSLF provides a way to read, create and modify MS PowerPoint presentations\r" +\r
-                "Pure Java API - you don't need PowerPoint to read and write *.ppt files\r" +\r
-                "Comprehensive support of PowerPoint objects");\r
-        tr2.getRichTextRuns()[0].setFontSize(28);\r
-        box2.setAnchor(new Rectangle(36, 80, 648, 200));\r
-        slide.addShape(box2);\r
-\r
-        TextBox box3 = new TextBox();\r
-        TextRun tr3 = box3.getTextRun();\r
-        tr3.setRunType(TextHeaderAtom.BODY_TYPE);\r
-        tr3.setText(\r
-                "Rich text\r" +\r
-                "Tables\r" +\r
-                "Shapes\r" +\r
-                "Pictures\r" +\r
-                "Master slides");\r
-        tr3.getRichTextRuns()[0].setFontSize(24);\r
-        tr3.getRichTextRuns()[0].setIndentLevel(1);\r
-        box3.setAnchor(new Rectangle(36, 265, 648, 150));\r
-        slide.addShape(box3);\r
-\r
-        TextBox box4 = new TextBox();\r
-        TextRun tr4 = box4.getTextRun();\r
-        tr4.setRunType(TextHeaderAtom.BODY_TYPE);\r
-        tr4.setText("Access to low level data structures");\r
-        box4.setAnchor(new Rectangle(36, 430, 648, 50));\r
-        slide.addShape(box4);\r
-    }\r
-\r
-    public static void slide4(SlideShow ppt) throws IOException {\r
-        Slide slide = ppt.createSlide();\r
-\r
-        String[][] txt1 = {\r
-            {"Note"},\r
-            {"This presentation was created programmatically using POI HSLF"}\r
-        };\r
-        Table table1 = new Table(2, 1);\r
-        for (int i = 0; i < txt1.length; i++) {\r
-            for (int j = 0; j < txt1[i].length; j++) {\r
-                TableCell cell = table1.getCell(i, j);\r
-                cell.setText(txt1[i][j]);\r
-                cell.getTextRun().getRichTextRuns()[0].setFontSize(10);\r
-                RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];\r
-                rt.setFontName("Arial");\r
-                rt.setBold(true);\r
-                if(i == 0){\r
-                    rt.setFontSize(32);\r
-                    rt.setFontColor(Color.white);\r
-                    cell.getFill().setForegroundColor(new Color(0, 153, 204));\r
-                } else {\r
-                    rt.setFontSize(28);\r
-                    cell.getFill().setForegroundColor(new Color(235, 239, 241));\r
-                }\r
-                cell.setVerticalAlignment(TextBox.AnchorMiddle);\r
-            }\r
-        }\r
-\r
-        Line border1 = table1.createBorder();\r
-        border1.setLineColor(Color.black);\r
-        border1.setLineWidth(1.0);\r
-        table1.setAllBorders(border1);\r
-\r
-        Line border2 = table1.createBorder();\r
-        border2.setLineColor(Color.black);\r
-        border2.setLineWidth(2.0);\r
-        table1.setOutsideBorders(border2);\r
-\r
-        table1.setColumnWidth(0, 510);\r
-        table1.setRowHeight(0, 60);\r
-        table1.setRowHeight(1, 100);\r
-        slide.addShape(table1);\r
-\r
-        table1.moveTo(100, 100);\r
-\r
-        TextBox box1 = new TextBox();\r
-        box1.setHorizontalAlignment(TextBox.AlignCenter);\r
-        TextRun tr1 = box1.getTextRun();\r
-        tr1.setText("The source code is available at\r" +\r
-                "http://people.apache.org/~yegor/apachecon_eu08/");\r
-        RichTextRun rt = tr1.getRichTextRuns()[0];\r
-        rt.setFontSize(24);\r
-        box1.setAnchor(new Rectangle(80, 356, 553, 65));\r
-        slide.addShape(box1);\r
-\r
-    }\r
-\r
-    public static void slide5(SlideShow ppt) throws IOException {\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox box1 = new TextBox();\r
-        TextRun tr1 = box1.getTextRun();\r
-        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);\r
-        tr1.setText("HSLF in Action - 1\rData Extraction");\r
-        box1.setAnchor(new Rectangle(36, 21, 648, 100));\r
-        slide.addShape(box1);\r
-\r
-        TextBox box2 = new TextBox();\r
-        TextRun tr2 = box2.getTextRun();\r
-        tr2.setRunType(TextHeaderAtom.BODY_TYPE);\r
-        tr2.setText(\r
-                "Text from slides and notes\r" +\r
-                "Images\r" +\r
-                "Shapes and their properties (type, position in the slide, color, font, etc.)");\r
-        box2.setAnchor(new Rectangle(36, 150, 648, 300));\r
-        slide.addShape(box2);\r
-\r
-\r
-    }\r
-\r
-    public static void slide6(SlideShow ppt) throws IOException {\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox box1 = new TextBox();\r
-        TextRun tr1 = box1.getTextRun();\r
-        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);\r
-        tr1.setText("HSLF in Action - 2");\r
-        box1.setAnchor(new Rectangle(36, 20, 648, 90));\r
-        slide.addShape(box1);\r
-\r
-        TextBox box2 = new TextBox();\r
-        TextRun tr2 = box2.getTextRun();\r
-        tr2.getRichTextRuns()[0].setFontSize(18);\r
-        tr2.setText("Creating a simple presentation from scratch");\r
-        box2.setAnchor(new Rectangle(170, 100, 364, 30));\r
-        slide.addShape(box2);\r
-\r
-        TextBox box3 = new TextBox();\r
-        TextRun tr3 = box3.getTextRun();\r
-        RichTextRun rt3 = tr3.getRichTextRuns()[0];\r
-        rt3.setFontName("Courier New");\r
-        rt3.setFontSize(8);\r
-        tr3.setText(\r
-                "        SlideShow ppt = new SlideShow();\r" +\r
-                "        Slide slide = ppt.createSlide();\r" +\r
-                "\r" +\r
-                "        TextBox box2 = new TextBox();\r" +\r
-                "        box2.setHorizontalAlignment(TextBox.AlignCenter);\r" +\r
-                "        box2.setVerticalAlignment(TextBox.AnchorMiddle);\r" +\r
-                "        box2.getTextRun().setText(\"Java Code\");\r" +\r
-                "        box2.getFill().setForegroundColor(new Color(187, 224, 227));\r" +\r
-                "        box2.setLineColor(Color.black);\r" +\r
-                "        box2.setLineWidth(0.75);\r" +\r
-                "        box2.setAnchor(new Rectangle(66, 243, 170, 170));\r" +\r
-                "        slide.addShape(box2);\r" +\r
-                "\r" +\r
-                "        TextBox box3 = new TextBox();\r" +\r
-                "        box3.setHorizontalAlignment(TextBox.AlignCenter);\r" +\r
-                "        box3.setVerticalAlignment(TextBox.AnchorMiddle);\r" +\r
-                "        box3.getTextRun().setText(\"*.ppt file\");\r" +\r
-                "        box3.setLineWidth(0.75);\r" +\r
-                "        box3.setLineColor(Color.black);\r" +\r
-                "        box3.getFill().setForegroundColor(new Color(187, 224, 227));\r" +\r
-                "        box3.setAnchor(new Rectangle(473, 243, 170, 170));\r" +\r
-                "        slide.addShape(box3);\r" +\r
-                "\r" +\r
-                "        AutoShape box4 = new AutoShape(ShapeTypes.Arrow);\r" +\r
-                "        box4.getFill().setForegroundColor(new Color(187, 224, 227));\r" +\r
-                "        box4.setLineWidth(0.75);\r" +\r
-                "        box4.setLineColor(Color.black);\r" +\r
-                "        box4.setAnchor(new Rectangle(253, 288, 198, 85));\r" +\r
-                "        slide.addShape(box4);\r" +\r
-                "\r" +\r
-                "        FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\r" +\r
-                "        ppt.write(out);\r" +\r
-                "        out.close();");\r
-        box3.setAnchor(new Rectangle(30, 150, 618, 411));\r
-        slide.addShape(box3);\r
-    }\r
-\r
-    public static void slide7(SlideShow ppt) throws IOException {\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox box2 = new TextBox();\r
-        box2.setHorizontalAlignment(TextBox.AlignCenter);\r
-        box2.setVerticalAlignment(TextBox.AnchorMiddle);\r
-        box2.getTextRun().setText("Java Code");\r
-        box2.getFill().setForegroundColor(new Color(187, 224, 227));\r
-        box2.setLineColor(Color.black);\r
-        box2.setLineWidth(0.75);\r
-        box2.setAnchor(new Rectangle(66, 243, 170, 170));\r
-        slide.addShape(box2);\r
-\r
-        TextBox box3 = new TextBox();\r
-        box3.setHorizontalAlignment(TextBox.AlignCenter);\r
-        box3.setVerticalAlignment(TextBox.AnchorMiddle);\r
-        box3.getTextRun().setText("*.ppt file");\r
-        box3.setLineWidth(0.75);\r
-        box3.setLineColor(Color.black);\r
-        box3.getFill().setForegroundColor(new Color(187, 224, 227));\r
-        box3.setAnchor(new Rectangle(473, 243, 170, 170));\r
-        slide.addShape(box3);\r
-\r
-        AutoShape box4 = new AutoShape(ShapeTypes.Arrow);\r
-        box4.getFill().setForegroundColor(new Color(187, 224, 227));\r
-        box4.setLineWidth(0.75);\r
-        box4.setLineColor(Color.black);\r
-        box4.setAnchor(new Rectangle(253, 288, 198, 85));\r
-        slide.addShape(box4);\r
-    }\r
-\r
-    public static void slide8(SlideShow ppt) throws IOException {\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox box1 = new TextBox();\r
-        TextRun tr1 = box1.getTextRun();\r
-        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);\r
-        tr1.setText("Wait, there is more!");\r
-        box1.setAnchor(new Rectangle(36, 21, 648, 90));\r
-        slide.addShape(box1);\r
-\r
-        TextBox box2 = new TextBox();\r
-        TextRun tr2 = box2.getTextRun();\r
-        tr2.setRunType(TextHeaderAtom.BODY_TYPE);\r
-        tr2.setText(\r
-                "Rich text\r" +\r
-                "Tables\r" +\r
-                "Pictures (JPEG, PNG, BMP, WMF, PICT)\r" +\r
-                "Comprehensive formatting features");\r
-        box2.setAnchor(new Rectangle(36, 126, 648, 356));\r
-        slide.addShape(box2);\r
-    }\r
-\r
-    public static void slide9(SlideShow ppt) throws IOException {\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox box1 = new TextBox();\r
-        TextRun tr1 = box1.getTextRun();\r
-        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);\r
-        tr1.setText("HSLF in Action - 3");\r
-        box1.setAnchor(new Rectangle(36, 20, 648, 50));\r
-        slide.addShape(box1);\r
-\r
-        TextBox box2 = new TextBox();\r
-        TextRun tr2 = box2.getTextRun();\r
-        tr2.getRichTextRuns()[0].setFontSize(18);\r
-        tr2.setText("PPGraphics2D: PowerPoint Graphics2D driver");\r
-        box2.setAnchor(new Rectangle(178, 70, 387, 30));\r
-        slide.addShape(box2);\r
-\r
-        TextBox box3 = new TextBox();\r
-        TextRun tr3 = box3.getTextRun();\r
-        RichTextRun rt3 = tr3.getRichTextRuns()[0];\r
-        rt3.setFontName("Courier New");\r
-        rt3.setFontSize(8);\r
-        tr3.setText(\r
-                "        //bar chart data. The first value is the bar color, the second is the width\r" +\r
-                "        Object[] def = new Object[]{\r" +\r
-                "            Color.yellow, new Integer(100),\r" +\r
-                "            Color.green, new Integer(150),\r" +\r
-                "            Color.gray, new Integer(75),\r" +\r
-                "            Color.red, new Integer(200),\r" +\r
-                "        };\r" +\r
-                "\r" +\r
-                "        SlideShow ppt = new SlideShow();\r" +\r
-                "        Slide slide = ppt.createSlide();\r" +\r
-                "\r" +\r
-                "        ShapeGroup group = new ShapeGroup();\r" +\r
-                "        //define position of the drawing in the slide\r" +\r
-                "        Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);\r" +\r
-                "        group.setAnchor(bounds);\r" +\r
-                "        slide.addShape(group);\r" +\r
-                "        Graphics2D graphics = new PPGraphics2D(group);\r" +\r
-                "\r" +\r
-                "        //draw a simple bar graph\r" +\r
-                "        int x = bounds.x + 50, y = bounds.y + 50;\r" +\r
-                "        graphics.setFont(new Font(\"Arial\", Font.BOLD, 10));\r" +\r
-                "        for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {\r" +\r
-                "            graphics.setColor(Color.black);\r" +\r
-                "            int width = ((Integer)def[i+1]).intValue();\r" +\r
-                "            graphics.drawString(\"Q\" + idx, x-20, y+20);\r" +\r
-                "            graphics.drawString(width + \"%\", x + width + 10, y + 20);\r" +\r
-                "            graphics.setColor((Color)def[i]);\r" +\r
-                "            graphics.fill(new Rectangle(x, y, width, 30));\r" +\r
-                "            y += 40;\r" +\r
-                "        }\r" +\r
-                "        graphics.setColor(Color.black);\r" +\r
-                "        graphics.setFont(new Font(\"Arial\", Font.BOLD, 14));\r" +\r
-                "        graphics.draw(bounds);\r" +\r
-                "        graphics.drawString(\"Performance\", x + 70, y + 40);\r" +\r
-                "\r" +\r
-                "        FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\r" +\r
-                "        ppt.write(out);\r" +\r
-                "        out.close();");\r
-        box3.setAnchor(new Rectangle(96, 110, 499, 378));\r
-        slide.addShape(box3);\r
-    }\r
-\r
-    public static void slide10(SlideShow ppt) throws IOException {\r
-        //bar chart data. The first value is the bar color, the second is the width\r
-        Object[] def = new Object[]{\r
-            Color.yellow, new Integer(100),\r
-            Color.green, new Integer(150),\r
-            Color.gray, new Integer(75),\r
-            Color.red, new Integer(200),\r
-        };\r
-\r
-        Slide slide = ppt.createSlide();\r
-\r
-        ShapeGroup group = new ShapeGroup();\r
-        //define position of the drawing in the slide\r
-        Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);\r
-        group.setAnchor(bounds);\r
-        slide.addShape(group);\r
-        Graphics2D graphics = new PPGraphics2D(group);\r
-\r
-        //draw a simple bar graph\r
-        int x = bounds.x + 50, y = bounds.y + 50;\r
-        graphics.setFont(new Font("Arial", Font.BOLD, 10));\r
-        for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {\r
-            graphics.setColor(Color.black);\r
-            int width = ((Integer)def[i+1]).intValue();\r
-            graphics.drawString("Q" + idx, x-20, y+20);\r
-            graphics.drawString(width + "%", x + width + 10, y + 20);\r
-            graphics.setColor((Color)def[i]);\r
-            graphics.fill(new Rectangle(x, y, width, 30));\r
-            y += 40;\r
-        }\r
-        graphics.setColor(Color.black);\r
-        graphics.setFont(new Font("Arial", Font.BOLD, 14));\r
-        graphics.draw(bounds);\r
-        graphics.drawString("Performance", x + 70, y + 40);\r
-\r
-    }\r
-\r
-    public static void slide11(SlideShow ppt) throws IOException {\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox box1 = new TextBox();\r
-        TextRun tr1 = box1.getTextRun();\r
-        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);\r
-        tr1.setText("HSLF Development Plans");\r
-        box1.setAnchor(new Rectangle(36, 21, 648, 90));\r
-        slide.addShape(box1);\r
-\r
-        TextBox box2 = new TextBox();\r
-        TextRun tr2 = box2.getTextRun();\r
-        tr2.setRunType(TextHeaderAtom.BODY_TYPE);\r
-        tr2.getRichTextRuns()[0].setFontSize(32);\r
-        tr2.setText(\r
-                "Support for more PowerPoint functionality\r" +\r
-                "Rendering slides into java.awt.Graphics2D");\r
-        box2.setAnchor(new Rectangle(36, 126, 648, 100));\r
-        slide.addShape(box2);\r
-\r
-        TextBox box3 = new TextBox();\r
-        TextRun tr3 = box3.getTextRun();\r
-        tr3.setRunType(TextHeaderAtom.BODY_TYPE);\r
-        tr3.getRichTextRuns()[0].setIndentLevel(1);\r
-        tr3.setText(\r
-                "A way to export slides into images or other formats");\r
-        box3.setAnchor(new Rectangle(36, 220, 648, 70));\r
-        slide.addShape(box3);\r
-\r
-        TextBox box4 = new TextBox();\r
-        TextRun tr4 = box4.getTextRun();\r
-        tr4.setRunType(TextHeaderAtom.BODY_TYPE);\r
-        tr4.getRichTextRuns()[0].setFontSize(32);\r
-        tr4.setText(\r
-                "Integration with Apache FOP - Formatting Objects Processor");\r
-        box4.setAnchor(new Rectangle(36, 290, 648, 90));\r
-        slide.addShape(box4);\r
-\r
-        TextBox box5 = new TextBox();\r
-        TextRun tr5 = box5.getTextRun();\r
-        tr5.setRunType(TextHeaderAtom.BODY_TYPE);\r
-        tr5.getRichTextRuns()[0].setIndentLevel(1);\r
-        tr5.setText(\r
-                "Transformation of XSL-FO into PPT\r" +\r
-                "PPT2PDF transcoder");\r
-        box5.setAnchor(new Rectangle(36, 380, 648, 100));\r
-        slide.addShape(box5);\r
-    }\r
-\r
-    public static void slide12(SlideShow ppt) throws IOException {\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox box1 = new TextBox();\r
-        TextRun tr1 = box1.getTextRun();\r
-        tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);\r
-        tr1.setText("Questions?");\r
-        box1.setAnchor(new Rectangle(54, 167, 612, 115));\r
-        slide.addShape(box1);\r
-\r
-        TextBox box2 = new TextBox();\r
-        TextRun tr2 = box2.getTextRun();\r
-        tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);\r
-        tr2.setText(\r
-                "http://poi.apache.org/hslf/\r" +\r
-                "http://people.apache.org/~yegor");\r
-        box2.setAnchor(new Rectangle(108, 306, 504, 138));\r
-        slide.addShape(box2);\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.hslf.model.*;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.io.File;
+import java.awt.*;
+
+/**
+ * Presentation for Fast Feather Track on ApacheconEU 2008
+ *
+ * @author Yegor Kozlov
+ */
+public final class ApacheconEU08 {
+
+    public static void main(String[] args) throws IOException {
+        SlideShow ppt = new SlideShow();
+        ppt.setPageSize(new Dimension(720, 540));
+
+        slide1(ppt);
+        slide2(ppt);
+        slide3(ppt);
+        slide4(ppt);
+        slide5(ppt);
+        slide6(ppt);
+        slide7(ppt);
+        slide8(ppt);
+        slide9(ppt);
+        slide10(ppt);
+        slide11(ppt);
+        slide12(ppt);
+
+        FileOutputStream out = new FileOutputStream("apachecon_eu_08.ppt");
+        ppt.write(out);
+        out.close();
+
+    }
+
+    public static void slide1(SlideShow ppt) throws IOException {
+        Slide slide = ppt.createSlide();
+
+        TextBox box1 = new TextBox();
+        TextRun tr1 = box1.getTextRun();
+        tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);
+        tr1.setText("POI-HSLF");
+        box1.setAnchor(new Rectangle(54, 78, 612, 115));
+        slide.addShape(box1);
+
+        TextBox box2 = new TextBox();
+        TextRun tr2 = box2.getTextRun();
+        tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);
+        tr2.setText("Java API To Access Microsoft PowerPoint Format Files");
+        box2.setAnchor(new Rectangle(108, 204, 504, 138));
+        slide.addShape(box2);
+
+        TextBox box3 = new TextBox();
+        TextRun tr3 = box3.getTextRun();
+        tr3.getRichTextRuns()[0].setFontSize(32);
+        box3.setHorizontalAlignment(TextBox.AlignCenter);
+        tr3.setText(
+                "Yegor Kozlov\r" +
+                "yegor - apache - org");
+        box3.setAnchor(new Rectangle(206, 348, 310, 84));
+        slide.addShape(box3);
+    }
+
+    public static void slide2(SlideShow ppt) throws IOException {
+        Slide slide = ppt.createSlide();
+
+        TextBox box1 = new TextBox();
+        TextRun tr1 = box1.getTextRun();
+        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+        tr1.setText("What is HSLF?");
+        box1.setAnchor(new Rectangle(36, 21, 648, 90));
+        slide.addShape(box1);
+
+        TextBox box2 = new TextBox();
+        TextRun tr2 = box2.getTextRun();
+        tr2.setRunType(TextHeaderAtom.BODY_TYPE);
+        tr2.setText("HorribleSLideshowFormat is the POI Project's pure Java implementation " +
+                "of the Powerpoint binary file format. \r" +
+                "POI sub-project since 2005\r" +
+                "Started by Nick Birch, Yegor Kozlov joined soon after");
+        box2.setAnchor(new Rectangle(36, 126, 648, 356));
+        slide.addShape(box2);
+
+
+    }
+
+    public static void slide3(SlideShow ppt) throws IOException {
+        Slide slide = ppt.createSlide();
+
+        TextBox box1 = new TextBox();
+        TextRun tr1 = box1.getTextRun();
+        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+        tr1.setText("HSLF in a Nutshell");
+        box1.setAnchor(new Rectangle(36, 15, 648, 65));
+        slide.addShape(box1);
+
+        TextBox box2 = new TextBox();
+        TextRun tr2 = box2.getTextRun();
+        tr2.setRunType(TextHeaderAtom.BODY_TYPE);
+        tr2.setText(
+                "HSLF provides a way to read, create and modify MS PowerPoint presentations\r" +
+                "Pure Java API - you don't need PowerPoint to read and write *.ppt files\r" +
+                "Comprehensive support of PowerPoint objects");
+        tr2.getRichTextRuns()[0].setFontSize(28);
+        box2.setAnchor(new Rectangle(36, 80, 648, 200));
+        slide.addShape(box2);
+
+        TextBox box3 = new TextBox();
+        TextRun tr3 = box3.getTextRun();
+        tr3.setRunType(TextHeaderAtom.BODY_TYPE);
+        tr3.setText(
+                "Rich text\r" +
+                "Tables\r" +
+                "Shapes\r" +
+                "Pictures\r" +
+                "Master slides");
+        tr3.getRichTextRuns()[0].setFontSize(24);
+        tr3.getRichTextRuns()[0].setIndentLevel(1);
+        box3.setAnchor(new Rectangle(36, 265, 648, 150));
+        slide.addShape(box3);
+
+        TextBox box4 = new TextBox();
+        TextRun tr4 = box4.getTextRun();
+        tr4.setRunType(TextHeaderAtom.BODY_TYPE);
+        tr4.setText("Access to low level data structures");
+        box4.setAnchor(new Rectangle(36, 430, 648, 50));
+        slide.addShape(box4);
+    }
+
+    public static void slide4(SlideShow ppt) throws IOException {
+        Slide slide = ppt.createSlide();
+
+        String[][] txt1 = {
+            {"Note"},
+            {"This presentation was created programmatically using POI HSLF"}
+        };
+        Table table1 = new Table(2, 1);
+        for (int i = 0; i < txt1.length; i++) {
+            for (int j = 0; j < txt1[i].length; j++) {
+                TableCell cell = table1.getCell(i, j);
+                cell.setText(txt1[i][j]);
+                cell.getTextRun().getRichTextRuns()[0].setFontSize(10);
+                RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
+                rt.setFontName("Arial");
+                rt.setBold(true);
+                if(i == 0){
+                    rt.setFontSize(32);
+                    rt.setFontColor(Color.white);
+                    cell.getFill().setForegroundColor(new Color(0, 153, 204));
+                } else {
+                    rt.setFontSize(28);
+                    cell.getFill().setForegroundColor(new Color(235, 239, 241));
+                }
+                cell.setVerticalAlignment(TextBox.AnchorMiddle);
+            }
+        }
+
+        Line border1 = table1.createBorder();
+        border1.setLineColor(Color.black);
+        border1.setLineWidth(1.0);
+        table1.setAllBorders(border1);
+
+        Line border2 = table1.createBorder();
+        border2.setLineColor(Color.black);
+        border2.setLineWidth(2.0);
+        table1.setOutsideBorders(border2);
+
+        table1.setColumnWidth(0, 510);
+        table1.setRowHeight(0, 60);
+        table1.setRowHeight(1, 100);
+        slide.addShape(table1);
+
+        table1.moveTo(100, 100);
+
+        TextBox box1 = new TextBox();
+        box1.setHorizontalAlignment(TextBox.AlignCenter);
+        TextRun tr1 = box1.getTextRun();
+        tr1.setText("The source code is available at\r" +
+                "http://people.apache.org/~yegor/apachecon_eu08/");
+        RichTextRun rt = tr1.getRichTextRuns()[0];
+        rt.setFontSize(24);
+        box1.setAnchor(new Rectangle(80, 356, 553, 65));
+        slide.addShape(box1);
+
+    }
+
+    public static void slide5(SlideShow ppt) throws IOException {
+        Slide slide = ppt.createSlide();
+
+        TextBox box1 = new TextBox();
+        TextRun tr1 = box1.getTextRun();
+        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+        tr1.setText("HSLF in Action - 1\rData Extraction");
+        box1.setAnchor(new Rectangle(36, 21, 648, 100));
+        slide.addShape(box1);
+
+        TextBox box2 = new TextBox();
+        TextRun tr2 = box2.getTextRun();
+        tr2.setRunType(TextHeaderAtom.BODY_TYPE);
+        tr2.setText(
+                "Text from slides and notes\r" +
+                "Images\r" +
+                "Shapes and their properties (type, position in the slide, color, font, etc.)");
+        box2.setAnchor(new Rectangle(36, 150, 648, 300));
+        slide.addShape(box2);
+
+
+    }
+
+    public static void slide6(SlideShow ppt) throws IOException {
+        Slide slide = ppt.createSlide();
+
+        TextBox box1 = new TextBox();
+        TextRun tr1 = box1.getTextRun();
+        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+        tr1.setText("HSLF in Action - 2");
+        box1.setAnchor(new Rectangle(36, 20, 648, 90));
+        slide.addShape(box1);
+
+        TextBox box2 = new TextBox();
+        TextRun tr2 = box2.getTextRun();
+        tr2.getRichTextRuns()[0].setFontSize(18);
+        tr2.setText("Creating a simple presentation from scratch");
+        box2.setAnchor(new Rectangle(170, 100, 364, 30));
+        slide.addShape(box2);
+
+        TextBox box3 = new TextBox();
+        TextRun tr3 = box3.getTextRun();
+        RichTextRun rt3 = tr3.getRichTextRuns()[0];
+        rt3.setFontName("Courier New");
+        rt3.setFontSize(8);
+        tr3.setText(
+                "        SlideShow ppt = new SlideShow();\r" +
+                "        Slide slide = ppt.createSlide();\r" +
+                "\r" +
+                "        TextBox box2 = new TextBox();\r" +
+                "        box2.setHorizontalAlignment(TextBox.AlignCenter);\r" +
+                "        box2.setVerticalAlignment(TextBox.AnchorMiddle);\r" +
+                "        box2.getTextRun().setText(\"Java Code\");\r" +
+                "        box2.getFill().setForegroundColor(new Color(187, 224, 227));\r" +
+                "        box2.setLineColor(Color.black);\r" +
+                "        box2.setLineWidth(0.75);\r" +
+                "        box2.setAnchor(new Rectangle(66, 243, 170, 170));\r" +
+                "        slide.addShape(box2);\r" +
+                "\r" +
+                "        TextBox box3 = new TextBox();\r" +
+                "        box3.setHorizontalAlignment(TextBox.AlignCenter);\r" +
+                "        box3.setVerticalAlignment(TextBox.AnchorMiddle);\r" +
+                "        box3.getTextRun().setText(\"*.ppt file\");\r" +
+                "        box3.setLineWidth(0.75);\r" +
+                "        box3.setLineColor(Color.black);\r" +
+                "        box3.getFill().setForegroundColor(new Color(187, 224, 227));\r" +
+                "        box3.setAnchor(new Rectangle(473, 243, 170, 170));\r" +
+                "        slide.addShape(box3);\r" +
+                "\r" +
+                "        AutoShape box4 = new AutoShape(ShapeTypes.Arrow);\r" +
+                "        box4.getFill().setForegroundColor(new Color(187, 224, 227));\r" +
+                "        box4.setLineWidth(0.75);\r" +
+                "        box4.setLineColor(Color.black);\r" +
+                "        box4.setAnchor(new Rectangle(253, 288, 198, 85));\r" +
+                "        slide.addShape(box4);\r" +
+                "\r" +
+                "        FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\r" +
+                "        ppt.write(out);\r" +
+                "        out.close();");
+        box3.setAnchor(new Rectangle(30, 150, 618, 411));
+        slide.addShape(box3);
+    }
+
+    public static void slide7(SlideShow ppt) throws IOException {
+        Slide slide = ppt.createSlide();
+
+        TextBox box2 = new TextBox();
+        box2.setHorizontalAlignment(TextBox.AlignCenter);
+        box2.setVerticalAlignment(TextBox.AnchorMiddle);
+        box2.getTextRun().setText("Java Code");
+        box2.getFill().setForegroundColor(new Color(187, 224, 227));
+        box2.setLineColor(Color.black);
+        box2.setLineWidth(0.75);
+        box2.setAnchor(new Rectangle(66, 243, 170, 170));
+        slide.addShape(box2);
+
+        TextBox box3 = new TextBox();
+        box3.setHorizontalAlignment(TextBox.AlignCenter);
+        box3.setVerticalAlignment(TextBox.AnchorMiddle);
+        box3.getTextRun().setText("*.ppt file");
+        box3.setLineWidth(0.75);
+        box3.setLineColor(Color.black);
+        box3.getFill().setForegroundColor(new Color(187, 224, 227));
+        box3.setAnchor(new Rectangle(473, 243, 170, 170));
+        slide.addShape(box3);
+
+        AutoShape box4 = new AutoShape(ShapeTypes.Arrow);
+        box4.getFill().setForegroundColor(new Color(187, 224, 227));
+        box4.setLineWidth(0.75);
+        box4.setLineColor(Color.black);
+        box4.setAnchor(new Rectangle(253, 288, 198, 85));
+        slide.addShape(box4);
+    }
+
+    public static void slide8(SlideShow ppt) throws IOException {
+        Slide slide = ppt.createSlide();
+
+        TextBox box1 = new TextBox();
+        TextRun tr1 = box1.getTextRun();
+        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+        tr1.setText("Wait, there is more!");
+        box1.setAnchor(new Rectangle(36, 21, 648, 90));
+        slide.addShape(box1);
+
+        TextBox box2 = new TextBox();
+        TextRun tr2 = box2.getTextRun();
+        tr2.setRunType(TextHeaderAtom.BODY_TYPE);
+        tr2.setText(
+                "Rich text\r" +
+                "Tables\r" +
+                "Pictures (JPEG, PNG, BMP, WMF, PICT)\r" +
+                "Comprehensive formatting features");
+        box2.setAnchor(new Rectangle(36, 126, 648, 356));
+        slide.addShape(box2);
+    }
+
+    public static void slide9(SlideShow ppt) throws IOException {
+        Slide slide = ppt.createSlide();
+
+        TextBox box1 = new TextBox();
+        TextRun tr1 = box1.getTextRun();
+        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+        tr1.setText("HSLF in Action - 3");
+        box1.setAnchor(new Rectangle(36, 20, 648, 50));
+        slide.addShape(box1);
+
+        TextBox box2 = new TextBox();
+        TextRun tr2 = box2.getTextRun();
+        tr2.getRichTextRuns()[0].setFontSize(18);
+        tr2.setText("PPGraphics2D: PowerPoint Graphics2D driver");
+        box2.setAnchor(new Rectangle(178, 70, 387, 30));
+        slide.addShape(box2);
+
+        TextBox box3 = new TextBox();
+        TextRun tr3 = box3.getTextRun();
+        RichTextRun rt3 = tr3.getRichTextRuns()[0];
+        rt3.setFontName("Courier New");
+        rt3.setFontSize(8);
+        tr3.setText(
+                "        //bar chart data. The first value is the bar color, the second is the width\r" +
+                "        Object[] def = new Object[]{\r" +
+                "            Color.yellow, new Integer(100),\r" +
+                "            Color.green, new Integer(150),\r" +
+                "            Color.gray, new Integer(75),\r" +
+                "            Color.red, new Integer(200),\r" +
+                "        };\r" +
+                "\r" +
+                "        SlideShow ppt = new SlideShow();\r" +
+                "        Slide slide = ppt.createSlide();\r" +
+                "\r" +
+                "        ShapeGroup group = new ShapeGroup();\r" +
+                "        //define position of the drawing in the slide\r" +
+                "        Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);\r" +
+                "        group.setAnchor(bounds);\r" +
+                "        slide.addShape(group);\r" +
+                "        Graphics2D graphics = new PPGraphics2D(group);\r" +
+                "\r" +
+                "        //draw a simple bar graph\r" +
+                "        int x = bounds.x + 50, y = bounds.y + 50;\r" +
+                "        graphics.setFont(new Font(\"Arial\", Font.BOLD, 10));\r" +
+                "        for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {\r" +
+                "            graphics.setColor(Color.black);\r" +
+                "            int width = ((Integer)def[i+1]).intValue();\r" +
+                "            graphics.drawString(\"Q\" + idx, x-20, y+20);\r" +
+                "            graphics.drawString(width + \"%\", x + width + 10, y + 20);\r" +
+                "            graphics.setColor((Color)def[i]);\r" +
+                "            graphics.fill(new Rectangle(x, y, width, 30));\r" +
+                "            y += 40;\r" +
+                "        }\r" +
+                "        graphics.setColor(Color.black);\r" +
+                "        graphics.setFont(new Font(\"Arial\", Font.BOLD, 14));\r" +
+                "        graphics.draw(bounds);\r" +
+                "        graphics.drawString(\"Performance\", x + 70, y + 40);\r" +
+                "\r" +
+                "        FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\r" +
+                "        ppt.write(out);\r" +
+                "        out.close();");
+        box3.setAnchor(new Rectangle(96, 110, 499, 378));
+        slide.addShape(box3);
+    }
+
+    public static void slide10(SlideShow ppt) throws IOException {
+        //bar chart data. The first value is the bar color, the second is the width
+        Object[] def = new Object[]{
+            Color.yellow, new Integer(100),
+            Color.green, new Integer(150),
+            Color.gray, new Integer(75),
+            Color.red, new Integer(200),
+        };
+
+        Slide slide = ppt.createSlide();
+
+        ShapeGroup group = new ShapeGroup();
+        //define position of the drawing in the slide
+        Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
+        group.setAnchor(bounds);
+        slide.addShape(group);
+        Graphics2D graphics = new PPGraphics2D(group);
+
+        //draw a simple bar graph
+        int x = bounds.x + 50, y = bounds.y + 50;
+        graphics.setFont(new Font("Arial", Font.BOLD, 10));
+        for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {
+            graphics.setColor(Color.black);
+            int width = ((Integer)def[i+1]).intValue();
+            graphics.drawString("Q" + idx, x-20, y+20);
+            graphics.drawString(width + "%", x + width + 10, y + 20);
+            graphics.setColor((Color)def[i]);
+            graphics.fill(new Rectangle(x, y, width, 30));
+            y += 40;
+        }
+        graphics.setColor(Color.black);
+        graphics.setFont(new Font("Arial", Font.BOLD, 14));
+        graphics.draw(bounds);
+        graphics.drawString("Performance", x + 70, y + 40);
+
+    }
+
+    public static void slide11(SlideShow ppt) throws IOException {
+        Slide slide = ppt.createSlide();
+
+        TextBox box1 = new TextBox();
+        TextRun tr1 = box1.getTextRun();
+        tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+        tr1.setText("HSLF Development Plans");
+        box1.setAnchor(new Rectangle(36, 21, 648, 90));
+        slide.addShape(box1);
+
+        TextBox box2 = new TextBox();
+        TextRun tr2 = box2.getTextRun();
+        tr2.setRunType(TextHeaderAtom.BODY_TYPE);
+        tr2.getRichTextRuns()[0].setFontSize(32);
+        tr2.setText(
+                "Support for more PowerPoint functionality\r" +
+                "Rendering slides into java.awt.Graphics2D");
+        box2.setAnchor(new Rectangle(36, 126, 648, 100));
+        slide.addShape(box2);
+
+        TextBox box3 = new TextBox();
+        TextRun tr3 = box3.getTextRun();
+        tr3.setRunType(TextHeaderAtom.BODY_TYPE);
+        tr3.getRichTextRuns()[0].setIndentLevel(1);
+        tr3.setText(
+                "A way to export slides into images or other formats");
+        box3.setAnchor(new Rectangle(36, 220, 648, 70));
+        slide.addShape(box3);
+
+        TextBox box4 = new TextBox();
+        TextRun tr4 = box4.getTextRun();
+        tr4.setRunType(TextHeaderAtom.BODY_TYPE);
+        tr4.getRichTextRuns()[0].setFontSize(32);
+        tr4.setText(
+                "Integration with Apache FOP - Formatting Objects Processor");
+        box4.setAnchor(new Rectangle(36, 290, 648, 90));
+        slide.addShape(box4);
+
+        TextBox box5 = new TextBox();
+        TextRun tr5 = box5.getTextRun();
+        tr5.setRunType(TextHeaderAtom.BODY_TYPE);
+        tr5.getRichTextRuns()[0].setIndentLevel(1);
+        tr5.setText(
+                "Transformation of XSL-FO into PPT\r" +
+                "PPT2PDF transcoder");
+        box5.setAnchor(new Rectangle(36, 380, 648, 100));
+        slide.addShape(box5);
+    }
+
+    public static void slide12(SlideShow ppt) throws IOException {
+        Slide slide = ppt.createSlide();
+
+        TextBox box1 = new TextBox();
+        TextRun tr1 = box1.getTextRun();
+        tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);
+        tr1.setText("Questions?");
+        box1.setAnchor(new Rectangle(54, 167, 612, 115));
+        slide.addShape(box1);
+
+        TextBox box2 = new TextBox();
+        TextRun tr2 = box2.getTextRun();
+        tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);
+        tr2.setText(
+                "http://poi.apache.org/hslf/\r" +
+                "http://people.apache.org/~yegor");
+        box2.setAnchor(new Rectangle(108, 306, 504, 138));
+        slide.addShape(box2);
+    }
+}
index a4559713c4d9bde450396641f6460319864dfa54..3a97b61aa00c25a47509587aee96d2fb2986c354 100644 (file)
@@ -1,62 +1,62 @@
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.examples;\r
-\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.usermodel.RichTextRun;\r
-import org.apache.poi.hslf.model.Slide;\r
-import org.apache.poi.hslf.model.TextBox;\r
-\r
-import java.io.FileOutputStream;\r
-\r
-/**\r
- * How to create a single-level bulleted list\r
- * and change some of the bullet attributes\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class BulletsDemo {\r
-\r
-    public static void main(String[] args) throws Exception {\r
-\r
-        SlideShow ppt = new SlideShow();\r
-\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox shape = new TextBox();\r
-        RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];\r
-        shape.setText(\r
-                "January\r" +\r
-                "February\r" +\r
-                "March\r" +\r
-                "April");\r
-        rt.setFontSize(42);\r
-        rt.setBullet(true);\r
-        rt.setBulletOffset(0);  //bullet offset\r
-        rt.setTextOffset(50);   //text offset (should be greater than bullet offset)\r
-        rt.setBulletChar('\u263A'); //bullet character\r
-        slide.addShape(shape);\r
-\r
-        shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300));  //position of the text box in the slide\r
-        slide.addShape(shape);\r
-\r
-        FileOutputStream out = new FileOutputStream("bullets.ppt");\r
-        ppt.write(out);\r
-        out.close();\r
-   }\r
-}\r
+/* ====================================================================
+   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.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.RichTextRun;
+import org.apache.poi.hslf.model.Slide;
+import org.apache.poi.hslf.model.TextBox;
+
+import java.io.FileOutputStream;
+
+/**
+ * How to create a single-level bulleted list
+ * and change some of the bullet attributes
+ *
+ * @author Yegor Kozlov
+ */
+public final class BulletsDemo {
+
+    public static void main(String[] args) throws Exception {
+
+        SlideShow ppt = new SlideShow();
+
+        Slide slide = ppt.createSlide();
+
+        TextBox shape = new TextBox();
+        RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
+        shape.setText(
+                "January\r" +
+                "February\r" +
+                "March\r" +
+                "April");
+        rt.setFontSize(42);
+        rt.setBullet(true);
+        rt.setBulletOffset(0);  //bullet offset
+        rt.setTextOffset(50);   //text offset (should be greater than bullet offset)
+        rt.setBulletChar('\u263A'); //bullet character
+        slide.addShape(shape);
+
+        shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300));  //position of the text box in the slide
+        slide.addShape(shape);
+
+        FileOutputStream out = new FileOutputStream("bullets.ppt");
+        ppt.write(out);
+        out.close();
+   }
+}
index 9254c37da3c26750afa91bad0f555fac29e12d6e..c20a2f186f4cc68fd0cbd0524e21145bc1ddaec2 100755 (executable)
@@ -1,59 +1,60 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.examples;\r
-\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.usermodel.RichTextRun;\r
-import org.apache.poi.hslf.model.*;\r
-\r
-import java.io.FileInputStream;\r
-import java.io.FileOutputStream;\r
-import java.awt.*;\r
-\r
-/**\r
- * Demonstrates how to create hyperlinks in PowerPoint presentations\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class CreateHyperlink {\r
-\r
-    public static void main(String[] args) throws Exception {\r
-        SlideShow ppt = new SlideShow();\r
-\r
-        Slide slide = ppt.createSlide();\r
-\r
-        TextBox shape = new TextBox();\r
-        shape.setText("Apache POI");\r
-        Rectangle anchor = new Rectangle(100, 100, 200, 50);\r
-        shape.setAnchor(anchor);\r
-\r
-        String text = shape.getText();\r
-        Hyperlink link = new Hyperlink();\r
-        link.setAddress("http://www.apache.org");\r
-        link.setTitle(shape.getText());\r
-        int linkId = ppt.addHyperlink(link);\r
-\r
-        shape.setHyperlink(linkId, 0, text.length());\r
-\r
-        slide.addShape(shape);\r
-\r
-        FileOutputStream out = new FileOutputStream("hyperlink.ppt");\r
-        ppt.write(out);\r
-        out.close();\r
-\r
-   }\r
-}\r
+/* ====================================================================
+   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.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.RichTextRun;
+import org.apache.poi.hslf.model.*;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.awt.*;
+
+/**
+ * Demonstrates how to create hyperlinks in PowerPoint presentations
+ *
+ * @author Yegor Kozlov
+ */
+public final class CreateHyperlink {
+
+    public static void main(String[] args) throws Exception {
+        SlideShow ppt = new SlideShow();
+
+        Slide slide = ppt.createSlide();
+
+        TextBox shape = new TextBox();
+        shape.setText("Apache POI");
+        Rectangle anchor = new Rectangle(100, 100, 200, 50);
+        shape.setAnchor(anchor);
+
+        String text = shape.getText();
+        Hyperlink link = new Hyperlink();
+        link.setAddress("http://www.apache.org");
+        link.setTitle(shape.getText());
+        int linkId = ppt.addHyperlink(link);
+
+        shape.setHyperlink(linkId, 0, text.length());
+
+        slide.addShape(shape);
+
+        FileOutputStream out = new FileOutputStream("hyperlink.ppt");
+        ppt.write(out);
+        out.close();
+
+   }
+}
index 611466c9247acce111daf4a687e8034c33dd6312..a278e894b6c9f6977246d1f0b175ad6b657bf788 100755 (executable)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.examples;\r
-\r
-import org.apache.poi.hslf.usermodel.*;\r
-import org.apache.poi.hslf.model.*;\r
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;\r
-import org.apache.poi.hwpf.HWPFDocument;\r
-import org.apache.poi.hwpf.usermodel.Range;\r
-import org.apache.poi.hwpf.usermodel.Paragraph;\r
-\r
-import java.io.*;\r
-\r
-/**\r
- * Demonstrates how you can extract misc embedded data from a ppt file\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class DataExtraction {\r
-\r
-    public static void main(String args[]) throws Exception {\r
-\r
-        if (args.length == 0) {\r
-            usage();\r
-            return;\r
-        }\r
-\r
-        FileInputStream is = new FileInputStream(args[0]);\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        //extract all sound files embedded in this presentation\r
-        SoundData[] sound = ppt.getSoundData();\r
-        for (int i = 0; i < sound.length; i++) {\r
-            String type = sound[i].getSoundType();  //*.wav\r
-            String name = sound[i].getSoundName();  //typically file name\r
-            byte[] data = sound[i].getData();       //raw bytes\r
-\r
-            //save the sound  on disk\r
-            FileOutputStream out = new FileOutputStream(name + type);\r
-            out.write(data);\r
-            out.close();\r
-        }\r
-\r
-        //extract embedded OLE documents\r
-        Slide[] slide = ppt.getSlides();\r
-        for (int i = 0; i < slide.length; i++) {\r
-            Shape[] shape = slide[i].getShapes();\r
-            for (int j = 0; j < shape.length; j++) {\r
-                if (shape[j] instanceof OLEShape) {\r
-                    OLEShape ole = (OLEShape) shape[j];\r
-                    ObjectData data = ole.getObjectData();\r
-                    String name = ole.getInstanceName();\r
-                    if ("Worksheet".equals(name)) {\r
-\r
-                        //read xls\r
-                        HSSFWorkbook wb = new HSSFWorkbook(data.getData());\r
-\r
-                    } else if ("Document".equals(name)) {\r
-                        HWPFDocument doc = new HWPFDocument(data.getData());\r
-                        //read the word document\r
-                        Range r = doc.getRange();      \r
-                        for(int k = 0; k < r.numParagraphs(); k++) {\r
-                            Paragraph p = r.getParagraph(k);\r
-                            System.out.println(p.text());\r
-                         }\r
-\r
-                        //save on disk\r
-                        FileOutputStream out = new FileOutputStream(name + "-("+(j)+").doc");\r
-                        doc.write(out);\r
-                        out.close();\r
-                     }  else {\r
-                        FileOutputStream out = new FileOutputStream(ole.getProgID() + "-"+(j+1)+".dat");\r
-                        InputStream dis = data.getData();\r
-                        byte[] chunk = new byte[2048];\r
-                        int count;\r
-                        while ((count = dis.read(chunk)) >= 0) {\r
-                          out.write(chunk,0,count);\r
-                        }\r
-                        is.close();\r
-                        out.close();\r
-                    }\r
-                }\r
-\r
-            }\r
-        }\r
-\r
-        //Pictures\r
-        for (int i = 0; i < slide.length; i++) {\r
-            Shape[] shape = slide[i].getShapes();\r
-            for (int j = 0; j < shape.length; j++) {\r
-                if (shape[j] instanceof Picture) {\r
-                    Picture p = (Picture) shape[j];\r
-                    PictureData data = p.getPictureData();\r
-                    String name = p.getPictureName();\r
-                    int type = data.getType();\r
-                    String ext;\r
-                    switch (type) {\r
-                        case Picture.JPEG:\r
-                            ext = ".jpg";\r
-                            break;\r
-                        case Picture.PNG:\r
-                            ext = ".png";\r
-                            break;\r
-                        case Picture.WMF:\r
-                            ext = ".wmf";\r
-                            break;\r
-                        case Picture.EMF:\r
-                            ext = ".emf";\r
-                            break;\r
-                        case Picture.PICT:\r
-                            ext = ".pict";\r
-                            break;\r
-                        case Picture.DIB:\r
-                            ext = ".dib";\r
-                            break;\r
-                        default:\r
-                            continue;\r
-                    }\r
-                    FileOutputStream out = new FileOutputStream("pict-" + j + ext);\r
-                    out.write(data.getData());\r
-                    out.close();\r
-                }\r
-\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    private static void usage(){\r
-        System.out.println("Usage: DataExtraction  ppt");\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.hslf.model.*;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.hwpf.usermodel.Range;
+import org.apache.poi.hwpf.usermodel.Paragraph;
+
+import java.io.*;
+
+/**
+ * Demonstrates how you can extract misc embedded data from a ppt file
+ *
+ * @author Yegor Kozlov
+ */
+public final class DataExtraction {
+
+    public static void main(String args[]) throws Exception {
+
+        if (args.length == 0) {
+            usage();
+            return;
+        }
+
+        FileInputStream is = new FileInputStream(args[0]);
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        //extract all sound files embedded in this presentation
+        SoundData[] sound = ppt.getSoundData();
+        for (int i = 0; i < sound.length; i++) {
+            String type = sound[i].getSoundType();  //*.wav
+            String name = sound[i].getSoundName();  //typically file name
+            byte[] data = sound[i].getData();       //raw bytes
+
+            //save the sound  on disk
+            FileOutputStream out = new FileOutputStream(name + type);
+            out.write(data);
+            out.close();
+        }
+
+        //extract embedded OLE documents
+        Slide[] slide = ppt.getSlides();
+        for (int i = 0; i < slide.length; i++) {
+            Shape[] shape = slide[i].getShapes();
+            for (int j = 0; j < shape.length; j++) {
+                if (shape[j] instanceof OLEShape) {
+                    OLEShape ole = (OLEShape) shape[j];
+                    ObjectData data = ole.getObjectData();
+                    String name = ole.getInstanceName();
+                    if ("Worksheet".equals(name)) {
+
+                        //read xls
+                        HSSFWorkbook wb = new HSSFWorkbook(data.getData());
+
+                    } else if ("Document".equals(name)) {
+                        HWPFDocument doc = new HWPFDocument(data.getData());
+                        //read the word document
+                        Range r = doc.getRange();
+                        for(int k = 0; k < r.numParagraphs(); k++) {
+                            Paragraph p = r.getParagraph(k);
+                            System.out.println(p.text());
+                         }
+
+                        //save on disk
+                        FileOutputStream out = new FileOutputStream(name + "-("+(j)+").doc");
+                        doc.write(out);
+                        out.close();
+                     }  else {
+                        FileOutputStream out = new FileOutputStream(ole.getProgID() + "-"+(j+1)+".dat");
+                        InputStream dis = data.getData();
+                        byte[] chunk = new byte[2048];
+                        int count;
+                        while ((count = dis.read(chunk)) >= 0) {
+                          out.write(chunk,0,count);
+                        }
+                        is.close();
+                        out.close();
+                    }
+                }
+
+            }
+        }
+
+        //Pictures
+        for (int i = 0; i < slide.length; i++) {
+            Shape[] shape = slide[i].getShapes();
+            for (int j = 0; j < shape.length; j++) {
+                if (shape[j] instanceof Picture) {
+                    Picture p = (Picture) shape[j];
+                    PictureData data = p.getPictureData();
+                    String name = p.getPictureName();
+                    int type = data.getType();
+                    String ext;
+                    switch (type) {
+                        case Picture.JPEG:
+                            ext = ".jpg";
+                            break;
+                        case Picture.PNG:
+                            ext = ".png";
+                            break;
+                        case Picture.WMF:
+                            ext = ".wmf";
+                            break;
+                        case Picture.EMF:
+                            ext = ".emf";
+                            break;
+                        case Picture.PICT:
+                            ext = ".pict";
+                            break;
+                        case Picture.DIB:
+                            ext = ".dib";
+                            break;
+                        default:
+                            continue;
+                    }
+                    FileOutputStream out = new FileOutputStream("pict-" + j + ext);
+                    out.write(data.getData());
+                    out.close();
+                }
+
+            }
+        }
+
+    }
+
+    private static void usage(){
+        System.out.println("Usage: DataExtraction  ppt");
+    }
+}
index 87a59c38bb89b4e973ea094727a3de30b9264554..b3d85640e04c17934e8b0a422dc706ad3f563e1f 100755 (executable)
@@ -1,80 +1,80 @@
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.examples;\r
-\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.model.*;\r
-\r
-import java.awt.*;\r
-import java.io.FileOutputStream;\r
-import java.io.FileInputStream;\r
-\r
-/**\r
- * Demonstrates how to draw into a slide using the HSLF Graphics2D driver.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class Graphics2DDemo {\r
-\r
-    /**\r
-     * A simple bar chart demo\r
-     */\r
-    public static void main(String[] args) throws Exception {\r
-        SlideShow ppt = new SlideShow();\r
-\r
-        //bar chart data. The first value is the bar color, the second is the width\r
-        Object[] def = new Object[]{\r
-            Color.yellow, new Integer(40),\r
-            Color.green, new Integer(60),\r
-            Color.gray, new Integer(30),\r
-            Color.red, new Integer(80),\r
-        };\r
-\r
-        Slide slide = ppt.createSlide();\r
-\r
-        ShapeGroup group = new ShapeGroup();\r
-        //define position of the drawing in the slide\r
-        Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);\r
-        group.setAnchor(bounds);\r
-        group.setCoordinates(new java.awt.Rectangle(0, 0, 100, 100));\r
-        slide.addShape(group);\r
-        Graphics2D graphics = new PPGraphics2D(group);\r
-\r
-        //draw a simple bar graph\r
-        int x = 10, y = 10;\r
-        graphics.setFont(new Font("Arial", Font.BOLD, 10));\r
-        for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {\r
-            graphics.setColor(Color.black);\r
-            int width = ((Integer)def[i+1]).intValue();\r
-            graphics.drawString("Q" + idx, x-5, y+10);\r
-            graphics.drawString(width + "%", x + width+3, y + 10);\r
-            graphics.setColor((Color)def[i]);\r
-            graphics.fill(new Rectangle(x, y, width, 10));\r
-            y += 15;\r
-        }\r
-        graphics.setColor(Color.black);\r
-        graphics.setFont(new Font("Arial", Font.BOLD, 14));\r
-        graphics.draw(group.getCoordinates());\r
-        graphics.drawString("Performance", x + 30, y + 10);\r
-\r
-        FileOutputStream out = new FileOutputStream("hslf-graphics.ppt");\r
-        ppt.write(out);\r
-        out.close();\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.model.*;
+
+import java.awt.*;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+
+/**
+ * Demonstrates how to draw into a slide using the HSLF Graphics2D driver.
+ *
+ * @author Yegor Kozlov
+ */
+public final class Graphics2DDemo {
+
+    /**
+     * A simple bar chart demo
+     */
+    public static void main(String[] args) throws Exception {
+        SlideShow ppt = new SlideShow();
+
+        //bar chart data. The first value is the bar color, the second is the width
+        Object[] def = new Object[]{
+            Color.yellow, new Integer(40),
+            Color.green, new Integer(60),
+            Color.gray, new Integer(30),
+            Color.red, new Integer(80),
+        };
+
+        Slide slide = ppt.createSlide();
+
+        ShapeGroup group = new ShapeGroup();
+        //define position of the drawing in the slide
+        Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
+        group.setAnchor(bounds);
+        group.setCoordinates(new java.awt.Rectangle(0, 0, 100, 100));
+        slide.addShape(group);
+        Graphics2D graphics = new PPGraphics2D(group);
+
+        //draw a simple bar graph
+        int x = 10, y = 10;
+        graphics.setFont(new Font("Arial", Font.BOLD, 10));
+        for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {
+            graphics.setColor(Color.black);
+            int width = ((Integer)def[i+1]).intValue();
+            graphics.drawString("Q" + idx, x-5, y+10);
+            graphics.drawString(width + "%", x + width+3, y + 10);
+            graphics.setColor((Color)def[i]);
+            graphics.fill(new Rectangle(x, y, width, 10));
+            y += 15;
+        }
+        graphics.setColor(Color.black);
+        graphics.setFont(new Font("Arial", Font.BOLD, 14));
+        graphics.draw(group.getCoordinates());
+        graphics.drawString("Performance", x + 30, y + 10);
+
+        FileOutputStream out = new FileOutputStream("hslf-graphics.ppt");
+        ppt.write(out);
+        out.close();
+    }
+
+}
index f919e545ffdb8cbc7ffd1e06cbc0388e5d6464a4..968426c5134c0687f8ce97ab3e3a2df86a319eda 100644 (file)
@@ -1,80 +1,81 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.examples;\r
-\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.model.Slide;\r
-import org.apache.poi.hslf.model.TextRun;\r
-import org.apache.poi.hslf.model.Hyperlink;\r
-import org.apache.poi.hslf.model.Shape;\r
-\r
-import java.io.FileInputStream;\r
-\r
-/**\r
- * Demonstrates how to read hyperlinks from  a presentation\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class Hyperlinks {\r
-\r
-    public static void main(String[] args) throws Exception {\r
-        for (int i = 0; i < args.length; i++) {\r
-            FileInputStream is = new FileInputStream(args[i]);\r
-            SlideShow ppt = new SlideShow(is);\r
-            is.close();\r
-\r
-            Slide[] slide = ppt.getSlides();\r
-            for (int j = 0; j < slide.length; j++) {\r
-                System.out.println("slide " + slide[j].getSlideNumber());\r
-\r
-                //read hyperlinks from the slide's text runs\r
-                System.out.println("reading hyperlinks from the text runs");\r
-                TextRun[] txt = slide[j].getTextRuns();\r
-                for (int k = 0; k < txt.length; k++) {\r
-                    String text = txt[k].getText();\r
-                    Hyperlink[] links = txt[k].getHyperlinks();\r
-                    if(links != null) for (int l = 0; l < links.length; l++) {\r
-                        Hyperlink link = links[l];\r
-                        String title = link.getTitle();\r
-                        String address = link.getAddress();\r
-                        System.out.println("  " + title);\r
-                        System.out.println("  " + address);\r
-                        String substring = text.substring(link.getStartIndex(), link.getEndIndex()-1);//in ppt end index is inclusive\r
-                        System.out.println("  " + substring);\r
-                    }\r
-                }\r
-\r
-                //in PowerPoint you can assign a hyperlink to a shape without text,\r
-                //for example to a Line object. The code below demonstrates how to\r
-                //read such hyperlinks\r
-                System.out.println("  reading hyperlinks from the slide's shapes");\r
-                Shape[] sh = slide[j].getShapes();\r
-                for (int k = 0; k < sh.length; k++) {\r
-                    Hyperlink link = sh[k].getHyperlink();\r
-                    if(link != null)  {\r
-                        String title = link.getTitle();\r
-                        String address = link.getAddress();\r
-                        System.out.println("  " + title);\r
-                        System.out.println("  " + address);\r
-                    }\r
-                }\r
-            }\r
-\r
-        }\r
-\r
-   }\r
-}\r
+/* ====================================================================
+   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.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.model.Slide;
+import org.apache.poi.hslf.model.TextRun;
+import org.apache.poi.hslf.model.Hyperlink;
+import org.apache.poi.hslf.model.Shape;
+
+import java.io.FileInputStream;
+
+/**
+ * Demonstrates how to read hyperlinks from  a presentation
+ *
+ * @author Yegor Kozlov
+ */
+public final class Hyperlinks {
+
+    public static void main(String[] args) throws Exception {
+        for (int i = 0; i < args.length; i++) {
+            FileInputStream is = new FileInputStream(args[i]);
+            SlideShow ppt = new SlideShow(is);
+            is.close();
+
+            Slide[] slide = ppt.getSlides();
+            for (int j = 0; j < slide.length; j++) {
+                System.out.println("slide " + slide[j].getSlideNumber());
+
+                //read hyperlinks from the slide's text runs
+                System.out.println("reading hyperlinks from the text runs");
+                TextRun[] txt = slide[j].getTextRuns();
+                for (int k = 0; k < txt.length; k++) {
+                    String text = txt[k].getText();
+                    Hyperlink[] links = txt[k].getHyperlinks();
+                    if(links != null) for (int l = 0; l < links.length; l++) {
+                        Hyperlink link = links[l];
+                        String title = link.getTitle();
+                        String address = link.getAddress();
+                        System.out.println("  " + title);
+                        System.out.println("  " + address);
+                        String substring = text.substring(link.getStartIndex(), link.getEndIndex()-1);//in ppt end index is inclusive
+                        System.out.println("  " + substring);
+                    }
+                }
+
+                //in PowerPoint you can assign a hyperlink to a shape without text,
+                //for example to a Line object. The code below demonstrates how to
+                //read such hyperlinks
+                System.out.println("  reading hyperlinks from the slide's shapes");
+                Shape[] sh = slide[j].getShapes();
+                for (int k = 0; k < sh.length; k++) {
+                    Hyperlink link = sh[k].getHyperlink();
+                    if(link != null)  {
+                        String title = link.getTitle();
+                        String address = link.getAddress();
+                        System.out.println("  " + title);
+                        System.out.println("  " + address);
+                    }
+                }
+            }
+
+        }
+
+   }
+}
index 8a75297121ff641441da525b8230af7c745b98f8..2371f0fbf6ae19a2bc0284beaae02225827678a0 100755 (executable)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.examples;\r
-\r
-import org.apache.poi.hslf.usermodel.*;\r
-import org.apache.poi.hslf.model.*;\r
-import org.apache.poi.hslf.record.TextHeaderAtom;\r
-\r
-import javax.imageio.ImageIO;\r
-import java.io.IOException;\r
-import java.io.FileOutputStream;\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.awt.*;\r
-import java.awt.image.BufferedImage;\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-/**\r
- * Demonstrates how you can use HSLF to convert each slide into a PNG image\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class PPT2PNG {\r
-\r
-    public static void main(String args[]) throws Exception {\r
-\r
-        if (args.length == 0) {\r
-            usage();\r
-            return;\r
-        }\r
-\r
-        int slidenum = -1;\r
-        float scale = 1;\r
-        String file = null;\r
-\r
-        for (int i = 0; i < args.length; i++) {\r
-            if (args[i].startsWith("-")) {\r
-                if ("-scale".equals(args[i])){\r
-                    scale = Float.parseFloat(args[++i]);\r
-                } else if ("-slide".equals(args[i])) {\r
-                    slidenum = Integer.parseInt(args[++i]);\r
-                }\r
-            } else {\r
-                file = args[i];\r
-            }\r
-        }\r
-        if(file == null){\r
-            usage();\r
-            return;\r
-        }\r
-\r
-        FileInputStream is = new FileInputStream(file);\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        Dimension pgsize = ppt.getPageSize();\r
-        int width = (int)(pgsize.width*scale);\r
-        int height = (int)(pgsize.height*scale);\r
-\r
-        Slide[] slide = ppt.getSlides();\r
-        for (int i = 0; i < slide.length; i++) {\r
-            if (slidenum != -1 && slidenum != (i+1)) continue;\r
-\r
-            String title = slide[i].getTitle();\r
-            System.out.println("Rendering slide "+slide[i].getSlideNumber() + (title == null ? "" : ": " + title));\r
-\r
-            BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);\r
-            Graphics2D graphics = img.createGraphics();\r
-            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);\r
-            graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);\r
-            graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);\r
-            graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);\r
-\r
-            graphics.setPaint(Color.white);\r
-            graphics.fill(new Rectangle2D.Float(0, 0, width, height));\r
-\r
-            graphics.scale((double)width/pgsize.width, (double)height/pgsize.height);\r
-\r
-            slide[i].draw(graphics);\r
-\r
-            String fname = file.replaceAll("\\.ppt", "-" + (i+1) + ".png");\r
-            FileOutputStream out = new FileOutputStream(fname);\r
-            ImageIO.write(img, "png", out);\r
-            out.close();\r
-        }\r
-    }\r
-\r
-    private static void usage(){\r
-        System.out.println("Usage: PPT2PNG [-scale <scale> -slide <num>] ppt");\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.hslf.model.*;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+
+import javax.imageio.ImageIO;
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Demonstrates how you can use HSLF to convert each slide into a PNG image
+ *
+ * @author Yegor Kozlov
+ */
+public final class PPT2PNG {
+
+    public static void main(String args[]) throws Exception {
+
+        if (args.length == 0) {
+            usage();
+            return;
+        }
+
+        int slidenum = -1;
+        float scale = 1;
+        String file = null;
+
+        for (int i = 0; i < args.length; i++) {
+            if (args[i].startsWith("-")) {
+                if ("-scale".equals(args[i])){
+                    scale = Float.parseFloat(args[++i]);
+                } else if ("-slide".equals(args[i])) {
+                    slidenum = Integer.parseInt(args[++i]);
+                }
+            } else {
+                file = args[i];
+            }
+        }
+        if(file == null){
+            usage();
+            return;
+        }
+
+        FileInputStream is = new FileInputStream(file);
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        Dimension pgsize = ppt.getPageSize();
+        int width = (int)(pgsize.width*scale);
+        int height = (int)(pgsize.height*scale);
+
+        Slide[] slide = ppt.getSlides();
+        for (int i = 0; i < slide.length; i++) {
+            if (slidenum != -1 && slidenum != (i+1)) continue;
+
+            String title = slide[i].getTitle();
+            System.out.println("Rendering slide "+slide[i].getSlideNumber() + (title == null ? "" : ": " + title));
+
+            BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+            Graphics2D graphics = img.createGraphics();
+            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+            graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+            graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+            graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+
+            graphics.setPaint(Color.white);
+            graphics.fill(new Rectangle2D.Float(0, 0, width, height));
+
+            graphics.scale((double)width/pgsize.width, (double)height/pgsize.height);
+
+            slide[i].draw(graphics);
+
+            String fname = file.replaceAll("\\.ppt", "-" + (i+1) + ".png");
+            FileOutputStream out = new FileOutputStream(fname);
+            ImageIO.write(img, "png", out);
+            out.close();
+        }
+    }
+
+    private static void usage(){
+        System.out.println("Usage: PPT2PNG [-scale <scale> -slide <num>] ppt");
+    }
+}
index 25ff9ad017ca689a07edfbc3ea6d230981606942..44935c05ac9c989f53a43adca2798a12222d9e93 100755 (executable)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.examples;\r
-\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.usermodel.RichTextRun;\r
-import org.apache.poi.hslf.model.*;\r
-\r
-import java.awt.*;\r
-import java.io.FileOutputStream;\r
-\r
-/**\r
- * Demonstrates how to create tables\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class TableDemo {\r
-\r
-    public static void main(String[] args) throws Exception {\r
-\r
-        //test data for the first taable\r
-        String[][] txt1 = {\r
-            {"INPUT FILE", "NUMBER OF RECORDS"},\r
-            {"Item File", "11,559"},\r
-            {"Vendor File", "502"},\r
-            {"Purchase History File - # of PO\u2019s\r(12/01/04 - 05/31/06)", "12,852"},\r
-            {"Purchase History File - # of PO Lines\r(12/01/04 - 05/31/06)", "53,523" },\r
-            {"Total PO History Spend", "$10,172,038"}\r
-        };\r
-\r
-        SlideShow ppt = new SlideShow();\r
-\r
-        Slide slide = ppt.createSlide();\r
-\r
-        //six rows, two columns\r
-        Table table1 = new Table(6, 2);\r
-        for (int i = 0; i < txt1.length; i++) {\r
-            for (int j = 0; j < txt1[i].length; j++) {\r
-                TableCell cell = table1.getCell(i, j);\r
-                cell.setText(txt1[i][j]);\r
-                RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];\r
-                rt.setFontName("Arial");\r
-                rt.setFontSize(10);\r
-                if(i == 0){\r
-                    cell.getFill().setForegroundColor(new Color(227, 227, 227));\r
-                } else {\r
-                    rt.setBold(true);\r
-                }\r
-                cell.setVerticalAlignment(TextBox.AnchorMiddle);\r
-                cell.setHorizontalAlignment(TextBox.AlignCenter);\r
-            }\r
-        }\r
-\r
-        Line border1 = table1.createBorder();\r
-        border1.setLineColor(Color.black);\r
-        border1.setLineWidth(1.0);\r
-        table1.setAllBorders(border1);\r
-\r
-        table1.setColumnWidth(0, 300);\r
-        table1.setColumnWidth(1, 150);\r
-\r
-        slide.addShape(table1);\r
-        int pgWidth = ppt.getPageSize().width;\r
-        table1.moveTo((pgWidth - table1.getAnchor().width)/2, 100);\r
-\r
-        //test data for the second taable\r
-        String[][] txt2 = {\r
-            {"Data Source"},\r
-            {"CAS Internal Metrics - Item Master Summary\r" +\r
-             "CAS Internal Metrics - Vendor Summary\r" +\r
-             "CAS Internal Metrics - PO History Summary"}\r
-        };\r
-\r
-        //two rows, one column\r
-        Table table2 = new Table(2, 1);\r
-        for (int i = 0; i < txt2.length; i++) {\r
-            for (int j = 0; j < txt2[i].length; j++) {\r
-                TableCell cell = table2.getCell(i, j);\r
-                cell.setText(txt2[i][j]);\r
-                RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];\r
-                rt.setFontSize(10);\r
-                rt.setFontName("Arial");\r
-                if(i == 0){\r
-                    cell.getFill().setForegroundColor(new Color(0, 51, 102));\r
-                    rt.setFontColor(Color.white);\r
-                    rt.setBold(true);\r
-                    rt.setFontSize(14);\r
-                    cell.setHorizontalAlignment(TextBox.AlignCenter);\r
-                } else {\r
-                    rt.setBullet(true);\r
-                    rt.setFontSize(12);\r
-                    cell.setHorizontalAlignment(TextBox.AlignLeft);\r
-                }\r
-                cell.setVerticalAlignment(TextBox.AnchorMiddle);\r
-            }\r
-        }\r
-        table2.setColumnWidth(0, 300);\r
-        table2.setRowHeight(0, 30);\r
-        table2.setRowHeight(1, 70);\r
-\r
-        Line border2 = table2.createBorder();\r
-        table2.setOutsideBorders(border2);\r
-\r
-        slide.addShape(table2);\r
-        table2.moveTo(200, 400);\r
-\r
-        FileOutputStream out = new FileOutputStream("hslf-table.ppt");\r
-        ppt.write(out);\r
-        out.close();\r
-\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.RichTextRun;
+import org.apache.poi.hslf.model.*;
+
+import java.awt.*;
+import java.io.FileOutputStream;
+
+/**
+ * Demonstrates how to create tables
+ *
+ * @author Yegor Kozlov
+ */
+public final class TableDemo {
+
+    public static void main(String[] args) throws Exception {
+
+        //test data for the first taable
+        String[][] txt1 = {
+            {"INPUT FILE", "NUMBER OF RECORDS"},
+            {"Item File", "11,559"},
+            {"Vendor File", "502"},
+            {"Purchase History File - # of PO\u2019s\r(12/01/04 - 05/31/06)", "12,852"},
+            {"Purchase History File - # of PO Lines\r(12/01/04 - 05/31/06)", "53,523" },
+            {"Total PO History Spend", "$10,172,038"}
+        };
+
+        SlideShow ppt = new SlideShow();
+
+        Slide slide = ppt.createSlide();
+
+        //six rows, two columns
+        Table table1 = new Table(6, 2);
+        for (int i = 0; i < txt1.length; i++) {
+            for (int j = 0; j < txt1[i].length; j++) {
+                TableCell cell = table1.getCell(i, j);
+                cell.setText(txt1[i][j]);
+                RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
+                rt.setFontName("Arial");
+                rt.setFontSize(10);
+                if(i == 0){
+                    cell.getFill().setForegroundColor(new Color(227, 227, 227));
+                } else {
+                    rt.setBold(true);
+                }
+                cell.setVerticalAlignment(TextBox.AnchorMiddle);
+                cell.setHorizontalAlignment(TextBox.AlignCenter);
+            }
+        }
+
+        Line border1 = table1.createBorder();
+        border1.setLineColor(Color.black);
+        border1.setLineWidth(1.0);
+        table1.setAllBorders(border1);
+
+        table1.setColumnWidth(0, 300);
+        table1.setColumnWidth(1, 150);
+
+        slide.addShape(table1);
+        int pgWidth = ppt.getPageSize().width;
+        table1.moveTo((pgWidth - table1.getAnchor().width)/2, 100);
+
+        //test data for the second taable
+        String[][] txt2 = {
+            {"Data Source"},
+            {"CAS Internal Metrics - Item Master Summary\r" +
+             "CAS Internal Metrics - Vendor Summary\r" +
+             "CAS Internal Metrics - PO History Summary"}
+        };
+
+        //two rows, one column
+        Table table2 = new Table(2, 1);
+        for (int i = 0; i < txt2.length; i++) {
+            for (int j = 0; j < txt2[i].length; j++) {
+                TableCell cell = table2.getCell(i, j);
+                cell.setText(txt2[i][j]);
+                RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
+                rt.setFontSize(10);
+                rt.setFontName("Arial");
+                if(i == 0){
+                    cell.getFill().setForegroundColor(new Color(0, 51, 102));
+                    rt.setFontColor(Color.white);
+                    rt.setBold(true);
+                    rt.setFontSize(14);
+                    cell.setHorizontalAlignment(TextBox.AlignCenter);
+                } else {
+                    rt.setBullet(true);
+                    rt.setFontSize(12);
+                    cell.setHorizontalAlignment(TextBox.AlignLeft);
+                }
+                cell.setVerticalAlignment(TextBox.AnchorMiddle);
+            }
+        }
+        table2.setColumnWidth(0, 300);
+        table2.setRowHeight(0, 30);
+        table2.setRowHeight(1, 70);
+
+        Line border2 = table2.createBorder();
+        table2.setOutsideBorders(border2);
+
+        slide.addShape(table2);
+        table2.moveTo(200, 400);
+
+        FileOutputStream out = new FileOutputStream("hslf-table.ppt");
+        ppt.write(out);
+        out.close();
+
+    }
+}
index 122533f9ec781cd41df3a3cf174d742660f71e68..82d3a8a2303f9877116e1975106f7b455c9cce05 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf;
 
 import org.apache.poi.hwpf.HWPFDocument;
@@ -24,7 +23,7 @@ import org.apache.poi.hwpf.model.*;
 
 import java.io.*;
 
-public class Word2Forrest
+public final class Word2Forrest
 {
   Writer _out;
   HWPFDocument _doc;
index 97b4be484e2baacbd45d82ad5ce5a93af5040c63..b93ac1f6df348d8c9077620822289ccbdde8e5e4 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hdf.event;
 
 
@@ -27,7 +26,7 @@ import org.apache.poi.util.LittleEndian;
 
 import java.util.ArrayList;
 
-public class EventBridge implements HDFLowLevelParsingListener
+public final class EventBridge implements HDFLowLevelParsingListener
 {
 
   private static int HEADER_EVEN_INDEX = 0;
index 8bf2a183136b987872dc60980e34bbc162ac4fe1..3358832d30d6cf8b27e042e5558e8c679969a7f5 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hdf.event;
 
 import org.apache.poi.hdf.model.hdftypes.ChpxNode;
index 05c27b93365801b37e0b4f27a7ea7de2b9e84a77..aa8f2b5c712c4f0e36e8cbdd37a56687984fd4fe 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hdf.event;
 
 import org.apache.poi.hdf.model.hdftypes.SectionProperties;
index 2d54a3c0f863abc1f35bd18f48827bbc369c7420..50bfc1a36b674b4d6f33cacd9185f14547cba4f7 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.extractor;
 
@@ -24,10 +21,10 @@ package org.apache.poi.hdf.extractor;
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class CHP implements Cloneable
+public final class CHP implements Cloneable
 {
   boolean _bold;
   boolean _italic;
index 0176188ae91ecae620d2882f35b7f5dfd6843bfd..1c9eab6e9c6c0a0e801fe764376b1bf44f7c92c3 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.hdf.extractor;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class FontTable
+public final class FontTable
 {
   String[] fontNames;
 
index 6662754282e29e03143248b68dae19e1d904d193..83ede7aeda17dd0a20495095aa8d6ff329734e1a 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.hdf.extractor;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class HeaderFooter
+public final class HeaderFooter
 {
   public static final int HEADER_EVEN = 1;
   public static final int HEADER_ODD = 2;
index d332fc5f4eb445ab28227000afe61cdc61196d2b..43932b947284f9bb6e730d2b299f0ecaac27c747 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.extractor;
 
@@ -26,10 +23,10 @@ import java.util.*;
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class NewOleFile extends RandomAccessFile
+public final class NewOleFile extends RandomAccessFile
 {
     private byte[] LAOLA_ID_ARRAY = new byte[]{(byte)0xd0, (byte)0xcf, (byte)0x11,
                                                (byte)0xe0, (byte)0xa1, (byte)0xb1,
index 44e9a78607424254f14de2017872ed05d01536b8..1075e145d0ef0c3dfedc9104f43ffd12719e1360 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.hdf.extractor;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class PAP implements Cloneable
+public final class PAP implements Cloneable
 {
   int _istd;//index to style descriptor.
   byte _jc;//justification code
index a7f5958ffcbe2fcba094eb3978dc78122a71997a..61b7dc52b1e0eabca03cea828720c069bb8f9c7d 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.hdf.extractor;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class PropertySet
+public final class PropertySet
 {
     private String _name;
     private int _type;
index cdd0e9504c188bb271c0c923564a90707779f405..300c2f8ad34a213235bf8067573b6f341ce399a0 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.hdf.extractor;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class SEP
+public final class SEP
 {
   int _index;
   byte _bkc;
index 0be6ada106e0f1a5fc24d77865454b253a0f8de7..b011b425e67672913eaf09af50562a5ebe684bfd 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.extractor;
 
@@ -24,10 +21,10 @@ package org.apache.poi.hdf.extractor;
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class StyleDescription
+public final class StyleDescription
 {
 
   private static int PARAGRAPH_STYLE = 1;
index ff10eb8e9f38b39cf7f1bc25e6c339e0eebbdd02..751b03666f480e1bc930397817d7a2ddd71c070f 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.extractor;
 
@@ -25,10 +22,10 @@ import java.util.*;
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class StyleSheet
+public final class StyleSheet
 {
 
   private static final int NIL_STYLE = 4095;
index b248b3ee58cd36023f86db9b93e6a074765c6348..42ccde2842eaf15050da2354ab1646b9cb9a271d 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.hdf.extractor;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class TAP
+public final class TAP
 {
   short _jc;
   int _dxaGapHalf;
index a6663410b0a6c25efe513c5f35bae3c447c55e58..be201b52c89c9e6ef1825734c77c02fd5a503900 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.hdf.extractor;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class TC
+public final class TC
 {
 
   boolean _fFirstMerged;
index f254ea81b0b7827acefdba32138a83ebc1d018e3..c95d0980a4684938502217c49d9185a552cc401a 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.extractor;
 
@@ -25,10 +22,10 @@ import java.util.*;
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class TableRow
+public final class TableRow
 {
   TAP _descriptor;
   ArrayList _cells;
index d5de406b6b56b4a9c12679e17924b06b9a574028..378b78fb9eae33917e1e3d1bc2b94cf8a387e423 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.hdf.extractor;
 
@@ -24,10 +22,10 @@ import org.apache.poi.hdf.extractor.util.*;
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class TextPiece extends PropertyNode implements Comparable
+public final class TextPiece extends PropertyNode implements Comparable
 {
   private boolean _usesUnicode;
   private int _length;
@@ -49,5 +47,5 @@ public class TextPiece extends PropertyNode implements Comparable
    public int compareTo(Object obj) {
        return 0;
    }
-   
+
 }
index 3e663f432cf26181c203666f3670311250daba16..7c222ec8186b04eb943de815932ee4ac72dd9fa6 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.hdf.extractor;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class Utils
+public final class Utils
 {
 
     public static short convertBytesToShort(byte firstByte, byte secondByte)
index 2c89fa4bef85850e36484bfdbc9bbb7a58d28ff7..a525d97141b9467ad3376c3bed299ec9ea45c1dc 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.extractor;
 
@@ -39,7 +36,7 @@ import org.apache.poi.util.LittleEndian;
  * @author Ryan Ackley
  */
 
-public class WordDocument
+public final class WordDocument
 {
   /** byte buffer containing the main Document stream*/
   byte[] _header;
@@ -182,7 +179,7 @@ public class WordDocument
   {
        this(new FileInputStream(fileName));
   }
-  
+
   public WordDocument(InputStream inputStream) throws IOException
   {
         //do Ole stuff
@@ -818,8 +815,8 @@ public class WordDocument
 
     return "<fo:region-" + where + " display-align=\"" + align + "\" extent=\""
              + extent + "pt\" "+region+"/>";
-// org.apache.fop.fo.expr.PropertyException: 
-// Border and padding for region "xsl-region-before" must be '0' 
+// org.apache.fop.fo.expr.PropertyException:
+// Border and padding for region "xsl-region-before" must be '0'
 // (See 6.4.13 in XSL 1.0).
 //             extent + "pt\" padding-left=\"" + marginLeft + "pt\" padding-right=\"" +
 //             marginRight + "pt\" padding-top=\"" + marginTop + "pt\" padding-bottom=\"" +
index d5210a02e9ab881561dfb8482f3e09d849008056..9e5ae6ce2f9460af72c59e1121f94eec2b7ddf3e 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.hdf.extractor.data;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class DOP
+public final class DOP
 {
 
   public boolean _fFacingPages;
index 05aa53b60277831bead0ec1e3e23049003aafa3f..86e4cf0f2f9dca9e9c71a3600f56f41af59f7571 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.hdf.extractor.data;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class LFO
+public final class LFO
 {
   int _lsid;
   int _clfolvl;
index f4f4e39c565cccf288ce9358edc6fc0b0dfcbc8e..2984d97485fa94dc43335e53c9ab9b8244cf259b 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.hdf.extractor.data;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class LFOLVL
+public final class LFOLVL
 {
   int _iStartAt;
   int _ilvl;
index 16ccfb099f84cc1b883890d41134085e99207d24..932a921c7df1c2206da140753a41ef2cba02289f 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.hdf.extractor.data;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class LST
+public final class LST
 {
   int _lsid;
   int _tplc;
index 52caa33a34907af0eca539ee3dd50d627b5d2358..0e0ed23f688eab67703aa65628cbf816f81be870 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.hdf.extractor.data;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
 
-public class LVL
+public final class LVL
 {
   public int _iStartAt;
   public byte _nfc;
index c128e1023b683451bbfa82bb90609b6a9f92304d..76ff9b2c37faea64d181919b9e35514891a8b406 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.extractor.data;
 
@@ -28,10 +25,10 @@ import org.apache.poi.hdf.extractor.*;
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class ListTables
+public final class ListTables
 {
 
   LFO[] _pllfo;
index f1e2c8371ade416f3fb06d69ea8630b1792a512d..3f05811544a6d88b903f6d7561d540a9a3f7d84b 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.extractor.util;
 
@@ -34,11 +31,11 @@ import java.util.*;
  * are in ascending order.  The Iterator.remove() method is supported.
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  *
 */
 
-public class BTreeSet extends AbstractSet implements Set {
+public final class BTreeSet extends AbstractSet implements Set {
 
     /*
      * Instance Variables
index c65d321e89a58ce41e48d087eca09db691fe183a..35e0da232a472e8cb99664e98edfcf6678b0fe38 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.extractor.util;
 
@@ -24,10 +21,10 @@ package org.apache.poi.hdf.extractor.util;
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class ChpxNode extends PropertyNode
+public final class ChpxNode extends PropertyNode
 {
 
 
index 6566ee737911b5d8cf7527f51603bdef093bf9ee..5c9e7205d4b8173174b452c1d48623640af49734 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.extractor.util;
 
@@ -24,10 +21,10 @@ package org.apache.poi.hdf.extractor.util;
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class NumberFormatter
+public final class NumberFormatter
 {
   private final static int ARABIC = 0;
   private final static int UPPER_ROMAN = 1;
index 4f614b55325fd6509adbb0d2701334720a81f90f..7ba34c0297d6a09c73987f86d80f5239dcaf3fc1 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.hdf.extractor.util;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class PapxNode extends PropertyNode
+public final class PapxNode extends PropertyNode
 {
 
 
index 6011d00022ca84e1e7e4c9187e9488bdec98f175..aea50f1bfc65b06bc18a804dffd0bf33208b9e90 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.hdf.extractor.util;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class PropertyNode implements Comparable
-{
+public abstract class PropertyNode implements Comparable {
   private byte[] _grpprl;
   private int _fcStart;
   private int _fcEnd;
index 5b55611e0dfe58b47e51aa7114d7ac713161a3f6..f5391d0976e6f31e0c8bb668321477ab2621f9ed 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.hdf.extractor.util;
 
 /**
  * Comment me
  *
- * @author Ryan Ackley 
+ * @author Ryan Ackley
  */
 
-public class SepxNode extends PropertyNode
+public final class SepxNode extends PropertyNode
 {
 
   int _index;
@@ -39,9 +36,9 @@ public class SepxNode extends PropertyNode
   {
     return getGrpprl();
   }
-  
+
   public int compareTo(Object obj) {
       return 0;
   }
-  
+
 }
index da757c6e860af83903212bc1036de9eee06fb9f8..058f111187fba092ba14550ee1d21d7160b7e596 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hdf.model;
 
 import java.io.InputStream;
@@ -24,7 +23,7 @@ import java.io.IOException;
 import org.apache.poi.hdf.event.HDFParsingListener;
 import org.apache.poi.hdf.event.EventBridge;
 
-public class HDFDocument
+public final class HDFDocument
 {
 
   HDFObjectModel _model;
index 66012e8c8db72064a0b2ea2febb71abe3ba2bd83..f08bd0deb07dadcd882737e0a4de830b973a940a 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.
 ==================================================================== */
-        
-/*
- * HDFObjectFactory.java
- *
- * Created on February 24, 2002, 2:17 PM
- */
 
 package org.apache.poi.hdf.model;
 
@@ -53,7 +46,7 @@ import org.apache.poi.util.LittleEndian;
  * that represent the data.
  * @author  andy
  */
-public class HDFObjectFactory
+public final class HDFObjectFactory
 {
 
     /** OLE stuff*/
index 4b49b39755a6d7cc26dee47b9ba782c50fa65f12..e0c84314f13d985e223f2d1797fa305d1b0a47bd 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hdf.model;
 
 import org.apache.poi.hdf.event.HDFLowLevelParsingListener;
@@ -31,7 +30,7 @@ import org.apache.poi.hdf.model.hdftypes.ListTables;
 import org.apache.poi.hdf.model.hdftypes.StyleSheet;
 
 
-public class HDFObjectModel implements HDFLowLevelParsingListener
+public final class HDFObjectModel implements HDFLowLevelParsingListener
 {
 
     /** "WordDocument" from the POIFS */
index d0506185aad0253746d2e6a29fe20079b4bf6552..7eb167ead4db0adbc92cdd117a209d8242c28e21 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hdf.model.hdftypes;
 
 import org.apache.poi.util.LittleEndian;
@@ -36,7 +35,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Ryan Ackley
  */
-public class CHPFormattedDiskPage extends FormattedDiskPage
+public final class CHPFormattedDiskPage extends FormattedDiskPage
 {
 
 
index e5d450f87a1821341c771a334fa7cc57e58c93cd..a85edbad44569939d023f46d8a0ca2150130defc 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -27,7 +24,7 @@ import org.apache.poi.hdf.model.hdftypes.definitions.CHPAbstractType;
  * @author Ryan Ackley
  */
 
-public class CharacterProperties extends CHPAbstractType implements Cloneable
+public final class CharacterProperties extends CHPAbstractType implements Cloneable
 {
 
   public CharacterProperties()
index db45ee88daf96748a778dbd35d8f17fbea5cfc9a..ab0845358d54d34d445f54561c19003c7779857b 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -27,7 +24,7 @@ package org.apache.poi.hdf.model.hdftypes;
  * @author Ryan Ackley
  */
 
-public class ChpxNode extends PropertyNode
+public final class ChpxNode extends PropertyNode
 {
 
 
index 6bfc372489e55a10e049a2f06227b8fd784fab11..2020d78f43fc349500b9c42f2906c8e98f291a56 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -27,7 +24,7 @@ import org.apache.poi.util.LittleEndian;
  * @author Ryan Ackley
  */
 
-public class DocumentProperties implements HDFType
+public final class DocumentProperties implements HDFType
 {
 
   public boolean _fFacingPages;
index b6793b7a6456f3c81e6956d5860f622325239818..23409b54787e7b4fefb1e1e8c20fec9f95841e78 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hdf.model.hdftypes;
 
 import org.apache.poi.util.BitField;
@@ -28,7 +27,7 @@ import org.apache.poi.hdf.model.hdftypes.definitions.FIBAbstractType;
  *
  * @author  andy
  */
-public class FileInformationBlock extends FIBAbstractType
+public final class FileInformationBlock extends FIBAbstractType
 {
 /*
     private  short field_1_id;
index 14927f2fecafb84cff7dbb51295975b042bcbac6..e1aa22f8294d3b2bd90cc6c3e686faefdb129f67 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.hdf.model.hdftypes;
 
@@ -26,7 +24,7 @@ import org.apache.poi.util.LittleEndian;
  * @author Ryan Ackley
  */
 
-public class FontTable implements HDFType
+public final class FontTable implements HDFType
 {
   String[] fontNames;
 
index 0e61cf35b1c3ea3da0343705e1b94a9e832c5391..ba912cb7ced56cada540c73ae97c559757f75ae3 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.hdf.model.hdftypes;
 
index 681d2999fc95e8f876df44044ab8d86ed986a76f..f82a0295beabc5ce5a95058a0210efc9b19c2f05 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.
 ==================================================================== */
-        
-/*
- * HDFType.java
- *
- * Created on February 24, 2002, 2:37 PM
- */
 
 package org.apache.poi.hdf.model.hdftypes;
 
index ffe3b3a9c21596fd04371b18df4df6aecb31707a..e5a8ffae76d8d6a207606a6c68da5c0cb84d3161 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.hdf.model.hdftypes;
 
@@ -25,7 +23,7 @@ package org.apache.poi.hdf.model.hdftypes;
  * @author Ryan Ackley
  */
 
-public class HeaderFooter
+public final class HeaderFooter
 {
   public static final int HEADER_EVEN = 1;
   public static final int HEADER_ODD = 2;
index d582f9309433f41b413c7cba179362f0cea0088d..0294ed43d8386b9e3b0c3e20604dd7e92e46feb0 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -26,7 +23,7 @@ package org.apache.poi.hdf.model.hdftypes;
  * @author Ryan Ackley
  */
 
-public class LFO
+public final class LFO
 {
   int _lsid;
   int _clfolvl;
index 59026ba4ec1d57fddb06f0aacc9cebd3173d70b0..78425fa60f9b5c8d8347a8003341c9954c2f927c 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -26,7 +23,7 @@ package org.apache.poi.hdf.model.hdftypes;
  * @author Ryan Ackley
  */
 
-public class LFOLVL
+public final class LFOLVL
 {
   int _iStartAt;
   int _ilvl;
index dd7b5e3346e4484e00bee87b8172b1b4c34133b0..fd8405b97c4f0464af1e1cbb9b8a22137a0f2d44 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -26,7 +23,7 @@ package org.apache.poi.hdf.model.hdftypes;
  * @author Ryan Ackley
  */
 
-public class LST
+public final class LST
 {
   int _lsid;
   int _tplc;
index 408491e9e2d764d66afc21d428c5fa9d5a6b9323..68e891a0b1bebcff201406b83a79d5b51375d172 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -27,7 +24,7 @@ package org.apache.poi.hdf.model.hdftypes;
  */
 
 
-public class LVL
+public final class LVL
 {
   public int _iStartAt;
   public byte _nfc;
index 3767051e3789fbc7122a75f066bda205a76f3337..e8dbead5714e06d53dc4765608edbeed18e65030 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -31,7 +28,7 @@ import org.apache.poi.hdf.extractor.*;
  * @author Ryan Ackley
  */
 
-public class ListTables implements HDFType
+public final class ListTables implements HDFType
 {
 
   LFO[] _pllfo;
@@ -148,7 +145,7 @@ public class ListTables implements HDFType
             lfolvl._fFormatting = StyleSheet.getFlag(lfolvl._ilvl & 0x20);
             lfolvl._ilvl = (lfolvl._ilvl & (byte)0x0f);
             lfolvlNum++;
-    
+
             if(lfolvl._fFormatting)
             {
               // The size of a LFOLVL is 8 bytes.
@@ -175,7 +172,7 @@ public class ListTables implements HDFType
     lvl._fPrevSpace = StyleSheet.getFlag(code & 0x20);
     lvl._fWord6 = StyleSheet.getFlag(code & 0x40);
 
-    //  rgbxchNums - This array should be zero terminated unless it is full 
+    //  rgbxchNums - This array should be zero terminated unless it is full
     //  (all 9 levels full).
     System.arraycopy(data, offset, lvl._rgbxchNums, 0, 9);
     offset += 9;
index a91707d256ce1a50ca5d8d55f61052ff7c16c9dd..40b712f9de90856606958f00b321202c5ac6fc61 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hdf.model.hdftypes;
 
 import org.apache.poi.util.LittleEndian;
@@ -36,7 +35,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Ryan Ackley
  */
-public class PAPFormattedDiskPage extends FormattedDiskPage
+public final class PAPFormattedDiskPage extends FormattedDiskPage
 {
 
     /**
index df3c7ff46151f09622ad89b88a52d73cdc059b12..14a000f820afe77b2fcc4be47164b0d623b61eee 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -26,7 +23,7 @@ package org.apache.poi.hdf.model.hdftypes;
  * @author Ryan Ackley
  */
 
-public class PapxNode extends PropertyNode
+public final class PapxNode extends PropertyNode
 {
 
 
index 2d6901b07fe7446b5ddabf6f938d69c3c6f06cc0..ce4495ac34f8a246e457a8158409e47dd14a5257 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -27,7 +24,7 @@ import org.apache.poi.hdf.model.hdftypes.definitions.PAPAbstractType;
  * @author Ryan Ackley
  */
 
-public class ParagraphProperties  extends PAPAbstractType implements Cloneable
+public final class ParagraphProperties  extends PAPAbstractType implements Cloneable
 {
 
 
index 3fe2b53ea16d4713ae4266a8b2b29948297415cf..b757be7be6cb3c4daa8866401b4c41100d491cbb 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hdf.model.hdftypes;
 
 
@@ -29,7 +28,7 @@ package org.apache.poi.hdf.model.hdftypes;
  *
  * @author Ryan Ackley
  */
-public class PlexOfCps
+public final class PlexOfCps
 {
     private int _count;
     private int _offset;
index 19d65e2870b32de7767388c9f9ee92c7d9d220ae..d41e63d1edf7ead4d0cbdeb2f887ea8f9b4f10dd 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hdf.model.hdftypes;
 
 
@@ -25,8 +24,7 @@ package org.apache.poi.hdf.model.hdftypes;
  *
  * @author Ryan Ackley
  */
-public class PropertyNode implements Comparable
-{
+public abstract class PropertyNode implements Comparable {
   private byte[] _grpprl;
   private int _fcStart;
   private int _fcEnd;
index 455493d77b7671771f1a50a81444aeab409e1673..ec480cbc23d8bb538a7a680942946f6918d8c0ff 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -27,7 +24,7 @@ import org.apache.poi.hdf.model.hdftypes.definitions.SEPAbstractType;
  * @author Ryan Ackley
  */
 
-public class SectionProperties extends SEPAbstractType implements HDFType
+public final class SectionProperties extends SEPAbstractType implements HDFType
 {
   /*int _index;
   byte _bkc;
index 9b274af5cbcdb8e79c4d5dbf0cc5334d06cb8a3b..f7d293ce5024c9c44d284fd328831e7a80b151a7 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -26,7 +23,7 @@ package org.apache.poi.hdf.model.hdftypes;
  * @author Ryan Ackley
  */
 
-public class SepxNode extends PropertyNode
+public final class SepxNode extends PropertyNode
 {
 
   int _index;
index 5c967482eaed592757cd8db7bb759988948d286f..d3297c213231f1613bf354638c5701de643bdb00 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -27,7 +24,7 @@ import org.apache.poi.util.LittleEndian;
  * @author Ryan Ackley
  */
 
-public class StyleDescription implements HDFType
+public final class StyleDescription implements HDFType
 {
 
   private static int PARAGRAPH_STYLE = 1;
index c499988eed9758dea590fef83c44ffccab594d39..99607f837ce1f6262ab55ee015042e9512e6ed4f 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -33,7 +30,7 @@ import org.apache.poi.hdf.model.hdftypes.definitions.TCAbstractType;
  * @author Ryan Ackley
  */
 
-public class StyleSheet implements HDFType
+public final class StyleSheet implements HDFType
 {
 
   private static final int NIL_STYLE = 4095;
index 68ef449e926cc11c60e5d669b91d9dc59a36ab1e..c58f5f05bf0e8d51c5fd80a827acae3871aca18b 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -28,7 +25,7 @@ import org.apache.poi.util.LittleEndian;
  * @author Ryan Ackley
  */
 
-public class TableCellDescriptor extends TCAbstractType implements HDFType
+public final class TableCellDescriptor extends TCAbstractType implements HDFType
 {
 
   /*boolean _fFirstMerged;
index ce9f223f75add68c69dfd3b1c7e493553b5915cd..af029a290e76a535a6a6ab6e36ec4ece3217831b 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes;
 
@@ -28,7 +25,7 @@ import org.apache.poi.hdf.model.hdftypes.definitions.TAPAbstractType;
  * @author Ryan Ackley
  */
 
-public class TableProperties extends TAPAbstractType
+public final class TableProperties extends TAPAbstractType
 {
 
 
index 98f75e934f4e87ce557af96cac44459b07642704..61da53bc218083e5a4a9c65c1240b1cee6485128 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.hdf.model.hdftypes;
 
@@ -27,7 +25,7 @@ package org.apache.poi.hdf.model.hdftypes;
  * @author Ryan Ackley
  */
 
-public class TextPiece extends PropertyNode implements Comparable
+public final class TextPiece extends PropertyNode implements Comparable
 {
   private boolean _usesUnicode;
   private int _length;
index b940c11a7958708ddeb876ef35e563945647a4cf..d49c46f85f5a2bdcead1d9f300daa45f13d04080 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
index b08c8fec143109bc57128a658476496b4cec9360..0853175e47c8bac6ee4395b4f62cb268382c8592 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
index 8c83dad207c06a7519ce44232729b70130b3b737..6a0f92025b7e19a3fc69c91872053fe0a0ead983 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
index e442f2a5624f895d2d2755a9fc809f0b96b2fd85..f0bb7b8569c4a9438d1b3ed0de866b8c6b3995ba 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
index 728024ade4036398c04c0bde0ed5cd87c34be3b6..3de980e7d5a54cdcfd0ab5d6160c88eca479a3c7 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
index 87118a784cf3df72efcd145931c3aac44d0e48b8..d7d189627006518524138b6e485e0c7901f7b418 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
index 0f262fa00663e43084326ed9f7df9f7e09ede1d6..014958afc338243482618d790134939ea00abf5a 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.hdftypes.definitions;
 
index 548ce86497cd96f5b2809d88b4b913585a46ec9c..25d9612d104ee7993db8964cdfd11425751c7192 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.util;
 
@@ -39,7 +36,7 @@ import org.apache.poi.hdf.model.hdftypes.PropertyNode;
  *
 */
 
-public class BTreeSet extends AbstractSet
+public final class BTreeSet extends AbstractSet
 {
 
     /*
index 482787131c961693f007b119909d18349567bae1..48ccceb544aeaf6d08e1c567ad6c3129c165068b 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model.util;
 
@@ -27,7 +24,7 @@ package org.apache.poi.hdf.model.util;
  * @author Ryan Ackley
  */
 
-public class NumberFormatter
+public final class NumberFormatter
 {
   private final static int ARABIC = 0;
   private final static int UPPER_ROMAN = 1;
index 5ef7ef4d9f2addd33d7078584f6389ba93d5eeac..77950d7ed13cc56e0da80c554b8714ab5c0b3dae 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.hdf.model.util;
 
 import org.apache.poi.hdf.model.hdftypes.FormattedDiskPage;
 
-public class ParsingState
+public final class ParsingState
 {
 
   //int _numPages;// = charPlcf.length();
index 764b8e3f5ff60f655f8b76d6380dc51db4b2fab3..06bea56a6086ec6c087239b097ee32bfb37e0c2f 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf;
 
 import java.io.FileInputStream;
@@ -40,59 +41,59 @@ import org.apache.poi.util.LittleEndian;
  *  http://www.gnome.ru/projects/docs/slide1.png
  *  http://www.gnome.ru/projects/docs/slide2.png
  */
-public class HDGFDiagram extends POIDocument {
+public final class HDGFDiagram extends POIDocument {
        private static final String VISIO_HEADER = "Visio (TM) Drawing\r\n";
-       
+
        private byte[] _docstream;
-       
+
        private short version;
        private long docSize;
-       
+
        private Pointer trailerPointer;
        private TrailerStream trailer;
-       
+
        private ChunkFactory chunkFactory;
        private PointerFactory ptrFactory;
-       
+
        public HDGFDiagram(POIFSFileSystem fs) throws IOException {
                this(fs.getRoot(), fs);
        }
        public HDGFDiagram(DirectoryNode dir, POIFSFileSystem fs) throws IOException {
                super(dir, fs);
-               
+
                DocumentEntry docProps =
                        (DocumentEntry)dir.getEntry("VisioDocument");
 
                // Grab the document stream
                _docstream = new byte[docProps.getSize()];
                dir.createDocumentInputStream("VisioDocument").read(_docstream);
-               
+
                // Read in the common POI streams
                readProperties();
-               
+
                // Check it's really visio
                String typeString = new String(_docstream, 0, 20);
                if(! typeString.equals(VISIO_HEADER)) {
                        throw new IllegalArgumentException("Wasn't a valid visio document, started with " + typeString);
                }
-               
+
                // Grab the version number, 0x1a -> 0x1b
                version = LittleEndian.getShort(_docstream, 0x1a);
                // Grab the document size, 0x1c -> 0x1f
                docSize = LittleEndian.getUInt(_docstream, 0x1c);
                // ??? 0x20 -> 0x23
-               
+
                // Create the Chunk+Pointer Factories for the document version
                ptrFactory = new PointerFactory(version);
                chunkFactory = new ChunkFactory(version);
-               
+
                // Grab the pointer to the trailer
                trailerPointer = ptrFactory.createPointer(_docstream, 0x24);
-               
+
                // Now grab the trailer
                trailer = (TrailerStream)
                        Stream.createStream(trailerPointer, _docstream, chunkFactory, ptrFactory);
-               
+
                // Finally, find all our streams
                trailer.findChildren(_docstream);
        }
@@ -108,21 +109,21 @@ public class HDGFDiagram extends POIDocument {
         */
        public Stream[] getTopLevelStreams() { return trailer.getPointedToStreams(); }
        public long getDocumentSize() { return docSize; }
-       
+
        /**
         * Prints out some simple debug on the base contents of the file.
-        * @see org.apache.poi.hdgf.dev.VSDDumper 
+        * @see org.apache.poi.hdgf.dev.VSDDumper
         */
        public void debug() throws IOException {
                System.err.println("Trailer is at " + trailerPointer.getOffset());
                System.err.println("Trailer has type " + trailerPointer.getType());
                System.err.println("Trailer has length " + trailerPointer.getLength());
                System.err.println("Trailer has format " + trailerPointer.getFormat());
-               
+
                for(int i=0; i<trailer.getPointedToStreams().length; i++) {
                        Stream stream = trailer.getPointedToStreams()[i];
                        Pointer ptr = stream.getPointer();
-                       
+
                        System.err.println("Looking at pointer " + i);
                        System.err.println("\tType is " + ptr.getType() + "\t\t" + Integer.toHexString(ptr.getType()));
                        System.err.println("\tOffset is " + ptr.getOffset() + "\t\t" + Long.toHexString(ptr.getOffset()));
@@ -131,10 +132,10 @@ public class HDGFDiagram extends POIDocument {
                        System.err.println("\tFormat is " + ptr.getFormat() + "\t\t" + Long.toHexString(ptr.getFormat()));
                        System.err.println("\tCompressed is " + ptr.destinationCompressed());
                        System.err.println("\tStream is " + stream.getClass());
-                       
+
                        if(stream instanceof PointerContainingStream) {
                                PointerContainingStream pcs = (PointerContainingStream)stream;
-                               
+
                                if(pcs.getPointedToStreams() != null && pcs.getPointedToStreams().length > 0) {
                                        System.err.println("\tContains " + pcs.getPointedToStreams().length + " other pointers/streams");
                                        for(int j=0; j<pcs.getPointedToStreams().length; j++) {
@@ -145,7 +146,7 @@ public class HDGFDiagram extends POIDocument {
                                        }
                                }
                        }
-                       
+
                        if(stream instanceof StringsStream) {
                                System.err.println("\t\t**strings**");
                                StringsStream ss = (StringsStream)stream;
@@ -153,11 +154,11 @@ public class HDGFDiagram extends POIDocument {
                        }
                }
        }
-       
+
        public void write(OutputStream out) {
                throw new IllegalStateException("Writing is not yet implemented, see http://poi.apache.org/hdgf/");
        }
-       
+
        /**
         * For testing only
         */
index 5928927c4d6f029f4ed80e44ff24b940850e42b9..bb37e47b185bbe034ecb582fa27f4a785a4e4ea7 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.chunks;
 
 import java.util.ArrayList;
@@ -27,10 +28,10 @@ import org.apache.poi.util.StringUtil;
 /**
  * Base of all chunks, which hold data, flags etc
  */
-public class Chunk {
-       /** 
-        * The contents of the chunk, excluding the header, 
-        * trailer and separator 
+public final class Chunk {
+       /**
+        * The contents of the chunk, excluding the header,
+        * trailer and separator
         */
        private byte[] contents;
        private ChunkHeader header;
@@ -46,17 +47,17 @@ public class Chunk {
        //private Block[] blocks
        /** The name of the chunk, as found from the commandDefinitions */
        private String name;
-       
+
        /** For logging warnings about the structure of the file */
        private POILogger logger = POILogFactory.getLogger(Chunk.class);
-       
+
        public Chunk(ChunkHeader header, ChunkTrailer trailer, ChunkSeparator separator, byte[] contents) {
                this.header = header;
                this.trailer = trailer;
                this.separator = separator;
                this.contents = contents;
        }
-       
+
        public byte[] _getContents() {
                return contents;
        }
@@ -102,7 +103,7 @@ public class Chunk {
                }
                return size;
        }
-       
+
        /**
         * Uses our CommandDefinitions to process the commands
         *  our chunk type has, and figure out the
@@ -112,14 +113,14 @@ public class Chunk {
                if(commandDefinitions == null) {
                        throw new IllegalStateException("You must supply the command definitions before calling processCommands!");
                }
-               
+
                // Loop over the definitions, building the commands
                //  and getting their values
                ArrayList commands = new ArrayList();
                for(int i=0; i<commandDefinitions.length; i++) {
                        int type = commandDefinitions[i].getType();
                        int offset = commandDefinitions[i].getOffset();
-                       
+
                        // Handle virtual commands
                        if(type == 10) {
                                name = commandDefinitions[i].getName();
@@ -128,7 +129,7 @@ public class Chunk {
                                continue;
                        }
 
-                       
+
                        // Build the appropriate command for the type
                        Command command;
                        if(type == 11 || type == 21) {
@@ -136,7 +137,7 @@ public class Chunk {
                        } else {
                                command = new Command(commandDefinitions[i]);
                        }
-                       
+
                        // Bizarely, many of the offsets are from the start of the
                        //  header, not from the start of the chunk body
                        switch(type) {
@@ -151,15 +152,15 @@ public class Chunk {
                                        offset -= 19;
                                }
                        }
-                       
+
                        // Check we seem to have enough data
                        if(offset >= contents.length) {
-                               logger.log(POILogger.WARN, 
+                               logger.log(POILogger.WARN,
                                                "Command offset " + offset + " past end of data at " + contents.length
                                );
                                continue;
                        }
-               
+
                        // Process
                        switch(type) {
                        // Types 0->7 = a flat at bit 0->7
@@ -189,7 +190,7 @@ public class Chunk {
                                if(endsAt == startsAt) {
                                        endsAt = contents.length;
                                }
-                               
+
                                int strLen = (endsAt-startsAt) / 2;
                                command.value = StringUtil.getFromUnicodeLE(contents, startsAt, strLen);
                                break;
@@ -203,7 +204,7 @@ public class Chunk {
                                                LittleEndian.getInt(contents, offset)
                                );
                                break;
-                               
+
                        // Types 11 and 21 hold the offset to the blocks
                        case 11: case 21:
                                if(offset < contents.length - 3) {
@@ -212,26 +213,26 @@ public class Chunk {
                                        bcmd.setOffset(bOffset);
                                }
                                break;
-                               
+
                        default:
-                               logger.log(POILogger.INFO, 
+                               logger.log(POILogger.INFO,
                                                "Command of type " + type + " not processed!");
                        }
-                       
+
                        // Add to the array
                        commands.add(command);
                }
-               
+
                // Save the commands we liked the look of
                this.commands = (Command[])commands.toArray(
                                                        new Command[commands.size()] );
-               
+
                // Now build up the blocks, if we had a command that tells
                //  us where a block is
        }
-       
+
        /**
-        * A command in the visio file. In order to make things fun, 
+        * A command in the visio file. In order to make things fun,
         *  all the chunk actually stores is the value of the command.
         * You have to have your own lookup table to figure out what
         *  the commands are based on the chunk type.
@@ -239,7 +240,7 @@ public class Chunk {
        public static class Command {
                protected Object value;
                private CommandDefinition definition;
-               
+
                private Command(CommandDefinition definition, Object value) {
                        this.definition = definition;
                        this.value = value;
@@ -247,7 +248,7 @@ public class Chunk {
                private Command(CommandDefinition definition) {
                        this(definition, null);
                }
-               
+
                public CommandDefinition getDefinition() { return definition; }
                public Object getValue() { return value; }
        }
index 34a2f4f89360dc86f4a384771fb02177a1665446..d2779c88b0e5f2eaf1ee05fb9d75fa4e5bfab353 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.chunks;
 
 import java.io.BufferedReader;
@@ -34,32 +35,32 @@ import org.apache.poi.util.POILogger;
  * Makes use of chunks_parse_cmds.tbl from vsdump to be able
  *  to process the chunk value area
  */
-public class ChunkFactory {
+public final class ChunkFactory {
        /** The version of the currently open document */
        private int version;
        /**
         * Key is a Chunk's type, value is an array of its CommandDefinitions
         */
        private Hashtable chunkCommandDefinitions = new Hashtable();
-       /** 
-        * What the name is of the chunk table definitions file? 
+       /**
+        * What the name is of the chunk table definitions file?
         * This file comes from the scratchpad resources directory.
         */
-       private static String chunkTableName = 
+       private static String chunkTableName =
                "/org/apache/poi/hdgf/chunks_parse_cmds.tbl";
-       
+
        /** For logging problems we spot with the file */
        private POILogger logger = POILogFactory.getLogger(ChunkFactory.class);
-       
+
        public ChunkFactory(int version) throws IOException {
                this.version = version;
-               
+
                processChunkParseCommands();
        }
-       
-       /** 
+
+       /**
         * Open chunks_parse_cmds.tbl and process it, to get the definitions
-        *  of all the different possible chunk commands. 
+        *  of all the different possible chunk commands.
         */
        private void processChunkParseCommands() throws IOException {
                String line;
@@ -67,7 +68,7 @@ public class ChunkFactory {
                if(cpd == null) {
                        throw new IllegalStateException("Unable to find HDGF chunk definition on the classpath - " + chunkTableName);
                }
-               
+
                BufferedReader inp = new BufferedReader(new InputStreamReader(cpd));
                while( (line = inp.readLine()) != null ) {
                        if(line.startsWith("#")) continue;
@@ -81,28 +82,28 @@ public class ChunkFactory {
                        }
                        int chunkType = Integer.parseInt(line.substring(6));
                        ArrayList defsL = new ArrayList();
-                       
+
                        // Data entries
                        while( ! (line = inp.readLine()).startsWith("end") ) {
                                StringTokenizer st = new StringTokenizer(line, " ");
                                int defType = Integer.parseInt(st.nextToken());
                                int offset = Integer.parseInt(st.nextToken());
                                String name = st.nextToken("\uffff").substring(1);
-                               
+
                                CommandDefinition def = new CommandDefinition(defType,offset,name);
                                defsL.add(def);
                        }
-                       
+
                        CommandDefinition[] defs = (CommandDefinition[])
                                defsL.toArray(new CommandDefinition[defsL.size()]);
-                       
+
                        // Add to the hashtable
                        chunkCommandDefinitions.put(new Integer(chunkType), defs);
                }
                inp.close();
                cpd.close();
        }
-       
+
        public int getVersion() { return version; }
 
        /**
@@ -112,25 +113,25 @@ public class ChunkFactory {
         */
        public Chunk createChunk(byte[] data, int offset) {
                // Create the header
-               ChunkHeader header = 
+               ChunkHeader header =
                        ChunkHeader.createChunkHeader(version, data, offset);
                // Sanity check
                if(header.length < 0) {
                        throw new IllegalArgumentException("Found a chunk with a negative length, which isn't allowed");
                }
-               
+
                // How far up to look
                int endOfDataPos = offset + header.getLength() + header.getSizeInBytes();
-               
+
                // Check we have enough data, and tweak the header size
                //  as required
                if(endOfDataPos > data.length) {
                        logger.log(POILogger.WARN,
                                "Header called for " + header.getLength() +" bytes, but that would take us passed the end of the data!");
-                       
+
                        endOfDataPos = data.length;
                        header.length = data.length - offset - header.getSizeInBytes();
-                       
+
                        if(header.hasTrailer()) {
                                header.length -= 8;
                                endOfDataPos  -= 8;
@@ -140,7 +141,7 @@ public class ChunkFactory {
                                endOfDataPos  -= 4;
                        }
                }
-               
+
 
                // Create the trailer and separator, if required
                ChunkTrailer trailer = null;
@@ -167,20 +168,20 @@ public class ChunkFactory {
                byte[] contents = new byte[header.getLength()];
                System.arraycopy(data, offset+header.getSizeInBytes(), contents, 0, contents.length);
                Chunk chunk = new Chunk(header, trailer, separator, contents);
-               
+
                // Feed in the stuff from  chunks_parse_cmds.tbl
                CommandDefinition[] defs = (CommandDefinition[])
                        chunkCommandDefinitions.get(new Integer(header.getType()));
                if(defs == null) defs = new CommandDefinition[0];
                chunk.commandDefinitions = defs;
-               
+
                // Now get the chunk to process its commands
                chunk.processCommands();
-               
+
                // All done
                return chunk;
        }
-       
+
        /**
         * The definition of a Command, which a chunk may hold.
         * The Command holds the value, this describes it.
@@ -194,7 +195,7 @@ public class ChunkFactory {
                        this.offset = offset;
                        this.name = name;
                }
-               
+
                public String getName() {
                        return name;
                }
index 88c91c74f9bb256e6942b75ad2ae6459d34e0845..7808ce847daf89800b1a804bef8b87aeed558dd4 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.chunks;
 
 import org.apache.poi.util.LittleEndian;
@@ -26,7 +27,7 @@ public abstract class ChunkHeader {
        protected int id;
        protected int length;
        protected int unknown1;
-       
+
        /**
         * Creates the appropriate ChunkHeader for the Chunk Header at
         *  the given location, for the given document version.
@@ -45,24 +46,24 @@ public abstract class ChunkHeader {
                        ch.length   = (int)LittleEndian.getUInt(data, offset + 12);
                        ch.unknown2 = LittleEndian.getShort(data, offset + 16);
                        ch.unknown3 = (short)LittleEndian.getUnsignedByte(data, offset + 18);
-                       
+
                        return ch;
                } else if(documentVersion == 5 || documentVersion == 4) {
                        ChunkHeaderV4V5 ch = new ChunkHeaderV4V5();
-                       
+
                        ch.type = (int)LittleEndian.getShort(data, offset + 0);
                        ch.id   = (int)LittleEndian.getShort(data, offset + 2);
                        ch.unknown2 = (short)LittleEndian.getUnsignedByte(data, offset + 4);
                        ch.unknown3 = (short)LittleEndian.getUnsignedByte(data, offset + 5);
                        ch.unknown1 = (short)LittleEndian.getShort(data, offset + 6);
                        ch.length   = (int)LittleEndian.getUInt(data, offset + 8);
-                       
+
                        return ch;
                } else {
                        throw new IllegalArgumentException("Visio files with versions below 4 are not supported, yours was " + documentVersion);
                }
        }
-       
+
        /**
         * Returns the size of a chunk header for the given document version.
         */
@@ -75,11 +76,11 @@ public abstract class ChunkHeader {
                        return ChunkHeaderV4V5.getHeaderSize();
                }
        }
-       
+
        public abstract int getSizeInBytes();
        public abstract boolean hasTrailer();
        public abstract boolean hasSeparator();
-       
+
        /**
         * Returns the ID/IX of the chunk
         */
index c77a249204bbbaa2d4c6445e3220a98440dee64f..1d3b763ece5562a3b5b4e246dd69ec2e193c23a0 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.chunks;
 
 /**
  * A chunk header from v11+
  */
-public class ChunkHeaderV11 extends ChunkHeaderV6 {
+public final class ChunkHeaderV11 extends ChunkHeaderV6 {
        /**
         * Does the chunk have a separator?
         */
        public boolean hasSeparator() {
-               // For some reason, there are two types that don't have a 
+               // For some reason, there are two types that don't have a
                //  separator despite the flags that indicate they do
                if(type == 0x1f || type == 0xc9) { return false; }
-               
+
                // If there's a trailer, there's a separator
                if(hasTrailer()) { return true; }
 
@@ -35,7 +36,7 @@ public class ChunkHeaderV11 extends ChunkHeaderV6 {
                if(unknown2 == 2 && unknown3 == 0x54 && type == 0xaa) { return true; }
                if(unknown2 == 3 && unknown3 != 0x50) { return true; }
                if(type == 0x69) { return true; }
-               
+
                return false;
        }
 }
index 335c9c543e24db8d00d0beaf806aec678665d573..7162f5056fba309b84f36ef733718969199ee04b 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.chunks;
 
 /**
  * A chunk header from v4 or v5
  */
-public class ChunkHeaderV4V5 extends ChunkHeader {
+public final class ChunkHeaderV4V5 extends ChunkHeader {
        protected short unknown2;
        protected short unknown3;
 
@@ -29,15 +30,15 @@ public class ChunkHeaderV4V5 extends ChunkHeader {
        public short getUnknown3() {
                return unknown3;
        }
-       
+
        protected static int getHeaderSize() {
                return 12;
        }
-       
+
        public int getSizeInBytes() {
                return getHeaderSize();
        }
-       
+
        /**
         * Does the chunk have a trailer?
         */
@@ -45,7 +46,7 @@ public class ChunkHeaderV4V5 extends ChunkHeader {
                // V4 and V5 never has trailers
                return false;
        }
-       
+
        /**
         * Does the chunk have a separator?
         */
index 4d13b85bd232c6b19c2a858810a5b8695551e046..cfbae6e04c90efc6e7651b48352a7cd8c8191907 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.chunks;
 
 /**
@@ -29,7 +30,7 @@ public class ChunkHeaderV6 extends ChunkHeader {
        public short getUnknown3() {
                return unknown3;
        }
-       
+
        protected static int getHeaderSize() {
                // Looks like it ought to be 19...
                return 19;
@@ -37,7 +38,7 @@ public class ChunkHeaderV6 extends ChunkHeader {
        public int getSizeInBytes() {
                return getHeaderSize();
        }
-       
+
        /**
         * Does the chunk have a trailer?
         */
index 5ce4097446915130e20ad6c57dd07b75f43ff4f5..bf49ceac4804aa1e93fd5949a52f724e95e66893 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.chunks;
 
 /**
  * A separator between the trailer of one chunk, and the
  *  header of the next one
  */
-public class ChunkSeparator {
+public final class ChunkSeparator {
        protected byte[] separatorData;
-       
+
        public ChunkSeparator(byte[] data, int offset) {
                separatorData = new byte[4];
                System.arraycopy(data, offset, separatorData, 0, 4);
        }
-       
+
        public String toString() {
                return "<ChunkSeparator of length " + separatorData.length + ">";
        }
index a590732466b9b58ddbd2a354ff0acf5263f27c85..ad3441d88da737c561865587494841d65eaf79c1 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.chunks;
 
 /**
  * A trailer that follows a chunk
  */
-public class ChunkTrailer {
+public final class ChunkTrailer {
        protected byte[] trailerData;
-       
+
        public ChunkTrailer(byte[] data, int offset) {
                trailerData = new byte[8];
                System.arraycopy(data, offset, trailerData, 0, 8);
        }
-       
+
        public String toString() {
                return "<ChunkTrailer of length " + trailerData.length + ">";
        }
index 614b9259a0cdada28c326f5b2f8fb2cd9d9e2295..ed5e700d06f6c20ae81d61880da0a7c06ee9c3a2 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.dev;
 
 import java.io.FileInputStream;
@@ -31,27 +32,27 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  * Developer helper class to dump out the pointer+stream structure
  *  of a Visio file
  */
-public class VSDDumper {
+public final class VSDDumper {
        public static void main(String[] args) throws Exception {
                if(args.length == 0) {
                        System.err.println("Use:");
                        System.err.println("  VSDDumper <filename>");
                        System.exit(1);
                }
-               
+
                HDGFDiagram hdgf = new HDGFDiagram(
                                new POIFSFileSystem(new FileInputStream(args[0]))
                );
-               
+
                System.out.println("Opened " + args[0]);
                System.out.println("The document claims a size of " +
-                               hdgf.getDocumentSize() + "   (" + 
+                               hdgf.getDocumentSize() + "   (" +
                                Long.toHexString(hdgf.getDocumentSize()) + ")");
                System.out.println();
-               
+
                dumpStream(hdgf.getTrailerStream(), 0);
        }
-       
+
        public static void dumpStream(Stream stream, int indent) {
                String ind = "";
                for(int i=0; i<indent; i++) {
@@ -59,8 +60,8 @@ public class VSDDumper {
                }
                String ind2 = ind  + "    ";
                String ind3 = ind2 + "    ";
-               
-               
+
+
                Pointer ptr = stream.getPointer();
                System.out.println(ind + "Stream at\t" + ptr.getOffset() +
                                " - " + Integer.toHexString(ptr.getOffset()));
@@ -77,7 +78,7 @@ public class VSDDumper {
                }
                System.out.println(ind + "  Compressed is\t" + ptr.destinationCompressed());
                System.out.println(ind + "  Stream is\t" + stream.getClass().getName());
-               
+
                byte[] db = stream._getStore()._getContents();
                String ds = "";
                if(db.length >= 8) {
@@ -87,12 +88,12 @@ public class VSDDumper {
                        }
                }
                System.out.println(ind + "  First few bytes are\t" + ds);
-               
+
                if(stream instanceof PointerContainingStream) {
                        PointerContainingStream pcs = (PointerContainingStream)stream;
-                       System.out.println(ind + "  Has " + 
+                       System.out.println(ind + "  Has " +
                                        pcs.getPointedToStreams().length + " children:");
-                       
+
                        for(int i=0; i<pcs.getPointedToStreams().length; i++) {
                                dumpStream(pcs.getPointedToStreams()[i], (indent+1));
                        }
@@ -101,7 +102,7 @@ public class VSDDumper {
                        ChunkStream cs = (ChunkStream)stream;
                        System.out.println(ind + "  Has " + cs.getChunks().length +
                                        " chunks:");
-                       
+
                        for(int i=0; i<cs.getChunks().length; i++) {
                                Chunk chunk = cs.getChunks()[i];
                                System.out.println(ind2 + "" + chunk.getName());
@@ -111,7 +112,7 @@ public class VSDDumper {
                                System.out.println(ind2 + "  Holds " + chunk.getCommands().length + " commands");
                                for(int j=0; j<chunk.getCommands().length; j++) {
                                        Command command = chunk.getCommands()[j];
-                                       System.out.println(ind3 + "" + 
+                                       System.out.println(ind3 + "" +
                                                        command.getDefinition().getName() +
                                                        " " + command.getValue()
                                        );
index ae22b95cad907a33f77b9f3c523491c6ee8508e6..c893bd2dfb0cd39eeb640c54a601e033863e58d1 100644 (file)
@@ -1,44 +1,43 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-\r
-package org.apache.poi.hdgf.exceptions;\r
-\r
-/**\r
- * The superclass of all HDGF exceptions\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class HDGFException extends RuntimeException {\r
-\r
-    public HDGFException() {\r
-           super();\r
-    }\r
-\r
-   public HDGFException(String message) {\r
-           super(message);\r
-    }\r
-\r
-   public HDGFException(String message, Throwable cause) {\r
-        super(message, cause);\r
-    }\r
-\r
-    public HDGFException(Throwable cause) {\r
-        super(cause);\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.hdgf.exceptions;
+
+/**
+ * The superclass of all HDGF exceptions
+ *
+ * @author Yegor Kozlov
+ */
+public final class HDGFException extends RuntimeException {
+
+    public HDGFException() {
+           super();
+    }
+
+   public HDGFException(String message) {
+           super(message);
+    }
+
+   public HDGFException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public HDGFException(Throwable cause) {
+        super(cause);
+    }
+
+}
index 9b861d6d62e83f2230cf046ac253b82186cd26b9..c83257f5a32a280983498d9a7ab57a29b19aa8e4 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.extractor;
 
 import java.io.FileInputStream;
@@ -36,7 +37,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  * Can opperate on the command line (outputs to stdout), or
  *  can return the text for you (eg for use with Lucene).
  */
-public class VisioTextExtractor extends POIOLE2TextExtractor {
+public final class VisioTextExtractor extends POIOLE2TextExtractor {
        private HDGFDiagram hdgf;
        private POIFSFileSystem fs;
 
@@ -54,7 +55,7 @@ public class VisioTextExtractor extends POIOLE2TextExtractor {
        public VisioTextExtractor(InputStream inp) throws IOException {
                this(new POIFSFileSystem(inp));
        }
-       
+
        /**
         * Locates all the text entries in the file, and returns their
         *  contents.
@@ -77,7 +78,7 @@ public class VisioTextExtractor extends POIOLE2TextExtractor {
                        ChunkStream cs = (ChunkStream)stream;
                        for(int i=0; i<cs.getChunks().length; i++) {
                                Chunk chunk = cs.getChunks()[i];
-                               if(chunk != null && 
+                               if(chunk != null &&
                                                chunk.getName() != null &&
                                                chunk.getName().equals("Text") &&
                                                chunk.getCommands().length > 0) {
@@ -90,7 +91,7 @@ public class VisioTextExtractor extends POIOLE2TextExtractor {
                        }
                }
        }
-       
+
        /**
         * Returns the textual contents of the file.
         * Each textual object's text will be separated
@@ -108,17 +109,17 @@ public class VisioTextExtractor extends POIOLE2TextExtractor {
                }
                return text.toString();
        }
-       
+
        public static void main(String[] args) throws Exception {
                if(args.length == 0) {
                        System.err.println("Use:");
                        System.err.println("   VisioTextExtractor <file.vsd>");
                        System.exit(1);
                }
-               
-               VisioTextExtractor extractor = 
+
+               VisioTextExtractor extractor =
                        new VisioTextExtractor(new FileInputStream(args[0]));
-               
+
                // Print not PrintLn as already has \n added to it
                System.out.print(extractor.getText());
        }
index 848d52b869affd652dc0f0f8f590200422a9a6dd..d10f154e2e12b326b3f6f0d500b99a13ef06b880 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.pointers;
 
 /**
- * Base class of pointers, which hold metadata and offsets about 
+ * Base class of pointers, which hold metadata and offsets about
  *  blocks elsewhere in the file
  */
 public abstract class Pointer {
@@ -26,7 +27,7 @@ public abstract class Pointer {
        protected int offset;
        protected int length;
        protected short format;
-       
+
        public int getAddress() {
                return address;
        }
@@ -42,7 +43,7 @@ public abstract class Pointer {
        public int getType() {
                return type;
        }
-       
+
        public abstract int getSizeInBytes();
        public abstract boolean destinationHasStrings();
        public abstract boolean destinationHasPointers();
index 58e863907ef4edb8d5d8e640dd033ff2f998eaa7..fb97d6e2b8eba2eab9fede7dd27ead45f75e61e0 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.pointers;
 
 import org.apache.poi.util.LittleEndian;
@@ -22,13 +23,13 @@ import org.apache.poi.util.LittleEndian;
  * Factor class to create the appropriate pointers, based on the version
  *  of the file
  */
-public class PointerFactory {
+public final class PointerFactory {
        private int version;
        public PointerFactory(int version) {
                this.version = version;
        }
        public int getVersion() { return version; }
-       
+
        public Pointer createPointer(byte[] data, int offset) {
                Pointer p;
                if(version >= 6) {
@@ -38,7 +39,7 @@ public class PointerFactory {
                        p.offset = (int)LittleEndian.getUInt(data, offset+8);
                        p.length = (int)LittleEndian.getUInt(data, offset+12);
                        p.format = LittleEndian.getShort(data, offset+16);
-                       
+
                        return p;
                } else if(version == 5) {
                        throw new RuntimeException("TODO");
index 5f6ab18cf212e26ada5fddd4af2f384448617339..75445dcd117a9b159a1442855d60c82c8307d43b 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.pointers;
 
 /**
- * A Pointer from v6+ 
+ * A Pointer from v6+
  */
-public class PointerV6 extends Pointer {
+public final class PointerV6 extends Pointer {
        public boolean destinationHasStrings() {
                return (0x40 <= format && format < 0x50);
        }
@@ -31,12 +32,12 @@ public class PointerV6 extends Pointer {
        public boolean destinationHasChunks() {
                return (0xd0 <= format && format < 0xdf);
        }
-       
+
        public boolean destinationCompressed() {
                // Apparently, it's the second least significant bit
                return (format & 2) > 0;
        }
-       
+
        /**
         * With v6 pointers, the on-disk size is 18 bytes
         */
index 65b69d95adc28a256c46dd5e6abcd7d4f1bea7d7..0f7a92da95439f40d56854d59b04e9a4d0ea4201 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.streams;
 
 import java.util.ArrayList;
@@ -23,32 +24,32 @@ import org.apache.poi.hdgf.chunks.ChunkFactory;
 import org.apache.poi.hdgf.chunks.ChunkHeader;
 import org.apache.poi.hdgf.pointers.Pointer;
 
-public class ChunkStream extends Stream {
+public final class ChunkStream extends Stream {
        private ChunkFactory chunkFactory;
        /** All the Chunks we contain */
        private Chunk[] chunks;
-       
+
        protected ChunkStream(Pointer pointer, StreamStore store, ChunkFactory chunkFactory) {
                super(pointer, store);
                this.chunkFactory = chunkFactory;
-               
+
                // For compressed stores, we require all of the data
                store.copyBlockHeaderToContents();
        }
-       
+
        public Chunk[] getChunks() { return chunks; }
-       
+
        /**
         * Process the contents of the stream out into chunks
         */
        public void findChunks() {
                ArrayList chunksA = new ArrayList();
-               
+
                if(getPointer().getOffset() == 0x64b3) {
                        int i = 0;
                        i++;
                }
-               
+
                int pos = 0;
                byte[] contents = getStore().getContents();
                while(pos < contents.length) {
@@ -57,14 +58,14 @@ public class ChunkStream extends Stream {
                        if(pos+headerSize <= contents.length) {
                                Chunk chunk = chunkFactory.createChunk(contents, pos);
                                chunksA.add(chunk);
-                               
+
                                pos += chunk.getOnDiskSize();
                        } else {
                                System.err.println("Needed " + headerSize + " bytes to create the next chunk header, but only found " + (contents.length-pos) + " bytes, ignoring rest of data");
                                pos = contents.length;
                        }
                }
-               
+
                chunks = (Chunk[])chunksA.toArray(new Chunk[chunksA.size()]);
        }
 }
index 4bf70417dda148d1d72b633938601eea86c5693e..da6f3c11a59aed63661a3b7bf5a3781d5c8ace90 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.streams;
 
 import java.io.ByteArrayInputStream;
@@ -25,26 +26,26 @@ import org.apache.poi.hdgf.HDGFLZW;
  * A StreamStore where the data on-disk is compressed,
  *  using the crazy Visio LZW
  */
-public class CompressedStreamStore extends StreamStore {
+public final class CompressedStreamStore extends StreamStore {
        /** The raw, compressed contents */
        private byte[] compressedContents;
-       /** 
+       /**
         * We're not sure what this is, but it comes before the
         *  real contents in the de-compressed data
         */
        private byte[] blockHeader = new byte[4];
        private boolean blockHeaderInContents = false;
-       
+
        protected byte[] _getCompressedContents() { return compressedContents; }
        protected byte[] _getBlockHeader() { return blockHeader; }
-       
+
        /**
         * Creates a new compressed StreamStore, which will handle
         *  the decompression.
         */
        protected CompressedStreamStore(byte[] data, int offset, int length) throws IOException {
                this(decompress(data,offset,length));
-               
+
                compressedContents = new byte[length];
                System.arraycopy(data, offset, compressedContents, 0, length);
        }
@@ -55,7 +56,7 @@ public class CompressedStreamStore extends StreamStore {
                super(decompressedData[1], 0, decompressedData[1].length);
                blockHeader = decompressedData[0];
        }
-       
+
        /**
         * Some kinds of streams expect their 4 byte header to be
         *  on the front of the contents.
@@ -63,31 +64,31 @@ public class CompressedStreamStore extends StreamStore {
         */
        protected void copyBlockHeaderToContents() {
                if(blockHeaderInContents) return;
-               
+
                prependContentsWith(blockHeader);
                blockHeaderInContents = true;
        }
-       
+
 
        /**
         * Decompresses the given data, returning it as header + contents
         */
        public static byte[][] decompress(byte[] data, int offset, int length) throws IOException {
                ByteArrayInputStream bais = new ByteArrayInputStream(data, offset, length);
-               
+
                // Decompress
                HDGFLZW lzw = new HDGFLZW();
                byte[] decompressed = lzw.decode(bais);
-               
+
                // Split into header and contents
                byte[][] ret = new byte[2][];
                ret[0] = new byte[4];
                ret[1] = new byte[decompressed.length - 4];
-               
+
                System.arraycopy(decompressed, 0, ret[0], 0, 4);
                System.arraycopy(decompressed, 4, ret[1], 0, ret[1].length);
-               
+
                // All done
                return ret;
        }
-}
\ No newline at end of file
+}
index 761eb181f926ec321f0d6fe08d3f816608502bc3..ff8da5e983f819fa082bdd88d4c96b71facb1927 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.streams;
 
 import org.apache.poi.hdgf.chunks.ChunkFactory;
@@ -25,35 +26,35 @@ import org.apache.poi.util.LittleEndian;
  * A stream that holds pointers, possibly in addition to some
  *  other data too.
  */
-public class PointerContainingStream extends Stream {
+public class PointerContainingStream extends Stream { // TODO - instantiable superclass
        private Pointer[] childPointers;
        private Stream[] childStreams;
-       
+
        private ChunkFactory chunkFactory;
        private PointerFactory pointerFactory;
        private int numPointersLocalOffset;
-       
+
        protected PointerContainingStream(Pointer pointer, StreamStore store, ChunkFactory chunkFactory, PointerFactory pointerFactory) {
                super(pointer, store);
                this.chunkFactory = chunkFactory;
                this.pointerFactory = pointerFactory;
-               
+
                // Find the offset to the number of child pointers we have
                // This ought to be the first thing stored in us
                numPointersLocalOffset = (int)LittleEndian.getUInt(
                                store.getContents(), 0
                );
-               
+
                // Generate the objects for the pointers we contain
                int numPointers = (int)LittleEndian.getUInt(
                                store.getContents(), numPointersLocalOffset
                );
                childPointers = new Pointer[numPointers];
-               
+
                // After the number of pointers is another (unknown)
                //  4 byte value
                int pos = numPointersLocalOffset + 4 + 4;
-               
+
                // Now create the pointer objects
                for(int i=0; i<numPointers; i++) {
                        childPointers[i] = pointerFactory.createPointer(
@@ -62,7 +63,7 @@ public class PointerContainingStream extends Stream {
                        pos += childPointers[i].getSizeInBytes();
                }
        }
-       
+
        /**
         * Returns all the pointers that we contain
         */
@@ -72,8 +73,8 @@ public class PointerContainingStream extends Stream {
         * These are all the streams pointed to by the pointers
         *  that we contain.
         */
-       public Stream[] getPointedToStreams() { return childStreams; } 
-       
+       public Stream[] getPointedToStreams() { return childStreams; }
+
        /**
         * Performs a recursive search, identifying the pointers we contain,
         *  creating the Streams for where they point to, then searching
@@ -85,16 +86,16 @@ public class PointerContainingStream extends Stream {
                for(int i=0; i<childPointers.length; i++) {
                        Pointer ptr = childPointers[i];
                        childStreams[i] = Stream.createStream(ptr, documentData, chunkFactory, pointerFactory);
-                       
+
                        // Process chunk streams into their chunks
                        if(childStreams[i] instanceof ChunkStream) {
                                ChunkStream child = (ChunkStream)childStreams[i];
                                child.findChunks();
                        }
-                       
+
                        // Recurse into pointer containing streams
                        if(childStreams[i] instanceof PointerContainingStream) {
-                               PointerContainingStream child = 
+                               PointerContainingStream child =
                                        (PointerContainingStream)childStreams[i];
                                child.findChildren(documentData);
                        }
index 163fa83d9a19104259506a56ea349316c2154a9f..abd7f19e2c225f6adfa1000f64c495861b038ea2 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.streams;
 
 import java.io.IOException;
@@ -33,21 +34,21 @@ import org.apache.poi.hdgf.exceptions.HDGFException;
 public abstract class Stream {
        private Pointer pointer;
        private StreamStore store;
-       
+
        public Pointer getPointer() { return pointer; }
        protected StreamStore getStore() { return store; }
        public StreamStore _getStore() { return store; }
        public int _getContentsLength() { return store.getContents().length; }
-       
+
        /**
         * Creates a new Stream, having already used the pointer
-        *  to build a store 
+        *  to build a store
         */
        protected Stream(Pointer pointer, StreamStore store) {
                this.pointer = pointer;
                this.store = store;
        }
-       
+
        /**
         * Uses the pointer to locate a Stream within the document
         *  data, and creates it.
@@ -71,7 +72,7 @@ public abstract class Stream {
                                        documentData, pointer.getOffset(), pointer.getLength()
                        );
                }
-               
+
                // Figure out what sort of Stream to create, create and return it
                if(pointer.getType() == 20) {
                        return new TrailerStream(pointer, store, chunkFactory, pointerFactory);
@@ -80,12 +81,12 @@ public abstract class Stream {
                        return new PointerContainingStream(pointer, store, chunkFactory, pointerFactory);
                }
                else if(pointer.destinationHasChunks()) {
-                       return new ChunkStream(pointer, store, chunkFactory); 
+                       return new ChunkStream(pointer, store, chunkFactory);
                }
                else if(pointer.destinationHasStrings()) {
                        return new StringsStream(pointer, store, chunkFactory);
                }
-               
+
                // Give up and return a generic one
                return new UnknownStream(pointer, store);
        }
index 41532d8b0d1df9c936d7e9bc2f8e38b6c384b112..1c4e4e7ed8f8a1be482b7d95ab6edbd0bdd6f140 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.streams;
 
 /**
@@ -21,9 +22,9 @@ package org.apache.poi.hdgf.streams;
  *  handles de-compressing it as required.
  * In future, may also handle writing it back out again
  */
-public class StreamStore {
+public class StreamStore { // TODO - instantiable superclass
        private byte[] contents;
-       
+
        /**
         * Creates a new, non compressed Stream Store
         */
@@ -31,7 +32,7 @@ public class StreamStore {
                contents = new byte[length];
                System.arraycopy(data, offset, contents, 0, length);
        }
-       
+
        protected void prependContentsWith(byte[] b) {
                byte[] newContents = new byte[contents.length + b.length];
                System.arraycopy(b, 0, newContents, 0, b.length);
@@ -39,7 +40,7 @@ public class StreamStore {
                contents = newContents;
        }
        protected void copyBlockHeaderToContents() {}
-       
+
        protected byte[] getContents() { return contents; }
        public byte[] _getContents() { return contents; }
-}
\ No newline at end of file
+}
index b23ff921493b84a5ab9968fa4b4873bdc78b5d94..ac6386adc4763c545740b005ced5fa1f5af9e00f 100644 (file)
@@ -1,19 +1,20 @@
 /* ====================================================================
-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
+   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
+       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.
+   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.hdgf.streams;
 
 import org.apache.poi.hdgf.chunks.ChunkFactory;
@@ -23,7 +24,7 @@ import org.apache.poi.hdgf.pointers.Pointer;
  * A Stream which holds Strings. This is just another kind
  *  of ChunkStream, it seems
  */
-public class StringsStream extends Stream {
+public final class StringsStream extends Stream {
        protected StringsStream(Pointer pointer, StreamStore store, ChunkFactory chunkFactory) {
                super(pointer, store);
 //             super(pointer, store, chunkFactory);
index e754851dc842d14db20604dfac000da658d68323..9e772c2f188a92e76f29f3ef16a3515d2639a464 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.streams;
 
 import org.apache.poi.hdgf.chunks.ChunkFactory;
@@ -26,7 +27,7 @@ import org.apache.poi.hdgf.pointers.PointerFactory;
  * These is one of these in each document, and it's pointed to by
  *  a special series of byte near the start of the file.
  */
-public class TrailerStream extends PointerContainingStream {
+public class TrailerStream extends PointerContainingStream { // TODO - instantiable superclass
        protected TrailerStream(Pointer pointer, StreamStore store, ChunkFactory chunkFactory, PointerFactory pointerFactory) {
                super(pointer, store, chunkFactory, pointerFactory);
        }
index d7eef9b554d66853d93ee5e0a8c3f4f73ba28c3d..e08d7f93c7120254da3312cb04e775bc59425c21 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.streams;
 
 import org.apache.poi.hdgf.pointers.Pointer;
 
 /**
- * A placeholder for a stream where we don't known anything 
+ * A placeholder for a stream where we don't known anything
  *  about how to process / handle it
  */
-public class UnknownStream extends Stream {
+public final class UnknownStream extends Stream {
        protected UnknownStream(Pointer pointer, StreamStore store) {
                super(pointer, store);
        }
index 49de0d087672d63d8815ed8c00e91acfd7a0efc7..a27b61518ef7d387177bfedeba76e2543a22de5c 100644 (file)
@@ -30,16 +30,16 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
 /**
- * This class provides the basic functionality 
+ * This class provides the basic functionality
  *  for HPBF, our implementation of the publisher
- *  file format. 
+ *  file format.
  */
 public final class HPBFDocument extends POIDocument {
        private MainContents mainContents;
        private QuillContents quillContents;
        private EscherStm escherStm;
        private EscherDelayStm escherDelayStm;
-       
+
        /**
         * Opens a new publisher document
         */
@@ -49,19 +49,19 @@ public final class HPBFDocument extends POIDocument {
        public HPBFDocument(InputStream inp) throws IOException {
                this(new POIFSFileSystem(inp));
        }
-       
+
        /**
         * Opens an embeded publisher document,
         *  at the given directory.
         */
        public HPBFDocument(DirectoryNode dir, POIFSFileSystem fs) throws IOException {
                super(dir, fs);
-               
+
                // Go looking for our interesting child
                //  streams
                mainContents = new MainContents(dir);
                quillContents = new QuillContents(dir);
-               
+
                // Now the Escher bits
                escherStm = new EscherStm(dir);
                escherDelayStm = new EscherDelayStm(dir);
@@ -79,7 +79,7 @@ public final class HPBFDocument extends POIDocument {
        public EscherDelayStm getEscherDelayStm() {
                return escherDelayStm;
        }
-       
+
        public void write(OutputStream out) throws IOException {
                throw new IllegalStateException("Writing is not yet implemented, see http://poi.apache.org/hpbf/");
        }
index 6c52bbb04c9c38324f60106a7378481a53814630..df4bb15a4fae06437ee52fd8c91dcad753f5c18e 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.dev;
 
 import java.io.FileInputStream;
@@ -33,7 +34,7 @@ import org.apache.poi.util.StringUtil;
  *  files, while we try to figure out how they're
  *  constructed.
  */
-public class HPBFDumper {
+public final class HPBFDumper {
        private POIFSFileSystem fs;
        public HPBFDumper(POIFSFileSystem fs) {
                this.fs = fs;
@@ -41,7 +42,7 @@ public class HPBFDumper {
        public HPBFDumper(InputStream inp) throws IOException {
                this(new POIFSFileSystem(inp));
        }
-       
+
        private static byte[] getData(DirectoryNode dir, String name) throws IOException {
                DocumentEntry docProps =
                        (DocumentEntry)dir.getEntry(name);
@@ -49,11 +50,11 @@ public class HPBFDumper {
                // Grab the document stream
                byte[] d = new byte[docProps.getSize()];
                dir.createDocumentInputStream(name).read(d);
-               
+
                // All done
                return d;
        }
-       
+
        /**
         * Dumps out the given number of bytes as hex,
         *  two chars
@@ -64,7 +65,7 @@ public class HPBFDumper {
                        int j = i + offset;
                        int b = data[j];
                        if(b < 0) { b += 256; }
-                       
+
                        String bs = Integer.toHexString(b);
                        if(bs.length() == 1)
                                ret.append('0');
@@ -73,7 +74,7 @@ public class HPBFDumper {
                }
                return ret.toString();
        }
-       
+
        public static void main(String[] args) throws Exception {
                if(args.length < 1) {
                        System.err.println("Use:");
@@ -83,41 +84,41 @@ public class HPBFDumper {
                HPBFDumper dump = new HPBFDumper(
                                new FileInputStream(args[0])
                );
-               
+
                System.out.println("Dumping " + args[0]);
                dump.dumpContents();
                dump.dumpEnvelope();
                dump.dumpEscher();
                dump.dump001CompObj(dump.fs.getRoot());
                dump.dumpQuill();
-               
+
                // Still to go:
                //  (0x03)Internal
                //  Objects
        }
-       
+
        /**
         * Dump out the escher parts of the file.
         * Escher -> EscherStm and EscherDelayStm
         */
        public void dumpEscher() throws IOException {
-               DirectoryNode escherDir = (DirectoryNode) 
+               DirectoryNode escherDir = (DirectoryNode)
                        fs.getRoot().getEntry("Escher");
-               
+
                dumpEscherStm(escherDir);
                dumpEscherDelayStm(escherDir);
        }
        private void dumpEscherStream(byte[] data) {
-               DefaultEscherRecordFactory erf = 
+               DefaultEscherRecordFactory erf =
                        new DefaultEscherRecordFactory();
-               
+
                // Dump
                int left = data.length;
                while(left > 0) {
                        EscherRecord er = erf.createRecord(data, 0);
                        er.fillFields(data, 0, erf);
                        left -= er.getRecordSize();
-                       
+
                        System.out.println(er.toString());
                }
        }
@@ -135,52 +136,52 @@ public class HPBFDumper {
                if(data.length > 0)
                        dumpEscherStream(data);
        }
-       
+
        public void dumpEnvelope() throws IOException {
                byte[] data = getData(fs.getRoot(), "Envelope");
-               
+
                System.out.println("");
                System.out.println("Envelope - " + data.length + " bytes long:");
        }
-       
+
        public void dumpContents() throws IOException {
                byte[] data = getData(fs.getRoot(), "Contents");
-               
+
                System.out.println("");
                System.out.println("Contents - " + data.length + " bytes long:");
-               
+
                // 8 bytes, always seems to be
-               // E8 AC 2C 00 E8 03 05 01 
-               // E8 AC 2C 00 E8 03 05 01  
-               
+               // E8 AC 2C 00 E8 03 05 01
+               // E8 AC 2C 00 E8 03 05 01
+
                // 4 bytes - size of contents
                // 13/15 00 00 01
-               
+
                // ....
-               
+
            // E8 03 08 08 0C 20 03 00 00 00 00 88 16 00 00 00 ..... ..........
-               
+
            // 01 18 27 00 03 20 00 00 E8 03 08 08 0C 20 03 00 ..'.. ....... ..
-               
-               // 01 18 30 00 03 20 00 00 
+
+               // 01 18 30 00 03 20 00 00
                // E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
                // 00 00 00 88 1E 00 00 00
-               
+
                // 01 18 31 00 03 20 00 00
                // E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
                // 00 00 00 88 1E 00 00 00
-               
+
                // 01 18 32 00 03 20 00 00
                // E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
                // 00 00 00 88 1E 00 00 00
        }
-       
+
        public void dumpCONTENTSraw(DirectoryNode dir) throws IOException {
                byte[] data = getData(dir, "CONTENTS");
-               
+
                System.out.println("");
                System.out.println("CONTENTS - " + data.length + " bytes long:");
-               
+
                // Between the start and 0x200 we have
                //  CHNKINK(space) + 24 bytes
                //  0x1800
@@ -194,7 +195,7 @@ public class HPBFDumper {
                //  STSH + 8 bytes
                // but towards 0x200 the pattern may
                //  break down a little bit
-               
+
                // After the second of a given type,
                //  it seems to be 4 bytes giving the start,
                //  then 4 bytes giving the length, then
@@ -203,7 +204,7 @@ public class HPBFDumper {
                                new String(data, 0, 8) +
                                dumpBytes(data, 8, 0x20-8)
                );
-               
+
                int pos = 0x20;
                boolean sixNotEight = true;
                while(pos < 0x200) {
@@ -220,11 +221,11 @@ public class HPBFDumper {
                        System.out.println(
                                        text + " " + dumpBytes(data, pos+4, blen)
                        );
-                       
+
                        pos += 4 + blen;
                        sixNotEight = ! sixNotEight;
                }
-               
+
                // Text from 0x200 onwards until we get
                //  to \r(00)\n(00)(00)(00)
                int textStop = -1;
@@ -240,18 +241,18 @@ public class HPBFDumper {
                                        StringUtil.getFromUnicodeLE(data, 0x200, len)
                        );
                }
-               
+
                // The font list comes slightly later
-               
+
                // The hyperlinks may come before the fonts,
                //  or slightly in front
        }
        public void dumpCONTENTSguessed(DirectoryNode dir) throws IOException {
                byte[] data = getData(dir, "CONTENTS");
-               
+
                System.out.println("");
                System.out.println("CONTENTS - " + data.length + " bytes long:");
-               
+
                String[] startType = new String[20];
                String[] endType = new String[20];
                int[] optA = new int[20];
@@ -259,7 +260,7 @@ public class HPBFDumper {
                int[] optC = new int[20];
                int[] from = new int[20];
                int[] len = new int[20];
-               
+
                for(int i=0; i<20; i++) {
                        int offset = 0x20 + i*24;
                        if(data[offset] == 0x18 && data[offset+1] == 0x00) {
@@ -275,11 +276,11 @@ public class HPBFDumper {
                                // Doesn't have data
                        }
                }
-               
+
                String text = StringUtil.getFromUnicodeLE(
                                data, from[0], len[0]/2
                );
-               
+
                // Dump
                for(int i=0; i<20; i++) {
                        String num = Integer.toString(i);
@@ -287,14 +288,14 @@ public class HPBFDumper {
                                num = "0" + i;
                        }
                        System.out.print(num + " ");
-                       
+
                        if(startType[i] == null) {
                                System.out.println("(not present)");
                        } else {
                                System.out.println(
                                                "\t" +
-                                               startType[i] + " " + 
-                                               optA[i] + " " + 
+                                               startType[i] + " " +
+                                               optA[i] + " " +
                                                optB[i] + " " +
                                                optC[i]
                                );
@@ -303,30 +304,30 @@ public class HPBFDumper {
                                                endType[i] + " " +
                                                "from: " +
                                                Integer.toHexString(from[i]) +
-                                               " (" + from[i] + ")" + 
+                                               " (" + from[i] + ")" +
                                                ", len: " +
                                                Integer.toHexString(len[i]) +
                                                " (" + len[i] + ")"
                                );
                        }
                }
-               
+
                // Text
                System.out.println("");
                System.out.println("TEXT:");
                System.out.println(text);
                System.out.println("");
-               
+
                // All the others
                for(int i=0; i<20; i++) {
                        if(startType[i] == null) {
                                continue;
                        }
                        int start = from[i];
-                       
+
                        System.out.println(
                                        startType[i] + " -> " + endType[i] +
-                                       " @ " + Integer.toHexString(start) + 
+                                       " @ " + Integer.toHexString(start) +
                                        " (" + start + ")"
                        );
                        System.out.println("\t" + dumpBytes(data, start, 4));
@@ -335,15 +336,15 @@ public class HPBFDumper {
                        System.out.println("\t(etc)");
                }
        }
-       
+
        protected void dump001CompObj(DirectoryNode dir) {
                // TODO
        }
-       
+
        public void dumpQuill() throws IOException {
-               DirectoryNode quillDir = (DirectoryNode) 
+               DirectoryNode quillDir = (DirectoryNode)
                        fs.getRoot().getEntry("Quill");
-               DirectoryNode quillSubDir = (DirectoryNode) 
+               DirectoryNode quillSubDir = (DirectoryNode)
                        quillDir.getEntry("QuillSub");
 
                dump001CompObj(quillSubDir);
index cdec78c8cf1daa3562415a6ec9587110f82299df..c6bfca93b9eadacfe21f7d64bdab31cf07c93b56 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.dev;
 
 import java.io.FileInputStream;
@@ -31,10 +32,10 @@ import org.apache.poi.util.HexDump;
  *  HPBF (Publisher) file, while we try to figure out
  *  what the format of them is.
  */
-public class PLCDumper {
+public final class PLCDumper {
        private HPBFDocument doc;
        private QuillContents qc;
-       
+
        public PLCDumper(HPBFDocument hpbfDoc) {
                doc = hpbfDoc;
                qc = doc.getQuillContents();
@@ -45,7 +46,7 @@ public class PLCDumper {
        public PLCDumper(InputStream inp) throws IOException {
                this(new POIFSFileSystem(inp));
        }
-       
+
        public static void main(String[] args) throws Exception {
                if(args.length < 1) {
                        System.err.println("Use:");
@@ -55,14 +56,14 @@ public class PLCDumper {
                PLCDumper dump = new PLCDumper(
                                new FileInputStream(args[0])
                );
-               
+
                System.out.println("Dumping " + args[0]);
                dump.dumpPLC();
        }
-       
-       private void dumpPLC() {        
+
+       private void dumpPLC() {
                QCBit[] bits = qc.getBits();
-               
+
                for(int i=0; i<bits.length; i++) {
                        if(bits[i] == null) continue;
                        if(bits[i].getBitType().equals("PLC ")) {
@@ -70,14 +71,14 @@ public class PLCDumper {
                        }
                }
        }
-       
+
        private void dumpBit(QCBit bit, int index) {
                System.out.println("");
                System.out.println("Dumping " + bit.getBitType() + " bit at " + index);
                System.out.println("  Is a " + bit.getThingType() + ", number is " + bit.getOptA());
                System.out.println("  Starts at " + bit.getDataOffset() + " (0x" + Integer.toHexString(bit.getDataOffset()) + ")");
                System.out.println("  Runs for  " + bit.getLength() + " (0x" + Integer.toHexString(bit.getLength()) + ")");
-               
+
                System.out.println(HexDump.dump(bit.getData(), 0, 0));
        }
 }
index a28f16b7e8d636d6446b43d939acacf1b4d9e9d4..8187ab124993419819bd4271d4c90fe6c930ccb6 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.extractor;
 
 import java.io.FileInputStream;
@@ -28,12 +29,12 @@ import org.apache.poi.hpbf.model.qcbits.QCPLCBit.Type12;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
 /**
- * Extract text from HPBF Publisher files 
+ * Extract text from HPBF Publisher files
  */
-public class PublisherTextExtractor extends POIOLE2TextExtractor {
+public final class PublisherTextExtractor extends POIOLE2TextExtractor {
        private HPBFDocument doc;
        private boolean hyperlinksByDefault = false;
-       
+
        public PublisherTextExtractor(HPBFDocument doc) {
                super(doc);
                this.doc = doc;
@@ -44,7 +45,7 @@ public class PublisherTextExtractor extends POIOLE2TextExtractor {
        public PublisherTextExtractor(InputStream is) throws IOException {
                this(new POIFSFileSystem(is));
        }
-       
+
        /**
         * Should a call to getText() return hyperlinks inline
         *  with the text?
@@ -54,10 +55,10 @@ public class PublisherTextExtractor extends POIOLE2TextExtractor {
                this.hyperlinksByDefault = hyperlinksByDefault;
        }
 
-       
+
        public String getText() {
                StringBuffer text = new StringBuffer();
-               
+
                // Get the text from the Quill Contents
                QCBit[] bits = doc.getQuillContents().getBits();
                for(int i=0; i<bits.length; i++) {
@@ -66,7 +67,7 @@ public class PublisherTextExtractor extends POIOLE2TextExtractor {
                                text.append( t.getText().replace('\r', '\n') );
                        }
                }
-               
+
                // If requested, add in the hyperlinks
                // Ideally, we'd do these inline, but the hyperlink
                //  positions are relative to the text area the
@@ -84,20 +85,20 @@ public class PublisherTextExtractor extends POIOLE2TextExtractor {
                                }
                        }
                }
-               
+
                // Get more text
                // TODO
-               
+
                return text.toString();
        }
-       
-       
+
+
        public static void main(String[] args) throws Exception {
                if(args.length == 0) {
                        System.err.println("Use:");
                        System.err.println("  PublisherTextExtractor <file.pub>");
                }
-               
+
                for(int i=0; i<args.length; i++) {
                        PublisherTextExtractor te = new PublisherTextExtractor(
                                        new FileInputStream(args[i])
index 032484626e943e4dce7797f471532050fdd838da..3f4784ac4ac2405e2abd1f0e7a5a5af1925c24e3 100644 (file)
@@ -20,7 +20,9 @@ package org.apache.poi.hpbf.model;
 import java.io.IOException;
 
 import org.apache.poi.poifs.filesystem.DirectoryNode;
-
+/**
+ *
+ */
 public final class EscherDelayStm extends EscherPart {
        private static final String[] PATH = { "Escher", "EscherDelayStm", };
 
index 00e685f8f29ab5541a2f87c52770512121498773..fce22481ad35f797ed5c07700f065ab25df7ff1d 100644 (file)
@@ -29,36 +29,36 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
  */
 public abstract class EscherPart extends HPBFPart {
        private EscherRecord[] records;
-       
+
        /**
         * Creates the Escher Part, and finds our child
         *  escher records
         */
        public EscherPart(DirectoryNode baseDir, String[] parts) throws IOException {
                super(baseDir, parts);
-               
+
                // Now create our Escher children
-               DefaultEscherRecordFactory erf = 
+               DefaultEscherRecordFactory erf =
                        new DefaultEscherRecordFactory();
-               
+
                ArrayList ec = new ArrayList();
                int left = data.length;
                while(left > 0) {
                        EscherRecord er = erf.createRecord(data, 0);
                        er.fillFields(data, 0, erf);
                        left -= er.getRecordSize();
-                       
+
                        ec.add(er);
                }
-               
+
                records = (EscherRecord[])
                        ec.toArray(new EscherRecord[ec.size()]);
        }
-       
+
        public EscherRecord[] getEscherRecords() {
                return records;
        }
-       
+
        /**
         * Serialises our Escher children back
         *  into bytes.
@@ -66,13 +66,13 @@ public abstract class EscherPart extends HPBFPart {
        protected void generateData() {
                int size = 0;
                for(int i=0; i<records.length; i++) {
-                       size += records[i].getRecordSize(); 
+                       size += records[i].getRecordSize();
                }
-               
+
                data = new byte[size];
                size = 0;
                for(int i=0; i<records.length; i++) {
-                       int thisSize = 
+                       int thisSize =
                                records[i].serialize(size, data);
                        size += thisSize;
                }
index 2ed79ea34156bb72b6eccb4eab0a7b85a86b3335..07cd4c66acd507b51db2077a51da08b2646af29e 100644 (file)
@@ -20,7 +20,9 @@ package org.apache.poi.hpbf.model;
 import java.io.IOException;
 
 import org.apache.poi.poifs.filesystem.DirectoryNode;
-
+/**
+ *
+ */
 public final class EscherStm extends EscherPart {
        private static final String[] PATH = { "Escher", "EscherStm", };
        public EscherStm(DirectoryNode baseDir) throws IOException {
index 9db15c664206a430969ccb9204f9f04fdc7916a8..bd727e1b37cfdc058180f2074e6e0f7683398117 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model;
 
 import java.io.ByteArrayInputStream;
@@ -34,15 +35,15 @@ public abstract class HPBFPart {
         * @param path  the path to the part, eg Contents or Quill, QuillSub, CONTENTS
         */
        public HPBFPart(DirectoryNode baseDir, String[] path) throws IOException {
-                
+
                DirectoryNode dir = getDir(path, baseDir);
                String name = path[path.length-1];
-               
+
                DocumentEntry docProps;
                try {
                        docProps = (DocumentEntry)dir.getEntry(name);
                } catch (FileNotFoundException e) {
-                       throw new IllegalArgumentException("File invalid - failed to find document entry '" 
+                       throw new IllegalArgumentException("File invalid - failed to find document entry '"
                                        + name + "'");
                }
 
@@ -56,16 +57,16 @@ public abstract class HPBFPart {
                        try {
                                dir = (DirectoryNode)dir.getEntry(path[i]);
                        } catch (FileNotFoundException e) {
-                               throw new IllegalArgumentException("File invalid - failed to find directory entry '" 
+                               throw new IllegalArgumentException("File invalid - failed to find directory entry '"
                                                + path[i] + "'");
                        }
                }
                return dir;
        }
-       
+
        public void writeOut(DirectoryNode baseDir) throws IOException {
                String[] path = getPath();
-               
+
                // Ensure that all parent directories exist
                DirectoryNode dir = baseDir;
                for(int i=0; i<path.length-1; i++) {
@@ -75,22 +76,22 @@ public abstract class HPBFPart {
                                dir.createDirectory(path[i]);
                        }
                }
-               
+
                // Update the byte array with the latest data
                generateData();
-               
+
                // Write out
                ByteArrayInputStream bais = new ByteArrayInputStream(data);
                dir.createDocument(path[path.length-1], bais);
        }
-       
+
        /**
         * Called just before writing out, to trigger
         *  the data byte array to be updated with the
         *  latest contents.
         */
        protected abstract void generateData();
-       
+
        /**
         * Returns the raw data that makes up
         *  this document part.
index 9783ebdc54ec1be6908946c9254a482fbe2aa8bb..d1c5e3ff6166835a51800c1a53d5191e2f79a7cc 100644 (file)
@@ -26,7 +26,7 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
  */
 public final class MainContents extends HPBFPart {
        private static final String[] PATH = { "Contents", };
-       
+
        public MainContents(DirectoryNode baseDir) throws IOException {
                super(baseDir, PATH);
        }
index 56f7bfcc9cbb9444d0b259cc2a1f35e4bf75c2f9..87384fb1a2e94e405cb05ad04c9de986c26de281 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model;
 
 import java.io.IOException;
@@ -31,20 +32,20 @@ import org.apache.poi.util.LittleEndian;
 public final class QuillContents extends HPBFPart {
        private static final String[] PATH = { "Quill", "QuillSub", "CONTENTS", };
        private QCBit[] bits;
-       
+
        public QuillContents(DirectoryNode baseDir) throws IOException {
                super(baseDir, PATH);
-               
+
                // Now parse the first 512 bytes, and produce
                //  all our bits
-               
+
                // Check first 8 bytes
                String f8 = new String(data, 0, 8);
                if(! f8.equals("CHNKINK ")) {
                        throw new IllegalArgumentException("Expecting 'CHNKINK ' but was '"+f8+"'");
                }
                // Ignore the next 24, for now at least
-               
+
                // Now, parse all our QC Bits
                bits = new QCBit[20];
                for(int i=0; i<20; i++) {
@@ -58,10 +59,10 @@ public final class QuillContents extends HPBFPart {
                                String bitType = new String(data, offset+12, 4);
                                int from = (int)LittleEndian.getUInt(data, offset+16);
                                int len = (int)LittleEndian.getUInt(data, offset+20);
-                               
+
                                byte[] bitData = new byte[len];
                                System.arraycopy(data, from, bitData, 0, len);
-                               
+
                                // Create
                                if(bitType.equals("TEXT")) {
                                        bits[i] = new QCTextBit(thingType, bitType, bitData);
@@ -83,7 +84,7 @@ public final class QuillContents extends HPBFPart {
        public QCBit[] getBits() {
                return bits;
        }
-       
+
        protected void generateData() {
                // TODO
                throw new IllegalStateException("Not done yet!");
index d6a5608bb4f41637b85f1b5173da0f47aa7e7e96..ebbc3377ce25a9df0eacfe9beda9cbedd9b404f9 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model.qcbits;
 
 /**
@@ -23,19 +24,19 @@ public abstract class QCBit {
        protected String thingType;
        protected String bitType;
        protected byte[] data;
-       
+
        protected int optA;
        protected int optB;
        protected int optC;
-       
+
        protected int dataOffset;
-       
+
        public QCBit(String thingType, String bitType, byte[] data) {
                this.thingType = thingType;
                this.bitType = bitType;
                this.data = data;
        }
-       
+
        /**
         * Returns the type of the thing, eg TEXT, FONT
         *  or TOKN
@@ -75,7 +76,7 @@ public abstract class QCBit {
        public void setDataOffset(int offset) {
                this.dataOffset = offset;
        }
-       
+
        public int getLength() {
                return data.length;
        }
index 4bd57d514ac4a7c795cd75f0f7fc805c50293024..3b7975505ccb21b7a416aa1130852b0c205c1ffc 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model.qcbits;
 
 import org.apache.poi.util.LittleEndian;
@@ -24,12 +25,12 @@ import org.apache.poi.util.StringUtil;
  * A "PLC " (PLC) based bit of Quill Contents. The exact
  *  format is determined by the type of the PLCs.
  */
-public class QCPLCBit extends QCBit {
+public abstract class QCPLCBit extends QCBit {
        protected int numberOfPLCs;
        protected int typeOfPLCS;
-       /** 
+       /**
         * The data which goes before the main PLC entries.
-        * This is apparently always made up of 2 byte 
+        * This is apparently always made up of 2 byte
         *  un-signed ints..
         */
        protected int[] preData;
@@ -37,24 +38,24 @@ public class QCPLCBit extends QCBit {
        protected long[] plcValA;
        /** The second value of each PLC, normally 4 bytes */
        protected long[] plcValB;
-       
-       
+
+
        private QCPLCBit(String thingType, String bitType, byte[] data) {
                super(thingType, bitType, data);
-               
+
                // First four bytes are the number
                numberOfPLCs = (int)LittleEndian.getUInt(data, 0);
-               
+
                // Next four bytes are the type
                typeOfPLCS = (int)LittleEndian.getUInt(data, 4);
-               
+
                // Init the arrays that we can
                plcValA = new long[numberOfPLCs];
                plcValB = new long[numberOfPLCs];
        }
-       
-       
-       
+
+
+
        public int getNumberOfPLCs() {
                return numberOfPLCs;
        }
@@ -92,7 +93,7 @@ public class QCPLCBit extends QCBit {
                }
        }
 
-       
+
        /**
         * Type 0 seem to be somewhat rare. They have 8 bytes of pre-data,
         *  then 2x 2 byte values.
@@ -100,14 +101,14 @@ public class QCPLCBit extends QCBit {
        public static class Type0 extends QCPLCBit {
                private Type0(String thingType, String bitType, byte[] data) {
                        super(thingType, bitType, data);
-                       
+
                        // Grab our 4x pre-data
                        preData = new int[4];
                        preData[0] = LittleEndian.getUShort(data, 8+0);
                        preData[1] = LittleEndian.getUShort(data, 8+2);
                        preData[2] = LittleEndian.getUShort(data, 8+4);
                        preData[3] = LittleEndian.getUShort(data, 8+6);
-                       
+
                        // And grab the 2 byte values
                        for(int i=0; i<numberOfPLCs; i++) {
                                plcValA[i] = LittleEndian.getUShort(data, 16+(4*i));
@@ -115,7 +116,7 @@ public class QCPLCBit extends QCBit {
                        }
                }
        }
-       
+
        /**
         * Type 4 is quite common. They have 8 bytes of pre-data,
         *  then 2x 4 byte values.
@@ -123,14 +124,14 @@ public class QCPLCBit extends QCBit {
        public static class Type4 extends QCPLCBit {
                private Type4(String thingType, String bitType, byte[] data) {
                        super(thingType, bitType, data);
-                       
+
                        // Grab our 4x pre-data
                        preData = new int[4];
                        preData[0] = LittleEndian.getUShort(data, 8+0);
                        preData[1] = LittleEndian.getUShort(data, 8+2);
                        preData[2] = LittleEndian.getUShort(data, 8+4);
                        preData[3] = LittleEndian.getUShort(data, 8+6);
-                       
+
                        // And grab the 4 byte values
                        for(int i=0; i<numberOfPLCs; i++) {
                                plcValA[i] = LittleEndian.getUInt(data, 16+(8*i));
@@ -138,7 +139,7 @@ public class QCPLCBit extends QCBit {
                        }
                }
        }
-       
+
        /**
         * Type 8 is quite common. They have 14 bytes of pre-data,
         *  then 2x 4 byte values.
@@ -146,7 +147,7 @@ public class QCPLCBit extends QCBit {
        public static class Type8 extends QCPLCBit {
                private Type8(String thingType, String bitType, byte[] data) {
                        super(thingType, bitType, data);
-                       
+
                        // Grab our 7x pre-data
                        preData = new int[7];
                        preData[0] = LittleEndian.getUShort(data, 8+0);
@@ -156,7 +157,7 @@ public class QCPLCBit extends QCBit {
                        preData[4] = LittleEndian.getUShort(data, 8+8);
                        preData[5] = LittleEndian.getUShort(data, 8+10);
                        preData[6] = LittleEndian.getUShort(data, 8+12);
-                       
+
                        // And grab the 4 byte values
                        for(int i=0; i<numberOfPLCs; i++) {
                                plcValA[i] = LittleEndian.getUInt(data, 22+(8*i));
@@ -164,7 +165,7 @@ public class QCPLCBit extends QCBit {
                        }
                }
        }
-       
+
        /**
         * Type 12 holds hyperlinks, and is very complex.
         * There is normally one of these for each text
@@ -174,14 +175,14 @@ public class QCPLCBit extends QCBit {
         */
        public static class Type12 extends QCPLCBit {
                private String[] hyperlinks;
-               
+
                private static final int oneStartsAt = 0x4c;
                private static final int twoStartsAt = 0x68;
                private static final int threePlusIncrement = 22;
-               
+
                private Type12(String thingType, String bitType, byte[] data) {
                        super(thingType, bitType, data);
-                       
+
                        // How many hyperlinks do we really have?
                        // (zero hyperlinks gets numberOfPLCs=1)
                        if(data.length == 0x34) {
@@ -189,14 +190,14 @@ public class QCPLCBit extends QCBit {
                        } else {
                                hyperlinks = new String[numberOfPLCs];
                        }
-                       
+
                        // We have 4 bytes, then the start point of each
                        //  hyperlink, then the end point of the text.
                        preData = new int[1+numberOfPLCs+1];
                        for(int i=0; i<preData.length; i++) {
                                preData[i] = (int)LittleEndian.getUInt(data, 8+(i*4));
                        }
-                       
+
                        // Then we have a whole bunch of stuff, which grows
                        //  with the number of hyperlinks
                        // For now, we think these are shorts
@@ -207,13 +208,13 @@ public class QCPLCBit extends QCBit {
                        } else if(numberOfPLCs >= 2) {
                                until = twoStartsAt + (numberOfPLCs-2)*threePlusIncrement;
                        }
-                       
+
                        plcValA = new long[(until-at)/2];
                        plcValB = new long[0];
                        for(int i=0; i<plcValA.length; i++) {
                                plcValA[i] = LittleEndian.getUShort(data, at+(i*2));
                        }
-                       
+
                        // Finally, we have a series of lengths + hyperlinks
                        at = until;
                        for(int i=0; i<hyperlinks.length; i++) {
@@ -232,9 +233,9 @@ public class QCPLCBit extends QCBit {
                                }
                        }
                }
-               
+
                /**
-                * Returns the number of hyperlinks, which should 
+                * Returns the number of hyperlinks, which should
                 *  either be zero, or the number of PLC bits
                 */
                public int getNumberOfHyperlinks() {
@@ -251,7 +252,7 @@ public class QCPLCBit extends QCBit {
                }
                /**
                 * Returns where in the text (in characters) the
-                *  hyperlink at the given index starts 
+                *  hyperlink at the given index starts
                 *  applying to.
                 * This position is relative to the text area that this
                 *  PLCBit applies to.
index e3c8dcb5898b5e1496c84b3ccdb310eb5a52590e..9d8c42493cd0a2f2c34fa4ef973d66f97cafc8b8 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model.qcbits;
 
 import org.apache.poi.util.StringUtil;
@@ -21,7 +22,7 @@ import org.apache.poi.util.StringUtil;
 /**
  * A Text based bit of Quill Contents
  */
-public class QCTextBit extends QCBit {
+public final class QCTextBit extends QCBit {
        public QCTextBit(String thingType, String bitType, byte[] data) {
                super(thingType, bitType, data);
        }
@@ -35,7 +36,7 @@ public class QCTextBit extends QCBit {
                                data, 0, data.length/2
                );
        }
-       
+
        public void setText(String text) {
                data = new byte[text.length()*2];
                StringUtil.putUnicodeLE(text, data, 0);
index 2548b4fca69300459555d79acfed5da69ddb7aff..64dae7ba112e2c7f5db4c6f1745e3a80510d397e 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model.qcbits;
 
 /**
  * Any Quill Contents bits we don't know
  *  how to handle explicitly
  */
-public class UnknownQCBit extends QCBit {
+public final class UnknownQCBit extends QCBit {
        public UnknownQCBit(String thingType, String bitType, byte[] data) {
                super(thingType, bitType, data);
        }
index 15625fd2a85d321413d90713b4ad1a4d105ab909..05d85fe6e0be301d67f188dc50a454976e266e27 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf;
 
@@ -35,15 +32,15 @@ import org.apache.poi.util.LittleEndian;
 
 /**
  * This class provides helper functions for determining if a
- *  PowerPoint document is Encrypted. 
+ *  PowerPoint document is Encrypted.
  * In future, it may also provide Encryption and Decryption
- *  functions, but first we'd need to figure out how 
+ *  functions, but first we'd need to figure out how
  *  PowerPoint encryption is really done!
  *
  * @author Nick Burch
  */
 
-public class EncryptedSlideShow
+public final class EncryptedSlideShow
 {
        /**
         * Check to see if a HSLFSlideShow represents an encrypted
@@ -61,11 +58,11 @@ public class EncryptedSlideShow
                } catch(FileNotFoundException fnfe) {
                        // Doesn't have encrypted properties
                }
-               
+
                // If they encrypted the document but not the properties,
                //  it's harder.
                // We need to see what the last record pointed to by the
-               //  first PersistPrtHolder is - if it's a 
+               //  first PersistPrtHolder is - if it's a
                //  DocumentEncryptionAtom, then the file's Encrypted
                DocumentEncryptionAtom dea = fetchDocumentEncryptionAtom(hss);
                if(dea != null) {
@@ -73,23 +70,23 @@ public class EncryptedSlideShow
                }
                return false;
        }
-       
+
        /**
         * Return the DocumentEncryptionAtom for a HSLFSlideShow, or
         *  null if there isn't one.
         * @return a DocumentEncryptionAtom, or null if there isn't one
         */
        public static DocumentEncryptionAtom fetchDocumentEncryptionAtom(HSLFSlideShow hss) {
-               // Will be the last Record pointed to by the 
+               // Will be the last Record pointed to by the
                //  first PersistPrtHolder, if there is one
-               
+
                CurrentUserAtom cua = hss.getCurrentUserAtom();
                if(cua.getCurrentEditOffset() != 0) {
                        // Check it's not past the end of the file
                        if(cua.getCurrentEditOffset() > hss.getUnderlyingBytes().length) {
                                throw new CorruptPowerPointFileException("The CurrentUserAtom claims that the offset of last edit details are past the end of the file");
                        }
-                       
+
                        // Grab the details of the UserEditAtom there
                        // If the record's messed up, we could AIOOB
                        Record r = null;
@@ -102,7 +99,7 @@ public class EncryptedSlideShow
                        if(r == null) { return null; }
                        if(! (r instanceof UserEditAtom)) { return null; }
                        UserEditAtom uea = (UserEditAtom)r;
-                       
+
                        // Now get the PersistPtrHolder
                        Record r2 = Record.buildRecordAtOffset(
                                        hss.getUnderlyingBytes(),
@@ -110,7 +107,7 @@ public class EncryptedSlideShow
                        );
                        if(! (r2 instanceof PersistPtrHolder)) { return null; }
                        PersistPtrHolder pph = (PersistPtrHolder)r2;
-                       
+
                        // Now get the last record
                        int[] slideIds = pph.getKnownSlideIDs();
                        int maxSlideId = -1;
@@ -118,7 +115,7 @@ public class EncryptedSlideShow
                                if(slideIds[i] > maxSlideId) { maxSlideId = slideIds[i]; }
                        }
                        if(maxSlideId == -1) { return null; }
-                       
+
                        int offset = (
                                        (Integer)pph.getSlideLocationsLookup().get(
                                                        new Integer(maxSlideId)
@@ -127,13 +124,13 @@ public class EncryptedSlideShow
                                        hss.getUnderlyingBytes(),
                                        offset
                        );
-                       
+
                        // If we have a DocumentEncryptionAtom, it'll be this one
                        if(r3 instanceof DocumentEncryptionAtom) {
                                return (DocumentEncryptionAtom)r3;
                        }
                }
-               
+
                return null;
        }
 }
index c0a92a3188a2e7414955ade0808e5dbbcbf3cbbe..80767b3a0ea0b87a7c2024f594ef7ac0d985831d 100644 (file)
@@ -47,7 +47,7 @@ import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 
 /**
- * This class contains the main functionality for the Powerpoint file 
+ * This class contains the main functionality for the Powerpoint file
  * "reader". It is only a very basic class for now
  *
  * @author Nick Burch
@@ -80,7 +80,7 @@ public final class HSLFSlideShow extends POIDocument {
        }
 
        /**
-        * Constructs a Powerpoint document from fileName. Parses the document 
+        * Constructs a Powerpoint document from fileName. Parses the document
         * and places all the important stuff into data structures.
         *
         * @param fileName The name of the file to read.
@@ -90,9 +90,9 @@ public final class HSLFSlideShow extends POIDocument {
        {
                this(new FileInputStream(fileName));
        }
-  
+
        /**
-        * Constructs a Powerpoint document from an input stream. Parses the 
+        * Constructs a Powerpoint document from an input stream. Parses the
         * document and places all the important stuff into data structures.
         *
         * @param inputStream the source of the data
@@ -104,7 +104,7 @@ public final class HSLFSlideShow extends POIDocument {
        }
 
        /**
-        * Constructs a Powerpoint document from a POIFS Filesystem. Parses the 
+        * Constructs a Powerpoint document from a POIFS Filesystem. Parses the
         * document and places all the important stuff into data structures.
         *
         * @param filesystem the POIFS FileSystem to read from
@@ -114,9 +114,9 @@ public final class HSLFSlideShow extends POIDocument {
        {
                this(filesystem.getRoot(), filesystem);
        }
-       
+
        /**
-        * Constructs a Powerpoint document from a specific point in a 
+        * Constructs a Powerpoint document from a specific point in a
         *  POIFS Filesystem. Parses the document and places all the
         *  important stuff into data structures.
         *
@@ -127,15 +127,15 @@ public final class HSLFSlideShow extends POIDocument {
        public HSLFSlideShow(DirectoryNode dir, POIFSFileSystem filesystem) throws IOException
        {
                super(dir, filesystem);
-               
+
                // First up, grab the "Current User" stream
                // We need this before we can detect Encrypted Documents
                readCurrentUserStream();
-               
-               // Next up, grab the data that makes up the 
+
+               // Next up, grab the data that makes up the
                //  PowerPoint stream
                readPowerPointStream();
-               
+
                // Check to see if we have an encrypted document,
                //  bailing out if we do
                boolean encrypted = EncryptedSlideShow.checkIfEncrypted(this);
@@ -148,7 +148,7 @@ public final class HSLFSlideShow extends POIDocument {
 
                // Look for Property Streams:
                readProperties();
-               
+
                // Look for any other streams
                readOtherStreams();
 
@@ -171,8 +171,8 @@ public final class HSLFSlideShow extends POIDocument {
        }
 
        /**
-        * Extracts the main PowerPoint document stream from the 
-        *  POI file, ready to be passed 
+        * Extracts the main PowerPoint document stream from the
+        *  POI file, ready to be passed
         *
         * @throws IOException
         */
@@ -186,9 +186,9 @@ public final class HSLFSlideShow extends POIDocument {
                _docstream = new byte[docProps.getSize()];
                directory.createDocumentInputStream("PowerPoint Document").read(_docstream);
        }
-       
+
        /**
-        * Builds the list of records, based on the contents  
+        * Builds the list of records, based on the contents
         *  of the PowerPoint stream
         */
        private void buildRecords()
@@ -206,7 +206,7 @@ public final class HSLFSlideShow extends POIDocument {
                //      <xx xx yy yy zz zz zz zz dd dd dd dd dd dd dd>
                // All lengths given exclude the 8 byte record header
                // (Data records are known as Atoms)
-       
+
                // Document should start with:
                //   0F 00 E8 03 ## ## ## ##
            //     (type 1000 = document, info 00 0f is normal, rest is document length)
@@ -216,9 +216,9 @@ public final class HSLFSlideShow extends POIDocument {
                //   05 00 00 00 0A 00 00 00 xx xx xx
                //     (the contents of the document atom, not sure what it means yet)
                //   (records then follow)
-       
+
                // When parsing a document, look to see if you know about that type
-               //  of the current record. If you know it's a type that has children, 
+               //  of the current record. If you know it's a type that has children,
                //  process the record's data area looking for more records
                // If you know about the type and it doesn't have children, either do
                //  something with the data (eg TextRun) or skip over it
@@ -231,7 +231,7 @@ public final class HSLFSlideShow extends POIDocument {
 
     private Record[] read(byte[] docstream, int usrOffset){
         ArrayList lst = new ArrayList();
-        HashMap offset2id = new HashMap(); 
+        HashMap offset2id = new HashMap();
         while (usrOffset != 0){
             UserEditAtom usr = (UserEditAtom) Record.buildRecordAtOffset(docstream, usrOffset);
             lst.add(new Integer(usrOffset));
@@ -269,7 +269,7 @@ public final class HSLFSlideShow extends POIDocument {
     }
 
        /**
-        * Find the "Current User" stream, and load it 
+        * Find the "Current User" stream, and load it
         */
        private void readCurrentUserStream() {
                try {
@@ -279,9 +279,9 @@ public final class HSLFSlideShow extends POIDocument {
                        currentUser = new CurrentUserAtom();
                }
        }
-       
+
        /**
-        * Find any other streams from the filesystem, and load them 
+        * Find any other streams from the filesystem, and load them
         */
        private void readOtherStreams() {
                // Currently, there aren't any
@@ -301,7 +301,7 @@ public final class HSLFSlideShow extends POIDocument {
                        DocumentInputStream is = directory.createDocumentInputStream("Pictures");
                        is.read(pictstream);
                } catch (FileNotFoundException e){
-                       // Silently catch exceptions if the presentation doesn't 
+                       // Silently catch exceptions if the presentation doesn't
                        //  contain pictures - will use a null set instead
                        return;
                }
@@ -348,7 +348,7 @@ public final class HSLFSlideShow extends POIDocument {
                                        logger.log(POILogger.ERROR, "Problem reading picture: " + e + "\nYou document will probably become corrupted if you save it!");
                                }
                        }
-            
+
             pos += imgsize;
         }
        }
@@ -383,7 +383,7 @@ public final class HSLFSlideShow extends POIDocument {
 
         // The list of entries we've written out
         List writtenEntries = new ArrayList(1);
-        
+
         // Write out the Property Streams
         writeProperties(outFS, writtenEntries);
 
@@ -449,7 +449,7 @@ public final class HSLFSlideShow extends POIDocument {
         currentUser.writeToFS(outFS);
         writtenEntries.add("Current User");
 
-       
+
         // Write any pictures, into another stream
         if (_pictures.size() > 0) {
             ByteArrayOutputStream pict = new ByteArrayOutputStream();
@@ -461,7 +461,7 @@ public final class HSLFSlideShow extends POIDocument {
             );
             writtenEntries.add("Pictures");
         }
-        
+
         // If requested, write out any other streams we spot
         if(preserveNodes) {
                copyNodes(filesystem, outFS, writtenEntries);
@@ -498,7 +498,7 @@ public final class HSLFSlideShow extends POIDocument {
                _records = r;
                return addedAt;
        }
-       
+
        /**
         * Add a new picture to this presentation.
      *
index 223a1bbcd90d489e8ea4e44073fae1c16b0d7b41..9f59de4a86ac56f005f739a9ef4a438af95bdb55 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.blip;
 
 import org.apache.poi.hslf.usermodel.PictureData;
@@ -24,7 +25,7 @@ import java.io.ByteArrayOutputStream;
 /**
  * Represents a bitmap picture data:  JPEG or PNG.
  * The data is not compressed and the exact file content is written in the stream.
- * 
+ *
  * @author Yegor Kozlov
  */
 public abstract  class Bitmap extends PictureData {
index ab6d645d6e4e1c4d413f71ad90aa41597ec87719..b9ba597115a6412a0eaf1cc84e404c9e5310e813 100755 (executable)
@@ -1,51 +1,68 @@
-package org.apache.poi.hslf.blip;\r
-\r
-import org.apache.poi.hslf.usermodel.PictureData;\r
-import org.apache.poi.hslf.model.Picture;\r
-import org.apache.poi.util.POILogger;\r
-import org.apache.poi.util.POILogFactory;\r
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-import javax.imageio.ImageIO;\r
-import java.awt.*;\r
-import java.awt.image.BufferedImage;\r
-import java.io.ByteArrayInputStream;\r
-\r
-/**\r
- * Creates BufferedImage using javax.imageio.ImageIO and draws it in the specified graphics.\r
- *\r
- * @author  Yegor Kozlov.\r
- */\r
-public class BitmapPainter implements ImagePainter {\r
-    protected POILogger logger = POILogFactory.getLogger(this.getClass());\r
-\r
-    public void paint(Graphics2D graphics, PictureData pict, Picture parent) {\r
-        BufferedImage img;\r
-        try {\r
-               img = ImageIO.read(new ByteArrayInputStream(pict.getData()));\r
-        }\r
-        catch (Exception e){\r
-            logger.log(POILogger.WARN, "ImageIO failed to create image. image.type: " + pict.getType());\r
-            return;\r
-        }\r
-        Rectangle anchor = parent.getAnchor();\r
-        Image scaledImg = img.getScaledInstance(anchor.width, anchor.height, Image.SCALE_SMOOTH);\r
-        graphics.drawImage(scaledImg, anchor.x, anchor.y, null);\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.hslf.blip;
+
+import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.model.Picture;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
+
+/* ====================================================================
+   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.
+==================================================================== */
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+
+/**
+ * Creates BufferedImage using javax.imageio.ImageIO and draws it in the specified graphics.
+ *
+ * @author  Yegor Kozlov.
+ */
+public final class BitmapPainter implements ImagePainter {
+    protected POILogger logger = POILogFactory.getLogger(this.getClass());
+
+    public void paint(Graphics2D graphics, PictureData pict, Picture parent) {
+        BufferedImage img;
+        try {
+               img = ImageIO.read(new ByteArrayInputStream(pict.getData()));
+        }
+        catch (Exception e){
+            logger.log(POILogger.WARN, "ImageIO failed to create image. image.type: " + pict.getType());
+            return;
+        }
+        Rectangle anchor = parent.getAnchor();
+        Image scaledImg = img.getScaledInstance(anchor.width, anchor.height, Image.SCALE_SMOOTH);
+        graphics.drawImage(scaledImg, anchor.x, anchor.y, null);
+    }
+
+}
index 59914431332d7700b725691a929025a06e5cc7ee..7e97446e4356db6d1476f76b26755cd5de11ef05 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.blip;
 
 import org.apache.poi.hslf.model.Picture;
@@ -23,10 +24,10 @@ import java.io.IOException;
 
 /**
  * Represents a DIB picture data in a PPT file
- * 
+ *
  * @author Yegor Kozlov
  */
-public class DIB extends Bitmap {
+public final class DIB extends Bitmap {
     /**
      * Size of the BITMAPFILEHEADER structure preceding the actual DIB bytes
      */
index 97ef83b769ddd9bee89d23f21c0d4852b23e29c4..1f1b13370ac1f322f3a5e493434ffe0bd9879fa5 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.blip;
 
 import org.apache.poi.hslf.model.Picture;
@@ -29,10 +30,10 @@ import java.util.zip.DeflaterOutputStream;
 
 /**
  * Represents EMF (Windows Enhanced Metafile) picture data.
- * 
+ *
  * @author Yegor Kozlov
  */
-public class EMF extends Metafile {
+public final class EMF extends Metafile {
 
     /**
      * Extract compressed EMF data from a ppt
index 8849a31a22070f85abe11452a99d700646b0be46..2c350070486e47ed12da44d9249a98373a082f2f 100755 (executable)
@@ -1,71 +1,72 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.blip;\r
-\r
-import org.apache.poi.hslf.model.Picture;\r
-import org.apache.poi.hslf.usermodel.PictureData;\r
-\r
-import java.awt.*;\r
-\r
-/**\r
- * A common interface for objects that can render ppt picture data.\r
- * <p>\r
- * Subclasses can redefine it and use third-party libraries for actual rendering,\r
- * for example, Bitmaps can be rendered using javax.imageio.* , WMF can be rendered using Apache Batik,\r
- * PICT can be rendered using Apple QuickTime API for Java, etc.\r
- * </p>\r
- *\r
- * A typical usage is as follows:\r
- * <code>\r
- * public WMFPaiter implements ImagePainter{\r
- *   public void paint(Graphics2D graphics, PictureData pict, Picture parent){\r
- *       DataInputStream is = new DataInputStream(new ByteArrayInputStream(pict.getData()));\r
- *       org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore wmfStore =\r
- *               new org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore();\r
- *       try {\r
- *           wmfStore.read(is);\r
- *       } catch (IOException e){\r
- *           return;\r
- *       }\r
- *\r
- *       Rectangle anchor = parent.getAnchor();\r
- *       float scale = (float)anchor.width/wmfStore.getWidthPixels();\r
- *\r
- *       org.apache.batik.transcoder.wmf.tosvg.WMFPainter painter =\r
- *               new org.apache.batik.transcoder.wmf.tosvg.WMFPainter(wmfStore, 0, 0, scale);\r
- *       graphics.translate(anchor.x, anchor.y);\r
- *       painter.paint(graphics);\r
- *   }\r
- * }\r
- * PictureData.setImagePainter(Picture.WMF, new WMFPaiter());\r
- * ...\r
- * </code>\r
- * Subsequent calls of Slide.draw(Graphics gr) will use WMFPaiter for WMF images.\r
- *\r
- * @author  Yegor Kozlov.\r
- */\r
-public interface ImagePainter {\r
-\r
-    /**\r
-     * Paints the specified picture data\r
-     *\r
-     * @param graphics  the graphics to paintb into\r
-     * @param pict      the data to paint\r
-     * @param parent    the shapes that owns the picture data\r
-     */\r
-    public void paint(Graphics2D graphics, PictureData pict, Picture parent);\r
-}\r
+/* ====================================================================
+   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.hslf.blip;
+
+import org.apache.poi.hslf.model.Picture;
+import org.apache.poi.hslf.usermodel.PictureData;
+
+import java.awt.*;
+
+/**
+ * A common interface for objects that can render ppt picture data.
+ * <p>
+ * Subclasses can redefine it and use third-party libraries for actual rendering,
+ * for example, Bitmaps can be rendered using javax.imageio.* , WMF can be rendered using Apache Batik,
+ * PICT can be rendered using Apple QuickTime API for Java, etc.
+ * </p>
+ *
+ * A typical usage is as follows:
+ * <code>
+ * public WMFPaiter implements ImagePainter{
+ *   public void paint(Graphics2D graphics, PictureData pict, Picture parent){
+ *       DataInputStream is = new DataInputStream(new ByteArrayInputStream(pict.getData()));
+ *       org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore wmfStore =
+ *               new org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore();
+ *       try {
+ *           wmfStore.read(is);
+ *       } catch (IOException e){
+ *           return;
+ *       }
+ *
+ *       Rectangle anchor = parent.getAnchor();
+ *       float scale = (float)anchor.width/wmfStore.getWidthPixels();
+ *
+ *       org.apache.batik.transcoder.wmf.tosvg.WMFPainter painter =
+ *               new org.apache.batik.transcoder.wmf.tosvg.WMFPainter(wmfStore, 0, 0, scale);
+ *       graphics.translate(anchor.x, anchor.y);
+ *       painter.paint(graphics);
+ *   }
+ * }
+ * PictureData.setImagePainter(Picture.WMF, new WMFPaiter());
+ * ...
+ * </code>
+ * Subsequent calls of Slide.draw(Graphics gr) will use WMFPaiter for WMF images.
+ *
+ * @author  Yegor Kozlov.
+ */
+public interface ImagePainter {
+
+    /**
+     * Paints the specified picture data
+     *
+     * @param graphics  the graphics to paintb into
+     * @param pict      the data to paint
+     * @param parent    the shapes that owns the picture data
+     */
+    public void paint(Graphics2D graphics, PictureData pict, Picture parent);
+}
index cad42dc67c8d24ace2a5eb6586efb65fdf5dbb14..65ade3ee385b3eb11c814c59481b0e8762a84ed9 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.blip;
 
 import org.apache.poi.hslf.model.Picture;
 
 /**
  * Represents a JPEG picture data in a PPT file
- * 
+ *
  * @author Yegor Kozlov
  */
-public class JPEG extends Bitmap {
+public final class JPEG extends Bitmap {
 
     /**
      * @return type of  this picture
index c3895d1d93ee00aa7d8f82525a094dccd54d69dc..8a4d5aeb81f35bae494495c93482da325fced4f4 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.blip;
 
 import org.apache.poi.util.LittleEndian;
@@ -27,7 +28,7 @@ import java.util.zip.InflaterInputStream;
 /**
  * Represents a metafile picture which can be one of the following types: EMF, WMF, or PICT.
  * A metafile is stored compressed using the ZIP deflate/inflate algorithm.
- * 
+ *
  * @author Yegor Kozlov
  */
 public abstract class Metafile extends PictureData {
index fce1bc803a6cc48515c891f8c3f50c61ee05d370..5fe6bccec91d224149d33782d2b1ce7acce3665d 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.blip;
 
 import org.apache.poi.hslf.model.Picture;
@@ -27,10 +28,10 @@ import java.util.zip.DeflaterOutputStream;
 
 /**
  * Represents Macintosh PICT picture data.
- * 
+ *
  * @author Yegor Kozlov
  */
-public class PICT extends Metafile {
+public final class PICT extends Metafile {
 
     public PICT(){
         super();
index a72d3b6c10d2931e1150d3b75ac2e1c64aa31710..20016fd6b3bbe59a549dec60a16929694057e23a 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.blip;
 
 import org.apache.poi.hslf.model.Picture;
@@ -26,10 +27,10 @@ import java.io.IOException;
 
 /**
  * Represents a PNG picture data in a PPT file
- * 
+ *
  * @author Yegor Kozlov
  */
-public class PNG extends Bitmap {
+public final class PNG extends Bitmap {
 
     /**
      * @return PNG data
index b7f22c137b85abade91294ef3aec3ef330b365a1..acc74276ad01396a67f3afb4bfeccacc64eb120d 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.blip;
 
 import org.apache.poi.util.LittleEndian;
@@ -28,10 +29,10 @@ import java.util.zip.DeflaterOutputStream;
 
 /**
  * Represents a WMF (Windows Metafile) picture data.
- * 
+ *
  * @author Yegor Kozlov
  */
-public class WMF extends Metafile {
+public final class WMF extends Metafile {
 
     /**
      * Extract compressed WMF data from a ppt
index d69f45b1551e199cab9e5a3cd97bf8541d49a90d..f46906f73c63579327b519a9d8e6fbd7a9e012cd 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
@@ -16,8 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
-
 package org.apache.poi.hslf.dev;
 
 import org.apache.poi.hslf.*;
@@ -29,7 +26,7 @@ import org.apache.poi.hslf.record.*;
  * Having found them, it sees if they have DDF Textbox records, and if so,
  *  searches those for text. Prints out any text it finds
  */
-public class PPDrawingTextListing {
+public final class PPDrawingTextListing {
        public static void main(String[] args) throws Exception {
                if(args.length < 1) {
                        System.err.println("Need to give a filename");
index 8a68f8b37bd9c1e1ea9c37c5a840d75fef1cbb71..4b2c9b913b7516ff9f1f9dde05c4c51f49a3316f 100644 (file)
@@ -28,7 +28,7 @@ import java.io.*;
  * @author Yegor Kozlov
  */
 
-public class PPTXMLDump {
+public final class PPTXMLDump {
     public static final int HEADER_SIZE = 8; //size of the record header
     public static final int PICT_HEADER_SIZE = 25; //size of the picture header
     public final static String PPDOC_ENTRY = "PowerPoint Document";
index 8287e48a3b49ed57267d6427334be8079ab1b779..490e3e20554c13199be06e0007fe2d4286c70efa 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
@@ -16,8 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
-
 package org.apache.poi.hslf.dev;
 
 import org.apache.poi.hslf.HSLFSlideShow;
@@ -31,7 +28,7 @@ import org.apache.poi.hslf.record.SlideListWithText;
  * Having found them, it sees if they have any SlideListWithTexts,
  *  and reports how many, and what sorts of things they contain
  */
-public class SLWTListing {
+public final class SLWTListing {
        public static void main(String[] args) throws Exception {
                if(args.length < 1) {
                        System.err.println("Need to give a filename");
@@ -46,7 +43,7 @@ public class SLWTListing {
                        if(records[i] instanceof Document) {
                                Document doc = (Document)records[i];
                                SlideListWithText[] slwts = doc.getSlideListWithTexts();
-                               
+
                                System.out.println("Document at " + i + " had " + slwts.length + " SlideListWithTexts");
                                if(slwts.length == 0) {
                                        System.err.println("** Warning: Should have had at least 1! **");
@@ -54,14 +51,14 @@ public class SLWTListing {
                                if(slwts.length > 3) {
                                        System.err.println("** Warning: Shouldn't have more than 3!");
                                }
-                               
+
                                // Check the SLWTs contain what we'd expect
                                for(int j=0; j<slwts.length; j++) {
                                        SlideListWithText slwt = slwts[j];
                                        Record[] children = slwt.getChildRecords();
-                                       
+
                                        System.out.println(" - SLWT at " + j + " had " + children.length + " children:");
-                                       
+
                                        // Should only have SlideAtomSets if the second one
                                        int numSAS = slwt.getSlideAtomsSets().length;
                                        if(j == 1) {
@@ -75,7 +72,7 @@ public class SLWTListing {
                                                        System.err.println("  ** SLWT " + j + " had " + numSAS + " SlideAtomSets! (expected 0)");
                                                }
                                        }
-                                       
+
                                        // Report the first 5 children, to give a flavour
                                        int upTo = 5;
                                        if(children.length < 5) { upTo = children.length; }
index 97c3516774cf4fe49b912a31a3baf48a303e1c57..16858aa3dbc5f27bf42272f765bf6d4becbbb7d4 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
@@ -16,8 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
-
 package org.apache.poi.hslf.dev;
 
 import org.apache.poi.hslf.*;
@@ -28,7 +25,7 @@ import org.apache.poi.hslf.record.*;
  * Having found them, it sees if they have any text, and prints out
  *  what it finds.
  */
-public class SLWTTextListing {
+public final class SLWTTextListing {
        public static void main(String[] args) throws Exception {
                if(args.length < 1) {
                        System.err.println("Need to give a filename");
@@ -48,7 +45,7 @@ public class SLWTTextListing {
                                                System.out.println("Found SLWT at pos " + j + " in the Document at " + i);
                                                System.out.println("  Has " + docChildren[j].getChildRecords().length + " children");
 
-                                               // Grab the SlideAtomSet's, which contain 
+                                               // Grab the SlideAtomSet's, which contain
                                                //  a SlidePersistAtom and then a bunch of text
                                                //  + related records
                                                SlideListWithText slwt = (SlideListWithText)docChildren[j];
index a574d043eb3827fb3a0af183f9f9d5f9d0ef3b07..2dd32a4af064dba482834521f3c4480d31b717cf 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
@@ -16,8 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
-
 package org.apache.poi.hslf.dev;
 
 import org.apache.poi.hslf.*;
@@ -30,7 +27,7 @@ import org.apache.poi.hslf.record.*;
  *  what they are all about. Useful for checking the matching between
  *  Slides, Master Slides and Notes
  */
-public class SlideAndNotesAtomListing {
+public final class SlideAndNotesAtomListing {
        public static void main(String[] args) throws Exception {
                if(args.length < 1) {
                        System.err.println("Need to give a filename");
index 3889e6c345b3b6247aa9a17efc91b55e68e980b5..584ee1f29a8fa76bd47e32e2c911429cdfcbd131 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
@@ -16,8 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
-
 package org.apache.poi.hslf.dev;
 
 import org.apache.poi.hslf.*;
@@ -34,7 +31,7 @@ import java.util.Hashtable;
  *  in them, and displays them, so you can try to guess what they
  *  all mean
  */
-public class SlideIdListing {
+public final class SlideIdListing {
        private static byte[] fileContents;
 
        public static void main(String[] args) throws Exception {
@@ -47,12 +44,12 @@ public class SlideIdListing {
                // Create the slideshow object, for normal working with
                HSLFSlideShow hss = new HSLFSlideShow(args[0]);
                SlideShow ss = new SlideShow(hss);
-               
+
                // Grab the base contents
                fileContents = hss.getUnderlyingBytes();
                Record[] records = hss.getRecords();
                Record[] latestRecords = ss.getMostRecentCoreRecords();
-               
+
                // Grab any records that interest us
                Document document = null;
                for(int i=0; i<latestRecords.length; i++) {
@@ -60,10 +57,10 @@ public class SlideIdListing {
                                document = (Document)latestRecords[i];
                        }
                }
-               
+
                System.out.println("");
-               
-               
+
+
                // Look for SlidePersistAtoms, and report what they have to
                //  say about possible slide IDs
                SlideListWithText[] slwts = document.getSlideListWithTexts();
@@ -78,9 +75,9 @@ public class SlideIdListing {
                                }
                        }
                }
-               
+
                System.out.println("");
-               
+
                // Look for latest core records that are slides or notes
                for(int i=0; i<latestRecords.length; i++) {
                        if(latestRecords[i] instanceof Slide) {
@@ -108,7 +105,7 @@ public class SlideIdListing {
                }
 
                System.out.println("");
-               
+
                // Find any persist ones first
                int pos = 0;
                for(int i=0; i<records.length; i++) {
@@ -159,7 +156,7 @@ public class SlideIdListing {
                long rlen = LittleEndian.getUInt(fileContents, pos+4);
 
                Record r = Record.createRecordForType(type,fileContents,pos,(int)rlen+8);
-               
+
                return r;
        }
 }
index 838fa95c9e552f248fe6b33466cadb56efe9a15a..30001632754536f54ac3ce5c4cb3f43a74061e32 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.dev;
 
@@ -40,14 +37,14 @@ import org.apache.poi.util.LittleEndian;
  * To figure out what things are, and if they are atoms or not, used the
  *  list in hslf.record.RecordTypes
  *
- * To peek inside PPDrawings, which hold Escher drawings, we use the 
+ * To peek inside PPDrawings, which hold Escher drawings, we use the
  *  DDF package from POI (but we can fake it by using the Escher listings
  *  from hslf.record.RecordTypes also)
- * 
+ *
  * @author Nick Burch
  */
 
-public class SlideShowDumper
+public final class SlideShowDumper
 {
   private InputStream istream;
   private POIFSFileSystem filesystem;
@@ -91,7 +88,7 @@ public class SlideShowDumper
 
 
   /**
-   * Constructs a Powerpoint dump from fileName. Parses the document 
+   * Constructs a Powerpoint dump from fileName. Parses the document
    * and dumps out the contents
    *
    * @param fileName The name of the file to read.
@@ -101,9 +98,9 @@ public class SlideShowDumper
   {
        this(new FileInputStream(fileName));
   }
-  
+
   /**
-   * Constructs a Powerpoint dump from an input stream. Parses the 
+   * Constructs a Powerpoint dump from an input stream. Parses the
    * document and dumps out the contents
    *
    * @param inputStream the source of the data
@@ -117,7 +114,7 @@ public class SlideShowDumper
   }
 
   /**
-   * Constructs a Powerpoint dump from a POIFS Filesystem. Parses the 
+   * Constructs a Powerpoint dump from a POIFS Filesystem. Parses the
    * document and dumps out the contents
    *
    * @param filesystem the POIFS FileSystem to read from
@@ -189,7 +186,7 @@ public class SlideShowDumper
        //     (type 1001 = document atom, info 00 01 normal, 28 bytes long)
 
        // When parsing a document, look to see if you know about that type
-       //  of the current record. If you know it's a type that has children, 
+       //  of the current record. If you know it's a type that has children,
        //  process the record's data area looking for more records
        // If you know about the type and it doesn't have children, either do
        //  something with the data (eg TextRun) or skip over it
index 2296f7077ca791455dc85a859154857b6421cd3a..87662adedaedba1bcd2d08fbb31f40910c877cd6 100644 (file)
@@ -58,10 +58,10 @@ public final class SlideShowRecordDumper {
        boolean escher = false;
 
        int ndx=0;
-       for (; ndx<args.length; ndx++) {                
+       for (; ndx<args.length; ndx++) {
                if (!args[ndx].substring(0,1).equals("-"))
                        break;
-                               
+
                if (args[ndx].equals("-escher")) {
                        escher = true;
                } else if (args[ndx].equals("-verbose")) {
@@ -71,20 +71,20 @@ public final class SlideShowRecordDumper {
                        return;
                }
        }
-       
+
        // parsed any options, expect exactly one remaining arg (filename)
        if (ndx != args.length-1) {
                printUsage();
                return;
        }
-       
+
        filename = args[ndx];
 
        SlideShowRecordDumper foo = new SlideShowRecordDumper(filename, verbose, escher);
 
        foo.printDump();
   }
-  
+
   public static void printUsage() {
                System.err.println("Usage: SlideShowRecordDumper [-escher] [-verbose] <filename>");
                System.err.println("Valid Options:");
@@ -94,7 +94,7 @@ public final class SlideShowRecordDumper {
 
 
   /**
-   * Constructs a Powerpoint dump from fileName. Parses the document 
+   * Constructs a Powerpoint dump from fileName. Parses the document
    * and dumps out the contents
    *
    * @param fileName The name of the file to read.
@@ -139,7 +139,7 @@ public final class SlideShowRecordDumper {
 
   public int getDiskLen(Record r) throws IOException {
        if (r == null) return 0;
-       
+
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        r.writeOut(baos);
        byte[] b = baos.toByteArray();
@@ -148,13 +148,13 @@ public final class SlideShowRecordDumper {
 
   public String getPrintableRecordContents(Record r) throws IOException {
        if (r==null) return "<<null>>";
-       
+
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        r.writeOut(baos);
        byte[] b = baos.toByteArray();
        return HexDump.dump(b, 0, 0);
   }
-  
+
   public String printEscherRecord( EscherRecord er ) {
         String nl = System.getProperty( "line.separator" );
         StringBuffer buf = new StringBuffer();
@@ -163,41 +163,41 @@ public final class SlideShowRecordDumper {
                        buf.append(printEscherContainerRecord( (EscherContainerRecord)er ));
                } else if (er instanceof EscherTextboxRecord) {
                        buf.append("EscherTextboxRecord:" + nl);
-                       
+
                        EscherTextboxWrapper etw = new EscherTextboxWrapper((EscherTextboxRecord)er);
                        Record children[] = etw.getChildRecords();
                        for (int j=0; j<children.length; j++) {
                                if (children[j] instanceof StyleTextPropAtom) {
-                                       
+
                                        // need preceding Text[Chars|Bytes]Atom to initialize the data structure
-                                       if (j > 0 && (children[j-1] instanceof TextCharsAtom || 
+                                       if (j > 0 && (children[j-1] instanceof TextCharsAtom ||
                                                                  children[j-1] instanceof TextBytesAtom)) {
-                                                                       
-                                               int size = (children[j-1] instanceof TextCharsAtom) ? 
-                                                                               ((TextCharsAtom)children[j-1]).getText().length() : 
+
+                                               int size = (children[j-1] instanceof TextCharsAtom) ?
+                                                                               ((TextCharsAtom)children[j-1]).getText().length() :
                                                                                ((TextBytesAtom)children[j-1]).getText().length();
-                                                                               
+
                                                StyleTextPropAtom tsp = (StyleTextPropAtom)children[j];
                                                tsp.setParentTextSize(size);
-                                               
+
                                        } else {
                                                buf.append("Error! Couldn't find preceding TextAtom for style\n");
                                        }
-                                       
+
                                        buf.append(children[j].toString() + nl );
-                               } else {                                
+                               } else {
                                        buf.append(children[j].toString() + nl );
                                }
                        }
                } else {
                        buf.append( er.toString() );
-               }                       
+               }
                return buf.toString();
   }
-  
+
   public String printEscherContainerRecord( EscherContainerRecord ecr ) {
                String indent = "";
-               
+
         String nl = System.getProperty( "line.separator" );
 
         StringBuffer children = new StringBuffer();
@@ -211,13 +211,13 @@ public final class SlideShowRecordDumper {
 
             EscherRecord record = iterator.next();
             children.append(newIndent + "Child " + count + ":" + nl);
-            
+
                children.append( printEscherRecord(record) );
 
             count++;
         }
 
-        return 
+        return
                indent + ecr.getClass().getName() + " (" + ecr.getRecordName() + "):" + nl +
             indent + "  isContainer: " + ecr.isContainerRecord() + nl +
             indent + "  options: 0x" + HexDump.toHex( ecr.getOptions() ) + nl +
@@ -242,7 +242,7 @@ public final class SlideShowRecordDumper {
 
                // Figure out how big it is
                int len = getDiskLen(r);
-               
+
                // Grab the type as hex
                String hexType = makeHex((int)r.getRecordType(),4);
                String rHexType = reverseHex(hexType);
@@ -273,9 +273,9 @@ public final class SlideShowRecordDumper {
 
                        EscherRecord er = factory.createRecord(b, 0);
                        er.fillFields(b, 0, factory);
-                       
+
                        System.out.println( printEscherRecord( er ) );
-                                               
+
                } else if(optVerbose && r.getChildRecords() == null) {
                        String recData = getPrintableRecordContents(r);
                        System.out.println(ind + recData );
index fa19398d27085fabe4666d6665360f09e90ab27c..0ee4fbd0df9c4c0a146e4bebc97904b510791156 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
@@ -16,8 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
-
 package org.apache.poi.hslf.dev;
 
 import org.apache.poi.hslf.*;
@@ -33,7 +30,7 @@ import java.util.LinkedList;
  * Uses record level code to locate StyleTextPropAtom entries.
  * Having found them, it shows the contents
  */
-public class TextStyleListing {
+public final class TextStyleListing {
        public static void main(String[] args) throws Exception {
                if(args.length < 1) {
                        System.err.println("Need to give a filename");
@@ -84,7 +81,7 @@ public class TextStyleListing {
                        System.out.println("  Characters covered is " + tpc.getCharactersCovered());
                        showTextProps(tpc);
                }
-               
+
                LinkedList charStyles = stpa.getCharacterStyles();
                System.out.println("Contains " + charStyles.size() + " character styles:");
                for(int i=0; i<charStyles.size(); i++) {
index c5fb833364284bb8916f58c4830194b61f5f9c35..73fd29604d569d3bacc0ed38b0e00d5cae7790e4 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
@@ -16,8 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
-
 package org.apache.poi.hslf.dev;
 
 import org.apache.poi.hslf.*;
@@ -37,7 +34,7 @@ import java.util.Hashtable;
  *  persistence related atoms. Tries to match them together, to help
  *  illuminate quite what all the offsets mean
  */
-public class UserEditAndPersistListing {
+public final class UserEditAndPersistListing {
        private static byte[] fileContents;
 
        public static void main(String[] args) throws Exception {
@@ -122,7 +119,7 @@ public class UserEditAndPersistListing {
                CurrentUserAtom cua = ss.getCurrentUserAtom();
                System.out.println("Checking Current User Atom");
                System.out.println("  Thinks the CurrentEditOffset is " + cua.getCurrentEditOffset());
-               
+
                System.out.println("");
        }
 
@@ -133,7 +130,7 @@ public class UserEditAndPersistListing {
                long rlen = LittleEndian.getUInt(fileContents, pos+4);
 
                Record r = Record.createRecordForType(type,fileContents,pos,(int)rlen+8);
-               
+
                return r;
        }
 }
index d0af91f0dabbf89291d85fd0948f05bee850607c..3e0bf5a9afc0afe9e8ff07ac3139c69a71ac07b3 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.exceptions;
 
@@ -27,7 +24,7 @@ package org.apache.poi.hslf.exceptions;
  * @author Nick Burch
  */
 
-public class CorruptPowerPointFileException extends IllegalStateException
+public final class CorruptPowerPointFileException extends IllegalStateException
 {
        public CorruptPowerPointFileException(String s) {
                super(s);
index 08eabd223b6056bfeb2a30d4174c96ab31b5ef8b..862450a1cc3e7e5f0891a525e1872cad1ebd105e 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.exceptions;
 
 import org.apache.poi.EncryptedDocumentException;
@@ -22,7 +23,7 @@ import org.apache.poi.EncryptedDocumentException;
  * This exception is thrown when we try to open a PowerPoint file, and
  *  discover that it is encrypted
  */
-public class EncryptedPowerPointFileException extends EncryptedDocumentException
+public final class EncryptedPowerPointFileException extends EncryptedDocumentException
 {
        public EncryptedPowerPointFileException(String s) {
                super(s);
index 5e9f7e815b760aeba4be5c33b8f1ad0229b73d88..f534d9ce0debf3956a071d004259dffe140a1536 100644 (file)
@@ -1,43 +1,42 @@
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.exceptions;\r
-\r
-/**\r
- * A generic exception that can be thrown by HSLF classes\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class HSLFException extends RuntimeException {\r
-\r
-    public HSLFException() {\r
-           super();\r
-    }\r
-\r
-   public HSLFException(String message) {\r
-           super(message);\r
-    }\r
-\r
-   public HSLFException(String message, Throwable cause) {\r
-        super(message, cause);\r
-    }\r
-\r
-    public HSLFException(Throwable cause) {\r
-        super(cause);\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.exceptions;
+
+/**
+ * A generic exception that can be thrown by HSLF classes
+ *
+ * @author Yegor Kozlov
+ */
+public final class HSLFException extends RuntimeException {
+
+    public HSLFException() {
+           super();
+    }
+
+   public HSLFException(String message) {
+           super(message);
+    }
+
+   public HSLFException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public HSLFException(Throwable cause) {
+        super(cause);
+    }
+}
index a5943486f1a15146389f8450dd73cedddcb7a743..46df9c9621533bc60d678ecc595191267a919965 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.exceptions;
 
@@ -27,7 +24,7 @@ package org.apache.poi.hslf.exceptions;
  * @author Nick Burch
  */
 
-public class InvalidRecordFormatException extends Exception
+public final class InvalidRecordFormatException extends Exception
 {
        public InvalidRecordFormatException(String s) {
                super(s);
index 8f4aecd2e15f479b41b8ff06947faac392662fa9..24d6d9096ec63e011498f0f4ea05ca46f3c7ff2d 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,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.extractor;
 
 import org.apache.poi.hslf.usermodel.SlideShow;
@@ -30,7 +30,7 @@ import java.io.FileOutputStream;
  *
  * @author Yegor Kozlov
  */
-public class ImageExtractor {
+public final class ImageExtractor {
     public static void main(String args[]) throws IOException {
         if (args.length < 1) {
             System.err.println("Usage:");
index cc0205647b4d063314c2739a312848317d78e2a3..5e6cad510041c5697e327711407b2f74e2bec044 100644 (file)
@@ -43,7 +43,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
        private HSLFSlideShow _hslfshow;
        private SlideShow _show;
        private Slide[] _slides;
-       
+
        private boolean slidesByDefault = true;
        private boolean notesByDefault = false;
        private boolean commentsByDefault = false;
@@ -135,7 +135,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
        }
 
        /**
-        * Fetches all the slide text from the slideshow, 
+        * Fetches all the slide text from the slideshow,
         *  but not the notes, unless you've called
         *  setSlidesByDefault() and setNotesByDefault()
         *  to change this
@@ -162,18 +162,18 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
          return getText(getSlideText, getNoteText, commentsByDefault);
   }
   public String getText(boolean getSlideText, boolean getNoteText, boolean getCommentText) {
-       StringBuffer ret = new StringBuffer(); 
+       StringBuffer ret = new StringBuffer();
 
        if(getSlideText) {
                for(int i=0; i<_slides.length; i++) {
                        Slide slide = _slides[i];
-                       
+
                        // Slide header, if set
                        HeadersFooters hf = slide.getHeadersFooters();
                        if(hf != null && hf.isHeaderVisible() && hf.getHeaderText() != null) {
                                ret.append(hf.getHeaderText() + "\n");
                        }
-                       
+
                        // Slide text
                        TextRun[] runs = slide.getTextRuns();
                        for(int j=0; j<runs.length; j++) {
@@ -186,20 +186,20 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
                                        }
                                }
                        }
-                       
+
                        // Slide footer, if set
                        if(hf != null && hf.isFooterVisible() && hf.getFooterText() != null) {
                                ret.append(hf.getFooterText() + "\n");
                        }
-                       
+
                        // Comments, if requested and present
                        if(getCommentText) {
                                Comment[] comments = slide.getComments();
                                for(int j=0; j<comments.length; j++) {
                                        ret.append(
-                                                       comments[j].getAuthor() + 
+                                                       comments[j].getAuthor() +
                                                        " - " +
-                                                       comments[j].getText() + 
+                                                       comments[j].getText() +
                                                        "\n"
                                        );
                                }
@@ -216,14 +216,14 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
                //  but ensure no duplicates
                HashSet seenNotes = new HashSet();
                HeadersFooters hf = _show.getNotesHeadersFooters();
-               
+
                for(int i=0; i<_slides.length; i++) {
                        Notes notes = _slides[i].getNotesSheet();
                        if(notes == null) { continue; }
                        Integer id = new Integer(notes._getSheetNumber());
                        if(seenNotes.contains(id)) { continue; }
                        seenNotes.add(id);
-                       
+
                        // Repeat the Notes header, if set
                        if(hf != null && hf.isHeaderVisible() && hf.getHeaderText() != null) {
                                ret.append(hf.getHeaderText() + "\n");
@@ -241,7 +241,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
                                        }
                                }
                        }
-                       
+
                        // Repeat the notes footer, if set
                        if(hf != null && hf.isFooterVisible() && hf.getFooterText() != null) {
                                ret.append(hf.getFooterText() + "\n");
@@ -251,4 +251,4 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
 
        return ret.toString();
   }
-}
\ No newline at end of file
+}
index 3231a78a8ce2bba97deafec114c826b19397145c..9dfa6ce9d0c05f678285d72fa509984a435db80f 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.extractor;
 
@@ -42,12 +39,12 @@ import org.apache.poi.hslf.model.TextRun;
  * This class will get all the text from a Powerpoint Document, including
  *  all the bits you didn't want, and in a somewhat random order, but will
  *  do it very fast.
- * The class ignores most of the hslf classes, and doesn't use 
+ * The class ignores most of the hslf classes, and doesn't use
  *  HSLFSlideShow. Instead, it just does a very basic scan through the
  *  file, grabbing all the text records as it goes. It then returns the
  *  text, either as a single string, or as a vector of all the individual
  *  strings.
- * Because of how it works, it will return a lot of "crud" text that you 
+ * Because of how it works, it will return a lot of "crud" text that you
  *  probably didn't want! It will return text from master slides. It will
  *  return duplicate text, and some mangled text (powerpoint files often
  *  have duplicate copies of slide text in them). You don't get any idea
@@ -59,7 +56,7 @@ import org.apache.poi.hslf.model.TextRun;
  * @author Nick Burch
  */
 
-public class QuickButCruddyTextExtractor
+public final class QuickButCruddyTextExtractor
 {
        private POIFSFileSystem fs;
        private InputStream is;
@@ -193,12 +190,12 @@ public class QuickButCruddyTextExtractor
                        TextCharsAtom tca = (TextCharsAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
                        trun = new TextRun((TextHeaderAtom)null,tca,(StyleTextPropAtom)null);
                }
-               
+
                // CString (doesn't go via a TextRun)
                if(type == RecordTypes.CString.typeID) {
                        CString cs = (CString)Record.createRecordForType(type, pptContents, startPos, len+8);
                        String text = cs.getText();
-                       
+
                        // Ignore the ones we know to be rubbish
                        if(text.equals("___PPT10")) {
                        } else if(text.equals("Default Design")) {
@@ -211,10 +208,10 @@ public class QuickButCruddyTextExtractor
                if(trun != null) {
                        textV.add(trun.getText());
                }
-               
+
                // Wind on by the atom length, and check we're not at the end
                int newPos = (startPos + 8 + len);
-               if(newPos > (pptContents.length - 8)) { 
+               if(newPos > (pptContents.length - 8)) {
                        newPos = -1;
                }
                return newPos;
index 829e0104a76349951557bf2b556382b0f3147eb2..c9b55082b34f7d3a5dbae32c7c9cfb3d93d8a3b2 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.ddf.*;\r
-import org.apache.poi.hslf.record.*;\r
-import org.apache.poi.hslf.exceptions.HSLFException;\r
-import org.apache.poi.util.LittleEndian;\r
-\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.UnsupportedEncodingException;\r
-import java.util.Iterator;\r
-\r
-/**\r
- * Represents an ActiveX control in a PowerPoint document.\r
- *\r
- * TODO: finish\r
- * @author Yegor Kozlov\r
- */\r
-public final class ActiveXShape extends Picture {\r
-    public static final int DEFAULT_ACTIVEX_THUMBNAIL = -1;\r
-\r
-    /**\r
-     * Create a new <code>Picture</code>\r
-     *\r
-    * @param pictureIdx the index of the picture\r
-     */\r
-    public ActiveXShape(int movieIdx, int pictureIdx){\r
-        super(pictureIdx, null);\r
-        setActiveXIndex(movieIdx);\r
-    }\r
-\r
-    /**\r
-      * Create a <code>Picture</code> object\r
-      *\r
-      * @param escherRecord the <code>EscherSpContainer</code> record which holds information about\r
-      *        this picture in the <code>Slide</code>\r
-      * @param parent the parent shape of this picture\r
-      */\r
-     protected ActiveXShape(EscherContainerRecord escherRecord, Shape parent){\r
-        super(escherRecord, parent);\r
-    }\r
-\r
-    /**\r
-     * Create a new Placeholder and initialize internal structures\r
-     *\r
-     * @return the created <code>EscherContainerRecord</code> which holds shape data\r
-     */\r
-    protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {\r
-        _escherContainer = super.createSpContainer(idx, isChild);\r
-\r
-        EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);\r
-        spRecord.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE | EscherSpRecord.FLAG_OLESHAPE);\r
-\r
-        setShapeType(ShapeTypes.HostControl);\r
-        setEscherProperty(EscherProperties.BLIP__PICTUREID, idx);\r
-        setEscherProperty(EscherProperties.LINESTYLE__COLOR, 0x8000001);\r
-        setEscherProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80008);\r
-        setEscherProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);\r
-        setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, -1);\r
-\r
-        EscherClientDataRecord cldata = new EscherClientDataRecord();\r
-        cldata.setOptions((short)0xF);\r
-        _escherContainer.addChildRecord(cldata); // TODO unit test to prove getChildRecords().add is wrong\r
-\r
-        OEShapeAtom oe = new OEShapeAtom();\r
-\r
-        //convert hslf into ddf\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        try {\r
-            oe.writeOut(out);\r
-        } catch(Exception e){\r
-            throw new HSLFException(e);\r
-        }\r
-        cldata.setRemainingData(out.toByteArray());\r
-\r
-        return _escherContainer;\r
-    }\r
-\r
-    /**\r
-     * Assign a control to this shape\r
-     *\r
-     * @see org.apache.poi.hslf.usermodel.SlideShow#addMovie(String, int)\r
-     * @param idx  the index of the movie\r
-     */\r
-    public void setActiveXIndex(int idx){\r
-        EscherContainerRecord spContainer = getSpContainer();\r
-        for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext();) {\r
-            EscherRecord obj = it.next();\r
-            if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {\r
-                EscherClientDataRecord clientRecord = (EscherClientDataRecord)obj;\r
-                byte[] recdata = clientRecord.getRemainingData();\r
-                LittleEndian.putInt(recdata, 8, idx);\r
-            }\r
-        }\r
-    }\r
-\r
-    public int getControlIndex(){\r
-        int idx = -1;\r
-        OEShapeAtom oe = (OEShapeAtom)getClientDataRecord(RecordTypes.OEShapeAtom.typeID);\r
-        if(oe != null) idx = oe.getOptions();\r
-        return idx;\r
-    }\r
-\r
-    /**\r
-     * Set a property of this ActiveX control\r
-     * @param key\r
-     * @param value\r
-     */\r
-    public void setProperty(String key, String value){\r
-\r
-    }\r
-\r
-    /**\r
-     * Document-level container that specifies information about an ActiveX control\r
-     *\r
-     * @return container that specifies information about an ActiveX control\r
-     */\r
-    public ExControl getExControl(){\r
-        int idx = getControlIndex();\r
-        ExControl ctrl = null;\r
-        Document doc = getSheet().getSlideShow().getDocumentRecord();\r
-        ExObjList lst = (ExObjList)doc.findFirstOfType(RecordTypes.ExObjList.typeID);\r
-        if(lst != null){\r
-            Record[] ch = lst.getChildRecords();\r
-            for (int i = 0; i < ch.length; i++) {\r
-                if(ch[i] instanceof ExControl){\r
-                    ExControl c = (ExControl)ch[i];\r
-                    if(c.getExOleObjAtom().getObjID() == idx){\r
-                        ctrl = c;\r
-                        break;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return ctrl;\r
-    }\r
-\r
-    protected void afterInsert(Sheet sheet){\r
-        ExControl ctrl = getExControl();\r
-        ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber());\r
-\r
-        try {\r
-            String name = ctrl.getProgId() + "-" + getControlIndex();\r
-            byte[] data = (name + '\u0000').getBytes("UTF-16LE");\r
-            EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.GROUPSHAPE__SHAPENAME, false, data);\r
-            EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);\r
-            opt.addEscherProperty(prop);\r
-        } catch (UnsupportedEncodingException e){\r
-            throw new HSLFException(e);\r
-        }\r
-\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import org.apache.poi.ddf.*;
+import org.apache.poi.hslf.record.*;
+import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.util.LittleEndian;
+
+import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Iterator;
+
+/**
+ * Represents an ActiveX control in a PowerPoint document.
+ *
+ * TODO: finish
+ * @author Yegor Kozlov
+ */
+public final class ActiveXShape extends Picture {
+    public static final int DEFAULT_ACTIVEX_THUMBNAIL = -1;
+
+    /**
+     * Create a new <code>Picture</code>
+     *
+    * @param pictureIdx the index of the picture
+     */
+    public ActiveXShape(int movieIdx, int pictureIdx){
+        super(pictureIdx, null);
+        setActiveXIndex(movieIdx);
+    }
+
+    /**
+      * Create a <code>Picture</code> object
+      *
+      * @param escherRecord the <code>EscherSpContainer</code> record which holds information about
+      *        this picture in the <code>Slide</code>
+      * @param parent the parent shape of this picture
+      */
+     protected ActiveXShape(EscherContainerRecord escherRecord, Shape parent){
+        super(escherRecord, parent);
+    }
+
+    /**
+     * Create a new Placeholder and initialize internal structures
+     *
+     * @return the created <code>EscherContainerRecord</code> which holds shape data
+     */
+    protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
+        _escherContainer = super.createSpContainer(idx, isChild);
+
+        EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
+        spRecord.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE | EscherSpRecord.FLAG_OLESHAPE);
+
+        setShapeType(ShapeTypes.HostControl);
+        setEscherProperty(EscherProperties.BLIP__PICTUREID, idx);
+        setEscherProperty(EscherProperties.LINESTYLE__COLOR, 0x8000001);
+        setEscherProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80008);
+        setEscherProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
+        setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, -1);
+
+        EscherClientDataRecord cldata = new EscherClientDataRecord();
+        cldata.setOptions((short)0xF);
+        _escherContainer.addChildRecord(cldata); // TODO unit test to prove getChildRecords().add is wrong
+
+        OEShapeAtom oe = new OEShapeAtom();
+
+        //convert hslf into ddf
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try {
+            oe.writeOut(out);
+        } catch(Exception e){
+            throw new HSLFException(e);
+        }
+        cldata.setRemainingData(out.toByteArray());
+
+        return _escherContainer;
+    }
+
+    /**
+     * Assign a control to this shape
+     *
+     * @see org.apache.poi.hslf.usermodel.SlideShow#addMovie(String, int)
+     * @param idx  the index of the movie
+     */
+    public void setActiveXIndex(int idx){
+        EscherContainerRecord spContainer = getSpContainer();
+        for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext();) {
+            EscherRecord obj = it.next();
+            if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
+                EscherClientDataRecord clientRecord = (EscherClientDataRecord)obj;
+                byte[] recdata = clientRecord.getRemainingData();
+                LittleEndian.putInt(recdata, 8, idx);
+            }
+        }
+    }
+
+    public int getControlIndex(){
+        int idx = -1;
+        OEShapeAtom oe = (OEShapeAtom)getClientDataRecord(RecordTypes.OEShapeAtom.typeID);
+        if(oe != null) idx = oe.getOptions();
+        return idx;
+    }
+
+    /**
+     * Set a property of this ActiveX control
+     * @param key
+     * @param value
+     */
+    public void setProperty(String key, String value){
+
+    }
+
+    /**
+     * Document-level container that specifies information about an ActiveX control
+     *
+     * @return container that specifies information about an ActiveX control
+     */
+    public ExControl getExControl(){
+        int idx = getControlIndex();
+        ExControl ctrl = null;
+        Document doc = getSheet().getSlideShow().getDocumentRecord();
+        ExObjList lst = (ExObjList)doc.findFirstOfType(RecordTypes.ExObjList.typeID);
+        if(lst != null){
+            Record[] ch = lst.getChildRecords();
+            for (int i = 0; i < ch.length; i++) {
+                if(ch[i] instanceof ExControl){
+                    ExControl c = (ExControl)ch[i];
+                    if(c.getExOleObjAtom().getObjID() == idx){
+                        ctrl = c;
+                        break;
+                    }
+                }
+            }
+        }
+        return ctrl;
+    }
+
+    protected void afterInsert(Sheet sheet){
+        ExControl ctrl = getExControl();
+        ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber());
+
+        try {
+            String name = ctrl.getProgId() + "-" + getControlIndex();
+            byte[] data = (name + '\u0000').getBytes("UTF-16LE");
+            EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.GROUPSHAPE__SHAPENAME, false, data);
+            EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+            opt.addEscherProperty(prop);
+        } catch (UnsupportedEncodingException e){
+            throw new HSLFException(e);
+        }
+    }
+}
index 1fc4ec9932c28f3787b2a3890447dbca2933cd36..bc1cc1293f98473d6f966d272fca22e1d2a196a0 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.ddf.EscherProperties;\r
-\r
-import java.awt.geom.*;\r
-\r
-/**\r
- * Stores definition of auto-shapes.\r
- * See the Office Drawing 97-2007 Binary Format Specification for details.\r
- *\r
- * TODO: follow the spec and define all the auto-shapes\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class AutoShapes {\r
-    protected static ShapeOutline[] shapes;\r
-\r
-\r
-    /**\r
-     * Return shape outline by shape type\r
-     * @param type shape type see {@link ShapeTypes}\r
-     *\r
-     * @return the shape outline\r
-     */\r
-    public static ShapeOutline getShapeOutline(int type){\r
-        ShapeOutline outline = shapes[type];\r
-        return outline;\r
-    }\r
-\r
-    /**\r
-     * Auto-shapes are defined in the [0,21600] coordinate system.\r
-     * We need to transform it into normal slide coordinates\r
-     *\r
-    */\r
-    public static java.awt.Shape transform(java.awt.Shape outline, Rectangle2D anchor){\r
-        AffineTransform at = new AffineTransform();\r
-        at.translate(anchor.getX(), anchor.getY());\r
-        at.scale(\r
-                1.0f/21600*anchor.getWidth(),\r
-                1.0f/21600*anchor.getHeight()\r
-        );\r
-        return at.createTransformedShape(outline);\r
-    }\r
-\r
-    static {\r
-        shapes = new ShapeOutline[255];\r
-\r
-        shapes[ShapeTypes.Rectangle] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                Rectangle2D path = new Rectangle2D.Float(0, 0, 21600, 21600);\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.RoundRectangle] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);\r
-                RoundRectangle2D path = new RoundRectangle2D.Float(0, 0, 21600, 21600, adjval, adjval);\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.Ellipse] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                Ellipse2D path = new Ellipse2D.Float(0, 0, 21600, 21600);\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.Diamond] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(10800, 0);\r
-                path.lineTo(21600, 10800);\r
-                path.lineTo(10800, 21600);\r
-                path.lineTo(0, 10800);\r
-                path.closePath();\r
-                return path;\r
-           }\r
-        };\r
-\r
-        //m@0,l,21600r21600\r
-        shapes[ShapeTypes.IsocelesTriangle] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 10800);\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(adjval, 0);\r
-                path.lineTo(0, 21600);\r
-                path.lineTo(21600, 21600);\r
-                path.closePath();\r
-                return path;\r
-           }\r
-        };\r
-\r
-        shapes[ShapeTypes.RightTriangle] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(0, 0);\r
-                path.lineTo(21600, 21600);\r
-                path.lineTo(0, 21600);\r
-                path.closePath();\r
-                return path;\r
-           }\r
-        };\r
-\r
-        shapes[ShapeTypes.Parallelogram] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);\r
-\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(adjval, 0);\r
-                path.lineTo(21600, 0);\r
-                path.lineTo(21600 - adjval, 21600);\r
-                path.lineTo(0, 21600);\r
-                path.closePath();\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.Trapezoid] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);\r
-\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(0, 0);\r
-                path.lineTo(adjval, 21600);\r
-                path.lineTo(21600 - adjval, 21600);\r
-                path.lineTo(21600, 0);\r
-                path.closePath();\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.Hexagon] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);\r
-\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(adjval, 0);\r
-                path.lineTo(21600 - adjval, 0);\r
-                path.lineTo(21600, 10800);\r
-                path.lineTo(21600 - adjval, 21600);\r
-                path.lineTo(adjval, 21600);\r
-                path.lineTo(0, 10800);\r
-                path.closePath();\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.Octagon] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 6326);\r
-\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(adjval, 0);\r
-                path.lineTo(21600 - adjval, 0);\r
-                path.lineTo(21600, adjval);\r
-                path.lineTo(21600, 21600-adjval);\r
-                path.lineTo(21600-adjval, 21600);\r
-                path.lineTo(adjval, 21600);\r
-                path.lineTo(0, 21600-adjval);\r
-                path.lineTo(0, adjval);\r
-                path.closePath();\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.Plus] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);\r
-\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(adjval, 0);\r
-                path.lineTo(21600 - adjval, 0);\r
-                path.lineTo(21600 - adjval, adjval);\r
-                path.lineTo(21600, adjval);\r
-                path.lineTo(21600, 21600-adjval);\r
-                path.lineTo(21600-adjval, 21600-adjval);\r
-                path.lineTo(21600-adjval, 21600);\r
-                path.lineTo(adjval, 21600);\r
-                path.lineTo(adjval, 21600-adjval);\r
-                path.lineTo(0, 21600-adjval);\r
-                path.lineTo(0, adjval);\r
-                path.lineTo(adjval, adjval);\r
-                path.closePath();\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.Pentagon] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(10800, 0);\r
-                path.lineTo(21600, 8259);\r
-                path.lineTo(21600 - 4200, 21600);\r
-                path.lineTo(4200, 21600);\r
-                path.lineTo(0, 8259);\r
-                path.closePath();\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.DownArrow] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                //m0@0 l@1@0 @1,0 @2,0 @2@0,21600@0,10800,21600xe\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 16200);\r
-                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(0, adjval);\r
-                path.lineTo(adjval2, adjval);\r
-                path.lineTo(adjval2, 0);\r
-                path.lineTo(21600-adjval2, 0);\r
-                path.lineTo(21600-adjval2, adjval);\r
-                path.lineTo(21600, adjval);\r
-                path.lineTo(10800, 21600);\r
-                path.closePath();\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.UpArrow] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                //m0@0 l@1@0 @1,21600@2,21600@2@0,21600@0,10800,xe\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);\r
-                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(0, adjval);\r
-                path.lineTo(adjval2, adjval);\r
-                path.lineTo(adjval2, 21600);\r
-                path.lineTo(21600-adjval2, 21600);\r
-                path.lineTo(21600-adjval2, adjval);\r
-                path.lineTo(21600, adjval);\r
-                path.lineTo(10800, 0);\r
-                path.closePath();\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.Arrow] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                //m@0, l@0@1 ,0@1,0@2@0@2@0,21600,21600,10800xe\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 16200);\r
-                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(adjval, 0);\r
-                path.lineTo(adjval, adjval2);\r
-                path.lineTo(0, adjval2);\r
-                path.lineTo(0, 21600-adjval2);\r
-                path.lineTo(adjval, 21600-adjval2);\r
-                path.lineTo(adjval, 21600);\r
-                path.lineTo(21600, 10800);\r
-                path.closePath();\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.LeftArrow] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                //m@0, l@0@1,21600@1,21600@2@0@2@0,21600,,10800xe\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);\r
-                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(adjval, 0);\r
-                path.lineTo(adjval, adjval2);\r
-                path.lineTo(21600, adjval2);\r
-                path.lineTo(21600, 21600-adjval2);\r
-                path.lineTo(adjval, 21600-adjval2);\r
-                path.lineTo(adjval, 21600);\r
-                path.lineTo(0, 10800);\r
-                path.closePath();\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.Can] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                //m10800,qx0@1l0@2qy10800,21600,21600@2l21600@1qy10800,xem0@1qy10800@0,21600@1nfe\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);\r
-\r
-                GeneralPath path = new GeneralPath();\r
-\r
-                path.append(new Arc2D.Float(0, 0, 21600, adjval, 0, 180, Arc2D.OPEN), false);\r
-                path.moveTo(0, adjval/2);\r
-\r
-                path.lineTo(0, 21600 - adjval/2);\r
-                path.closePath();\r
-\r
-                path.append(new Arc2D.Float(0, 21600 - adjval, 21600, adjval, 180, 180, Arc2D.OPEN), false);\r
-                path.moveTo(21600, 21600 - adjval/2);\r
-\r
-                path.lineTo(21600, adjval/2);\r
-                path.append(new Arc2D.Float(0, 0, 21600, adjval, 180, 180, Arc2D.OPEN), false);\r
-                path.moveTo(0, adjval/2);\r
-                path.closePath();\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.LeftBrace] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                //m21600,qx10800@0l10800@2qy0@11,10800@3l10800@1qy21600,21600e\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 1800);\r
-                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 10800);\r
-\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(21600, 0);\r
-\r
-                path.append(new Arc2D.Float(10800, 0, 21600, adjval*2, 90, 90, Arc2D.OPEN), false);\r
-                path.moveTo(10800, adjval);\r
-\r
-                path.lineTo(10800, adjval2 - adjval);\r
-\r
-                path.append(new Arc2D.Float(-10800, adjval2 - 2*adjval, 21600, adjval*2, 270, 90, Arc2D.OPEN), false);\r
-                path.moveTo(0, adjval2);\r
-\r
-                path.append(new Arc2D.Float(-10800, adjval2, 21600, adjval*2, 0, 90, Arc2D.OPEN), false);\r
-                path.moveTo(10800, adjval2 + adjval);\r
-\r
-                path.lineTo(10800, 21600 - adjval);\r
-\r
-                path.append(new Arc2D.Float(10800, 21600 - 2*adjval, 21600, adjval*2, 180, 90, Arc2D.OPEN), false);\r
-\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.RightBrace] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                //m,qx10800@0 l10800@2qy21600@11,10800@3l10800@1qy,21600e\r
-                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 1800);\r
-                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 10800);\r
-\r
-                GeneralPath path = new GeneralPath();\r
-                path.moveTo(0, 0);\r
-\r
-                path.append(new Arc2D.Float(-10800, 0, 21600, adjval*2, 0, 90, Arc2D.OPEN), false);\r
-                path.moveTo(10800, adjval);\r
-\r
-                path.lineTo(10800, adjval2 - adjval);\r
-\r
-                path.append(new Arc2D.Float(10800, adjval2 - 2*adjval, 21600, adjval*2, 180, 90, Arc2D.OPEN), false);\r
-                path.moveTo(21600, adjval2);\r
-\r
-                path.append(new Arc2D.Float(10800, adjval2, 21600, adjval*2, 90, 90, Arc2D.OPEN), false);\r
-                path.moveTo(10800, adjval2 + adjval);\r
-\r
-                path.lineTo(10800, 21600 - adjval);\r
-\r
-                path.append(new Arc2D.Float(-10800, 21600 - 2*adjval, 21600, adjval*2, 270, 90, Arc2D.OPEN), false);\r
-\r
-                return path;\r
-            }\r
-        };\r
-\r
-        shapes[ShapeTypes.StraightConnector1] = new ShapeOutline(){\r
-            public java.awt.Shape getOutline(Shape shape){\r
-                return new Line2D.Float(0, 0, 21600, 21600);\r
-            }\r
-        };\r
-\r
-\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import org.apache.poi.ddf.EscherProperties;
+
+import java.awt.geom.*;
+
+/**
+ * Stores definition of auto-shapes.
+ * See the Office Drawing 97-2007 Binary Format Specification for details.
+ *
+ * TODO: follow the spec and define all the auto-shapes
+ *
+ * @author Yegor Kozlov
+ */
+public final class AutoShapes {
+    protected static ShapeOutline[] shapes;
+
+
+    /**
+     * Return shape outline by shape type
+     * @param type shape type see {@link ShapeTypes}
+     *
+     * @return the shape outline
+     */
+    public static ShapeOutline getShapeOutline(int type){
+        ShapeOutline outline = shapes[type];
+        return outline;
+    }
+
+    /**
+     * Auto-shapes are defined in the [0,21600] coordinate system.
+     * We need to transform it into normal slide coordinates
+     *
+    */
+    public static java.awt.Shape transform(java.awt.Shape outline, Rectangle2D anchor){
+        AffineTransform at = new AffineTransform();
+        at.translate(anchor.getX(), anchor.getY());
+        at.scale(
+                1.0f/21600*anchor.getWidth(),
+                1.0f/21600*anchor.getHeight()
+        );
+        return at.createTransformedShape(outline);
+    }
+
+    static {
+        shapes = new ShapeOutline[255];
+
+        shapes[ShapeTypes.Rectangle] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                Rectangle2D path = new Rectangle2D.Float(0, 0, 21600, 21600);
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.RoundRectangle] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
+                RoundRectangle2D path = new RoundRectangle2D.Float(0, 0, 21600, 21600, adjval, adjval);
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.Ellipse] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                Ellipse2D path = new Ellipse2D.Float(0, 0, 21600, 21600);
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.Diamond] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                GeneralPath path = new GeneralPath();
+                path.moveTo(10800, 0);
+                path.lineTo(21600, 10800);
+                path.lineTo(10800, 21600);
+                path.lineTo(0, 10800);
+                path.closePath();
+                return path;
+           }
+        };
+
+        //m@0,l,21600r21600
+        shapes[ShapeTypes.IsocelesTriangle] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 10800);
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(0, 21600);
+                path.lineTo(21600, 21600);
+                path.closePath();
+                return path;
+           }
+        };
+
+        shapes[ShapeTypes.RightTriangle] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, 0);
+                path.lineTo(21600, 21600);
+                path.lineTo(0, 21600);
+                path.closePath();
+                return path;
+           }
+        };
+
+        shapes[ShapeTypes.Parallelogram] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(21600, 0);
+                path.lineTo(21600 - adjval, 21600);
+                path.lineTo(0, 21600);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.Trapezoid] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, 0);
+                path.lineTo(adjval, 21600);
+                path.lineTo(21600 - adjval, 21600);
+                path.lineTo(21600, 0);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.Hexagon] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(21600 - adjval, 0);
+                path.lineTo(21600, 10800);
+                path.lineTo(21600 - adjval, 21600);
+                path.lineTo(adjval, 21600);
+                path.lineTo(0, 10800);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.Octagon] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 6326);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(21600 - adjval, 0);
+                path.lineTo(21600, adjval);
+                path.lineTo(21600, 21600-adjval);
+                path.lineTo(21600-adjval, 21600);
+                path.lineTo(adjval, 21600);
+                path.lineTo(0, 21600-adjval);
+                path.lineTo(0, adjval);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.Plus] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(21600 - adjval, 0);
+                path.lineTo(21600 - adjval, adjval);
+                path.lineTo(21600, adjval);
+                path.lineTo(21600, 21600-adjval);
+                path.lineTo(21600-adjval, 21600-adjval);
+                path.lineTo(21600-adjval, 21600);
+                path.lineTo(adjval, 21600);
+                path.lineTo(adjval, 21600-adjval);
+                path.lineTo(0, 21600-adjval);
+                path.lineTo(0, adjval);
+                path.lineTo(adjval, adjval);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.Pentagon] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(10800, 0);
+                path.lineTo(21600, 8259);
+                path.lineTo(21600 - 4200, 21600);
+                path.lineTo(4200, 21600);
+                path.lineTo(0, 8259);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.DownArrow] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                //m0@0 l@1@0 @1,0 @2,0 @2@0,21600@0,10800,21600xe
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 16200);
+                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, adjval);
+                path.lineTo(adjval2, adjval);
+                path.lineTo(adjval2, 0);
+                path.lineTo(21600-adjval2, 0);
+                path.lineTo(21600-adjval2, adjval);
+                path.lineTo(21600, adjval);
+                path.lineTo(10800, 21600);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.UpArrow] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                //m0@0 l@1@0 @1,21600@2,21600@2@0,21600@0,10800,xe
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
+                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, adjval);
+                path.lineTo(adjval2, adjval);
+                path.lineTo(adjval2, 21600);
+                path.lineTo(21600-adjval2, 21600);
+                path.lineTo(21600-adjval2, adjval);
+                path.lineTo(21600, adjval);
+                path.lineTo(10800, 0);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.Arrow] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                //m@0, l@0@1 ,0@1,0@2@0@2@0,21600,21600,10800xe
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 16200);
+                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(adjval, adjval2);
+                path.lineTo(0, adjval2);
+                path.lineTo(0, 21600-adjval2);
+                path.lineTo(adjval, 21600-adjval2);
+                path.lineTo(adjval, 21600);
+                path.lineTo(21600, 10800);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.LeftArrow] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                //m@0, l@0@1,21600@1,21600@2@0@2@0,21600,,10800xe
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
+                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(adjval, adjval2);
+                path.lineTo(21600, adjval2);
+                path.lineTo(21600, 21600-adjval2);
+                path.lineTo(adjval, 21600-adjval2);
+                path.lineTo(adjval, 21600);
+                path.lineTo(0, 10800);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.Can] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                //m10800,qx0@1l0@2qy10800,21600,21600@2l21600@1qy10800,xem0@1qy10800@0,21600@1nfe
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
+
+                GeneralPath path = new GeneralPath();
+
+                path.append(new Arc2D.Float(0, 0, 21600, adjval, 0, 180, Arc2D.OPEN), false);
+                path.moveTo(0, adjval/2);
+
+                path.lineTo(0, 21600 - adjval/2);
+                path.closePath();
+
+                path.append(new Arc2D.Float(0, 21600 - adjval, 21600, adjval, 180, 180, Arc2D.OPEN), false);
+                path.moveTo(21600, 21600 - adjval/2);
+
+                path.lineTo(21600, adjval/2);
+                path.append(new Arc2D.Float(0, 0, 21600, adjval, 180, 180, Arc2D.OPEN), false);
+                path.moveTo(0, adjval/2);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.LeftBrace] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                //m21600,qx10800@0l10800@2qy0@11,10800@3l10800@1qy21600,21600e
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 1800);
+                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 10800);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(21600, 0);
+
+                path.append(new Arc2D.Float(10800, 0, 21600, adjval*2, 90, 90, Arc2D.OPEN), false);
+                path.moveTo(10800, adjval);
+
+                path.lineTo(10800, adjval2 - adjval);
+
+                path.append(new Arc2D.Float(-10800, adjval2 - 2*adjval, 21600, adjval*2, 270, 90, Arc2D.OPEN), false);
+                path.moveTo(0, adjval2);
+
+                path.append(new Arc2D.Float(-10800, adjval2, 21600, adjval*2, 0, 90, Arc2D.OPEN), false);
+                path.moveTo(10800, adjval2 + adjval);
+
+                path.lineTo(10800, 21600 - adjval);
+
+                path.append(new Arc2D.Float(10800, 21600 - 2*adjval, 21600, adjval*2, 180, 90, Arc2D.OPEN), false);
+
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.RightBrace] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                //m,qx10800@0 l10800@2qy21600@11,10800@3l10800@1qy,21600e
+                int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 1800);
+                int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 10800);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, 0);
+
+                path.append(new Arc2D.Float(-10800, 0, 21600, adjval*2, 0, 90, Arc2D.OPEN), false);
+                path.moveTo(10800, adjval);
+
+                path.lineTo(10800, adjval2 - adjval);
+
+                path.append(new Arc2D.Float(10800, adjval2 - 2*adjval, 21600, adjval*2, 180, 90, Arc2D.OPEN), false);
+                path.moveTo(21600, adjval2);
+
+                path.append(new Arc2D.Float(10800, adjval2, 21600, adjval*2, 90, 90, Arc2D.OPEN), false);
+                path.moveTo(10800, adjval2 + adjval);
+
+                path.lineTo(10800, 21600 - adjval);
+
+                path.append(new Arc2D.Float(-10800, 21600 - 2*adjval, 21600, adjval*2, 270, 90, Arc2D.OPEN), false);
+
+                return path;
+            }
+        };
+
+        shapes[ShapeTypes.StraightConnector1] = new ShapeOutline(){
+            public java.awt.Shape getOutline(Shape shape){
+                return new Line2D.Float(0, 0, 21600, 21600);
+            }
+        };
+
+
+    }
+}
index e2718f6acaa5551bdad9f5bf70de4e36cac01dee..531f2da191b9ce82b897caa74f37df4038de8841 100644 (file)
@@ -29,10 +29,10 @@ import java.io.ByteArrayInputStream;
 
 /**
  * Background shape
- * 
+ *
  * @author Yegor Kozlov
  */
-public class Background extends Shape {
+public final class Background extends Shape {
 
     protected Background(EscherContainerRecord escherRecord, Shape parent) {
         super(escherRecord, parent);
index 896d43c84ecf6ee8701ef734de34b0bb5a7017d7..27afa47c8a5d995715912d1fc8856d12bd8758ba 100644 (file)
@@ -20,7 +20,7 @@ package org.apache.poi.hslf.model;
 import org.apache.poi.hslf.record.Comment2000;
 
 /**
- * 
+ *
  * @author Nick Burch
  */
 public final class Comment {
index 49393250d1484232d5385247a67a17d475582c72..dd985a0381aeff0e5c6445023ce9a70634803b3f 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
@@ -32,7 +31,7 @@ import java.awt.*;
  *
  * @author Yegor Kozlov
  */
-public class Fill {
+public final class Fill {
     // For logging
     protected POILogger logger = POILogFactory.getLogger(this.getClass());
 
@@ -229,7 +228,7 @@ public class Fill {
     /**
      * Assign picture used to fill the underlying shape.
      *
-     * @param idx 0-based index of the picture added to this ppt by <code>SlideShow.addPicture</code> method. 
+     * @param idx 0-based index of the picture added to this ppt by <code>SlideShow.addPicture</code> method.
      */
     public void setPictureData(int idx){
         EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
index fb3980a455b34bbf9ad56287e27b723414431820..545ffdffe1029ad4ddf7c5284c05b71cda5efedf 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.ddf.*;\r
-import org.apache.poi.util.LittleEndian;\r
-import org.apache.poi.util.POILogger;\r
-import org.apache.poi.util.HexDump;\r
-\r
-import java.awt.geom.*;\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-\r
-/**\r
- * A "Freeform" shape.\r
- *\r
- * <p>\r
- * Shapes drawn with the "Freeform" tool have cubic bezier curve segments in the smooth sections\r
- * and straight-line segments in the straight sections. This object closely corresponds to <code>java.awt.geom.GeneralPath</code>.\r
- * </p>\r
- * @author Yegor Kozlov\r
- */\r
-public class Freeform extends AutoShape {\r
-\r
-    public static final byte[] SEGMENTINFO_MOVETO   = new byte[]{0x00, 0x40};\r
-    public static final byte[] SEGMENTINFO_LINETO   = new byte[]{0x00, (byte)0xAC};\r
-    public static final byte[] SEGMENTINFO_ESCAPE   = new byte[]{0x01, 0x00};\r
-    public static final byte[] SEGMENTINFO_ESCAPE2  = new byte[]{0x01, 0x20};\r
-    public static final byte[] SEGMENTINFO_CUBICTO  = new byte[]{0x00, (byte)0xAD};\r
-    public static final byte[] SEGMENTINFO_CUBICTO2 = new byte[]{0x00, (byte)0xB3}; //OpenOffice inserts 0xB3 instead of 0xAD.\r
-    public static final byte[] SEGMENTINFO_CLOSE    = new byte[]{0x01, (byte)0x60};\r
-    public static final byte[] SEGMENTINFO_END      = new byte[]{0x00, (byte)0x80};\r
-\r
-    /**\r
-     * Create a Freeform object and initialize it from the supplied Record container.\r
-     *\r
-     * @param escherRecord       <code>EscherSpContainer</code> container which holds information about this shape\r
-     * @param parent    the parent of the shape\r
-     */\r
-   protected Freeform(EscherContainerRecord escherRecord, Shape parent){\r
-        super(escherRecord, parent);\r
-\r
-    }\r
-\r
-    /**\r
-     * Create a new Freeform. This constructor is used when a new shape is created.\r
-     *\r
-     * @param parent    the parent of this Shape. For example, if this text box is a cell\r
-     * in a table then the parent is Table.\r
-     */\r
-    public Freeform(Shape parent){\r
-        super(null, parent);\r
-        _escherContainer = createSpContainer(ShapeTypes.NotPrimitive, parent instanceof ShapeGroup);\r
-    }\r
-\r
-    /**\r
-     * Create a new Freeform. This constructor is used when a new shape is created.\r
-     *\r
-     */\r
-    public Freeform(){\r
-        this(null);\r
-    }\r
-\r
-    /**\r
-     * Set the shape path\r
-     *\r
-     * @param path\r
-     */\r
-    public void setPath(GeneralPath path)\r
-    {\r
-        Rectangle2D bounds = path.getBounds2D();\r
-        PathIterator it = path.getPathIterator(new AffineTransform());\r
-\r
-        ArrayList segInfo = new ArrayList();\r
-        ArrayList pntInfo = new ArrayList();\r
-        boolean isClosed = false;\r
-        while (!it.isDone()) {\r
-            double[] vals = new double[6];\r
-            int type = it.currentSegment(vals);\r
-            switch (type) {\r
-                case PathIterator.SEG_MOVETO:\r
-                    pntInfo.add(new Point2D.Double(vals[0], vals[1]));\r
-                    segInfo.add(SEGMENTINFO_MOVETO);\r
-                    break;\r
-                case PathIterator.SEG_LINETO:\r
-                    pntInfo.add(new Point2D.Double(vals[0], vals[1]));\r
-                    segInfo.add(SEGMENTINFO_LINETO);\r
-                    segInfo.add(SEGMENTINFO_ESCAPE);\r
-                    break;\r
-                case PathIterator.SEG_CUBICTO:\r
-                    pntInfo.add(new Point2D.Double(vals[0], vals[1]));\r
-                    pntInfo.add(new Point2D.Double(vals[2], vals[3]));\r
-                    pntInfo.add(new Point2D.Double(vals[4], vals[5]));\r
-                    segInfo.add(SEGMENTINFO_CUBICTO);\r
-                    segInfo.add(SEGMENTINFO_ESCAPE2);\r
-                    break;\r
-                case PathIterator.SEG_QUADTO:\r
-                    //TODO: figure out how to convert SEG_QUADTO into SEG_CUBICTO  \r
-                    logger.log(POILogger.WARN, "SEG_QUADTO is not supported");\r
-                    break;\r
-                case PathIterator.SEG_CLOSE:\r
-                    pntInfo.add(pntInfo.get(0));\r
-                    segInfo.add(SEGMENTINFO_LINETO);\r
-                    segInfo.add(SEGMENTINFO_ESCAPE);\r
-                    segInfo.add(SEGMENTINFO_LINETO);\r
-                    segInfo.add(SEGMENTINFO_CLOSE);\r
-                    isClosed = true;\r
-                    break;\r
-            }\r
-\r
-            it.next();\r
-        }\r
-        if(!isClosed) segInfo.add(SEGMENTINFO_LINETO);\r
-        segInfo.add(new byte[]{0x00, (byte)0x80});\r
-\r
-        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);\r
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4));\r
-\r
-        EscherArrayProperty verticesProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__VERTICES + 0x4000), false, null);\r
-        verticesProp.setNumberOfElementsInArray(pntInfo.size());\r
-        verticesProp.setNumberOfElementsInMemory(pntInfo.size());\r
-        verticesProp.setSizeOfElements(0xFFF0);\r
-        for (int i = 0; i < pntInfo.size(); i++) {\r
-            Point2D.Double pnt = (Point2D.Double)pntInfo.get(i);\r
-            byte[] data = new byte[4];\r
-            LittleEndian.putShort(data, 0, (short)((pnt.getX() - bounds.getX())*MASTER_DPI/POINT_DPI));\r
-            LittleEndian.putShort(data, 2, (short)((pnt.getY() - bounds.getY())*MASTER_DPI/POINT_DPI));\r
-            verticesProp.setElement(i, data);\r
-        }\r
-        opt.addEscherProperty(verticesProp);\r
-\r
-        EscherArrayProperty segmentsProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000), false, null);\r
-        segmentsProp.setNumberOfElementsInArray(segInfo.size());\r
-        segmentsProp.setNumberOfElementsInMemory(segInfo.size());\r
-        segmentsProp.setSizeOfElements(0x2);\r
-        for (int i = 0; i < segInfo.size(); i++) {\r
-            byte[] seg = (byte[])segInfo.get(i);\r
-            segmentsProp.setElement(i, seg);\r
-        }\r
-        opt.addEscherProperty(segmentsProp);\r
-\r
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, (int)(bounds.getWidth()*MASTER_DPI/POINT_DPI)));\r
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, (int)(bounds.getHeight()*MASTER_DPI/POINT_DPI)));\r
-\r
-        opt.sortProperties();\r
-\r
-        setAnchor(bounds);\r
-    }\r
-\r
-    /**\r
-     * Gets the freeform path\r
-     *\r
-     * @return the freeform path\r
-     */\r
-     public GeneralPath getPath(){\r
-        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);\r
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4));\r
-\r
-        EscherArrayProperty verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES + 0x4000));\r
-        if(verticesProp == null) verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES));\r
-\r
-        EscherArrayProperty segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000));\r
-        if(segmentsProp == null) segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO));\r
-\r
-        //sanity check\r
-        if(verticesProp == null) {\r
-            logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__VERTICES ");\r
-            return null;\r
-        }\r
-        if(segmentsProp == null) {\r
-            logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__SEGMENTINFO ");\r
-            return null;\r
-        }\r
-\r
-        GeneralPath path = new GeneralPath();\r
-        int numPoints = verticesProp.getNumberOfElementsInArray();\r
-        int numSegments = segmentsProp.getNumberOfElementsInArray();\r
-        for (int i = 0, j = 0; i < numSegments && j < numPoints; i++) {\r
-            byte[] elem = segmentsProp.getElement(i);\r
-            if(Arrays.equals(elem, SEGMENTINFO_MOVETO)){\r
-                byte[] p = verticesProp.getElement(j++);\r
-                short x = LittleEndian.getShort(p, 0);\r
-                short y = LittleEndian.getShort(p, 2);\r
-                path.moveTo(\r
-                        ((float)x*POINT_DPI/MASTER_DPI),\r
-                        ((float)y*POINT_DPI/MASTER_DPI));\r
-            } else if (Arrays.equals(elem, SEGMENTINFO_CUBICTO) || Arrays.equals(elem, SEGMENTINFO_CUBICTO2)){\r
-                i++;\r
-                byte[] p1 = verticesProp.getElement(j++);\r
-                short x1 = LittleEndian.getShort(p1, 0);\r
-                short y1 = LittleEndian.getShort(p1, 2);\r
-                byte[] p2 = verticesProp.getElement(j++);\r
-                short x2 = LittleEndian.getShort(p2, 0);\r
-                short y2 = LittleEndian.getShort(p2, 2);\r
-                byte[] p3 = verticesProp.getElement(j++);\r
-                short x3 = LittleEndian.getShort(p3, 0);\r
-                short y3 = LittleEndian.getShort(p3, 2);\r
-                path.curveTo(\r
-                        ((float)x1*POINT_DPI/MASTER_DPI), ((float)y1*POINT_DPI/MASTER_DPI),\r
-                        ((float)x2*POINT_DPI/MASTER_DPI), ((float)y2*POINT_DPI/MASTER_DPI),\r
-                        ((float)x3*POINT_DPI/MASTER_DPI), ((float)y3*POINT_DPI/MASTER_DPI));\r
-\r
-            } else if (Arrays.equals(elem, SEGMENTINFO_LINETO)){\r
-                i++;\r
-                byte[] pnext = segmentsProp.getElement(i);\r
-                if(Arrays.equals(pnext, SEGMENTINFO_ESCAPE)){\r
-                    if(j + 1 < numPoints){\r
-                        byte[] p = verticesProp.getElement(j++);\r
-                        short x = LittleEndian.getShort(p, 0);\r
-                        short y = LittleEndian.getShort(p, 2);\r
-                        path.lineTo(\r
-                                ((float)x*POINT_DPI/MASTER_DPI), ((float)y*POINT_DPI/MASTER_DPI));\r
-                    }\r
-                } else if (Arrays.equals(pnext, SEGMENTINFO_CLOSE)){\r
-                    path.closePath();\r
-                }\r
-            }\r
-        }\r
-        return path;\r
-    }\r
-\r
-    public java.awt.Shape getOutline(){\r
-        GeneralPath path =  getPath();\r
-        Rectangle2D anchor = getAnchor2D();\r
-        Rectangle2D bounds = path.getBounds2D();\r
-        AffineTransform at = new AffineTransform();\r
-        at.translate(anchor.getX(), anchor.getY());\r
-        at.scale(\r
-                anchor.getWidth()/bounds.getWidth(),\r
-                anchor.getHeight()/bounds.getHeight()\r
-        );\r
-        return at.createTransformedShape(path);\r
-    }\r
-}\r
+/* ====================================================================
+   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.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;
+import java.util.Arrays;
+
+/**
+ * A "Freeform" shape.
+ *
+ * <p>
+ * Shapes drawn with the "Freeform" tool have cubic bezier curve segments in the smooth sections
+ * and straight-line segments in the straight sections. This object closely corresponds to <code>java.awt.geom.GeneralPath</code>.
+ * </p>
+ * @author Yegor Kozlov
+ */
+public final class Freeform extends AutoShape {
+
+    public static final byte[] SEGMENTINFO_MOVETO   = new byte[]{0x00, 0x40};
+    public static final byte[] SEGMENTINFO_LINETO   = new byte[]{0x00, (byte)0xAC};
+    public static final byte[] SEGMENTINFO_ESCAPE   = new byte[]{0x01, 0x00};
+    public static final byte[] SEGMENTINFO_ESCAPE2  = new byte[]{0x01, 0x20};
+    public static final byte[] SEGMENTINFO_CUBICTO  = new byte[]{0x00, (byte)0xAD};
+    public static final byte[] SEGMENTINFO_CUBICTO2 = new byte[]{0x00, (byte)0xB3}; //OpenOffice inserts 0xB3 instead of 0xAD.
+    public static final byte[] SEGMENTINFO_CLOSE    = new byte[]{0x01, (byte)0x60};
+    public static final byte[] SEGMENTINFO_END      = new byte[]{0x00, (byte)0x80};
+
+    /**
+     * Create a Freeform 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
+     */
+   protected Freeform(EscherContainerRecord escherRecord, Shape parent){
+        super(escherRecord, parent);
+
+    }
+
+    /**
+     * Create a new Freeform. This constructor is used when a new shape is created.
+     *
+     * @param parent    the parent of this Shape. For example, if this text box is a cell
+     * in a table then the parent is Table.
+     */
+    public Freeform(Shape parent){
+        super(null, parent);
+        _escherContainer = createSpContainer(ShapeTypes.NotPrimitive, parent instanceof ShapeGroup);
+    }
+
+    /**
+     * Create a new Freeform. This constructor is used when a new shape is created.
+     *
+     */
+    public Freeform(){
+        this(null);
+    }
+
+    /**
+     * Set the shape path
+     *
+     * @param path
+     */
+    public void setPath(GeneralPath path)
+    {
+        Rectangle2D bounds = path.getBounds2D();
+        PathIterator it = path.getPathIterator(new AffineTransform());
+
+        ArrayList segInfo = new ArrayList();
+        ArrayList pntInfo = new ArrayList();
+        boolean isClosed = false;
+        while (!it.isDone()) {
+            double[] vals = new double[6];
+            int type = it.currentSegment(vals);
+            switch (type) {
+                case PathIterator.SEG_MOVETO:
+                    pntInfo.add(new Point2D.Double(vals[0], vals[1]));
+                    segInfo.add(SEGMENTINFO_MOVETO);
+                    break;
+                case PathIterator.SEG_LINETO:
+                    pntInfo.add(new Point2D.Double(vals[0], vals[1]));
+                    segInfo.add(SEGMENTINFO_LINETO);
+                    segInfo.add(SEGMENTINFO_ESCAPE);
+                    break;
+                case PathIterator.SEG_CUBICTO:
+                    pntInfo.add(new Point2D.Double(vals[0], vals[1]));
+                    pntInfo.add(new Point2D.Double(vals[2], vals[3]));
+                    pntInfo.add(new Point2D.Double(vals[4], vals[5]));
+                    segInfo.add(SEGMENTINFO_CUBICTO);
+                    segInfo.add(SEGMENTINFO_ESCAPE2);
+                    break;
+                case PathIterator.SEG_QUADTO:
+                    //TODO: figure out how to convert SEG_QUADTO into SEG_CUBICTO
+                    logger.log(POILogger.WARN, "SEG_QUADTO is not supported");
+                    break;
+                case PathIterator.SEG_CLOSE:
+                    pntInfo.add(pntInfo.get(0));
+                    segInfo.add(SEGMENTINFO_LINETO);
+                    segInfo.add(SEGMENTINFO_ESCAPE);
+                    segInfo.add(SEGMENTINFO_LINETO);
+                    segInfo.add(SEGMENTINFO_CLOSE);
+                    isClosed = true;
+                    break;
+            }
+
+            it.next();
+        }
+        if(!isClosed) segInfo.add(SEGMENTINFO_LINETO);
+        segInfo.add(new byte[]{0x00, (byte)0x80});
+
+        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4));
+
+        EscherArrayProperty verticesProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__VERTICES + 0x4000), false, null);
+        verticesProp.setNumberOfElementsInArray(pntInfo.size());
+        verticesProp.setNumberOfElementsInMemory(pntInfo.size());
+        verticesProp.setSizeOfElements(0xFFF0);
+        for (int i = 0; i < pntInfo.size(); i++) {
+            Point2D.Double pnt = (Point2D.Double)pntInfo.get(i);
+            byte[] data = new byte[4];
+            LittleEndian.putShort(data, 0, (short)((pnt.getX() - bounds.getX())*MASTER_DPI/POINT_DPI));
+            LittleEndian.putShort(data, 2, (short)((pnt.getY() - bounds.getY())*MASTER_DPI/POINT_DPI));
+            verticesProp.setElement(i, data);
+        }
+        opt.addEscherProperty(verticesProp);
+
+        EscherArrayProperty segmentsProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000), false, null);
+        segmentsProp.setNumberOfElementsInArray(segInfo.size());
+        segmentsProp.setNumberOfElementsInMemory(segInfo.size());
+        segmentsProp.setSizeOfElements(0x2);
+        for (int i = 0; i < segInfo.size(); i++) {
+            byte[] seg = (byte[])segInfo.get(i);
+            segmentsProp.setElement(i, seg);
+        }
+        opt.addEscherProperty(segmentsProp);
+
+        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, (int)(bounds.getWidth()*MASTER_DPI/POINT_DPI)));
+        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, (int)(bounds.getHeight()*MASTER_DPI/POINT_DPI)));
+
+        opt.sortProperties();
+
+        setAnchor(bounds);
+    }
+
+    /**
+     * Gets the freeform path
+     *
+     * @return the freeform path
+     */
+     public GeneralPath getPath(){
+        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4));
+
+        EscherArrayProperty verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES + 0x4000));
+        if(verticesProp == null) verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES));
+
+        EscherArrayProperty segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000));
+        if(segmentsProp == null) segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO));
+
+        //sanity check
+        if(verticesProp == null) {
+            logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__VERTICES ");
+            return null;
+        }
+        if(segmentsProp == null) {
+            logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__SEGMENTINFO ");
+            return null;
+        }
+
+        GeneralPath path = new GeneralPath();
+        int numPoints = verticesProp.getNumberOfElementsInArray();
+        int numSegments = segmentsProp.getNumberOfElementsInArray();
+        for (int i = 0, j = 0; i < numSegments && j < numPoints; i++) {
+            byte[] elem = segmentsProp.getElement(i);
+            if(Arrays.equals(elem, SEGMENTINFO_MOVETO)){
+                byte[] p = verticesProp.getElement(j++);
+                short x = LittleEndian.getShort(p, 0);
+                short y = LittleEndian.getShort(p, 2);
+                path.moveTo(
+                        ((float)x*POINT_DPI/MASTER_DPI),
+                        ((float)y*POINT_DPI/MASTER_DPI));
+            } else if (Arrays.equals(elem, SEGMENTINFO_CUBICTO) || Arrays.equals(elem, SEGMENTINFO_CUBICTO2)){
+                i++;
+                byte[] p1 = verticesProp.getElement(j++);
+                short x1 = LittleEndian.getShort(p1, 0);
+                short y1 = LittleEndian.getShort(p1, 2);
+                byte[] p2 = verticesProp.getElement(j++);
+                short x2 = LittleEndian.getShort(p2, 0);
+                short y2 = LittleEndian.getShort(p2, 2);
+                byte[] p3 = verticesProp.getElement(j++);
+                short x3 = LittleEndian.getShort(p3, 0);
+                short y3 = LittleEndian.getShort(p3, 2);
+                path.curveTo(
+                        ((float)x1*POINT_DPI/MASTER_DPI), ((float)y1*POINT_DPI/MASTER_DPI),
+                        ((float)x2*POINT_DPI/MASTER_DPI), ((float)y2*POINT_DPI/MASTER_DPI),
+                        ((float)x3*POINT_DPI/MASTER_DPI), ((float)y3*POINT_DPI/MASTER_DPI));
+
+            } else if (Arrays.equals(elem, SEGMENTINFO_LINETO)){
+                i++;
+                byte[] pnext = segmentsProp.getElement(i);
+                if(Arrays.equals(pnext, SEGMENTINFO_ESCAPE)){
+                    if(j + 1 < numPoints){
+                        byte[] p = verticesProp.getElement(j++);
+                        short x = LittleEndian.getShort(p, 0);
+                        short y = LittleEndian.getShort(p, 2);
+                        path.lineTo(
+                                ((float)x*POINT_DPI/MASTER_DPI), ((float)y*POINT_DPI/MASTER_DPI));
+                    }
+                } else if (Arrays.equals(pnext, SEGMENTINFO_CLOSE)){
+                    path.closePath();
+                }
+            }
+        }
+        return path;
+    }
+
+    public java.awt.Shape getOutline(){
+        GeneralPath path =  getPath();
+        Rectangle2D anchor = getAnchor2D();
+        Rectangle2D bounds = path.getBounds2D();
+        AffineTransform at = new AffineTransform();
+        at.translate(anchor.getX(), anchor.getY());
+        at.scale(
+                anchor.getWidth()/bounds.getWidth(),
+                anchor.getHeight()/bounds.getHeight()
+        );
+        return at.createTransformedShape(path);
+    }
+}
index 38b0dff9e20039238acda6769e1cb88f7238740a..8bb441e4e46846a57501bb693be940834bd577bd 100644 (file)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.hslf.record.*;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-\r
-/**\r
- * Header / Footer settings.\r
- * \r
- * You can get these on slides, or across all notes\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class HeadersFooters {\r
-\r
-    private HeadersFootersContainer _container;\r
-    private boolean _newRecord;\r
-    private SlideShow _ppt;\r
-    private Sheet _sheet;\r
-    private boolean _ppt2007;\r
-\r
-\r
-    public HeadersFooters(HeadersFootersContainer rec, SlideShow ppt, boolean newRecord, boolean isPpt2007){\r
-        _container = rec;\r
-        _newRecord = newRecord;\r
-        _ppt = ppt;\r
-        _ppt2007 = isPpt2007;\r
-    }\r
-\r
-    public HeadersFooters(HeadersFootersContainer rec, Sheet sheet, boolean newRecord, boolean isPpt2007){\r
-        _container = rec;\r
-        _newRecord = newRecord;\r
-        _sheet = sheet;\r
-        _ppt2007 = isPpt2007;\r
-    }\r
-\r
-    /**\r
-     * Headers's text\r
-     *\r
-     * @return Headers's text\r
-     */\r
-    public String getHeaderText(){\r
-        CString cs = _container == null ? null : _container.getHeaderAtom();\r
-        return getPlaceholderText(OEPlaceholderAtom.MasterHeader, cs);\r
-    }\r
-\r
-    /**\r
-     * Sets headers's text\r
-     *\r
-     * @param text headers's text\r
-     */\r
-    public void setHeaderText(String text){\r
-        if(_newRecord) attach();\r
-\r
-        setHeaderVisible(true);\r
-        CString cs = _container.getHeaderAtom();\r
-        if(cs == null) cs = _container.addHeaderAtom();\r
-\r
-        cs.setText(text);\r
-    }\r
-\r
-    /**\r
-     * Footer's text\r
-     *\r
-     * @return Footer's text\r
-     */\r
-    public String getFooterText(){\r
-        CString cs = _container == null ? null : _container.getFooterAtom();\r
-        return getPlaceholderText(OEPlaceholderAtom.MasterFooter, cs);\r
-    }\r
-\r
-    /**\r
-     * Sets footers's text\r
-     *\r
-     * @param text footers's text\r
-     */\r
-    public void setFootersText(String text){\r
-        if(_newRecord) attach();\r
-\r
-        setFooterVisible(true);\r
-        CString cs = _container.getFooterAtom();\r
-        if(cs == null) cs = _container.addFooterAtom();\r
-\r
-        cs.setText(text);\r
-    }\r
-\r
-    /**\r
-     * This is the date that the user wants in the footers, instead of today's date.\r
-     *\r
-     * @return custom user date\r
-     */\r
-    public String getDateTimeText(){\r
-        CString cs = _container == null ? null : _container.getUserDateAtom();\r
-        return getPlaceholderText(OEPlaceholderAtom.MasterDate, cs);\r
-    }\r
-\r
-    /**\r
-     * Sets custom user date to be displayed instead of today's date.\r
-     *\r
-     * @param text custom user date\r
-     */\r
-    public void setDateTimeText(String text){\r
-        if(_newRecord) attach();\r
-\r
-        setUserDateVisible(true);\r
-        setDateTimeVisible(true);\r
-        CString cs = _container.getUserDateAtom();\r
-        if(cs == null) cs = _container.addUserDateAtom();\r
-\r
-        cs.setText(text);\r
-    }\r
-\r
-    /**\r
-     * whether the footer text is displayed.\r
-     */\r
-    public boolean isFooterVisible(){\r
-        return isVisible(HeadersFootersAtom.fHasFooter, OEPlaceholderAtom.MasterFooter);\r
-    }\r
-\r
-    /**\r
-     * whether the footer text is displayed.\r
-     */\r
-    public void setFooterVisible(boolean flag){\r
-        if(_newRecord) attach();\r
-        _container.getHeadersFootersAtom().setFlag(HeadersFootersAtom.fHasFooter, flag);\r
-    }\r
-\r
-    /**\r
-     * whether the header text is displayed.\r
-     */\r
-    public boolean isHeaderVisible(){\r
-        return isVisible(HeadersFootersAtom.fHasHeader, OEPlaceholderAtom.MasterHeader);\r
-    }\r
-\r
-    /**\r
-     * whether the header text is displayed.\r
-     */\r
-    public void setHeaderVisible(boolean flag){\r
-        if(_newRecord) attach();\r
-        _container.getHeadersFootersAtom().setFlag(HeadersFootersAtom.fHasHeader, flag);\r
-    }\r
-\r
-    /**\r
-     * whether the date is displayed in the footer.\r
-     */\r
-    public boolean isDateTimeVisible(){\r
-        return isVisible(HeadersFootersAtom.fHasDate, OEPlaceholderAtom.MasterDate);\r
-    }\r
-\r
-    /**\r
-     * whether the date is displayed in the footer.\r
-     */\r
-    public void setDateTimeVisible(boolean flag){\r
-        if(_newRecord) attach();\r
-        _container.getHeadersFootersAtom().setFlag(HeadersFootersAtom.fHasDate, flag);\r
-    }\r
-\r
-    /**\r
-     * whether the custom user date is used instead of today's date.\r
-     */\r
-    public boolean isUserDateVisible(){\r
-        return isVisible(HeadersFootersAtom.fHasUserDate, OEPlaceholderAtom.MasterDate);\r
-    }\r
-\r
-    /**\r
-     * whether the date is displayed in the footer.\r
-     */\r
-    public void setUserDateVisible(boolean flag){\r
-        if(_newRecord) attach();\r
-        _container.getHeadersFootersAtom().setFlag(HeadersFootersAtom.fHasUserDate, flag);\r
-    }\r
-\r
-    /**\r
-     * whether the slide number is displayed in the footer.\r
-     */\r
-    public boolean isSlideNumberVisible(){\r
-        return isVisible(HeadersFootersAtom.fHasSlideNumber, OEPlaceholderAtom.MasterSlideNumber);\r
-    }\r
-\r
-    /**\r
-     * whether the slide number is displayed in the footer.\r
-     */\r
-    public void setSlideNumberVisible(boolean flag){\r
-        if(_newRecord) attach();\r
-        _container.getHeadersFootersAtom().setFlag(HeadersFootersAtom.fHasSlideNumber, flag);\r
-    }\r
-\r
-    /**\r
-     *  An integer that specifies the format ID to be used to style the datetime.\r
-     *\r
-     * @return an integer that specifies the format ID to be used to style the datetime.\r
-     */\r
-    public int getDateTimeFormat(){\r
-        return _container.getHeadersFootersAtom().getFormatId();\r
-    }\r
-\r
-    /**\r
-     *  An integer that specifies the format ID to be used to style the datetime.\r
-     *\r
-     * @param formatId an integer that specifies the format ID to be used to style the datetime.\r
-     */\r
-    public void setDateTimeFormat(int formatId){\r
-        if(_newRecord) attach();\r
-        _container.getHeadersFootersAtom().setFormatId(formatId);\r
-    }\r
-\r
-    /**\r
-     * Attach this HeadersFootersContainer to the parent Document record\r
-     */\r
-    private void attach(){\r
-        Document doc = _ppt.getDocumentRecord();\r
-        Record[] ch = doc.getChildRecords();\r
-        Record lst = null;\r
-        for (int i=0; i < ch.length; i++){\r
-            if(ch[i].getRecordType() == RecordTypes.List.typeID){\r
-                lst = ch[i];\r
-                break;\r
-            }\r
-        }\r
-        doc.addChildAfter(_container, lst);\r
-        _newRecord = false;\r
-    }\r
-\r
-    private boolean isVisible(int flag, int placeholderId){\r
-        boolean visible;\r
-        if(_ppt2007){\r
-            Sheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];\r
-            TextShape placeholder = master.getPlaceholder(placeholderId);\r
-            visible = placeholder != null && placeholder.getText() != null;\r
-        } else {\r
-            visible = _container.getHeadersFootersAtom().getFlag(flag);\r
-        }\r
-        return visible;\r
-    }\r
-\r
-    private String getPlaceholderText(int placeholderId, CString cs){\r
-        String text = null;\r
-        if(_ppt2007){\r
-            Sheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];\r
-            TextShape placeholder = master.getPlaceholder(placeholderId);\r
-            if(placeholder != null) text = placeholder.getText();\r
-\r
-            //default text in master placeholders is not visible\r
-            if("*".equals(text)) text = null;\r
-        } else {\r
-            text = cs == null ? null : cs.getText();\r
-        }\r
-        return text;\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import org.apache.poi.hslf.record.*;
+import org.apache.poi.hslf.usermodel.SlideShow;
+
+/**
+ * Header / Footer settings.
+ *
+ * You can get these on slides, or across all notes
+ *
+ * @author Yegor Kozlov
+ */
+public final class HeadersFooters {
+
+    private HeadersFootersContainer _container;
+    private boolean _newRecord;
+    private SlideShow _ppt;
+    private Sheet _sheet;
+    private boolean _ppt2007;
+
+
+    public HeadersFooters(HeadersFootersContainer rec, SlideShow ppt, boolean newRecord, boolean isPpt2007){
+        _container = rec;
+        _newRecord = newRecord;
+        _ppt = ppt;
+        _ppt2007 = isPpt2007;
+    }
+
+    public HeadersFooters(HeadersFootersContainer rec, Sheet sheet, boolean newRecord, boolean isPpt2007){
+        _container = rec;
+        _newRecord = newRecord;
+        _sheet = sheet;
+        _ppt2007 = isPpt2007;
+    }
+
+    /**
+     * Headers's text
+     *
+     * @return Headers's text
+     */
+    public String getHeaderText(){
+        CString cs = _container == null ? null : _container.getHeaderAtom();
+        return getPlaceholderText(OEPlaceholderAtom.MasterHeader, cs);
+    }
+
+    /**
+     * Sets headers's text
+     *
+     * @param text headers's text
+     */
+    public void setHeaderText(String text){
+        if(_newRecord) attach();
+
+        setHeaderVisible(true);
+        CString cs = _container.getHeaderAtom();
+        if(cs == null) cs = _container.addHeaderAtom();
+
+        cs.setText(text);
+    }
+
+    /**
+     * Footer's text
+     *
+     * @return Footer's text
+     */
+    public String getFooterText(){
+        CString cs = _container == null ? null : _container.getFooterAtom();
+        return getPlaceholderText(OEPlaceholderAtom.MasterFooter, cs);
+    }
+
+    /**
+     * Sets footers's text
+     *
+     * @param text footers's text
+     */
+    public void setFootersText(String text){
+        if(_newRecord) attach();
+
+        setFooterVisible(true);
+        CString cs = _container.getFooterAtom();
+        if(cs == null) cs = _container.addFooterAtom();
+
+        cs.setText(text);
+    }
+
+    /**
+     * This is the date that the user wants in the footers, instead of today's date.
+     *
+     * @return custom user date
+     */
+    public String getDateTimeText(){
+        CString cs = _container == null ? null : _container.getUserDateAtom();
+        return getPlaceholderText(OEPlaceholderAtom.MasterDate, cs);
+    }
+
+    /**
+     * Sets custom user date to be displayed instead of today's date.
+     *
+     * @param text custom user date
+     */
+    public void setDateTimeText(String text){
+        if(_newRecord) attach();
+
+        setUserDateVisible(true);
+        setDateTimeVisible(true);
+        CString cs = _container.getUserDateAtom();
+        if(cs == null) cs = _container.addUserDateAtom();
+
+        cs.setText(text);
+    }
+
+    /**
+     * whether the footer text is displayed.
+     */
+    public boolean isFooterVisible(){
+        return isVisible(HeadersFootersAtom.fHasFooter, OEPlaceholderAtom.MasterFooter);
+    }
+
+    /**
+     * whether the footer text is displayed.
+     */
+    public void setFooterVisible(boolean flag){
+        if(_newRecord) attach();
+        _container.getHeadersFootersAtom().setFlag(HeadersFootersAtom.fHasFooter, flag);
+    }
+
+    /**
+     * whether the header text is displayed.
+     */
+    public boolean isHeaderVisible(){
+        return isVisible(HeadersFootersAtom.fHasHeader, OEPlaceholderAtom.MasterHeader);
+    }
+
+    /**
+     * whether the header text is displayed.
+     */
+    public void setHeaderVisible(boolean flag){
+        if(_newRecord) attach();
+        _container.getHeadersFootersAtom().setFlag(HeadersFootersAtom.fHasHeader, flag);
+    }
+
+    /**
+     * whether the date is displayed in the footer.
+     */
+    public boolean isDateTimeVisible(){
+        return isVisible(HeadersFootersAtom.fHasDate, OEPlaceholderAtom.MasterDate);
+    }
+
+    /**
+     * whether the date is displayed in the footer.
+     */
+    public void setDateTimeVisible(boolean flag){
+        if(_newRecord) attach();
+        _container.getHeadersFootersAtom().setFlag(HeadersFootersAtom.fHasDate, flag);
+    }
+
+    /**
+     * whether the custom user date is used instead of today's date.
+     */
+    public boolean isUserDateVisible(){
+        return isVisible(HeadersFootersAtom.fHasUserDate, OEPlaceholderAtom.MasterDate);
+    }
+
+    /**
+     * whether the date is displayed in the footer.
+     */
+    public void setUserDateVisible(boolean flag){
+        if(_newRecord) attach();
+        _container.getHeadersFootersAtom().setFlag(HeadersFootersAtom.fHasUserDate, flag);
+    }
+
+    /**
+     * whether the slide number is displayed in the footer.
+     */
+    public boolean isSlideNumberVisible(){
+        return isVisible(HeadersFootersAtom.fHasSlideNumber, OEPlaceholderAtom.MasterSlideNumber);
+    }
+
+    /**
+     * whether the slide number is displayed in the footer.
+     */
+    public void setSlideNumberVisible(boolean flag){
+        if(_newRecord) attach();
+        _container.getHeadersFootersAtom().setFlag(HeadersFootersAtom.fHasSlideNumber, flag);
+    }
+
+    /**
+     *  An integer that specifies the format ID to be used to style the datetime.
+     *
+     * @return an integer that specifies the format ID to be used to style the datetime.
+     */
+    public int getDateTimeFormat(){
+        return _container.getHeadersFootersAtom().getFormatId();
+    }
+
+    /**
+     *  An integer that specifies the format ID to be used to style the datetime.
+     *
+     * @param formatId an integer that specifies the format ID to be used to style the datetime.
+     */
+    public void setDateTimeFormat(int formatId){
+        if(_newRecord) attach();
+        _container.getHeadersFootersAtom().setFormatId(formatId);
+    }
+
+    /**
+     * Attach this HeadersFootersContainer to the parent Document record
+     */
+    private void attach(){
+        Document doc = _ppt.getDocumentRecord();
+        Record[] ch = doc.getChildRecords();
+        Record lst = null;
+        for (int i=0; i < ch.length; i++){
+            if(ch[i].getRecordType() == RecordTypes.List.typeID){
+                lst = ch[i];
+                break;
+            }
+        }
+        doc.addChildAfter(_container, lst);
+        _newRecord = false;
+    }
+
+    private boolean isVisible(int flag, int placeholderId){
+        boolean visible;
+        if(_ppt2007){
+            Sheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];
+            TextShape placeholder = master.getPlaceholder(placeholderId);
+            visible = placeholder != null && placeholder.getText() != null;
+        } else {
+            visible = _container.getHeadersFootersAtom().getFlag(flag);
+        }
+        return visible;
+    }
+
+    private String getPlaceholderText(int placeholderId, CString cs){
+        String text = null;
+        if(_ppt2007){
+            Sheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];
+            TextShape placeholder = master.getPlaceholder(placeholderId);
+            if(placeholder != null) text = placeholder.getText();
+
+            //default text in master placeholders is not visible
+            if("*".equals(text)) text = null;
+        } else {
+            text = cs == null ? null : cs.getText();
+        }
+        return text;
+    }
+
+}
index c92935f7a8c32120ba74b4350c325c923a7b56a3..5c33d807ee37ae8ebf29585618e79af975cb2e0e 100644 (file)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.hslf.record.*;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.ddf.EscherContainerRecord;\r
-import org.apache.poi.ddf.EscherRecord;\r
-import org.apache.poi.ddf.EscherClientDataRecord;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Iterator;\r
-\r
-/**\r
- * Represents a hyperlink in a PowerPoint document\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class Hyperlink {\r
-    public static final byte LINK_NEXTSLIDE = InteractiveInfoAtom.LINK_NextSlide;\r
-    public static final byte LINK_PREVIOUSSLIDE = InteractiveInfoAtom.LINK_PreviousSlide;\r
-    public static final byte LINK_FIRSTSLIDE = InteractiveInfoAtom.LINK_FirstSlide;\r
-    public static final byte LINK_LASTSLIDE = InteractiveInfoAtom.LINK_LastSlide;\r
-    public static final byte LINK_URL = InteractiveInfoAtom.LINK_Url;\r
-    public static final byte LINK_NULL = InteractiveInfoAtom.LINK_NULL;\r
-\r
-    private int id=-1;\r
-    private int type;\r
-    private String address;\r
-    private String title;\r
-    private int startIndex, endIndex;\r
-\r
-    /**\r
-     * Gets the type of the hyperlink action.\r
-     * Must be a <code>LINK_*</code>  constant</code>\r
-     *\r
-     * @return the hyperlink URL\r
-     * @see InteractiveInfoAtom\r
-     */\r
-    public int getType() {\r
-        return type;\r
-    }\r
-\r
-    public void setType(int val) {\r
-        type = val;\r
-        switch(type){\r
-            case LINK_NEXTSLIDE:\r
-                title = "NEXT";\r
-                address = "1,-1,NEXT";\r
-                break;\r
-            case LINK_PREVIOUSSLIDE:\r
-                title = "PREV";\r
-                address = "1,-1,PREV";\r
-                break;\r
-            case LINK_FIRSTSLIDE:\r
-                title = "FIRST";\r
-                address = "1,-1,FIRST";\r
-                break;\r
-            case LINK_LASTSLIDE:\r
-                title = "LAST";\r
-                address = "1,-1,LAST";\r
-                break;\r
-            default:\r
-                title = "";\r
-                address = "";\r
-                break;\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Gets the hyperlink URL\r
-     *\r
-     * @return the hyperlink URL\r
-     */\r
-    public String getAddress() {\r
-        return address;\r
-    }\r
-\r
-    public void setAddress(String str) {\r
-        address = str;\r
-    }\r
-\r
-    public int getId() {\r
-        return id;\r
-    }\r
-\r
-    public void setId(int id) {\r
-        this.id = id;\r
-    }\r
-\r
-    /**\r
-     * Gets the hyperlink user-friendly title (if different from URL)\r
-     *\r
-     * @return the  hyperlink user-friendly title\r
-     */\r
-    public String getTitle() {\r
-        return title;\r
-    }\r
-\r
-    public void setTitle(String str) {\r
-        title = str;\r
-    }\r
-\r
-    /**\r
-     * Gets the beginning character position\r
-     *\r
-     * @return the beginning character position\r
-     */\r
-    public int getStartIndex() {\r
-        return startIndex;\r
-    }\r
-\r
-    /**\r
-     * Gets the ending character position\r
-     *\r
-     * @return the ending character position\r
-     */\r
-    public int getEndIndex() {\r
-        return endIndex;\r
-    }\r
-\r
-    /**\r
-     * Find hyperlinks in a text run\r
-     *\r
-     * @param run  <code>TextRun</code> to lookup hyperlinks in\r
-     * @return found hyperlinks or <code>null</code> if not found\r
-     */\r
-    protected static Hyperlink[] find(TextRun run){\r
-        ArrayList lst = new ArrayList();\r
-        SlideShow ppt = run.getSheet().getSlideShow();\r
-        //document-level container which stores info about all links in a presentation\r
-        ExObjList exobj = ppt.getDocumentRecord().getExObjList();\r
-        if (exobj == null) {\r
-            return null;\r
-        }\r
-        Record[] records = run._records;\r
-        if(records != null) find(records, exobj, lst);\r
-\r
-        Hyperlink[] links = null;\r
-        if (lst.size() > 0){\r
-            links = new Hyperlink[lst.size()];\r
-            lst.toArray(links);\r
-        }\r
-        return links;\r
-    }\r
-\r
-    /**\r
-     * Find hyperlink assigned to the supplied shape\r
-     *\r
-     * @param shape  <code>Shape</code> to lookup hyperlink in\r
-     * @return found hyperlink or <code>null</code>\r
-     */\r
-    protected static Hyperlink find(Shape shape){\r
-        ArrayList lst = new ArrayList();\r
-        SlideShow ppt = shape.getSheet().getSlideShow();\r
-        //document-level container which stores info about all links in a presentation\r
-        ExObjList exobj = ppt.getDocumentRecord().getExObjList();\r
-        if (exobj == null) {\r
-            return null;\r
-        }\r
-\r
-        EscherContainerRecord spContainer = shape.getSpContainer();\r
-        for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext(); ) {\r
-            EscherRecord obj = it.next();\r
-            if (obj.getRecordId() ==  EscherClientDataRecord.RECORD_ID){\r
-                byte[] data = obj.serialize();\r
-                Record[] records = Record.findChildRecords(data, 8, data.length-8);\r
-                if(records != null) find(records, exobj, lst);\r
-            }\r
-        }\r
-\r
-        return lst.size() == 1 ? (Hyperlink)lst.get(0) : null;\r
-    }\r
-\r
-    private static void find(Record[] records, ExObjList exobj, List out){\r
-        for (int i = 0; i < records.length; i++) {\r
-            //see if we have InteractiveInfo in the textrun's records\r
-            if( records[i] instanceof InteractiveInfo){\r
-                InteractiveInfo hldr = (InteractiveInfo)records[i];\r
-                InteractiveInfoAtom info = hldr.getInteractiveInfoAtom();\r
-                int id = info.getHyperlinkID();\r
-                ExHyperlink linkRecord = exobj.get(id);\r
-                if (linkRecord != null){\r
-                    Hyperlink link = new Hyperlink();\r
-                    link.title = linkRecord.getLinkTitle();\r
-                    link.address = linkRecord.getLinkURL();\r
-                    link.type = info.getAction();\r
-\r
-                    if (++i < records.length && records[i] instanceof TxInteractiveInfoAtom){\r
-                        TxInteractiveInfoAtom txinfo = (TxInteractiveInfoAtom)records[i];\r
-                        link.startIndex = txinfo.getStartIndex();\r
-                        link.endIndex = txinfo.getEndIndex();\r
-                    }\r
-                    out.add(link);\r
-                }\r
-            }\r
-        }\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import org.apache.poi.hslf.record.*;
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherRecord;
+import org.apache.poi.ddf.EscherClientDataRecord;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * Represents a hyperlink in a PowerPoint document
+ *
+ * @author Yegor Kozlov
+ */
+public final class Hyperlink {
+    public static final byte LINK_NEXTSLIDE = InteractiveInfoAtom.LINK_NextSlide;
+    public static final byte LINK_PREVIOUSSLIDE = InteractiveInfoAtom.LINK_PreviousSlide;
+    public static final byte LINK_FIRSTSLIDE = InteractiveInfoAtom.LINK_FirstSlide;
+    public static final byte LINK_LASTSLIDE = InteractiveInfoAtom.LINK_LastSlide;
+    public static final byte LINK_URL = InteractiveInfoAtom.LINK_Url;
+    public static final byte LINK_NULL = InteractiveInfoAtom.LINK_NULL;
+
+    private int id=-1;
+    private int type;
+    private String address;
+    private String title;
+    private int startIndex, endIndex;
+
+    /**
+     * Gets the type of the hyperlink action.
+     * Must be a <code>LINK_*</code>  constant</code>
+     *
+     * @return the hyperlink URL
+     * @see InteractiveInfoAtom
+     */
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int val) {
+        type = val;
+        switch(type){
+            case LINK_NEXTSLIDE:
+                title = "NEXT";
+                address = "1,-1,NEXT";
+                break;
+            case LINK_PREVIOUSSLIDE:
+                title = "PREV";
+                address = "1,-1,PREV";
+                break;
+            case LINK_FIRSTSLIDE:
+                title = "FIRST";
+                address = "1,-1,FIRST";
+                break;
+            case LINK_LASTSLIDE:
+                title = "LAST";
+                address = "1,-1,LAST";
+                break;
+            default:
+                title = "";
+                address = "";
+                break;
+        }
+    }
+
+    /**
+     * Gets the hyperlink URL
+     *
+     * @return the hyperlink URL
+     */
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String str) {
+        address = str;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    /**
+     * Gets the hyperlink user-friendly title (if different from URL)
+     *
+     * @return the  hyperlink user-friendly title
+     */
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String str) {
+        title = str;
+    }
+
+    /**
+     * Gets the beginning character position
+     *
+     * @return the beginning character position
+     */
+    public int getStartIndex() {
+        return startIndex;
+    }
+
+    /**
+     * Gets the ending character position
+     *
+     * @return the ending character position
+     */
+    public int getEndIndex() {
+        return endIndex;
+    }
+
+    /**
+     * Find hyperlinks in a text run
+     *
+     * @param run  <code>TextRun</code> to lookup hyperlinks in
+     * @return found hyperlinks or <code>null</code> if not found
+     */
+    protected static Hyperlink[] find(TextRun run){
+        ArrayList lst = new ArrayList();
+        SlideShow ppt = run.getSheet().getSlideShow();
+        //document-level container which stores info about all links in a presentation
+        ExObjList exobj = ppt.getDocumentRecord().getExObjList();
+        if (exobj == null) {
+            return null;
+        }
+        Record[] records = run._records;
+        if(records != null) find(records, exobj, lst);
+
+        Hyperlink[] links = null;
+        if (lst.size() > 0){
+            links = new Hyperlink[lst.size()];
+            lst.toArray(links);
+        }
+        return links;
+    }
+
+    /**
+     * Find hyperlink assigned to the supplied shape
+     *
+     * @param shape  <code>Shape</code> to lookup hyperlink in
+     * @return found hyperlink or <code>null</code>
+     */
+    protected static Hyperlink find(Shape shape){
+        ArrayList lst = new ArrayList();
+        SlideShow ppt = shape.getSheet().getSlideShow();
+        //document-level container which stores info about all links in a presentation
+        ExObjList exobj = ppt.getDocumentRecord().getExObjList();
+        if (exobj == null) {
+            return null;
+        }
+
+        EscherContainerRecord spContainer = shape.getSpContainer();
+        for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext(); ) {
+            EscherRecord obj = it.next();
+            if (obj.getRecordId() ==  EscherClientDataRecord.RECORD_ID){
+                byte[] data = obj.serialize();
+                Record[] records = Record.findChildRecords(data, 8, data.length-8);
+                if(records != null) find(records, exobj, lst);
+            }
+        }
+
+        return lst.size() == 1 ? (Hyperlink)lst.get(0) : null;
+    }
+
+    private static void find(Record[] records, ExObjList exobj, List out){
+        for (int i = 0; i < records.length; i++) {
+            //see if we have InteractiveInfo in the textrun's records
+            if( records[i] instanceof InteractiveInfo){
+                InteractiveInfo hldr = (InteractiveInfo)records[i];
+                InteractiveInfoAtom info = hldr.getInteractiveInfoAtom();
+                int id = info.getHyperlinkID();
+                ExHyperlink linkRecord = exobj.get(id);
+                if (linkRecord != null){
+                    Hyperlink link = new Hyperlink();
+                    link.title = linkRecord.getLinkTitle();
+                    link.address = linkRecord.getLinkURL();
+                    link.type = info.getAction();
+
+                    if (++i < records.length && records[i] instanceof TxInteractiveInfoAtom){
+                        TxInteractiveInfoAtom txinfo = (TxInteractiveInfoAtom)records[i];
+                        link.startIndex = txinfo.getStartIndex();
+                        link.endIndex = txinfo.getEndIndex();
+                    }
+                    out.add(link);
+                }
+            }
+        }
+    }
+}
index 370da96d6b17b7da763b080ff232f308973bcf07..e40a46519c88d4d2a14c37dce6ef82992b601995 100644 (file)
@@ -27,7 +27,7 @@ import java.awt.geom.Line2D;
  *
  *  @author Yegor Kozlov
  */
-public class Line extends SimpleShape {
+public final class Line extends SimpleShape {
     /**
     * Solid (continuous) pen
     */
@@ -114,7 +114,7 @@ public class Line extends SimpleShape {
         EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
         short type = (ShapeTypes.Line << 4) | 0x2;
         spRecord.setOptions(type);
-  
+
         //set default properties for a line
         EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
 
index 501cf65bdf414b371f2c03be5bd0efce2b41a6f3..f3968448c402c01e0d73da495fe2324cc3af2e5a 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hslf.model;
 
 import org.apache.poi.hslf.record.SheetContainer;
@@ -26,7 +27,7 @@ import org.apache.poi.hslf.model.textproperties.TextProp;
  * The superclass of all master sheets - Slide masters, Notes masters, etc.
  *
  * For now it's empty. When we understand more about masters in ppt we will add the common functionality here.
- * 
+ *
  * @author Yegor Kozlov
  */
 public abstract class MasterSheet extends Sheet {
index ff4cac0a55074f5a1c2fb3c8db002db9f5d09493..9d066ac9441b94628069019cb13f74ab6c465109 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.model;\r
-\r
-import java.io.ByteArrayOutputStream;\r
-\r
-import org.apache.poi.ddf.EscherClientDataRecord;\r
-import org.apache.poi.ddf.EscherContainerRecord;\r
-import org.apache.poi.ddf.EscherProperties;\r
-import org.apache.poi.hslf.exceptions.HSLFException;\r
-import org.apache.poi.hslf.record.*;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-\r
-/**\r
- * Represents a movie in a PowerPoint document.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public final class MovieShape extends Picture {\r
-    public static final int DEFAULT_MOVIE_THUMBNAIL = -1;\r
-\r
-    public static final int MOVIE_MPEG = 1;\r
-    public static final int MOVIE_AVI  = 2;\r
-\r
-    /**\r
-     * Create a new <code>Picture</code>\r
-     *\r
-    * @param pictureIdx the index of the picture\r
-     */\r
-    public MovieShape(int movieIdx, int pictureIdx){\r
-        super(pictureIdx, null);\r
-        setMovieIndex(movieIdx);\r
-        setAutoPlay(true);\r
-    }\r
-\r
-    /**\r
-     * Create a new <code>Picture</code>\r
-     *\r
-     * @param idx the index of the picture\r
-     * @param parent the parent shape\r
-     */\r
-    public MovieShape(int movieIdx, int idx, Shape parent) {\r
-        super(idx, parent);\r
-        setMovieIndex(movieIdx);\r
-    }\r
-\r
-    /**\r
-      * Create a <code>Picture</code> object\r
-      *\r
-      * @param escherRecord the <code>EscherSpContainer</code> record which holds information about\r
-      *        this picture in the <code>Slide</code>\r
-      * @param parent the parent shape of this picture\r
-      */\r
-     protected MovieShape(EscherContainerRecord escherRecord, Shape parent){\r
-        super(escherRecord, parent);\r
-    }\r
-\r
-    /**\r
-     * Create a new Placeholder and initialize internal structures\r
-     *\r
-     * @return the created <code>EscherContainerRecord</code> which holds shape data\r
-     */\r
-    protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {\r
-        _escherContainer = super.createSpContainer(idx, isChild);\r
-\r
-        setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x1000100);\r
-        setEscherProperty(EscherProperties.FILL__NOFILLHITTEST, 0x10001);\r
-\r
-        EscherClientDataRecord cldata = new EscherClientDataRecord();\r
-        cldata.setOptions((short)0xF);\r
-        _escherContainer.addChildRecord(cldata);\r
-\r
-        OEShapeAtom oe = new OEShapeAtom();\r
-        InteractiveInfo info = new InteractiveInfo();\r
-        InteractiveInfoAtom infoAtom = info.getInteractiveInfoAtom();\r
-        infoAtom.setAction(InteractiveInfoAtom.ACTION_MEDIA);\r
-        infoAtom.setHyperlinkType(InteractiveInfoAtom.LINK_NULL);\r
-\r
-        AnimationInfo an = new AnimationInfo();\r
-        AnimationInfoAtom anAtom = an.getAnimationInfoAtom();\r
-        anAtom.setFlag(AnimationInfoAtom.Automatic, true);\r
-\r
-        //convert hslf into ddf\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        try {\r
-            oe.writeOut(out);\r
-            an.writeOut(out);\r
-            info.writeOut(out);\r
-        } catch(Exception e){\r
-            throw new HSLFException(e);\r
-        }\r
-        cldata.setRemainingData(out.toByteArray());\r
-\r
-        return _escherContainer;\r
-    }\r
-\r
-    /**\r
-     * Assign a movie to this shape\r
-     *\r
-     * @see org.apache.poi.hslf.usermodel.SlideShow#addMovie(String, int)\r
-     * @param idx  the index of the movie\r
-     */\r
-    public void setMovieIndex(int idx){\r
-        OEShapeAtom oe = (OEShapeAtom)getClientDataRecord(RecordTypes.OEShapeAtom.typeID);\r
-        oe.setOptions(idx);\r
-\r
-        AnimationInfo an = (AnimationInfo)getClientDataRecord(RecordTypes.AnimationInfo.typeID);\r
-        if(an != null) {\r
-            AnimationInfoAtom ai = an.getAnimationInfoAtom();\r
-            ai.setDimColor(0x07000000);\r
-            ai.setFlag(AnimationInfoAtom.Automatic, true);\r
-            ai.setFlag(AnimationInfoAtom.Play, true);\r
-            ai.setFlag(AnimationInfoAtom.Synchronous, true);\r
-            ai.setOrderID(idx + 1);\r
-        }\r
-    }\r
-\r
-    public void setAutoPlay(boolean flag){\r
-        AnimationInfo an = (AnimationInfo)getClientDataRecord(RecordTypes.AnimationInfo.typeID);\r
-        if(an != null){\r
-            an.getAnimationInfoAtom().setFlag(AnimationInfoAtom.Automatic, flag);\r
-            updateClientData();\r
-        }\r
-    }\r
-\r
-    public boolean  isAutoPlay(){\r
-        AnimationInfo an = (AnimationInfo)getClientDataRecord(RecordTypes.AnimationInfo.typeID);\r
-        if(an != null){\r
-            return an.getAnimationInfoAtom().getFlag(AnimationInfoAtom.Automatic);\r
-        }\r
-        return false;\r
-    }\r
-\r
-    /**\r
-     *  Returns UNC or local path to a video file\r
-     *\r
-     * @return UNC or local path to a video file\r
-     */\r
-    public String getPath(){\r
-        OEShapeAtom oe = (OEShapeAtom)getClientDataRecord(RecordTypes.OEShapeAtom.typeID);\r
-        int idx = oe.getOptions();\r
-\r
-        SlideShow ppt = getSheet().getSlideShow();\r
-        ExObjList lst = (ExObjList)ppt.getDocumentRecord().findFirstOfType(RecordTypes.ExObjList.typeID);\r
-        if(lst == null) return null;\r
-\r
-        Record[]  r = lst.getChildRecords();\r
-        for (int i = 0; i < r.length; i++) {\r
-            if(r[i] instanceof ExMCIMovie){\r
-                ExMCIMovie mci = (ExMCIMovie)r[i];\r
-                ExVideoContainer exVideo = mci.getExVideo();\r
-                int objectId = exVideo.getExMediaAtom().getObjectId();\r
-                if(objectId == idx){\r
-                    return exVideo.getPathAtom().getText();\r
-                }\r
-            }\r
-\r
-        }\r
-        return null;\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import java.io.ByteArrayOutputStream;
+
+import org.apache.poi.ddf.EscherClientDataRecord;
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherProperties;
+import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.hslf.record.*;
+import org.apache.poi.hslf.usermodel.SlideShow;
+
+/**
+ * Represents a movie in a PowerPoint document.
+ *
+ * @author Yegor Kozlov
+ */
+public final class MovieShape extends Picture {
+    public static final int DEFAULT_MOVIE_THUMBNAIL = -1;
+
+    public static final int MOVIE_MPEG = 1;
+    public static final int MOVIE_AVI  = 2;
+
+    /**
+     * Create a new <code>Picture</code>
+     *
+    * @param pictureIdx the index of the picture
+     */
+    public MovieShape(int movieIdx, int pictureIdx){
+        super(pictureIdx, null);
+        setMovieIndex(movieIdx);
+        setAutoPlay(true);
+    }
+
+    /**
+     * Create a new <code>Picture</code>
+     *
+     * @param idx the index of the picture
+     * @param parent the parent shape
+     */
+    public MovieShape(int movieIdx, int idx, Shape parent) {
+        super(idx, parent);
+        setMovieIndex(movieIdx);
+    }
+
+    /**
+      * Create a <code>Picture</code> object
+      *
+      * @param escherRecord the <code>EscherSpContainer</code> record which holds information about
+      *        this picture in the <code>Slide</code>
+      * @param parent the parent shape of this picture
+      */
+     protected MovieShape(EscherContainerRecord escherRecord, Shape parent){
+        super(escherRecord, parent);
+    }
+
+    /**
+     * Create a new Placeholder and initialize internal structures
+     *
+     * @return the created <code>EscherContainerRecord</code> which holds shape data
+     */
+    protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
+        _escherContainer = super.createSpContainer(idx, isChild);
+
+        setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x1000100);
+        setEscherProperty(EscherProperties.FILL__NOFILLHITTEST, 0x10001);
+
+        EscherClientDataRecord cldata = new EscherClientDataRecord();
+        cldata.setOptions((short)0xF);
+        _escherContainer.addChildRecord(cldata);
+
+        OEShapeAtom oe = new OEShapeAtom();
+        InteractiveInfo info = new InteractiveInfo();
+        InteractiveInfoAtom infoAtom = info.getInteractiveInfoAtom();
+        infoAtom.setAction(InteractiveInfoAtom.ACTION_MEDIA);
+        infoAtom.setHyperlinkType(InteractiveInfoAtom.LINK_NULL);
+
+        AnimationInfo an = new AnimationInfo();
+        AnimationInfoAtom anAtom = an.getAnimationInfoAtom();
+        anAtom.setFlag(AnimationInfoAtom.Automatic, true);
+
+        //convert hslf into ddf
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try {
+            oe.writeOut(out);
+            an.writeOut(out);
+            info.writeOut(out);
+        } catch(Exception e){
+            throw new HSLFException(e);
+        }
+        cldata.setRemainingData(out.toByteArray());
+
+        return _escherContainer;
+    }
+
+    /**
+     * Assign a movie to this shape
+     *
+     * @see org.apache.poi.hslf.usermodel.SlideShow#addMovie(String, int)
+     * @param idx  the index of the movie
+     */
+    public void setMovieIndex(int idx){
+        OEShapeAtom oe = (OEShapeAtom)getClientDataRecord(RecordTypes.OEShapeAtom.typeID);
+        oe.setOptions(idx);
+
+        AnimationInfo an = (AnimationInfo)getClientDataRecord(RecordTypes.AnimationInfo.typeID);
+        if(an != null) {
+            AnimationInfoAtom ai = an.getAnimationInfoAtom();
+            ai.setDimColor(0x07000000);
+            ai.setFlag(AnimationInfoAtom.Automatic, true);
+            ai.setFlag(AnimationInfoAtom.Play, true);
+            ai.setFlag(AnimationInfoAtom.Synchronous, true);
+            ai.setOrderID(idx + 1);
+        }
+    }
+
+    public void setAutoPlay(boolean flag){
+        AnimationInfo an = (AnimationInfo)getClientDataRecord(RecordTypes.AnimationInfo.typeID);
+        if(an != null){
+            an.getAnimationInfoAtom().setFlag(AnimationInfoAtom.Automatic, flag);
+            updateClientData();
+        }
+    }
+
+    public boolean  isAutoPlay(){
+        AnimationInfo an = (AnimationInfo)getClientDataRecord(RecordTypes.AnimationInfo.typeID);
+        if(an != null){
+            return an.getAnimationInfoAtom().getFlag(AnimationInfoAtom.Automatic);
+        }
+        return false;
+    }
+
+    /**
+     * @return UNC or local path to a video file
+     */
+    public String getPath(){
+        OEShapeAtom oe = (OEShapeAtom)getClientDataRecord(RecordTypes.OEShapeAtom.typeID);
+        int idx = oe.getOptions();
+
+        SlideShow ppt = getSheet().getSlideShow();
+        ExObjList lst = (ExObjList)ppt.getDocumentRecord().findFirstOfType(RecordTypes.ExObjList.typeID);
+        if(lst == null) return null;
+
+        Record[]  r = lst.getChildRecords();
+        for (int i = 0; i < r.length; i++) {
+            if(r[i] instanceof ExMCIMovie){
+                ExMCIMovie mci = (ExMCIMovie)r[i];
+                ExVideoContainer exVideo = mci.getExVideo();
+                int objectId = exVideo.getExMediaAtom().getObjectId();
+                if(objectId == idx){
+                    return exVideo.getPathAtom().getText();
+                }
+            }
+
+        }
+        return null;
+    }
+}
index 44fb80630d70c66dc7a2456703096a372f035f82..cdb05030b4d304b53fdcad6d520ca81a81add3b4 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.model;
 
 /**
- * This class represents a slide's notes in a PowerPoint Document. It 
- *  allows access to the text within, and the layout. For now, it only 
+ * This class represents a slide's notes in a PowerPoint Document. It
+ *  allows access to the text within, and the layout. For now, it only
  *  does the text side of things though
  *
  * @author Nick Burch
  */
 
-public class Notes extends Sheet
+public final class Notes extends Sheet
 {
   private TextRun[] _runs;
 
@@ -42,7 +39,7 @@ public class Notes extends Sheet
       super(notes, notes.getNotesAtom().getSlideID());
 
        // Now, build up TextRuns from pairs of TextHeaderAtom and
-       //  one of TextBytesAtom or TextCharsAtom, found inside 
+       //  one of TextBytesAtom or TextCharsAtom, found inside
        //  EscherTextboxWrapper's in the PPDrawing
        _runs = findTextRuns(getPPDrawing());
 
index 642b569461a4b17184cf855f13232f13a3e174f6..161a332b3407c7b3e5be8e4d98a6e58f8707b8b5 100755 (executable)
-/*\r
-* Licensed to the Apache Software Foundation (ASF) under one or more\r
-* contributor license agreements.  See the NOTICE file distributed with\r
-* this work for additional information regarding copyright ownership.\r
-* The ASF licenses this file to You under the Apache License, Version 2.0\r
-* (the "License"); you may not use this file except in compliance with\r
-* the License.  You may obtain a copy of the License at\r
-*\r
-*     http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*/\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.ddf.*;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.usermodel.ObjectData;\r
-import org.apache.poi.hslf.record.ExObjList;\r
-import org.apache.poi.hslf.record.Record;\r
-import org.apache.poi.hslf.record.ExEmbed;\r
-import org.apache.poi.util.POILogger;\r
-\r
-\r
-/**\r
- * A shape representing embedded OLE obejct.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class OLEShape extends Picture {\r
-    protected ExEmbed _exEmbed;\r
-\r
-    /**\r
-     * Create a new <code>OLEShape</code>\r
-     *\r
-    * @param idx the index of the picture\r
-     */\r
-    public OLEShape(int idx){\r
-        super(idx);\r
-    }\r
-\r
-    /**\r
-     * Create a new <code>OLEShape</code>\r
-     *\r
-     * @param idx the index of the picture\r
-     * @param parent the parent shape\r
-     */\r
-    public OLEShape(int idx, Shape parent) {\r
-        super(idx, parent);\r
-    }\r
-\r
-    /**\r
-      * Create a <code>OLEShape</code> object\r
-      *\r
-      * @param escherRecord the <code>EscherSpContainer</code> record which holds information about\r
-      *        this picture in the <code>Slide</code>\r
-      * @param parent the parent shape of this picture\r
-      */\r
-     protected OLEShape(EscherContainerRecord escherRecord, Shape parent){\r
-        super(escherRecord, parent);\r
-    }\r
-\r
-    /**\r
-     * Returns unique identifier for the OLE object.\r
-     *\r
-     * @return the unique identifier for the OLE object\r
-     */\r
-    public int getObjectID(){\r
-        return getEscherProperty(EscherProperties.BLIP__PICTUREID);\r
-    }\r
-\r
-    /**\r
-     * Returns unique identifier for the OLE object.\r
-     *\r
-     * @return the unique identifier for the OLE object\r
-     */\r
-    public ObjectData getObjectData(){\r
-        SlideShow ppt = getSheet().getSlideShow();\r
-        ObjectData[] ole = ppt.getEmbeddedObjects();\r
-\r
-        //persist reference\r
-        int ref = getExEmbed().getExOleObjAtom().getObjStgDataRef();\r
-        for (int i = 0; i < ole.length; i++) {\r
-            if(ole[i].getExOleObjStg().getPersistId() == ref) return ole[i];\r
-\r
-        }\r
-        logger.log(POILogger.WARN, "OLE data not found");\r
-        return null;\r
-    }\r
-\r
-    /**\r
-     * Return the record container for this embedded object.\r
-     *\r
-     * <p>\r
-     * It contains:\r
-     * 1. ExEmbedAtom.(4045)\r
-     * 2. ExOleObjAtom (4035)\r
-     * 3. CString (4026), Instance MenuName (1) used for menus and the Links dialog box.\r
-     * 4. CString (4026), Instance ProgID (2) that stores the OLE Programmatic Identifier.\r
-     *     A ProgID is a string that uniquely identifies a given object.\r
-     * 5. CString (4026), Instance ClipboardName (3) that appears in the paste special dialog.\r
-     * 6. MetaFile( 4033), optional\r
-     * </p>\r
-     */\r
-    public ExEmbed getExEmbed(){\r
-        if(_exEmbed == null){\r
-            SlideShow ppt = getSheet().getSlideShow();\r
-\r
-            ExObjList lst = ppt.getDocumentRecord().getExObjList();\r
-            if(lst == null){\r
-                logger.log(POILogger.WARN, "ExObjList not found");\r
-                return null;\r
-            }\r
-\r
-            int id = getObjectID();\r
-            Record[] ch = lst.getChildRecords();\r
-            for (int i = 0; i < ch.length; i++) {\r
-                if(ch[i] instanceof ExEmbed){\r
-                    ExEmbed embd = (ExEmbed)ch[i];\r
-                    if( embd.getExOleObjAtom().getObjID() == id) _exEmbed = embd;\r
-                }\r
-            }\r
-        }\r
-        return _exEmbed;\r
-    }\r
-\r
-    /**\r
-     * Returns the instance name of the embedded object, e.g. "Document" or "Workbook".\r
-     *\r
-     * @return the instance name of the embedded object\r
-     */\r
-    public String getInstanceName(){\r
-        return getExEmbed().getMenuName();\r
-    }\r
-\r
-    /**\r
-     * Returns the full name of the embedded object,\r
-     *  e.g. "Microsoft Word Document" or "Microsoft Office Excel Worksheet".\r
-     *\r
-     * @return the full name of the embedded object\r
-     */\r
-    public String getFullName(){\r
-        return getExEmbed().getClipboardName();\r
-    }\r
-\r
-    /**\r
-     * Returns the ProgID that stores the OLE Programmatic Identifier.\r
-     * A ProgID is a string that uniquely identifies a given object, for example,\r
-     * "Word.Document.8" or "Excel.Sheet.8".\r
-     *\r
-     * @return the ProgID\r
-     */\r
-    public String getProgID(){\r
-        return getExEmbed().getProgId();\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import org.apache.poi.ddf.*;
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.ObjectData;
+import org.apache.poi.hslf.record.ExObjList;
+import org.apache.poi.hslf.record.Record;
+import org.apache.poi.hslf.record.ExEmbed;
+import org.apache.poi.util.POILogger;
+
+
+/**
+ * A shape representing embedded OLE obejct.
+ *
+ * @author Yegor Kozlov
+ */
+public final class OLEShape extends Picture {
+    protected ExEmbed _exEmbed;
+
+    /**
+     * Create a new <code>OLEShape</code>
+     *
+    * @param idx the index of the picture
+     */
+    public OLEShape(int idx){
+        super(idx);
+    }
+
+    /**
+     * Create a new <code>OLEShape</code>
+     *
+     * @param idx the index of the picture
+     * @param parent the parent shape
+     */
+    public OLEShape(int idx, Shape parent) {
+        super(idx, parent);
+    }
+
+    /**
+      * Create a <code>OLEShape</code> object
+      *
+      * @param escherRecord the <code>EscherSpContainer</code> record which holds information about
+      *        this picture in the <code>Slide</code>
+      * @param parent the parent shape of this picture
+      */
+     protected OLEShape(EscherContainerRecord escherRecord, Shape parent){
+        super(escherRecord, parent);
+    }
+
+    /**
+     * Returns unique identifier for the OLE object.
+     *
+     * @return the unique identifier for the OLE object
+     */
+    public int getObjectID(){
+        return getEscherProperty(EscherProperties.BLIP__PICTUREID);
+    }
+
+    /**
+     * Returns unique identifier for the OLE object.
+     *
+     * @return the unique identifier for the OLE object
+     */
+    public ObjectData getObjectData(){
+        SlideShow ppt = getSheet().getSlideShow();
+        ObjectData[] ole = ppt.getEmbeddedObjects();
+
+        //persist reference
+        int ref = getExEmbed().getExOleObjAtom().getObjStgDataRef();
+        for (int i = 0; i < ole.length; i++) {
+            if(ole[i].getExOleObjStg().getPersistId() == ref) return ole[i];
+
+        }
+        logger.log(POILogger.WARN, "OLE data not found");
+        return null;
+    }
+
+    /**
+     * Return the record container for this embedded object.
+     *
+     * <p>
+     * It contains:
+     * 1. ExEmbedAtom.(4045)
+     * 2. ExOleObjAtom (4035)
+     * 3. CString (4026), Instance MenuName (1) used for menus and the Links dialog box.
+     * 4. CString (4026), Instance ProgID (2) that stores the OLE Programmatic Identifier.
+     *     A ProgID is a string that uniquely identifies a given object.
+     * 5. CString (4026), Instance ClipboardName (3) that appears in the paste special dialog.
+     * 6. MetaFile( 4033), optional
+     * </p>
+     */
+    public ExEmbed getExEmbed(){
+        if(_exEmbed == null){
+            SlideShow ppt = getSheet().getSlideShow();
+
+            ExObjList lst = ppt.getDocumentRecord().getExObjList();
+            if(lst == null){
+                logger.log(POILogger.WARN, "ExObjList not found");
+                return null;
+            }
+
+            int id = getObjectID();
+            Record[] ch = lst.getChildRecords();
+            for (int i = 0; i < ch.length; i++) {
+                if(ch[i] instanceof ExEmbed){
+                    ExEmbed embd = (ExEmbed)ch[i];
+                    if( embd.getExOleObjAtom().getObjID() == id) _exEmbed = embd;
+                }
+            }
+        }
+        return _exEmbed;
+    }
+
+    /**
+     * Returns the instance name of the embedded object, e.g. "Document" or "Workbook".
+     *
+     * @return the instance name of the embedded object
+     */
+    public String getInstanceName(){
+        return getExEmbed().getMenuName();
+    }
+
+    /**
+     * Returns the full name of the embedded object,
+     *  e.g. "Microsoft Word Document" or "Microsoft Office Excel Worksheet".
+     *
+     * @return the full name of the embedded object
+     */
+    public String getFullName(){
+        return getExEmbed().getClipboardName();
+    }
+
+    /**
+     * Returns the ProgID that stores the OLE Programmatic Identifier.
+     * A ProgID is a string that uniquely identifies a given object, for example,
+     * "Word.Document.8" or "Excel.Sheet.8".
+     *
+     * @return the ProgID
+     */
+    public String getProgID(){
+        return getExEmbed().getProgId();
+    }
+}
index 8b4de90509a32107d4d0a44c17f98d3aef045b02..e6f7a9ded9e3b38fbce6b98a6335455441909491 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.hslf.record.FontEntityAtom;\r
-\r
-/**\r
- * Represents a Font used in a presenation.\r
- * <p>\r
- * In PowerPoint Font is a shared resource and can be shared among text object in the presentation.\r
- * </p>\r
- * Some commonly used fonts are predefined in static constants. \r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class PPFont {\r
-    /**\r
-     * ANSI character set\r
-     */\r
-    public final static byte ANSI_CHARSET = 0;\r
-\r
-    /**\r
-     * Default character set.\r
-     */\r
-    public final static byte DEFAULT_CHARSET = 1;\r
-\r
-    /**\r
-     * Symbol character set\r
-     */\r
-    public final static byte SYMBOL_CHARSET = 2;\r
-\r
-\r
-    /**\r
-     * Constants for the pitch and family of the font.\r
-     * The two low-order bits specify the pitch of the font and can be one of the following values\r
-     */\r
-    public final static byte DEFAULT_PITCH  = 0;\r
-    public final static byte FIXED_PITCH    = 1;\r
-    public final static byte VARIABLE_PITCH = 2;\r
-\r
-    /**\r
-     * Don't care or don't know.\r
-     */\r
-    public final static byte FF_DONTCARE    = 0;\r
-    /**\r
-     * Fonts with variable stroke width (proportional) and with serifs. Times New Roman is an example.\r
-     */\r
-    public final static byte FF_ROMAN       = 16;\r
-    /**\r
-     * Fonts with variable stroke width (proportional) and without serifs. Arial is an example.\r
-     */\r
-    public final static byte FF_SWISS       = 32;\r
-    /**\r
-     * Fonts designed to look like handwriting. Script and Cursive are examples.\r
-     */\r
-    public final static byte FF_SCRIPT      = 64;\r
-    /**\r
-     * Fonts with constant stroke width (monospace), with or without serifs.\r
-     * Monospace fonts are usually modern. CourierNew is an example\r
-     */\r
-    public final static byte FF_MODERN      = 48;\r
-    /**\r
-     * Novelty fonts. Old English is an example\r
-     */\r
-    public final static byte FF_DECORATIVE  = 80;\r
-\r
-\r
-    protected int charset;\r
-    protected int type;\r
-    protected int flags;\r
-    protected int pitch;\r
-    protected String name;\r
-\r
-    /**\r
-     * Creates a new instance of PPFont\r
-     */\r
-    public PPFont(){\r
-\r
-    }\r
-\r
-    /**\r
-     * Creates a new instance of PPFont and initialize it from the supplied font atom\r
-     */\r
-    public PPFont(FontEntityAtom fontAtom){\r
-        name = fontAtom.getFontName();\r
-        charset = fontAtom.getCharSet();\r
-        type = fontAtom.getFontType();\r
-        flags = fontAtom.getFontFlags();\r
-        pitch = fontAtom.getPitchAndFamily();\r
-    }\r
-\r
-    /**\r
-     * set the name for the font (i.e. Arial)\r
-     *\r
-     * @param val  String representing the name of the font to use\r
-     */\r
-     public void setFontName(String val){\r
-        name = val;\r
-    }\r
-\r
-    /**\r
-     * get the name for the font (i.e. Arial)\r
-     *\r
-     * @return String representing the name of the font to use\r
-     */\r
-    public String getFontName(){\r
-        return name;\r
-    }\r
-\r
-    /**\r
-     * set the character set\r
-     *\r
-     * @param val - characterset\r
-     */\r
-    public void setCharSet(int val){\r
-        charset = val;\r
-    }\r
-\r
-    /**\r
-     * get the character set\r
-     *\r
-     * @return charset - characterset\r
-     */\r
-    public int getCharSet(){\r
-        return charset;\r
-    }\r
-\r
-    /**\r
-     * set the font flags\r
-     * Bit 1: If set, font is subsetted\r
-     *\r
-     * @param val - the font flags\r
-     */\r
-    public void setFontFlags(int val){\r
-        flags = val;\r
-    }\r
-\r
-    /**\r
-     * get the character set\r
-     * Bit 1: If set, font is subsetted\r
-     *\r
-     * @return the font flags\r
-     */\r
-    public int getFontFlags(){\r
-        return flags;\r
-    }\r
-\r
-    /**\r
-     * set the font type\r
-     * <p>\r
-     * Bit 1: Raster Font\r
-     * Bit 2: Device Font\r
-     * Bit 3: TrueType Font\r
-     * </p>\r
-     *\r
-     * @param val - the font type\r
-     */\r
-    public void setFontType(int val){\r
-        type = val;\r
-    }\r
-\r
-    /**\r
-     * get the font type\r
-     * <p>\r
-     * Bit 1: Raster Font\r
-     * Bit 2: Device Font\r
-     * Bit 3: TrueType Font\r
-     * </p>\r
-     *\r
-     * @return the font type\r
-     */\r
-    public int getFontType(){\r
-        return type;\r
-    }\r
-\r
-    /**\r
-     * set lfPitchAndFamily\r
-     *\r
-     *\r
-     * @param val - Corresponds to the lfPitchAndFamily field of the Win32 API LOGFONT structure\r
-     */\r
-    public void setPitchAndFamily(int val){\r
-        pitch = val;\r
-    }\r
-\r
-    /**\r
-     * get lfPitchAndFamily\r
-     *\r
-     * @return corresponds to the lfPitchAndFamily field of the Win32 API LOGFONT structure\r
-     */\r
-    public int getPitchAndFamily(){\r
-        return pitch;\r
-    }\r
-\r
-    public static final PPFont ARIAL;\r
-    public static final PPFont TIMES_NEW_ROMAN ;\r
-    public static final PPFont COURIER_NEW;\r
-    public static final PPFont WINGDINGS;\r
-    static {\r
-        ARIAL = new PPFont();\r
-        ARIAL.setFontName("Arial");\r
-        ARIAL.setCharSet(ANSI_CHARSET);\r
-        ARIAL.setFontType(4);\r
-        ARIAL.setFontFlags(0);\r
-        ARIAL.setPitchAndFamily(VARIABLE_PITCH | FF_SWISS);\r
-\r
-        TIMES_NEW_ROMAN = new PPFont();\r
-        TIMES_NEW_ROMAN.setFontName("Times New Roman");\r
-        TIMES_NEW_ROMAN.setCharSet(ANSI_CHARSET);\r
-        TIMES_NEW_ROMAN.setFontType(4);\r
-        TIMES_NEW_ROMAN.setFontFlags(0);\r
-        TIMES_NEW_ROMAN.setPitchAndFamily(VARIABLE_PITCH | FF_ROMAN);\r
-\r
-        COURIER_NEW = new PPFont();\r
-        COURIER_NEW.setFontName("Courier New");\r
-        COURIER_NEW.setCharSet(ANSI_CHARSET);\r
-        COURIER_NEW.setFontType(4);\r
-        COURIER_NEW.setFontFlags(0);\r
-        COURIER_NEW.setPitchAndFamily(FIXED_PITCH | FF_MODERN);\r
-\r
-        WINGDINGS = new PPFont();\r
-        WINGDINGS.setFontName("Wingdings");\r
-        WINGDINGS.setCharSet(SYMBOL_CHARSET);\r
-        WINGDINGS.setFontType(4);\r
-        WINGDINGS.setFontFlags(0);\r
-        WINGDINGS.setPitchAndFamily(VARIABLE_PITCH | FF_DONTCARE);\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import org.apache.poi.hslf.record.FontEntityAtom;
+
+/**
+ * Represents a Font used in a presenation.
+ * <p>
+ * In PowerPoint Font is a shared resource and can be shared among text object in the presentation.
+ * </p>
+ * Some commonly used fonts are predefined in static constants.
+ *
+ * @author Yegor Kozlov
+ */
+public final class PPFont {
+    /**
+     * ANSI character set
+     */
+    public final static byte ANSI_CHARSET = 0;
+
+    /**
+     * Default character set.
+     */
+    public final static byte DEFAULT_CHARSET = 1;
+
+    /**
+     * Symbol character set
+     */
+    public final static byte SYMBOL_CHARSET = 2;
+
+
+    /**
+     * Constants for the pitch and family of the font.
+     * The two low-order bits specify the pitch of the font and can be one of the following values
+     */
+    public final static byte DEFAULT_PITCH  = 0;
+    public final static byte FIXED_PITCH    = 1;
+    public final static byte VARIABLE_PITCH = 2;
+
+    /**
+     * Don't care or don't know.
+     */
+    public final static byte FF_DONTCARE    = 0;
+    /**
+     * Fonts with variable stroke width (proportional) and with serifs. Times New Roman is an example.
+     */
+    public final static byte FF_ROMAN       = 16;
+    /**
+     * Fonts with variable stroke width (proportional) and without serifs. Arial is an example.
+     */
+    public final static byte FF_SWISS       = 32;
+    /**
+     * Fonts designed to look like handwriting. Script and Cursive are examples.
+     */
+    public final static byte FF_SCRIPT      = 64;
+    /**
+     * Fonts with constant stroke width (monospace), with or without serifs.
+     * Monospace fonts are usually modern. CourierNew is an example
+     */
+    public final static byte FF_MODERN      = 48;
+    /**
+     * Novelty fonts. Old English is an example
+     */
+    public final static byte FF_DECORATIVE  = 80;
+
+
+    protected int charset;
+    protected int type;
+    protected int flags;
+    protected int pitch;
+    protected String name;
+
+    /**
+     * Creates a new instance of PPFont
+     */
+    public PPFont(){
+
+    }
+
+    /**
+     * Creates a new instance of PPFont and initialize it from the supplied font atom
+     */
+    public PPFont(FontEntityAtom fontAtom){
+        name = fontAtom.getFontName();
+        charset = fontAtom.getCharSet();
+        type = fontAtom.getFontType();
+        flags = fontAtom.getFontFlags();
+        pitch = fontAtom.getPitchAndFamily();
+    }
+
+    /**
+     * set the name for the font (i.e. Arial)
+     *
+     * @param val  String representing the name of the font to use
+     */
+     public void setFontName(String val){
+        name = val;
+    }
+
+    /**
+     * get the name for the font (i.e. Arial)
+     *
+     * @return String representing the name of the font to use
+     */
+    public String getFontName(){
+        return name;
+    }
+
+    /**
+     * set the character set
+     *
+     * @param val - characterset
+     */
+    public void setCharSet(int val){
+        charset = val;
+    }
+
+    /**
+     * get the character set
+     *
+     * @return charset - characterset
+     */
+    public int getCharSet(){
+        return charset;
+    }
+
+    /**
+     * set the font flags
+     * Bit 1: If set, font is subsetted
+     *
+     * @param val - the font flags
+     */
+    public void setFontFlags(int val){
+        flags = val;
+    }
+
+    /**
+     * get the character set
+     * Bit 1: If set, font is subsetted
+     *
+     * @return the font flags
+     */
+    public int getFontFlags(){
+        return flags;
+    }
+
+    /**
+     * set the font type
+     * <p>
+     * Bit 1: Raster Font
+     * Bit 2: Device Font
+     * Bit 3: TrueType Font
+     * </p>
+     *
+     * @param val - the font type
+     */
+    public void setFontType(int val){
+        type = val;
+    }
+
+    /**
+     * get the font type
+     * <p>
+     * Bit 1: Raster Font
+     * Bit 2: Device Font
+     * Bit 3: TrueType Font
+     * </p>
+     *
+     * @return the font type
+     */
+    public int getFontType(){
+        return type;
+    }
+
+    /**
+     * set lfPitchAndFamily
+     *
+     *
+     * @param val - Corresponds to the lfPitchAndFamily field of the Win32 API LOGFONT structure
+     */
+    public void setPitchAndFamily(int val){
+        pitch = val;
+    }
+
+    /**
+     * get lfPitchAndFamily
+     *
+     * @return corresponds to the lfPitchAndFamily field of the Win32 API LOGFONT structure
+     */
+    public int getPitchAndFamily(){
+        return pitch;
+    }
+
+    public static final PPFont ARIAL;
+    public static final PPFont TIMES_NEW_ROMAN ;
+    public static final PPFont COURIER_NEW;
+    public static final PPFont WINGDINGS;
+    static {
+        ARIAL = new PPFont();
+        ARIAL.setFontName("Arial");
+        ARIAL.setCharSet(ANSI_CHARSET);
+        ARIAL.setFontType(4);
+        ARIAL.setFontFlags(0);
+        ARIAL.setPitchAndFamily(VARIABLE_PITCH | FF_SWISS);
+
+        TIMES_NEW_ROMAN = new PPFont();
+        TIMES_NEW_ROMAN.setFontName("Times New Roman");
+        TIMES_NEW_ROMAN.setCharSet(ANSI_CHARSET);
+        TIMES_NEW_ROMAN.setFontType(4);
+        TIMES_NEW_ROMAN.setFontFlags(0);
+        TIMES_NEW_ROMAN.setPitchAndFamily(VARIABLE_PITCH | FF_ROMAN);
+
+        COURIER_NEW = new PPFont();
+        COURIER_NEW.setFontName("Courier New");
+        COURIER_NEW.setCharSet(ANSI_CHARSET);
+        COURIER_NEW.setFontType(4);
+        COURIER_NEW.setFontFlags(0);
+        COURIER_NEW.setPitchAndFamily(FIXED_PITCH | FF_MODERN);
+
+        WINGDINGS = new PPFont();
+        WINGDINGS.setFontName("Wingdings");
+        WINGDINGS.setCharSet(SYMBOL_CHARSET);
+        WINGDINGS.setFontType(4);
+        WINGDINGS.setFontFlags(0);
+        WINGDINGS.setPitchAndFamily(VARIABLE_PITCH | FF_DONTCARE);
+    }
+}
index 37cedce0fabcb36dfebeb3a8e73cfd859dbbd5a1..4686dc3f7668982af201adf2dcef841f0d992a0e 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 
@@ -37,7 +38,7 @@ import org.apache.poi.util.POILogFactory;
  *
  * @author Yegor Kozlov
  */
-public class PPGraphics2D extends Graphics2D implements Cloneable {
+public final class PPGraphics2D extends Graphics2D implements Cloneable {
 
     protected POILogger log = POILogFactory.getLogger(this.getClass());
 
index db86f288115979d558d2632a44d1824cdb936d5e..72fcbd6af7e2e01b0d89773fe9db43c2dd3c4f4e 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hslf.model;
 
 import org.apache.poi.ddf.*;
@@ -72,7 +73,7 @@ public class Picture extends SimpleShape {
      * Windows DIB (BMP)
      */
     public static final byte DIB = 7;
-    
+
     /**
      * Create a new <code>Picture</code>
      *
@@ -143,7 +144,7 @@ public class Picture extends SimpleShape {
     /**
      * Resize this picture to the default size.
      * For PNG and JPEG resizes the image to 100%,
-     * for other types sets the default size of 200x200 pixels.  
+     * for other types sets the default size of 200x200 pixels.
      */
     public void setDefaultSize(){
         PictureData pict = getPictureData();
@@ -151,10 +152,10 @@ public class Picture extends SimpleShape {
             BufferedImage img = null;
             try {
                        img = ImageIO.read(new ByteArrayInputStream(pict.getData()));
-            } 
+            }
             catch (IOException e){}
                catch (NegativeArraySizeException ne) {}
-               
+
             if(img != null) {
                // Valid image, set anchor from it
                setAnchor(new java.awt.Rectangle(0, 0, img.getWidth()*POINT_DPI/PIXEL_DPI, img.getHeight()*POINT_DPI/PIXEL_DPI));
@@ -163,7 +164,7 @@ public class Picture extends SimpleShape {
                setAnchor(new java.awt.Rectangle(0, 0, 200, 200));
             }
         } else {
-            //default size of a metafile picture is 200x200 
+            //default size of a metafile picture is 200x200
             setAnchor(new java.awt.Rectangle(50, 50, 200, 200));
         }
     }
index 1474fdc7c082cef2b85a412f8aa8c93a8251448c..71716fe4b891ba465c8c97e23e39be3d69eaffe2 100644 (file)
@@ -29,7 +29,7 @@ import java.io.ByteArrayOutputStream;
  *
  * @author Yegor Kozlov
  */
-public class Placeholder extends TextBox {
+public final class Placeholder extends TextBox {
 
     protected Placeholder(EscherContainerRecord escherRecord, Shape parent){
         super(escherRecord, parent);
index ea4afe01b29ee89339552e0da793e70ce717d09c..4e2eb3ed10c7c9b203641be1b1deaeb2f478588f 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.ddf.*;\r
-import org.apache.poi.util.LittleEndian;\r
-\r
-import java.awt.geom.Point2D;\r
-\r
-/**\r
- * A simple closed polygon shape\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class Polygon extends AutoShape {\r
-    /**\r
-     * Create a Polygon object and initialize it from the supplied Record container.\r
-     *\r
-     * @param escherRecord       <code>EscherSpContainer</code> container which holds information about this shape\r
-     * @param parent    the parent of the shape\r
-     */\r
-   protected Polygon(EscherContainerRecord escherRecord, Shape parent){\r
-        super(escherRecord, parent);\r
-\r
-    }\r
-\r
-    /**\r
-     * Create a new Polygon. This constructor is used when a new shape is created.\r
-     *\r
-     * @param parent    the parent of this Shape. For example, if this text box is a cell\r
-     * in a table then the parent is Table.\r
-     */\r
-    public Polygon(Shape parent){\r
-        super(null, parent);\r
-        _escherContainer = createSpContainer(ShapeTypes.NotPrimitive, parent instanceof ShapeGroup);\r
-    }\r
-\r
-    /**\r
-     * Create a new Polygon. This constructor is used when a new shape is created.\r
-     *\r
-     */\r
-    public Polygon(){\r
-        this(null);\r
-    }\r
-\r
-    /**\r
-     * Set the polygon vertices\r
-     *\r
-     * @param xPoints\r
-     * @param yPoints\r
-     */\r
-    public void setPoints(float[] xPoints, float[] yPoints)\r
-    {\r
-        float right  = findBiggest(xPoints);\r
-        float bottom = findBiggest(yPoints);\r
-        float left   = findSmallest(xPoints);\r
-        float top    = findSmallest(yPoints);\r
-\r
-        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);\r
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, (int)((right - left)*POINT_DPI/MASTER_DPI)));\r
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, (int)((bottom - top)*POINT_DPI/MASTER_DPI)));\r
-\r
-        for (int i = 0; i < xPoints.length; i++) {\r
-            xPoints[i] += -left;\r
-            yPoints[i] += -top;\r
-        }\r
-\r
-        int numpoints = xPoints.length;\r
-\r
-        EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0] );\r
-        verticesProp.setNumberOfElementsInArray(numpoints+1);\r
-        verticesProp.setNumberOfElementsInMemory(numpoints+1);\r
-        verticesProp.setSizeOfElements(0xFFF0);\r
-        for (int i = 0; i < numpoints; i++)\r
-        {\r
-            byte[] data = new byte[4];\r
-            LittleEndian.putShort(data, 0, (short)(xPoints[i]*POINT_DPI/MASTER_DPI));\r
-            LittleEndian.putShort(data, 2, (short)(yPoints[i]*POINT_DPI/MASTER_DPI));\r
-            verticesProp.setElement(i, data);\r
-        }\r
-        byte[] data = new byte[4];\r
-        LittleEndian.putShort(data, 0, (short)(xPoints[0]*POINT_DPI/MASTER_DPI));\r
-        LittleEndian.putShort(data, 2, (short)(yPoints[0]*POINT_DPI/MASTER_DPI));\r
-        verticesProp.setElement(numpoints, data);\r
-        opt.addEscherProperty(verticesProp);\r
-\r
-        EscherArrayProperty segmentsProp = new EscherArrayProperty(EscherProperties.GEOMETRY__SEGMENTINFO, false, null );\r
-        segmentsProp.setSizeOfElements(0x0002);\r
-        segmentsProp.setNumberOfElementsInArray(numpoints * 2 + 4);\r
-        segmentsProp.setNumberOfElementsInMemory(numpoints * 2 + 4);\r
-        segmentsProp.setElement(0, new byte[] { (byte)0x00, (byte)0x40 } );\r
-        segmentsProp.setElement(1, new byte[] { (byte)0x00, (byte)0xAC } );\r
-        for (int i = 0; i < numpoints; i++)\r
-        {\r
-            segmentsProp.setElement(2 + i * 2, new byte[] { (byte)0x01, (byte)0x00 } );\r
-            segmentsProp.setElement(3 + i * 2, new byte[] { (byte)0x00, (byte)0xAC } );\r
-        }\r
-        segmentsProp.setElement(segmentsProp.getNumberOfElementsInArray() - 2, new byte[] { (byte)0x01, (byte)0x60 } );\r
-        segmentsProp.setElement(segmentsProp.getNumberOfElementsInArray() - 1, new byte[] { (byte)0x00, (byte)0x80 } );\r
-        opt.addEscherProperty(segmentsProp);\r
-\r
-        opt.sortProperties();\r
-    }\r
-\r
-    /**\r
-     * Set the polygon vertices\r
-     *\r
-     * @param points the polygon vertices\r
-     */\r
-      public void setPoints(Point2D[] points)\r
-     {\r
-        float[] xpoints = new float[points.length];\r
-        float[] ypoints = new float[points.length];\r
-        for (int i = 0; i < points.length; i++) {\r
-            xpoints[i] = (float)points[i].getX();\r
-            ypoints[i] = (float)points[i].getY();\r
-\r
-        }\r
-\r
-        setPoints(xpoints, ypoints);\r
-    }\r
-\r
-    private float findBiggest( float[] values )\r
-    {\r
-        float result = Float.MIN_VALUE;\r
-        for ( int i = 0; i < values.length; i++ )\r
-        {\r
-            if (values[i] > result)\r
-                result = values[i];\r
-        }\r
-        return result;\r
-    }\r
-\r
-    private float findSmallest( float[] values )\r
-    {\r
-        float result = Float.MAX_VALUE;\r
-        for ( int i = 0; i < values.length; i++ )\r
-        {\r
-            if (values[i] < result)\r
-                result = values[i];\r
-        }\r
-        return result;\r
-    }\r
-\r
-\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import org.apache.poi.ddf.*;
+import org.apache.poi.util.LittleEndian;
+
+import java.awt.geom.Point2D;
+
+/**
+ * A simple closed polygon shape
+ *
+ * @author Yegor Kozlov
+ */
+public final class Polygon extends AutoShape {
+    /**
+     * Create a Polygon 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
+     */
+   protected Polygon(EscherContainerRecord escherRecord, Shape parent){
+        super(escherRecord, parent);
+
+    }
+
+    /**
+     * Create a new Polygon. This constructor is used when a new shape is created.
+     *
+     * @param parent    the parent of this Shape. For example, if this text box is a cell
+     * in a table then the parent is Table.
+     */
+    public Polygon(Shape parent){
+        super(null, parent);
+        _escherContainer = createSpContainer(ShapeTypes.NotPrimitive, parent instanceof ShapeGroup);
+    }
+
+    /**
+     * Create a new Polygon. This constructor is used when a new shape is created.
+     *
+     */
+    public Polygon(){
+        this(null);
+    }
+
+    /**
+     * Set the polygon vertices
+     *
+     * @param xPoints
+     * @param yPoints
+     */
+    public void setPoints(float[] xPoints, float[] yPoints)
+    {
+        float right  = findBiggest(xPoints);
+        float bottom = findBiggest(yPoints);
+        float left   = findSmallest(xPoints);
+        float top    = findSmallest(yPoints);
+
+        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, (int)((right - left)*POINT_DPI/MASTER_DPI)));
+        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, (int)((bottom - top)*POINT_DPI/MASTER_DPI)));
+
+        for (int i = 0; i < xPoints.length; i++) {
+            xPoints[i] += -left;
+            yPoints[i] += -top;
+        }
+
+        int numpoints = xPoints.length;
+
+        EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0] );
+        verticesProp.setNumberOfElementsInArray(numpoints+1);
+        verticesProp.setNumberOfElementsInMemory(numpoints+1);
+        verticesProp.setSizeOfElements(0xFFF0);
+        for (int i = 0; i < numpoints; i++)
+        {
+            byte[] data = new byte[4];
+            LittleEndian.putShort(data, 0, (short)(xPoints[i]*POINT_DPI/MASTER_DPI));
+            LittleEndian.putShort(data, 2, (short)(yPoints[i]*POINT_DPI/MASTER_DPI));
+            verticesProp.setElement(i, data);
+        }
+        byte[] data = new byte[4];
+        LittleEndian.putShort(data, 0, (short)(xPoints[0]*POINT_DPI/MASTER_DPI));
+        LittleEndian.putShort(data, 2, (short)(yPoints[0]*POINT_DPI/MASTER_DPI));
+        verticesProp.setElement(numpoints, data);
+        opt.addEscherProperty(verticesProp);
+
+        EscherArrayProperty segmentsProp = new EscherArrayProperty(EscherProperties.GEOMETRY__SEGMENTINFO, false, null );
+        segmentsProp.setSizeOfElements(0x0002);
+        segmentsProp.setNumberOfElementsInArray(numpoints * 2 + 4);
+        segmentsProp.setNumberOfElementsInMemory(numpoints * 2 + 4);
+        segmentsProp.setElement(0, new byte[] { (byte)0x00, (byte)0x40 } );
+        segmentsProp.setElement(1, new byte[] { (byte)0x00, (byte)0xAC } );
+        for (int i = 0; i < numpoints; i++)
+        {
+            segmentsProp.setElement(2 + i * 2, new byte[] { (byte)0x01, (byte)0x00 } );
+            segmentsProp.setElement(3 + i * 2, new byte[] { (byte)0x00, (byte)0xAC } );
+        }
+        segmentsProp.setElement(segmentsProp.getNumberOfElementsInArray() - 2, new byte[] { (byte)0x01, (byte)0x60 } );
+        segmentsProp.setElement(segmentsProp.getNumberOfElementsInArray() - 1, new byte[] { (byte)0x00, (byte)0x80 } );
+        opt.addEscherProperty(segmentsProp);
+
+        opt.sortProperties();
+    }
+
+    /**
+     * Set the polygon vertices
+     *
+     * @param points the polygon vertices
+     */
+      public void setPoints(Point2D[] points)
+     {
+        float[] xpoints = new float[points.length];
+        float[] ypoints = new float[points.length];
+        for (int i = 0; i < points.length; i++) {
+            xpoints[i] = (float)points[i].getX();
+            ypoints[i] = (float)points[i].getY();
+
+        }
+
+        setPoints(xpoints, ypoints);
+    }
+
+    private float findBiggest( float[] values )
+    {
+        float result = Float.MIN_VALUE;
+        for ( int i = 0; i < values.length; i++ )
+        {
+            if (values[i] > result)
+                result = values[i];
+        }
+        return result;
+    }
+
+    private float findSmallest( float[] values )
+    {
+        float result = Float.MAX_VALUE;
+        for ( int i = 0; i < values.length; i++ )
+        {
+            if (values[i] < result)
+                result = values[i];
+        }
+        return result;
+    }
+
+
+}
index 7ab12543709963de14cbf3587fd35416d5d91570..3971d5216db0ee0e49a847343ec00d2fb924f216 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
index ab95fae66a5387c1cf0950856f7c6ca0ff26605f..9440bc61e2de4bb7d865e21566466c4765f54a47 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
@@ -29,12 +30,12 @@ import java.util.Iterator;
  *
  * @author Yegor Kozlov
  */
-public class ShapeFactory {
+public final class ShapeFactory {
     // For logging
     protected static POILogger logger = POILogFactory.getLogger(ShapeFactory.class);
 
     /**
-     * Create a new shape from the data provided.  
+     * Create a new shape from the data provided.
      */
     public static Shape createShape(EscherContainerRecord spContainer, Shape parent){
         if (spContainer.getRecordId() == EscherContainerRecord.SPGR_CONTAINER){
@@ -96,7 +97,7 @@ public class ShapeFactory {
                 } else if (oes != null){
                     shape = new OLEShape(spContainer, parent);
                 }
-                
+
                 if(shape == null) shape = new Picture(spContainer, parent);
                 break;
             }
index 50119b6bff99b0ed5e9be0cc773da7f039bfd155..fe9b4216872566883ae03d05ee00af4480741403 100644 (file)
@@ -86,7 +86,7 @@ public class ShapeGroup extends Shape{
                        logger.log(POILogger.ERROR, "Shape contained non container escher record, was " + r.getClass().getName());
                }
         }
-        
+
         // Put the shapes into an array, and return
         Shape[] shapes = shapeList.toArray(new Shape[shapeList.size()]);
         return shapes;
index 069fdbc4d06fcdd310d68bff0fb645efd9dffb97..591bb55523e34e50744f3547b7d3c314e27d967c 100755 (executable)
@@ -1,27 +1,28 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-/**\r
- * Date: Apr 17, 2008\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public interface ShapeOutline {\r
-    java.awt.Shape getOutline(Shape shape);\r
-\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+/**
+ * Date: Apr 17, 2008
+ *
+ * @author Yegor Kozlov
+ */
+public interface ShapeOutline {
+    java.awt.Shape getOutline(Shape shape);
+
+}
index fa947ddfed69b49bcb74b832c3841a8420094933..15a727af71abda3560bcdf7235867a3c25c9d7c4 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-\r
-import org.apache.poi.util.POILogger;\r
-import org.apache.poi.util.POILogFactory;\r
-\r
-import java.awt.*;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-/**\r
- * Paint a shape into java.awt.Graphics2D\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class ShapePainter {\r
-    protected static POILogger logger = POILogFactory.getLogger(ShapePainter.class);\r
-\r
-    public static void paint(SimpleShape shape, Graphics2D graphics){\r
-        Rectangle2D anchor = shape.getLogicalAnchor2D();\r
-        java.awt.Shape outline = shape.getOutline();\r
-\r
-        //flip vertical\r
-        if(shape.getFlipVertical()){\r
-            graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());\r
-            graphics.scale(1, -1);\r
-            graphics.translate(-anchor.getX(), -anchor.getY());\r
-        }\r
-        //flip horizontal\r
-        if(shape.getFlipHorizontal()){\r
-            graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());\r
-            graphics.scale(-1, 1);\r
-            graphics.translate(-anchor.getX() , -anchor.getY());\r
-        }\r
-\r
-        //rotate transform\r
-        double angle = shape.getRotation();\r
-\r
-        if(angle != 0){\r
-            double centerX = anchor.getX() + anchor.getWidth()/2;\r
-            double centerY = anchor.getY() + anchor.getHeight()/2;\r
-\r
-            graphics.translate(centerX, centerY);\r
-            graphics.rotate(Math.toRadians(angle));\r
-            graphics.translate(-centerX, -centerY);\r
-        }\r
-\r
-        //fill\r
-        Color fillColor = shape.getFill().getForegroundColor();\r
-        if (fillColor != null) {\r
-            //TODO: implement gradient and texture fill patterns\r
-            graphics.setPaint(fillColor);\r
-            graphics.fill(outline);\r
-        }\r
-\r
-        //border\r
-        Color lineColor = shape.getLineColor();\r
-        if (lineColor != null){\r
-            graphics.setPaint(lineColor);\r
-            float width = (float)shape.getLineWidth();\r
-            if(width == 0) width = 0.75f;\r
-\r
-            int dashing = shape.getLineDashing();\r
-            //TODO: implement more dashing styles\r
-            float[] dashptrn = null;\r
-            switch(dashing){\r
-                case Line.PEN_SOLID:\r
-                    dashptrn = null;\r
-                    break;\r
-                case Line.PEN_PS_DASH:\r
-                    dashptrn = new float[]{width, width};\r
-                    break;\r
-                case Line.PEN_DOTGEL:\r
-                    dashptrn = new float[]{width*4, width*3};\r
-                    break;\r
-               default:\r
-                    logger.log(POILogger.WARN, "unsupported dashing: " + dashing);\r
-                    dashptrn = new float[]{width, width};\r
-                    break;\r
-            }\r
-\r
-            Stroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashptrn, 0.0f);\r
-            graphics.setStroke(stroke);\r
-            graphics.draw(outline);\r
-        }\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
+
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Paint a shape into java.awt.Graphics2D
+ *
+ * @author Yegor Kozlov
+ */
+public final class ShapePainter {
+    protected static POILogger logger = POILogFactory.getLogger(ShapePainter.class);
+
+    public static void paint(SimpleShape shape, Graphics2D graphics){
+        Rectangle2D anchor = shape.getLogicalAnchor2D();
+        java.awt.Shape outline = shape.getOutline();
+
+        //flip vertical
+        if(shape.getFlipVertical()){
+            graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
+            graphics.scale(1, -1);
+            graphics.translate(-anchor.getX(), -anchor.getY());
+        }
+        //flip horizontal
+        if(shape.getFlipHorizontal()){
+            graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
+            graphics.scale(-1, 1);
+            graphics.translate(-anchor.getX() , -anchor.getY());
+        }
+
+        //rotate transform
+        double angle = shape.getRotation();
+
+        if(angle != 0){
+            double centerX = anchor.getX() + anchor.getWidth()/2;
+            double centerY = anchor.getY() + anchor.getHeight()/2;
+
+            graphics.translate(centerX, centerY);
+            graphics.rotate(Math.toRadians(angle));
+            graphics.translate(-centerX, -centerY);
+        }
+
+        //fill
+        Color fillColor = shape.getFill().getForegroundColor();
+        if (fillColor != null) {
+            //TODO: implement gradient and texture fill patterns
+            graphics.setPaint(fillColor);
+            graphics.fill(outline);
+        }
+
+        //border
+        Color lineColor = shape.getLineColor();
+        if (lineColor != null){
+            graphics.setPaint(lineColor);
+            float width = (float)shape.getLineWidth();
+            if(width == 0) width = 0.75f;
+
+            int dashing = shape.getLineDashing();
+            //TODO: implement more dashing styles
+            float[] dashptrn = null;
+            switch(dashing){
+                case Line.PEN_SOLID:
+                    dashptrn = null;
+                    break;
+                case Line.PEN_PS_DASH:
+                    dashptrn = new float[]{width, width};
+                    break;
+                case Line.PEN_DOTGEL:
+                    dashptrn = new float[]{width*4, width*3};
+                    break;
+               default:
+                    logger.log(POILogger.WARN, "unsupported dashing: " + dashing);
+                    dashptrn = new float[]{width, width};
+                    break;
+            }
+
+            Stroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashptrn, 0.0f);
+            graphics.setStroke(stroke);
+            graphics.draw(outline);
+        }
+    }
+}
index fea017a08e5303aa2d922ee120e02a4e3aa757dd..8f786e61fde0de1ca3a6fe4eb8b46eb9d2170896 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.hslf.exceptions.HSLFException;
@@ -26,7 +27,7 @@ import java.lang.reflect.Field;
  *
  * @author Yegor Kozlov
  */
-public class ShapeTypes implements org.apache.poi.sl.usermodel.ShapeTypes {
+public final class ShapeTypes implements org.apache.poi.sl.usermodel.ShapeTypes {
     /**
      * Return name of the shape by id
      * @param type  - the id of the shape, one of the static constants defined in this class
index 26597118b8d9c903c6ba1ba22e8c6460ab11a800..6ce6368e5141c415417f158bf200d70b7784c22e 100644 (file)
@@ -15,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
@@ -190,7 +189,7 @@ public abstract class Sheet {
                     lst.toArray(recs);
                     trun._records = recs;
                     trun.setIndex(slwtIndex);
-                    
+
                     found.add(trun);
                     i++;
                 } else {
@@ -379,7 +378,7 @@ public abstract class Sheet {
      * @param shape
      */
     protected void onAddTextShape(TextShape shape) {
-    
+
     }
 
     /**
index cb32e69c2bba5d4ac16413977b0f117f0ed95426..13a2835b2227a0f43f21cfa32a6ef466d677f4ee 100644 (file)
@@ -38,7 +38,7 @@ import org.apache.poi.util.LittleEndian;
  *
  *  @author Yegor Kozlov
  */
-public class SimpleShape extends Shape {
+public abstract class SimpleShape extends Shape {
 
     /**
      * Records stored in EscherClientDataRecord
index bb2e8fc79f9d4246eb49e4835b86b8f0e7eca282..d01ac302d72fe55287177e6362a8630b3a015fee 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.model;
 
@@ -32,7 +29,7 @@ import org.apache.poi.ddf.EscherDgRecord;
 import org.apache.poi.ddf.EscherSpRecord;
 
 /**
- * This class represents a slide in a PowerPoint Document. It allows 
+ * This class represents a slide in a PowerPoint Document. It allows
  *  access to the text within, and the layout. For now, it only does
  *  the text side of things though
  *
@@ -40,7 +37,7 @@ import org.apache.poi.ddf.EscherSpRecord;
  * @author Yegor Kozlov
  */
 
-public class Slide extends Sheet
+public final class Slide extends Sheet
 {
        private int _slideNo;
        private SlideAtomsSet _atomSet;
@@ -90,7 +87,7 @@ public class Slide extends Sheet
             _runs[i].setSheet(this);
                }
        }
-  
+
        /**
        * Create a new Slide instance
        * @param sheetNumber The internal number of the sheet, as used by PersistPtrHolder
@@ -120,7 +117,7 @@ public class Slide extends Sheet
                        sa.setNotesID(notes._getSheetNumber());
                }
        }
-  
+
        /**
        * Changes the Slide's (external facing) page number.
        * @see org.apache.poi.hslf.usermodel.SlideShow#reorderSlide(int, int)
@@ -128,7 +125,7 @@ public class Slide extends Sheet
        public void setSlideNumber(int newSlideNumber) {
                _slideNo = newSlideNumber;
        }
-  
+
     /**
      * Called by SlideShow ater a new slide is created.
      * <p>
@@ -162,7 +159,7 @@ public class Slide extends Sheet
             if(spr != null) spr.setShapeId(allocateShapeId());
         }
 
-        //PPT doen't increment the number of saved shapes for group descriptor and background 
+        //PPT doen't increment the number of saved shapes for group descriptor and background
         dg.setNumShapes(1);
     }
 
@@ -207,7 +204,7 @@ public class Slide extends Sheet
                }
                return null;
        }
-  
+
        // Simple Accesser methods follow
 
        /**
@@ -361,10 +358,10 @@ public class Slide extends Sheet
         }
         return super.getColorScheme();
     }
-    
+
     /**
      * Get the comment(s) for this slide.
-     * Note - for now, only works on PPT 2000 and 
+     * Note - for now, only works on PPT 2000 and
      *  PPT 2003 files. Doesn't work for PPT 97
      *  ones, as they do their comments oddly.
      */
@@ -393,7 +390,7 @@ public class Slide extends Sheet
                                                count++;
                                        }
                                }
-                               
+
                                // Now build
                                Comment[] comments = new Comment[count];
                                count = 0;
@@ -405,12 +402,12 @@ public class Slide extends Sheet
                                                count++;
                                        }
                                }
-                               
+
                                return comments;
                        }
                }
        }
-       
+
        // None found
        return new Comment[0];
     }
@@ -433,7 +430,7 @@ public class Slide extends Sheet
     }
 
     /**
-     * Header / Footer settings for this slide.  
+     * Header / Footer settings for this slide.
      *
      * @return Header / Footer settings for this slide
      */
index b30a46e38a7dc317fc481ca92cd106621b12e2c7..a72e4658b7a2bca539d799751c8513584f45a641 100644 (file)
@@ -29,7 +29,7 @@ import org.apache.poi.hslf.usermodel.SlideShow;
  *
  * @author Yegor Kozlov
  */
-public class SlideMaster extends MasterSheet {
+public final class SlideMaster extends MasterSheet {
     private TextRun[] _runs;
 
     /**
@@ -64,7 +64,7 @@ public class SlideMaster extends MasterSheet {
 
     /**
      * Pickup a style attribute from the master.
-     * This is the "workhorse" which returns the default style attrubutes. 
+     * This is the "workhorse" which returns the default style attrubutes.
      */
     public TextProp getStyleAttribute(int txtype, int level, String name, boolean isCharacter) {
 
@@ -111,7 +111,7 @@ public class SlideMaster extends MasterSheet {
     /**
      * Assign SlideShow for this slide master.
      * (Used interanlly)
-     */ 
+     */
     public void setSlideShow(SlideShow ss) {
         super.setSlideShow(ss);
 
index 907bce377355eb062e1723d78af08422d53c975a..b8d9f623b46b0cfd33b70ffaa27221a7f0620a9e 100755 (executable)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.ddf.*;\r
-import org.apache.poi.util.LittleEndian;\r
-\r
-import java.util.*;\r
-import java.util.List;\r
-import java.awt.*;\r
-\r
-/**\r
- * Represents a table in a PowerPoint presentation\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class Table extends ShapeGroup {\r
-\r
-    protected static final int BORDER_TOP = 1;\r
-    protected static final int BORDER_RIGHT = 2;\r
-    protected static final int BORDER_BOTTOM = 3;\r
-    protected static final int BORDER_LEFT = 4;\r
-\r
-    protected static final int BORDERS_ALL = 5;\r
-    protected static final int BORDERS_OUTSIDE = 6;\r
-    protected static final int BORDERS_INSIDE = 7;\r
-    protected static final int BORDERS_NONE = 8;\r
-\r
-\r
-    protected TableCell[][] cells;\r
-\r
-    /**\r
-     * Create a new Table of the given number of rows and columns\r
-     *\r
-     * @param numrows the number of rows\r
-     * @param numcols the number of columns\r
-     */\r
-    public Table(int numrows, int numcols) {\r
-        super();\r
-\r
-        if(numrows < 1) throw new IllegalArgumentException("The number of rows must be greater than 1");\r
-        if(numcols < 1) throw new IllegalArgumentException("The number of columns must be greater than 1");\r
-\r
-        int x=0, y=0, tblWidth=0, tblHeight=0;\r
-        cells = new TableCell[numrows][numcols];\r
-        for (int i = 0; i < cells.length; i++) {\r
-            x = 0;\r
-            for (int j = 0; j < cells[i].length; j++) {\r
-                cells[i][j] = new TableCell(this);\r
-                Rectangle anchor = new Rectangle(x, y, TableCell.DEFAULT_WIDTH, TableCell.DEFAULT_HEIGHT);\r
-                cells[i][j].setAnchor(anchor);\r
-                x += TableCell.DEFAULT_WIDTH;\r
-            }\r
-            y += TableCell.DEFAULT_HEIGHT;\r
-        }\r
-        tblWidth = x;\r
-        tblHeight = y;\r
-        setAnchor(new Rectangle(0, 0, tblWidth, tblHeight));\r
-\r
-        EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);\r
-        EscherOptRecord opt = new EscherOptRecord();\r
-        opt.setRecordId((short)0xF122);\r
-        opt.addEscherProperty(new EscherSimpleProperty((short)0x39F, 1));\r
-        EscherArrayProperty p = new EscherArrayProperty((short)0x43A0, false, null);\r
-        p.setSizeOfElements(0x0004);\r
-        p.setNumberOfElementsInArray(numrows);\r
-        p.setNumberOfElementsInMemory(numrows);\r
-        opt.addEscherProperty(p);\r
-        List<EscherRecord> lst = spCont.getChildRecords();\r
-        lst.add(lst.size()-1, opt);\r
-        spCont.setChildRecords(lst);\r
-    }\r
-\r
-    /**\r
-     * Create a Table object and initilize it from the supplied Record container.\r
-     *\r
-     * @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape\r
-     * @param parent       the parent of the shape\r
-     */\r
-    public Table(EscherContainerRecord escherRecord, Shape parent) {\r
-        super(escherRecord, parent);\r
-    }\r
-\r
-    /**\r
-     * Gets a cell\r
-     *\r
-     * @param row the row index (0-based)\r
-     * @param col the column index (0-based)\r
-     * @return the cell\r
-     */\r
-    public TableCell getCell(int row, int col) {\r
-        return cells[row][col];\r
-    }\r
-\r
-    public int getNumberOfColumns() {\r
-        return cells[0].length;\r
-    }\r
-    public int getNumberOfRows() {\r
-        return cells.length;\r
-    }\r
-\r
-    protected void afterInsert(Sheet sh){\r
-        super.afterInsert(sh);\r
-\r
-        EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);\r
-        List<EscherRecord> lst = spCont.getChildRecords();\r
-        EscherOptRecord opt = (EscherOptRecord)lst.get(lst.size()-2);\r
-        EscherArrayProperty p = (EscherArrayProperty)opt.getEscherProperty(1);\r
-        for (int i = 0; i < cells.length; i++) {\r
-            TableCell cell = cells[i][0];\r
-            int rowHeight = cell.getAnchor().height*MASTER_DPI/POINT_DPI;\r
-            byte[] val = new byte[4];\r
-            LittleEndian.putInt(val, rowHeight);\r
-            p.setElement(i, val);\r
-            for (int j = 0; j < cells[i].length; j++) {\r
-                TableCell c = cells[i][j];\r
-                addShape(c);\r
-\r
-                Line bt = c.getBorderTop();\r
-                if(bt != null) addShape(bt);\r
-\r
-                Line br = c.getBorderRight();\r
-                if(br != null) addShape(br);\r
-\r
-                Line bb = c.getBorderBottom();\r
-                if(bb != null) addShape(bb);\r
-\r
-                Line bl = c.getBorderLeft();\r
-                if(bl != null) addShape(bl);\r
-\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    protected void initTable(){\r
-        Shape[] sh = getShapes();\r
-        Arrays.sort(sh, new Comparator(){\r
-            public int compare( Object o1, Object o2 ) {\r
-                Rectangle anchor1 = ((Shape)o1).getAnchor();\r
-                Rectangle anchor2 = ((Shape)o2).getAnchor();\r
-                int delta = anchor1.y - anchor2.y;\r
-                if(delta == 0) delta = anchor1.x - anchor2.y;\r
-                return delta;\r
-            }\r
-        });\r
-        int y0 = -1;\r
-        int maxrowlen = 0;\r
-        ArrayList lst = new ArrayList();\r
-        ArrayList row = null;\r
-        for (int i = 0; i < sh.length; i++) {\r
-            if(sh[i] instanceof TextShape){\r
-                Rectangle anchor = sh[i].getAnchor();\r
-                if(anchor.y != y0){\r
-                    y0 = anchor.y;\r
-                    row = new ArrayList();\r
-                    lst.add(row);\r
-                }\r
-                row.add(sh[i]);\r
-                maxrowlen = Math.max(maxrowlen, row.size());\r
-            }\r
-        }\r
-        cells = new TableCell[lst.size()][maxrowlen];\r
-        for (int i = 0; i < lst.size(); i++) {\r
-            row = (ArrayList)lst.get(i);\r
-            for (int j = 0; j < row.size(); j++) {\r
-                TextShape tx = (TextShape)row.get(j);\r
-                cells[i][j] = new TableCell(tx.getSpContainer(), getParent());\r
-                cells[i][j].setSheet(tx.getSheet());\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Assign the <code>SlideShow</code> this shape belongs to\r
-     *\r
-     * @param sheet owner of this shape\r
-     */\r
-    public void setSheet(Sheet sheet){\r
-        super.setSheet(sheet);\r
-        if(cells == null) initTable();\r
-    }\r
-\r
-    /**\r
-     * Sets the row height.\r
-     *\r
-     * @param row the row index (0-based)\r
-     * @param height the height to set (in pixels)\r
-     */\r
-    public void setRowHeight(int row, int height){\r
-        int currentHeight = cells[row][0].getAnchor().height;\r
-        int dy = height - currentHeight;\r
-\r
-        for (int i = row; i < cells.length; i++) {\r
-            for (int j = 0; j < cells[i].length; j++) {\r
-                Rectangle anchor = cells[i][j].getAnchor();\r
-                if(i == row) anchor.height = height;\r
-                else anchor.y += dy;\r
-                cells[i][j].setAnchor(anchor);\r
-            }\r
-        }\r
-        Rectangle tblanchor = getAnchor();\r
-        tblanchor.height += dy;\r
-        setAnchor(tblanchor);\r
-\r
-    }\r
-\r
-    /**\r
-     * Sets the column width.\r
-     *\r
-     * @param col the column index (0-based)\r
-     * @param width the width to set (in pixels)\r
-     */\r
-    public void setColumnWidth(int col, int width){\r
-        int currentWidth = cells[0][col].getAnchor().width;\r
-        int dx = width - currentWidth;\r
-        for (int i = 0; i < cells.length; i++) {\r
-            Rectangle anchor = cells[i][col].getAnchor();\r
-            anchor.width = width;\r
-            cells[i][col].setAnchor(anchor);\r
-\r
-            if(col < cells[i].length - 1) for (int j = col+1; j < cells[i].length; j++) {\r
-                anchor = cells[i][j].getAnchor();\r
-                anchor.x += dx;\r
-                cells[i][j].setAnchor(anchor);\r
-            }\r
-        }\r
-        Rectangle tblanchor = getAnchor();\r
-        tblanchor.width += dx;\r
-        setAnchor(tblanchor);\r
-    }\r
-\r
-    /**\r
-     * Format the table and apply the specified Line to all cell boundaries,\r
-     * both outside and inside\r
-     *\r
-     * @param line the border line\r
-     */\r
-    public void setAllBorders(Line line){\r
-        for (int i = 0; i < cells.length; i++) {\r
-            for (int j = 0; j < cells[i].length; j++) {\r
-                TableCell cell = cells[i][j];\r
-                cell.setBorderTop(cloneBorder(line));\r
-                cell.setBorderLeft(cloneBorder(line));\r
-                if(j == cells[i].length - 1) cell.setBorderRight(cloneBorder(line));\r
-                if(i == cells.length - 1) cell.setBorderBottom(cloneBorder(line));\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Format the outside border using the specified Line object\r
-     *\r
-     * @param line the border line\r
-     */\r
-    public void setOutsideBorders(Line line){\r
-        for (int i = 0; i < cells.length; i++) {\r
-            for (int j = 0; j < cells[i].length; j++) {\r
-                TableCell cell = cells[i][j];\r
-\r
-                if(j == 0) cell.setBorderLeft(cloneBorder(line));\r
-                if(j == cells[i].length - 1) cell.setBorderRight(cloneBorder(line));\r
-                else {\r
-                    cell.setBorderLeft(null);\r
-                    cell.setBorderLeft(null);\r
-                }\r
-\r
-                if(i == 0) cell.setBorderTop(cloneBorder(line));\r
-                else if(i == cells.length - 1) cell.setBorderBottom(cloneBorder(line));\r
-                else {\r
-                    cell.setBorderTop(null);\r
-                    cell.setBorderBottom(null);\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Format the inside border using the specified Line object\r
-     *\r
-     * @param line the border line\r
-     */\r
-    public void setInsideBorders(Line line){\r
-        for (int i = 0; i < cells.length; i++) {\r
-            for (int j = 0; j < cells[i].length; j++) {\r
-                TableCell cell = cells[i][j];\r
-\r
-                if(j != cells[i].length - 1)\r
-                    cell.setBorderRight(cloneBorder(line));\r
-                else {\r
-                    cell.setBorderLeft(null);\r
-                    cell.setBorderLeft(null);\r
-                }\r
-                if(i != cells.length - 1) cell.setBorderBottom(cloneBorder(line));\r
-                else {\r
-                    cell.setBorderTop(null);\r
-                    cell.setBorderBottom(null);\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private Line cloneBorder(Line line){\r
-        Line border = createBorder();\r
-        border.setLineWidth(line.getLineWidth());\r
-        border.setLineStyle(line.getLineStyle());\r
-        border.setLineDashing(line.getLineDashing());\r
-        border.setLineColor(line.getLineColor());\r
-        return border;\r
-    }\r
-\r
-    /**\r
-     * Create a border to format this table\r
-     *\r
-     * @return the created border\r
-     */\r
-    public Line createBorder(){\r
-        Line line = new Line(this);\r
-\r
-        EscherOptRecord opt = (EscherOptRecord)getEscherChild(line.getSpContainer(), EscherOptRecord.RECORD_ID);\r
-        setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, -1);\r
-        setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, -1);\r
-        setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000);\r
-        setEscherProperty(opt, EscherProperties.THREED__LIGHTFACE, 0x80000);\r
-\r
-        return line;\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import org.apache.poi.ddf.*;
+import org.apache.poi.util.LittleEndian;
+
+import java.util.*;
+import java.util.List;
+import java.awt.*;
+
+/**
+ * Represents a table in a PowerPoint presentation
+ *
+ * @author Yegor Kozlov
+ */
+public final class Table extends ShapeGroup {
+
+    protected static final int BORDER_TOP = 1;
+    protected static final int BORDER_RIGHT = 2;
+    protected static final int BORDER_BOTTOM = 3;
+    protected static final int BORDER_LEFT = 4;
+
+    protected static final int BORDERS_ALL = 5;
+    protected static final int BORDERS_OUTSIDE = 6;
+    protected static final int BORDERS_INSIDE = 7;
+    protected static final int BORDERS_NONE = 8;
+
+
+    protected TableCell[][] cells;
+
+    /**
+     * Create a new Table of the given number of rows and columns
+     *
+     * @param numrows the number of rows
+     * @param numcols the number of columns
+     */
+    public Table(int numrows, int numcols) {
+        super();
+
+        if(numrows < 1) throw new IllegalArgumentException("The number of rows must be greater than 1");
+        if(numcols < 1) throw new IllegalArgumentException("The number of columns must be greater than 1");
+
+        int x=0, y=0, tblWidth=0, tblHeight=0;
+        cells = new TableCell[numrows][numcols];
+        for (int i = 0; i < cells.length; i++) {
+            x = 0;
+            for (int j = 0; j < cells[i].length; j++) {
+                cells[i][j] = new TableCell(this);
+                Rectangle anchor = new Rectangle(x, y, TableCell.DEFAULT_WIDTH, TableCell.DEFAULT_HEIGHT);
+                cells[i][j].setAnchor(anchor);
+                x += TableCell.DEFAULT_WIDTH;
+            }
+            y += TableCell.DEFAULT_HEIGHT;
+        }
+        tblWidth = x;
+        tblHeight = y;
+        setAnchor(new Rectangle(0, 0, tblWidth, tblHeight));
+
+        EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
+        EscherOptRecord opt = new EscherOptRecord();
+        opt.setRecordId((short)0xF122);
+        opt.addEscherProperty(new EscherSimpleProperty((short)0x39F, 1));
+        EscherArrayProperty p = new EscherArrayProperty((short)0x43A0, false, null);
+        p.setSizeOfElements(0x0004);
+        p.setNumberOfElementsInArray(numrows);
+        p.setNumberOfElementsInMemory(numrows);
+        opt.addEscherProperty(p);
+        List<EscherRecord> lst = spCont.getChildRecords();
+        lst.add(lst.size()-1, opt);
+        spCont.setChildRecords(lst);
+    }
+
+    /**
+     * Create a Table object and initilize 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
+     */
+    public Table(EscherContainerRecord escherRecord, Shape parent) {
+        super(escherRecord, parent);
+    }
+
+    /**
+     * Gets a cell
+     *
+     * @param row the row index (0-based)
+     * @param col the column index (0-based)
+     * @return the cell
+     */
+    public TableCell getCell(int row, int col) {
+        return cells[row][col];
+    }
+
+    public int getNumberOfColumns() {
+        return cells[0].length;
+    }
+    public int getNumberOfRows() {
+        return cells.length;
+    }
+
+    protected void afterInsert(Sheet sh){
+        super.afterInsert(sh);
+
+        EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
+        List<EscherRecord> lst = spCont.getChildRecords();
+        EscherOptRecord opt = (EscherOptRecord)lst.get(lst.size()-2);
+        EscherArrayProperty p = (EscherArrayProperty)opt.getEscherProperty(1);
+        for (int i = 0; i < cells.length; i++) {
+            TableCell cell = cells[i][0];
+            int rowHeight = cell.getAnchor().height*MASTER_DPI/POINT_DPI;
+            byte[] val = new byte[4];
+            LittleEndian.putInt(val, rowHeight);
+            p.setElement(i, val);
+            for (int j = 0; j < cells[i].length; j++) {
+                TableCell c = cells[i][j];
+                addShape(c);
+
+                Line bt = c.getBorderTop();
+                if(bt != null) addShape(bt);
+
+                Line br = c.getBorderRight();
+                if(br != null) addShape(br);
+
+                Line bb = c.getBorderBottom();
+                if(bb != null) addShape(bb);
+
+                Line bl = c.getBorderLeft();
+                if(bl != null) addShape(bl);
+
+            }
+        }
+
+    }
+
+    protected void initTable(){
+        Shape[] sh = getShapes();
+        Arrays.sort(sh, new Comparator(){
+            public int compare( Object o1, Object o2 ) {
+                Rectangle anchor1 = ((Shape)o1).getAnchor();
+                Rectangle anchor2 = ((Shape)o2).getAnchor();
+                int delta = anchor1.y - anchor2.y;
+                if(delta == 0) delta = anchor1.x - anchor2.y;
+                return delta;
+            }
+        });
+        int y0 = -1;
+        int maxrowlen = 0;
+        ArrayList lst = new ArrayList();
+        ArrayList row = null;
+        for (int i = 0; i < sh.length; i++) {
+            if(sh[i] instanceof TextShape){
+                Rectangle anchor = sh[i].getAnchor();
+                if(anchor.y != y0){
+                    y0 = anchor.y;
+                    row = new ArrayList();
+                    lst.add(row);
+                }
+                row.add(sh[i]);
+                maxrowlen = Math.max(maxrowlen, row.size());
+            }
+        }
+        cells = new TableCell[lst.size()][maxrowlen];
+        for (int i = 0; i < lst.size(); i++) {
+            row = (ArrayList)lst.get(i);
+            for (int j = 0; j < row.size(); j++) {
+                TextShape tx = (TextShape)row.get(j);
+                cells[i][j] = new TableCell(tx.getSpContainer(), getParent());
+                cells[i][j].setSheet(tx.getSheet());
+            }
+        }
+    }
+
+    /**
+     * Assign the <code>SlideShow</code> this shape belongs to
+     *
+     * @param sheet owner of this shape
+     */
+    public void setSheet(Sheet sheet){
+        super.setSheet(sheet);
+        if(cells == null) initTable();
+    }
+
+    /**
+     * Sets the row height.
+     *
+     * @param row the row index (0-based)
+     * @param height the height to set (in pixels)
+     */
+    public void setRowHeight(int row, int height){
+        int currentHeight = cells[row][0].getAnchor().height;
+        int dy = height - currentHeight;
+
+        for (int i = row; i < cells.length; i++) {
+            for (int j = 0; j < cells[i].length; j++) {
+                Rectangle anchor = cells[i][j].getAnchor();
+                if(i == row) anchor.height = height;
+                else anchor.y += dy;
+                cells[i][j].setAnchor(anchor);
+            }
+        }
+        Rectangle tblanchor = getAnchor();
+        tblanchor.height += dy;
+        setAnchor(tblanchor);
+
+    }
+
+    /**
+     * Sets the column width.
+     *
+     * @param col the column index (0-based)
+     * @param width the width to set (in pixels)
+     */
+    public void setColumnWidth(int col, int width){
+        int currentWidth = cells[0][col].getAnchor().width;
+        int dx = width - currentWidth;
+        for (int i = 0; i < cells.length; i++) {
+            Rectangle anchor = cells[i][col].getAnchor();
+            anchor.width = width;
+            cells[i][col].setAnchor(anchor);
+
+            if(col < cells[i].length - 1) for (int j = col+1; j < cells[i].length; j++) {
+                anchor = cells[i][j].getAnchor();
+                anchor.x += dx;
+                cells[i][j].setAnchor(anchor);
+            }
+        }
+        Rectangle tblanchor = getAnchor();
+        tblanchor.width += dx;
+        setAnchor(tblanchor);
+    }
+
+    /**
+     * Format the table and apply the specified Line to all cell boundaries,
+     * both outside and inside
+     *
+     * @param line the border line
+     */
+    public void setAllBorders(Line line){
+        for (int i = 0; i < cells.length; i++) {
+            for (int j = 0; j < cells[i].length; j++) {
+                TableCell cell = cells[i][j];
+                cell.setBorderTop(cloneBorder(line));
+                cell.setBorderLeft(cloneBorder(line));
+                if(j == cells[i].length - 1) cell.setBorderRight(cloneBorder(line));
+                if(i == cells.length - 1) cell.setBorderBottom(cloneBorder(line));
+            }
+        }
+    }
+
+    /**
+     * Format the outside border using the specified Line object
+     *
+     * @param line the border line
+     */
+    public void setOutsideBorders(Line line){
+        for (int i = 0; i < cells.length; i++) {
+            for (int j = 0; j < cells[i].length; j++) {
+                TableCell cell = cells[i][j];
+
+                if(j == 0) cell.setBorderLeft(cloneBorder(line));
+                if(j == cells[i].length - 1) cell.setBorderRight(cloneBorder(line));
+                else {
+                    cell.setBorderLeft(null);
+                    cell.setBorderLeft(null);
+                }
+
+                if(i == 0) cell.setBorderTop(cloneBorder(line));
+                else if(i == cells.length - 1) cell.setBorderBottom(cloneBorder(line));
+                else {
+                    cell.setBorderTop(null);
+                    cell.setBorderBottom(null);
+                }
+            }
+        }
+    }
+
+    /**
+     * Format the inside border using the specified Line object
+     *
+     * @param line the border line
+     */
+    public void setInsideBorders(Line line){
+        for (int i = 0; i < cells.length; i++) {
+            for (int j = 0; j < cells[i].length; j++) {
+                TableCell cell = cells[i][j];
+
+                if(j != cells[i].length - 1)
+                    cell.setBorderRight(cloneBorder(line));
+                else {
+                    cell.setBorderLeft(null);
+                    cell.setBorderLeft(null);
+                }
+                if(i != cells.length - 1) cell.setBorderBottom(cloneBorder(line));
+                else {
+                    cell.setBorderTop(null);
+                    cell.setBorderBottom(null);
+                }
+            }
+        }
+    }
+
+    private Line cloneBorder(Line line){
+        Line border = createBorder();
+        border.setLineWidth(line.getLineWidth());
+        border.setLineStyle(line.getLineStyle());
+        border.setLineDashing(line.getLineDashing());
+        border.setLineColor(line.getLineColor());
+        return border;
+    }
+
+    /**
+     * Create a border to format this table
+     *
+     * @return the created border
+     */
+    public Line createBorder(){
+        Line line = new Line(this);
+
+        EscherOptRecord opt = (EscherOptRecord)getEscherChild(line.getSpContainer(), EscherOptRecord.RECORD_ID);
+        setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, -1);
+        setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, -1);
+        setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000);
+        setEscherProperty(opt, EscherProperties.THREED__LIGHTFACE, 0x80000);
+
+        return line;
+    }
+}
index 71833678a51a7daf8d78a563811f49e2fac862e7..d8198283bdd634bfa98bb6cd754c114030abc9ed 100755 (executable)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.ddf.*;\r
-import org.apache.poi.hslf.record.TextHeaderAtom;\r
-\r
-import java.awt.*;\r
-\r
-/**\r
- * Represents a cell in a ppt table\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class TableCell extends TextBox {\r
-    protected static final int DEFAULT_WIDTH = 100;\r
-    protected static final int DEFAULT_HEIGHT = 40;\r
-\r
-    private Line borderLeft;\r
-    private Line borderRight;\r
-    private Line borderTop;\r
-    private Line borderBottom;\r
-\r
-    /**\r
-     * Create a TableCell object and initialize it from the supplied Record container.\r
-     *\r
-     * @param escherRecord       <code>EscherSpContainer</code> container which holds information about this shape\r
-     * @param parent    the parent of the shape\r
-     */\r
-   protected TableCell(EscherContainerRecord escherRecord, Shape parent){\r
-        super(escherRecord, parent);\r
-    }\r
-\r
-    /**\r
-     * Create a new TableCell. This constructor is used when a new shape is created.\r
-     *\r
-     * @param parent    the parent of this Shape. For example, if this text box is a cell\r
-     * in a table then the parent is Table.\r
-     */\r
-    public TableCell(Shape parent){\r
-        super(parent);\r
-\r
-        setShapeType(ShapeTypes.Rectangle);\r
-        //_txtrun.setRunType(TextHeaderAtom.HALF_BODY_TYPE);\r
-        //_txtrun.getRichTextRuns()[0].setFlag(false, 0, false);\r
-    }\r
-\r
-    protected EscherContainerRecord createSpContainer(boolean isChild){\r
-        _escherContainer = super.createSpContainer(isChild);\r
-        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);\r
-        setEscherProperty(opt, EscherProperties.TEXT__TEXTID, 0);\r
-        setEscherProperty(opt, EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20000);\r
-        setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150001);\r
-        setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000);\r
-        setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x40000);\r
-\r
-        return _escherContainer;\r
-    }\r
-\r
-    protected void anchorBorder(int type, Line line){\r
-        Rectangle cellAnchor = getAnchor();\r
-        Rectangle lineAnchor = new Rectangle();\r
-        switch(type){\r
-            case Table.BORDER_TOP:\r
-                lineAnchor.x = cellAnchor.x;\r
-                lineAnchor.y = cellAnchor.y;\r
-                lineAnchor.width = cellAnchor.width;\r
-                lineAnchor.height = 0;\r
-                break;\r
-            case Table.BORDER_RIGHT:\r
-                lineAnchor.x = cellAnchor.x + cellAnchor.width;\r
-                lineAnchor.y = cellAnchor.y;\r
-                lineAnchor.width = 0;\r
-                lineAnchor.height = cellAnchor.height;\r
-                break;\r
-            case Table.BORDER_BOTTOM:\r
-                lineAnchor.x = cellAnchor.x;\r
-                lineAnchor.y = cellAnchor.y + cellAnchor.height;\r
-                lineAnchor.width = cellAnchor.width;\r
-                lineAnchor.height = 0;\r
-                break;\r
-            case Table.BORDER_LEFT:\r
-                lineAnchor.x = cellAnchor.x;\r
-                lineAnchor.y = cellAnchor.y;\r
-                lineAnchor.width = 0;\r
-                lineAnchor.height = cellAnchor.height;\r
-                break;\r
-            default:\r
-                throw new IllegalArgumentException("Unknown border type: " + type);\r
-        }\r
-        line.setAnchor(lineAnchor);\r
-    }\r
-\r
-    public Line getBorderLeft() {\r
-        return borderLeft;\r
-    }\r
-\r
-    public void setBorderLeft(Line line) {\r
-        if(line != null) anchorBorder(Table.BORDER_LEFT, line);\r
-        this.borderLeft = line;\r
-    }\r
-\r
-    public Line getBorderRight() {\r
-        return borderRight;\r
-    }\r
-\r
-    public void setBorderRight(Line line) {\r
-        if(line != null) anchorBorder(Table.BORDER_RIGHT, line);\r
-        this.borderRight = line;\r
-    }\r
-\r
-    public Line getBorderTop() {\r
-        return borderTop;\r
-    }\r
-\r
-    public void setBorderTop(Line line) {\r
-        if(line != null) anchorBorder(Table.BORDER_TOP, line);\r
-        this.borderTop = line;\r
-    }\r
-\r
-    public Line getBorderBottom() {\r
-        return borderBottom;\r
-    }\r
-\r
-    public void setBorderBottom(Line line) {\r
-        if(line != null) anchorBorder(Table.BORDER_BOTTOM, line);\r
-        this.borderBottom = line;\r
-    }\r
-\r
-    public void setAnchor(Rectangle anchor){\r
-        super.setAnchor(anchor);\r
-\r
-        if(borderTop != null) anchorBorder(Table.BORDER_TOP, borderTop);\r
-        if(borderRight != null) anchorBorder(Table.BORDER_RIGHT, borderRight);\r
-        if(borderBottom != null) anchorBorder(Table.BORDER_BOTTOM, borderBottom);\r
-        if(borderLeft != null) anchorBorder(Table.BORDER_LEFT, borderLeft);\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import org.apache.poi.ddf.*;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+
+import java.awt.*;
+
+/**
+ * Represents a cell in a ppt table
+ *
+ * @author Yegor Kozlov
+ */
+public final class TableCell extends TextBox {
+    protected static final int DEFAULT_WIDTH = 100;
+    protected static final int DEFAULT_HEIGHT = 40;
+
+    private Line borderLeft;
+    private Line borderRight;
+    private Line borderTop;
+    private Line borderBottom;
+
+    /**
+     * Create a TableCell 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
+     */
+   protected TableCell(EscherContainerRecord escherRecord, Shape parent){
+        super(escherRecord, parent);
+    }
+
+    /**
+     * Create a new TableCell. This constructor is used when a new shape is created.
+     *
+     * @param parent    the parent of this Shape. For example, if this text box is a cell
+     * in a table then the parent is Table.
+     */
+    public TableCell(Shape parent){
+        super(parent);
+
+        setShapeType(ShapeTypes.Rectangle);
+        //_txtrun.setRunType(TextHeaderAtom.HALF_BODY_TYPE);
+        //_txtrun.getRichTextRuns()[0].setFlag(false, 0, false);
+    }
+
+    protected EscherContainerRecord createSpContainer(boolean isChild){
+        _escherContainer = super.createSpContainer(isChild);
+        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+        setEscherProperty(opt, EscherProperties.TEXT__TEXTID, 0);
+        setEscherProperty(opt, EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20000);
+        setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150001);
+        setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000);
+        setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x40000);
+
+        return _escherContainer;
+    }
+
+    protected void anchorBorder(int type, Line line){
+        Rectangle cellAnchor = getAnchor();
+        Rectangle lineAnchor = new Rectangle();
+        switch(type){
+            case Table.BORDER_TOP:
+                lineAnchor.x = cellAnchor.x;
+                lineAnchor.y = cellAnchor.y;
+                lineAnchor.width = cellAnchor.width;
+                lineAnchor.height = 0;
+                break;
+            case Table.BORDER_RIGHT:
+                lineAnchor.x = cellAnchor.x + cellAnchor.width;
+                lineAnchor.y = cellAnchor.y;
+                lineAnchor.width = 0;
+                lineAnchor.height = cellAnchor.height;
+                break;
+            case Table.BORDER_BOTTOM:
+                lineAnchor.x = cellAnchor.x;
+                lineAnchor.y = cellAnchor.y + cellAnchor.height;
+                lineAnchor.width = cellAnchor.width;
+                lineAnchor.height = 0;
+                break;
+            case Table.BORDER_LEFT:
+                lineAnchor.x = cellAnchor.x;
+                lineAnchor.y = cellAnchor.y;
+                lineAnchor.width = 0;
+                lineAnchor.height = cellAnchor.height;
+                break;
+            default:
+                throw new IllegalArgumentException("Unknown border type: " + type);
+        }
+        line.setAnchor(lineAnchor);
+    }
+
+    public Line getBorderLeft() {
+        return borderLeft;
+    }
+
+    public void setBorderLeft(Line line) {
+        if(line != null) anchorBorder(Table.BORDER_LEFT, line);
+        this.borderLeft = line;
+    }
+
+    public Line getBorderRight() {
+        return borderRight;
+    }
+
+    public void setBorderRight(Line line) {
+        if(line != null) anchorBorder(Table.BORDER_RIGHT, line);
+        this.borderRight = line;
+    }
+
+    public Line getBorderTop() {
+        return borderTop;
+    }
+
+    public void setBorderTop(Line line) {
+        if(line != null) anchorBorder(Table.BORDER_TOP, line);
+        this.borderTop = line;
+    }
+
+    public Line getBorderBottom() {
+        return borderBottom;
+    }
+
+    public void setBorderBottom(Line line) {
+        if(line != null) anchorBorder(Table.BORDER_BOTTOM, line);
+        this.borderBottom = line;
+    }
+
+    public void setAnchor(Rectangle anchor){
+        super.setAnchor(anchor);
+
+        if(borderTop != null) anchorBorder(Table.BORDER_TOP, borderTop);
+        if(borderRight != null) anchorBorder(Table.BORDER_RIGHT, borderRight);
+        if(borderBottom != null) anchorBorder(Table.BORDER_BOTTOM, borderBottom);
+        if(borderLeft != null) anchorBorder(Table.BORDER_LEFT, borderLeft);
+    }
+}
index dda55a2c7b197da6fd778ad125da32b836b49f01..46e080eb5d0c704c18dd873744d64ec795430f65 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
@@ -33,7 +32,7 @@ public class TextBox extends TextShape {
 
     /**
      * 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
      */
index 9a86120e7c7484b1b622280ad5538b955fa6bc47..f297ff0263721a5e8f5f0019b674d99a098f5710 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.hslf.usermodel.RichTextRun;\r
-import org.apache.poi.hslf.record.TextRulerAtom;\r
-import org.apache.poi.util.POILogger;\r
-import org.apache.poi.util.POILogFactory;\r
-\r
-import java.text.AttributedString;\r
-import java.text.AttributedCharacterIterator;\r
-import java.text.BreakIterator;\r
-import java.awt.font.TextAttribute;\r
-import java.awt.font.LineBreakMeasurer;\r
-import java.awt.font.TextLayout;\r
-import java.awt.font.FontRenderContext;\r
-import java.awt.*;\r
-import java.awt.geom.Rectangle2D;\r
-import java.awt.geom.Point2D;\r
-import java.util.ArrayList;\r
-\r
-/**\r
- * Paint text into java.awt.Graphics2D\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class TextPainter {\r
-    protected POILogger logger = POILogFactory.getLogger(this.getClass());\r
-\r
-    /**\r
-     * Display unicode square if a bullet char can't be displayed,\r
-     * for example, if Wingdings font is used.\r
-     * TODO: map Wingdngs and Symbol to unicode Arial\r
-     */\r
-    protected static final char DEFAULT_BULLET_CHAR = '\u25a0';\r
-\r
-    protected TextShape _shape;\r
-\r
-    public TextPainter(TextShape shape){\r
-        _shape = shape;\r
-    }\r
-\r
-    /**\r
-     * Convert the underlying set of rich text runs into java.text.AttributedString\r
-     */\r
-    public AttributedString getAttributedString(TextRun txrun){\r
-        String text = txrun.getText();\r
-        //TODO: properly process tabs\r
-        text = text.replace('\t', ' ');\r
-        text = text.replace((char)160, ' ');\r
-\r
-        AttributedString at = new AttributedString(text);\r
-        RichTextRun[] rt = txrun.getRichTextRuns();\r
-        for (int i = 0; i < rt.length; i++) {\r
-            int start = rt[i].getStartIndex();\r
-            int end = rt[i].getEndIndex();\r
-            if(start == end) {\r
-                logger.log(POILogger.INFO,  "Skipping RichTextRun with zero length");\r
-                continue;\r
-            }\r
-\r
-            at.addAttribute(TextAttribute.FAMILY, rt[i].getFontName(), start, end);\r
-            at.addAttribute(TextAttribute.SIZE, new Float(rt[i].getFontSize()), start, end);\r
-            at.addAttribute(TextAttribute.FOREGROUND, rt[i].getFontColor(), start, end);\r
-            if(rt[i].isBold()) at.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, start, end);\r
-            if(rt[i].isItalic()) at.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, start, end);\r
-            if(rt[i].isUnderlined()) {\r
-                at.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, start, end);\r
-                at.addAttribute(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_TWO_PIXEL, start, end);\r
-            }\r
-            if(rt[i].isStrikethrough()) at.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, start, end);\r
-            int superScript = rt[i].getSuperscript();\r
-            if(superScript != 0) at.addAttribute(TextAttribute.SUPERSCRIPT, superScript > 0 ? TextAttribute.SUPERSCRIPT_SUPER : TextAttribute.SUPERSCRIPT_SUB, start, end);\r
-\r
-        }\r
-        return at;\r
-    }\r
-\r
-    public void paint(Graphics2D graphics){\r
-        Rectangle2D anchor = _shape.getLogicalAnchor2D();\r
-        TextElement[] elem = getTextElements((float)anchor.getWidth(), graphics.getFontRenderContext());\r
-        if(elem == null) return;\r
-\r
-        float textHeight = 0;\r
-        for (int i = 0; i < elem.length; i++) {\r
-            textHeight += elem[i].ascent + elem[i].descent;\r
-        }\r
-\r
-        int valign = _shape.getVerticalAlignment();\r
-        double y0 = anchor.getY();\r
-        switch (valign){\r
-            case TextShape.AnchorTopBaseline:\r
-            case TextShape.AnchorTop:\r
-                y0 += _shape.getMarginTop();\r
-                break;\r
-            case TextShape.AnchorBottom:\r
-                y0 += anchor.getHeight() - textHeight - _shape.getMarginBottom();\r
-                break;\r
-            default:\r
-            case TextShape.AnchorMiddle:\r
-                float delta =  (float)anchor.getHeight() - textHeight - _shape.getMarginTop() - _shape.getMarginBottom();\r
-                y0 += _shape.getMarginTop()  + delta/2;\r
-                break;\r
-        }\r
-\r
-        //finally draw the text fragments\r
-        for (int i = 0; i < elem.length; i++) {\r
-            y0 += elem[i].ascent;\r
-\r
-            Point2D.Double pen = new Point2D.Double();\r
-            pen.y = y0;\r
-            switch (elem[i]._align) {\r
-                default:\r
-                case TextShape.AlignLeft:\r
-                    pen.x = anchor.getX() + _shape.getMarginLeft();\r
-                    break;\r
-                case TextShape.AlignCenter:\r
-                    pen.x = anchor.getX() + _shape.getMarginLeft() +\r
-                            (anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight()) / 2;\r
-                    break;\r
-                case TextShape.AlignRight:\r
-                    pen.x = anchor.getX() + _shape.getMarginLeft() +\r
-                            (anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight());\r
-                    break;\r
-            }\r
-            if(elem[i]._bullet != null){\r
-                graphics.drawString(elem[i]._bullet.getIterator(), (float)(pen.x + elem[i]._bulletOffset), (float)pen.y);\r
-            }\r
-            AttributedCharacterIterator chIt = elem[i]._text.getIterator();\r
-            if(chIt.getEndIndex() > chIt.getBeginIndex()) {\r
-                graphics.drawString(chIt, (float)(pen.x + elem[i]._textOffset), (float)pen.y);\r
-            }\r
-            y0 += elem[i].descent;\r
-        }\r
-    }\r
-\r
-    public TextElement[] getTextElements(float textWidth, FontRenderContext frc){\r
-        TextRun run = _shape.getTextRun();\r
-        if (run == null) return null;\r
-\r
-        String text = run.getText();\r
-        if (text == null || text.equals("")) return null;\r
-\r
-        AttributedString at = getAttributedString(run);\r
-\r
-        AttributedCharacterIterator it = at.getIterator();\r
-        int paragraphStart = it.getBeginIndex();\r
-        int paragraphEnd = it.getEndIndex();\r
-\r
-        ArrayList lines = new ArrayList();\r
-        LineBreakMeasurer measurer = new LineBreakMeasurer(it, frc);\r
-        measurer.setPosition(paragraphStart);\r
-        while (measurer.getPosition() < paragraphEnd) {\r
-            int startIndex = measurer.getPosition();\r
-            int nextBreak = text.indexOf('\n', measurer.getPosition() + 1);\r
-\r
-            boolean prStart = text.charAt(startIndex) == '\n';\r
-            if(prStart) measurer.setPosition(startIndex++);\r
-\r
-            RichTextRun rt = run.getRichTextRunAt(startIndex == text.length() ? (startIndex-1) : startIndex);\r
-            if(rt == null) {\r
-                logger.log(POILogger.WARN,  "RichTextRun not found at pos" + startIndex + "; text.length: " + text.length());\r
-                break;\r
-            }\r
-\r
-            float wrappingWidth = textWidth - _shape.getMarginLeft() - _shape.getMarginRight();\r
-            int bulletOffset = rt.getBulletOffset();\r
-            int textOffset = rt.getTextOffset();\r
-            int indent = rt.getIndentLevel();\r
-\r
-            TextRulerAtom ruler = run.getTextRuler();\r
-            if(ruler != null) {\r
-                int bullet_val = ruler.getBulletOffsets()[indent]*Shape.POINT_DPI/Shape.MASTER_DPI;\r
-                int text_val = ruler.getTextOffsets()[indent]*Shape.POINT_DPI/Shape.MASTER_DPI;\r
-                if(bullet_val > text_val){\r
-                    int a = bullet_val;\r
-                    bullet_val = text_val;\r
-                    text_val = a;\r
-                }\r
-                if(bullet_val != 0 ) bulletOffset = bullet_val;\r
-                if(text_val != 0) textOffset = text_val;\r
-            }\r
-\r
-            if(bulletOffset > 0 || prStart || startIndex == 0) wrappingWidth -= textOffset;\r
-\r
-            if (_shape.getWordWrap() == TextShape.WrapNone) {\r
-                wrappingWidth = _shape.getSheet().getSlideShow().getPageSize().width;\r
-            }\r
-\r
-            TextLayout textLayout = measurer.nextLayout(wrappingWidth + 1,\r
-                    nextBreak == -1 ? paragraphEnd : nextBreak, true);\r
-            if (textLayout == null) {\r
-                textLayout = measurer.nextLayout(textWidth,\r
-                    nextBreak == -1 ? paragraphEnd : nextBreak, false);\r
-            }\r
-            if(textLayout == null){\r
-                logger.log(POILogger.WARN, "Failed to break text into lines: wrappingWidth: "+wrappingWidth+\r
-                        "; text: " + rt.getText());\r
-                measurer.setPosition(rt.getEndIndex());\r
-                continue;\r
-            }\r
-            int endIndex = measurer.getPosition();\r
-\r
-            float lineHeight = (float)textLayout.getBounds().getHeight();\r
-            int linespacing = rt.getLineSpacing();\r
-            if(linespacing == 0) linespacing = 100;\r
-\r
-            TextElement el = new TextElement();\r
-            if(linespacing >= 0){\r
-                el.ascent = textLayout.getAscent()*linespacing/100;\r
-            } else {\r
-                el.ascent = -linespacing*Shape.POINT_DPI/Shape.MASTER_DPI;\r
-            }\r
-\r
-            el._align = rt.getAlignment();\r
-            el.advance = textLayout.getAdvance();\r
-            el._textOffset = textOffset;\r
-            el._text = new AttributedString(it, startIndex, endIndex);\r
-            el.textStartIndex = startIndex;\r
-            el.textEndIndex = endIndex;\r
-\r
-            if (prStart){\r
-                int sp = rt.getSpaceBefore();\r
-                float spaceBefore;\r
-                if(sp >= 0){\r
-                    spaceBefore = lineHeight * sp/100;\r
-                } else {\r
-                    spaceBefore = -sp*Shape.POINT_DPI/Shape.MASTER_DPI;\r
-                }\r
-                el.ascent += spaceBefore;\r
-            }\r
-\r
-            float descent;\r
-            if(linespacing >= 0){\r
-                descent = (textLayout.getDescent() + textLayout.getLeading())*linespacing/100;\r
-            } else {\r
-                descent = -linespacing*Shape.POINT_DPI/Shape.MASTER_DPI;\r
-            }\r
-            if (prStart){\r
-                int sp = rt.getSpaceAfter();\r
-                float spaceAfter;\r
-                if(sp >= 0){\r
-                    spaceAfter = lineHeight * sp/100;\r
-                } else {\r
-                    spaceAfter = -sp*Shape.POINT_DPI/Shape.MASTER_DPI;\r
-                }\r
-                el.ascent += spaceAfter;\r
-            }\r
-            el.descent = descent;\r
-\r
-            if(rt.isBullet() && (prStart || startIndex == 0)){\r
-                it.setIndex(startIndex);\r
-\r
-                AttributedString bat = new AttributedString(Character.toString(rt.getBulletChar()));\r
-                Color clr = rt.getBulletColor();\r
-                if (clr != null) bat.addAttribute(TextAttribute.FOREGROUND, clr);\r
-                else bat.addAttribute(TextAttribute.FOREGROUND, it.getAttribute(TextAttribute.FOREGROUND));\r
-\r
-                int fontIdx = rt.getBulletFont();\r
-                if(fontIdx == -1) fontIdx = rt.getFontIndex();\r
-                PPFont bulletFont = _shape.getSheet().getSlideShow().getFont(fontIdx);\r
-                bat.addAttribute(TextAttribute.FAMILY, bulletFont.getFontName());\r
-\r
-                int bulletSize = rt.getBulletSize();\r
-                int fontSize = rt.getFontSize();\r
-                if(bulletSize != -1) fontSize = Math.round(fontSize*bulletSize*0.01f);\r
-                bat.addAttribute(TextAttribute.SIZE, new Float(fontSize));\r
-\r
-                if(!new Font(bulletFont.getFontName(), Font.PLAIN, 1).canDisplay(rt.getBulletChar())){\r
-                    bat.addAttribute(TextAttribute.FAMILY, "Arial");\r
-                    bat = new AttributedString("" + DEFAULT_BULLET_CHAR, bat.getIterator().getAttributes());\r
-                }\r
-\r
-                if(text.substring(startIndex, endIndex).length() > 1){\r
-                    el._bullet = bat;\r
-                    el._bulletOffset = bulletOffset;\r
-                }\r
-            }\r
-            lines.add(el);\r
-        }\r
-\r
-        //finally draw the text fragments\r
-        TextElement[] elems = new TextElement[lines.size()];\r
-        return (TextElement[])lines.toArray(elems);\r
-    }\r
-\r
-    public static class TextElement {\r
-        public AttributedString _text;\r
-        public int _textOffset;\r
-        public AttributedString _bullet;\r
-        public int _bulletOffset;\r
-        public int _align;\r
-        public float ascent, descent;\r
-        public float advance;\r
-        public int textStartIndex, textEndIndex;\r
-    }\r
-}\r
+/* ====================================================================
+   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.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.font.LineBreakMeasurer;
+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.util.ArrayList;
+
+/**
+ * Paint text into java.awt.Graphics2D
+ *
+ * @author Yegor Kozlov
+ */
+public final class TextPainter {
+    protected POILogger logger = POILogFactory.getLogger(this.getClass());
+
+    /**
+     * Display unicode square if a bullet char can't be displayed,
+     * for example, if Wingdings font is used.
+     * TODO: map Wingdngs and Symbol to unicode Arial
+     */
+    protected static final char DEFAULT_BULLET_CHAR = '\u25a0';
+
+    protected TextShape _shape;
+
+    public TextPainter(TextShape shape){
+        _shape = shape;
+    }
+
+    /**
+     * Convert the underlying set of rich text runs into java.text.AttributedString
+     */
+    public AttributedString getAttributedString(TextRun txrun){
+        String text = txrun.getText();
+        //TODO: properly process tabs
+        text = text.replace('\t', ' ');
+        text = text.replace((char)160, ' ');
+
+        AttributedString at = new AttributedString(text);
+        RichTextRun[] rt = txrun.getRichTextRuns();
+        for (int i = 0; i < rt.length; i++) {
+            int start = rt[i].getStartIndex();
+            int end = rt[i].getEndIndex();
+            if(start == end) {
+                logger.log(POILogger.INFO,  "Skipping RichTextRun with zero length");
+                continue;
+            }
+
+            at.addAttribute(TextAttribute.FAMILY, rt[i].getFontName(), start, end);
+            at.addAttribute(TextAttribute.SIZE, new Float(rt[i].getFontSize()), start, end);
+            at.addAttribute(TextAttribute.FOREGROUND, rt[i].getFontColor(), start, end);
+            if(rt[i].isBold()) at.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, start, end);
+            if(rt[i].isItalic()) at.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, start, end);
+            if(rt[i].isUnderlined()) {
+                at.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, start, end);
+                at.addAttribute(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_TWO_PIXEL, start, end);
+            }
+            if(rt[i].isStrikethrough()) at.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, start, end);
+            int superScript = rt[i].getSuperscript();
+            if(superScript != 0) at.addAttribute(TextAttribute.SUPERSCRIPT, superScript > 0 ? TextAttribute.SUPERSCRIPT_SUPER : TextAttribute.SUPERSCRIPT_SUB, start, end);
+
+        }
+        return at;
+    }
+
+    public void paint(Graphics2D graphics){
+        Rectangle2D anchor = _shape.getLogicalAnchor2D();
+        TextElement[] elem = getTextElements((float)anchor.getWidth(), graphics.getFontRenderContext());
+        if(elem == null) return;
+
+        float textHeight = 0;
+        for (int i = 0; i < elem.length; i++) {
+            textHeight += elem[i].ascent + elem[i].descent;
+        }
+
+        int valign = _shape.getVerticalAlignment();
+        double y0 = anchor.getY();
+        switch (valign){
+            case TextShape.AnchorTopBaseline:
+            case TextShape.AnchorTop:
+                y0 += _shape.getMarginTop();
+                break;
+            case TextShape.AnchorBottom:
+                y0 += anchor.getHeight() - textHeight - _shape.getMarginBottom();
+                break;
+            default:
+            case TextShape.AnchorMiddle:
+                float delta =  (float)anchor.getHeight() - textHeight - _shape.getMarginTop() - _shape.getMarginBottom();
+                y0 += _shape.getMarginTop()  + delta/2;
+                break;
+        }
+
+        //finally draw the text fragments
+        for (int i = 0; i < elem.length; i++) {
+            y0 += elem[i].ascent;
+
+            Point2D.Double pen = new Point2D.Double();
+            pen.y = y0;
+            switch (elem[i]._align) {
+                default:
+                case TextShape.AlignLeft:
+                    pen.x = anchor.getX() + _shape.getMarginLeft();
+                    break;
+                case TextShape.AlignCenter:
+                    pen.x = anchor.getX() + _shape.getMarginLeft() +
+                            (anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight()) / 2;
+                    break;
+                case TextShape.AlignRight:
+                    pen.x = anchor.getX() + _shape.getMarginLeft() +
+                            (anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight());
+                    break;
+            }
+            if(elem[i]._bullet != null){
+                graphics.drawString(elem[i]._bullet.getIterator(), (float)(pen.x + elem[i]._bulletOffset), (float)pen.y);
+            }
+            AttributedCharacterIterator chIt = elem[i]._text.getIterator();
+            if(chIt.getEndIndex() > chIt.getBeginIndex()) {
+                graphics.drawString(chIt, (float)(pen.x + elem[i]._textOffset), (float)pen.y);
+            }
+            y0 += elem[i].descent;
+        }
+    }
+
+    public TextElement[] getTextElements(float textWidth, FontRenderContext frc){
+        TextRun run = _shape.getTextRun();
+        if (run == null) return null;
+
+        String text = run.getText();
+        if (text == null || text.equals("")) return null;
+
+        AttributedString at = getAttributedString(run);
+
+        AttributedCharacterIterator it = at.getIterator();
+        int paragraphStart = it.getBeginIndex();
+        int paragraphEnd = it.getEndIndex();
+
+        ArrayList lines = new ArrayList();
+        LineBreakMeasurer measurer = new LineBreakMeasurer(it, frc);
+        measurer.setPosition(paragraphStart);
+        while (measurer.getPosition() < paragraphEnd) {
+            int startIndex = measurer.getPosition();
+            int nextBreak = text.indexOf('\n', measurer.getPosition() + 1);
+
+            boolean prStart = text.charAt(startIndex) == '\n';
+            if(prStart) measurer.setPosition(startIndex++);
+
+            RichTextRun rt = run.getRichTextRunAt(startIndex == text.length() ? (startIndex-1) : startIndex);
+            if(rt == null) {
+                logger.log(POILogger.WARN,  "RichTextRun not found at pos" + startIndex + "; text.length: " + text.length());
+                break;
+            }
+
+            float wrappingWidth = textWidth - _shape.getMarginLeft() - _shape.getMarginRight();
+            int bulletOffset = rt.getBulletOffset();
+            int textOffset = rt.getTextOffset();
+            int indent = rt.getIndentLevel();
+
+            TextRulerAtom ruler = run.getTextRuler();
+            if(ruler != null) {
+                int bullet_val = ruler.getBulletOffsets()[indent]*Shape.POINT_DPI/Shape.MASTER_DPI;
+                int text_val = ruler.getTextOffsets()[indent]*Shape.POINT_DPI/Shape.MASTER_DPI;
+                if(bullet_val > text_val){
+                    int a = bullet_val;
+                    bullet_val = text_val;
+                    text_val = a;
+                }
+                if(bullet_val != 0 ) bulletOffset = bullet_val;
+                if(text_val != 0) textOffset = text_val;
+            }
+
+            if(bulletOffset > 0 || prStart || startIndex == 0) wrappingWidth -= textOffset;
+
+            if (_shape.getWordWrap() == TextShape.WrapNone) {
+                wrappingWidth = _shape.getSheet().getSlideShow().getPageSize().width;
+            }
+
+            TextLayout textLayout = measurer.nextLayout(wrappingWidth + 1,
+                    nextBreak == -1 ? paragraphEnd : nextBreak, true);
+            if (textLayout == null) {
+                textLayout = measurer.nextLayout(textWidth,
+                    nextBreak == -1 ? paragraphEnd : nextBreak, false);
+            }
+            if(textLayout == null){
+                logger.log(POILogger.WARN, "Failed to break text into lines: wrappingWidth: "+wrappingWidth+
+                        "; text: " + rt.getText());
+                measurer.setPosition(rt.getEndIndex());
+                continue;
+            }
+            int endIndex = measurer.getPosition();
+
+            float lineHeight = (float)textLayout.getBounds().getHeight();
+            int linespacing = rt.getLineSpacing();
+            if(linespacing == 0) linespacing = 100;
+
+            TextElement el = new TextElement();
+            if(linespacing >= 0){
+                el.ascent = textLayout.getAscent()*linespacing/100;
+            } else {
+                el.ascent = -linespacing*Shape.POINT_DPI/Shape.MASTER_DPI;
+            }
+
+            el._align = rt.getAlignment();
+            el.advance = textLayout.getAdvance();
+            el._textOffset = textOffset;
+            el._text = new AttributedString(it, startIndex, endIndex);
+            el.textStartIndex = startIndex;
+            el.textEndIndex = endIndex;
+
+            if (prStart){
+                int sp = rt.getSpaceBefore();
+                float spaceBefore;
+                if(sp >= 0){
+                    spaceBefore = lineHeight * sp/100;
+                } else {
+                    spaceBefore = -sp*Shape.POINT_DPI/Shape.MASTER_DPI;
+                }
+                el.ascent += spaceBefore;
+            }
+
+            float descent;
+            if(linespacing >= 0){
+                descent = (textLayout.getDescent() + textLayout.getLeading())*linespacing/100;
+            } else {
+                descent = -linespacing*Shape.POINT_DPI/Shape.MASTER_DPI;
+            }
+            if (prStart){
+                int sp = rt.getSpaceAfter();
+                float spaceAfter;
+                if(sp >= 0){
+                    spaceAfter = lineHeight * sp/100;
+                } else {
+                    spaceAfter = -sp*Shape.POINT_DPI/Shape.MASTER_DPI;
+                }
+                el.ascent += spaceAfter;
+            }
+            el.descent = descent;
+
+            if(rt.isBullet() && (prStart || startIndex == 0)){
+                it.setIndex(startIndex);
+
+                AttributedString bat = new AttributedString(Character.toString(rt.getBulletChar()));
+                Color clr = rt.getBulletColor();
+                if (clr != null) bat.addAttribute(TextAttribute.FOREGROUND, clr);
+                else bat.addAttribute(TextAttribute.FOREGROUND, it.getAttribute(TextAttribute.FOREGROUND));
+
+                int fontIdx = rt.getBulletFont();
+                if(fontIdx == -1) fontIdx = rt.getFontIndex();
+                PPFont bulletFont = _shape.getSheet().getSlideShow().getFont(fontIdx);
+                bat.addAttribute(TextAttribute.FAMILY, bulletFont.getFontName());
+
+                int bulletSize = rt.getBulletSize();
+                int fontSize = rt.getFontSize();
+                if(bulletSize != -1) fontSize = Math.round(fontSize*bulletSize*0.01f);
+                bat.addAttribute(TextAttribute.SIZE, new Float(fontSize));
+
+                if(!new Font(bulletFont.getFontName(), Font.PLAIN, 1).canDisplay(rt.getBulletChar())){
+                    bat.addAttribute(TextAttribute.FAMILY, "Arial");
+                    bat = new AttributedString("" + DEFAULT_BULLET_CHAR, bat.getIterator().getAttributes());
+                }
+
+                if(text.substring(startIndex, endIndex).length() > 1){
+                    el._bullet = bat;
+                    el._bulletOffset = bulletOffset;
+                }
+            }
+            lines.add(el);
+        }
+
+        //finally draw the text fragments
+        TextElement[] elems = new TextElement[lines.size()];
+        return (TextElement[])lines.toArray(elems);
+    }
+
+    public static class TextElement {
+        public AttributedString _text;
+        public int _textOffset;
+        public AttributedString _bullet;
+        public int _bulletOffset;
+        public int _align;
+        public float ascent, descent;
+        public float advance;
+        public int textStartIndex, textEndIndex;
+    }
+}
index cf2db50e86b2a6e0846f759693640845b85398a7..6260c62cac0eb9a15ab01e633e7b25e7bcf4d171 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.model;
 
@@ -38,7 +35,7 @@ import org.apache.poi.util.StringUtil;
  * @author Nick Burch
  */
 
-public class TextRun
+public final class TextRun
 {
        // Note: These fields are protected to help with unit testing
        //   Other classes shouldn't really go playing with them!
@@ -80,7 +77,7 @@ public class TextRun
        public TextRun(TextHeaderAtom tha, TextBytesAtom tba, StyleTextPropAtom sta) {
                this(tha,tba,null,sta);
        }
-       
+
        /**
         * Internal constructor and initializer
         */
@@ -95,7 +92,7 @@ public class TextRun
                        _isUnicode = true;
                }
                String runRawText = getText();
-               
+
                // Figure out the rich text runs
                LinkedList pStyles = new LinkedList();
                LinkedList cStyles = new LinkedList();
@@ -107,7 +104,7 @@ public class TextRun
                }
         buildRichTextRuns(pStyles, cStyles, runRawText);
        }
-       
+
        public void buildRichTextRuns(LinkedList pStyles, LinkedList cStyles, String runRawText){
 
         // Handle case of no current style, with a default
@@ -258,25 +255,25 @@ public class TextRun
     }
 
     // Update methods follow
-       
+
        /**
-        * Adds the supplied text onto the end of the TextRun, 
+        * Adds the supplied text onto the end of the TextRun,
         *  creating a new RichTextRun (returned) for it to
-        *  sit in. 
+        *  sit in.
         * In many cases, before calling this, you'll want to add
         *  a newline onto the end of your last RichTextRun
         */
        public RichTextRun appendText(String s) {
                // We will need a StyleTextProp atom
                ensureStyleAtomPresent();
-               
-               // First up, append the text to the 
+
+               // First up, append the text to the
                //  underlying text atom
                int oldSize = getRawText().length();
                storeText(
                                getRawText() + s
                );
-               
+
                // If either of the previous styles overran
                //  the text by one, we need to shuffle that
                //  extra character onto the new ones
@@ -296,32 +293,32 @@ public class TextRun
                                        tpc.getCharactersCovered() - cOverRun
                        );
                }
-               
+
                // Next, add the styles for its paragraph and characters
                TextPropCollection newPTP =
                        _styleAtom.addParagraphTextPropCollection(s.length()+pOverRun);
                TextPropCollection newCTP =
                        _styleAtom.addCharacterTextPropCollection(s.length()+cOverRun);
-               
+
                // Now, create the new RichTextRun
                RichTextRun nr = new RichTextRun(
-                               this, oldSize, s.length(), 
+                               this, oldSize, s.length(),
                                newPTP, newCTP, false, false
                );
-               
+
                // Add the new RichTextRun onto our list
                RichTextRun[] newRuns = new RichTextRun[_rtRuns.length+1];
                System.arraycopy(_rtRuns, 0, newRuns, 0, _rtRuns.length);
                newRuns[newRuns.length-1] = nr;
                _rtRuns = newRuns;
-               
+
                // And return the new run to the caller
                return nr;
        }
 
        /**
-        * Saves the given string to the records. Doesn't 
-        *  touch the stylings. 
+        * Saves the given string to the records. Doesn't
+        *  touch the stylings.
         */
        private void storeText(String s) {
                // Remove a single trailing \r, as there is an implicit one at the
@@ -329,7 +326,7 @@ public class TextRun
                if(s.endsWith("\r")) {
                        s = s.substring(0, s.length()-1);
                }
-               
+
                // Store in the appropriate record
                if(_isUnicode) {
                        // The atom can safely convert to unicode
@@ -344,11 +341,11 @@ public class TextRun
                                _byteAtom.setText(text);
                        } else {
                                // Need to swap a TextBytesAtom for a TextCharsAtom
-                               
+
                                // Build the new TextCharsAtom
                                _charAtom = new TextCharsAtom();
                                _charAtom.setText(s);
-                               
+
                                // Use the TextHeaderAtom to do the swap on the parent
                                RecordContainer parent = _headerAtom.getParentRecord();
                                Record[] cr = parent.getChildRecords();
@@ -360,7 +357,7 @@ public class TextRun
                                                break;
                                        }
                                }
-                               
+
                                // Flag the change
                                _byteAtom = null;
                                _isUnicode = true;
@@ -379,7 +376,7 @@ public class TextRun
             }
         }
        }
-       
+
        /**
         * Handles an update to the text stored in one of the Rich Text Runs
         * @param run
@@ -396,10 +393,10 @@ public class TextRun
                if(runID == -1) {
                        throw new IllegalArgumentException("Supplied RichTextRun wasn't from this TextRun");
                }
-               
+
                // Ensure a StyleTextPropAtom is present, adding if required
                ensureStyleAtomPresent();
-               
+
                // Update the text length for its Paragraph and Character stylings
                // If it's shared:
                //   * calculate the new length based on the run's old text
@@ -416,7 +413,7 @@ public class TextRun
                if(runID == _rtRuns.length-1) {
                        newSize++;
                }
-               
+
                if(run._isParagraphStyleShared()) {
                        pCol.updateTextSize( pCol.getCharactersCovered() - run.getLength() + s.length() );
                } else {
@@ -427,14 +424,14 @@ public class TextRun
                } else {
                        cCol.updateTextSize(newSize);
                }
-               
+
                // Build up the new text
                // As we go through, update the start position for all subsequent runs
                // The building relies on the old text still being present
                StringBuffer newText = new StringBuffer();
                for(int i=0; i<_rtRuns.length; i++) {
                        int newStartPos = newText.length();
-                       
+
                        // Build up the new text
                        if(i != runID) {
                                // Not the affected run, so keep old text
@@ -443,7 +440,7 @@ public class TextRun
                                // Affected run, so use new text
                                newText.append(s);
                        }
-                       
+
                        // Do we need to update the start position of this run?
                        // (Need to get the text before we update the start pos)
                        if(i <= runID) {
@@ -453,15 +450,15 @@ public class TextRun
                                _rtRuns[i].updateStartPosition(newStartPos);
                        }
                }
-               
+
                // Now we can save the new text
                storeText(newText.toString());
        }
 
        /**
         * Changes the text, and sets it all to have the same styling
-        *  as the the first character has. 
-        * If you care about styling, do setText on a RichTextRun instead 
+        *  as the the first character has.
+        * If you care about styling, do setText on a RichTextRun instead
         */
        public void setRawText(String s) {
                // Save the new text to the atoms
@@ -481,10 +478,10 @@ public class TextRun
                if(_styleAtom != null) {
                        LinkedList pStyles = _styleAtom.getParagraphStyles();
                        while(pStyles.size() > 1) { pStyles.removeLast(); }
-                       
+
                        LinkedList cStyles = _styleAtom.getCharacterStyles();
                        while(cStyles.size() > 1) { cStyles.removeLast(); }
-                       
+
                        _rtRuns[0].setText(s);
                } else {
                        // Recreate rich text run with no styling
@@ -503,7 +500,7 @@ public class TextRun
     }
 
     /**
-        * Ensure a StyleTextPropAtom is present for this run, 
+        * Ensure a StyleTextPropAtom is present for this run,
         *  by adding if required. Normally for internal TextRun use.
         */
        public void ensureStyleAtomPresent() {
@@ -511,23 +508,23 @@ public class TextRun
                        // All there
                        return;
                }
-               
+
                // Create a new one at the right size
                _styleAtom = new StyleTextPropAtom(getRawText().length() + 1);
-               
+
                // Use the TextHeader atom to get at the parent
                RecordContainer runAtomsParent = _headerAtom.getParentRecord();
-               
+
                // Add the new StyleTextPropAtom after the TextCharsAtom / TextBytesAtom
                Record addAfter = _byteAtom;
                if(_byteAtom == null) { addAfter = _charAtom; }
                runAtomsParent.addChildAfter(_styleAtom, addAfter);
-               
+
                // Feed this to our sole rich text run
                if(_rtRuns.length != 1) {
                        throw new IllegalStateException("Needed to add StyleTextPropAtom when had many rich text runs");
                }
-               // These are the only styles for now 
+               // These are the only styles for now
                _rtRuns[0].supplyTextProps(
                                (TextPropCollection)_styleAtom.getParagraphStyles().get(0),
                                (TextPropCollection)_styleAtom.getCharacterStyles().get(0),
@@ -572,7 +569,7 @@ public class TextRun
                        return _byteAtom.getText();
                }
        }
-       
+
        /**
         * Fetch the rich text runs (runs of text with the same styling) that
         *  are contained within this block of text
@@ -580,13 +577,13 @@ public class TextRun
        public RichTextRun[] getRichTextRuns() {
                return  _rtRuns;
        }
-       
+
        /**
        * Returns the type of the text, from the TextHeaderAtom.
        * Possible values can be seen from TextHeaderAtom
        * @see org.apache.poi.hslf.record.TextHeaderAtom
        */
-       public int getRunType() { 
+       public int getRunType() {
                return _headerAtom.getTextType();
        }
 
@@ -599,7 +596,7 @@ public class TextRun
        public void setRunType(int type) {
                _headerAtom.setTextType(type);
        }
-       
+
        /**
         * Supply the SlideShow we belong to.
         * Also passes it on to our child RichTextRuns
@@ -618,7 +615,7 @@ public class TextRun
     }
 
     public Sheet getSheet(){
-        return this.sheet;        
+        return this.sheet;
     }
 
     /**
index 9b5e8bfc4cbd244349db32b6d0fbd94acec86fc6..843f1238900a120cf4446fb3382278e8bc3a5d49 100644 (file)
@@ -1,69 +1,69 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.model;\r
-\r
-import org.apache.poi.hslf.model.textproperties.TextProp;\r
-import org.apache.poi.hslf.record.*;\r
-\r
-/**\r
- * Title masters define the design template for slides with a Title Slide layout.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TitleMaster extends MasterSheet {\r
-    private TextRun[] _runs;\r
-\r
-    /**\r
-     * Constructs a TitleMaster\r
-     *\r
-     */\r
-    public TitleMaster(org.apache.poi.hslf.record.Slide record, int sheetNo) {\r
-        super(record, sheetNo);\r
-\r
-        _runs = findTextRuns(getPPDrawing());\r
-        for (int i = 0; i < _runs.length; i++) _runs[i].setSheet(this);\r
-    }\r
-\r
-    /**\r
-     * Returns an array of all the TextRuns found\r
-     */\r
-    public TextRun[] getTextRuns() {\r
-        return _runs;\r
-    }\r
-\r
-    /**\r
-     * Delegate the call to the underlying slide master.\r
-     */\r
-    public TextProp getStyleAttribute(int txtype, int level, String name, boolean isCharacter) {\r
-        MasterSheet master = getMasterSheet();\r
-        return master == null ? null : master.getStyleAttribute(txtype, level, name, isCharacter);\r
-    }\r
-\r
-    /**\r
-     * Returns the slide master for this title master.\r
-     */\r
-    public MasterSheet getMasterSheet(){\r
-        SlideMaster[] master = getSlideShow().getSlidesMasters();\r
-        SlideAtom sa = ((org.apache.poi.hslf.record.Slide)getSheetContainer()).getSlideAtom();\r
-        int masterId = sa.getMasterID();\r
-        for (int i = 0; i < master.length; i++) {\r
-            if (masterId == master[i]._getSheetNumber()) return master[i];\r
-        }\r
-        return null;\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import org.apache.poi.hslf.model.textproperties.TextProp;
+import org.apache.poi.hslf.record.*;
+
+/**
+ * Title masters define the design template for slides with a Title Slide layout.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TitleMaster extends MasterSheet {
+    private TextRun[] _runs;
+
+    /**
+     * Constructs a TitleMaster
+     *
+     */
+    public TitleMaster(org.apache.poi.hslf.record.Slide record, int sheetNo) {
+        super(record, sheetNo);
+
+        _runs = findTextRuns(getPPDrawing());
+        for (int i = 0; i < _runs.length; i++) _runs[i].setSheet(this);
+    }
+
+    /**
+     * Returns an array of all the TextRuns found
+     */
+    public TextRun[] getTextRuns() {
+        return _runs;
+    }
+
+    /**
+     * Delegate the call to the underlying slide master.
+     */
+    public TextProp getStyleAttribute(int txtype, int level, String name, boolean isCharacter) {
+        MasterSheet master = getMasterSheet();
+        return master == null ? null : master.getStyleAttribute(txtype, level, name, isCharacter);
+    }
+
+    /**
+     * Returns the slide master for this title master.
+     */
+    public MasterSheet getMasterSheet(){
+        SlideMaster[] master = getSlideShow().getSlidesMasters();
+        SlideAtom sa = ((org.apache.poi.hslf.record.Slide)getSheetContainer()).getSlideAtom();
+        int masterId = sa.getMasterID();
+        for (int i = 0; i < master.length; i++) {
+            if (masterId == master[i]._getSheetNumber()) return master[i];
+        }
+        return null;
+    }
+}
index 0ea21b299205856e8d47187de606a33245d36c67..f1bce9593a1243c11bf4611848de2ef91402228f 100644 (file)
@@ -1,41 +1,41 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.model.textproperties;\r
-\r
-/** \r
- * Definition for the common paragraph text property bitset.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class ParagraphFlagsTextProp extends BitMaskTextProp {\r
-       public static final int BULLET_IDX = 0;\r
-       public static final int BULLET_HARDFONT_IDX = 1;\r
-       public static final int BULLET_HARDCOLOR_IDX = 2;\r
-       public static final int BULLET_HARDSIZE_IDX = 4;\r
-\r
-    public static String NAME = "paragraph_flags";\r
-\r
-       public ParagraphFlagsTextProp() {\r
-               super(2,  0xF, NAME, new String[] {\r
-                                       "bullet",\r
-                    "bullet.hardfont",\r
-                                       "bullet.hardcolor",\r
-                    "bullet.hardsize"}\r
-               );\r
-       }\r
-}
\ No newline at end of file
+/* ====================================================================
+   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.hslf.model.textproperties;
+
+/**
+ * Definition for the common paragraph text property bitset.
+ *
+ * @author Yegor Kozlov
+ */
+public final class ParagraphFlagsTextProp extends BitMaskTextProp {
+       public static final int BULLET_IDX = 0;
+       public static final int BULLET_HARDFONT_IDX = 1;
+       public static final int BULLET_HARDCOLOR_IDX = 2;
+       public static final int BULLET_HARDSIZE_IDX = 4;
+
+    public static String NAME = "paragraph_flags";
+
+       public ParagraphFlagsTextProp() {
+               super(2,  0xF, NAME, new String[] {
+                                       "bullet",
+                    "bullet.hardfont",
+                                       "bullet.hardcolor",
+                    "bullet.hardsize"}
+               );
+       }
+}
index 37dae8fec30eb55bf8a6e3cbd0dd7484b79d50b0..e9dc5cd955deaa38bbe170b746a19f04f1d28694 100755 (executable)
@@ -1,97 +1,98 @@
-/*\r
-* Licensed to the Apache Software Foundation (ASF) under one or more\r
-* contributor license agreements.  See the NOTICE file distributed with\r
-* this work for additional information regarding copyright ownership.\r
-* The ASF licenses this file to You under the Apache License, Version 2.0\r
-* (the "License"); you may not use this file except in compliance with\r
-* the License.  You may obtain a copy of the License at\r
-*\r
-*     http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*/\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-import org.apache.poi.util.POILogger;\r
-\r
-/**\r
- * A container record that specifies information about animation information for a shape.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class AnimationInfo extends RecordContainer {\r
-       private byte[] _header;\r
-\r
-       // Links to our more interesting children\r
-       private AnimationInfoAtom animationAtom;\r
-\r
-       /**\r
-        * Set things up, and find our more interesting children\r
-        */\r
-       protected AnimationInfo(byte[] source, int start, int len) {\r
-               // Grab the header\r
-               _header = new byte[8];\r
-               System.arraycopy(source,start,_header,0,8);\r
-\r
-               // Find our children\r
-               _children = Record.findChildRecords(source,start+8,len-8);\r
-               findInterestingChildren();\r
-       }\r
-\r
-       /**\r
-        * Go through our child records, picking out the ones that are\r
-        *  interesting, and saving those for use by the easy helper\r
-        *  methods.\r
-        */     \r
-       private void findInterestingChildren() {\r
-\r
-               // First child should be the ExMediaAtom\r
-               if(_children[0] instanceof AnimationInfoAtom) {\r
-                       animationAtom = (AnimationInfoAtom)_children[0];\r
-               } else {\r
-                       logger.log(POILogger.ERROR, "First child record wasn't a AnimationInfoAtom, was of type " + _children[0].getRecordType());\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Create a new AnimationInfo, with blank fields\r
-        */\r
-       public AnimationInfo() {\r
-        // Setup our header block\r
-               _header = new byte[8];\r
-               _header[0] = 0x0f; // We are a container record\r
-               LittleEndian.putShort(_header, 2, (short)getRecordType());\r
-               \r
-        _children = new Record[1];\r
-               _children[0] = animationAtom = new AnimationInfoAtom();\r
-       }\r
-\r
-       /**\r
-        * We are of type 4103\r
-        */\r
-       public long getRecordType() { return RecordTypes.AnimationInfo.typeID; }\r
-\r
-       /**\r
-        * Write the contents of the record back, so it can be written\r
-        *  to disk\r
-        */\r
-       public void writeOut(OutputStream out) throws IOException {\r
-               writeOut(_header[0],_header[1],getRecordType(),_children,out);\r
-       }\r
-\r
-    /**\r
-     * Returns the AnimationInfo\r
-     */\r
-    public AnimationInfoAtom getAnimationInfoAtom() {\r
-        return animationAtom;\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.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 animation information for a shape.
+ *
+ * @author Yegor Kozlov
+ */
+public final class AnimationInfo extends RecordContainer {
+       private byte[] _header;
+
+       // Links to our more interesting children
+       private AnimationInfoAtom animationAtom;
+
+       /**
+        * Set things up, and find our more interesting children
+        */
+       protected AnimationInfo(byte[] source, int start, int len) {
+               // Grab the header
+               _header = new byte[8];
+               System.arraycopy(source,start,_header,0,8);
+
+               // Find our children
+               _children = Record.findChildRecords(source,start+8,len-8);
+               findInterestingChildren();
+       }
+
+       /**
+        * Go through our child records, picking out the ones that are
+        *  interesting, and saving those for use by the easy helper
+        *  methods.
+        */
+       private void findInterestingChildren() {
+
+               // First child should be the ExMediaAtom
+               if(_children[0] instanceof AnimationInfoAtom) {
+                       animationAtom = (AnimationInfoAtom)_children[0];
+               } else {
+                       logger.log(POILogger.ERROR, "First child record wasn't a AnimationInfoAtom, was of type " + _children[0].getRecordType());
+               }
+       }
+
+       /**
+        * Create a new AnimationInfo, with blank fields
+        */
+       public AnimationInfo() {
+        // Setup our header block
+               _header = new byte[8];
+               _header[0] = 0x0f; // We are a container record
+               LittleEndian.putShort(_header, 2, (short)getRecordType());
+
+        _children = new Record[1];
+               _children[0] = animationAtom = new AnimationInfoAtom();
+       }
+
+       /**
+        * We are of type 4103
+        */
+       public long getRecordType() { return RecordTypes.AnimationInfo.typeID; }
+
+       /**
+        * Write the contents of the record back, so it can be written
+        *  to disk
+        */
+       public void writeOut(OutputStream out) throws IOException {
+               writeOut(_header[0],_header[1],getRecordType(),_children,out);
+       }
+
+    /**
+     * Returns the AnimationInfo
+     */
+    public AnimationInfoAtom getAnimationInfoAtom() {
+        return animationAtom;
+    }
+
+}
index 4de22e50c38796810b19bc744060773dd2d02f64..731a3b51c92669b3d5f9a96991846d2d6d4d4b7c 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-import java.util.Date;\r
-\r
-import org.apache.poi.hslf.util.SystemTimeUtils;\r
-import org.apache.poi.util.LittleEndian;\r
-\r
-/**\r
- * An atom record that specifies the animation information for a shape.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class AnimationInfoAtom extends RecordAtom\r
-{\r
-\r
-    /**\r
-     * whether the animation plays in the reverse direction\r
-     */\r
-    public static final int Reverse = 1;\r
-    /**\r
-     * whether the animation starts automatically\r
-     */\r
-    public static final int Automatic = 4;\r
-    /**\r
-     * whether the animation has an associated sound\r
-     */\r
-    public static final int Sound = 16;\r
-    /**\r
-     * whether all playing sounds are stopped when this animation begins\r
-     */\r
-    public static final int StopSound = 64;\r
-    /**\r
-     * whether an associated sound, media or action verb is activated when the shape is clicked.\r
-     */\r
-    public static final int Play = 256;\r
-    /**\r
-     * specifies that the animation, while playing, stops other slide show actions.\r
-     */\r
-    public static final int Synchronous = 1024;\r
-    /**\r
-     * whether the shape is hidden while the animation is not playing\r
-     */\r
-    public static final int Hide = 4096;\r
-    /**\r
-     * whether the background of the shape is animated\r
-     */\r
-    public static final int AnimateBg = 16384;\r
-\r
-    /**\r
-     * Record header.\r
-     */\r
-    private byte[] _header;\r
-\r
-    /**\r
-     * record data\r
-     */\r
-    private byte[] _recdata;\r
-\r
-    /**\r
-     * Constructs a brand new link related atom record.\r
-     */\r
-    protected AnimationInfoAtom() {\r
-        _recdata = new byte[28];\r
-\r
-        _header = new byte[8];\r
-        LittleEndian.putShort(_header, 0, (short)0x01);\r
-        LittleEndian.putShort(_header, 2, (short)getRecordType());\r
-        LittleEndian.putInt(_header, 4, _recdata.length);\r
-    }\r
-\r
-    /**\r
-     * Constructs the link related atom record from its\r
-     *  source data.\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start the start offset into the byte array.\r
-     * @param len the length of the slice in the byte array.\r
-     */\r
-    protected AnimationInfoAtom(byte[] source, int start, int len) {\r
-        // Get the header\r
-        _header = new byte[8];\r
-        System.arraycopy(source,start,_header,0,8);\r
-\r
-        // Grab the record data\r
-        _recdata = new byte[len-8];\r
-        System.arraycopy(source,start+8,_recdata,0,len-8);\r
-    }\r
-\r
-    /**\r
-     * Gets the record type.\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() {\r
-        return RecordTypes.AnimationInfoAtom.typeID;\r
-    }\r
-\r
-    /**\r
-     * Write the contents of the record back, so it can be written\r
-     * to disk\r
-     *\r
-     * @param out the output stream to write to.\r
-     * @throws java.io.IOException if an error occurs.\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        out.write(_header);\r
-        out.write(_recdata);\r
-    }\r
-\r
-    /**\r
-     * A rgb structure that specifies a color for the dim effect after the animation is complete.\r
-     *\r
-     * @return  color for the dim effect after the animation is complete\r
-     */\r
-    public int getDimColor(){\r
-        return LittleEndian.getInt(_recdata, 0);\r
-    }\r
-\r
-    /**\r
-     * A rgb structure that specifies a color for the dim effect after the animation is complete.\r
-     *\r
-     * @param rgb  color for the dim effect after the animation is complete\r
-     */\r
-    public void setDimColor(int rgb){\r
-         LittleEndian.putInt(_recdata, 0, rgb);\r
-    }\r
-\r
-    /**\r
-     *  A bit mask specifying options for displaying headers and footers\r
-     *\r
-     * @return A bit mask specifying options for displaying headers and footers\r
-     */\r
-    public int getMask(){\r
-        return LittleEndian.getInt(_recdata, 4);\r
-    }\r
-\r
-    /**\r
-     *  A bit mask specifying options for displaying video\r
-     *\r
-     * @param mask A bit mask specifying options for displaying video\r
-     */\r
-    public void setMask(int mask){\r
-        LittleEndian.putInt(_recdata, 4, mask);\r
-    }\r
-\r
-    /**\r
-     * @param bit the bit to check\r
-     * @return whether the specified flag is set\r
-     */\r
-    public boolean getFlag(int bit){\r
-        return (getMask() & bit) != 0;\r
-    }\r
-\r
-    /**\r
-     * @param  bit the bit to set\r
-     * @param  value whether the specified bit is set\r
-     */\r
-    public void setFlag(int bit, boolean value){\r
-        int mask = getMask();\r
-        if(value) mask |= bit;\r
-        else mask &= ~bit;\r
-        setMask(mask);\r
-    }\r
-\r
-    /**\r
-     * A 4-byte unsigned integer that specifies a reference to a sound\r
-     * in the SoundCollectionContainer record to locate the embedded audio\r
-     *\r
-     * @return  reference to a sound\r
-     */\r
-    public int getSoundIdRef(){\r
-        return LittleEndian.getInt(_recdata, 8);\r
-    }\r
-\r
-    /**\r
-     * A 4-byte unsigned integer that specifies a reference to a sound\r
-     * in the SoundCollectionContainer record to locate the embedded audio\r
-     *\r
-     * @param id reference to a sound\r
-     */\r
-    public void setSoundIdRef(int id){\r
-         LittleEndian.putInt(_recdata, 8, id);\r
-    }\r
-\r
-    /**\r
-     * A signed integer that specifies the delay time, in milliseconds, before the animation starts to play.\r
-     * If {@link #Automatic} is 0x1, this value MUST be greater than or equal to 0; otherwise, this field MUST be ignored.\r
-     */\r
-    public int getDelayTime(){\r
-        return LittleEndian.getInt(_recdata, 12);\r
-    }\r
-    /**\r
-     * A signed integer that specifies the delay time, in milliseconds, before the animation starts to play.\r
-     * If {@link #Automatic} is 0x1, this value MUST be greater than or equal to 0; otherwise, this field MUST be ignored.\r
-     */\r
-    public void setDelayTime(int id){\r
-         LittleEndian.putInt(_recdata, 12, id);\r
-    }\r
-\r
-    /**\r
-     * A signed integer that specifies the order of the animation in the slide.\r
-     * It MUST be greater than or equal to -2. The value -2 specifies that this animation follows the order of\r
-     * the corresponding placeholder shape on the main master slide or title master slide.\r
-     * The value -1 SHOULD NOT <105> be used.\r
-     */\r
-    public int getOrderID(){\r
-        return LittleEndian.getInt(_recdata, 16);\r
-    }\r
-\r
-    /**\r
-     * A signed integer that specifies the order of the animation in the slide.\r
-     * It MUST be greater than or equal to -2. The value -2 specifies that this animation follows the order of\r
-     * the corresponding placeholder shape on the main master slide or title master slide.\r
-     * The value -1 SHOULD NOT <105> be used.\r
-     */\r
-    public void setOrderID(int id){\r
-         LittleEndian.putInt(_recdata, 16, id);\r
-    }\r
-\r
-    /**\r
-     * An unsigned integer that specifies the number of slides that this animation continues playing.\r
-     * This field is utilized only in conjunction with media.\r
-     * The value 0xFFFFFFFF specifies that the animation plays for one slide.\r
-     */\r
-    public int getSlideCount(){\r
-        return LittleEndian.getInt(_recdata, 18);\r
-    }\r
-\r
-    /**\r
-     * An unsigned integer that specifies the number of slides that this animation continues playing.\r
-     * This field is utilized only in conjunction with media.\r
-     * The value 0xFFFFFFFF specifies that the animation plays for one slide.\r
-     */\r
-    public void setSlideCount(int id){\r
-         LittleEndian.putInt(_recdata, 18, id);\r
-    }\r
-\r
-    public String toString(){\r
-        StringBuffer buf = new StringBuffer();\r
-        buf.append("AnimationInfoAtom\n");\r
-        buf.append("\tDimColor: " + getDimColor() + "\n");\r
-        int mask = getMask();\r
-        buf.append("\tMask: " + mask + ", 0x"+Integer.toHexString(mask)+"\n");\r
-        buf.append("\t  Reverse: " + getFlag(Reverse)+"\n");\r
-        buf.append("\t  Automatic: " + getFlag(Automatic)+"\n");\r
-        buf.append("\t  Sound: " + getFlag(Sound)+"\n");\r
-        buf.append("\t  StopSound: " + getFlag(StopSound)+"\n");\r
-        buf.append("\t  Play: " + getFlag(Play)+"\n");\r
-        buf.append("\t  Synchronous: " + getFlag(Synchronous)+"\n");\r
-        buf.append("\t  Hide: " + getFlag(Hide)+"\n");\r
-        buf.append("\t  AnimateBg: " + getFlag(AnimateBg)+"\n");\r
-        buf.append("\tSoundIdRef: " + getSoundIdRef() + "\n");\r
-        buf.append("\tDelayTime: " + getDelayTime() + "\n");\r
-        buf.append("\tOrderID: " + getOrderID() + "\n");\r
-        buf.append("\tSlideCount: " + getSlideCount() + "\n");\r
-        return buf.toString();\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.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 the animation information for a shape.
+ *
+ * @author Yegor Kozlov
+ */
+public final class AnimationInfoAtom extends RecordAtom
+{
+
+    /**
+     * whether the animation plays in the reverse direction
+     */
+    public static final int Reverse = 1;
+    /**
+     * whether the animation starts automatically
+     */
+    public static final int Automatic = 4;
+    /**
+     * whether the animation has an associated sound
+     */
+    public static final int Sound = 16;
+    /**
+     * whether all playing sounds are stopped when this animation begins
+     */
+    public static final int StopSound = 64;
+    /**
+     * whether an associated sound, media or action verb is activated when the shape is clicked.
+     */
+    public static final int Play = 256;
+    /**
+     * specifies that the animation, while playing, stops other slide show actions.
+     */
+    public static final int Synchronous = 1024;
+    /**
+     * whether the shape is hidden while the animation is not playing
+     */
+    public static final int Hide = 4096;
+    /**
+     * whether the background of the shape is animated
+     */
+    public static final int AnimateBg = 16384;
+
+    /**
+     * Record header.
+     */
+    private byte[] _header;
+
+    /**
+     * record data
+     */
+    private byte[] _recdata;
+
+    /**
+     * Constructs a brand new link related atom record.
+     */
+    protected AnimationInfoAtom() {
+        _recdata = new byte[28];
+
+        _header = new byte[8];
+        LittleEndian.putShort(_header, 0, (short)0x01);
+        LittleEndian.putShort(_header, 2, (short)getRecordType());
+        LittleEndian.putInt(_header, 4, _recdata.length);
+    }
+
+    /**
+     * Constructs the link related atom record from its
+     *  source data.
+     *
+     * @param source the source data as a byte array.
+     * @param start the start offset into the byte array.
+     * @param len the length of the slice in the byte array.
+     */
+    protected AnimationInfoAtom(byte[] source, int start, int len) {
+        // Get the header
+        _header = new byte[8];
+        System.arraycopy(source,start,_header,0,8);
+
+        // Grab the record data
+        _recdata = new byte[len-8];
+        System.arraycopy(source,start+8,_recdata,0,len-8);
+    }
+
+    /**
+     * Gets the record type.
+     * @return the record type.
+     */
+    public long getRecordType() {
+        return RecordTypes.AnimationInfoAtom.typeID;
+    }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     * to disk
+     *
+     * @param out the output stream to write to.
+     * @throws java.io.IOException if an error occurs.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        out.write(_header);
+        out.write(_recdata);
+    }
+
+    /**
+     * A rgb structure that specifies a color for the dim effect after the animation is complete.
+     *
+     * @return  color for the dim effect after the animation is complete
+     */
+    public int getDimColor(){
+        return LittleEndian.getInt(_recdata, 0);
+    }
+
+    /**
+     * A rgb structure that specifies a color for the dim effect after the animation is complete.
+     *
+     * @param rgb  color for the dim effect after the animation is complete
+     */
+    public void setDimColor(int rgb){
+         LittleEndian.putInt(_recdata, 0, rgb);
+    }
+
+    /**
+     *  A bit mask specifying options for displaying headers and footers
+     *
+     * @return A bit mask specifying options for displaying headers and footers
+     */
+    public int getMask(){
+        return LittleEndian.getInt(_recdata, 4);
+    }
+
+    /**
+     *  A bit mask specifying options for displaying video
+     *
+     * @param mask A bit mask specifying options for displaying video
+     */
+    public void setMask(int mask){
+        LittleEndian.putInt(_recdata, 4, mask);
+    }
+
+    /**
+     * @param bit the bit to check
+     * @return whether the specified flag is set
+     */
+    public boolean getFlag(int bit){
+        return (getMask() & bit) != 0;
+    }
+
+    /**
+     * @param  bit the bit to set
+     * @param  value whether the specified bit is set
+     */
+    public void setFlag(int bit, boolean value){
+        int mask = getMask();
+        if(value) mask |= bit;
+        else mask &= ~bit;
+        setMask(mask);
+    }
+
+    /**
+     * A 4-byte unsigned integer that specifies a reference to a sound
+     * in the SoundCollectionContainer record to locate the embedded audio
+     *
+     * @return  reference to a sound
+     */
+    public int getSoundIdRef(){
+        return LittleEndian.getInt(_recdata, 8);
+    }
+
+    /**
+     * A 4-byte unsigned integer that specifies a reference to a sound
+     * in the SoundCollectionContainer record to locate the embedded audio
+     *
+     * @param id reference to a sound
+     */
+    public void setSoundIdRef(int id){
+         LittleEndian.putInt(_recdata, 8, id);
+    }
+
+    /**
+     * A signed integer that specifies the delay time, in milliseconds, before the animation starts to play.
+     * If {@link #Automatic} is 0x1, this value MUST be greater than or equal to 0; otherwise, this field MUST be ignored.
+     */
+    public int getDelayTime(){
+        return LittleEndian.getInt(_recdata, 12);
+    }
+    /**
+     * A signed integer that specifies the delay time, in milliseconds, before the animation starts to play.
+     * If {@link #Automatic} is 0x1, this value MUST be greater than or equal to 0; otherwise, this field MUST be ignored.
+     */
+    public void setDelayTime(int id){
+         LittleEndian.putInt(_recdata, 12, id);
+    }
+
+    /**
+     * A signed integer that specifies the order of the animation in the slide.
+     * It MUST be greater than or equal to -2. The value -2 specifies that this animation follows the order of
+     * the corresponding placeholder shape on the main master slide or title master slide.
+     * The value -1 SHOULD NOT <105> be used.
+     */
+    public int getOrderID(){
+        return LittleEndian.getInt(_recdata, 16);
+    }
+
+    /**
+     * A signed integer that specifies the order of the animation in the slide.
+     * It MUST be greater than or equal to -2. The value -2 specifies that this animation follows the order of
+     * the corresponding placeholder shape on the main master slide or title master slide.
+     * The value -1 SHOULD NOT <105> be used.
+     */
+    public void setOrderID(int id){
+         LittleEndian.putInt(_recdata, 16, id);
+    }
+
+    /**
+     * An unsigned integer that specifies the number of slides that this animation continues playing.
+     * This field is utilized only in conjunction with media.
+     * The value 0xFFFFFFFF specifies that the animation plays for one slide.
+     */
+    public int getSlideCount(){
+        return LittleEndian.getInt(_recdata, 18);
+    }
+
+    /**
+     * An unsigned integer that specifies the number of slides that this animation continues playing.
+     * This field is utilized only in conjunction with media.
+     * The value 0xFFFFFFFF specifies that the animation plays for one slide.
+     */
+    public void setSlideCount(int id){
+         LittleEndian.putInt(_recdata, 18, id);
+    }
+
+    public String toString(){
+        StringBuffer buf = new StringBuffer();
+        buf.append("AnimationInfoAtom\n");
+        buf.append("\tDimColor: " + getDimColor() + "\n");
+        int mask = getMask();
+        buf.append("\tMask: " + mask + ", 0x"+Integer.toHexString(mask)+"\n");
+        buf.append("\t  Reverse: " + getFlag(Reverse)+"\n");
+        buf.append("\t  Automatic: " + getFlag(Automatic)+"\n");
+        buf.append("\t  Sound: " + getFlag(Sound)+"\n");
+        buf.append("\t  StopSound: " + getFlag(StopSound)+"\n");
+        buf.append("\t  Play: " + getFlag(Play)+"\n");
+        buf.append("\t  Synchronous: " + getFlag(Synchronous)+"\n");
+        buf.append("\t  Hide: " + getFlag(Hide)+"\n");
+        buf.append("\t  AnimateBg: " + getFlag(AnimateBg)+"\n");
+        buf.append("\tSoundIdRef: " + getSoundIdRef() + "\n");
+        buf.append("\tDelayTime: " + getDelayTime() + "\n");
+        buf.append("\tOrderID: " + getOrderID() + "\n");
+        buf.append("\tSlideCount: " + getSlideCount() + "\n");
+        return buf.toString();
+    }
+
+}
index e7e46baa00b2409f0e0ee289770e234f09091dc4..a428621e634af26e6fdaeaf8eda156dee6b35409 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hslf.record;
 
 import java.io.IOException;
@@ -30,15 +31,15 @@ import org.apache.poi.util.StringUtil;
  * @author Nick Burch
  */
 
-public class CString extends RecordAtom {
+public final class CString extends RecordAtom {
        private byte[] _header;
        private static long _type = 4026l;
-       
+
        /** The bytes that make up the text */
        private byte[] _text;
-       
+
        /** Grabs the text. */
-       public String getText() { 
+       public String getText() {
                return StringUtil.getFromUnicodeLE(_text);
        }
 
@@ -51,18 +52,18 @@ public class CString extends RecordAtom {
                // Update the size (header bytes 5-8)
                LittleEndian.putInt(_header,4,_text.length);
        }
-       
-       /** 
+
+       /**
         * Grabs the count, from the first two bytes of the header.
-        * The meaning of the count is specific to the type of the parent record 
+        * The meaning of the count is specific to the type of the parent record
         */
        public int getOptions() {
                return (int)LittleEndian.getShort(_header);
        }
-       
-       /** 
+
+       /**
         * Sets the count
-        * The meaning of the count is specific to the type of the parent record 
+        * The meaning of the count is specific to the type of the parent record
         */
        public void setOptions(int count) {
                LittleEndian.putShort(_header, (short)count);
@@ -70,8 +71,8 @@ public class CString extends RecordAtom {
 
        /* *************** record code follows ********************** */
 
-       /** 
-        * For the CStrubg Atom 
+       /**
+        * For the CStrubg Atom
         */
        protected CString(byte[] source, int start, int len) {
                // Sanity Checking
index 4e9e029fd3a3ad072d7e4fc512eda8760b31bc0b..4aea93f869a6eb85a43c7ee35b0798836dcf86f6 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.hslf.record;
 
@@ -27,13 +25,13 @@ import java.io.ByteArrayOutputStream;
 /**
  * A ColorSchemeAtom (type 2032). Holds the 8 RGB values for the different
  *  colours of bits of text, that makes up a given colour scheme.
- * Slides (presumably) link to a given colour scheme atom, and that 
+ * Slides (presumably) link to a given colour scheme atom, and that
  *  defines the colours to be used
  *
  * @author Nick Burch
  */
 
-public class ColorSchemeAtom extends RecordAtom
+public final class ColorSchemeAtom extends RecordAtom
 {
        private byte[] _header;
        private static long _type = 2032l;
@@ -85,7 +83,7 @@ public class ColorSchemeAtom extends RecordAtom
                        { accentAndHyperlinkColourRGB = rgb; }
 
        /** Fetch the RGB value for Accent And Following Hyperlink Colour */
-       public int getAccentAndFollowingHyperlinkColourRGB() 
+       public int getAccentAndFollowingHyperlinkColourRGB()
                { return accentAndFollowingHyperlinkColourRGB; }
        /** Set the RGB value for Accent And Following Hyperlink Colour */
        public void setAccentAndFollowingHyperlinkColourRGB(int rgb)
@@ -93,7 +91,7 @@ public class ColorSchemeAtom extends RecordAtom
 
        /* *************** record code follows ********************** */
 
-       /** 
+       /**
         * For the Colour Scheme (ColorSchem) Atom
         */
        protected ColorSchemeAtom(byte[] source, int start, int len) {
@@ -119,7 +117,7 @@ public class ColorSchemeAtom extends RecordAtom
                accentAndHyperlinkColourRGB = (int)LittleEndian.getInt(source,start+8+24);
                accentAndFollowingHyperlinkColourRGB = (int)LittleEndian.getInt(source,start+8+28);
        }
-       
+
        /**
         * Create a new ColorSchemeAtom, to go with a new Slide
         */
@@ -128,7 +126,7 @@ public class ColorSchemeAtom extends RecordAtom
                LittleEndian.putUShort(_header, 0, 16);
                LittleEndian.putUShort(_header, 2, (int)_type);
                LittleEndian.putInt(_header, 4, 32);
-                
+
                // Setup the default rgb values
                backgroundColourRGB = 16777215;
                textAndLinesColourRGB = 0;
@@ -139,7 +137,7 @@ public class ColorSchemeAtom extends RecordAtom
                accentAndHyperlinkColourRGB = 16764108;
                accentAndFollowingHyperlinkColourRGB = 11711154;
        }
-       
+
 
        /**
         * We are of type 3999
index 31ef11a66c6ef8c7a86ca629278cac62f63c65d2..0a65cdbffd8869a4232093dad4d6997fba79140b 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hslf.record;
 
 import java.io.IOException;
@@ -23,24 +24,24 @@ import org.apache.poi.util.LittleEndian;
 
 /**
  * This class represents a comment on a slide, in the format used by
- *  PPT 2000/XP/etc. (PPT 97 uses plain Escher Text Boxes for comments) 
+ *  PPT 2000/XP/etc. (PPT 97 uses plain Escher Text Boxes for comments)
  * @author Nick Burch
  */
-public class Comment2000 extends RecordContainer {
+public final class Comment2000 extends RecordContainer {
        private byte[] _header;
        private static long _type = 12000;
-       
+
        // Links to our more interesting children
        private CString authorRecord;
        private CString authorInitialsRecord;
        private CString commentRecord;
-       private Comment2000Atom commentAtom; 
-       
-       /** 
+       private Comment2000Atom commentAtom;
+
+       /**
         * Returns the Comment2000Atom of this Comment
-        */ 
+        */
        public Comment2000Atom getComment2000Atom() { return commentAtom; }
-       
+
        /**
         * Get the Author of this comment
         */
@@ -79,8 +80,8 @@ public class Comment2000 extends RecordContainer {
        public void setText(String text) {
                commentRecord.setText(text);
        }
-       
-       /** 
+
+       /**
         * Set things up, and find our more interesting children
         */
        protected Comment2000(byte[] source, int start, int len) {
@@ -97,7 +98,7 @@ public class Comment2000 extends RecordContainer {
         * Go through our child records, picking out the ones that are
         *  interesting, and saving those for use by the easy helper
         *  methods.
-        */     
+        */
        private void findInterestingChildren() {
                // First child should be the author
                if(_children[0] instanceof CString) {
@@ -124,18 +125,18 @@ public class Comment2000 extends RecordContainer {
                        throw new IllegalStateException("Fourth child record wasn't a Comment2000Atom, was of type " + _children[3].getRecordType());
                }
        }
-       
+
        /**
         * Create a new Comment2000, with blank fields
         */
        public Comment2000() {
                _header = new byte[8];
                _children = new Record[4];
-               
+
                // Setup our header block
                _header[0] = 0x0f; // We are a container record
                LittleEndian.putShort(_header, 2, (short)_type);
-               
+
                // Setup our child records
                CString csa = new CString();
                CString csb = new CString();
index be8dc8dab8b031b8195813bc753e04324f213aa0..ab38e88d1c0e859257703edabb3999b77e327341 100644 (file)
@@ -14,7 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hslf.record;
 
@@ -31,7 +30,7 @@ import org.apache.poi.util.LittleEndian;
  * @author Daniel Noll
  */
 
-public class Comment2000Atom extends RecordAtom
+public final class Comment2000Atom extends RecordAtom
 {
     /**
      * Record header.
@@ -52,7 +51,7 @@ public class Comment2000Atom extends RecordAtom
 
         LittleEndian.putShort(_header, 2, (short)getRecordType());
         LittleEndian.putInt(_header, 4, _data.length);
-        
+
         // It is fine for the other values to be zero
     }
 
@@ -67,7 +66,7 @@ public class Comment2000Atom 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);
index 3284153cb132f77b71ab4efc69f7743cc56384e4..069d877a0a8123e2a20884517e52221e8a3cd6c6 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.hslf.record;
 
@@ -25,13 +23,13 @@ import java.io.IOException;
 import java.io.OutputStream;
 
 /**
- * Master container for Document. There is one of these for every 
+ * Master container for Document. There is one of these for every
  *  slideshow, and it holds lots of definitions, and some summaries.
  *
  * @author Nick Burch
  */
 
-public class Document extends PositionDependentRecordContainer
+public final class Document extends PositionDependentRecordContainer
 {
        private byte[] _header;
        private static long _type = 1000;
@@ -58,12 +56,12 @@ public class Document extends PositionDependentRecordContainer
         */
        public PPDrawingGroup getPPDrawingGroup() { return ppDrawing; }
        /**
-        * Returns the ExObjList, which holds the references to 
+        * Returns the ExObjList, which holds the references to
         *  external objects used in the slides. This may be null, if
         *  there are no external references.
         */
        public ExObjList getExObjList() { return exObjList; }
-       
+
        /**
         * Returns all the SlideListWithTexts that are defined for
         *  this Document. They hold the text, and some of the text
@@ -74,9 +72,9 @@ public class Document extends PositionDependentRecordContainer
 
     /**
         * Returns the SlideListWithText that deals with the
-        *  Master Slides 
+        *  Master Slides
         */
-       public SlideListWithText getMasterSlideListWithText() { 
+       public SlideListWithText getMasterSlideListWithText() {
         for (int i = 0; i < slwts.length; i++) {
             if(slwts[i].getInstance() == SlideListWithText.MASTER) {
                 return slwts[i];
@@ -111,7 +109,7 @@ public class Document extends PositionDependentRecordContainer
     }
 
 
-       /** 
+       /**
         * Set things up, and find our more interesting children
         */
        protected Document(byte[] source, int start, int len) {
@@ -146,7 +144,7 @@ public class Document extends PositionDependentRecordContainer
                                exObjList = (ExObjList)_children[i];
                        }
                }
-               
+
                // You should only every have 1, 2 or 3 SLWTs
                //  (normally it's 2, or 3 if you have notes)
                // Complain if it's not
@@ -156,7 +154,7 @@ public class Document extends PositionDependentRecordContainer
                if(slwtcount > 3) {
                        logger.log(POILogger.WARN, "Found " + slwtcount + " SlideListWithTexts - normally there should only be three!");
                }
-               
+
                // Now grab all the SLWTs
                slwts = new SlideListWithText[slwtcount];
                slwtcount = 0;
@@ -167,22 +165,22 @@ public class Document extends PositionDependentRecordContainer
                        }
                }
        }
-       
+
        /**
-        * Adds a new SlideListWithText record, at the appropriate 
+        * Adds a new SlideListWithText record, at the appropriate
         *  point in the child records.
         */
        public void addSlideListWithText(SlideListWithText slwt) {
-               // The new SlideListWithText should go in 
+               // The new SlideListWithText should go in
                //  just before the EndDocumentRecord
                Record endDoc = _children[_children.length - 1];
                if(endDoc.getRecordType() != RecordTypes.EndDocument.typeID) {
                        throw new IllegalStateException("The last child record of a Document should be EndDocument, but it was " + endDoc);
                }
-               
+
                // Add in the record
                addChildBefore(slwt, endDoc);
-                       
+
                // Updated our cached list of SlideListWithText records
                int newSize = slwts.length + 1;
                SlideListWithText[] nl = new SlideListWithText[newSize];
index 86bf5ce14e4c3823570f3a442ccde3e234690f47..3b28ab56a50a86350c37eb1f23465204edfe4299 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.hslf.record;
 
@@ -30,7 +28,7 @@ import java.io.OutputStream;
  * @author Nick Burch
  */
 
-public class DocumentAtom extends RecordAtom
+public final class DocumentAtom extends RecordAtom
 {
        private byte[] _header;
        private static long _type = 1001l;
@@ -96,7 +94,7 @@ public class DocumentAtom extends RecordAtom
 
        /* *************** record code follows ********************** */
 
-       /** 
+       /**
         * For the Document Atom
         */
        protected DocumentAtom(byte[] source, int start, int len) {
index 78e845af29625b12b9e31072cedae7a482ec474c..bf7860454a7189656c8e27c237bf84461f9d8bc8 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.hslf.record;
 
@@ -32,7 +30,7 @@ import java.io.OutputStream;
  * @author Nick Burch
  */
 
-public class DocumentEncryptionAtom extends RecordAtom
+public final class DocumentEncryptionAtom extends RecordAtom
 {
        private byte[] _header;
        private static long _type = 12052l;
@@ -40,7 +38,7 @@ public class DocumentEncryptionAtom extends RecordAtom
        private byte[] data;
        private String encryptionProviderName;
 
-       /** 
+       /**
         * For the Document Encryption Atom
         */
        protected DocumentEncryptionAtom(byte[] source, int start, int len) {
@@ -67,21 +65,21 @@ public class DocumentEncryptionAtom extends RecordAtom
                int stringLen = (endPos-pos) / 2;
                encryptionProviderName = StringUtil.getFromUnicodeLE(source, pos, stringLen);
        }
-       
+
        /**
         * Return the length of the encryption key, in bits
         */
        public int getKeyLength() {
                return data[28];
        }
-       
+
        /**
         * Return the name of the encryption provider used
         */
        public String getEncryptionProviderName() {
                return encryptionProviderName;
        }
-       
+
 
        /**
         * We are of type 12052
index c41ce6b80a94697c64e3b3f4800b5cb7b9266d3d..285f824b4303b4e2711d3353c47e0417eb07a501 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.hslf.record;
 
@@ -35,12 +33,12 @@ import java.io.OutputStream;
  * @author Nick Burch
  */
 
-public class DummyPositionSensitiveRecordWithChildren extends PositionDependentRecordContainer
+public final class DummyPositionSensitiveRecordWithChildren extends PositionDependentRecordContainer
 {
        private byte[] _header;
        private long _type;
 
-       /** 
+       /**
         * Create a new holder for a boring record with children, but with
         *  position dependent characteristics
         */
index d5dfcb41ebbf7e657ae09dc71c59dddbd0265708..18dea58923ea9cf048d966b5cbf1cbbedda2c59b 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.hslf.record;
 
@@ -31,12 +29,12 @@ import java.io.OutputStream;
  * @author Nick Burch
  */
 
-public class DummyRecordWithChildren extends RecordContainer
+public final class DummyRecordWithChildren extends RecordContainer
 {
        private byte[] _header;
        private long _type;
 
-       /** 
+       /**
         * Create a new holder for a boring record with children
         */
        protected DummyRecordWithChildren(byte[] source, int start, int len) {
index e17fe126004bb19cc28b762000ff1080e07d1140..eb66f2a288bbb77d517fbbf593fc80ed7feae62e 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.hslf.record;
 
@@ -23,12 +21,12 @@ import java.io.IOException;
 import java.io.OutputStream;
 
 /**
- * Environment, which contains lots of settings for the document. 
+ * Environment, which contains lots of settings for the document.
  *
  * @author Nick Burch
  */
 
-public class Environment extends PositionDependentRecordContainer
+public final class Environment extends PositionDependentRecordContainer
 {
        private byte[] _header;
        private static long _type = 1010;
@@ -44,7 +42,7 @@ public class Environment extends PositionDependentRecordContainer
        public FontCollection getFontCollection() { return fontCollection; }
 
 
-       /** 
+       /**
         * Set things up, and find our more interesting children
         */
        protected Environment(byte[] source, int start, int len) {
@@ -54,7 +52,7 @@ public class Environment extends PositionDependentRecordContainer
 
                // Find our children
                _children = Record.findChildRecords(source,start+8,len-8);
-               
+
                // Find our FontCollection record
                for(int i=0; i<_children.length; i++) {
                        if(_children[i] instanceof FontCollection) {
@@ -63,7 +61,7 @@ public class Environment extends PositionDependentRecordContainer
                 txmaster = (TxMasterStyleAtom)_children[i];
             }
                }
-               
+
                if(fontCollection == null) {
                        throw new IllegalStateException("Environment didn't contain a FontCollection record!");
                }
index 142eee88fcc08481b7b91554729be019e97b818a..8476d3dd56bba54337b3c97245517c93008c2d96 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.hslf.record;
 
@@ -26,7 +24,7 @@ import java.io.OutputStream;
 import java.io.ByteArrayOutputStream;
 
 /**
- * A wrapper around a DDF (Escher) EscherTextbox Record. Causes the DDF 
+ * A wrapper around a DDF (Escher) EscherTextbox Record. Causes the DDF
  *  Record to be accessible as if it were a HSLF record.
  * Note: when asked to write out, will simply put any child records correctly
  *  into the Escher layer. A call to the escher layer to write out (by the
@@ -35,7 +33,7 @@ import java.io.ByteArrayOutputStream;
  * @author Nick Burch
  */
 
-public class EscherTextboxWrapper extends RecordContainer
+public final class EscherTextboxWrapper extends RecordContainer
 {
        private EscherTextboxRecord _escherRecord;
        private long _type;
@@ -46,7 +44,7 @@ public class EscherTextboxWrapper extends RecordContainer
         */
        public EscherTextboxRecord getEscherRecord() { return _escherRecord; }
 
-       /** 
+       /**
         * Creates the wrapper for the given DDF Escher Record and children
         */
        public EscherTextboxWrapper(EscherTextboxRecord textbox) {
@@ -57,7 +55,7 @@ public class EscherTextboxWrapper extends RecordContainer
                byte[] data = _escherRecord.getData();
                _children = Record.findChildRecords(data,0,data.length);
        }
-       
+
        /**
         * Creates a new, empty wrapper for DDF Escher Records and their children
         */
@@ -68,7 +66,7 @@ public class EscherTextboxWrapper extends RecordContainer
 
                _children = new Record[0];
        }
-       
+
 
        /**
         * Return the type of the escher record (normally in the 0xFnnn range)
index 81ad98d9b7e8c28d4e1a52a51e8897bc0726bbc5..5d09e53a1989cd35ccd3bf6482556701050e14c7 100755 (executable)
@@ -1,53 +1,54 @@
-/*\r
-* Licensed to the Apache Software Foundation (ASF) under one or more\r
-* contributor license agreements.  See the NOTICE file distributed with\r
-* this work for additional information regarding copyright ownership.\r
-* The ASF licenses this file to You under the Apache License, Version 2.0\r
-* (the "License"); you may not use this file except in compliance with\r
-* the License.  You may obtain a copy of the License at\r
-*\r
-*     http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*/\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-import org.apache.poi.util.POILogger;\r
-\r
-/**\r
- * A container record that specifies information about a movie stored externally.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class ExAviMovie extends ExMCIMovie {\r
-\r
-    /**\r
-     * Set things up, and find our more interesting children\r
-     */\r
-    protected ExAviMovie(byte[] source, int start, int len) {\r
-        super(source, start, len);\r
-    }\r
-\r
-    /**\r
-     * Create a new ExAviMovie, with blank fields\r
-     */\r
-    public ExAviMovie() {\r
-        super();\r
-\r
-    }\r
-    /**\r
-     * We are of type 4102\r
-     */\r
-    public long getRecordType() {\r
-        return RecordTypes.ExAviMovie.typeID;\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.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.
+ *
+ * @author Yegor Kozlov
+ */
+public final class ExAviMovie extends ExMCIMovie {
+
+    /**
+     * Set things up, and find our more interesting children
+     */
+    protected ExAviMovie(byte[] source, int start, int len) {
+        super(source, start, len);
+    }
+
+    /**
+     * Create a new ExAviMovie, with blank fields
+     */
+    public ExAviMovie() {
+        super();
+
+    }
+    /**
+     * We are of type 4102
+     */
+    public long getRecordType() {
+        return RecordTypes.ExAviMovie.typeID;
+    }
+
+}
index 603cbad764800e6de61c6520850d7bf8def93c57..7df5a903dbf6d03593a3a5c22399a85580b76fb1 100755 (executable)
@@ -1,82 +1,82 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.OutputStream;\r
-import java.io.IOException;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-import org.apache.poi.util.POILogger;\r
-\r
-/**\r
- * A container record that specifies information about an ActiveX control. It contains:\r
- * <p>\r
- * 1. ExControlAtom (4091)\r
- * 2. ExOleObjAtom (4035)\r
- * 3. CString (4026), Instance MenuName (1) used for menus and the Links dialog box.\r
- * 4. CString (4026), Instance ProgID (2) that stores the OLE Programmatic Identifier.\r
- *  A ProgID is a string that uniquely identifies a given object.\r
- * 5. CString (4026), Instance ClipboardName (3) that appears in the paste special dialog.\r
- * 6. MetaFile( 4033), optional\r
- * </p>\r
- *\r
- *\r
- * @author Yegor kozlov\r
- */\r
-public class ExControl extends ExEmbed {\r
-\r
-    /**\r
-     * Set things up, and find our more interesting children\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start the start offset into the byte array.\r
-     * @param len the length of the slice in the byte array.\r
-     */\r
-    protected ExControl(byte[] source, int start, int len) {\r
-        super(source, start, len);\r
-    }\r
-\r
-    /**\r
-     * Create a new ExEmbed, with blank fields\r
-     */\r
-    public ExControl() {\r
-        super();\r
-\r
-        _children[0] = embedAtom = new ExControlAtom();\r
-    }\r
-\r
-    /**\r
-     * Gets the {@link ExControlAtom}.\r
-     *\r
-     * @return the {@link ExControlAtom}.\r
-     */\r
-    public ExControlAtom getExControlAtom()\r
-    {\r
-        return (ExControlAtom)_children[0];\r
-    }\r
-\r
-    /**\r
-     * Returns the type (held as a little endian in bytes 3 and 4)\r
-     * that this class handles.\r
-     *\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() {\r
-        return RecordTypes.ExControl.typeID;\r
-    }\r
-}\r
+/* ====================================================================
+   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.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:
+ * <p>
+ * 1. ExControlAtom (4091)
+ * 2. ExOleObjAtom (4035)
+ * 3. CString (4026), Instance MenuName (1) used for menus and the Links dialog box.
+ * 4. CString (4026), Instance ProgID (2) that stores the OLE Programmatic Identifier.
+ *  A ProgID is a string that uniquely identifies a given object.
+ * 5. CString (4026), Instance ClipboardName (3) that appears in the paste special dialog.
+ * 6. MetaFile( 4033), optional
+ * </p>
+ *
+ *
+ * @author Yegor kozlov
+ */
+public final class ExControl extends ExEmbed {
+
+    /**
+     * Set things up, and find our more interesting children
+     *
+     * @param source the source data as a byte array.
+     * @param start the start offset into the byte array.
+     * @param len the length of the slice in the byte array.
+     */
+    protected ExControl(byte[] source, int start, int len) {
+        super(source, start, len);
+    }
+
+    /**
+     * Create a new ExEmbed, with blank fields
+     */
+    public ExControl() {
+        super();
+
+        _children[0] = embedAtom = new ExControlAtom();
+    }
+
+    /**
+     * Gets the {@link ExControlAtom}.
+     *
+     * @return the {@link ExControlAtom}.
+     */
+    public ExControlAtom getExControlAtom()
+    {
+        return (ExControlAtom)_children[0];
+    }
+
+    /**
+     * Returns the type (held as a little endian in bytes 3 and 4)
+     * that this class handles.
+     *
+     * @return the record type.
+     */
+    public long getRecordType() {
+        return RecordTypes.ExControl.typeID;
+    }
+}
index 0204803ea5ae59d2a4508181772fa4c5998d7e48..951b5759ebd2e09216d574cb341cf118a7bc53b1 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-\r
-/**\r
- * An atom record that specifies an ActiveX control.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class ExControlAtom extends RecordAtom {\r
-\r
-\r
-    /**\r
-     * Record header.\r
-     */\r
-    private byte[] _header;\r
-\r
-    /**\r
-     * slideId.\r
-     */\r
-    private int _id;\r
-\r
-    /**\r
-     * Constructs a brand new embedded object atom record.\r
-     */\r
-    protected ExControlAtom() {\r
-        _header = new byte[8];\r
-\r
-        LittleEndian.putShort(_header, 2, (short) getRecordType());\r
-        LittleEndian.putInt(_header, 4, 4);\r
-\r
-    }\r
-\r
-    /**\r
-     * Constructs the ExControlAtom record from its source data.\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start  the start offset into the byte array.\r
-     * @param len    the length of the slice in the byte array.\r
-     */\r
-    protected ExControlAtom(byte[] source, int start, int len) {\r
-        // Get the header.\r
-        _header = new byte[8];\r
-        System.arraycopy(source, start, _header, 0, 8);\r
-\r
-        _id = LittleEndian.getInt(source, start + 8);\r
-    }\r
-\r
-    /**\r
-     * An integer that specifies which presentation slide is associated with the ActiveX control.\r
-     * <p>\r
-     * It MUST be 0x00000000 or equal to the value of the slideId field of a SlidePersistAtom record.\r
-     * The value 0x00000000 specifies a null reference.\r
-     * </p>\r
-     *\r
-     * @return an integer that specifies which presentation slide is associated with the ActiveX control\r
-     */\r
-    public int getSlideId() {\r
-        return _id;\r
-    }\r
-\r
-    /**\r
-     * Sets which presentation slide is associated with the ActiveX control.\r
-     *\r
-     * @param id an integer that specifies which presentation slide is associated with the ActiveX control\r
-     * <p>\r
-     * It MUST be 0x00000000 or equal to the value of the slideId field of a SlidePersistAtom record.\r
-     * The value 0x00000000 specifies a null reference.\r
-     * </p>\r
-     */\r
-    public void setSlideId(int id) {\r
-        _id = id;\r
-    }\r
-\r
-    /**\r
-     * Gets the record type.\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() {\r
-        return RecordTypes.ExControlAtom.typeID;\r
-    }\r
-\r
-    /**\r
-     * Write the contents of the record back, so it can be written\r
-     * to disk\r
-     *\r
-     * @param out the output stream to write to.\r
-     * @throws java.io.IOException if an error occurs.\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        out.write(_header);\r
-        byte[] data = new byte[4];\r
-        LittleEndian.putInt(data, _id);\r
-        out.write(data);\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.hslf.record;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.poi.util.LittleEndian;
+
+/**
+ * An atom record that specifies an ActiveX control.
+ *
+ * @author Yegor Kozlov
+ */
+public final class ExControlAtom extends RecordAtom {
+
+
+    /**
+     * Record header.
+     */
+    private byte[] _header;
+
+    /**
+     * slideId.
+     */
+    private int _id;
+
+    /**
+     * Constructs a brand new embedded object atom record.
+     */
+    protected ExControlAtom() {
+        _header = new byte[8];
+
+        LittleEndian.putShort(_header, 2, (short) getRecordType());
+        LittleEndian.putInt(_header, 4, 4);
+
+    }
+
+    /**
+     * Constructs the ExControlAtom record from its source data.
+     *
+     * @param source the source data as a byte array.
+     * @param start  the start offset into the byte array.
+     * @param len    the length of the slice in the byte array.
+     */
+    protected ExControlAtom(byte[] source, int start, int len) {
+        // Get the header.
+        _header = new byte[8];
+        System.arraycopy(source, start, _header, 0, 8);
+
+        _id = LittleEndian.getInt(source, start + 8);
+    }
+
+    /**
+     * An integer that specifies which presentation slide is associated with the ActiveX control.
+     * <p>
+     * It MUST be 0x00000000 or equal to the value of the slideId field of a SlidePersistAtom record.
+     * The value 0x00000000 specifies a null reference.
+     * </p>
+     *
+     * @return an integer that specifies which presentation slide is associated with the ActiveX control
+     */
+    public int getSlideId() {
+        return _id;
+    }
+
+    /**
+     * Sets which presentation slide is associated with the ActiveX control.
+     *
+     * @param id an integer that specifies which presentation slide is associated with the ActiveX control
+     * <p>
+     * It MUST be 0x00000000 or equal to the value of the slideId field of a SlidePersistAtom record.
+     * The value 0x00000000 specifies a null reference.
+     * </p>
+     */
+    public void setSlideId(int id) {
+        _id = id;
+    }
+
+    /**
+     * Gets the record type.
+     * @return the record type.
+     */
+    public long getRecordType() {
+        return RecordTypes.ExControlAtom.typeID;
+    }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     * to disk
+     *
+     * @param out the output stream to write to.
+     * @throws java.io.IOException if an error occurs.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        out.write(_header);
+        byte[] data = new byte[4];
+        LittleEndian.putInt(data, _id);
+        out.write(data);
+    }
+
+}
index c22609206d5a12a3d59e625e153af7379a40b23a..7d241758792905867b0e436851746afb5ed97c3b 100755 (executable)
-/*\r
-* Licensed to the Apache Software Foundation (ASF) under one or more\r
-* contributor license agreements.  See the NOTICE file distributed with\r
-* this work for additional information regarding copyright ownership.\r
-* The ASF licenses this file to You under the Apache License, Version 2.0\r
-* (the "License"); you may not use this file except in compliance with\r
-* the License.  You may obtain a copy of the License at\r
-*\r
-*     http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*/\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-import org.apache.poi.util.POILogger;\r
-\r
-/**\r
- * A container record that specifies information about a movie stored externally.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class ExMCIMovie extends RecordContainer {\r
-    private byte[] _header;\r
-\r
-    //An ExVideoContainer record that specifies information about the MCI movie\r
-    private ExVideoContainer exVideo;\r
-\r
-    /**\r
-     * Set things up, and find our more interesting children\r
-     */\r
-    protected ExMCIMovie(byte[] source, int start, int len) {\r
-        // Grab the header\r
-        _header = new byte[8];\r
-        System.arraycopy(source, start, _header, 0, 8);\r
-\r
-        // Find our children\r
-        _children = Record.findChildRecords(source, start + 8, len - 8);\r
-        findInterestingChildren();\r
-    }\r
-\r
-    /**\r
-     * Create a new ExMCIMovie, with blank fields\r
-     */\r
-    public ExMCIMovie() {\r
-        _header = new byte[8];\r
-        // Setup our header block\r
-        _header[0] = 0x0f; // We are a container record\r
-        LittleEndian.putShort(_header, 2, (short) getRecordType());\r
-\r
-        exVideo = new ExVideoContainer();\r
-        _children = new Record[]{exVideo};\r
-\r
-    }\r
-\r
-    /**\r
-     * Go through our child records, picking out the ones that are\r
-     * interesting, and saving those for use by the easy helper\r
-     * methods.\r
-     */\r
-    private void findInterestingChildren() {\r
-\r
-        // First child should be the ExVideoContainer\r
-        if (_children[0] instanceof ExVideoContainer) {\r
-            exVideo = (ExVideoContainer) _children[0];\r
-        } else {\r
-            logger.log(POILogger.ERROR, "First child record wasn't a ExVideoContainer, was of type " + _children[0].getRecordType());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * We are of type 4103\r
-     */\r
-    public long getRecordType() {\r
-        return RecordTypes.ExMCIMovie.typeID;\r
-    }\r
-\r
-    /**\r
-     * Write the contents of the record back, so it can be written\r
-     * to disk\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        writeOut(_header[0], _header[1], getRecordType(), _children, out);\r
-    }\r
-\r
-    /**\r
-     * Returns the ExVideoContainer that specifies information about the MCI movie\r
-     */\r
-    public ExVideoContainer getExVideo() {\r
-        return exVideo; }\r
-\r
-\r
-}\r
+/* ====================================================================
+   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.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.
+ *
+ * @author Yegor Kozlov
+ */
+public class ExMCIMovie extends RecordContainer { // TODO - instantiable superclass
+    private byte[] _header;
+
+    //An ExVideoContainer record that specifies information about the MCI movie
+    private ExVideoContainer exVideo;
+
+    /**
+     * Set things up, and find our more interesting children
+     */
+    protected ExMCIMovie(byte[] source, int start, int len) {
+        // Grab the header
+        _header = new byte[8];
+        System.arraycopy(source, start, _header, 0, 8);
+
+        // Find our children
+        _children = Record.findChildRecords(source, start + 8, len - 8);
+        findInterestingChildren();
+    }
+
+    /**
+     * Create a new ExMCIMovie, with blank fields
+     */
+    public ExMCIMovie() {
+        _header = new byte[8];
+        // Setup our header block
+        _header[0] = 0x0f; // We are a container record
+        LittleEndian.putShort(_header, 2, (short) getRecordType());
+
+        exVideo = new ExVideoContainer();
+        _children = new Record[]{exVideo};
+
+    }
+
+    /**
+     * Go through our child records, picking out the ones that are
+     * interesting, and saving those for use by the easy helper
+     * methods.
+     */
+    private void findInterestingChildren() {
+
+        // First child should be the ExVideoContainer
+        if (_children[0] instanceof ExVideoContainer) {
+            exVideo = (ExVideoContainer) _children[0];
+        } else {
+            logger.log(POILogger.ERROR, "First child record wasn't a ExVideoContainer, was of type " + _children[0].getRecordType());
+        }
+    }
+
+    /**
+     * We are of type 4103
+     */
+    public long getRecordType() {
+        return RecordTypes.ExMCIMovie.typeID;
+    }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     * to disk
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        writeOut(_header[0], _header[1], getRecordType(), _children, out);
+    }
+
+    /**
+     * Returns the ExVideoContainer that specifies information about the MCI movie
+     */
+    public ExVideoContainer getExVideo() {
+        return exVideo; }
+
+
+}
index e80768f30f442477f2385d69458d56950cf8a784..ee38bece75ac83a0aa536ceeb58195cda636470d 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-import java.util.Date;\r
-\r
-import org.apache.poi.hslf.util.SystemTimeUtils;\r
-import org.apache.poi.util.LittleEndian;\r
-\r
-/**\r
- * An atom record that specifies information about external audio or video data.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class ExMediaAtom extends RecordAtom\r
-{\r
-\r
-    /**\r
-     * A bit that specifies whether the audio or video data is repeated continuously during playback.\r
-     */\r
-    public static final int fLoop = 1;\r
-    /**\r
-     * A bit that specifies whether the audio or video data is rewound after playing.\r
-     */\r
-    public static final int fRewind = 2;\r
-    /**\r
-     * A bit that specifies whether the audio data is recorded narration for the slide show. It MUST be FALSE if this ExMediaAtom record is contained by an ExVideoContainer record.\r
-     */\r
-    public static final int fNarration = 4;\r
-\r
-    /**\r
-     * Record header.\r
-     */\r
-    private byte[] _header;\r
-\r
-    /**\r
-     * record data\r
-     */\r
-    private byte[] _recdata;\r
-\r
-    /**\r
-     * Constructs a brand new link related atom record.\r
-     */\r
-    protected ExMediaAtom() {\r
-        _recdata = new byte[8];\r
-\r
-        _header = new byte[8];\r
-        LittleEndian.putShort(_header, 2, (short)getRecordType());\r
-        LittleEndian.putInt(_header, 4, _recdata.length);\r
-    }\r
-\r
-    /**\r
-     * Constructs the link related atom record from its\r
-     *  source data.\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start the start offset into the byte array.\r
-     * @param len the length of the slice in the byte array.\r
-     */\r
-    protected ExMediaAtom(byte[] source, int start, int len) {\r
-        // Get the header\r
-        _header = new byte[8];\r
-        System.arraycopy(source,start,_header,0,8);\r
-\r
-        // Grab the record data\r
-        _recdata = new byte[len-8];\r
-        System.arraycopy(source,start+8,_recdata,0,len-8);\r
-    }\r
-\r
-    /**\r
-     * Gets the record type.\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() { return RecordTypes.ExMediaAtom.typeID; }\r
-\r
-    /**\r
-     * Write the contents of the record back, so it can be written\r
-     * to disk\r
-     *\r
-     * @param out the output stream to write to.\r
-     * @throws java.io.IOException if an error occurs.\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        out.write(_header);\r
-        out.write(_recdata);\r
-    }\r
-\r
-    /**\r
-     * A 4-byte unsigned integer that specifies an ID for an external object.\r
-     *\r
-     * @return  A 4-byte unsigned integer that specifies an ID for an external object.\r
-     */\r
-    public int getObjectId(){\r
-        return LittleEndian.getInt(_recdata, 0);\r
-    }\r
-\r
-    /**\r
-     * A 4-byte unsigned integer that specifies an ID for an external object.\r
-     *\r
-     * @param id  A 4-byte unsigned integer that specifies an ID for an external object.\r
-     */\r
-    public void setObjectId(int id){\r
-         LittleEndian.putInt(_recdata, 0, id);\r
-    }\r
-\r
-    /**\r
-     *  A bit mask specifying options for displaying headers and footers\r
-     *\r
-     * @return A bit mask specifying options for displaying headers and footers\r
-     */\r
-    public int getMask(){\r
-        return LittleEndian.getInt(_recdata, 4);\r
-    }\r
-\r
-    /**\r
-     *  A bit mask specifying options for displaying video\r
-     *\r
-     * @param mask A bit mask specifying options for displaying video\r
-     */\r
-    public void setMask(int mask){\r
-        LittleEndian.putInt(_recdata, 4, mask);\r
-    }\r
-\r
-    /**\r
-     * @param bit the bit to check\r
-     * @return whether the specified flag is set\r
-     */\r
-    public boolean getFlag(int bit){\r
-        return (getMask() & bit) != 0;\r
-    }\r
-\r
-    /**\r
-     * @param  bit the bit to set\r
-     * @param  value whether the specified bit is set\r
-     */\r
-    public void setFlag(int bit, boolean value){\r
-        int mask = getMask();\r
-        if(value) mask |= bit;\r
-        else mask &= ~bit;\r
-        setMask(mask);\r
-    }\r
-\r
-    public String toString(){\r
-        StringBuffer buf = new StringBuffer();\r
-        buf.append("ExMediaAtom\n");\r
-        buf.append("\tObjectId: " + getObjectId() + "\n");\r
-        buf.append("\tMask    : " + getMask() + "\n");\r
-        buf.append("\t  fLoop        : " + getFlag(fLoop) + "\n");\r
-        buf.append("\t  fRewind   : " + getFlag(fRewind) + "\n");\r
-        buf.append("\t  fNarration    : " + getFlag(fNarration) + "\n");\r
-        return buf.toString();\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.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 information about external audio or video data.
+ *
+ * @author Yegor Kozlov
+ */
+public final class ExMediaAtom extends RecordAtom
+{
+
+    /**
+     * A bit that specifies whether the audio or video data is repeated continuously during playback.
+     */
+    public static final int fLoop = 1;
+    /**
+     * A bit that specifies whether the audio or video data is rewound after playing.
+     */
+    public static final int fRewind = 2;
+    /**
+     * A bit that specifies whether the audio data is recorded narration for the slide show. It MUST be FALSE if this ExMediaAtom record is contained by an ExVideoContainer record.
+     */
+    public static final int fNarration = 4;
+
+    /**
+     * Record header.
+     */
+    private byte[] _header;
+
+    /**
+     * record data
+     */
+    private byte[] _recdata;
+
+    /**
+     * Constructs a brand new link related atom record.
+     */
+    protected ExMediaAtom() {
+        _recdata = new byte[8];
+
+        _header = new byte[8];
+        LittleEndian.putShort(_header, 2, (short)getRecordType());
+        LittleEndian.putInt(_header, 4, _recdata.length);
+    }
+
+    /**
+     * Constructs the link related atom record from its
+     *  source data.
+     *
+     * @param source the source data as a byte array.
+     * @param start the start offset into the byte array.
+     * @param len the length of the slice in the byte array.
+     */
+    protected ExMediaAtom(byte[] source, int start, int len) {
+        // Get the header
+        _header = new byte[8];
+        System.arraycopy(source,start,_header,0,8);
+
+        // Grab the record data
+        _recdata = new byte[len-8];
+        System.arraycopy(source,start+8,_recdata,0,len-8);
+    }
+
+    /**
+     * Gets the record type.
+     * @return the record type.
+     */
+    public long getRecordType() { return RecordTypes.ExMediaAtom.typeID; }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     * to disk
+     *
+     * @param out the output stream to write to.
+     * @throws java.io.IOException if an error occurs.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        out.write(_header);
+        out.write(_recdata);
+    }
+
+    /**
+     * A 4-byte unsigned integer that specifies an ID for an external object.
+     *
+     * @return  A 4-byte unsigned integer that specifies an ID for an external object.
+     */
+    public int getObjectId(){
+        return LittleEndian.getInt(_recdata, 0);
+    }
+
+    /**
+     * A 4-byte unsigned integer that specifies an ID for an external object.
+     *
+     * @param id  A 4-byte unsigned integer that specifies an ID for an external object.
+     */
+    public void setObjectId(int id){
+         LittleEndian.putInt(_recdata, 0, id);
+    }
+
+    /**
+     *  A bit mask specifying options for displaying headers and footers
+     *
+     * @return A bit mask specifying options for displaying headers and footers
+     */
+    public int getMask(){
+        return LittleEndian.getInt(_recdata, 4);
+    }
+
+    /**
+     *  A bit mask specifying options for displaying video
+     *
+     * @param mask A bit mask specifying options for displaying video
+     */
+    public void setMask(int mask){
+        LittleEndian.putInt(_recdata, 4, mask);
+    }
+
+    /**
+     * @param bit the bit to check
+     * @return whether the specified flag is set
+     */
+    public boolean getFlag(int bit){
+        return (getMask() & bit) != 0;
+    }
+
+    /**
+     * @param  bit the bit to set
+     * @param  value whether the specified bit is set
+     */
+    public void setFlag(int bit, boolean value){
+        int mask = getMask();
+        if(value) mask |= bit;
+        else mask &= ~bit;
+        setMask(mask);
+    }
+
+    public String toString(){
+        StringBuffer buf = new StringBuffer();
+        buf.append("ExMediaAtom\n");
+        buf.append("\tObjectId: " + getObjectId() + "\n");
+        buf.append("\tMask    : " + getMask() + "\n");
+        buf.append("\t  fLoop        : " + getFlag(fLoop) + "\n");
+        buf.append("\t  fRewind   : " + getFlag(fRewind) + "\n");
+        buf.append("\t  fNarration    : " + getFlag(fNarration) + "\n");
+        return buf.toString();
+    }
+
+}
index 36f9fda1ab0c237d76195fe27c76f6782e520602..473201f26c3de54a3831422c1e3831bcb8b76c2e 100755 (executable)
-/*\r
-* Licensed to the Apache Software Foundation (ASF) under one or more\r
-* contributor license agreements.  See the NOTICE file distributed with\r
-* this work for additional information regarding copyright ownership.\r
-* The ASF licenses this file to You under the Apache License, Version 2.0\r
-* (the "License"); you may not use this file except in compliance with\r
-* the License.  You may obtain a copy of the License at\r
-*\r
-*     http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*/\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-import org.apache.poi.util.POILogger;\r
-\r
-/**\r
- * A container record that specifies information about external video data.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class ExVideoContainer extends RecordContainer {\r
-       private byte[] _header;\r
-\r
-       // Links to our more interesting children\r
-       private ExMediaAtom mediaAtom;\r
-    //the UNC or local path to a video file.\r
-    private CString pathAtom;\r
-\r
-       /**\r
-        * Set things up, and find our more interesting children\r
-        */\r
-       protected ExVideoContainer(byte[] source, int start, int len) {\r
-               // Grab the header\r
-               _header = new byte[8];\r
-               System.arraycopy(source,start,_header,0,8);\r
-\r
-               // Find our children\r
-               _children = Record.findChildRecords(source,start+8,len-8);\r
-               findInterestingChildren();\r
-       }\r
-\r
-       /**\r
-        * Go through our child records, picking out the ones that are\r
-        *  interesting, and saving those for use by the easy helper\r
-        *  methods.\r
-        */     \r
-       private void findInterestingChildren() {\r
-\r
-               // First child should be the ExMediaAtom\r
-               if(_children[0] instanceof ExMediaAtom) {\r
-                       mediaAtom = (ExMediaAtom)_children[0];\r
-               } else {\r
-                       logger.log(POILogger.ERROR, "First child record wasn't a ExMediaAtom, was of type " + _children[0].getRecordType());\r
-               }\r
-        if(_children[1] instanceof CString) {\r
-            pathAtom = (CString)_children[1];\r
-        } else {\r
-            logger.log(POILogger.ERROR, "Second child record wasn't a CString, was of type " + _children[1].getRecordType());\r
-        }\r
-       }\r
-\r
-       /**\r
-        * Create a new ExVideoContainer, with blank fields\r
-        */\r
-       public ExVideoContainer() {\r
-        // Setup our header block\r
-               _header = new byte[8];\r
-               _header[0] = 0x0f; // We are a container record\r
-               LittleEndian.putShort(_header, 2, (short)getRecordType());\r
-               \r
-        _children = new Record[2];\r
-               _children[0] = mediaAtom = new ExMediaAtom();\r
-               _children[1] = pathAtom = new CString();\r
-       }\r
-\r
-       /**\r
-        * We are of type 4103\r
-        */\r
-       public long getRecordType() { return RecordTypes.ExVideoContainer.typeID; }\r
-\r
-       /**\r
-        * Write the contents of the record back, so it can be written\r
-        *  to disk\r
-        */\r
-       public void writeOut(OutputStream out) throws IOException {\r
-               writeOut(_header[0],_header[1],getRecordType(),_children,out);\r
-       }\r
-\r
-    /**\r
-     * Returns the ExMediaAtom of this link\r
-     */\r
-    public ExMediaAtom getExMediaAtom() { return mediaAtom; }\r
-\r
-    /**\r
-     * Returns the Path Atom (CString) of this link\r
-     */\r
-    public CString getPathAtom() { return pathAtom; }\r
-\r
-}\r
+/* ====================================================================
+   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.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 external video data.
+ *
+ * @author Yegor Kozlov
+ */
+public final class ExVideoContainer extends RecordContainer {
+       private byte[] _header;
+
+       // Links to our more interesting children
+       private ExMediaAtom mediaAtom;
+    //the UNC or local path to a video file.
+    private CString pathAtom;
+
+       /**
+        * Set things up, and find our more interesting children
+        */
+       protected ExVideoContainer(byte[] source, int start, int len) {
+               // Grab the header
+               _header = new byte[8];
+               System.arraycopy(source,start,_header,0,8);
+
+               // Find our children
+               _children = Record.findChildRecords(source,start+8,len-8);
+               findInterestingChildren();
+       }
+
+       /**
+        * Go through our child records, picking out the ones that are
+        *  interesting, and saving those for use by the easy helper
+        *  methods.
+        */
+       private void findInterestingChildren() {
+
+               // First child should be the ExMediaAtom
+               if(_children[0] instanceof ExMediaAtom) {
+                       mediaAtom = (ExMediaAtom)_children[0];
+               } else {
+                       logger.log(POILogger.ERROR, "First child record wasn't a ExMediaAtom, was of type " + _children[0].getRecordType());
+               }
+        if(_children[1] instanceof CString) {
+            pathAtom = (CString)_children[1];
+        } else {
+            logger.log(POILogger.ERROR, "Second child record wasn't a CString, was of type " + _children[1].getRecordType());
+        }
+       }
+
+       /**
+        * Create a new ExVideoContainer, with blank fields
+        */
+       public ExVideoContainer() {
+        // Setup our header block
+               _header = new byte[8];
+               _header[0] = 0x0f; // We are a container record
+               LittleEndian.putShort(_header, 2, (short)getRecordType());
+
+        _children = new Record[2];
+               _children[0] = mediaAtom = new ExMediaAtom();
+               _children[1] = pathAtom = new CString();
+       }
+
+       /**
+        * We are of type 4103
+        */
+       public long getRecordType() { return RecordTypes.ExVideoContainer.typeID; }
+
+       /**
+        * Write the contents of the record back, so it can be written
+        *  to disk
+        */
+       public void writeOut(OutputStream out) throws IOException {
+               writeOut(_header[0],_header[1],getRecordType(),_children,out);
+       }
+
+    /**
+     * Returns the ExMediaAtom of this link
+     */
+    public ExMediaAtom getExMediaAtom() { return mediaAtom; }
+
+    /**
+     * Returns the Path Atom (CString) of this link
+     */
+    public CString getPathAtom() { return pathAtom; }
+
+}
index c0d55ac0ee708bd533e65b549ec0ece77d45f4a2..be6cdde42c20f65b340ce1a2830987dfa0d0598c 100644 (file)
@@ -14,7 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hslf.record;
 
@@ -30,7 +29,7 @@ import java.util.*;
  * @author Yegor Kozlov
  */
 
-public class FontCollection extends RecordContainer {
+public final class FontCollection extends RecordContainer {
     private List fonts;
        private byte[] _header;
 
index 76cb4c264b81890b3a56e8a076c81324fdd64f9f..54284e028f7ab5e24a543ac447a33535841842f8 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.hslf.record;
 
@@ -34,7 +32,7 @@ import java.io.UnsupportedEncodingException;
  * @author Yegor Kozlov
  */
 
-public class FontEntityAtom extends RecordAtom {
+public final class FontEntityAtom extends RecordAtom {
        /**
      * record header
      */
@@ -75,7 +73,7 @@ public class FontEntityAtom extends RecordAtom {
 
     /**
      * A null-terminated string that specifies the typeface name of the font.
-     * The length of this string must not exceed 32 characters 
+     * The length of this string must not exceed 32 characters
         *  including the null terminator.
      * @return font name
      */
@@ -99,7 +97,7 @@ public class FontEntityAtom extends RecordAtom {
 
     /**
      * Set the name of the font.
-     * The length of this string must not exceed 32 characters 
+     * The length of this string must not exceed 32 characters
         *  including the null terminator.
         * Will be converted to null-terminated if not already
      * @param name of the font
index 1c90b95960af324b23e2d7240f53720a6ac6ee55..b9006051dd6332ea9d3ac277894c05a70bf5f74d 100644 (file)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-\r
-/**\r
- * An atom record that specifies options for displaying headers and footers\r
- * on a presentation slide or notes slide.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-\r
-public class HeadersFootersAtom extends RecordAtom {\r
-\r
-    /**\r
-     * A bit that specifies whether the date is displayed in the footer.\r
-     * @see #getMask()\r
-     * @see #setMask(int)\r
-     */\r
-    public static final int fHasDate = 1;\r
-\r
-    /**\r
-     * A bit that specifies whether the current datetime is used for displaying the datetime.\r
-     * @see #getMask()\r
-     * @see #setMask(int)\r
-     */\r
-    public static final int fHasTodayDate = 2;\r
-\r
-    /**\r
-     * A bit that specifies whether the date specified in UserDateAtom record\r
-     * is used for displaying the datetime.\r
-     *\r
-     * @see #getMask()\r
-     * @see #setMask(int)\r
-     */\r
-     public static final int fHasUserDate = 4;\r
-\r
-    /**\r
-     * A bit that specifies whether the slide number is displayed in the footer.\r
-     * \r
-     * @see #getMask()\r
-     * @see #setMask(int)\r
-     */\r
-    public static final int fHasSlideNumber = 8;\r
-\r
-    /**\r
-     * bit that specifies whether the header text is displayed.\r
-     *\r
-     * @see #getMask()\r
-     * @see #setMask(int)\r
-     */\r
-    public static final int fHasHeader = 16;\r
-\r
-    /**\r
-     * bit that specifies whether the footer text is displayed.\r
-     *\r
-     * @see #getMask()\r
-     * @see #setMask(int)\r
-     */\r
-    public static final int fHasFooter = 32;\r
-\r
-    /**\r
-     * record header\r
-     */\r
-    private byte[] _header;\r
-\r
-       /**\r
-     * record data\r
-     */\r
-       private byte[] _recdata;\r
-\r
-    /**\r
-     * Build an instance of <code>HeadersFootersAtom</code> from on-disk data\r
-     */\r
-       protected HeadersFootersAtom(byte[] source, int start, int len) {\r
-               // Get the header\r
-               _header = new byte[8];\r
-               System.arraycopy(source,start,_header,0,8);\r
-\r
-               // Grab the record data\r
-               _recdata = new byte[len-8];\r
-               System.arraycopy(source,start+8,_recdata,0,len-8);\r
-       }\r
-\r
-    /**\r
-     * Create a new instance of <code>HeadersFootersAtom</code>\r
-     */\r
-    public HeadersFootersAtom() {\r
-        _recdata = new byte[4];\r
-\r
-        _header = new byte[8];\r
-        LittleEndian.putShort(_header, 2, (short)getRecordType());\r
-        LittleEndian.putInt(_header, 4, _recdata.length);\r
-    }\r
-\r
-    public long getRecordType() {\r
-        return RecordTypes.HeadersFootersAtom.typeID;\r
-    }\r
-\r
-    /**\r
-        * Write the contents of the record back, so it can be written to disk\r
-        */\r
-       public void writeOut(OutputStream out) throws IOException {\r
-               out.write(_header);\r
-               out.write(_recdata);\r
-       }\r
-\r
-    /**\r
-     * A signed integer that specifies the format ID to be used to style the datetime.\r
-     * <p>\r
-     * It MUST be in the range [0, 12]. </br>\r
-     * This value is converted into a string as specified by the index field of the DateTimeMCAtom record.\r
-     * It MUST be ignored unless fHasTodayDate is TRUE.\r
-     * </b>\r
-     *\r
-     * @return  A signed integer that specifies the format ID to be used to style the datetime.\r
-     */\r
-    public int getFormatId(){\r
-        return LittleEndian.getShort(_recdata, 0);\r
-    }\r
-\r
-    /**\r
-     * A signed integer that specifies the format ID to be used to style the datetime.\r
-     *\r
-     * @param formatId  A signed integer that specifies the format ID to be used to style the datetime.\r
-     */\r
-    public void setFormatId(int formatId){\r
-         LittleEndian.putUShort(_recdata, 0, formatId);\r
-    }\r
-\r
-    /**\r
-     *  A bit mask specifying options for displaying headers and footers\r
-     *\r
-     * <li> A - {@link #fHasDate} (1 bit): A bit that specifies whether the date is displayed in the footer.\r
-     * <li> B - {@link #fHasTodayDate} (1 bit): A bit that specifies whether the current datetime is used for\r
-     *      displaying the datetime.\r
-     * <li> C - {@link #fHasUserDate} (1 bit): A bit that specifies whether the date specified in UserDateAtom record\r
-     *      is used for displaying the datetime.\r
-     * <li> D - {@link #fHasSlideNumber} (1 bit): A bit that specifies whether the slide number is displayed in the footer.\r
-     * <li> E - {@link #fHasHeader} (1 bit): A bit that specifies whether the header text specified by HeaderAtom\r
-     *      record is displayed.\r
-     * <li> F - {@link #fHasFooter} (1 bit): A bit that specifies whether the footer text specified by FooterAtom\r
-     *      record is displayed.\r
-     * <li> reserved (10 bits): MUST be zero and MUST be ignored.\r
-     *\r
-     * @return A bit mask specifying options for displaying headers and footers\r
-     */\r
-    public int getMask(){\r
-        return LittleEndian.getShort(_recdata, 2);\r
-    }\r
-\r
-    /**\r
-     *  A bit mask specifying options for displaying headers and footers\r
-     *\r
-     * @param mask A bit mask specifying options for displaying headers and footers\r
-     */\r
-    public void setMask(int mask){\r
-        LittleEndian.putUShort(_recdata, 2, mask);\r
-    }\r
-\r
-    /**\r
-     * @param bit the bit to check\r
-     * @return whether the specified flag is set\r
-     */\r
-    public boolean getFlag(int bit){\r
-        return (getMask() & bit) != 0;\r
-    }\r
-\r
-    /**\r
-     * @param  bit the bit to set\r
-     * @param  value whether the specified bit is set\r
-     */\r
-    public void setFlag(int bit, boolean value){\r
-        int mask = getMask();\r
-        if(value) mask |= bit;\r
-        else mask &= ~bit;\r
-        setMask(mask);\r
-    }\r
-\r
-    public String toString(){\r
-        StringBuffer buf = new StringBuffer();\r
-        buf.append("HeadersFootersAtom\n");\r
-        buf.append("\tFormatId: " + getFormatId() + "\n");\r
-        buf.append("\tMask    : " + getMask() + "\n");\r
-        buf.append("\t  fHasDate        : " + getFlag(fHasDate) + "\n");\r
-        buf.append("\t  fHasTodayDate   : " + getFlag(fHasTodayDate) + "\n");\r
-        buf.append("\t  fHasUserDate    : " + getFlag(fHasUserDate) + "\n");\r
-        buf.append("\t  fHasSlideNumber : " + getFlag(fHasSlideNumber) + "\n");\r
-        buf.append("\t  fHasHeader      : " + getFlag(fHasHeader) + "\n");\r
-        buf.append("\t  fHasFooter      : " + getFlag(fHasFooter) + "\n");\r
-        return buf.toString();\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.record;
+
+import org.apache.poi.util.LittleEndian;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * An atom record that specifies options for displaying headers and footers
+ * on a presentation slide or notes slide.
+ *
+ * @author Yegor Kozlov
+ */
+
+public final class HeadersFootersAtom extends RecordAtom {
+
+    /**
+     * A bit that specifies whether the date is displayed in the footer.
+     * @see #getMask()
+     * @see #setMask(int)
+     */
+    public static final int fHasDate = 1;
+
+    /**
+     * A bit that specifies whether the current datetime is used for displaying the datetime.
+     * @see #getMask()
+     * @see #setMask(int)
+     */
+    public static final int fHasTodayDate = 2;
+
+    /**
+     * A bit that specifies whether the date specified in UserDateAtom record
+     * is used for displaying the datetime.
+     *
+     * @see #getMask()
+     * @see #setMask(int)
+     */
+     public static final int fHasUserDate = 4;
+
+    /**
+     * A bit that specifies whether the slide number is displayed in the footer.
+     *
+     * @see #getMask()
+     * @see #setMask(int)
+     */
+    public static final int fHasSlideNumber = 8;
+
+    /**
+     * bit that specifies whether the header text is displayed.
+     *
+     * @see #getMask()
+     * @see #setMask(int)
+     */
+    public static final int fHasHeader = 16;
+
+    /**
+     * bit that specifies whether the footer text is displayed.
+     *
+     * @see #getMask()
+     * @see #setMask(int)
+     */
+    public static final int fHasFooter = 32;
+
+    /**
+     * record header
+     */
+    private byte[] _header;
+
+       /**
+     * record data
+     */
+       private byte[] _recdata;
+
+    /**
+     * Build an instance of <code>HeadersFootersAtom</code> from on-disk data
+     */
+       protected HeadersFootersAtom(byte[] source, int start, int len) {
+               // Get the header
+               _header = new byte[8];
+               System.arraycopy(source,start,_header,0,8);
+
+               // Grab the record data
+               _recdata = new byte[len-8];
+               System.arraycopy(source,start+8,_recdata,0,len-8);
+       }
+
+    /**
+     * Create a new instance of <code>HeadersFootersAtom</code>
+     */
+    public HeadersFootersAtom() {
+        _recdata = new byte[4];
+
+        _header = new byte[8];
+        LittleEndian.putShort(_header, 2, (short)getRecordType());
+        LittleEndian.putInt(_header, 4, _recdata.length);
+    }
+
+    public long getRecordType() {
+        return RecordTypes.HeadersFootersAtom.typeID;
+    }
+
+    /**
+        * Write the contents of the record back, so it can be written to disk
+        */
+       public void writeOut(OutputStream out) throws IOException {
+               out.write(_header);
+               out.write(_recdata);
+       }
+
+    /**
+     * A signed integer that specifies the format ID to be used to style the datetime.
+     * <p>
+     * It MUST be in the range [0, 12]. </br>
+     * This value is converted into a string as specified by the index field of the DateTimeMCAtom record.
+     * It MUST be ignored unless fHasTodayDate is TRUE.
+     * </b>
+     *
+     * @return  A signed integer that specifies the format ID to be used to style the datetime.
+     */
+    public int getFormatId(){
+        return LittleEndian.getShort(_recdata, 0);
+    }
+
+    /**
+     * A signed integer that specifies the format ID to be used to style the datetime.
+     *
+     * @param formatId  A signed integer that specifies the format ID to be used to style the datetime.
+     */
+    public void setFormatId(int formatId){
+         LittleEndian.putUShort(_recdata, 0, formatId);
+    }
+
+    /**
+     *  A bit mask specifying options for displaying headers and footers
+     *
+     * <li> A - {@link #fHasDate} (1 bit): A bit that specifies whether the date is displayed in the footer.
+     * <li> B - {@link #fHasTodayDate} (1 bit): A bit that specifies whether the current datetime is used for
+     *      displaying the datetime.
+     * <li> C - {@link #fHasUserDate} (1 bit): A bit that specifies whether the date specified in UserDateAtom record
+     *      is used for displaying the datetime.
+     * <li> D - {@link #fHasSlideNumber} (1 bit): A bit that specifies whether the slide number is displayed in the footer.
+     * <li> E - {@link #fHasHeader} (1 bit): A bit that specifies whether the header text specified by HeaderAtom
+     *      record is displayed.
+     * <li> F - {@link #fHasFooter} (1 bit): A bit that specifies whether the footer text specified by FooterAtom
+     *      record is displayed.
+     * <li> reserved (10 bits): MUST be zero and MUST be ignored.
+     *
+     * @return A bit mask specifying options for displaying headers and footers
+     */
+    public int getMask(){
+        return LittleEndian.getShort(_recdata, 2);
+    }
+
+    /**
+     *  A bit mask specifying options for displaying headers and footers
+     *
+     * @param mask A bit mask specifying options for displaying headers and footers
+     */
+    public void setMask(int mask){
+        LittleEndian.putUShort(_recdata, 2, mask);
+    }
+
+    /**
+     * @param bit the bit to check
+     * @return whether the specified flag is set
+     */
+    public boolean getFlag(int bit){
+        return (getMask() & bit) != 0;
+    }
+
+    /**
+     * @param  bit the bit to set
+     * @param  value whether the specified bit is set
+     */
+    public void setFlag(int bit, boolean value){
+        int mask = getMask();
+        if(value) mask |= bit;
+        else mask &= ~bit;
+        setMask(mask);
+    }
+
+    public String toString(){
+        StringBuffer buf = new StringBuffer();
+        buf.append("HeadersFootersAtom\n");
+        buf.append("\tFormatId: " + getFormatId() + "\n");
+        buf.append("\tMask    : " + getMask() + "\n");
+        buf.append("\t  fHasDate        : " + getFlag(fHasDate) + "\n");
+        buf.append("\t  fHasTodayDate   : " + getFlag(fHasTodayDate) + "\n");
+        buf.append("\t  fHasUserDate    : " + getFlag(fHasUserDate) + "\n");
+        buf.append("\t  fHasSlideNumber : " + getFlag(fHasSlideNumber) + "\n");
+        buf.append("\t  fHasHeader      : " + getFlag(fHasHeader) + "\n");
+        buf.append("\t  fHasFooter      : " + getFlag(fHasFooter) + "\n");
+        return buf.toString();
+    }
+}
index e121574bc122cad4ec2d5497e7458f8cb43a4800..9f2a0eecd7faa21b5fe0637119dd05906a600905 100644 (file)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-import org.apache.poi.util.POILogger;\r
-\r
-import java.io.OutputStream;\r
-import java.io.IOException;\r
-\r
-/**\r
- * A container record that specifies information about the footers on a presentation slide.\r
- * <p>\r
- * It contains:<br>\r
- * <li> 1. {@link HeadersFootersAtom}\r
- * <li> 2. {@link CString }, Instance UserDate (0), optional: Stores the user's date.\r
- *    This is the date that the user wants in the footers, instead of today's date.\r
- * <li> 3. {@link CString }, Instance Header (1), optional: Stores the Header's contents.\r
- * <li> 4. {@link CString }, Instance Footer (2), optional: Stores the Footer's contents.\r
- * </p>\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class HeadersFootersContainer extends RecordContainer {\r
-\r
-    /**\r
-     * "instance" field in the record header indicating that this HeadersFootersContaine\r
-     *  is applied for slides\r
-     */\r
-    public static final short SlideHeadersFootersContainer = 0x3F;\r
-    /**\r
-      * "instance" field in the record header indicating that this HeadersFootersContaine\r
-     *   is applied for notes and handouts\r
-      */\r
-    public static final short NotesHeadersFootersContainer = 0x4F;\r
-\r
-    public static final int USERDATEATOM    = 0;\r
-    public static final int HEADERATOM      = 1;\r
-    public static final int FOOTERATOM      = 2;\r
-\r
-    private byte[] _header;\r
-    private HeadersFootersAtom hdAtom;\r
-    private CString csDate, csHeader, csFooter;\r
-\r
-    protected HeadersFootersContainer(byte[] source, int start, int len) {\r
-        // Grab the header\r
-        _header = new byte[8];\r
-        System.arraycopy(source,start,_header,0,8);\r
-\r
-        _children = Record.findChildRecords(source,start+8,len-8);\r
-        for(int i=0; i < _children.length; i++){\r
-            if(_children[i] instanceof HeadersFootersAtom) hdAtom = (HeadersFootersAtom)_children[i];\r
-            else if(_children[i] instanceof CString) {\r
-                CString cs = (CString)_children[i];\r
-                int opts = cs.getOptions() >> 4;\r
-                switch(opts){\r
-                    case USERDATEATOM: csDate = cs; break;\r
-                    case HEADERATOM: csHeader = cs; break;\r
-                    case FOOTERATOM: csFooter = cs; break;\r
-                    default:\r
-                        logger.log(POILogger.WARN, "Unexpected CString.Options in HeadersFootersContainer: " + opts);\r
-                        break;\r
-                }\r
-            } else {\r
-                logger.log(POILogger.WARN, "Unexpected record in HeadersFootersContainer: " + _children[i]);\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    public HeadersFootersContainer(short options) {\r
-        _header = new byte[8];\r
-        LittleEndian.putShort(_header, 0, options);\r
-        LittleEndian.putShort(_header, 2, (short)getRecordType());\r
-\r
-        hdAtom = new HeadersFootersAtom();\r
-        _children = new Record[]{\r
-            hdAtom\r
-        };\r
-        csDate = csHeader = csFooter = null;\r
-\r
-    }\r
-\r
-    /**\r
-     * Return the type, which is <code>{@link RecordTypes#HeadersFooters}</code>\r
-     */\r
-    public long getRecordType() {\r
-        return RecordTypes.HeadersFooters.typeID;\r
-    }\r
-\r
-    /**\r
-     * Must be either {@link #SlideHeadersFootersContainer} or {@link #NotesHeadersFootersContainer}\r
-     *\r
-     * @return "instance" field in the record header\r
-     */\r
-    public int getOptions(){\r
-        return LittleEndian.getShort(_header, 0);\r
-    }\r
-\r
-    /**\r
-     * Write the contents of the record back, so it can be written to disk\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        writeOut(_header[0],_header[1],getRecordType(),_children,out);\r
-    }\r
-\r
-    /**\r
-     * HeadersFootersAtom stores the basic information of the header and footer structure.\r
-     *\r
-     * @return <code>HeadersFootersAtom</code>\r
-     */\r
-    public HeadersFootersAtom getHeadersFootersAtom(){\r
-        return hdAtom;\r
-    }\r
-\r
-    /**\r
-     * A {@link CString} record that stores the user's date.\r
-     * <p>This is the date that the user wants in the footers, instead of today's date.</p>\r
-     *\r
-     * @return A {@link CString} record that stores the user's date or <code>null</code>\r
-     */\r
-    public CString getUserDateAtom(){\r
-        return csDate;\r
-    }\r
-\r
-    /**\r
-     * A {@link CString} record that stores the Header's contents.\r
-     *\r
-     * @return A {@link CString} record that stores the Header's contents or <code>null</code>\r
-     */\r
-    public CString getHeaderAtom(){\r
-        return csHeader;\r
-    }\r
-\r
-    /**\r
-     * A {@link CString} record that stores the Footers's contents.\r
-     *\r
-     * @return A {@link CString} record that stores the Footers's contents or <code>null</code>\r
-     */\r
-    public CString getFooterAtom(){\r
-        return csFooter;\r
-    }\r
-\r
-    /**\r
-     * Insert a {@link CString} record that stores the user's date.\r
-     *\r
-     * @return  the created {@link CString} record that stores the user's date.\r
-     */\r
-    public CString addUserDateAtom(){\r
-        if(csDate != null) return csDate;\r
-\r
-        csDate = new CString();\r
-        csDate.setOptions(USERDATEATOM << 4);\r
-\r
-        addChildAfter(csDate, hdAtom);\r
-\r
-        return csDate;\r
-    }\r
-\r
-    /**\r
-     * Insert a {@link CString} record that stores the user's date.\r
-     *\r
-     * @return  the created {@link CString} record that stores the user's date.\r
-     */\r
-    public CString addHeaderAtom(){\r
-        if(csHeader != null) return csHeader;\r
-\r
-        csHeader = new CString();\r
-        csHeader.setOptions(HEADERATOM << 4);\r
-\r
-        Record r = hdAtom;\r
-        if(csDate != null) r = hdAtom;\r
-        addChildAfter(csHeader, r);\r
-\r
-        return csHeader;\r
-    }\r
-\r
-    /**\r
-     * Insert a {@link CString} record that stores the user's date.\r
-     *\r
-     * @return  the created {@link CString} record that stores the user's date.\r
-     */\r
-    public CString addFooterAtom(){\r
-        if(csFooter != null) return csFooter;\r
-\r
-        csFooter = new CString();\r
-        csFooter.setOptions(FOOTERATOM << 4);\r
-\r
-        Record r = hdAtom;\r
-        if(csHeader != null) r = csHeader;\r
-        else if(csDate != null) r = csDate;\r
-        addChildAfter(csFooter, r);\r
-\r
-        return csFooter;\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.record;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogger;
+
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * A container record that specifies information about the footers on a presentation slide.
+ * <p>
+ * It contains:<br>
+ * <li> 1. {@link HeadersFootersAtom}
+ * <li> 2. {@link CString }, Instance UserDate (0), optional: Stores the user's date.
+ *    This is the date that the user wants in the footers, instead of today's date.
+ * <li> 3. {@link CString }, Instance Header (1), optional: Stores the Header's contents.
+ * <li> 4. {@link CString }, Instance Footer (2), optional: Stores the Footer's contents.
+ * </p>
+ *
+ * @author Yegor Kozlov
+ */
+public final class HeadersFootersContainer extends RecordContainer {
+
+    /**
+     * "instance" field in the record header indicating that this HeadersFootersContaine
+     *  is applied for slides
+     */
+    public static final short SlideHeadersFootersContainer = 0x3F;
+    /**
+      * "instance" field in the record header indicating that this HeadersFootersContaine
+     *   is applied for notes and handouts
+      */
+    public static final short NotesHeadersFootersContainer = 0x4F;
+
+    public static final int USERDATEATOM    = 0;
+    public static final int HEADERATOM      = 1;
+    public static final int FOOTERATOM      = 2;
+
+    private byte[] _header;
+    private HeadersFootersAtom hdAtom;
+    private CString csDate, csHeader, csFooter;
+
+    protected HeadersFootersContainer(byte[] source, int start, int len) {
+        // Grab the header
+        _header = new byte[8];
+        System.arraycopy(source,start,_header,0,8);
+
+        _children = Record.findChildRecords(source,start+8,len-8);
+        for(int i=0; i < _children.length; i++){
+            if(_children[i] instanceof HeadersFootersAtom) hdAtom = (HeadersFootersAtom)_children[i];
+            else if(_children[i] instanceof CString) {
+                CString cs = (CString)_children[i];
+                int opts = cs.getOptions() >> 4;
+                switch(opts){
+                    case USERDATEATOM: csDate = cs; break;
+                    case HEADERATOM: csHeader = cs; break;
+                    case FOOTERATOM: csFooter = cs; break;
+                    default:
+                        logger.log(POILogger.WARN, "Unexpected CString.Options in HeadersFootersContainer: " + opts);
+                        break;
+                }
+            } else {
+                logger.log(POILogger.WARN, "Unexpected record in HeadersFootersContainer: " + _children[i]);
+            }
+        }
+
+    }
+
+    public HeadersFootersContainer(short options) {
+        _header = new byte[8];
+        LittleEndian.putShort(_header, 0, options);
+        LittleEndian.putShort(_header, 2, (short)getRecordType());
+
+        hdAtom = new HeadersFootersAtom();
+        _children = new Record[]{
+            hdAtom
+        };
+        csDate = csHeader = csFooter = null;
+
+    }
+
+    /**
+     * Return the type, which is <code>{@link RecordTypes#HeadersFooters}</code>
+     */
+    public long getRecordType() {
+        return RecordTypes.HeadersFooters.typeID;
+    }
+
+    /**
+     * Must be either {@link #SlideHeadersFootersContainer} or {@link #NotesHeadersFootersContainer}
+     *
+     * @return "instance" field in the record header
+     */
+    public int getOptions(){
+        return LittleEndian.getShort(_header, 0);
+    }
+
+    /**
+     * Write the contents of the record back, so it can be written to disk
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        writeOut(_header[0],_header[1],getRecordType(),_children,out);
+    }
+
+    /**
+     * HeadersFootersAtom stores the basic information of the header and footer structure.
+     *
+     * @return <code>HeadersFootersAtom</code>
+     */
+    public HeadersFootersAtom getHeadersFootersAtom(){
+        return hdAtom;
+    }
+
+    /**
+     * A {@link CString} record that stores the user's date.
+     * <p>This is the date that the user wants in the footers, instead of today's date.</p>
+     *
+     * @return A {@link CString} record that stores the user's date or <code>null</code>
+     */
+    public CString getUserDateAtom(){
+        return csDate;
+    }
+
+    /**
+     * A {@link CString} record that stores the Header's contents.
+     *
+     * @return A {@link CString} record that stores the Header's contents or <code>null</code>
+     */
+    public CString getHeaderAtom(){
+        return csHeader;
+    }
+
+    /**
+     * A {@link CString} record that stores the Footers's contents.
+     *
+     * @return A {@link CString} record that stores the Footers's contents or <code>null</code>
+     */
+    public CString getFooterAtom(){
+        return csFooter;
+    }
+
+    /**
+     * Insert a {@link CString} record that stores the user's date.
+     *
+     * @return  the created {@link CString} record that stores the user's date.
+     */
+    public CString addUserDateAtom(){
+        if(csDate != null) return csDate;
+
+        csDate = new CString();
+        csDate.setOptions(USERDATEATOM << 4);
+
+        addChildAfter(csDate, hdAtom);
+
+        return csDate;
+    }
+
+    /**
+     * Insert a {@link CString} record that stores the user's date.
+     *
+     * @return  the created {@link CString} record that stores the user's date.
+     */
+    public CString addHeaderAtom(){
+        if(csHeader != null) return csHeader;
+
+        csHeader = new CString();
+        csHeader.setOptions(HEADERATOM << 4);
+
+        Record r = hdAtom;
+        if(csDate != null) r = hdAtom;
+        addChildAfter(csHeader, r);
+
+        return csHeader;
+    }
+
+    /**
+     * Insert a {@link CString} record that stores the user's date.
+     *
+     * @return  the created {@link CString} record that stores the user's date.
+     */
+    public CString addFooterAtom(){
+        if(csFooter != null) return csFooter;
+
+        csFooter = new CString();
+        csFooter.setOptions(FOOTERATOM << 4);
+
+        Record r = hdAtom;
+        if(csHeader != null) r = csHeader;
+        else if(csDate != null) r = csDate;
+        addChildAfter(csFooter, r);
+
+        return csFooter;
+    }
+}
index 2915040e18b8717b22ba868609162dc23648c5d2..0c1f02b389703bb96d9a446df01276617fa1fedb 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.hslf.record;
 
@@ -31,7 +29,7 @@ import org.apache.poi.util.LittleEndian;
  * @author Yegor Kozlov
  */
 
-public class MainMaster extends SheetContainer
+public final class MainMaster extends SheetContainer
 {
        private byte[] _header;
        private static long _type = 1016;
@@ -49,7 +47,7 @@ public class MainMaster extends SheetContainer
        public SlideAtom getSlideAtom() { return slideAtom; }
 
        /**
-        * Returns the PPDrawing of this Slide, which has all the 
+        * Returns the PPDrawing of this Slide, which has all the
         *  interesting data in it
         */
        public PPDrawing getPPDrawing() { return ppDrawing; }
@@ -58,7 +56,7 @@ public class MainMaster extends SheetContainer
 
     public ColorSchemeAtom[] getColorSchemeAtoms() { return clrscheme; }
 
-       /** 
+       /**
         * Set things up, and find our more interesting children
         */
        protected MainMaster(byte[] source, int start, int len) {
@@ -96,7 +94,7 @@ public class MainMaster extends SheetContainer
         * We are of type 1016
         */
        public long getRecordType() { return _type; }
-       
+
        /**
         * Write the contents of the record back, so it can be written
         *  to disk
@@ -108,5 +106,5 @@ public class MainMaster extends SheetContainer
     public ColorSchemeAtom getColorScheme(){
         return _colorScheme;
     }
-    
+
 }
index 4c66e12ada9553a273a3491963807b42d9ac7edc..80ee6039f1064a94348b156b2f56ee44f0ad2d47 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.hslf.record;
 
@@ -29,7 +27,7 @@ import java.io.OutputStream;
  * @author Nick Burch
  */
 
-public class Notes extends SheetContainer
+public final class Notes extends SheetContainer
 {
        private byte[] _header;
        private static long _type = 1008l;
@@ -44,13 +42,13 @@ public class Notes extends SheetContainer
         */
        public NotesAtom getNotesAtom() { return notesAtom; }
        /**
-        * Returns the PPDrawing of this Notes, which has all the 
+        * Returns the PPDrawing of this Notes, which has all the
         *  interesting data in it
         */
        public PPDrawing getPPDrawing() { return ppDrawing; }
 
 
-       /** 
+       /**
         * Set things up, and find our more interesting children
         */
        protected Notes(byte[] source, int start, int len) {
index 3c88c1f2bbf7943b491373b0b8bc1e4f4ddfb304..bf4c5fe1a994e961b5b1ca25c7117c98c79953db 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.hslf.record;
 
@@ -30,7 +28,7 @@ import java.io.OutputStream;
  * @author Nick Burch
  */
 
-public class NotesAtom extends RecordAtom
+public final class NotesAtom extends RecordAtom
 {
        private byte[] _header;
        private static long _type = 1009l;
@@ -55,7 +53,7 @@ public class NotesAtom extends RecordAtom
 
        /* *************** record code follows ********************** */
 
-       /** 
+       /**
         * For the Notes Atom
         */
        protected NotesAtom(byte[] source, int start, int len) {
index 9bfae4fccb4d76f6fa946c6331b937765b0be5eb..1d8d7df62f4fe6cac7e2c34a05567e0c9e1438bf 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.hslf.record;
 
@@ -32,7 +30,7 @@ import java.io.OutputStream;
  * @author Yegor Kozlov
  */
 
-public class OEPlaceholderAtom extends RecordAtom{
+public final class OEPlaceholderAtom extends RecordAtom{
 
     /**
      * The full size of the master body text placeholder shape.
@@ -109,7 +107,7 @@ public class OEPlaceholderAtom extends RecordAtom{
     public static final byte MasterFooter = 9;
 
     /**
-     * The corresponding shape contains a header text field. 
+     * The corresponding shape contains a header text field.
      * The corresponding slide must be a notes master slide or handout master slide.
      */
     public static final byte MasterHeader = 10;
index 4a319c2c415e98ae6f39c341fe81ce5249a2b17e..f0975a152ebe83f36a0812dbc15c04acf4dd400e 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-import java.util.Date;\r
-\r
-import org.apache.poi.hslf.util.SystemTimeUtils;\r
-import org.apache.poi.util.LittleEndian;\r
-\r
-/**\r
- * Atom that contains information that describes shape client data.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class OEShapeAtom extends RecordAtom\r
-{\r
-\r
-    /**\r
-     * Record header.\r
-     */\r
-    private byte[] _header;\r
-\r
-    /**\r
-     * record data\r
-     */\r
-    private byte[] _recdata;\r
-\r
-    /**\r
-     * Constructs a brand new link related atom record.\r
-     */\r
-    public OEShapeAtom() {\r
-        _recdata = new byte[4];\r
-\r
-        _header = new byte[8];\r
-        LittleEndian.putShort(_header, 2, (short)getRecordType());\r
-        LittleEndian.putInt(_header, 4, _recdata.length);\r
-    }\r
-\r
-    /**\r
-     * Constructs the link related atom record from its\r
-     *  source data.\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start the start offset into the byte array.\r
-     * @param len the length of the slice in the byte array.\r
-     */\r
-    protected OEShapeAtom(byte[] source, int start, int len) {\r
-        // Get the header\r
-        _header = new byte[8];\r
-        System.arraycopy(source,start,_header,0,8);\r
-\r
-        // Grab the record data\r
-        _recdata = new byte[len-8];\r
-        System.arraycopy(source,start+8,_recdata,0,len-8);\r
-    }\r
-\r
-    /**\r
-     * Gets the record type.\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() { return RecordTypes.OEShapeAtom.typeID; }\r
-\r
-    /**\r
-     * Write the contents of the record back, so it can be written\r
-     * to disk\r
-     *\r
-     * @param out the output stream to write to.\r
-     * @throws java.io.IOException if an error occurs.\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        out.write(_header);\r
-        out.write(_recdata);\r
-    }\r
-\r
-    /**\r
-     * shape flags.\r
-     *\r
-     * @return  shape flags.\r
-     */\r
-    public int getOptions(){\r
-        return LittleEndian.getInt(_recdata, 0);\r
-    }\r
-\r
-    /**\r
-     * shape flags.\r
-     *\r
-     * @param id  shape flags.\r
-     */\r
-    public void setOptions(int id){\r
-         LittleEndian.putInt(_recdata, 0, id);\r
-    }\r
-}\r
+/* ====================================================================
+   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.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;
+
+/**
+ * Atom that contains information that describes shape client data.
+ *
+ * @author Yegor Kozlov
+ */
+public final class OEShapeAtom extends RecordAtom
+{
+
+    /**
+     * Record header.
+     */
+    private byte[] _header;
+
+    /**
+     * record data
+     */
+    private byte[] _recdata;
+
+    /**
+     * Constructs a brand new link related atom record.
+     */
+    public OEShapeAtom() {
+        _recdata = new byte[4];
+
+        _header = new byte[8];
+        LittleEndian.putShort(_header, 2, (short)getRecordType());
+        LittleEndian.putInt(_header, 4, _recdata.length);
+    }
+
+    /**
+     * Constructs the link related atom record from its
+     *  source data.
+     *
+     * @param source the source data as a byte array.
+     * @param start the start offset into the byte array.
+     * @param len the length of the slice in the byte array.
+     */
+    protected OEShapeAtom(byte[] source, int start, int len) {
+        // Get the header
+        _header = new byte[8];
+        System.arraycopy(source,start,_header,0,8);
+
+        // Grab the record data
+        _recdata = new byte[len-8];
+        System.arraycopy(source,start+8,_recdata,0,len-8);
+    }
+
+    /**
+     * Gets the record type.
+     * @return the record type.
+     */
+    public long getRecordType() { return RecordTypes.OEShapeAtom.typeID; }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     * to disk
+     *
+     * @param out the output stream to write to.
+     * @throws java.io.IOException if an error occurs.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        out.write(_header);
+        out.write(_recdata);
+    }
+
+    /**
+     * shape flags.
+     *
+     * @return  shape flags.
+     */
+    public int getOptions(){
+        return LittleEndian.getInt(_recdata, 0);
+    }
+
+    /**
+     * shape flags.
+     *
+     * @param id  shape flags.
+     */
+    public void setOptions(int id){
+         LittleEndian.putInt(_recdata, 0, id);
+    }
+}
index 51ec01669010d2a012ceb54b3d2f6a17623f2d4d..e44b360a589a414ae5abbbcfe4ff1c3ea99a31b5 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.record;
 
 import org.apache.poi.util.LittleEndian;
@@ -35,7 +36,7 @@ import java.io.IOException;
  * @author Yegor Kozlov
  */
 
-public class OutlineTextRefAtom extends RecordAtom {
+public final class OutlineTextRefAtom extends RecordAtom {
     /**
      * record header
      */
index 1705a8cede5d2af23bfb3cef5ddab9c906329331..519154c5b54a7b8412e66a7ae8bbd35c09216dfc 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.hslf.record;
 
@@ -36,7 +34,7 @@ import java.util.Iterator;
  * These are actually wrappers onto Escher drawings. Make use of
  *  the DDF classes to do useful things with them.
  * For now, creates a tree of the Escher records, and then creates any
- *  PowerPoint (hslf) records found within the EscherTextboxRecord 
+ *  PowerPoint (hslf) records found within the EscherTextboxRecord
  *  (msofbtClientTextbox) records.
  * Also provides easy access to the EscherTextboxRecords, so that their
  *  text may be extracted and used in Sheets
@@ -46,7 +44,7 @@ import java.util.Iterator;
 
 // For now, pretending to be an atom. Might not always be, but that
 //  would require a wrapping class
-public class PPDrawing extends RecordAtom
+public final class PPDrawing extends RecordAtom
 {
        private byte[] _header;
        private long _type;
@@ -70,7 +68,7 @@ public class PPDrawing extends RecordAtom
 
        /* ******************** record stuff follows ********************** */
 
-       /** 
+       /**
         * Sets everything up, groks the escher etc
         */
        protected PPDrawing(byte[] source, int start, int len) {
@@ -104,7 +102,7 @@ public class PPDrawing extends RecordAtom
                        textboxWrappers[i] = (EscherTextboxWrapper)textboxes.get(i);
                }
        }
-       
+
        /**
         * Creates a new, empty, PPDrawing (typically for use with a new Slide
         *  or Notes)
@@ -114,12 +112,12 @@ public class PPDrawing extends RecordAtom
                LittleEndian.putUShort(_header, 0, 15);
                LittleEndian.putUShort(_header, 2, (int)RecordTypes.PPDrawing.typeID);
                LittleEndian.putInt(_header, 4, 0);
-                
+
                textboxWrappers = new EscherTextboxWrapper[]{};
                create();
        }
 
-       /** 
+       /**
         * Tree walking way of finding Escher Child Records
         */
        private void findEscherChildren(DefaultEscherRecordFactory erf, byte[] source, int startPos, int lenToGo, Vector found) {
@@ -143,7 +141,7 @@ public class PPDrawing extends RecordAtom
          * 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. 
+         * 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());
@@ -156,7 +154,7 @@ public class PPDrawing extends RecordAtom
                }
        }
 
-       /** 
+       /**
         * Look for EscherTextboxRecords
         */
        private void findEscherTextboxRecord(EscherRecord[] toSearch, Vector found) {
@@ -189,7 +187,7 @@ public class PPDrawing extends RecordAtom
         */
        public long getRecordType() { return _type; }
 
-       /** 
+       /**
         * We're pretending to be an atom, so return null
         */
        public Record[] getChildRecords() { return null; }
@@ -245,11 +243,11 @@ public class PPDrawing extends RecordAtom
                EscherContainerRecord spgrContainer = new EscherContainerRecord();
                spgrContainer.setOptions((short)15);
                spgrContainer.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
-               
+
                EscherContainerRecord spContainer = new EscherContainerRecord();
                spContainer.setOptions((short)15);
                spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
-               
+
                EscherSpgrRecord spgr = new EscherSpgrRecord();
                spgr.setOptions((short)1);
                spContainer.addChildRecord(spgr);
@@ -287,14 +285,14 @@ public class PPDrawing extends RecordAtom
                        dgContainer
                };
        }
-       
+
        /**
         * Add a new EscherTextboxWrapper to this <code>PPDrawing</code>.
         */
        public void addTextboxWrapper(EscherTextboxWrapper txtbox){
                EscherTextboxWrapper[] tw = new EscherTextboxWrapper[textboxWrappers.length + 1];
                System.arraycopy(textboxWrappers, 0, tw, 0, textboxWrappers.length);
-               
+
                tw[textboxWrappers.length] = txtbox;
                textboxWrappers = tw;
        }
index a9ccd7071d27e5b93a8274ca9fd61fcd7dd31951..08d523c3e1106144bba5e2b275c9b98e078e2d4e 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hslf.record;
 
 import org.apache.poi.ddf.*;
@@ -28,12 +29,12 @@ import java.util.Iterator;
 /**
  * Container records which always exists inside Document.
  * It always acts as a holder for escher DGG container
- *  which may contain which Escher BStore container information 
+ *  which may contain which Escher BStore container information
  *  about pictures containes in the presentation (if any).
- * 
+ *
  * @author Yegor Kozlov
  */
-public class PPDrawingGroup extends RecordAtom {
+public final class PPDrawingGroup extends RecordAtom {
 
     private byte[] _header;
     private EscherContainerRecord dggContainer;
index e46e5837bf0cce0f861c3a32eba2b2892c6a6db1..c71699f35b4e197fd60205dcfc645953e1084be6 100644 (file)
@@ -1,25 +1,26 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* ====================================================================
+   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.hslf.record;
 
 /**
  * Interface to define how a record can indicate it cares about what its
  *  parent is, and how it wants to be told which record is its parent.
- * 
+ *
  * @author Nick Burch (nick at torchbox dot com)
  */
 public interface ParentAwareRecord {
index 68b8b7cafee2fb6394dc42cfb58e4832d6c5e2ac..4a32d76e0bd7d718d025759414c0307ed27e0e8b 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.hslf.record;
 
@@ -39,13 +37,13 @@ import java.util.Hashtable;
  * @author Nick Burch
  */
 
-public class PersistPtrHolder extends PositionDependentRecordAtom
+public final class PersistPtrHolder extends PositionDependentRecordAtom
 {
        private byte[] _header;
        private byte[] _ptrData; // Will need to update this once we allow updates to _slideLocations
        private long _type;
-       
-       /** 
+
+       /**
         * Holds the lookup for slides to their position on disk.
         * You always need to check the most recent PersistPtrHolder
         *  that knows about a given slide to find the right location
@@ -82,7 +80,7 @@ public class PersistPtrHolder extends PositionDependentRecordAtom
        }
        /**
         * Get the lookup from slide numbers to their offsets inside
-        *  _ptrData, used when adding or moving slides. 
+        *  _ptrData, used when adding or moving slides.
         */
        public Hashtable getSlideOffsetDataLocationsLookup() {
                return _slideOffsetDataLocation;
@@ -102,7 +100,7 @@ public class PersistPtrHolder extends PositionDependentRecordAtom
                // Add to the slide location lookup hash
                _slideLocations.put(new Integer(slideID), new Integer(posOnDisk));
                // Add to the ptrData offset lookup hash
-               _slideOffsetDataLocation.put(new Integer(slideID), 
+               _slideOffsetDataLocation.put(new Integer(slideID),
                                new Integer(_ptrData.length + 4));
 
                // Build the info block
@@ -122,7 +120,7 @@ public class PersistPtrHolder extends PositionDependentRecordAtom
                LittleEndian.putInt(_header,4,newPtrData.length);
        }
 
-       /** 
+       /**
         * Create a new holder for a PersistPtr record
         */
        protected PersistPtrHolder(byte[] source, int start, int len) {
@@ -181,7 +179,7 @@ public class PersistPtrHolder extends PositionDependentRecordAtom
 
        /**
         * At write-out time, update the references to the sheets to their
-        *  new positions 
+        *  new positions
         */
        public void updateOtherRecordReferences(Hashtable oldToNewReferencesLookup) {
                int[] slideIDs = getKnownSlideIDs();
index 8238d10fb9938a256f69051b52d39cf82f083ee6..339331865c13b6044dd46d1f6ce753ae0c9da27f 100755 (executable)
@@ -1,37 +1,36 @@
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-/**\r
- * A record that can be referenced in PersistPtr storage.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public interface PersistRecord {\r
-\r
-    /**\r
-     * Fetch the persist ID\r
-     */\r
-    public int getPersistId();\r
-\r
-    /**\r
-     * Set the persist ID\r
-     */\r
-    public void setPersistId(int id);\r
-}\r
+/* ====================================================================
+   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.hslf.record;
+
+/**
+ * A record that can be referenced in PersistPtr storage.
+ *
+ * @author Yegor Kozlov
+ */
+public interface PersistRecord {
+
+    /**
+     * Fetch the persist ID
+     */
+    public int getPersistId();
+
+    /**
+     * Set the persist ID
+     */
+    public void setPersistId(int id);
+}
index dbcbaa75bd0686a06f250e057b931c25b81255a5..d32f330736a914b088600186c3b66272db7b379d 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.hslf.record;
 import java.util.Hashtable;
@@ -39,14 +37,14 @@ public interface PositionDependentRecord
        /** Fetch our location on the disk, as of the last write out */
        public int getLastOnDiskOffset();
 
-       /** 
+       /**
         * Update the Record's idea of where on disk it lives, after a write out.
         * Use with care...
         */
        public void setLastOnDiskOffset(int offset);
 
        /**
-        * Offer the record the list of records that have changed their 
+        * Offer the record the list of records that have changed their
         *  location as part of the writeout.
         */
        public void updateOtherRecordReferences(Hashtable oldToNewReferencesLookup);
index fa9b9cb1cad3b919af501adac34b2b5a855f2579..adec35908ac9ea5f94ef69135fbbc5c645faba51 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.hslf.record;
 import java.util.Hashtable;
@@ -36,16 +34,16 @@ public abstract class PositionDependentRecordAtom extends RecordAtom implements
        /** Fetch our location on the disk, as of the last write out */
        public int getLastOnDiskOffset() { return myLastOnDiskOffset; }
 
-       /** 
+       /**
         * Update the Record's idea of where on disk it lives, after a write out.
         * Use with care...
         */
-       public void setLastOnDiskOffset(int offset) { 
+       public void setLastOnDiskOffset(int offset) {
                myLastOnDiskOffset = offset;
        }
 
        /**
-        * Offer the record the list of records that have changed their 
+        * Offer the record the list of records that have changed their
         *  location as part of the writeout.
         * Allows records to update their internal pointers to other records
         *  locations
index d33359bd4f4764a6a759cb4bbe0dc251823aa6a9..652c6d860e35b7d411cbe2c91f8719680a7d65ce 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 java.util.Hashtable;
 
 /**
  * A special (and dangerous) kind of Record Container, for which other
- *  Atoms care about where this one lives on disk. 
+ *  Atoms care about where this one lives on disk.
  * Will track its position on disk.
  *
  * @author Nick Burch
@@ -31,7 +29,7 @@ import java.util.Hashtable;
 public abstract class PositionDependentRecordContainer extends RecordContainer implements PositionDependentRecord
 {
        private int sheetId; // Found from PersistPtrHolder
-       
+
        /**
         * Fetch our sheet ID, as found from a PersistPtrHolder.
         * Should match the RefId of our matching SlidePersistAtom
@@ -43,18 +41,18 @@ public abstract class PositionDependentRecordContainer extends RecordContainer i
         */
        public void setSheetId(int id) { sheetId = id; }
 
-       
+
        /** Our location on the disk, as of the last write out */
        protected int myLastOnDiskOffset;
 
        /** Fetch our location on the disk, as of the last write out */
        public int getLastOnDiskOffset() { return myLastOnDiskOffset; }
 
-       /** 
+       /**
         * Update the Record's idea of where on disk it lives, after a write out.
         * Use with care...
         */
-       public void setLastOnDiskOffset(int offset) { 
+       public void setLastOnDiskOffset(int offset) {
                myLastOnDiskOffset = offset;
        }
 
index 46cb7479e22e37071c398edd3760e87aafde9307..62dd11ffd4ade097c52817356377ff8813a922b1 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -53,10 +50,10 @@ public abstract class Record
         */
        public abstract long getRecordType();
 
-       /** 
+       /**
         * Fetch all the child records of this record
         * If this record is an atom, will return null
-        * If this record is a non-atom, but has no children, will return 
+        * If this record is a non-atom, but has no children, will return
         *  an empty array
         */
        public abstract Record[] getChildRecords();
@@ -65,7 +62,7 @@ public abstract class Record
         * Have the contents printer out into an OutputStream, used when
         *  writing a file back out to disk
         * (Normally, atom classes will keep their bytes around, but
-        *  non atom classes will just request the bytes from their 
+        *  non atom classes will just request the bytes from their
         *  children, then chuck on their header and return)
         */
        public abstract void writeOut(OutputStream o) throws IOException;
@@ -86,7 +83,7 @@ public abstract class Record
                LittleEndian.putShort(bs,s);
                o.write(bs);
        }
-       
+
        /**
         * Build and return the Record at the given offset.
         * Note - does less error checking and handling than findChildRecords
@@ -171,7 +168,7 @@ public abstract class Record
                Class c = null;
                try {
                        c = RecordTypes.recordHandlingClass((int)type);
-                       if(c == null) { 
+                       if(c == null) {
                                // How odd. RecordTypes normally subsitutes in
                                //  a default handler class if it has heard of the record
                                //  type but there's no support for it. Explicitly request
index fbc2a7c211a8016be505e2f8e6619fec6812d35b..964d3d1c45c0cc775360cb62f383388c35260694 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.hslf.record;
 
@@ -27,12 +25,12 @@ package org.apache.poi.hslf.record;
 
 public abstract class RecordAtom extends Record
 {
-       /** 
+       /**
         * We are an atom
         */
        public boolean isAnAtom() { return true; }
 
-       /** 
+       /**
         * We're an atom, returns null
         */
        public Record[] getChildRecords() { return null; }
index 0772e0312113fd4b178533296e4dac86d3557e3c..9450e6986e792230dddca50e4bb693e5b40a611c 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.hslf.record;
 
@@ -38,18 +36,18 @@ public abstract class RecordContainer extends Record
 {
        protected Record[] _children;
        private Boolean changingChildRecordsLock = new Boolean(true);
-       
-       /** 
-        * Return any children 
+
+       /**
+        * Return any children
         */
        public Record[] getChildRecords() { return _children; }
 
-       /** 
+       /**
         * We're not an atom
         */
        public boolean isAnAtom() { return false; }
 
-       
+
        /* ===============================================================
         *                   Internal Move Helpers
         * ===============================================================
@@ -59,7 +57,7 @@ public abstract class RecordContainer extends Record
         * Finds the location of the given child record
         */
        private int findChildLocation(Record child) {
-               // Synchronized as we don't want things changing 
+               // Synchronized as we don't want things changing
                //  as we're doing our search
                synchronized(changingChildRecordsLock) {
                        for(int i=0; i<_children.length; i++) {
@@ -67,10 +65,10 @@ public abstract class RecordContainer extends Record
                                        return i;
                                }
                        }
-               }       
+               }
                return -1;
        }
-       
+
        /**
         * Adds a child record, at the very end.
         * @param newChild The child record to add
@@ -85,7 +83,7 @@ public abstract class RecordContainer extends Record
                        _children = nc;
                }
        }
-       
+
        /**
         * Adds the given new Child Record at the given location,
         *  shuffling everything from there on down by one
@@ -96,12 +94,12 @@ public abstract class RecordContainer extends Record
                synchronized(changingChildRecordsLock) {
                        // Firstly, have the child added in at the end
                        appendChild(newChild);
-                       
+
                        // Now, have them moved to the right place
                        moveChildRecords( (_children.length-1), position, 1 );
                }
        }
-       
+
        /**
         * Moves <i>number</i> child records from <i>oldLoc</i>
         *  to <i>newLoc</i>. Caller must have the changingChildRecordsLock
@@ -112,17 +110,17 @@ public abstract class RecordContainer extends Record
        private void moveChildRecords(int oldLoc, int newLoc, int number) {
                if(oldLoc == newLoc) { return; }
                if(number == 0) { return; }
-                       
+
                // Check that we're not asked to move too many
                if(oldLoc+number > _children.length) {
                        throw new IllegalArgumentException("Asked to move more records than there are!");
                }
-               
+
                // Do the move
                ArrayUtil.arrayMoveWithin(_children, oldLoc, newLoc, number);
        }
-       
-       
+
+
        /**
         * Finds the first child record of the given type,
         *  or null if none of the child records are of the
@@ -136,7 +134,7 @@ public abstract class RecordContainer extends Record
                }
                return null;
        }
-       
+
        /* ===============================================================
         *                   External Move Methods
         * ===============================================================
@@ -150,7 +148,7 @@ public abstract class RecordContainer extends Record
                        appendChild(newChild);
                }
        }
-       
+
        /**
         * Adds the given Child Record after the supplied record
         * @param newChild
@@ -163,12 +161,12 @@ public abstract class RecordContainer extends Record
                        if(loc == -1) {
                                throw new IllegalArgumentException("Asked to add a new child after another record, but that record wasn't one of our children!");
                        }
-                               
+
                        // Add one place after the supplied record
                        addChildAt(newChild, loc+1);
                }
        }
-       
+
        /**
         * Adds the given Child Record before the supplied record
         * @param newChild
@@ -181,49 +179,49 @@ public abstract class RecordContainer extends Record
                        if(loc == -1) {
                                throw new IllegalArgumentException("Asked to add a new child before another record, but that record wasn't one of our children!");
                        }
-                               
+
                        // Add at the place of the supplied record
                        addChildAt(newChild, loc);
                }
        }
-       
+
        /**
         * Moves the given Child Record to before the supplied record
         */
        public void moveChildBefore(Record child, Record before) {
                moveChildrenBefore(child, 1, before);
        }
-       
+
        /**
         * Moves the given Child Records to before the supplied record
         */
        public void moveChildrenBefore(Record firstChild, int number, Record before) {
                if(number < 1) { return; }
-               
+
                synchronized(changingChildRecordsLock) {
                        // Decide where we're going to put them
                        int newLoc = findChildLocation(before);
                        if(newLoc == -1) {
                                throw new IllegalArgumentException("Asked to move children before another record, but that record wasn't one of our children!");
                        }
-                       
+
                        // Figure out where they are now
                        int oldLoc = findChildLocation(firstChild);
                        if(oldLoc == -1) {
                                throw new IllegalArgumentException("Asked to move a record that wasn't a child!");
                        }
-                       
+
                        // Actually move
                        moveChildRecords(oldLoc, newLoc, number);
                }
        }
-       
+
        /**
-        * Moves the given Child Records to after the supplied record 
+        * Moves the given Child Records to after the supplied record
         */
        public void moveChildrenAfter(Record firstChild, int number, Record after) {
                if(number < 1) { return; }
-               
+
                synchronized(changingChildRecordsLock) {
                        // Decide where we're going to put them
                        int newLoc = findChildLocation(after);
@@ -232,20 +230,20 @@ public abstract class RecordContainer extends Record
                        }
                        // We actually want after this though
                        newLoc++;
-                       
+
                        // Figure out where they are now
                        int oldLoc = findChildLocation(firstChild);
                        if(oldLoc == -1) {
                                throw new IllegalArgumentException("Asked to move a record that wasn't a child!");
                        }
-                       
+
                        // Actually move
                        moveChildRecords(oldLoc, newLoc, number);
                }
        }
 
     /**
-     * Set child records. 
+     * Set child records.
      *
      * @param records   the new child records
      */
@@ -269,7 +267,7 @@ public abstract class RecordContainer extends Record
        public void writeOut(byte headerA, byte headerB, long type, Record[] children, OutputStream out) throws IOException {
                // If we have a mutable output stream, take advantage of that
                if(out instanceof MutableByteArrayOutputStream) {
-                       MutableByteArrayOutputStream mout = 
+                       MutableByteArrayOutputStream mout =
                                (MutableByteArrayOutputStream)out;
 
                        // Grab current size
index 7fb46e4fd1681a151fbbfb88a17199c53931451c..9532805a8b4bcee6e9d7703f104eec4cbdfeec0f 100644 (file)
@@ -30,7 +30,7 @@ import java.lang.reflect.Field;
  * @author Yegor Kozlov
  * @author Nick Burch
  */
-public class RecordTypes {
+public final class RecordTypes {
     public static HashMap typeToName;
     public static HashMap typeToClass;
 
@@ -152,14 +152,14 @@ public class RecordTypes {
     public static final Type PersistPtrIncrementalBlock = new Type(6002,PersistPtrHolder.class);
     public static final Type GScalingAtom = new Type(10001,null);
     public static final Type GRColorAtom = new Type(10002,null);
-    
+
     // Records ~12000 seem to be related to the Comments used in PPT 2000/XP
     // (Comments in PPT97 are normal Escher text boxes)
     public static final Type Comment2000 = new Type(12000,Comment2000.class);
     public static final Type Comment2000Atom = new Type(12001,Comment2000Atom.class);
     public static final Type Comment2000Summary = new Type(12004,null);
     public static final Type Comment2000SummaryAtom = new Type(12005,null);
-    
+
     // Records ~12050 seem to be related to Document Encryption
     public static final Type DocumentEncryptionAtom = new Type(12052,DocumentEncryptionAtom.class);
 
@@ -265,7 +265,7 @@ public class RecordTypes {
     }
 
 
-       /** 
+       /**
         * Wrapper for the details of a PowerPoint or Escher record type.
         * Contains both the type, and the handling class (if any), and
         *  offers methods to get either back out.
index 0f49b5bd03277a25cab8844938091756ab59b0df..26b9e95f17bc339a35b0c86d5efeb634c6acedfb 100644 (file)
@@ -1,99 +1,98 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-import java.util.Date;\r
-\r
-import org.apache.poi.hslf.util.SystemTimeUtils;\r
-import org.apache.poi.util.LittleEndian;\r
-\r
-/**\r
- * An atom record that specifies that a shape is a header or footer placeholder shape\r
- *\r
- * @since  PowerPoint 2007\r
- * @author Yegor Kozlov\r
- */\r
-\r
-public class RoundTripHFPlaceholder12 extends RecordAtom\r
-{\r
-    /**\r
-     * Record header.\r
-     */\r
-    private byte[] _header;\r
-\r
-    /**\r
-     * Specifies the placeholder shape ID.\r
-     *\r
-     * MUST be {@link OEPlaceholderAtom#MasterDate},  {@link OEPlaceholderAtom#MasterSlideNumber}, \r
-     * {@link OEPlaceholderAtom#MasterFooter}, or {@link OEPlaceholderAtom#MasterHeader}\r
-     */\r
-    private byte _placeholderId;\r
-\r
-    /**\r
-     * Constructs the comment atom record from its source data.\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start the start offset into the byte array.\r
-     * @param len the length of the slice in the byte array.\r
-     */\r
-    protected RoundTripHFPlaceholder12(byte[] source, int start, int len) {\r
-        // Get the header.\r
-        _header = new byte[8];\r
-        System.arraycopy(source,start,_header,0,8);\r
-\r
-        // Get the record data.\r
-        _placeholderId = source[start+8];\r
-    }\r
-\r
-    /**\r
-     * Gets the comment number (note - each user normally has their own count).\r
-     * @return the comment number.\r
-     */\r
-    public int getPlaceholderId() {\r
-        return _placeholderId;\r
-    }\r
-\r
-    /**\r
-     * Sets the comment number (note - each user normally has their own count).\r
-     * @param number the comment number.\r
-     */\r
-    public void setPlaceholderId(int number) {\r
-        _placeholderId = (byte)number;\r
-    }\r
-\r
-    /**\r
-     * Gets the record type.\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() { return RecordTypes.RoundTripHFPlaceholder12.typeID; }\r
-\r
-    /**\r
-     * Write the contents of the record back, so it can be written\r
-     * to disk\r
-     *\r
-     * @param out the output stream to write to.\r
-     * @throws java.io.IOException if an error occurs.\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        out.write(_header);\r
-        out.write(_placeholderId);\r
-    }\r
-}
\ No newline at end of file
+/* ====================================================================
+   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.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
+ *
+ * @since  PowerPoint 2007
+ * @author Yegor Kozlov
+ */
+
+public final class RoundTripHFPlaceholder12 extends RecordAtom
+{
+    /**
+     * Record header.
+     */
+    private byte[] _header;
+
+    /**
+     * Specifies the placeholder shape ID.
+     *
+     * MUST be {@link OEPlaceholderAtom#MasterDate},  {@link OEPlaceholderAtom#MasterSlideNumber},
+     * {@link OEPlaceholderAtom#MasterFooter}, or {@link OEPlaceholderAtom#MasterHeader}
+     */
+    private byte _placeholderId;
+
+    /**
+     * Constructs the comment atom record from its source data.
+     *
+     * @param source the source data as a byte array.
+     * @param start the start offset into the byte array.
+     * @param len the length of the slice in the byte array.
+     */
+    protected RoundTripHFPlaceholder12(byte[] source, int start, int len) {
+        // Get the header.
+        _header = new byte[8];
+        System.arraycopy(source,start,_header,0,8);
+
+        // Get the record data.
+        _placeholderId = source[start+8];
+    }
+
+    /**
+     * Gets the comment number (note - each user normally has their own count).
+     * @return the comment number.
+     */
+    public int getPlaceholderId() {
+        return _placeholderId;
+    }
+
+    /**
+     * Sets the comment number (note - each user normally has their own count).
+     * @param number the comment number.
+     */
+    public void setPlaceholderId(int number) {
+        _placeholderId = (byte)number;
+    }
+
+    /**
+     * Gets the record type.
+     * @return the record type.
+     */
+    public long getRecordType() { return RecordTypes.RoundTripHFPlaceholder12.typeID; }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     * to disk
+     *
+     * @param out the output stream to write to.
+     * @throws java.io.IOException if an error occurs.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        out.write(_header);
+        out.write(_placeholderId);
+    }
+}
index 1f0ece6014332eba978ef20d8294fe52c02b35ac..08c05c46af2d7b228f3a2b705aa0e89509d4cf08 100644 (file)
@@ -1,32 +1,33 @@
-/*\r
-* Licensed to the Apache Software Foundation (ASF) under one or more\r
-* contributor license agreements.  See the NOTICE file distributed with\r
-* this work for additional information regarding copyright ownership.\r
-* The ASF licenses this file to You under the Apache License, Version 2.0\r
-* (the "License"); you may not use this file except in compliance with\r
-* the License.  You may obtain a copy of the License at\r
-*\r
-*     http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*/\r
-package org.apache.poi.hslf.record;\r
-\r
-/**\r
- * The superclass of all sheet container records - Slide, Notes, MainMaster, etc.\r
- */\r
-public abstract class SheetContainer extends PositionDependentRecordContainer {\r
-\r
-    /**\r
-     * Returns the PPDrawing of this sheet, which has all the\r
-     *  interesting data in it\r
-     */\r
-    public abstract PPDrawing getPPDrawing();\r
-\r
-    public abstract ColorSchemeAtom getColorScheme();\r
-\r
-}\r
+/* ====================================================================
+   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.hslf.record;
+
+/**
+ * The superclass of all sheet container records - Slide, Notes, MainMaster, etc.
+ */
+public abstract class SheetContainer extends PositionDependentRecordContainer {
+
+    /**
+     * Returns the PPDrawing of this sheet, which has all the
+     *  interesting data in it
+     */
+    public abstract PPDrawing getPPDrawing();
+
+    public abstract ColorSchemeAtom getColorScheme();
+
+}
index 26bdfc8046aa938c762823563ed896bf280f8c38..a833c4016a60b74facca7803303ddd9fafb68f63 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.hslf.record;
 
@@ -31,7 +29,7 @@ import org.apache.poi.util.LittleEndian;
  * @author Nick Burch
  */
 
-public class Slide extends SheetContainer
+public final class Slide extends SheetContainer
 {
        private byte[] _header;
        private static long _type = 1006l;
@@ -47,13 +45,13 @@ public class Slide extends SheetContainer
        public SlideAtom getSlideAtom() { return slideAtom; }
 
        /**
-        * Returns the PPDrawing of this Slide, which has all the 
+        * Returns the PPDrawing of this Slide, which has all the
         *  interesting data in it
         */
        public PPDrawing getPPDrawing() { return ppDrawing; }
 
 
-       /** 
+       /**
         * Set things up, and find our more interesting children
         */
        protected Slide(byte[] source, int start, int len) {
@@ -105,7 +103,7 @@ public class Slide extends SheetContainer
         * We are of type 1006
         */
        public long getRecordType() { return _type; }
-       
+
        /**
         * Write the contents of the record back, so it can be written
         *  to disk
index 7e05bf858566cf6cc8d02361308a1467565addcd..f759ed02c1083fd1d06955b893cdf3479e58598b 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.hslf.record;
 
@@ -31,7 +29,7 @@ import java.io.OutputStream;
  * @author Nick Burch
  */
 
-public class SlideAtom extends RecordAtom
+public final class SlideAtom extends RecordAtom
 {
        private byte[] _header;
        private static long _type = 1007l;
@@ -50,7 +48,7 @@ public class SlideAtom extends RecordAtom
 
        /** Get the ID of the master slide used. 0 if this is a master slide, otherwise -2147483648 */
        public int getMasterID() { return masterID; }
-    /** Change slide master.  */ 
+    /** Change slide master.  */
     public void setMasterID(int id) { masterID = id; }
        /** Get the ID of the notes for this slide. 0 if doesn't have one */
        public int getNotesID()  { return notesID; }
@@ -70,7 +68,7 @@ public class SlideAtom extends RecordAtom
 
        /* *************** record code follows ********************** */
 
-       /** 
+       /**
         * For the Slide Atom
         */
        protected SlideAtom(byte[] source, int start, int len) {
@@ -114,7 +112,7 @@ public class SlideAtom extends RecordAtom
                reserved = new byte[len-30];
                System.arraycopy(source,start+30,reserved,0,reserved.length);
        }
-       
+
        /**
         * Create a new SlideAtom, to go with a new Slide
         */
@@ -123,7 +121,7 @@ public class SlideAtom extends RecordAtom
                LittleEndian.putUShort(_header, 0, 2);
                LittleEndian.putUShort(_header, 2, (int)_type);
                LittleEndian.putInt(_header, 4, 24);
-                
+
                byte[] ssdate = new byte[12];
                layoutAtom = new SSlideLayoutAtom(ssdate);
                layoutAtom.setGeometryType(SSlideLayoutAtom.BLANK_SLIDE);
@@ -172,7 +170,7 @@ public class SlideAtom extends RecordAtom
         * Holds the geometry of the Slide, and the ID of the placeholders
         *  on the slide.
         * (Embeded inside SlideAtom is a SSlideLayoutAtom, without the
-        *  usual record header. Since it's a fixed size and tied to 
+        *  usual record header. Since it's a fixed size and tied to
         *  the SlideAtom, we'll hold it here.)
         */
        public class SSlideLayoutAtom {
index 03f5778139526ccdfb0edd5995fb21ff7f885a75..11bd4752c7d0c10f465e2715fc861b270aaca95e 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.hslf.record;
 
@@ -48,7 +46,7 @@ import java.util.Vector;
  */
 
 // For now, pretend to be an atom
-public class SlideListWithText extends RecordContainer
+public final class SlideListWithText extends RecordContainer
 {
 
     /**
@@ -72,7 +70,7 @@ public class SlideListWithText extends RecordContainer
 
        private SlideAtomsSet[] slideAtomsSets;
 
-       /** 
+       /**
         * Create a new holder for slide records
         */
        protected SlideListWithText(byte[] source, int start, int len) {
@@ -81,10 +79,10 @@ public class SlideListWithText extends RecordContainer
                System.arraycopy(source,start,_header,0,8);
 
                // Find our children
-               _children = Record.findChildRecords(source,start+8,len-8);      
+               _children = Record.findChildRecords(source,start+8,len-8);
 
                // Group our children together into SlideAtomsSets
-               // That way, model layer code can just grab the sets to use, 
+               // That way, model layer code can just grab the sets to use,
                //  without having to try to match the children together
                Vector sets = new Vector();
                for(int i=0; i<_children.length; i++) {
@@ -98,7 +96,7 @@ public class SlideListWithText extends RecordContainer
                                int clen = endPos - i - 1;
                                boolean emptySet = false;
                                if(clen == 0) { emptySet = true; }
-                               
+
                                // Create a SlideAtomsSets, not caring if they're empty
                                //if(emptySet) { continue; }
                                Record[] spaChildren = new Record[clen];
@@ -127,11 +125,11 @@ public class SlideListWithText extends RecordContainer
                LittleEndian.putUShort(_header, 2, (int)_type);
                LittleEndian.putInt(_header, 4, 0);
 
-               // We have no children to start with 
+               // We have no children to start with
                _children = new Record[0];
                slideAtomsSets = new SlideAtomsSet[0];
        }
-       
+
        /**
         * Add a new SlidePersistAtom, to the end of the current list,
         *  and update the internal list of SlidePersistAtoms
@@ -184,7 +182,7 @@ public class SlideListWithText extends RecordContainer
        /**
         * Inner class to wrap up a matching set of records that hold the
         *  text for a given sheet. Contains the leading SlidePersistAtom,
-        *  and all of the records until the next SlidePersistAtom. This 
+        *  and all of the records until the next SlidePersistAtom. This
         *  includes sets of TextHeaderAtom and TextBytesAtom/TextCharsAtom,
         *  along with some others.
         */
index 2539bc570879840c4668d0fe8bd1696cad6fb812..a567cff83027916f0e711a007c7ff6683469c113 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.hslf.record;
 
@@ -30,22 +28,22 @@ import java.io.OutputStream;
  * @author Nick Burch
  */
 
-public class SlidePersistAtom extends RecordAtom
+public final class SlidePersistAtom extends RecordAtom
 {
        private byte[] _header;
        private static long _type = 1011l;
 
-       /** 
-        * Slide reference ID. Should correspond to the PersistPtr 
-        *  "sheet ID" of the matching slide/notes record 
+       /**
+        * Slide reference ID. Should correspond to the PersistPtr
+        *  "sheet ID" of the matching slide/notes record
         */
        private int refID;
        private boolean hasShapesOtherThanPlaceholders;
        /** Number of placeholder texts that will follow in the SlideListWithText */
        private int numPlaceholderTexts;
-       /** 
+       /**
         * The internal identifier (256+), which is used to tie slides
-        *  and notes together 
+        *  and notes together
         */
        private int slideIdentifier;
        /** Reserved fields. Who knows what they do */
@@ -55,7 +53,7 @@ public class SlidePersistAtom extends RecordAtom
        public int getSlideIdentifier() { return slideIdentifier; }
        public int getNumPlaceholderTexts() { return numPlaceholderTexts; }
        public boolean getHasShapesOtherThanPlaceholders() { return hasShapesOtherThanPlaceholders; }
-       
+
        // Only set these if you know what you're doing!
        public void setRefID(int id) {
                refID = id;
@@ -66,7 +64,7 @@ public class SlidePersistAtom extends RecordAtom
 
        /* *************** record code follows ********************** */
 
-       /** 
+       /**
         * For the SlidePersist Atom
         */
        protected SlidePersistAtom(byte[] source, int start, int len) {
@@ -94,12 +92,12 @@ public class SlidePersistAtom extends RecordAtom
                // Last useful one is the unique slide identifier
                slideIdentifier = (int)LittleEndian.getInt(source,start+20);
 
-               // Finally you have typically 4 or 8 bytes of reserved fields, 
+               // Finally you have typically 4 or 8 bytes of reserved fields,
                //  all zero running from 24 bytes in to the end
                reservedFields = new byte[len-24];
                System.arraycopy(source,start+24,reservedFields,0,reservedFields.length);
        }
-       
+
        /**
         * Create a new SlidePersistAtom, for use with a new Slide
         */
index 211a9b0ee4a298cccaafb6030a38020d6ef6104f..f454e4d2088dedea97e2ec32752d0482fe9ab4b8 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.record;\r
-\r
-import org.apache.poi.util.POILogger;\r
-\r
-import java.io.OutputStream;\r
-import java.io.IOException;\r
-\r
-/**\r
- * A container holding information about a sound. It contains:\r
- * <p>\r
- * <li>1. CString (4026), Instance 0: Name of sound (e.g. "crash")\r
- * <li>2. CString (4026), Instance 1: Type of sound (e.g. ".wav")\r
- * <li>3. CString (4026), Instance 2: Reference id of sound in sound collection\r
- * <li>4. CString (4026), Instance 3, optional: Built-in id of sound, for sounds we ship. This is the id that?s in the reg file.\r
- * <li>5. SoundData (2023), optional\r
- * </p>\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class Sound extends RecordContainer {\r
-    /**\r
-     * Record header data.\r
-     */\r
-    private byte[] _header;\r
-\r
-    // Links to our more interesting children\r
-    private CString _name;\r
-    private CString _type;\r
-    private SoundData _data;\r
-\r
-\r
-    /**\r
-     * Set things up, and find our more interesting children\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start the start offset into the byte array.\r
-     * @param len the length of the slice in the byte array.\r
-     */\r
-    protected Sound(byte[] source, int start, int len) {\r
-        // Grab the header\r
-        _header = new byte[8];\r
-        System.arraycopy(source,start,_header,0,8);\r
-\r
-        // Find our children\r
-        _children = Record.findChildRecords(source,start+8,len-8);\r
-        findInterestingChildren();\r
-    }\r
-\r
-    private void findInterestingChildren() {\r
-        // First child should be the ExHyperlinkAtom\r
-        if(_children[0] instanceof CString) {\r
-            _name = (CString)_children[0];\r
-        } else {\r
-            logger.log(POILogger.ERROR, "First child record wasn't a CString, was of type " + _children[0].getRecordType());\r
-        }\r
-\r
-        // Second child should be the ExOleObjAtom\r
-        if (_children[1] instanceof CString) {\r
-            _type = (CString)_children[1];\r
-        } else {\r
-            logger.log(POILogger.ERROR, "Second child record wasn't a CString, was of type " + _children[1].getRecordType());\r
-        }\r
-\r
-        for (int i = 2; i < _children.length; i++) {\r
-            if(_children[i] instanceof SoundData){\r
-                _data = (SoundData)_children[i];\r
-                break;\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    /**\r
-     * Returns the type (held as a little endian in bytes 3 and 4)\r
-     * that this class handles.\r
-     *\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() {\r
-        return RecordTypes.Sound.typeID;\r
-    }\r
-\r
-    /**\r
-     * Have the contents printer out into an OutputStream, used when\r
-     * writing a file back out to disk.\r
-     *\r
-     * @param out the output stream.\r
-     * @throws java.io.IOException if there was an error writing to the stream.\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        writeOut(_header[0],_header[1],getRecordType(),_children,out);\r
-    }\r
-\r
-    /**\r
-     * Name of the sound (e.g. "crash")\r
-     *\r
-     * @return name of the sound\r
-     */\r
-    public String getSoundName(){\r
-        return _name.getText();\r
-    }\r
-\r
-    /**\r
-     * Type of the sound (e.g. ".wav")\r
-     *\r
-     * @return type of the sound\r
-     */\r
-    public String getSoundType(){\r
-        return _type.getText();\r
-    }\r
-\r
-    /**\r
-     * The sound data\r
-     *\r
-     * @return the sound data.\r
-     */\r
-    public byte[] getSoundData(){\r
-        return _data == null ? null : _data.getData();\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.record;
+
+import org.apache.poi.util.POILogger;
+
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * A container holding information about a sound. It contains:
+ * <p>
+ * <li>1. CString (4026), Instance 0: Name of sound (e.g. "crash")
+ * <li>2. CString (4026), Instance 1: Type of sound (e.g. ".wav")
+ * <li>3. CString (4026), Instance 2: Reference id of sound in sound collection
+ * <li>4. CString (4026), Instance 3, optional: Built-in id of sound, for sounds we ship. This is the id that?s in the reg file.
+ * <li>5. SoundData (2023), optional
+ * </p>
+ *
+ * @author Yegor Kozlov
+ */
+public final class Sound extends RecordContainer {
+    /**
+     * Record header data.
+     */
+    private byte[] _header;
+
+    // Links to our more interesting children
+    private CString _name;
+    private CString _type;
+    private SoundData _data;
+
+
+    /**
+     * Set things up, and find our more interesting children
+     *
+     * @param source the source data as a byte array.
+     * @param start the start offset into the byte array.
+     * @param len the length of the slice in the byte array.
+     */
+    protected Sound(byte[] source, int start, int len) {
+        // Grab the header
+        _header = new byte[8];
+        System.arraycopy(source,start,_header,0,8);
+
+        // Find our children
+        _children = Record.findChildRecords(source,start+8,len-8);
+        findInterestingChildren();
+    }
+
+    private void findInterestingChildren() {
+        // First child should be the ExHyperlinkAtom
+        if(_children[0] instanceof CString) {
+            _name = (CString)_children[0];
+        } else {
+            logger.log(POILogger.ERROR, "First child record wasn't a CString, was of type " + _children[0].getRecordType());
+        }
+
+        // Second child should be the ExOleObjAtom
+        if (_children[1] instanceof CString) {
+            _type = (CString)_children[1];
+        } else {
+            logger.log(POILogger.ERROR, "Second child record wasn't a CString, was of type " + _children[1].getRecordType());
+        }
+
+        for (int i = 2; i < _children.length; i++) {
+            if(_children[i] instanceof SoundData){
+                _data = (SoundData)_children[i];
+                break;
+            }
+        }
+
+    }
+
+    /**
+     * Returns the type (held as a little endian in bytes 3 and 4)
+     * that this class handles.
+     *
+     * @return the record type.
+     */
+    public long getRecordType() {
+        return RecordTypes.Sound.typeID;
+    }
+
+    /**
+     * Have the contents printer out into an OutputStream, used when
+     * writing a file back out to disk.
+     *
+     * @param out the output stream.
+     * @throws java.io.IOException if there was an error writing to the stream.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        writeOut(_header[0],_header[1],getRecordType(),_children,out);
+    }
+
+    /**
+     * Name of the sound (e.g. "crash")
+     *
+     * @return name of the sound
+     */
+    public String getSoundName(){
+        return _name.getText();
+    }
+
+    /**
+     * Type of the sound (e.g. ".wav")
+     *
+     * @return type of the sound
+     */
+    public String getSoundType(){
+        return _type.getText();
+    }
+
+    /**
+     * The sound data
+     *
+     * @return the sound data.
+     */
+    public byte[] getSoundData(){
+        return _data == null ? null : _data.getData();
+    }
+}
index c244859ea0e96f17cc8eb7a72037a8c974560872..8d86b175e7196bfdf74b181822fe3cf1d928fbcb 100755 (executable)
@@ -1,73 +1,74 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.record;\r
-\r
-import org.apache.poi.util.POILogger;\r
-\r
-import java.io.OutputStream;\r
-import java.io.IOException;\r
-\r
-/**\r
- * Is a container for all sound related atoms and containers. It contains:\r
- *<li>1. SoundCollAtom (2021)\r
- *<li>2. Sound (2022), for each sound, if any\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class SoundCollection extends RecordContainer {\r
-    /**\r
-     * Record header data.\r
-     */\r
-    private byte[] _header;\r
-\r
-    /**\r
-     * Set things up, and find our more interesting children\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start the start offset into the byte array.\r
-     * @param len the length of the slice in the byte array.\r
-     */\r
-    protected SoundCollection(byte[] source, int start, int len) {\r
-        // Grab the header\r
-        _header = new byte[8];\r
-        System.arraycopy(source,start,_header,0,8);\r
-\r
-        // Find our children\r
-        _children = Record.findChildRecords(source,start+8,len-8);\r
-    }\r
-\r
-    /**\r
-     * Returns the type (held as a little endian in bytes 3 and 4)\r
-     * that this class handles.\r
-     *\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() {\r
-        return RecordTypes.SoundCollection.typeID;\r
-    }\r
-\r
-    /**\r
-     * Have the contents printer out into an OutputStream, used when\r
-     * writing a file back out to disk.\r
-     *\r
-     * @param out the output stream.\r
-     * @throws java.io.IOException if there was an error writing to the stream.\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        writeOut(_header[0],_header[1],getRecordType(),_children,out);\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.record;
+
+import org.apache.poi.util.POILogger;
+
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * Is a container for all sound related atoms and containers. It contains:
+ *<li>1. SoundCollAtom (2021)
+ *<li>2. Sound (2022), for each sound, if any
+ *
+ * @author Yegor Kozlov
+ */
+public final class SoundCollection extends RecordContainer {
+    /**
+     * Record header data.
+     */
+    private byte[] _header;
+
+    /**
+     * Set things up, and find our more interesting children
+     *
+     * @param source the source data as a byte array.
+     * @param start the start offset into the byte array.
+     * @param len the length of the slice in the byte array.
+     */
+    protected SoundCollection(byte[] source, int start, int len) {
+        // Grab the header
+        _header = new byte[8];
+        System.arraycopy(source,start,_header,0,8);
+
+        // Find our children
+        _children = Record.findChildRecords(source,start+8,len-8);
+    }
+
+    /**
+     * Returns the type (held as a little endian in bytes 3 and 4)
+     * that this class handles.
+     *
+     * @return the record type.
+     */
+    public long getRecordType() {
+        return RecordTypes.SoundCollection.typeID;
+    }
+
+    /**
+     * Have the contents printer out into an OutputStream, used when
+     * writing a file back out to disk.
+     *
+     * @param out the output stream.
+     * @throws java.io.IOException if there was an error writing to the stream.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        writeOut(_header[0],_header[1],getRecordType(),_children,out);
+    }
+}
index 42be48f2ac8115559814e7436945278442b5defd..6492d0175cba467742c4a8c5f4814f1f14329f79 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.ByteArrayInputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.OutputStream;\r
-import java.util.zip.InflaterInputStream;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-\r
-/**\r
- * Storage for embedded sounds.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class SoundData extends RecordAtom {\r
-\r
-    /**\r
-     * Record header.\r
-     */\r
-    private byte[] _header;\r
-\r
-    /**\r
-     * Record data.\r
-     */\r
-    private byte[] _data;\r
-\r
-    /**\r
-     * Constructs a new empty sound container.\r
-     */\r
-    protected SoundData() {\r
-        _header = new byte[8];\r
-        _data = new byte[0];\r
-\r
-        LittleEndian.putShort(_header, 2, (short)getRecordType());\r
-        LittleEndian.putInt(_header, 4, _data.length);\r
-    }\r
-\r
-    /**\r
-     * Constructs the link related atom record from its\r
-     *  source data.\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start the start offset into the byte array.\r
-     * @param len the length of the slice in the byte array.\r
-     */\r
-    protected SoundData(byte[] source, int start, int len) {\r
-        // Get the header.\r
-        _header = new byte[8];\r
-        System.arraycopy(source,start,_header,0,8);\r
-\r
-        // Get the record data.\r
-        _data = new byte[len-8];\r
-        System.arraycopy(source,start+8,_data,0,len-8);\r
-    }\r
-\r
-    /**\r
-     * Returns the sound data.\r
-     *\r
-     * @return the sound data \r
-     */\r
-    public byte[] getData() {\r
-        return _data;\r
-    }\r
-\r
-    /**\r
-     * Gets the record type.\r
-     *\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() {\r
-        return RecordTypes.SoundData.typeID;\r
-    }\r
-\r
-    /**\r
-     * Write the contents of the record back, so it can be written\r
-     * to disk.\r
-     *\r
-     * @param out the output stream to write to.\r
-     * @throws java.io.IOException if an error occurs.\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        out.write(_header);\r
-        out.write(_data);\r
-    }\r
-}\r
+/* ====================================================================
+   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.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;
+
+/**
+ * Storage for embedded sounds.
+ *
+ * @author Yegor Kozlov
+ */
+public final class SoundData extends RecordAtom {
+
+    /**
+     * Record header.
+     */
+    private byte[] _header;
+
+    /**
+     * Record data.
+     */
+    private byte[] _data;
+
+    /**
+     * Constructs a new empty sound container.
+     */
+    protected SoundData() {
+        _header = new byte[8];
+        _data = new byte[0];
+
+        LittleEndian.putShort(_header, 2, (short)getRecordType());
+        LittleEndian.putInt(_header, 4, _data.length);
+    }
+
+    /**
+     * Constructs the link related atom record from its
+     *  source data.
+     *
+     * @param source the source data as a byte array.
+     * @param start the start offset into the byte array.
+     * @param len the length of the slice in the byte array.
+     */
+    protected SoundData(byte[] source, int start, int len) {
+        // 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);
+    }
+
+    /**
+     * Returns the sound data.
+     *
+     * @return the sound data
+     */
+    public byte[] getData() {
+        return _data;
+    }
+
+    /**
+     * Gets the record type.
+     *
+     * @return the record type.
+     */
+    public long getRecordType() {
+        return RecordTypes.SoundData.typeID;
+    }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     * to disk.
+     *
+     * @param out the output stream to write to.
+     * @throws java.io.IOException if an error occurs.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        out.write(_header);
+        out.write(_data);
+    }
+}
index 7f084d82e43e0428ee18fb627667f55775daa292..7e77c2f949034ecf3bb493e18c0a71be2a044ffb 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.hslf.record;
 
@@ -35,7 +33,7 @@ import org.apache.poi.util.POILogger;
 import org.apache.poi.util.HexDump;
 
 /**
- * A StyleTextPropAtom (type 4001). Holds basic character properties 
+ * A StyleTextPropAtom (type 4001). Holds basic character properties
  *  (bold, italic, underline, font size etc) and paragraph properties
  *  (alignment, line spacing etc) for the block of text (TextBytesAtom
  *  or TextCharsAtom) that this record follows.
@@ -51,7 +49,7 @@ import org.apache.poi.util.HexDump;
  * @author Yegor Kozlov
  */
 
-public class StyleTextPropAtom extends RecordAtom
+public final class StyleTextPropAtom extends RecordAtom
 {
        private byte[] _header;
        private static long _type = 4001l;
@@ -59,13 +57,13 @@ public class StyleTextPropAtom extends RecordAtom
 
        private byte[] rawContents; // Holds the contents between write-outs
 
-       /** 
+       /**
         * Only set to true once setParentTextSize(int) is called.
         * Until then, no stylings will have been decoded
         */
        private boolean initialised = false;
 
-       /** 
+       /**
         * The list of all the different paragraph stylings we code for.
         * Each entry is a TextPropCollection, which tells you how many
         *  Characters the paragraph covers, and also contains the TextProps
@@ -78,10 +76,10 @@ public class StyleTextPropAtom extends RecordAtom
         *  paragraph stylings
         */
        public void setParagraphStyles(LinkedList ps) { paragraphStyles = ps; }
-       /** 
+       /**
         * The list of all the different character stylings we code for.
         * Each entry is a TextPropCollection, which tells you how many
-        *  Characters the character styling covers, and also contains the 
+        *  Characters the character styling covers, and also contains the
         *  TextProps that actually define the styling of the characters.
         */
        private LinkedList charStyles;
@@ -91,7 +89,7 @@ public class StyleTextPropAtom extends RecordAtom
         *  character stylings
         */
        public void setCharacterStyles(LinkedList cs) { charStyles = cs; }
-       
+
        /**
         * Returns how many characters the paragraph's
         *  TextPropCollections cover.
@@ -334,7 +332,7 @@ public class StyleTextPropAtom extends RecordAtom
 
                        // Save this properties set
                        charStyles.add(thisCollection);
-                       
+
                        // Handle extra 1 char styles at the end
                        if(pos < rawContents.length && textHandled == size) {
                                chsize++;
@@ -407,7 +405,7 @@ public class StyleTextPropAtom extends RecordAtom
                charStyles.add(tpc);
                return tpc;
        }
-       
+
 /* ************************************************************************ */
 
 
@@ -418,14 +416,14 @@ public class StyleTextPropAtom extends RecordAtom
      */
     public String toString(){
         StringBuffer out = new StringBuffer();
-        
+
            out.append("StyleTextPropAtom:\n");
         if (!initialised) {
                out.append("Uninitialised, dumping Raw Style Data\n");
         } else {
-        
+
                out.append("Paragraph properties\n");
-               
+
                for (Iterator it1 = getParagraphStyles().iterator(); it1.hasNext();) {
                    TextPropCollection pr = (TextPropCollection)it1.next();
                    out.append("  chars covered: " + pr.getCharactersCovered());
@@ -435,9 +433,9 @@ public class StyleTextPropAtom extends RecordAtom
                        out.append("    " + p.getName() + " = " + p.getValue() );
                        out.append(" (0x" + HexDump.toHex(p.getValue()) + ")\n");
                    }
-                   
+
                    out.append("  para bytes that would be written: \n");
-                   
+
                    try {
                                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                                        pr.writeOut(baos);
@@ -447,7 +445,7 @@ public class StyleTextPropAtom extends RecordAtom
                        e.printStackTrace();
                    }
                }
-       
+
                out.append("Character properties\n");
                for (Iterator it1 = getCharacterStyles().iterator(); it1.hasNext();) {
                    TextPropCollection pr = (TextPropCollection)it1.next();
@@ -458,9 +456,9 @@ public class StyleTextPropAtom extends RecordAtom
                        out.append("    " + p.getName() + " = " + p.getValue() );
                        out.append(" (0x" + HexDump.toHex(p.getValue()) + ")\n");
                    }
-                   
+
                    out.append("  char bytes that would be written: \n");
-                   
+
                    try {
                                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                                        pr.writeOut(baos);
@@ -471,7 +469,7 @@ public class StyleTextPropAtom extends RecordAtom
                    }
                }
         }
-               
+
         out.append("  original byte stream \n");
                out.append( HexDump.dump(rawContents, 0, 0) );
 
index 3e6cf2cbfdb36cdfe77590e0794f529ec65e84e3..b793613764238997c563848930b5cede11213a5e 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.hslf.record;
 
@@ -27,14 +25,14 @@ import java.io.OutputStream;
 
 /**
  * A TextBytesAtom (type 4008). Holds text in ascii form (unknown
- *  code page, for now assumed to be the default of 
+ *  code page, for now assumed to be the default of
  *  org.apache.poi.util.StringUtil, which is the Excel default).
  * The trailing return character is always stripped from this
  *
  * @author Nick Burch
  */
 
-public class TextBytesAtom extends RecordAtom
+public final class TextBytesAtom extends RecordAtom
 {
        private byte[] _header;
        private static long _type = 4008l;
@@ -43,12 +41,12 @@ public class TextBytesAtom extends RecordAtom
        private byte[] _text;
 
        /** Grabs the text. Uses the default codepage */
-       public String getText() { 
+       public String getText() {
                return StringUtil.getFromCompressedUnicode(_text,0,_text.length);
        }
 
        /** Updates the text in the Atom. Must be 8 bit ascii */
-       public void setText(byte[] b) { 
+       public void setText(byte[] b) {
                // Set the text
                _text = b;
 
@@ -58,7 +56,7 @@ public class TextBytesAtom extends RecordAtom
 
        /* *************** record code follows ********************** */
 
-       /** 
+       /**
         * For the TextBytes Atom
         */
        protected TextBytesAtom(byte[] source, int start, int len) {
@@ -73,7 +71,7 @@ public class TextBytesAtom extends RecordAtom
                _text = new byte[len-8];
                System.arraycopy(source,start+8,_text,0,len-8);
        }
-       
+
        /**
         * Create an empty TextBytes Atom
         */
@@ -104,7 +102,7 @@ public class TextBytesAtom extends RecordAtom
        }
 
        /**
-        * dump debug info; use getText() to return a string 
+        * dump debug info; use getText() to return a string
         * representation of the atom
         */
        public String toString() {
index 0e751a73ada30e15e17607c01ecc39af8e45f88b..e279af060dedbe4c5c66d7c72af8db2a238cb593 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.hslf.record;
 
@@ -32,7 +30,7 @@ import java.io.OutputStream;
  * @author Nick Burch
  */
 
-public class TextCharsAtom extends RecordAtom
+public final class TextCharsAtom extends RecordAtom
 {
        private byte[] _header;
        private static long _type = 4000l;
@@ -41,7 +39,7 @@ public class TextCharsAtom extends RecordAtom
        private byte[] _text;
 
        /** Grabs the text. */
-       public String getText() { 
+       public String getText() {
                return StringUtil.getFromUnicodeLE(_text);
        }
 
@@ -57,8 +55,8 @@ public class TextCharsAtom extends RecordAtom
 
        /* *************** record code follows ********************** */
 
-       /** 
-        * For the TextChars Atom 
+       /**
+        * For the TextChars Atom
         */
        protected TextCharsAtom(byte[] source, int start, int len) {
                // Sanity Checking
@@ -98,9 +96,9 @@ public class TextCharsAtom extends RecordAtom
                // Write out our text
                out.write(_text);
        }
-       
+
        /**
-        * dump debug info; use getText() to return a string 
+        * dump debug info; use getText() to return a string
         * representation of the atom
         */
        public String toString() {
index 85ea29c42d285d3f15ea6f04264f6df090c1e66b..9931eb93b1b05c508ccba081578fd5cbb6cc15de 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.hslf.record;
 
@@ -31,7 +29,7 @@ import java.io.OutputStream;
  * @author Nick Burch
  */
 
-public class TextHeaderAtom extends RecordAtom implements ParentAwareRecord
+public final class TextHeaderAtom extends RecordAtom implements ParentAwareRecord
 {
        private byte[] _header;
        private static long _type = 3999l;
@@ -51,13 +49,13 @@ public class TextHeaderAtom extends RecordAtom implements ParentAwareRecord
 
        public int getTextType() { return textType; }
        public void setTextType(int type) { textType = type; }
-       
+
        public RecordContainer getParentRecord() { return parentRecord; }
-       public void setParentRecord(RecordContainer record) { this.parentRecord = record; } 
+       public void setParentRecord(RecordContainer record) { this.parentRecord = record; }
 
        /* *************** record code follows ********************** */
 
-       /** 
+       /**
         * For the TextHeader Atom
         */
        protected TextHeaderAtom(byte[] source, int start, int len) {
@@ -76,7 +74,7 @@ public class TextHeaderAtom extends RecordAtom implements ParentAwareRecord
                // Grab the type
                textType = (int)LittleEndian.getInt(source,start+8);
        }
-       
+
        /**
         * Create a new TextHeader Atom, for an unknown type of text
         */
index 0be988d51f5e395c55fe8c684525e7f2e93d05a8..052126e1278644a63015139baef28b5b513cfa88 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import java.io.ByteArrayInputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.OutputStream;\r
-import java.util.zip.InflaterInputStream;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-import org.apache.poi.util.POILogger;\r
-\r
-/**\r
- * Ruler of a text as it differs from the style's ruler settings.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TextRulerAtom extends RecordAtom {\r
-\r
-    /**\r
-     * Record header.\r
-     */\r
-    private byte[] _header;\r
-\r
-    /**\r
-     * Record data.\r
-     */\r
-    private byte[] _data;\r
-\r
-    //ruler internals\r
-    private int defaultTabSize;\r
-    private int numLevels;\r
-    private int[] tabStops;\r
-    private int[] bulletOffsets = new int[5];\r
-    private int[] textOffsets = new int[5];\r
-\r
-    /**\r
-     * Constructs a new empty ruler atom.\r
-     */\r
-    public TextRulerAtom() {\r
-        _header = new byte[8];\r
-        _data = new byte[0];\r
-\r
-        LittleEndian.putShort(_header, 2, (short)getRecordType());\r
-        LittleEndian.putInt(_header, 4, _data.length);\r
-    }\r
-\r
-    /**\r
-     * Constructs the ruler atom record from its\r
-     *  source data.\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start the start offset into the byte array.\r
-     * @param len the length of the slice in the byte array.\r
-     */\r
-    protected TextRulerAtom(byte[] source, int start, int len) {\r
-        // Get the header.\r
-        _header = new byte[8];\r
-        System.arraycopy(source,start,_header,0,8);\r
-\r
-        // Get the record data.\r
-        _data = new byte[len-8];\r
-        System.arraycopy(source,start+8,_data,0,len-8);\r
-\r
-        try {\r
-            read();\r
-        } catch (Exception e){\r
-            logger.log(POILogger.ERROR, "Failed to parse TextRulerAtom: " + e.getMessage()); \r
-            e.printStackTrace();\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Gets the record type.\r
-     *\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() {\r
-        return RecordTypes.TextRulerAtom.typeID;\r
-    }\r
-\r
-    /**\r
-     * Write the contents of the record back, so it can be written\r
-     * to disk.\r
-     *\r
-     * @param out the output stream to write to.\r
-     * @throws java.io.IOException if an error occurs.\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        out.write(_header);\r
-        out.write(_data);\r
-    }\r
-\r
-    /**\r
-     * Read the record bytes and initialize the internal variables\r
-     */\r
-    private void read(){\r
-        int pos = 0;\r
-        short mask = LittleEndian.getShort(_data);  pos += 4;\r
-        short val;\r
-        int[] bits = {1, 0, 2, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12};\r
-        for (int i = 0; i < bits.length; i++) {\r
-            if((mask & 1 << bits[i]) != 0){\r
-                switch (bits[i]){\r
-                    case 0:\r
-                        //defaultTabSize\r
-                        defaultTabSize = LittleEndian.getShort(_data, pos); pos += 2;\r
-                        break;\r
-                    case 1:\r
-                        //numLevels\r
-                        numLevels = LittleEndian.getShort(_data, pos); pos += 2;\r
-                        break;\r
-                    case 2:\r
-                        //tabStops\r
-                        val = LittleEndian.getShort(_data, pos); pos += 2;\r
-                        tabStops = new int[val*2];\r
-                        for (int j = 0; j < tabStops.length; j++) {\r
-                            tabStops[j] = LittleEndian.getUShort(_data, pos); pos += 2;\r
-                        }\r
-                        break;\r
-                    case 3:\r
-                    case 4:\r
-                    case 5:\r
-                    case 6:\r
-                    case 7:\r
-                        //bullet.offset\r
-                        val = LittleEndian.getShort(_data, pos); pos += 2;\r
-                        bulletOffsets[bits[i]-3] = val;\r
-                        break;\r
-                    case 8:\r
-                    case 9:\r
-                    case 10:\r
-                    case 11:\r
-                    case 12:\r
-                        //text.offset\r
-                        val = LittleEndian.getShort(_data, pos); pos += 2;\r
-                        textOffsets[bits[i]-8] = val;\r
-                        break;\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Default distance between tab stops, in master coordinates (576 dpi).\r
-     */\r
-    public int getDefaultTabSize(){\r
-        return defaultTabSize;\r
-    }\r
-\r
-    /**\r
-     * Number of indent levels (maximum 5).\r
-     */\r
-    public int getNumberOfLevels(){\r
-        return numLevels;\r
-    }\r
-\r
-    /**\r
-     * Default distance between tab stops, in master coordinates (576 dpi).\r
-     */\r
-    public int[] getTabStops(){\r
-        return tabStops;\r
-    }\r
-\r
-    /**\r
-     * Paragraph's distance from shape's left margin, in master coordinates (576 dpi).\r
-     */\r
-    public int[] getTextOffsets(){\r
-        return textOffsets;\r
-    }\r
-\r
-    /**\r
-     * First line of paragraph's distance from shape's left margin, in master coordinates (576 dpi).\r
-     */\r
-    public int[] getBulletOffsets(){\r
-        return bulletOffsets;\r
-    }\r
-\r
-    public static TextRulerAtom getParagraphInstance(){\r
-        byte[] data = new byte[] {\r
-            0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00,\r
-            0x10, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01\r
-        };\r
-        TextRulerAtom ruler = new TextRulerAtom(data, 0, data.length);\r
-        return ruler;\r
-    }\r
-\r
-    public void setParagraphIndent(short tetxOffset, short bulletOffset){\r
-        LittleEndian.putShort(_data, 4, tetxOffset);\r
-        LittleEndian.putShort(_data, 6, bulletOffset);\r
-        LittleEndian.putShort(_data, 8, bulletOffset);\r
-    }\r
-}\r
+/* ====================================================================
+   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.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;
+
+/**
+ * Ruler of a text as it differs from the style's ruler settings.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TextRulerAtom extends RecordAtom {
+
+    /**
+     * Record header.
+     */
+    private byte[] _header;
+
+    /**
+     * Record data.
+     */
+    private byte[] _data;
+
+    //ruler internals
+    private int defaultTabSize;
+    private int numLevels;
+    private int[] tabStops;
+    private int[] bulletOffsets = new int[5];
+    private int[] textOffsets = new int[5];
+
+    /**
+     * Constructs a new empty ruler atom.
+     */
+    public TextRulerAtom() {
+        _header = new byte[8];
+        _data = new byte[0];
+
+        LittleEndian.putShort(_header, 2, (short)getRecordType());
+        LittleEndian.putInt(_header, 4, _data.length);
+    }
+
+    /**
+     * Constructs the ruler atom record from its
+     *  source data.
+     *
+     * @param source the source data as a byte array.
+     * @param start the start offset into the byte array.
+     * @param len the length of the slice in the byte array.
+     */
+    protected TextRulerAtom(byte[] source, int start, int len) {
+        // 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);
+
+        try {
+            read();
+        } catch (Exception e){
+            logger.log(POILogger.ERROR, "Failed to parse TextRulerAtom: " + e.getMessage());
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Gets the record type.
+     *
+     * @return the record type.
+     */
+    public long getRecordType() {
+        return RecordTypes.TextRulerAtom.typeID;
+    }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     * to disk.
+     *
+     * @param out the output stream to write to.
+     * @throws java.io.IOException if an error occurs.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        out.write(_header);
+        out.write(_data);
+    }
+
+    /**
+     * Read the record bytes and initialize the internal variables
+     */
+    private void read(){
+        int pos = 0;
+        short mask = LittleEndian.getShort(_data);  pos += 4;
+        short val;
+        int[] bits = {1, 0, 2, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12};
+        for (int i = 0; i < bits.length; i++) {
+            if((mask & 1 << bits[i]) != 0){
+                switch (bits[i]){
+                    case 0:
+                        //defaultTabSize
+                        defaultTabSize = LittleEndian.getShort(_data, pos); pos += 2;
+                        break;
+                    case 1:
+                        //numLevels
+                        numLevels = LittleEndian.getShort(_data, pos); pos += 2;
+                        break;
+                    case 2:
+                        //tabStops
+                        val = LittleEndian.getShort(_data, pos); pos += 2;
+                        tabStops = new int[val*2];
+                        for (int j = 0; j < tabStops.length; j++) {
+                            tabStops[j] = LittleEndian.getUShort(_data, pos); pos += 2;
+                        }
+                        break;
+                    case 3:
+                    case 4:
+                    case 5:
+                    case 6:
+                    case 7:
+                        //bullet.offset
+                        val = LittleEndian.getShort(_data, pos); pos += 2;
+                        bulletOffsets[bits[i]-3] = val;
+                        break;
+                    case 8:
+                    case 9:
+                    case 10:
+                    case 11:
+                    case 12:
+                        //text.offset
+                        val = LittleEndian.getShort(_data, pos); pos += 2;
+                        textOffsets[bits[i]-8] = val;
+                        break;
+                }
+            }
+        }
+    }
+
+    /**
+     * Default distance between tab stops, in master coordinates (576 dpi).
+     */
+    public int getDefaultTabSize(){
+        return defaultTabSize;
+    }
+
+    /**
+     * Number of indent levels (maximum 5).
+     */
+    public int getNumberOfLevels(){
+        return numLevels;
+    }
+
+    /**
+     * Default distance between tab stops, in master coordinates (576 dpi).
+     */
+    public int[] getTabStops(){
+        return tabStops;
+    }
+
+    /**
+     * Paragraph's distance from shape's left margin, in master coordinates (576 dpi).
+     */
+    public int[] getTextOffsets(){
+        return textOffsets;
+    }
+
+    /**
+     * First line of paragraph's distance from shape's left margin, in master coordinates (576 dpi).
+     */
+    public int[] getBulletOffsets(){
+        return bulletOffsets;
+    }
+
+    public static TextRulerAtom getParagraphInstance(){
+        byte[] data = new byte[] {
+            0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00,
+            0x10, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01
+        };
+        TextRulerAtom ruler = new TextRulerAtom(data, 0, data.length);
+        return ruler;
+    }
+
+    public void setParagraphIndent(short tetxOffset, short bulletOffset){
+        LittleEndian.putShort(_data, 4, tetxOffset);
+        LittleEndian.putShort(_data, 6, bulletOffset);
+        LittleEndian.putShort(_data, 8, bulletOffset);
+    }
+}
index 85cdd1e156ae7ad8e1cfc4fc704d0c93f41e014e..f0e79761aaa0e7a3637ee9b304c6b42cabd54581 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.record;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-\r
-import java.io.OutputStream;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-\r
-/**\r
- * The special info runs contained in this text.\r
- * Special info runs consist of character properties which don?t follow styles.\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class TextSpecInfoAtom extends RecordAtom {\r
-    /**\r
-     * Record header.\r
-     */\r
-    private byte[] _header;\r
-\r
-    /**\r
-     * Record data.\r
-     */\r
-    private byte[] _data;\r
-\r
-    /**\r
-     * Constructs the link related atom record from its\r
-     *  source data.\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start the start offset into the byte array.\r
-     * @param len the length of the slice in the byte array.\r
-     */\r
-    protected TextSpecInfoAtom(byte[] source, int start, int len) {\r
-        // Get the header.\r
-        _header = new byte[8];\r
-        System.arraycopy(source,start,_header,0,8);\r
-\r
-        // Get the record data.\r
-        _data = new byte[len-8];\r
-        System.arraycopy(source,start+8,_data,0,len-8);\r
-\r
-    }\r
-    /**\r
-     * Gets the record type.\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() { return RecordTypes.TextSpecInfoAtom.typeID; }\r
-\r
-    /**\r
-     * Write the contents of the record back, so it can be written\r
-     * to disk\r
-     *\r
-     * @param out the output stream to write to.\r
-     * @throws java.io.IOException if an error occurs.\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        out.write(_header);\r
-        out.write(_data);\r
-    }\r
-\r
-    /**\r
-     * Update the text length\r
-     *\r
-     * @param size the text length\r
-     */\r
-    public void setTextSize(int size){\r
-        LittleEndian.putInt(_data, 0, size);\r
-    }\r
-\r
-    /**\r
-     * Reset the content to one info run with the default values\r
-     * @param size  the site of parent text\r
-     */\r
-    public void reset(int size){\r
-        _data = new byte[10];\r
-        // 01 00 00 00\r
-        LittleEndian.putInt(_data, 0, size);\r
-        // 01 00 00 00\r
-        LittleEndian.putInt(_data, 4, 1); //mask\r
-        // 00 00\r
-        LittleEndian.putShort(_data, 8, (short)0); //langId\r
-\r
-        // Update the size (header bytes 5-8)\r
-        LittleEndian.putInt(_header, 4, _data.length);\r
-    }\r
-\r
-    /**\r
-     * Get the number of characters covered by this records\r
-     *\r
-     * @return the number of characters covered by this records\r
-     */\r
-    public int getCharactersCovered(){\r
-        int covered = 0;\r
-        TextSpecInfoRun[] runs = getTextSpecInfoRuns();\r
-        for (int i = 0; i < runs.length; i++) covered += runs[i].len;\r
-        return covered;\r
-    }\r
-\r
-    public TextSpecInfoRun[] getTextSpecInfoRuns(){\r
-        ArrayList lst = new ArrayList();\r
-        int pos = 0;\r
-        int[] bits = {1, 0, 2};\r
-        while(pos < _data.length) {\r
-            TextSpecInfoRun run = new TextSpecInfoRun();\r
-            run.len = LittleEndian.getInt(_data, pos); pos += 4;\r
-            run.mask = LittleEndian.getInt(_data, pos); pos += 4;\r
-            for (int i = 0; i < bits.length; i++) {\r
-                if((run.mask & 1 << bits[i]) != 0){\r
-                    switch (bits[i]){\r
-                        case 0:\r
-                            run.spellInfo = LittleEndian.getShort(_data, pos); pos += 2;\r
-                            break;\r
-                        case 1:\r
-                            run.langId = LittleEndian.getShort(_data, pos); pos += 2;\r
-                            break;\r
-                        case 2:\r
-                            run.altLangId = LittleEndian.getShort(_data, pos); pos += 2;\r
-                            break;\r
-                    }\r
-                }\r
-            }\r
-            lst.add(run);\r
-        }\r
-        return (TextSpecInfoRun[])lst.toArray(new TextSpecInfoRun[lst.size()]);\r
-\r
-    }\r
-\r
-    public static class TextSpecInfoRun {\r
-        //Length of special info run.\r
-        protected int len;\r
-\r
-        //Special info mask of this run;\r
-        protected int mask;\r
-\r
-        // info fields as indicated by the mask.\r
-        // -1 means the bit is not set\r
-        protected short spellInfo = -1;\r
-        protected short langId = -1;\r
-        protected short altLangId = -1;\r
-\r
-        /**\r
-         * Spelling status of this text. See Spell Info table below.\r
-         *\r
-         * <p>Spell Info Types:</p>\r
-         * <li>0    Unchecked\r
-         * <li>1    Previously incorrect, needs rechecking\r
-         * <li>2    Correct\r
-         * <li>3    Incorrect\r
-         *\r
-         * @return Spelling status of this text\r
-         */\r
-        public short getSpellInfo(){\r
-            return spellInfo;\r
-        }\r
-\r
-        /**\r
-         * Windows LANGID for this text.\r
-         *\r
-         * @return Windows LANGID for this text.\r
-         */\r
-        public short getLangId(){\r
-            return spellInfo;\r
-        }\r
-\r
-        /**\r
-         * Alternate Windows LANGID of this text;\r
-         * must be a valid non-East Asian LANGID if the text has an East Asian language,\r
-         * otherwise may be an East Asian LANGID or language neutral (zero).\r
-         *\r
-         * @return  Alternate Windows LANGID of this text\r
-         */\r
-        public short getAltLangId(){\r
-            return altLangId;\r
-        }\r
-\r
-        /**\r
-         * @return Length of special info run.\r
-         */\r
-        public int length(){\r
-            return len;\r
-        }\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.record;
+
+import org.apache.poi.util.LittleEndian;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+
+/**
+ * The special info runs contained in this text.
+ * Special info runs consist of character properties which don?t follow styles.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TextSpecInfoAtom extends RecordAtom {
+    /**
+     * Record header.
+     */
+    private byte[] _header;
+
+    /**
+     * Record data.
+     */
+    private byte[] _data;
+
+    /**
+     * Constructs the link related atom record from its
+     *  source data.
+     *
+     * @param source the source data as a byte array.
+     * @param start the start offset into the byte array.
+     * @param len the length of the slice in the byte array.
+     */
+    protected TextSpecInfoAtom(byte[] source, int start, int len) {
+        // 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);
+
+    }
+    /**
+     * Gets the record type.
+     * @return the record type.
+     */
+    public long getRecordType() { return RecordTypes.TextSpecInfoAtom.typeID; }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     * to disk
+     *
+     * @param out the output stream to write to.
+     * @throws java.io.IOException if an error occurs.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        out.write(_header);
+        out.write(_data);
+    }
+
+    /**
+     * Update the text length
+     *
+     * @param size the text length
+     */
+    public void setTextSize(int size){
+        LittleEndian.putInt(_data, 0, size);
+    }
+
+    /**
+     * Reset the content to one info run with the default values
+     * @param size  the site of parent text
+     */
+    public void reset(int size){
+        _data = new byte[10];
+        // 01 00 00 00
+        LittleEndian.putInt(_data, 0, size);
+        // 01 00 00 00
+        LittleEndian.putInt(_data, 4, 1); //mask
+        // 00 00
+        LittleEndian.putShort(_data, 8, (short)0); //langId
+
+        // Update the size (header bytes 5-8)
+        LittleEndian.putInt(_header, 4, _data.length);
+    }
+
+    /**
+     * Get the number of characters covered by this records
+     *
+     * @return the number of characters covered by this records
+     */
+    public int getCharactersCovered(){
+        int covered = 0;
+        TextSpecInfoRun[] runs = getTextSpecInfoRuns();
+        for (int i = 0; i < runs.length; i++) covered += runs[i].len;
+        return covered;
+    }
+
+    public TextSpecInfoRun[] getTextSpecInfoRuns(){
+        ArrayList lst = new ArrayList();
+        int pos = 0;
+        int[] bits = {1, 0, 2};
+        while(pos < _data.length) {
+            TextSpecInfoRun run = new TextSpecInfoRun();
+            run.len = LittleEndian.getInt(_data, pos); pos += 4;
+            run.mask = LittleEndian.getInt(_data, pos); pos += 4;
+            for (int i = 0; i < bits.length; i++) {
+                if((run.mask & 1 << bits[i]) != 0){
+                    switch (bits[i]){
+                        case 0:
+                            run.spellInfo = LittleEndian.getShort(_data, pos); pos += 2;
+                            break;
+                        case 1:
+                            run.langId = LittleEndian.getShort(_data, pos); pos += 2;
+                            break;
+                        case 2:
+                            run.altLangId = LittleEndian.getShort(_data, pos); pos += 2;
+                            break;
+                    }
+                }
+            }
+            lst.add(run);
+        }
+        return (TextSpecInfoRun[])lst.toArray(new TextSpecInfoRun[lst.size()]);
+
+    }
+
+    public static class TextSpecInfoRun {
+        //Length of special info run.
+        protected int len;
+
+        //Special info mask of this run;
+        protected int mask;
+
+        // info fields as indicated by the mask.
+        // -1 means the bit is not set
+        protected short spellInfo = -1;
+        protected short langId = -1;
+        protected short altLangId = -1;
+
+        /**
+         * Spelling status of this text. See Spell Info table below.
+         *
+         * <p>Spell Info Types:</p>
+         * <li>0    Unchecked
+         * <li>1    Previously incorrect, needs rechecking
+         * <li>2    Correct
+         * <li>3    Incorrect
+         *
+         * @return Spelling status of this text
+         */
+        public short getSpellInfo(){
+            return spellInfo;
+        }
+
+        /**
+         * Windows LANGID for this text.
+         *
+         * @return Windows LANGID for this text.
+         */
+        public short getLangId(){
+            return spellInfo;
+        }
+
+        /**
+         * Alternate Windows LANGID of this text;
+         * must be a valid non-East Asian LANGID if the text has an East Asian language,
+         * otherwise may be an East Asian LANGID or language neutral (zero).
+         *
+         * @return  Alternate Windows LANGID of this text
+         */
+        public short getAltLangId(){
+            return altLangId;
+        }
+
+        /**
+         * @return Length of special info run.
+         */
+        public int length(){
+            return len;
+        }
+    }
+}
index e6a827977343284bcae5f00a9240f73412146f86..eb9dd8e0cac11ccc6a2172dbe7899a63d2d4ba84 100644 (file)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.record;\r
-\r
-import org.apache.poi.util.LittleEndian;\r
-\r
-import java.io.OutputStream;\r
-import java.io.IOException;\r
-\r
-/**\r
- * Tne atom that holds starting and ending character positions of a hyperlink\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TxInteractiveInfoAtom extends RecordAtom {\r
-    /**\r
-     * Record header.\r
-     */\r
-    private byte[] _header;\r
-\r
-    /**\r
-     * Record data.\r
-     */\r
-    private byte[] _data;\r
-\r
-    /**\r
-     * Constructs a brand new link related atom record.\r
-     */\r
-    public TxInteractiveInfoAtom() {\r
-        _header = new byte[8];\r
-        _data = new byte[8];\r
-\r
-        LittleEndian.putShort(_header, 2, (short)getRecordType());\r
-        LittleEndian.putInt(_header, 4, _data.length);\r
-    }\r
-\r
-    /**\r
-     * Constructs the link related atom record from its\r
-     *  source data.\r
-     *\r
-     * @param source the source data as a byte array.\r
-     * @param start the start offset into the byte array.\r
-     * @param len the length of the slice in the byte array.\r
-     */\r
-    protected TxInteractiveInfoAtom(byte[] source, int start, int len) {\r
-        // Get the header.\r
-        _header = new byte[8];\r
-        System.arraycopy(source,start,_header,0,8);\r
-\r
-        // Get the record data.\r
-        _data = new byte[len-8];\r
-        System.arraycopy(source,start+8,_data,0,len-8);\r
-\r
-    }\r
-\r
-    /**\r
-     * Gets the beginning character position\r
-     *\r
-     * @return the beginning character position\r
-     */\r
-    public int getStartIndex() {\r
-        return LittleEndian.getInt(_data, 0);\r
-    }\r
-\r
-    /**\r
-     * Sets the beginning character position\r
-     * @param idx the beginning character position\r
-     */\r
-    public void setStartIndex(int idx) {\r
-        LittleEndian.putInt(_data, 0, idx);\r
-    }\r
-\r
-    /**\r
-     * Gets the ending character position\r
-     *\r
-     * @return the ending character position\r
-     */\r
-    public int getEndIndex() {\r
-        return LittleEndian.getInt(_data, 4);\r
-    }\r
-\r
-    /**\r
-     * Sets the ending character position\r
-     *\r
-     * @param idx the ending character position\r
-     */\r
-    public void setEndIndex(int idx) {\r
-        LittleEndian.putInt(_data, 4, idx);\r
-    }\r
-\r
-    /**\r
-     * Gets the record type.\r
-     * @return the record type.\r
-     */\r
-    public long getRecordType() { return RecordTypes.TxInteractiveInfoAtom.typeID; }\r
-\r
-    /**\r
-     * Write the contents of the record back, so it can be written\r
-     * to disk\r
-     *\r
-     * @param out the output stream to write to.\r
-     * @throws java.io.IOException if an error occurs.\r
-     */\r
-    public void writeOut(OutputStream out) throws IOException {\r
-        out.write(_header);\r
-        out.write(_data);\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.record;
+
+import org.apache.poi.util.LittleEndian;
+
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * Tne atom that holds starting and ending character positions of a hyperlink
+ *
+ * @author Yegor Kozlov
+ */
+public final class TxInteractiveInfoAtom extends RecordAtom {
+    /**
+     * Record header.
+     */
+    private byte[] _header;
+
+    /**
+     * Record data.
+     */
+    private byte[] _data;
+
+    /**
+     * Constructs a brand new link related atom record.
+     */
+    public TxInteractiveInfoAtom() {
+        _header = new byte[8];
+        _data = new byte[8];
+
+        LittleEndian.putShort(_header, 2, (short)getRecordType());
+        LittleEndian.putInt(_header, 4, _data.length);
+    }
+
+    /**
+     * Constructs the link related atom record from its
+     *  source data.
+     *
+     * @param source the source data as a byte array.
+     * @param start the start offset into the byte array.
+     * @param len the length of the slice in the byte array.
+     */
+    protected TxInteractiveInfoAtom(byte[] source, int start, int len) {
+        // 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);
+
+    }
+
+    /**
+     * Gets the beginning character position
+     *
+     * @return the beginning character position
+     */
+    public int getStartIndex() {
+        return LittleEndian.getInt(_data, 0);
+    }
+
+    /**
+     * Sets the beginning character position
+     * @param idx the beginning character position
+     */
+    public void setStartIndex(int idx) {
+        LittleEndian.putInt(_data, 0, idx);
+    }
+
+    /**
+     * Gets the ending character position
+     *
+     * @return the ending character position
+     */
+    public int getEndIndex() {
+        return LittleEndian.getInt(_data, 4);
+    }
+
+    /**
+     * Sets the ending character position
+     *
+     * @param idx the ending character position
+     */
+    public void setEndIndex(int idx) {
+        LittleEndian.putInt(_data, 4, idx);
+    }
+
+    /**
+     * Gets the record type.
+     * @return the record type.
+     */
+    public long getRecordType() { return RecordTypes.TxInteractiveInfoAtom.typeID; }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     * to disk
+     *
+     * @param out the output stream to write to.
+     * @throws java.io.IOException if an error occurs.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        out.write(_header);
+        out.write(_data);
+    }
+}
index 05bf42c7b8b0172deae2c0a29569821cf71d889a..b262530c0dde9c47fd60747bbbbc0a8752f8d85c 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
@@ -41,7 +40,7 @@ import org.apache.poi.hslf.model.textproperties.*;
  *
  *  @author Yegor Kozlov
  */
-public class TxMasterStyleAtom extends RecordAtom {
+public final class TxMasterStyleAtom extends RecordAtom {
 
     /**
      * Maximum number of indentatio levels allowed in PowerPoint documents
@@ -116,7 +115,7 @@ public class TxMasterStyleAtom extends RecordAtom {
      * Must be a constant defined in <code>TextHeaderAtom</code>
      *
      * @return type of the text
-     * @see TextHeaderAtom 
+     * @see TextHeaderAtom
      */
     public int getTextType(){
         //The atom instance value is the text type
index 5b8726a51e778fe271a0380c1133db047182b36c..6df2aa9198c3bfe21bb9473c7b224b5c87d2a889 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.hslf.record;
 
@@ -31,12 +29,12 @@ import java.io.OutputStream;
  * @author Nick Burch
  */
 
-public class UnknownRecordPlaceholder extends RecordAtom
+public final class UnknownRecordPlaceholder extends RecordAtom
 {
        private byte[] _contents;
        private long _type;
 
-       /** 
+       /**
         * Create a new holder for a record we don't grok
         */
        protected UnknownRecordPlaceholder(byte[] source, int start, int len) {
index 60a647516bab66674d9e038583c0dac153ab0968..97765c408b1e6bd2c24c600ac9bc879c2a4b0abf 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.hslf.record;
 
@@ -35,7 +33,7 @@ import java.util.Hashtable;
  * @author Nick Burch
  */
 
-public class UserEditAtom extends PositionDependentRecordAtom
+public final class UserEditAtom extends PositionDependentRecordAtom
 {
        public static final int LAST_VIEW_NONE = 0;
        public static final int LAST_VIEW_SLIDE_VIEW = 1;
@@ -72,7 +70,7 @@ public class UserEditAtom extends PositionDependentRecordAtom
 
        /* *************** record code follows ********************** */
 
-       /** 
+       /**
         * For the UserEdit Atom
         */
        protected UserEditAtom(byte[] source, int start, int len) {
@@ -90,12 +88,12 @@ public class UserEditAtom extends PositionDependentRecordAtom
                pptVersion = (int)LittleEndian.getInt(source,start+4+8);
 
                // Get the offset to the previous incremental save's UserEditAtom
-               // This will be the byte offset on disk where the previous one 
+               // This will be the byte offset on disk where the previous one
                //  starts, or 0 if this is the first one
                lastUserEditAtomOffset = (int)LittleEndian.getInt(source,start+8+8);
 
                // Get the offset to the persist pointers
-               // This will be the byte offset on disk where the preceding 
+               // This will be the byte offset on disk where the preceding
                //  PersistPtrFullBlock or PersistPtrIncrementalBlock starts
                persistPointersOffset = (int)LittleEndian.getInt(source,start+12+8);
 
@@ -105,7 +103,7 @@ public class UserEditAtom extends PositionDependentRecordAtom
 
                // Maximum number of persist objects written
                maxPersistWritten = (int)LittleEndian.getInt(source,start+20+8);
-               
+
                // Last view type
                lastViewType = (short)LittleEndian.getShort(source,start+24+8);
 
index d21d098c3e54312896f7cca88c1546b883884bdd..635e0ea265b6017daefd99e9aa4e6d1432d0369f 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.usermodel;
 
 import org.apache.poi.util.LittleEndian;
@@ -234,7 +235,7 @@ public abstract class PictureData {
      * Register ImagePainter for the specified image type
      *
      * @param type  image type, must be one of the static constants defined in the <code>Picture<code> class.
-     * @param painter   
+     * @param painter
      */
     public static void setImagePainter(int type, ImagePainter painter){
         painters[type] = painter;
index a4238b473806b1c4dc6ca6f6d9f33664c6073f22..da8093ecf47eaf9db0ed86864af837280453295b 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.usermodel;
 
@@ -38,22 +35,22 @@ import org.apache.poi.util.POILogFactory;
 
 /**
  * Represents a run of text, all with the same style
- * 
+ *
  */
-public class RichTextRun {
+public final class RichTextRun {
     protected POILogger logger = POILogFactory.getLogger(this.getClass());
 
        /** The TextRun we belong to */
        private TextRun parentRun;
        /** The SlideShow we belong to */
        private SlideShow slideShow;
-       
+
        /** Where in the parent TextRun we start from */
        private int startPos;
-       
+
        /** How long a string (in the parent TextRun) we represent */
        private int length;
-       
+
     private String _fontname;
     /**
         * Our paragraph and character style.
@@ -84,7 +81,7 @@ public class RichTextRun {
         * @param pShared The paragraph styles are shared with other runs
         * @param cShared The character styles are shared with other runs
         */
-       public RichTextRun(TextRun parent, int startAt, int len, 
+       public RichTextRun(TextRun parent, int startAt, int len,
        TextPropCollection pStyle,  TextPropCollection cStyle,
        boolean pShared, boolean cShared) {
                parentRun = parent;
@@ -97,8 +94,8 @@ public class RichTextRun {
        }
 
        /**
-        * Supply (normally default) textprops, and if they're shared, 
-        *  when a run gets them 
+        * Supply (normally default) textprops, and if they're shared,
+        *  when a run gets them
         */
        public void supplyTextProps(TextPropCollection pStyle,  TextPropCollection cStyle, boolean pShared, boolean cShared) {
                if(paragraphStyle != null || characterStyle != null) {
@@ -119,7 +116,7 @@ public class RichTextRun {
             _fontname = null;
         }
        }
-       
+
        /**
         * Get the length of the text
         */
@@ -157,7 +154,7 @@ public class RichTextRun {
        public String getRawText() {
                return parentRun.getRawText().substring(startPos, startPos+length);
        }
-       
+
        /**
         * Change the text
         */
@@ -165,7 +162,7 @@ public class RichTextRun {
         String s = parentRun.normalize(text);
         setRawText(s);
        }
-       
+
     /**
      * Change the text
      */
@@ -181,10 +178,10 @@ public class RichTextRun {
        public void updateStartPosition(int startAt) {
                startPos = startAt;
        }
-       
-       
+
+
        // --------------- Internal helpers on rich text properties -------
-       
+
        /**
         * Fetch the value of the given flag in the CharFlagsTextProp.
         * Returns false if the CharFlagsTextProp isn't present, since the
@@ -227,7 +224,7 @@ public class RichTextRun {
 
        /**
         * Set the value of the given flag in the CharFlagsTextProp, adding
-        *  it if required. 
+        *  it if required.
         */
        private void setCharFlagsTextPropVal(int index, boolean value) {
         if(getFlag(true, index) != value) setFlag(true, index, value);
@@ -268,11 +265,11 @@ public class RichTextRun {
                }
                return tp;
        }
-       
+
        /**
-        * Fetch the value of the given Character related TextProp. 
-        * Returns -1 if that TextProp isn't present. 
-        * If the TextProp isn't present, the value from the appropriate 
+        * Fetch the value of the given Character related TextProp.
+        * Returns -1 if that TextProp isn't present.
+        * If the TextProp isn't present, the value from the appropriate
         *  Master Sheet will apply.
         */
        private int getCharTextPropVal(String propName) {
@@ -315,7 +312,7 @@ public class RichTextRun {
 
                return prop == null ? -1 : prop.getValue();
        }
-       
+
        /**
         * Sets the value of the given Character TextProp, add if required
         * @param propName The name of the Character TextProp
@@ -327,7 +324,7 @@ public class RichTextRun {
                        parentRun.ensureStyleAtomPresent();
                        // paragraphStyle will now be defined
                }
-               
+
                TextProp tp = fetchOrAddTextProp(paragraphStyle, propName);
                tp.setValue(val);
        }
@@ -342,12 +339,12 @@ public class RichTextRun {
                        parentRun.ensureStyleAtomPresent();
                        // characterStyle will now be defined
                }
-               
+
                TextProp tp = fetchOrAddTextProp(characterStyle, propName);
                tp.setValue(val);
        }
-       
-       
+
+
        // --------------- Friendly getters / setters on rich text properties -------
 
     /**
@@ -363,7 +360,7 @@ public class RichTextRun {
        public void setBold(boolean bold) {
                setCharFlagsTextPropVal(CharFlagsTextProp.BOLD_IDX, bold);
        }
-       
+
     /**
      * Is the text italic?
      */
@@ -377,7 +374,7 @@ public class RichTextRun {
        public void setItalic(boolean italic) {
                setCharFlagsTextPropVal(CharFlagsTextProp.ITALIC_IDX, italic);
        }
-       
+
     /**
      * Is the text underlined?
      */
@@ -509,7 +506,7 @@ public class RichTextRun {
             return slideShow.getFontCollection().getFontWithId(fontIdx);
         }
        }
-       
+
        /**
         * @return font color as RGB value
         * @see java.awt.Color
@@ -529,13 +526,13 @@ public class RichTextRun {
        /**
         * Sets color of the text, as a int bgr.
         * (PowerPoint stores as BlueGreenRed, not the more
-        *  usual RedGreenBlue) 
+        *  usual RedGreenBlue)
         * @see java.awt.Color
         */
        public void setFontColor(int bgr) {
                setCharTextPropVal("font.color", bgr);
        }
-       
+
     /**
      * Sets color of the text, as a java.awt.Color
      */
@@ -772,15 +769,15 @@ public class RichTextRun {
         return val == -1 ? 0 : val;
     }
        // --------------- Internal HSLF methods, not intended for end-user use! -------
-       
+
        /**
         * Internal Use Only - get the underlying paragraph style collection.
-        * For normal use, use the friendly setters and getters 
+        * For normal use, use the friendly setters and getters
         */
        public TextPropCollection _getRawParagraphStyle() { return paragraphStyle; }
        /**
         * Internal Use Only - get the underlying character style collection.
-        * For normal use, use the friendly setters and getters 
+        * For normal use, use the friendly setters and getters
         */
        public TextPropCollection _getRawCharacterStyle() { return characterStyle; }
        /**
index e5fbf12412d4b38c375b1cb6a29c62244418fcd6..15650d0ad759b554ca4460e5e6b95699455c7721 100644 (file)
@@ -49,7 +49,7 @@ import org.apache.poi.util.POILogger;
  *  - 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
  */
@@ -80,15 +80,15 @@ public final class SlideShow {
   // For logging
     private POILogger logger = POILogFactory.getLogger(this.getClass());
 
-  
+
   /* ===============================================================
    *                       Setup Code
    * ===============================================================
    */
-  
+
 
   /**
-   * Constructs a Powerpoint document from the underlying 
+   * Constructs a Powerpoint document from the underlying
    * HSLFSlideShow object. Finds the model stuff from this
    *
    * @param hslfSlideShow the HSLFSlideShow to base on
@@ -97,7 +97,7 @@ public final class SlideShow {
        // Get useful things from our base slideshow
     _hslfSlideShow = hslfSlideShow;
        _records = _hslfSlideShow.getRecords();
-       
+
        // Handle Parent-aware Reocrds
        for(int i=0; i<_records.length; i++) {
                handleParentAwareRecords(_records[i]);
@@ -105,11 +105,11 @@ public final class SlideShow {
 
        // 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.
    */
@@ -133,7 +133,7 @@ public final class SlideShow {
          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];
@@ -164,14 +164,14 @@ public final class SlideShow {
                if(_records[i] instanceof PersistPtrHolder) {
                        PersistPtrHolder pph = (PersistPtrHolder)_records[i];
 
-                       // If we've already seen any of the "slide" IDs for this 
+                       // 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
@@ -186,7 +186,7 @@ public final class SlideShow {
        // 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();
@@ -214,24 +214,24 @@ public final class SlideShow {
 
                                if(thatRecordAt.equals(recordAt)) {
                                        // Bingo. Now, where do we store it?
-                                       Integer storeAtI = 
+                                       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 pdrc =
                                                        (PositionDependentRecordContainer)_records[i];
                                                pdrc.setSheetId(thisID.intValue());
                                        }
-                                       
+
                                        // 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
@@ -247,7 +247,7 @@ public final class SlideShow {
                }
        }
   }
-  
+
        /**
         * For a given SlideAtomsSet, return the core record, based on the refID from the
         *  SlidePersistAtom
@@ -257,7 +257,7 @@ public final class SlideShow {
                int refID = spa.getRefID();
                return getCoreRecordForRefID(refID);
        }
-  
+
        /**
         * For a given refID (the internal, 0 based numbering scheme), return the
         *  core record
@@ -302,7 +302,7 @@ public final class SlideShow {
        // 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 
+       //  SlideAtom/NotesAtom to match them with the StyleAtomSet
 
        SlideListWithText masterSLWT = _documentRecord.getMasterSlideListWithText();
        SlideListWithText slidesSLWT = _documentRecord.getSlideSlideListWithText();
@@ -354,7 +354,7 @@ public final class SlideShow {
        Hashtable slideIdToNotes = new Hashtable();
        if(notesSLWT == null) {
                // None
-               notesRecords = new org.apache.poi.hslf.record.Notes[0]; 
+               notesRecords = new org.apache.poi.hslf.record.Notes[0];
        } else {
                // Match up the records and the SlideAtomSets
                notesSets = notesSLWT.getSlideAtomsSets();
@@ -380,13 +380,13 @@ public final class SlideShow {
                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]; 
+               slidesRecords = new org.apache.poi.hslf.record.Slide[0];
        } else {
                // Match up the records and the SlideAtomSets
                slidesSets = slidesSLWT.getSlideAtomsSets();
@@ -394,7 +394,7 @@ public final class SlideShow {
                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;
@@ -403,7 +403,7 @@ public final class SlideShow {
                        }
                }
        }
-       
+
        // Finally, generate model objects for everything
        // Notes first
        _notes = new Notes[notesRecords.length];
@@ -449,7 +449,7 @@ public final class SlideShow {
     *                       Accessor Code
     * ===============================================================
     */
-   
+
 
        /**
         * Returns an array of the most recent version of all the interesting
@@ -506,10 +506,10 @@ public final class SlideShow {
                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)
         */
        public void setPageSize(Dimension pgsize){
@@ -517,7 +517,7 @@ public final class SlideShow {
                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
         */
@@ -527,13 +527,13 @@ public final class SlideShow {
         */
        public Document getDocumentRecord() { return _documentRecord; }
 
-       
+
        /* ===============================================================
         *                       Re-ordering Code
         * ===============================================================
         */
-          
-       
+
+
        /**
         * Re-orders a slide, to a new position.
         * @param oldSlideNumber The old slide number (1 based)
@@ -612,7 +612,7 @@ public final class SlideShow {
         *                       Addition Code
         * ===============================================================
         */
-          
+
 
        /**
         * Create a blank <code>Slide</code>.
index ad7922ef6172fa489602c8f2516026299d46fad7..cc084fa0290a57bbb4e4fdf560daeb104fd0ee6a 100755 (executable)
@@ -1,93 +1,94 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.usermodel;\r
-\r
-import org.apache.poi.hslf.record.*;\r
-\r
-import java.util.ArrayList;\r
-\r
-/**\r
- * A class that represents sound data embedded in a slide show.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class SoundData {\r
-    /**\r
-     * The record that contains the object data.\r
-     */\r
-    private Sound _container;\r
-\r
-    /**\r
-     * Creates the object data wrapping the record that contains the sound data.\r
-     *\r
-     * @param container the record that contains the sound data.\r
-     */\r
-    public SoundData(Sound container) {\r
-        this._container = container;\r
-    }\r
-\r
-    /**\r
-     * Name of the sound (e.g. "crash")\r
-     *\r
-     * @return name of the sound\r
-     */\r
-    public String getSoundName(){\r
-        return _container.getSoundName();\r
-    }\r
-\r
-    /**\r
-     * Type of the sound (e.g. ".wav")\r
-     *\r
-     * @return type of the sound\r
-     */\r
-    public String getSoundType(){\r
-        return _container.getSoundType();\r
-    }\r
-\r
-    /**\r
-     * Gets an input stream which returns the binary of the sound data.\r
-     *\r
-     * @return the input stream which will contain the binary of the sound data.\r
-     */\r
-    public byte[] getData() {\r
-        return _container.getSoundData();\r
-    }\r
-\r
-    /**\r
-     * Find all sound records in the supplied Document records\r
-     *\r
-     * @param document the document to find in\r
-     * @return the array with the sound data\r
-     */\r
-    public static SoundData[] find(Document document){\r
-        ArrayList lst = new ArrayList();\r
-        Record[] ch = document.getChildRecords();\r
-        for (int i = 0; i < ch.length; i++) {\r
-            if(ch[i].getRecordType() == RecordTypes.SoundCollection.typeID){\r
-                RecordContainer col = (RecordContainer)ch[i];\r
-                Record[] sr = col.getChildRecords();\r
-                for (int j = 0; j < sr.length; j++) {\r
-                    if(sr[j] instanceof Sound){\r
-                        lst.add(new SoundData((Sound)sr[j]));\r
-                    }\r
-                }\r
-            }\r
-\r
-        }\r
-        return (SoundData[])lst.toArray(new SoundData[lst.size()]);\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.usermodel;
+
+import org.apache.poi.hslf.record.*;
+
+import java.util.ArrayList;
+
+/**
+ * A class that represents sound data embedded in a slide show.
+ *
+ * @author Yegor Kozlov
+ */
+public final class SoundData {
+    /**
+     * The record that contains the object data.
+     */
+    private Sound _container;
+
+    /**
+     * Creates the object data wrapping the record that contains the sound data.
+     *
+     * @param container the record that contains the sound data.
+     */
+    public SoundData(Sound container) {
+        this._container = container;
+    }
+
+    /**
+     * Name of the sound (e.g. "crash")
+     *
+     * @return name of the sound
+     */
+    public String getSoundName(){
+        return _container.getSoundName();
+    }
+
+    /**
+     * Type of the sound (e.g. ".wav")
+     *
+     * @return type of the sound
+     */
+    public String getSoundType(){
+        return _container.getSoundType();
+    }
+
+    /**
+     * Gets an input stream which returns the binary of the sound data.
+     *
+     * @return the input stream which will contain the binary of the sound data.
+     */
+    public byte[] getData() {
+        return _container.getSoundData();
+    }
+
+    /**
+     * Find all sound records in the supplied Document records
+     *
+     * @param document the document to find in
+     * @return the array with the sound data
+     */
+    public static SoundData[] find(Document document){
+        ArrayList lst = new ArrayList();
+        Record[] ch = document.getChildRecords();
+        for (int i = 0; i < ch.length; i++) {
+            if(ch[i].getRecordType() == RecordTypes.SoundCollection.typeID){
+                RecordContainer col = (RecordContainer)ch[i];
+                Record[] sr = col.getChildRecords();
+                for (int j = 0; j < sr.length; j++) {
+                    if(sr[j] instanceof Sound){
+                        lst.add(new SoundData((Sound)sr[j]));
+                    }
+                }
+            }
+
+        }
+        return (SoundData[])lst.toArray(new SoundData[lst.size()]);
+    }
+}
index 54e8569d71a6b574fbf7f2ca298445f8a852c691..be7c046027f225108f82cd5a61d4b0b3d7fc0fc4 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.hslf.util;
 
@@ -29,7 +27,7 @@ import java.io.ByteArrayOutputStream;
  * @author Nick Burch
  */
 
-public class MutableByteArrayOutputStream extends ByteArrayOutputStream
+public final class MutableByteArrayOutputStream extends ByteArrayOutputStream
 {
        /** Return how many bytes we've stuffed in so far */
        public int getBytesWritten() { return -1; }
index 379b05bf6aa4ad9cf8a83bd19b0f68e1337c03b3..926a2f564579a7e0a9c2e4d803055ac651f87885 100644 (file)
@@ -26,7 +26,7 @@ import org.apache.poi.util.LittleEndian;
 /**
  * A helper class for dealing with SystemTime Structs, as defined at
  * http://msdn.microsoft.com/library/en-us/sysinfo/base/systemtime_str.asp .
- * 
+ *
  * Discrepancies between Calendar and SYSTEMTIME:
  *  - that January = 1 in SYSTEMTIME, 0 in Calendar.
  *  - that the day of the week (0) starts on Sunday in SYSTEMTIME, and Monday in Calendar
@@ -36,7 +36,7 @@ import org.apache.poi.util.LittleEndian;
  * @author Daniel Noll
  * @author Nick Burch
  */
-public class SystemTimeUtils {
+public final class SystemTimeUtils {
        /**
         * Get the date found in the byte array, as a java Data object
         */
@@ -48,10 +48,10 @@ public class SystemTimeUtils {
         */
        public static Date getDate(byte[] data, int offset) {
         Calendar cal = new GregorianCalendar();
-        
+
         cal.set(Calendar.YEAR,         LittleEndian.getShort(data,offset));
         cal.set(Calendar.MONTH,        LittleEndian.getShort(data,offset+2)-1);
-        // Not actually needed - can be found from day of month 
+        // Not actually needed - can be found from day of month
         //cal.set(Calendar.DAY_OF_WEEK,  LittleEndian.getShort(data,offset+4)+1);
         cal.set(Calendar.DAY_OF_MONTH, LittleEndian.getShort(data,offset+6));
         cal.set(Calendar.HOUR_OF_DAY,  LittleEndian.getShort(data,offset+8));
@@ -61,17 +61,17 @@ public class SystemTimeUtils {
 
         return cal.getTime();
        }
-       
+
        /**
         * Convert the supplied java Date into a SystemTime struct, and write it
-        *  into the supplied byte array. 
+        *  into the supplied byte array.
         */
        public static void storeDate(Date date, byte[] dest) {
                storeDate(date, dest, 0);
        }
        /**
         * Convert the supplied java Date into a SystemTime struct, and write it
-        *  into the supplied byte array. 
+        *  into the supplied byte array.
         */
        public static void storeDate(Date date, byte[] dest, int offset) {
         Calendar cal = new GregorianCalendar();
index 7eaca4f1b79a09be3e805d681d71eec0f74a1fb2..39162852e46e8c2bbbe3ee60ff3ed66d9e1e4270 100644 (file)
@@ -23,39 +23,39 @@ abstract public class Chunk {
        protected int chunkId;
        protected int type;
        protected String namePrefix = "__substg1.0_";
-       
+
        /**
         * Gets the id of this chunk
         */
        public int getChunkId() {
                return this.chunkId;
        }
-       
+
        /**
         * Gets the numeric type of this chunk.
         */
        public int getType() {
                return this.type;
        }
-       
+
        /**
         * Creates a string to use to identify this chunk in the POI file system object.
         */
        public String getEntryName() {
                String type = Integer.toHexString(this.type);
                while(type.length() < 4) type = "0" + type;
-               
+
                String chunkId = Integer.toHexString(this.chunkId);
                while(chunkId.length() < 4) chunkId = "0" + chunkId;
-               
+
                return this.namePrefix + chunkId.toUpperCase() + type.toUpperCase();
        }
-       
+
        /**
         * Gets a reference to a ByteArrayOutputStream that contains the value of this chunk.
         */
        public abstract ByteArrayOutputStream getValueByteArray();
-       
+
        /**
         * Sets the value of this chunk using a OutputStream
         * @param value
index af77badb3b486b60862a272890eca503ddff5cbf..ae7e77b70dfaa5678dbb9778cb20d44f7d8e9e17 100644 (file)
@@ -20,10 +20,10 @@ package org.apache.poi.hsmf.datatypes;
 
 /**
  * Collection of convenence chunks for standard parts of the MSG file.
- * 
+ *
  * @author Travis Ferguson
  */
-public class Chunks {
+public final class Chunks {
        /* String parts of Outlook Messages that are currently known */
 
        /** Type of message that the MSG represents (ie. IPM.Note) */
@@ -44,7 +44,7 @@ public class Chunks {
        public StringChunk conversationTopic;
        /** Type of server that the message originated from (SMTP, etc). */
        public StringChunk sentByServerType;
-       
+
        private Chunks(boolean newStringType) {
                messageClass = new StringChunk(0x001A, newStringType);
                textBodyChunk = new StringChunk(0x1000, newStringType);
@@ -56,7 +56,7 @@ public class Chunks {
                conversationTopic = new StringChunk(0x0070, newStringType);
                sentByServerType = new StringChunk(0x0075, newStringType);
        }
-       
+
        public static Chunks getInstance(boolean newStringType) {
                return new Chunks(newStringType);
        }
index f4d675a05ac1cb37919931d0a3370a8a77ba8ac9..2949ba19081b4250ed7d12fd685fd79221ffac03 100644 (file)
 
 package org.apache.poi.hsmf.datatypes;
 
-public class Types {
+public final class Types {
        public static int BINARY = 0x0102;
-       
+
        /** A string, until Outlook 3.0 */
        public static int OLD_STRING = 0x001E;
        /** A string, from Outlook 3.0 onwards */
        public static int NEW_STRING = 0x001F;
-       
+
        public static int LONG = 0x0003;
        public static int TIME = 0x0040;
        public static int BOOLEAN = 0x000B;
-       
+
        public static String asFileEnding(int type) {
                String str = Integer.toHexString(type).toUpperCase();
                while(str.length() < 4) {
index 5c04518cb46042e78047038ba3b2c8b048118b4d..e0208847598bb64afbffbb099998f57a992df023 100644 (file)
@@ -17,7 +17,7 @@
 
 package org.apache.poi.hsmf.exceptions;
 
-public class ChunkNotFoundException extends Exception {
+public final class ChunkNotFoundException extends Exception {
        private static final long serialVersionUID = 1L;
 
        public ChunkNotFoundException(String chunkName) {
index 308d0c670400174a50a6093d80ff778d19d78fdb..0c33901aee3cb3b8a00dc1108baad9b902180384 100644 (file)
@@ -21,7 +21,7 @@ package org.apache.poi.hsmf.exceptions;
  * Exception for when a directory chunk is not found but is expected.
  * @author Travis Ferguson
  */
-public class DirectoryChunkNotFoundException extends Exception {
+public final class DirectoryChunkNotFoundException extends Exception {
        private static final long serialVersionUID = 1L;
 
        public DirectoryChunkNotFoundException(String directory) {
index 8aa849fa2f22d66a42d77a566fb03a00e7d4e4f4..725659044c0647ce3921b7df673dc4b144282d93 100644 (file)
@@ -45,13 +45,13 @@ import org.apache.poi.hssf.record.formula.Ptg;
  */
 public final class HSSFChart {
        private ChartRecord chartRecord;
-       
+
        private LegendRecord legendRecord;
        private ChartTitleFormatRecord chartTitleFormat;
        private SeriesTextRecord chartTitleText;
-       
+
        private List series = new ArrayList();
-       
+
        private HSSFChart(ChartRecord chartRecord) {
                this.chartRecord = chartRecord;
        }
@@ -129,22 +129,22 @@ public final class HSSFChart {
                sheet.insertChartRecords( records );
                workbook.insertChartRecord();
        }
-       
+
        /**
         * Returns all the charts for the given sheet.
-        * 
+        *
         * NOTE: You won't be able to do very much with
         *  these charts yet, as this is very limited support
         */
        public static HSSFChart[] getSheetCharts(HSSFSheet sheet) {
                List charts = new ArrayList();
                HSSFChart lastChart = null;
-               
+
                // Find records of interest
                List records = sheet.getSheet().getRecords();
                for(Iterator it = records.iterator(); it.hasNext();) {
                        RecordBase r = (RecordBase)it.next();
-                       
+
                        if(r instanceof ChartRecord) {
                                lastChart = new HSSFChart((ChartRecord)r);
                                charts.add(lastChart);
@@ -174,7 +174,7 @@ public final class HSSFChart {
                                }
                        }
                }
-               
+
                return (HSSFChart[])
                        charts.toArray( new HSSFChart[charts.size()] );
        }
@@ -196,7 +196,7 @@ public final class HSSFChart {
        public void setChartWidth(int width) { chartRecord.setWidth(width); }
        /** Sets the height of the chart. {@link ChartRecord} */
        public void setChartHeight(int height) { chartRecord.setHeight(height); }
-       
+
        /**
         * Returns the series of the chart
         */
@@ -204,7 +204,7 @@ public final class HSSFChart {
                return (HSSFSeries[])
                        series.toArray(new HSSFSeries[series.size()]);
        }
-       
+
        /**
         * Returns the chart's title, if there is one,
         *  or null if not
@@ -215,9 +215,9 @@ public final class HSSFChart {
                }
                return null;
        }
-       
+
        /**
-        * Changes the chart's title, but only if there 
+        * Changes the chart's title, but only if there
         *  was one already.
         * TODO - add in the records if not
         */
@@ -860,18 +860,18 @@ public final class HSSFChart {
                return r;
        }
 
-       
+
        /**
         * A series in a chart
         */
        public class HSSFSeries {
                private SeriesRecord series;
                private SeriesTextRecord seriesTitleText;
-               
+
                /* package */ HSSFSeries(SeriesRecord series) {
                        this.series = series;
                }
-               
+
                public short getNumValues() {
                        return series.getNumValues();
                }
@@ -881,7 +881,7 @@ public final class HSSFChart {
                public short getValueType() {
                        return series.getValuesDataType();
                }
-               
+
                /**
                 * Returns the series' title, if there is one,
                 *  or null if not
@@ -892,9 +892,9 @@ public final class HSSFChart {
                        }
                        return null;
                }
-               
+
                /**
-                * Changes the series' title, but only if there 
+                * Changes the series' title, but only if there
                 *  was one already.
                 * TODO - add in the records if not
                 */
index 9bc8354a73576c01dc0bed3ef240379e6e6614b2..a43852be8b4bde8f00fed86ab24648c4d1d19dc4 100644 (file)
@@ -15,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf;
 
 import java.io.InputStream;
@@ -47,7 +46,7 @@ import org.apache.poi.hwpf.usermodel.*;
  *
  * @author Ryan Ackley
  */
-public class HWPFDocument extends POIDocument
+public final class HWPFDocument extends POIDocument
 //  implements Cloneable
 {
   /** The FIB */
@@ -93,13 +92,13 @@ public class HWPFDocument extends POIDocument
 
   /** Holds the save history for this document. */
   protected SavedByTable _sbt;
-  
+
   /** Holds pictures table */
   protected PicturesTable _pictures;
-  
+
   /** Holds FSBA (shape) information */
   protected FSPATable _fspa;
-  
+
   /** Escher Drawing Group information */
   protected EscherRecordHolder _dgg;
 
@@ -145,7 +144,7 @@ public class HWPFDocument extends POIDocument
     //do Ole stuff
     this( verifyAndBuildPOIFS(istream) );
   }
-  
+
   /**
    * This constructor loads a Word document from a POIFSFileSystem
    *
@@ -157,7 +156,7 @@ public class HWPFDocument extends POIDocument
   {
        this(pfilesystem.getRoot(), pfilesystem);
   }
-  
+
   /**
    * This constructor loads a Word document from a specific point
    *  in a POIFSFileSystem, probably not the default.
@@ -172,12 +171,12 @@ public class HWPFDocument extends POIDocument
     // Sort out the hpsf properties
        super(directory, pfilesystem);
     readProperties();
-    
+
     // read in the main stream.
     DocumentEntry documentProps = (DocumentEntry)
        directory.getEntry("WordDocument");
     _mainStream = new byte[documentProps.getSize()];
-    
+
     directory.createDocumentInputStream("WordDocument").read(_mainStream);
 
     // Create our FIB, and check for the doc being encrypted
@@ -225,26 +224,26 @@ public class HWPFDocument extends POIDocument
     // Get the cp of the start of text in the main stream
     // The latest spec doc says this is always zero!
     int fcMin = 0;
-    //fcMin = _fib.getFcMin() 
+    //fcMin = _fib.getFcMin()
 
     // Start to load up our standard structures.
     _dop = new DocumentProperties(_tableStream, _fib.getFcDop());
     _cft = new ComplexFileTable(_mainStream, _tableStream, _fib.getFcClx(), fcMin);
     _tpt = _cft.getTextPieceTable();
-    
+
     // Word XP and later all put in a zero filled buffer in
     //  front of the text. This screws up the system for offsets,
     //  which assume we always start at zero. This is an adjustment.
     int cpMin = _tpt.getCpMin();
-    
+
     // Now load the rest of the properties, which need to be adjusted
     //  for where text really begin
     _cbt = new CHPBinTable(_mainStream, _tableStream, _fib.getFcPlcfbteChpx(), _fib.getLcbPlcfbteChpx(), cpMin, _tpt);
     _pbt = new PAPBinTable(_mainStream, _tableStream, _dataStream, _fib.getFcPlcfbtePapx(), _fib.getLcbPlcfbtePapx(), cpMin, _tpt);
-    
+
     // Read FSPA and Escher information
     _fspa = new FSPATable(_tableStream, _fib.getFcPlcspaMom(), _fib.getLcbPlcspaMom(), getTextTable().getTextPieces());
-    
+
     if (_fib.getFcDggInfo() != 0)
     {
         _dgg = new EscherRecordHolder(_tableStream, _fib.getFcDggInfo(), _fib.getLcbDggInfo());
@@ -252,7 +251,7 @@ public class HWPFDocument extends POIDocument
     {
         _dgg = new EscherRecordHolder();
     }
-    
+
     // read in the pictures stream
     _pictures = new PicturesTable(this, _dataStream, _mainStream, _fspa, _dgg);
     // And the art shapes stream
@@ -303,7 +302,7 @@ public class HWPFDocument extends POIDocument
   {
     return _dop;
   }
-  
+
   /**
    * Returns the range that covers all text in the
    *  file, including main text, footnotes, headers
@@ -325,35 +324,35 @@ public class HWPFDocument extends POIDocument
          // First up, trigger a full-recalculate
          // Needed in case of deletes etc
          getOverallRange();
-         
+
          // Now, return the real one
          return new Range(
-                         _cpSplit.getMainDocumentStart(), 
-                         _cpSplit.getMainDocumentEnd(), 
+                         _cpSplit.getMainDocumentStart(),
+                         _cpSplit.getMainDocumentEnd(),
                          this
       );
   }
-  
+
   /**
    * Returns the range which covers all the Footnotes.
    */
   public Range getFootnoteRange() {
          return new Range(
-                         _cpSplit.getFootnoteStart(), 
-                         _cpSplit.getFootnoteEnd(), 
+                         _cpSplit.getFootnoteStart(),
+                         _cpSplit.getFootnoteEnd(),
                          this
       );
   }
-  
+
   /**
    * Returns the range which covers all "Header Stories".
    * A header story contains a header, footer, end note
-   *  separators and footnote separators. 
+   *  separators and footnote separators.
    */
   public Range getHeaderStoryRange() {
          return new Range(
-                         _cpSplit.getHeaderStoryStart(), 
-                         _cpSplit.getHeaderStoryEnd(), 
+                         _cpSplit.getHeaderStoryStart(),
+                         _cpSplit.getHeaderStoryEnd(),
                          this
       );
   }
@@ -390,14 +389,14 @@ public class HWPFDocument extends POIDocument
   {
     return _sbt;
   }
-  
+
   /**
    * @return PicturesTable object, that is able to extract images from this document
    */
   public PicturesTable getPicturesTable() {
          return _pictures;
   }
-  
+
   /**
    * @return ShapesTable object, that is able to extract office are shapes from this document
    */
@@ -553,7 +552,7 @@ public class HWPFDocument extends POIDocument
     pfs.createDocument(new ByteArrayInputStream(tableBuf), "1Table");
     pfs.createDocument(new ByteArrayInputStream(dataBuf), "Data");
     writeProperties(pfs);
-    
+
     pfs.writeFilesystem(out);
   }
 
index a9a7210e8abd28abc0d78c7ce8b736c7324168db..5aba80c60618dd35137a9273955168c74b87602c 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.hwpf;
 
 import java.io.*;
 
 import org.apache.poi.hwpf.usermodel.*;
 
-public class QuickTest
+public final class QuickTest
 {
   public QuickTest()
   {
index 8d14c3613aaa47e5f2177e81d19ffbcaff0b3b70..8e7bcac90aa641c0bb8ba34e0985eded5a4570c5 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hwpf.dev;
 
 import java.io.FileInputStream;
@@ -26,25 +27,25 @@ import org.apache.poi.hwpf.model.FileInformationBlock;
  *  HWPF file. End users will probably never need to
  *  use this program.
  */
-public class HWPFLister {
+public final class HWPFLister {
        private HWPFDocument doc;
        public HWPFLister(HWPFDocument doc) {
                this.doc = doc;
        }
-       
+
        public static void main(String[] args) throws Exception {
                if(args.length == 0) {
                        System.err.println("Use:");
                        System.err.println("   HWPFLister <filename>");
                        System.exit(1);
                }
-               
+
                HWPFLister l = new HWPFLister(
                                new HWPFDocument(new FileInputStream(args[0]))
                );
                l.dumpFIB();
        }
-       
+
        public void dumpFIB() throws Exception {
                FileInformationBlock fib = doc.getFileInformationBlock();
                System.out.println(fib.toString());
index 816b2c1221b55d686b00eed4f767f4e5235a1d44..e63ad4f5a4bf5daad36ff8f5ecb895c0f4c08d15 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hwpf.extractor;
 
 import java.io.IOException;
@@ -33,16 +34,16 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
 /**
  * Class to extract the text from a Word Document.
- * 
+ *
  * You should use either getParagraphText() or getText() unless
  *  you have a strong reason otherwise.
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class WordExtractor extends POIOLE2TextExtractor {
+public final class WordExtractor extends POIOLE2TextExtractor {
        private POIFSFileSystem fs;
        private HWPFDocument doc;
-       
+
        /**
         * Create a new Word Extractor
         * @param is InputStream containing the word file
@@ -63,7 +64,7 @@ public class WordExtractor extends POIOLE2TextExtractor {
                this(new HWPFDocument(dir, fs));
                this.fs = fs;
        }
-       
+
        /**
         * Create a new Word Extractor
         * @param doc The HWPFDocument to extract from
@@ -89,14 +90,14 @@ public class WordExtractor extends POIOLE2TextExtractor {
                WordExtractor extractor = new WordExtractor(fin);
                System.out.println(extractor.getText());
        }
-       
+
        /**
         * Get the text from the word file, as an array with one String
         *  per paragraph
         */
        public String[] getParagraphText() {
                String[] ret;
-               
+
                // Extract using the model code
                try {
                Range r = doc.getRange();
@@ -105,7 +106,7 @@ public class WordExtractor extends POIOLE2TextExtractor {
                        for(int i=0; i<ret.length; i++) {
                                Paragraph p = r.getParagraph(i);
                                ret[i] = p.text();
-                               
+
                                // Fix the line ending
                                if(ret[i].endsWith("\r")) {
                                        ret[i] = ret[i] + "\n";
@@ -117,10 +118,10 @@ public class WordExtractor extends POIOLE2TextExtractor {
                        ret = new String[1];
                        ret[0] = getTextFromPieces();
                }
-               
+
                return ret;
        }
-       
+
        /**
         * Add the header/footer text, if it's not empty
         */
@@ -146,7 +147,7 @@ public class WordExtractor extends POIOLE2TextExtractor {
         */
        public String getHeaderText() {
                HeaderStories hs = new HeaderStories(doc);
-               
+
                StringBuffer ret = new StringBuffer();
                if(hs.getFirstHeader() != null) {
                        appendHeaderFooter(hs.getFirstHeader(), ret);
@@ -157,7 +158,7 @@ public class WordExtractor extends POIOLE2TextExtractor {
                if(hs.getOddHeader() != null) {
                        appendHeaderFooter(hs.getOddHeader(), ret);
                }
-               
+
                return ret.toString();
        }
        /**
@@ -165,7 +166,7 @@ public class WordExtractor extends POIOLE2TextExtractor {
         */
        public String getFooterText() {
                HeaderStories hs = new HeaderStories(doc);
-               
+
                StringBuffer ret = new StringBuffer();
                if(hs.getFirstFooter() != null) {
                        appendHeaderFooter(hs.getFirstFooter(), ret);
@@ -176,10 +177,10 @@ public class WordExtractor extends POIOLE2TextExtractor {
                if(hs.getOddFooter() != null) {
                        appendHeaderFooter(hs.getOddFooter(), ret);
                }
-               
+
                return ret.toString();
        }
-       
+
        /**
         * Grab the text out of the text pieces. Might also include various
         *  bits of crud, but will work in cases where the text piece -> paragraph
@@ -187,7 +188,7 @@ public class WordExtractor extends POIOLE2TextExtractor {
         */
        public String getTextFromPieces() {
        StringBuffer textBuf = new StringBuffer();
-       
+
        Iterator textPieces = doc.getTextTable().getTextPieces().iterator();
        while (textPieces.hasNext()) {
                TextPiece piece = (TextPiece) textPieces.next();
@@ -203,39 +204,39 @@ public class WordExtractor extends POIOLE2TextExtractor {
                        throw new InternalError("Standard Encoding " + encoding + " not found, JVM broken");
                }
        }
-       
+
        String text = textBuf.toString();
-       
+
        // Fix line endings (Note - won't get all of them
        text = text.replaceAll("\r\r\r", "\r\n\r\n\r\n");
        text = text.replaceAll("\r\r", "\r\n\r\n");
-       
+
        if(text.endsWith("\r")) {
                text += "\n";
        }
-       
+
        return text;
        }
-       
+
        /**
         * Grab the text, based on the paragraphs. Shouldn't include any crud,
         *  but slightly slower than getTextFromPieces().
         */
        public String getText() {
                StringBuffer ret = new StringBuffer();
-               
+
                ret.append(getHeaderText());
-               
+
                String[] text = getParagraphText();
                for(int i=0; i<text.length; i++) {
                        ret.append(text[i]);
                }
-               
+
                ret.append(getFooterText());
-               
+
                return ret.toString();
        }
-       
+
        /**
         * Removes any fields (eg macros, page markers etc)
         *  from the string.
index d22edb63261b545dc9ff07f2f191299943a86fc1..d4c0b1fb7a31e1d91770d5901ea345e08965c832 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hwpf.model;
 
 /**
@@ -25,7 +26,7 @@ package org.apache.poi.hwpf.model;
  */
 public abstract class BytePropertyNode extends PropertyNode {
        private boolean isUnicode;
-       
+
        /**
         * @param fcStart The start of the text for this property, in _bytes_
         * @param fcEnd The end of the text for this property, in _bytes_
@@ -43,7 +44,7 @@ public abstract class BytePropertyNode extends PropertyNode {
                        return val/2;
                return val;
        }
-       
+
        public boolean isUnicode() {
                return isUnicode;
        }
index f46aee80a18661b19477066da0644560ba60a098..1374bd67d5cc9e5725d8719bff76da6d3ac61af2 100644 (file)
@@ -32,7 +32,7 @@ import org.apache.poi.hwpf.sprm.SprmBuffer;
  *
  * @author Ryan Ackley
  */
-public class CHPBinTable
+public final class CHPBinTable
 {
   /** List of character properties.*/
   protected ArrayList _textRuns = new ArrayList();
@@ -120,13 +120,13 @@ public class CHPBinTable
   public void insert(int listIndex, int cpStart, SprmBuffer buf)
   {
        boolean needsToBeUnicode = tpt.isUnicodeAtCharOffset(cpStart);
-         
+
     CHPX insertChpx = new CHPX(0, 0, buf, needsToBeUnicode);
-    
+
     // Ensure character offsets are really characters
     insertChpx.setStart(cpStart);
     insertChpx.setEnd(cpStart);
-    
+
     if (listIndex == _textRuns.size())
     {
       _textRuns.add(insertChpx);
@@ -145,7 +145,7 @@ public class CHPBinTable
         // Again ensure contains character based offsets no matter what
         clone.setStart(cpStart);
         clone.setEnd(chpx.getEnd());
-        
+
         chpx.setEnd(cpStart);
 
         _textRuns.add(listIndex + 1, insertChpx);
index e6b302300feb86b64ecab01403720514110184bc..fa24a78b0dcbcd7bfab0414b641df4b6988417fd 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf.model;
 
 import java.util.List;
@@ -39,7 +38,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Ryan Ackley
  */
-public class CHPFormattedDiskPage extends FormattedDiskPage
+public final class CHPFormattedDiskPage extends FormattedDiskPage
 {
     private static final int FC_SIZE = 4;
 
index a89036c73357fe48ffac9df43435954f6da9ecbb..f2dc4c3d7f794e362e66c4068b0987d89c270063 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model;
 
@@ -26,15 +23,15 @@ import org.apache.poi.hwpf.sprm.CharacterSprmUncompressor;
 
 /**
  * DANGER - works in bytes!
- * 
+ *
  * Make sure you call getStart() / getEnd() when you want characters
- *  (normal use), but getStartByte() / getEndByte() when you're 
+ *  (normal use), but getStartByte() / getEndByte() when you're
  *  reading in / writing out!
  *
  * @author Ryan Ackley
  */
 
-public class CHPX extends BytePropertyNode
+public final class CHPX extends BytePropertyNode
 {
 
   public CHPX(int fcStart, int fcEnd, byte[] grpprl, boolean isUnicode)
index 1e3a20731bc21b607f43e4d11fbb979328ca8f64..225fc1c333636bdac668938ff3c9bdbc9d5940b3 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hwpf.model;
 
 import org.apache.poi.hwpf.HWPFDocument;
@@ -23,12 +24,12 @@ import org.apache.poi.hwpf.HWPFDocument;
  *  where different kinds of text can be found within the
  *  overall CP splurge.
  */
-public class CPSplitCalculator {
+public final class CPSplitCalculator {
        private FileInformationBlock fib;
        public CPSplitCalculator(FileInformationBlock fib) {
                this.fib = fib;
        }
-       
+
        /**
         * Where the main document text starts. Always 0.
         */
@@ -36,13 +37,13 @@ public class CPSplitCalculator {
                return 0;
        }
        /**
-        * Where the main document text ends. 
+        * Where the main document text ends.
         * Given by FibRgLw97.ccpText
         */
        public int getMainDocumentEnd() {
                return fib.getCcpText();
        }
-       
+
        /**
         * Where the Footnotes text starts.
         * Follows straight on from the main text.
@@ -58,7 +59,7 @@ public class CPSplitCalculator {
                return getFootnoteStart() +
                        fib.getCcpFtn();
        }
-       
+
        /**
         * Where the "Header Story" text starts.
         * Follows straight on from the footnotes.
@@ -74,7 +75,7 @@ public class CPSplitCalculator {
                return getHeaderStoryStart() +
                        fib.getCcpHdd();
        }
-       
+
        /**
         * Where the Comment (Atn) text starts.
         * Follows straight on from the header stories.
@@ -90,7 +91,7 @@ public class CPSplitCalculator {
                return getCommentsStart() +
                        fib.getCcpCommentAtn();
        }
-       
+
        /**
         * Where the End Note text starts.
         * Follows straight on from the comments.
@@ -106,7 +107,7 @@ public class CPSplitCalculator {
                return getEndNoteStart() +
                        fib.getCcpEdn();
        }
-       
+
        /**
         * Where the Main Textbox text starts.
         * Follows straight on from the end note.
@@ -122,7 +123,7 @@ public class CPSplitCalculator {
                return getMainTextboxStart() +
                        fib.getCcpTxtBx();
        }
-       
+
        /**
         * Where the Header Textbox text starts.
         * Follows straight on from the main textbox.
index ef1adda2f955f44ab810cd3d9fce0a03b2b53505..565cdb2cb8bf28a6f1eadcf2b0300c59a67d0b5a 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.hwpf.model;
 
 import org.apache.poi.hwpf.sprm.SprmBuffer;
 
 import java.lang.ref.SoftReference;
 
-public class CachedPropertyNode
+public final class CachedPropertyNode
   extends PropertyNode
 {
   protected SoftReference _propCache;
index afeb6e0e85df390582c356167a4477dd13b60b91..12d0e2e77de7f271f5b77c72ad73189e2ac0cd7a 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model;
 
@@ -25,7 +22,7 @@ import java.io.IOException;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.hwpf.model.io.*;
 
-public class ComplexFileTable
+public final class ComplexFileTable
 {
 
   private static final byte GRPPRL_TYPE = 1;
index 59c13310e5b7b035bd207bf4e8478f4ec2d1b097..fed2e0643df97183bc7deb515618f3f7f23c3ccd 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model;
 
@@ -29,7 +26,7 @@ import org.apache.poi.hwpf.model.types.DOPAbstractType;
  * @author Ryan Ackley
  */
 
-public class DocumentProperties extends DOPAbstractType
+public final class DocumentProperties extends DOPAbstractType
 {
 
 
index 5dc874a511dc6fb7dafb738a3bf3340480255044..310dbc52c3e325dd06d7a32cbf817971265873a7 100644 (file)
@@ -27,21 +27,21 @@ import org.apache.poi.ddf.EscherRecordFactory;
 
 /**
  * Based on AbstractEscherRecordHolder from HSSF.
- * 
+ *
  * @author Squeeself
  */
 public final class EscherRecordHolder {
        private final ArrayList<EscherRecord> escherRecords;
-       
+
        public EscherRecordHolder() {
                escherRecords = new ArrayList<EscherRecord>();
        }
-       
+
        public EscherRecordHolder(byte[] data, int offset, int size) {
                this();
                fillEscherRecords(data, offset, size);
        }
-       
+
        private void fillEscherRecords(byte[] data, int offset, int size)
        {
                EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
@@ -54,11 +54,11 @@ public final class EscherRecordHolder {
                        pos += bytesRead + 1; // There is an empty byte between each top-level record in a Word doc
                }
        }
-       
+
        public List<EscherRecord> getEscherRecords() {
                return escherRecords;
        }
-       
+
        public String toString() {
                StringBuffer buffer = new StringBuffer();
 
@@ -72,7 +72,7 @@ public final class EscherRecordHolder {
                }
                return buffer.toString();
        }
-       
+
        /**
         * If we have a EscherContainerRecord as one of our
         *  children (and most top level escher holders do),
@@ -104,7 +104,7 @@ public final class EscherRecordHolder {
                                return r;
                        }
                }
-               
+
                // Then check our children in turn
                for(Iterator<EscherRecord> it = records.iterator(); it.hasNext();) {
                        EscherRecord r = it.next();
@@ -115,7 +115,7 @@ public final class EscherRecordHolder {
                                }
                        }
                }
-               
+
                // Not found in this lot
                return null;
        }
index b087978ab109cf8d1cfa61989b2ec4aab9f64a4c..294cb88f2d6515a64aedd47641b885e11251bda8 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf.model;
 
 import java.util.HashSet;
@@ -29,7 +28,7 @@ import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 
-public class FIBFieldHandler
+public final class FIBFieldHandler
 {
   public static final int STSHFORIG = 0;
   public static final int STSHF = 1;
index 8129daaed8ca509879f6114ef9f9fedf01358f43..8d5967411c4157f43a30f80649a7a4c7680a2332 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf.model;
 
 import java.io.IOException;
@@ -26,7 +25,7 @@ import org.apache.poi.util.LittleEndian;
  * Handles the fibRgLw / The FibRgLw97 part of
  *  the FIB (File Information Block)
  */
-public class FIBLongHandler {
+public final class FIBLongHandler {
   public static final int CBMAC = 0;
   public static final int PRODUCTCREATED = 1;
   public static final int PRODUCTREVISED = 2;
index e8c2b20afeda06f64ead96dbe05d6657ca4c47c6..4de7e5a29ddeb6d4f7abd277f67f81166384f8f0 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf.model;
 
 import java.io.IOException;
@@ -23,10 +22,10 @@ import java.io.IOException;
 import org.apache.poi.util.LittleEndian;
 
 /**
- * Handles the fibRgW / FibRgW97 part of 
+ * Handles the fibRgW / FibRgW97 part of
  *  the FIB (File Information Block)
  */
-public class FIBShortHandler {
+public final class FIBShortHandler {
   public final static int MAGICCREATED = 0;
   public final static int MAGICREVISED = 1;
   public final static int MAGICCREATEDPRIVATE = 2;
index bb3d5def1fe6eaf143e96d6f1fba59eaf605373f..2f683589d1de3971b0993d5ac42010ac04c19547 100644 (file)
@@ -23,10 +23,10 @@ import org.apache.poi.util.LittleEndian;
 
 /**
  * File Shape Address structure
- * 
+ *
  * @author Squeeself
  */
-public class FSPA 
+public final class FSPA
 {
     public static final int FSPA_SIZE = 26;
     private int spid; // Shape identifier. Used to get data position
@@ -44,11 +44,11 @@ public class FSPA
         private static BitField fBelowText = BitFieldFactory.getInstance(0x4000); // if true, shape is below text, otherwise above
         private static BitField fAnchorLock = BitFieldFactory.getInstance(0x8000); // if true, anchor is locked
     private int cTxbx; // Count of textboxes in shape (undo doc only)
-    
+
     public FSPA()
     {
     }
-    
+
     public FSPA(byte[] bytes, int offset)
     {
         spid = LittleEndian.getInt(bytes, offset);
@@ -65,77 +65,77 @@ public class FSPA
         offset += LittleEndian.SHORT_SIZE;
         cTxbx = LittleEndian.getInt(bytes, offset);
     }
-    
+
     public int getSpid()
     {
         return spid;
     }
-    
+
     public int getXaLeft()
     {
         return xaLeft;
     }
-    
+
     public int getYaTop()
     {
         return yaTop;
     }
-    
+
     public int getXaRight()
     {
         return xaRight;
     }
-    
+
     public int getYaBottom()
     {
         return yaBottom;
     }
-    
+
     public boolean isFHdr()
     {
         return fHdr.isSet(options);
     }
-    
+
     public short getBx()
     {
         return bx.getShortValue(options);
     }
-    
+
     public short getBy()
     {
         return by.getShortValue(options);
     }
-    
+
     public short getWr()
     {
         return wr.getShortValue(options);
     }
-    
+
     public short getWrk()
     {
         return wrk.getShortValue(options);
     }
-    
+
     public boolean isFRcaSimple()
     {
         return fRcaSimple.isSet(options);
     }
-    
+
     public boolean isFBelowText()
     {
         return fBelowText.isSet(options);
     }
-    
+
     public boolean isFAnchorLock()
     {
         return fAnchorLock.isSet(options);
     }
-    
+
     public int getCTxbx()
     {
         return cTxbx;
     }
-    
+
     public byte[] toByteArray()
     {
         int offset = 0;
@@ -158,7 +158,7 @@ public class FSPA
 
         return buf;
     }
-    
+
     public String toString()
     {
         StringBuffer buf = new StringBuffer();
index 812ab1a4a766feb548571b252cb27513f58bf5c7..5f25e8bb595a279696e4a89fa2ce3a016f608ce6 100644 (file)
@@ -25,33 +25,33 @@ import java.util.Map;
 
 /**
  * This class holds all the FSPA (File Shape Address) structures.
- * 
+ *
  * @author Squeeself
  */
-public final class FSPATable 
+public final class FSPATable
 {
     private final List _shapes = new ArrayList();
     private final Map _shapeIndexesByPropertyStart = new HashMap();
     private final List _text;
-    
+
     public FSPATable(byte[] tableStream, int fcPlcspa, int lcbPlcspa, List tpt)
     {
         _text = tpt;
         // Will be 0 if no drawing objects in document
         if (fcPlcspa == 0)
             return;
-        
+
         PlexOfCps plex = new PlexOfCps(tableStream, fcPlcspa, lcbPlcspa, FSPA.FSPA_SIZE);
         for (int i=0; i < plex.length(); i++)
         {
             GenericPropertyNode property = plex.getProperty(i);
             FSPA fspa = new FSPA(property.getBytes(), 0);
-            
+
             _shapes.add(fspa);
             _shapeIndexesByPropertyStart.put(new Integer(property.getStart()), new Integer(i));
         }
     }
-    
+
     public FSPA getFspaFromCp(int cp)
     {
         Integer idx = (Integer)_shapeIndexesByPropertyStart.get(new Integer(cp));
@@ -60,14 +60,14 @@ public final class FSPATable
         }
         return (FSPA)_shapes.get(idx.intValue());
     }
-    
+
     public FSPA[] getShapes()
     {
         FSPA[] result = new FSPA[_shapes.size()];
         _shapes.toArray(result);
         return result;
     }
-    
+
     public String toString()
     {
         StringBuffer buf = new StringBuffer();
index 72f3de9925f3973e7a754c0aed0c82c326576120..b3ddb356c1d1aa83c64a8888d31a73f7ea586184 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.hwpf.model;
 
@@ -31,7 +29,7 @@ import java.util.Arrays;
  *
  * @author Praveen Mathew
  */
-public class Ffn
+public final class Ffn
 {
   private int _cbFfnM1;//total length of FFN - 1.
   private byte _info;
index d6e2ac30d413f4831e1dd84bd5474485f831f283..5bf14adf6ba2a9d479fae3cd14d1a1edb8dd8d53 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.hwpf.model;
 
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 
-public class FieldDescriptor
+public final class FieldDescriptor
 {
   byte _fieldBoundaryType;
   byte _info;
index 22952735e41cbe1bb737d5cedb3e43f8e2b6502b..01b95354b37deaee0382e7ac6d1ff8a083c3752c 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.hwpf.model;
 
@@ -31,7 +29,7 @@ import org.apache.poi.hwpf.model.types.FIBAbstractType;
  * The File Information Block (FIB). Holds pointers
  *  to various bits of the file, and lots of flags which
  *  specify properties of the document.
- * 
+ *
  * The parent class, {@link FIBAbstractType}, holds the
  *  first 32 bytes, which make up the FibBase.
  * The next part, the fibRgW / FibRgW97, is handled
@@ -40,10 +38,10 @@ import org.apache.poi.hwpf.model.types.FIBAbstractType;
  *  handled by the {@link FIBLongHandler}.
  * Finally, the rest of the fields are handled by
  *  the {@link FIBFieldHandler}.
- * 
+ *
  * @author  andy
  */
-public class FileInformationBlock extends FIBAbstractType
+public final class FileInformationBlock extends FIBAbstractType
   implements Cloneable
 {
 
@@ -321,8 +319,8 @@ public class FileInformationBlock extends FIBAbstractType
     {
       _fieldHandler.setFieldSize(FIBFieldHandler.PLFLFO, modifiedHigh);
     }
-    
-    
+
+
     /**
      * How many bytes of the main stream contain real data.
      */
@@ -331,7 +329,7 @@ public class FileInformationBlock extends FIBAbstractType
     }
     /**
      * Updates the count of the number of bytes in the
-     * main stream which contain real data 
+     * main stream which contain real data
      */
     public void setCbMac(int cbMac) {
        _longHandler.setLong(FIBLongHandler.CBMAC, cbMac);
@@ -431,7 +429,7 @@ public class FileInformationBlock extends FIBAbstractType
        _longHandler.setLong(FIBLongHandler.CCPHDRTXBX, ccpTxtBx);
     }
 
-       
+
     public void clearOffsetsSizes()
     {
       _fieldHandler.clearFields();
@@ -446,22 +444,22 @@ public class FileInformationBlock extends FIBAbstractType
     {
       return _fieldHandler.getFieldSize(FIBFieldHandler.PLCFFLDMOM);
     }
-    
+
     public int getFcPlcspaMom()
     {
         return _fieldHandler.getFieldOffset(FIBFieldHandler.PLCSPAMOM);
     }
-    
+
     public int getLcbPlcspaMom()
     {
         return _fieldHandler.getFieldSize(FIBFieldHandler.PLCSPAMOM);
     }
-    
+
     public int getFcDggInfo()
     {
         return _fieldHandler.getFieldOffset(FIBFieldHandler.DGGINFO);
     }
-    
+
     public int getLcbDggInfo()
     {
         return _fieldHandler.getFieldSize(FIBFieldHandler.DGGINFO);
index a06b15634f304a58ababc8ee606ae8fe0ada0af2..2073be4bf9e4561e2b2a6b72ac24179c9b8fe0ee 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.hwpf.model;
 
@@ -32,7 +30,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Praveen Mathew
  */
-public class FontTable
+public final class FontTable
 {
   private short _stringCount;// how many strings are included in the string table
   private short _extraDataSz;// size in bytes of the extra data
index 5eb094d969397c2b6987b9bd2e425135a32fce8f..bbb56f5b15386265878abbf3118ecd628bbb9f69 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.hwpf.model;
 
index ff56d7fc91729e2e8a680c323ed8030a83be3710..28c380383f48ad436182e0cc42019d96c2e03e54 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.hwpf.model;
 
-public class GenericPropertyNode
+public final class GenericPropertyNode
   extends PropertyNode
 {
   public GenericPropertyNode(int start, int end, byte[] buf)
index af72559ced3edb1a518ad466d7b832752ff1e471..b1791132ec4260423976a8de5e3a48cb83530078 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.
 ==================================================================== */
-        
-/*
- * HDFType.java
- *
- * Created on February 24, 2002, 2:37 PM
- */
 
 package org.apache.poi.hwpf.model;
 
index ac2ece86da9c9dbf883244c242a1146691721e44..e9ab368b3afdcfbfb7a84791cfc81d82cd5663fb 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.hwpf.model;
 
@@ -25,7 +23,7 @@ import org.apache.poi.util.LittleEndian;
 
 import java.util.Arrays;
 
-public class ListData
+public final class ListData
 {
   private int _lsid;
   private int _tplc;
index 2c6c7285cce71fec1eaddc5449694e591c9599ca..bd5c123583c4b663bb5b9467d13a972d7b7949ce 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.hwpf.model;
 
@@ -23,7 +21,7 @@ import org.apache.poi.util.LittleEndian;
 
 import java.util.Arrays;
 
-public class ListFormatOverride
+public final class ListFormatOverride
 {
   int _lsid;
   int _reserved1;
index 9706c0a474707e798b269312a5ce690b3f26055d..ceb59167d44e8de6ee35d3d71e5482a8b70b31be 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.hwpf.model;
 
@@ -25,7 +23,7 @@ import org.apache.poi.util.BitFieldFactory;
 
 import java.util.Arrays;
 
-public class ListFormatOverrideLevel
+public final class ListFormatOverrideLevel
 {
   private static final int BASE_SIZE = 8;
 
index f6b4d8594fea8ec64c70b18d20331ea18dc920cb..de8e7afccdf0135d8fb46070fda179001e77a475 100644 (file)
@@ -23,7 +23,7 @@ import org.apache.poi.util.BitField;
 import org.apache.poi.util.LittleEndian;
 
 /**
- * 
+ *
  */
 public final class ListLevel
 {
@@ -90,7 +90,7 @@ public final class ListLevel
     _rgbxchNums = new byte[RGBXCH_NUMS_SIZE];
     System.arraycopy(buf, offset, _rgbxchNums, 0, RGBXCH_NUMS_SIZE);
     offset += RGBXCH_NUMS_SIZE;
-  
+
    _ixchFollow = buf[offset++];
     _dxaSpace = LittleEndian.getInt(buf, offset);
     offset += LittleEndian.INT_SIZE;
@@ -108,7 +108,7 @@ public final class ListLevel
     System.arraycopy(buf, offset, _grpprlChpx, 0, _cbGrpprlChpx);
     offset += _cbGrpprlChpx;
 
-    int numberTextLength = LittleEndian.getShort(buf, offset); 
+    int numberTextLength = LittleEndian.getShort(buf, offset);
     /* sometimes numberTextLength<0 */
     /* by derjohng */
     if (numberTextLength>0)
@@ -241,7 +241,7 @@ public final class ListLevel
         6 // int byte byte
         + RGBXCH_NUMS_SIZE
         + 13 // byte int int byte byte short
-        + _cbGrpprlChpx 
+        + _cbGrpprlChpx
         + _cbGrpprlPapx
         + 2; // numberText length
     if (_numberText != null) {
index 4196566d9ad9a1faa0745be9a831bf30eb0af1e9..4bc8e74d5c02e381f255aa986ea268912c446eb5 100644 (file)
@@ -15,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.model;
 
 import org.apache.poi.util.LittleEndian;
@@ -35,7 +34,7 @@ import java.io.IOException;
 /**
  * @author Ryan Ackley
  */
-public class ListTables
+public final class ListTables
 {
   private static final int LIST_DATA_SIZE = 28;
   private static final int LIST_FORMAT_OVERRIDE_SIZE = 16;
@@ -196,7 +195,7 @@ public class ListTables
        ListLevel lvl = lst.getLevels()[level];
        return lvl;
     } else {
-       log.log(POILogger.WARN, "Requested level " + level + " which was greater than the maximum defined (" + lst.numLevels() + ")"); 
+       log.log(POILogger.WARN, "Requested level " + level + " which was greater than the maximum defined (" + lst.numLevels() + ")");
        return null;
     }
   }
index ed47b59c59323cb7aaacd8a6e6e1d611b3691f3e..66446dfaa1b31b7511f8170b3c54925f188f72f3 100644 (file)
@@ -34,7 +34,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Ryan Ackley
  */
-public class PAPBinTable
+public final class PAPBinTable
 {
   protected ArrayList _paragraphs = new ArrayList();
   byte[] _dataStream;
@@ -77,13 +77,13 @@ public class PAPBinTable
   public void insert(int listIndex, int cpStart, SprmBuffer buf)
   {
     boolean needsToBeUnicode = tpt.isUnicodeAtCharOffset(cpStart);
-    
+
     PAPX forInsert = new PAPX(0, 0, buf, _dataStream, needsToBeUnicode);
-    
+
     // Ensure character offsets are really characters
     forInsert.setStart(cpStart);
     forInsert.setEnd(cpStart);
-    
+
     if (listIndex == _paragraphs.size())
     {
        _paragraphs.add(forInsert);
@@ -102,7 +102,7 @@ public class PAPBinTable
         {
           exc.printStackTrace();
         }
-        
+
        // Copy the properties of the one before to afterwards
        // Will go:
        //  Original, until insert at point
@@ -112,7 +112,7 @@ public class PAPBinTable
         // Again ensure contains character based offsets no matter what
         clone.setStart(cpStart);
         clone.setEnd(currentPap.getEnd());
-        
+
         currentPap.setEnd(cpStart);
 
         _paragraphs.add(listIndex + 1, forInsert);
index 1a9a7bad5908ac8acf467939624508d6bbdd75d4..ab7f8155bf0f7a9c1e152a8edc05746610a6e435 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf.model;
 
 import org.apache.poi.poifs.common.POIFSConstants;
@@ -41,7 +40,7 @@ import java.util.Arrays;
  *
  * @author Ryan Ackley
  */
-public class PAPFormattedDiskPage extends FormattedDiskPage
+public final class PAPFormattedDiskPage extends FormattedDiskPage
 {
 
     private static final int BX_SIZE = 13;
@@ -69,7 +68,7 @@ public class PAPFormattedDiskPage extends FormattedDiskPage
          int endAt = getEnd(x) - fcMin;
         boolean isUnicode = tpt.isUnicodeAtByteOffset(startAt);
          //System.err.println(startAt + " -> " + endAt + " = " + isUnicode);
-        
+
          _papxList.add(new PAPX(startAt, endAt, getGrpprl(x), getParagraphHeight(x), dataStream, isUnicode));
       }
       _fkp = null;
index 1e8ae86b526b4399ad12752391b13ebb43ddea78..73c1c8edd7baa50e308a3217eb8351c2a01db0b9 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model;
 
@@ -30,15 +27,15 @@ import org.apache.poi.hwpf.sprm.SprmOperation;
 
 /**
  * DANGER - works in bytes!
- * 
+ *
  * Make sure you call getStart() / getEnd() when you want characters
- *  (normal use), but getStartByte() / getEndByte() when you're 
+ *  (normal use), but getStartByte() / getEndByte() when you're
  *  reading in / writing out!
  *
  * @author Ryan Ackley
  */
 
-public class PAPX extends BytePropertyNode {
+public final class PAPX extends BytePropertyNode {
 
   private ParagraphHeight _phe;
   private int _hugeGrpprlOffset = -1;
index ea24fe4d59744b9905d9bb788e112b3cc5ff8acb..698dba32f67bc654f5b551ed5622f46622ff1da2 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model;
 
@@ -27,7 +24,7 @@ import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
 
-public class ParagraphHeight
+public final class ParagraphHeight
 {
   private short infoField;
     private BitField fSpare = BitFieldFactory.getInstance(0x0001);
index 5aeb788e951e018fcda14ebe000463209c60c1d3..d61d7f64dde4ede007643a6f5fbbe5131117196f 100644 (file)
@@ -15,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.model;
 
 import org.apache.poi.util.LittleEndian;
@@ -50,7 +49,7 @@ import org.apache.poi.ddf.EscherRecordFactory;
  *
  * @author Dmitry Romanov
  */
-public class PicturesTable
+public final class PicturesTable
 {
   static final int TYPE_IMAGE = 0x08;
   static final int TYPE_IMAGE_WORD2000 = 0x00;
@@ -72,7 +71,7 @@ public class PicturesTable
 
   /**
    *
-   * @param _document 
+   * @param _document
    * @param _dataStream
    */
   public PicturesTable(HWPFDocument _document, byte[] _dataStream, byte[] _mainStream, FSPATable fspa, EscherRecordHolder dgg)
@@ -94,7 +93,7 @@ public class PicturesTable
     }
     return false;
   }
-  
+
   public boolean hasEscherPicture(CharacterRun run) {
     if (run.isSpecialCharacter() && !run.isObj() && !run.isOle2() && !run.isData() && run.text().startsWith("\u0008")) {
       return true;
@@ -132,7 +131,7 @@ public class PicturesTable
    * to have that byte array in memory but only write picture's contents to stream, pass false and then use Picture.writeImageContent
    * @see Picture#writeImageContent(java.io.OutputStream)
    * @return a Picture object if picture exists for specified CharacterRun, null otherwise. PicturesTable.hasPicture is used to determine this.
-   * @see #hasPicture(org.apache.poi.hwpf.usermodel.CharacterRun) 
+   * @see #hasPicture(org.apache.poi.hwpf.usermodel.CharacterRun)
    */
   public Picture extractPicture(CharacterRun run, boolean fillBytes) {
     if (hasPicture(run)) {
@@ -140,7 +139,7 @@ public class PicturesTable
     }
     return null;
   }
-  
+
   /**
      * Performs a recursive search for pictures in the given list of escher records.
      *
@@ -184,12 +183,12 @@ public class PicturesTable
   /**
    * Not all documents have all the images concatenated in the data stream
    * although MS claims so. The best approach is to scan all character runs.
-   *  
+   *
    * @return a list of Picture objects found in current document
    */
   public List getAllPictures() {
     ArrayList pictures = new ArrayList();
-       
+
     Range range = _document.getRange();
     for (int i = 0; i < range.numCharacterRuns(); i++) {
        CharacterRun run = range.getCharacterRun(i);
@@ -199,7 +198,7 @@ public class PicturesTable
                pictures.add(picture);
        }
        }
-    
+
     searchForPictures(_dgg.getEscherRecords(), pictures);
 
     return pictures;
index ab4ee578f42d1c3022e2a4307240b6489b3187c0..2af7b7a6f3ee76887d842f30dda843453169617e 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model;
 
@@ -24,7 +21,7 @@ import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
 
-public class PieceDescriptor
+public final class PieceDescriptor
 {
 
   short descriptor;
index c0df0e8f8f875e4ae47ea3d5e97e742eeb9727db..fe458608a05e09f8994a26c21d567bc909959b40 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf.model;
 
 import java.util.ArrayList;
@@ -31,7 +30,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Ryan Ackley
  */
-public class PlexOfCps
+public final class PlexOfCps
 {
   private int _count;
   private int _offset;
@@ -56,7 +55,7 @@ public class PlexOfCps
   {
        // Figure out the number we hold
     _count = (size - 4)/(4 + sizeOfStruct);
-    
+
     _sizeOfStruct = sizeOfStruct;
     _props = new ArrayList(_count);
 
index 5a14917962d59c6617f833f19dd9af016126107a..c9b5fb9a7353a14dc3ffda5f1576d1a92c5ea7e3 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf.model;
 
 import java.util.Arrays;
@@ -48,7 +47,7 @@ public abstract class PropertyNode implements Comparable, Cloneable
       _cpStart = fcStart;
       _cpEnd = fcEnd;
       _buf = buf;
-      
+
       if(_cpStart < 0) {
          System.err.println("A property claimed to start before zero, at " + _cpStart + "! Resetting it to zero, and hoping for the best");
          _cpStart = 0;
@@ -92,7 +91,7 @@ public abstract class PropertyNode implements Comparable, Cloneable
 
     if (_cpEnd > start) {
         // The start of the change is before we end
-       
+
         if (_cpStart < end) {
             // The delete was somewhere in the middle of us
             _cpEnd = end >= _cpEnd ? start : _cpEnd - length;
index 7987280ed1370c0b5cdb60b9cf05f28a27b08878..7095f0dcf52bcb7f7bf781f3e963a3393b601406 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model;
 
@@ -26,7 +23,7 @@ import org.apache.poi.hwpf.usermodel.SectionProperties;
 
 /**
  */
-public class SEPX extends BytePropertyNode
+public final class SEPX extends BytePropertyNode
 {
 
   SectionDescriptor _sed;
index a94deaa6feb53a732eed6e6673fcd140b7f3b174..f4dc3e00ed6cdfc7ee219836828bc3ac742106c3 100644 (file)
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.model;
 
 
 /**
  * A single entry in the {@link SavedByTable}.
- * 
+ *
  * @author Daniel Noll
  */
-public class SavedByEntry
+public final class SavedByEntry
 {
   private String userName;
   private String saveLocation;
index b11b73fe191cc4c39db9ca7eddaed2b42fb25ba6..f7ffc81db8eba84c6a6566cfaeed411f2f74ac38 100644 (file)
@@ -15,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.model;
 
 import java.io.IOException;
@@ -31,10 +30,10 @@ import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 /**
  * String table containing the history of the last few revisions ("saves") of the document.
  * Read-only for the time being.
- * 
+ *
  * @author Daniel Noll
  */
-public class SavedByTable
+public final class SavedByTable
 {
   /**
    * A value that I don't know what it does, but is maintained for accuracy.
index 9c5bc08c11b4181030e9e7a31b47db2ba4a5aa11..d4a5ef238dd6376e6245fc3b265f33556aca3232 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.hwpf.model;
 
 import org.apache.poi.util.LittleEndian;
 
-public class SectionDescriptor
+public final class SectionDescriptor
 {
 
   private short fn;
index b88edbb95e285d5656c7afaaf5ce837c12c61ff5..2b15808c2978f72e61cbb343671c04a437b9d380 100644 (file)
@@ -27,7 +27,7 @@ import org.apache.poi.hwpf.model.io.*;
 /**
  * @author Ryan Ackley
  */
-public class SectionTable
+public final class SectionTable
 {
   private static final int SED_SIZE = 12;
 
@@ -60,7 +60,7 @@ public class SectionTable
       int fileOffset = sed.getFc();
       int startAt = CPtoFC(node.getStart());
       int endAt = CPtoFC(node.getEnd());
-      
+
       boolean isUnicodeAtStart = tpt.isUnicodeAtByteOffset( startAt );
 //      System.err.println(startAt + " -> " + endAt + " = " + isUnicodeAtStart);
 
@@ -79,7 +79,7 @@ public class SectionTable
         _sections.add(new SEPX(sed, startAt, endAt, buf, isUnicodeAtStart));
       }
     }
-    
+
     // Some files seem to lie about their unicode status, which
     //  is very very pesky. Try to work around these, but this
     //  is getting on for black magic...
@@ -99,7 +99,7 @@ public class SectionTable
         for(int i=0; i<_sections.size(); i++) {
                SEPX s = (SEPX)_sections.get(i);
             GenericPropertyNode node = sedPlex.getProperty(i);
-            
+
                s.setStart( CPtoFC(node.getStart()) );
                s.setEnd( CPtoFC(node.getEnd()) );
         }
index 998ea2d8fe9932b962f8785ed53ea03da8e3e4b1..426a24dfec3ff655d79bfc56024b6d0746371e0a 100644 (file)
@@ -22,7 +22,7 @@ import java.util.List;
 
 import org.apache.poi.hwpf.usermodel.Shape;
 
-public class ShapesTable {
+public final class ShapesTable {
         private List _shapes;
         private List _shapesVisibili;  //holds visible shapes
 
index 3f81953c99d6ab1b9d51d08c01feaf78e9d16eed..26e3ac43a3e0c2a0742e510a779ee597a40ffb2d 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model;
 
@@ -34,7 +31,7 @@ import org.apache.poi.util.BitFieldFactory;
  * @author Ryan Ackley
  */
 
-public class StyleDescription implements HDFType
+public final class StyleDescription implements HDFType
 {
 
   private final static int PARAGRAPH_STYLE = 1;
index b23533de34dbd3084edd577b6b32740de630131e..e8a161073989786166aa2a7467f4422ea59ccc67 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model;
 
@@ -39,7 +36,7 @@ import org.apache.poi.hwpf.sprm.CharacterSprmUncompressor;
  * @author Ryan Ackley
  */
 
-public class StyleSheet implements HDFType
+public final class StyleSheet implements HDFType
 {
 
   public static final int NIL_STYLE = 4095;
@@ -231,7 +228,7 @@ public class StyleSheet implements HDFType
           {
 
               parentPAP = _styleDescriptions[baseIndex].getPAP();
-              if(parentPAP == null) 
+              if(parentPAP == null)
               {
                  if(baseIndex == istd) {
                          // Oh dear, style claims that it is its own parent
index 57cd9099ee460c665cc8543d35c59d5f5ecfd4aa..d7bb2984b56c311420bc078c447992a249a9cc0e 100644 (file)
@@ -15,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.model;
 
 
@@ -29,7 +28,7 @@ import java.io.UnsupportedEncodingException;
  * @author Ryan Ackley
  */
 
-public class TextPiece extends PropertyNode implements Comparable
+public final class TextPiece extends PropertyNode implements Comparable
 {
   private boolean _usesUnicode;
 
@@ -44,7 +43,7 @@ public class TextPiece extends PropertyNode implements Comparable
          super(start, end, buildInitSB(text, pd));
          _usesUnicode = pd.isUnicode();
          _pd = pd;
-         
+
          // Validate
          int textLength = ((StringBuffer)_buf).length();
          if(end-start != textLength) {
@@ -54,7 +53,7 @@ public class TextPiece extends PropertyNode implements Comparable
                  throw new IllegalStateException("Told we're of negative size! start="+start + " end="+end);
          }
   }
-  
+
   /**
    * Create the StringBuffer from the text and unicode flag
    */
@@ -71,7 +70,7 @@ public class TextPiece extends PropertyNode implements Comparable
          }
          return new StringBuffer(str);
   }
-  
+
   /**
    * @return If this text piece is unicode
    */
@@ -101,7 +100,7 @@ public class TextPiece extends PropertyNode implements Comparable
    }
 
    /**
-    * Returns part of the string. 
+    * Returns part of the string.
     * Works only in characters, not in bytes!
     * @param start Local start position, in characters
     * @param end Local end position, in characters
@@ -109,7 +108,7 @@ public class TextPiece extends PropertyNode implements Comparable
    public String substring(int start, int end)
    {
           StringBuffer buf = (StringBuffer)_buf;
-          
+
           // Validate
           if(start < 0) {
                   throw new StringIndexOutOfBoundsException("Can't request a substring before 0 - asked for " + start);
index f13e6ecd177c9ebdb25fd8089bb148c274b07501..69e1f0ba797f2cd28abf1ba1061890f41e9ff636 100644 (file)
@@ -15,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.model;
 
 
@@ -38,7 +37,7 @@ import java.util.List;
  *  convertion.
  * @author Ryan Ackley
  */
-public class TextPieceTable
+public final class TextPieceTable
 {
   protected ArrayList _textPieces = new ArrayList();
   //int _multiple;
@@ -65,7 +64,7 @@ public class TextPieceTable
       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;
@@ -82,18 +81,18 @@ public class TextPieceTable
     {
       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;
@@ -105,7 +104,7 @@ public class TextPieceTable
       // 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[])
@@ -125,18 +124,18 @@ public class TextPieceTable
   {
     return _textPieces;
   }
-  
+
   /**
    * Is the text at the given Character offset
    *  unicode, or plain old ascii?
-   * In a very evil fashion, you have to actually 
+   * 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();
@@ -147,14 +146,14 @@ public class TextPieceTable
                  // Otherwise keep track for the last one
                  lastWas = tp.isUnicode();
          }
-         
+
          // If they ask off the end, just go with the last one...
          return lastWas;
   }
   /**
    * Is the text at the given byte offset
    *  unicode, or plain old ascii?
-   * In a very evil fashion, you have to actually 
+   * In a very evil fashion, you have to actually
    *  know this to make sense of character and
    *  paragraph properties :(
    * @param bytePos The character offset to check about
@@ -162,12 +161,12 @@ public class TextPieceTable
   public boolean isUnicodeAtByteOffset(int bytePos) {
          boolean lastWas = false;
          int curByte = 0;
-         
+
          Iterator it = _textPieces.iterator();
          while(it.hasNext()) {
                  TextPiece tp = (TextPiece)it.next();
                  int nextByte = curByte + tp.bytesLength();
-                 
+
                  // If the text piece covers the character, all good
                  if(curByte <= bytePos && nextByte >= bytePos) {
                          return tp.isUnicode();
@@ -177,7 +176,7 @@ public class TextPieceTable
                  // Move along
                  curByte = nextByte;
          }
-         
+
          // If they ask off the end, just go with the last one...
          return lastWas;
   }
@@ -234,10 +233,10 @@ public class TextPieceTable
     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++)
     {
@@ -245,7 +244,7 @@ public class TextPieceTable
       tp.setStart(tp.getStart() + length);
       tp.setEnd(tp.getEnd() + length);
     }
-    
+
     // All done
     return length;
   }
index 734577a26859edb23b2099e7105f5a190052e6b0..736d66ec87879b3604d7ec2b9af677a03ba7a5cd 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.hwpf.model;
 
 import java.util.Arrays;
 
-public class UPX
+public final class UPX
 {
   private byte[] _upx;
 
index b0bb5f72b091dd9ba6f3fe4f924c1bfe1be1335b..46989804a53af4bceec851ab3655f437090137fa 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.hwpf.model;
 
-public class UnhandledDataStructure
+public final class UnhandledDataStructure
 {
   byte[] _buf;
 
index c4721b840f0dd807264486082e0cc48c264da8c4..eb76f503c81a618fc3c2a208bd4b112440f92da7 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.hwpf.model.io;
 
 
 import java.util.HashMap;
 
-public class HWPFFileSystem
+public final class HWPFFileSystem
 {
   HashMap _streams = new HashMap();
 
index e9fab43ab6270f2b3925b368de7d624b174b449c..537576ff998051080074b62708d2fc6c1254c95c 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.hwpf.model.io;
 
 import java.io.ByteArrayOutputStream;
 
-public class HWPFOutputStream extends ByteArrayOutputStream
+public final class HWPFOutputStream extends ByteArrayOutputStream
 {
 
   int _offset;
index d0fc1236cf997e3e10d381ac3772796d2f714c4f..fad6c7e462507e31a6789577e6db4649095c356e 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model.types;
 
@@ -818,569 +815,569 @@ public abstract class CHPAbstractType
 
     /**
      * Sets the fBold field value.
-     * 
+     *
      */
     public void setFBold(boolean value)
     {
         field_2_format_flags = (int)fBold.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fBold field value.
      */
     public boolean isFBold()
     {
         return fBold.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fItalic field value.
-     * 
+     *
      */
     public void setFItalic(boolean value)
     {
         field_2_format_flags = (int)fItalic.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fItalic field value.
      */
     public boolean isFItalic()
     {
         return fItalic.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fRMarkDel field value.
-     * 
+     *
      */
     public void setFRMarkDel(boolean value)
     {
         field_2_format_flags = (int)fRMarkDel.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fRMarkDel field value.
      */
     public boolean isFRMarkDel()
     {
         return fRMarkDel.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fOutline field value.
-     * 
+     *
      */
     public void setFOutline(boolean value)
     {
         field_2_format_flags = (int)fOutline.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fOutline field value.
      */
     public boolean isFOutline()
     {
         return fOutline.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fFldVanish field value.
-     * 
+     *
      */
     public void setFFldVanish(boolean value)
     {
         field_2_format_flags = (int)fFldVanish.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fFldVanish field value.
      */
     public boolean isFFldVanish()
     {
         return fFldVanish.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fSmallCaps field value.
-     * 
+     *
      */
     public void setFSmallCaps(boolean value)
     {
         field_2_format_flags = (int)fSmallCaps.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fSmallCaps field value.
      */
     public boolean isFSmallCaps()
     {
         return fSmallCaps.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fCaps field value.
-     * 
+     *
      */
     public void setFCaps(boolean value)
     {
         field_2_format_flags = (int)fCaps.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fCaps field value.
      */
     public boolean isFCaps()
     {
         return fCaps.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fVanish field value.
-     * 
+     *
      */
     public void setFVanish(boolean value)
     {
         field_2_format_flags = (int)fVanish.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fVanish field value.
      */
     public boolean isFVanish()
     {
         return fVanish.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fRMark field value.
-     * 
+     *
      */
     public void setFRMark(boolean value)
     {
         field_2_format_flags = (int)fRMark.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fRMark field value.
      */
     public boolean isFRMark()
     {
         return fRMark.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fSpec field value.
-     * 
+     *
      */
     public void setFSpec(boolean value)
     {
         field_2_format_flags = (int)fSpec.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fSpec field value.
      */
     public boolean isFSpec()
     {
         return fSpec.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fStrike field value.
-     * 
+     *
      */
     public void setFStrike(boolean value)
     {
         field_2_format_flags = (int)fStrike.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fStrike field value.
      */
     public boolean isFStrike()
     {
         return fStrike.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fObj field value.
-     * 
+     *
      */
     public void setFObj(boolean value)
     {
         field_2_format_flags = (int)fObj.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fObj field value.
      */
     public boolean isFObj()
     {
         return fObj.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fShadow field value.
-     * 
+     *
      */
     public void setFShadow(boolean value)
     {
         field_2_format_flags = (int)fShadow.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fShadow field value.
      */
     public boolean isFShadow()
     {
         return fShadow.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fLowerCase field value.
-     * 
+     *
      */
     public void setFLowerCase(boolean value)
     {
         field_2_format_flags = (int)fLowerCase.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fLowerCase field value.
      */
     public boolean isFLowerCase()
     {
         return fLowerCase.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fData field value.
-     * 
+     *
      */
     public void setFData(boolean value)
     {
         field_2_format_flags = (int)fData.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fData field value.
      */
     public boolean isFData()
     {
         return fData.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fOle2 field value.
-     * 
+     *
      */
     public void setFOle2(boolean value)
     {
         field_2_format_flags = (int)fOle2.setBoolean(field_2_format_flags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fOle2 field value.
      */
     public boolean isFOle2()
     {
         return fOle2.isSet(field_2_format_flags);
-        
+
     }
 
     /**
      * Sets the fEmboss field value.
-     * 
+     *
      */
     public void setFEmboss(boolean value)
     {
         field_3_format_flags1 = (int)fEmboss.setBoolean(field_3_format_flags1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fEmboss field value.
      */
     public boolean isFEmboss()
     {
         return fEmboss.isSet(field_3_format_flags1);
-        
+
     }
 
     /**
      * Sets the fImprint field value.
-     * 
+     *
      */
     public void setFImprint(boolean value)
     {
         field_3_format_flags1 = (int)fImprint.setBoolean(field_3_format_flags1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fImprint field value.
      */
     public boolean isFImprint()
     {
         return fImprint.isSet(field_3_format_flags1);
-        
+
     }
 
     /**
      * Sets the fDStrike field value.
-     * 
+     *
      */
     public void setFDStrike(boolean value)
     {
         field_3_format_flags1 = (int)fDStrike.setBoolean(field_3_format_flags1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fDStrike field value.
      */
     public boolean isFDStrike()
     {
         return fDStrike.isSet(field_3_format_flags1);
-        
+
     }
 
     /**
      * Sets the fUsePgsuSettings field value.
-     * 
+     *
      */
     public void setFUsePgsuSettings(boolean value)
     {
         field_3_format_flags1 = (int)fUsePgsuSettings.setBoolean(field_3_format_flags1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fUsePgsuSettings field value.
      */
     public boolean isFUsePgsuSettings()
     {
         return fUsePgsuSettings.isSet(field_3_format_flags1);
-        
+
     }
 
     /**
      * Sets the icoHighlight field value.
-     * 
+     *
      */
     public void setIcoHighlight(byte value)
     {
         field_33_Highlight = (short)icoHighlight.setValue(field_33_Highlight, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the icoHighlight field value.
      */
     public byte getIcoHighlight()
     {
         return ( byte )icoHighlight.getValue(field_33_Highlight);
-        
+
     }
 
     /**
      * Sets the fHighlight field value.
-     * 
+     *
      */
     public void setFHighlight(boolean value)
     {
         field_33_Highlight = (short)fHighlight.setBoolean(field_33_Highlight, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fHighlight field value.
      */
     public boolean isFHighlight()
     {
         return fHighlight.isSet(field_33_Highlight);
-        
+
     }
 
     /**
      * Sets the kcd field value.
-     * 
+     *
      */
     public void setKcd(byte value)
     {
         field_33_Highlight = (short)kcd.setValue(field_33_Highlight, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the kcd field value.
      */
     public byte getKcd()
     {
         return ( byte )kcd.getValue(field_33_Highlight);
-        
+
     }
 
     /**
      * Sets the fNavHighlight field value.
-     * 
+     *
      */
     public void setFNavHighlight(boolean value)
     {
         field_33_Highlight = (short)fNavHighlight.setBoolean(field_33_Highlight, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fNavHighlight field value.
      */
     public boolean isFNavHighlight()
     {
         return fNavHighlight.isSet(field_33_Highlight);
-        
+
     }
 
     /**
      * Sets the fChsDiff field value.
-     * 
+     *
      */
     public void setFChsDiff(boolean value)
     {
         field_33_Highlight = (short)fChsDiff.setBoolean(field_33_Highlight, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fChsDiff field value.
      */
     public boolean isFChsDiff()
     {
         return fChsDiff.isSet(field_33_Highlight);
-        
+
     }
 
     /**
      * Sets the fMacChs field value.
-     * 
+     *
      */
     public void setFMacChs(boolean value)
     {
         field_33_Highlight = (short)fMacChs.setBoolean(field_33_Highlight, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fMacChs field value.
      */
     public boolean isFMacChs()
     {
         return fMacChs.isSet(field_33_Highlight);
-        
+
     }
 
     /**
      * Sets the fFtcAsciSym field value.
-     * 
+     *
      */
     public void setFFtcAsciSym(boolean value)
     {
         field_33_Highlight = (short)fFtcAsciSym.setBoolean(field_33_Highlight, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fFtcAsciSym field value.
      */
     public boolean isFFtcAsciSym()
     {
         return fFtcAsciSym.isSet(field_33_Highlight);
-        
+
     }
 
 
index 9441f8bb85fbefdccd1f4dc3188ea6a74d1808d0..9f7b04c95a80db7581edb40583cb0c156f2f4d96 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model.types;
 
@@ -1430,1934 +1427,1934 @@ public abstract class DOPAbstractType
 
     /**
      * Sets the fFacingPages field value.
-     * 
+     *
      */
     public void setFFacingPages(boolean value)
     {
         field_1_formatFlags = (byte)fFacingPages.setBoolean(field_1_formatFlags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fFacingPages field value.
      */
     public boolean isFFacingPages()
     {
         return fFacingPages.isSet(field_1_formatFlags);
-        
+
     }
 
     /**
      * Sets the fWidowControl field value.
-     * 
+     *
      */
     public void setFWidowControl(boolean value)
     {
         field_1_formatFlags = (byte)fWidowControl.setBoolean(field_1_formatFlags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fWidowControl field value.
      */
     public boolean isFWidowControl()
     {
         return fWidowControl.isSet(field_1_formatFlags);
-        
+
     }
 
     /**
      * Sets the fPMHMainDoc field value.
-     * 
+     *
      */
     public void setFPMHMainDoc(boolean value)
     {
         field_1_formatFlags = (byte)fPMHMainDoc.setBoolean(field_1_formatFlags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fPMHMainDoc field value.
      */
     public boolean isFPMHMainDoc()
     {
         return fPMHMainDoc.isSet(field_1_formatFlags);
-        
+
     }
 
     /**
      * Sets the grfSupression field value.
-     * 
+     *
      */
     public void setGrfSupression(byte value)
     {
         field_1_formatFlags = (byte)grfSupression.setValue(field_1_formatFlags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the grfSupression field value.
      */
     public byte getGrfSupression()
     {
         return ( byte )grfSupression.getValue(field_1_formatFlags);
-        
+
     }
 
     /**
      * Sets the fpc field value.
-     * 
+     *
      */
     public void setFpc(byte value)
     {
         field_1_formatFlags = (byte)fpc.setValue(field_1_formatFlags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fpc field value.
      */
     public byte getFpc()
     {
         return ( byte )fpc.getValue(field_1_formatFlags);
-        
+
     }
 
     /**
      * Sets the unused1 field value.
-     * 
+     *
      */
     public void setUnused1(boolean value)
     {
         field_1_formatFlags = (byte)unused1.setBoolean(field_1_formatFlags, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the unused1 field value.
      */
     public boolean isUnused1()
     {
         return unused1.isSet(field_1_formatFlags);
-        
+
     }
 
     /**
      * Sets the rncFtn field value.
-     * 
+     *
      */
     public void setRncFtn(byte value)
     {
         field_3_footnoteInfo = (short)rncFtn.setValue(field_3_footnoteInfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the rncFtn field value.
      */
     public byte getRncFtn()
     {
         return ( byte )rncFtn.getValue(field_3_footnoteInfo);
-        
+
     }
 
     /**
      * Sets the nFtn field value.
-     * 
+     *
      */
     public void setNFtn(short value)
     {
         field_3_footnoteInfo = (short)nFtn.setValue(field_3_footnoteInfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the nFtn field value.
      */
     public short getNFtn()
     {
         return ( short )nFtn.getValue(field_3_footnoteInfo);
-        
+
     }
 
     /**
      * Sets the fOnlyMacPics field value.
-     * 
+     *
      */
     public void setFOnlyMacPics(boolean value)
     {
         field_5_docinfo = (byte)fOnlyMacPics.setBoolean(field_5_docinfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fOnlyMacPics field value.
      */
     public boolean isFOnlyMacPics()
     {
         return fOnlyMacPics.isSet(field_5_docinfo);
-        
+
     }
 
     /**
      * Sets the fOnlyWinPics field value.
-     * 
+     *
      */
     public void setFOnlyWinPics(boolean value)
     {
         field_5_docinfo = (byte)fOnlyWinPics.setBoolean(field_5_docinfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fOnlyWinPics field value.
      */
     public boolean isFOnlyWinPics()
     {
         return fOnlyWinPics.isSet(field_5_docinfo);
-        
+
     }
 
     /**
      * Sets the fLabelDoc field value.
-     * 
+     *
      */
     public void setFLabelDoc(boolean value)
     {
         field_5_docinfo = (byte)fLabelDoc.setBoolean(field_5_docinfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fLabelDoc field value.
      */
     public boolean isFLabelDoc()
     {
         return fLabelDoc.isSet(field_5_docinfo);
-        
+
     }
 
     /**
      * Sets the fHyphCapitals field value.
-     * 
+     *
      */
     public void setFHyphCapitals(boolean value)
     {
         field_5_docinfo = (byte)fHyphCapitals.setBoolean(field_5_docinfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fHyphCapitals field value.
      */
     public boolean isFHyphCapitals()
     {
         return fHyphCapitals.isSet(field_5_docinfo);
-        
+
     }
 
     /**
      * Sets the fAutoHyphen field value.
-     * 
+     *
      */
     public void setFAutoHyphen(boolean value)
     {
         field_5_docinfo = (byte)fAutoHyphen.setBoolean(field_5_docinfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fAutoHyphen field value.
      */
     public boolean isFAutoHyphen()
     {
         return fAutoHyphen.isSet(field_5_docinfo);
-        
+
     }
 
     /**
      * Sets the fFormNoFields field value.
-     * 
+     *
      */
     public void setFFormNoFields(boolean value)
     {
         field_5_docinfo = (byte)fFormNoFields.setBoolean(field_5_docinfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fFormNoFields field value.
      */
     public boolean isFFormNoFields()
     {
         return fFormNoFields.isSet(field_5_docinfo);
-        
+
     }
 
     /**
      * Sets the fLinkStyles field value.
-     * 
+     *
      */
     public void setFLinkStyles(boolean value)
     {
         field_5_docinfo = (byte)fLinkStyles.setBoolean(field_5_docinfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fLinkStyles field value.
      */
     public boolean isFLinkStyles()
     {
         return fLinkStyles.isSet(field_5_docinfo);
-        
+
     }
 
     /**
      * Sets the fRevMarking field value.
-     * 
+     *
      */
     public void setFRevMarking(boolean value)
     {
         field_5_docinfo = (byte)fRevMarking.setBoolean(field_5_docinfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fRevMarking field value.
      */
     public boolean isFRevMarking()
     {
         return fRevMarking.isSet(field_5_docinfo);
-        
+
     }
 
     /**
      * Sets the fBackup field value.
-     * 
+     *
      */
     public void setFBackup(boolean value)
     {
         field_6_docinfo1 = (byte)fBackup.setBoolean(field_6_docinfo1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fBackup field value.
      */
     public boolean isFBackup()
     {
         return fBackup.isSet(field_6_docinfo1);
-        
+
     }
 
     /**
      * Sets the fExactCWords field value.
-     * 
+     *
      */
     public void setFExactCWords(boolean value)
     {
         field_6_docinfo1 = (byte)fExactCWords.setBoolean(field_6_docinfo1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fExactCWords field value.
      */
     public boolean isFExactCWords()
     {
         return fExactCWords.isSet(field_6_docinfo1);
-        
+
     }
 
     /**
      * Sets the fPagHidden field value.
-     * 
+     *
      */
     public void setFPagHidden(boolean value)
     {
         field_6_docinfo1 = (byte)fPagHidden.setBoolean(field_6_docinfo1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fPagHidden field value.
      */
     public boolean isFPagHidden()
     {
         return fPagHidden.isSet(field_6_docinfo1);
-        
+
     }
 
     /**
      * Sets the fPagResults field value.
-     * 
+     *
      */
     public void setFPagResults(boolean value)
     {
         field_6_docinfo1 = (byte)fPagResults.setBoolean(field_6_docinfo1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fPagResults field value.
      */
     public boolean isFPagResults()
     {
         return fPagResults.isSet(field_6_docinfo1);
-        
+
     }
 
     /**
      * Sets the fLockAtn field value.
-     * 
+     *
      */
     public void setFLockAtn(boolean value)
     {
         field_6_docinfo1 = (byte)fLockAtn.setBoolean(field_6_docinfo1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fLockAtn field value.
      */
     public boolean isFLockAtn()
     {
         return fLockAtn.isSet(field_6_docinfo1);
-        
+
     }
 
     /**
      * Sets the fMirrorMargins field value.
-     * 
+     *
      */
     public void setFMirrorMargins(boolean value)
     {
         field_6_docinfo1 = (byte)fMirrorMargins.setBoolean(field_6_docinfo1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fMirrorMargins field value.
      */
     public boolean isFMirrorMargins()
     {
         return fMirrorMargins.isSet(field_6_docinfo1);
-        
+
     }
 
     /**
      * Sets the unused3 field value.
-     * 
+     *
      */
     public void setUnused3(boolean value)
     {
         field_6_docinfo1 = (byte)unused3.setBoolean(field_6_docinfo1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the unused3 field value.
      */
     public boolean isUnused3()
     {
         return unused3.isSet(field_6_docinfo1);
-        
+
     }
 
     /**
      * Sets the fDfltTrueType field value.
-     * 
+     *
      */
     public void setFDfltTrueType(boolean value)
     {
         field_6_docinfo1 = (byte)fDfltTrueType.setBoolean(field_6_docinfo1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fDfltTrueType field value.
      */
     public boolean isFDfltTrueType()
     {
         return fDfltTrueType.isSet(field_6_docinfo1);
-        
+
     }
 
     /**
      * Sets the fPagSupressTopSpacing field value.
-     * 
+     *
      */
     public void setFPagSupressTopSpacing(boolean value)
     {
         field_7_docinfo2 = (byte)fPagSupressTopSpacing.setBoolean(field_7_docinfo2, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fPagSupressTopSpacing field value.
      */
     public boolean isFPagSupressTopSpacing()
     {
         return fPagSupressTopSpacing.isSet(field_7_docinfo2);
-        
+
     }
 
     /**
      * Sets the fProtEnabled field value.
-     * 
+     *
      */
     public void setFProtEnabled(boolean value)
     {
         field_7_docinfo2 = (byte)fProtEnabled.setBoolean(field_7_docinfo2, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fProtEnabled field value.
      */
     public boolean isFProtEnabled()
     {
         return fProtEnabled.isSet(field_7_docinfo2);
-        
+
     }
 
     /**
      * Sets the fDispFormFldSel field value.
-     * 
+     *
      */
     public void setFDispFormFldSel(boolean value)
     {
         field_7_docinfo2 = (byte)fDispFormFldSel.setBoolean(field_7_docinfo2, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fDispFormFldSel field value.
      */
     public boolean isFDispFormFldSel()
     {
         return fDispFormFldSel.isSet(field_7_docinfo2);
-        
+
     }
 
     /**
      * Sets the fRMView field value.
-     * 
+     *
      */
     public void setFRMView(boolean value)
     {
         field_7_docinfo2 = (byte)fRMView.setBoolean(field_7_docinfo2, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fRMView field value.
      */
     public boolean isFRMView()
     {
         return fRMView.isSet(field_7_docinfo2);
-        
+
     }
 
     /**
      * Sets the fRMPrint field value.
-     * 
+     *
      */
     public void setFRMPrint(boolean value)
     {
         field_7_docinfo2 = (byte)fRMPrint.setBoolean(field_7_docinfo2, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fRMPrint field value.
      */
     public boolean isFRMPrint()
     {
         return fRMPrint.isSet(field_7_docinfo2);
-        
+
     }
 
     /**
      * Sets the unused4 field value.
-     * 
+     *
      */
     public void setUnused4(boolean value)
     {
         field_7_docinfo2 = (byte)unused4.setBoolean(field_7_docinfo2, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the unused4 field value.
      */
     public boolean isUnused4()
     {
         return unused4.isSet(field_7_docinfo2);
-        
+
     }
 
     /**
      * Sets the fLockRev field value.
-     * 
+     *
      */
     public void setFLockRev(boolean value)
     {
         field_7_docinfo2 = (byte)fLockRev.setBoolean(field_7_docinfo2, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fLockRev field value.
      */
     public boolean isFLockRev()
     {
         return fLockRev.isSet(field_7_docinfo2);
-        
+
     }
 
     /**
      * Sets the fEmbedFonts field value.
-     * 
+     *
      */
     public void setFEmbedFonts(boolean value)
     {
         field_7_docinfo2 = (byte)fEmbedFonts.setBoolean(field_7_docinfo2, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fEmbedFonts field value.
      */
     public boolean isFEmbedFonts()
     {
         return fEmbedFonts.isSet(field_7_docinfo2);
-        
+
     }
 
     /**
      * Sets the oldfNoTabForInd field value.
-     * 
+     *
      */
     public void setOldfNoTabForInd(boolean value)
     {
         field_8_docinfo3 = (short)oldfNoTabForInd.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfNoTabForInd field value.
      */
     public boolean isOldfNoTabForInd()
     {
         return oldfNoTabForInd.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the oldfNoSpaceRaiseLower field value.
-     * 
+     *
      */
     public void setOldfNoSpaceRaiseLower(boolean value)
     {
         field_8_docinfo3 = (short)oldfNoSpaceRaiseLower.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfNoSpaceRaiseLower field value.
      */
     public boolean isOldfNoSpaceRaiseLower()
     {
         return oldfNoSpaceRaiseLower.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the oldfSuppressSpbfAfterPageBreak field value.
-     * 
+     *
      */
     public void setOldfSuppressSpbfAfterPageBreak(boolean value)
     {
         field_8_docinfo3 = (short)oldfSuppressSpbfAfterPageBreak.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfSuppressSpbfAfterPageBreak field value.
      */
     public boolean isOldfSuppressSpbfAfterPageBreak()
     {
         return oldfSuppressSpbfAfterPageBreak.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the oldfWrapTrailSpaces field value.
-     * 
+     *
      */
     public void setOldfWrapTrailSpaces(boolean value)
     {
         field_8_docinfo3 = (short)oldfWrapTrailSpaces.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfWrapTrailSpaces field value.
      */
     public boolean isOldfWrapTrailSpaces()
     {
         return oldfWrapTrailSpaces.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the oldfMapPrintTextColor field value.
-     * 
+     *
      */
     public void setOldfMapPrintTextColor(boolean value)
     {
         field_8_docinfo3 = (short)oldfMapPrintTextColor.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfMapPrintTextColor field value.
      */
     public boolean isOldfMapPrintTextColor()
     {
         return oldfMapPrintTextColor.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the oldfNoColumnBalance field value.
-     * 
+     *
      */
     public void setOldfNoColumnBalance(boolean value)
     {
         field_8_docinfo3 = (short)oldfNoColumnBalance.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfNoColumnBalance field value.
      */
     public boolean isOldfNoColumnBalance()
     {
         return oldfNoColumnBalance.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the oldfConvMailMergeEsc field value.
-     * 
+     *
      */
     public void setOldfConvMailMergeEsc(boolean value)
     {
         field_8_docinfo3 = (short)oldfConvMailMergeEsc.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfConvMailMergeEsc field value.
      */
     public boolean isOldfConvMailMergeEsc()
     {
         return oldfConvMailMergeEsc.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the oldfSupressTopSpacing field value.
-     * 
+     *
      */
     public void setOldfSupressTopSpacing(boolean value)
     {
         field_8_docinfo3 = (short)oldfSupressTopSpacing.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfSupressTopSpacing field value.
      */
     public boolean isOldfSupressTopSpacing()
     {
         return oldfSupressTopSpacing.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the oldfOrigWordTableRules field value.
-     * 
+     *
      */
     public void setOldfOrigWordTableRules(boolean value)
     {
         field_8_docinfo3 = (short)oldfOrigWordTableRules.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfOrigWordTableRules field value.
      */
     public boolean isOldfOrigWordTableRules()
     {
         return oldfOrigWordTableRules.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the oldfTransparentMetafiles field value.
-     * 
+     *
      */
     public void setOldfTransparentMetafiles(boolean value)
     {
         field_8_docinfo3 = (short)oldfTransparentMetafiles.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfTransparentMetafiles field value.
      */
     public boolean isOldfTransparentMetafiles()
     {
         return oldfTransparentMetafiles.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the oldfShowBreaksInFrames field value.
-     * 
+     *
      */
     public void setOldfShowBreaksInFrames(boolean value)
     {
         field_8_docinfo3 = (short)oldfShowBreaksInFrames.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfShowBreaksInFrames field value.
      */
     public boolean isOldfShowBreaksInFrames()
     {
         return oldfShowBreaksInFrames.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the oldfSwapBordersFacingPgs field value.
-     * 
+     *
      */
     public void setOldfSwapBordersFacingPgs(boolean value)
     {
         field_8_docinfo3 = (short)oldfSwapBordersFacingPgs.setBoolean(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the oldfSwapBordersFacingPgs field value.
      */
     public boolean isOldfSwapBordersFacingPgs()
     {
         return oldfSwapBordersFacingPgs.isSet(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the unused5 field value.
-     * 
+     *
      */
     public void setUnused5(byte value)
     {
         field_8_docinfo3 = (short)unused5.setValue(field_8_docinfo3, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the unused5 field value.
      */
     public byte getUnused5()
     {
         return ( byte )unused5.getValue(field_8_docinfo3);
-        
+
     }
 
     /**
      * Sets the rncEdn field value.
-     * 
+     *
      */
     public void setRncEdn(byte value)
     {
         field_23_Edn = (short)rncEdn.setValue(field_23_Edn, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the rncEdn field value.
      */
     public byte getRncEdn()
     {
         return ( byte )rncEdn.getValue(field_23_Edn);
-        
+
     }
 
     /**
      * Sets the nEdn field value.
-     * 
+     *
      */
     public void setNEdn(short value)
     {
         field_23_Edn = (short)nEdn.setValue(field_23_Edn, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the nEdn field value.
      */
     public short getNEdn()
     {
         return ( short )nEdn.getValue(field_23_Edn);
-        
+
     }
 
     /**
      * Sets the epc field value.
-     * 
+     *
      */
     public void setEpc(byte value)
     {
         field_24_Edn1 = (short)epc.setValue(field_24_Edn1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the epc field value.
      */
     public byte getEpc()
     {
         return ( byte )epc.getValue(field_24_Edn1);
-        
+
     }
 
     /**
      * Sets the nfcFtnRef1 field value.
-     * 
+     *
      */
     public void setNfcFtnRef1(byte value)
     {
         field_24_Edn1 = (short)nfcFtnRef1.setValue(field_24_Edn1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the nfcFtnRef1 field value.
      */
     public byte getNfcFtnRef1()
     {
         return ( byte )nfcFtnRef1.getValue(field_24_Edn1);
-        
+
     }
 
     /**
      * Sets the nfcEdnRef1 field value.
-     * 
+     *
      */
     public void setNfcEdnRef1(byte value)
     {
         field_24_Edn1 = (short)nfcEdnRef1.setValue(field_24_Edn1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the nfcEdnRef1 field value.
      */
     public byte getNfcEdnRef1()
     {
         return ( byte )nfcEdnRef1.getValue(field_24_Edn1);
-        
+
     }
 
     /**
      * Sets the fPrintFormData field value.
-     * 
+     *
      */
     public void setFPrintFormData(boolean value)
     {
         field_24_Edn1 = (short)fPrintFormData.setBoolean(field_24_Edn1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fPrintFormData field value.
      */
     public boolean isFPrintFormData()
     {
         return fPrintFormData.isSet(field_24_Edn1);
-        
+
     }
 
     /**
      * Sets the fSaveFormData field value.
-     * 
+     *
      */
     public void setFSaveFormData(boolean value)
     {
         field_24_Edn1 = (short)fSaveFormData.setBoolean(field_24_Edn1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fSaveFormData field value.
      */
     public boolean isFSaveFormData()
     {
         return fSaveFormData.isSet(field_24_Edn1);
-        
+
     }
 
     /**
      * Sets the fShadeFormData field value.
-     * 
+     *
      */
     public void setFShadeFormData(boolean value)
     {
         field_24_Edn1 = (short)fShadeFormData.setBoolean(field_24_Edn1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fShadeFormData field value.
      */
     public boolean isFShadeFormData()
     {
         return fShadeFormData.isSet(field_24_Edn1);
-        
+
     }
 
     /**
      * Sets the fWCFtnEdn field value.
-     * 
+     *
      */
     public void setFWCFtnEdn(boolean value)
     {
         field_24_Edn1 = (short)fWCFtnEdn.setBoolean(field_24_Edn1, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fWCFtnEdn field value.
      */
     public boolean isFWCFtnEdn()
     {
         return fWCFtnEdn.isSet(field_24_Edn1);
-        
+
     }
 
     /**
      * Sets the wvkSaved field value.
-     * 
+     *
      */
     public void setWvkSaved(byte value)
     {
         field_32_view = (short)wvkSaved.setValue(field_32_view, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the wvkSaved field value.
      */
     public byte getWvkSaved()
     {
         return ( byte )wvkSaved.getValue(field_32_view);
-        
+
     }
 
     /**
      * Sets the wScaleSaved field value.
-     * 
+     *
      */
     public void setWScaleSaved(short value)
     {
         field_32_view = (short)wScaleSaved.setValue(field_32_view, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the wScaleSaved field value.
      */
     public short getWScaleSaved()
     {
         return ( short )wScaleSaved.getValue(field_32_view);
-        
+
     }
 
     /**
      * Sets the zkSaved field value.
-     * 
+     *
      */
     public void setZkSaved(byte value)
     {
         field_32_view = (short)zkSaved.setValue(field_32_view, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the zkSaved field value.
      */
     public byte getZkSaved()
     {
         return ( byte )zkSaved.getValue(field_32_view);
-        
+
     }
 
     /**
      * Sets the fRotateFontW6 field value.
-     * 
+     *
      */
     public void setFRotateFontW6(boolean value)
     {
         field_32_view = (short)fRotateFontW6.setBoolean(field_32_view, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fRotateFontW6 field value.
      */
     public boolean isFRotateFontW6()
     {
         return fRotateFontW6.isSet(field_32_view);
-        
+
     }
 
     /**
      * Sets the iGutterPos field value.
-     * 
+     *
      */
     public void setIGutterPos(boolean value)
     {
         field_32_view = (short)iGutterPos.setBoolean(field_32_view, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the iGutterPos field value.
      */
     public boolean isIGutterPos()
     {
         return iGutterPos.isSet(field_32_view);
-        
+
     }
 
     /**
      * Sets the fNoTabForInd field value.
-     * 
+     *
      */
     public void setFNoTabForInd(boolean value)
     {
         field_33_docinfo4 = (int)fNoTabForInd.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fNoTabForInd field value.
      */
     public boolean isFNoTabForInd()
     {
         return fNoTabForInd.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fNoSpaceRaiseLower field value.
-     * 
+     *
      */
     public void setFNoSpaceRaiseLower(boolean value)
     {
         field_33_docinfo4 = (int)fNoSpaceRaiseLower.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fNoSpaceRaiseLower field value.
      */
     public boolean isFNoSpaceRaiseLower()
     {
         return fNoSpaceRaiseLower.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fSupressSpdfAfterPageBreak field value.
-     * 
+     *
      */
     public void setFSupressSpdfAfterPageBreak(boolean value)
     {
         field_33_docinfo4 = (int)fSupressSpdfAfterPageBreak.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fSupressSpdfAfterPageBreak field value.
      */
     public boolean isFSupressSpdfAfterPageBreak()
     {
         return fSupressSpdfAfterPageBreak.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fWrapTrailSpaces field value.
-     * 
+     *
      */
     public void setFWrapTrailSpaces(boolean value)
     {
         field_33_docinfo4 = (int)fWrapTrailSpaces.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fWrapTrailSpaces field value.
      */
     public boolean isFWrapTrailSpaces()
     {
         return fWrapTrailSpaces.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fMapPrintTextColor field value.
-     * 
+     *
      */
     public void setFMapPrintTextColor(boolean value)
     {
         field_33_docinfo4 = (int)fMapPrintTextColor.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fMapPrintTextColor field value.
      */
     public boolean isFMapPrintTextColor()
     {
         return fMapPrintTextColor.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fNoColumnBalance field value.
-     * 
+     *
      */
     public void setFNoColumnBalance(boolean value)
     {
         field_33_docinfo4 = (int)fNoColumnBalance.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fNoColumnBalance field value.
      */
     public boolean isFNoColumnBalance()
     {
         return fNoColumnBalance.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fConvMailMergeEsc field value.
-     * 
+     *
      */
     public void setFConvMailMergeEsc(boolean value)
     {
         field_33_docinfo4 = (int)fConvMailMergeEsc.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fConvMailMergeEsc field value.
      */
     public boolean isFConvMailMergeEsc()
     {
         return fConvMailMergeEsc.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fSupressTopSpacing field value.
-     * 
+     *
      */
     public void setFSupressTopSpacing(boolean value)
     {
         field_33_docinfo4 = (int)fSupressTopSpacing.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fSupressTopSpacing field value.
      */
     public boolean isFSupressTopSpacing()
     {
         return fSupressTopSpacing.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fOrigWordTableRules field value.
-     * 
+     *
      */
     public void setFOrigWordTableRules(boolean value)
     {
         field_33_docinfo4 = (int)fOrigWordTableRules.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fOrigWordTableRules field value.
      */
     public boolean isFOrigWordTableRules()
     {
         return fOrigWordTableRules.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fTransparentMetafiles field value.
-     * 
+     *
      */
     public void setFTransparentMetafiles(boolean value)
     {
         field_33_docinfo4 = (int)fTransparentMetafiles.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fTransparentMetafiles field value.
      */
     public boolean isFTransparentMetafiles()
     {
         return fTransparentMetafiles.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fShowBreaksInFrames field value.
-     * 
+     *
      */
     public void setFShowBreaksInFrames(boolean value)
     {
         field_33_docinfo4 = (int)fShowBreaksInFrames.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fShowBreaksInFrames field value.
      */
     public boolean isFShowBreaksInFrames()
     {
         return fShowBreaksInFrames.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fSwapBordersFacingPgs field value.
-     * 
+     *
      */
     public void setFSwapBordersFacingPgs(boolean value)
     {
         field_33_docinfo4 = (int)fSwapBordersFacingPgs.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fSwapBordersFacingPgs field value.
      */
     public boolean isFSwapBordersFacingPgs()
     {
         return fSwapBordersFacingPgs.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fSuppressTopSPacingMac5 field value.
-     * 
+     *
      */
     public void setFSuppressTopSPacingMac5(boolean value)
     {
         field_33_docinfo4 = (int)fSuppressTopSPacingMac5.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fSuppressTopSPacingMac5 field value.
      */
     public boolean isFSuppressTopSPacingMac5()
     {
         return fSuppressTopSPacingMac5.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fTruncDxaExpand field value.
-     * 
+     *
      */
     public void setFTruncDxaExpand(boolean value)
     {
         field_33_docinfo4 = (int)fTruncDxaExpand.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fTruncDxaExpand field value.
      */
     public boolean isFTruncDxaExpand()
     {
         return fTruncDxaExpand.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fPrintBodyBeforeHdr field value.
-     * 
+     *
      */
     public void setFPrintBodyBeforeHdr(boolean value)
     {
         field_33_docinfo4 = (int)fPrintBodyBeforeHdr.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fPrintBodyBeforeHdr field value.
      */
     public boolean isFPrintBodyBeforeHdr()
     {
         return fPrintBodyBeforeHdr.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fNoLeading field value.
-     * 
+     *
      */
     public void setFNoLeading(boolean value)
     {
         field_33_docinfo4 = (int)fNoLeading.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fNoLeading field value.
      */
     public boolean isFNoLeading()
     {
         return fNoLeading.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the fMWSmallCaps field value.
-     * 
+     *
      */
     public void setFMWSmallCaps(boolean value)
     {
         field_33_docinfo4 = (int)fMWSmallCaps.setBoolean(field_33_docinfo4, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fMWSmallCaps field value.
      */
     public boolean isFMWSmallCaps()
     {
         return fMWSmallCaps.isSet(field_33_docinfo4);
-        
+
     }
 
     /**
      * Sets the lvl field value.
-     * 
+     *
      */
     public void setLvl(byte value)
     {
         field_37_docinfo5 = (short)lvl.setValue(field_37_docinfo5, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the lvl field value.
      */
     public byte getLvl()
     {
         return ( byte )lvl.getValue(field_37_docinfo5);
-        
+
     }
 
     /**
      * Sets the fGramAllDone field value.
-     * 
+     *
      */
     public void setFGramAllDone(boolean value)
     {
         field_37_docinfo5 = (short)fGramAllDone.setBoolean(field_37_docinfo5, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fGramAllDone field value.
      */
     public boolean isFGramAllDone()
     {
         return fGramAllDone.isSet(field_37_docinfo5);
-        
+
     }
 
     /**
      * Sets the fGramAllClean field value.
-     * 
+     *
      */
     public void setFGramAllClean(boolean value)
     {
         field_37_docinfo5 = (short)fGramAllClean.setBoolean(field_37_docinfo5, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fGramAllClean field value.
      */
     public boolean isFGramAllClean()
     {
         return fGramAllClean.isSet(field_37_docinfo5);
-        
+
     }
 
     /**
      * Sets the fSubsetFonts field value.
-     * 
+     *
      */
     public void setFSubsetFonts(boolean value)
     {
         field_37_docinfo5 = (short)fSubsetFonts.setBoolean(field_37_docinfo5, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fSubsetFonts field value.
      */
     public boolean isFSubsetFonts()
     {
         return fSubsetFonts.isSet(field_37_docinfo5);
-        
+
     }
 
     /**
      * Sets the fHideLastVersion field value.
-     * 
+     *
      */
     public void setFHideLastVersion(boolean value)
     {
         field_37_docinfo5 = (short)fHideLastVersion.setBoolean(field_37_docinfo5, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fHideLastVersion field value.
      */
     public boolean isFHideLastVersion()
     {
         return fHideLastVersion.isSet(field_37_docinfo5);
-        
+
     }
 
     /**
      * Sets the fHtmlDoc field value.
-     * 
+     *
      */
     public void setFHtmlDoc(boolean value)
     {
         field_37_docinfo5 = (short)fHtmlDoc.setBoolean(field_37_docinfo5, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fHtmlDoc field value.
      */
     public boolean isFHtmlDoc()
     {
         return fHtmlDoc.isSet(field_37_docinfo5);
-        
+
     }
 
     /**
      * Sets the fSnapBorder field value.
-     * 
+     *
      */
     public void setFSnapBorder(boolean value)
     {
         field_37_docinfo5 = (short)fSnapBorder.setBoolean(field_37_docinfo5, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fSnapBorder field value.
      */
     public boolean isFSnapBorder()
     {
         return fSnapBorder.isSet(field_37_docinfo5);
-        
+
     }
 
     /**
      * Sets the fIncludeHeader field value.
-     * 
+     *
      */
     public void setFIncludeHeader(boolean value)
     {
         field_37_docinfo5 = (short)fIncludeHeader.setBoolean(field_37_docinfo5, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fIncludeHeader field value.
      */
     public boolean isFIncludeHeader()
     {
         return fIncludeHeader.isSet(field_37_docinfo5);
-        
+
     }
 
     /**
      * Sets the fIncludeFooter field value.
-     * 
+     *
      */
     public void setFIncludeFooter(boolean value)
     {
         field_37_docinfo5 = (short)fIncludeFooter.setBoolean(field_37_docinfo5, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fIncludeFooter field value.
      */
     public boolean isFIncludeFooter()
     {
         return fIncludeFooter.isSet(field_37_docinfo5);
-        
+
     }
 
     /**
      * Sets the fForcePageSizePag field value.
-     * 
+     *
      */
     public void setFForcePageSizePag(boolean value)
     {
         field_37_docinfo5 = (short)fForcePageSizePag.setBoolean(field_37_docinfo5, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fForcePageSizePag field value.
      */
     public boolean isFForcePageSizePag()
     {
         return fForcePageSizePag.isSet(field_37_docinfo5);
-        
+
     }
 
     /**
      * Sets the fMinFontSizePag field value.
-     * 
+     *
      */
     public void setFMinFontSizePag(boolean value)
     {
         field_37_docinfo5 = (short)fMinFontSizePag.setBoolean(field_37_docinfo5, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fMinFontSizePag field value.
      */
     public boolean isFMinFontSizePag()
     {
         return fMinFontSizePag.isSet(field_37_docinfo5);
-        
+
     }
 
     /**
      * Sets the fHaveVersions field value.
-     * 
+     *
      */
     public void setFHaveVersions(boolean value)
     {
         field_38_docinfo6 = (short)fHaveVersions.setBoolean(field_38_docinfo6, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fHaveVersions field value.
      */
     public boolean isFHaveVersions()
     {
         return fHaveVersions.isSet(field_38_docinfo6);
-        
+
     }
 
     /**
      * Sets the fAutoVersions field value.
-     * 
+     *
      */
     public void setFAutoVersions(boolean value)
     {
         field_38_docinfo6 = (short)fAutoVersions.setBoolean(field_38_docinfo6, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fAutoVersions field value.
      */
     public boolean isFAutoVersions()
     {
         return fAutoVersions.isSet(field_38_docinfo6);
-        
+
     }
 
     /**
      * Sets the fVirusPrompted field value.
-     * 
+     *
      */
     public void setFVirusPrompted(boolean value)
     {
         field_43_virusinfo = (int)fVirusPrompted.setBoolean(field_43_virusinfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fVirusPrompted field value.
      */
     public boolean isFVirusPrompted()
     {
         return fVirusPrompted.isSet(field_43_virusinfo);
-        
+
     }
 
     /**
      * Sets the fVirusLoadSafe field value.
-     * 
+     *
      */
     public void setFVirusLoadSafe(boolean value)
     {
         field_43_virusinfo = (int)fVirusLoadSafe.setBoolean(field_43_virusinfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fVirusLoadSafe field value.
      */
     public boolean isFVirusLoadSafe()
     {
         return fVirusLoadSafe.isSet(field_43_virusinfo);
-        
+
     }
 
     /**
      * Sets the KeyVirusSession30 field value.
-     * 
+     *
      */
     public void setKeyVirusSession30(int value)
     {
         field_43_virusinfo = (int)KeyVirusSession30.setValue(field_43_virusinfo, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the KeyVirusSession30 field value.
      */
     public int getKeyVirusSession30()
     {
         return ( int )KeyVirusSession30.getValue(field_43_virusinfo);
-        
+
     }
 
 
index 63961b455222c33dc76fe785a8e11745c332ec29..554d342acee35d8184e4fbb58288dc32798efa12 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model.types;
 
index b14882c9dffa5f0bc56b7a0914cbc2770afb4a1b..70460caaca4c790ef68191d507e77c1a392f39c3 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model.types;
 
@@ -1253,65 +1250,65 @@ public abstract class PAPAbstractType
 
     /**
      * Sets the fVertical field value.
-     * 
+     *
      */
     public void setFVertical(boolean value)
     {
         field_35_fontAlign = (short)fVertical.setBoolean(field_35_fontAlign, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fVertical field value.
      */
     public boolean isFVertical()
     {
         return fVertical.isSet(field_35_fontAlign);
-        
+
     }
 
     /**
      * Sets the fBackward field value.
-     * 
+     *
      */
     public void setFBackward(boolean value)
     {
         field_35_fontAlign = (short)fBackward.setBoolean(field_35_fontAlign, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fBackward field value.
      */
     public boolean isFBackward()
     {
         return fBackward.isSet(field_35_fontAlign);
-        
+
     }
 
     /**
      * Sets the fRotateFont field value.
-     * 
+     *
      */
     public void setFRotateFont(boolean value)
     {
         field_35_fontAlign = (short)fRotateFont.setBoolean(field_35_fontAlign, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fRotateFont field value.
      */
     public boolean isFRotateFont()
     {
         return fRotateFont.isSet(field_35_fontAlign);
-        
+
     }
 
 
index b05a5d7ce39c39c93d695a595f54bae71cc1b369..d1548f73b8a44292931d355381b2de364d937ce6 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model.types;
 
index 8ed88a18b3db7a2f768ea4363ef7105025bd9389..f1de3e114b198fc39088996b7f19faa09a086a12 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model.types;
 
index 016907a8a057f749d3c205cfb3403eb02a9c3789..e7b97ee4ffd8e964f958f8025c2240925949d617 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hwpf.model.types;
 
@@ -228,170 +225,170 @@ public abstract class TCAbstractType
 
     /**
      * Sets the fFirstMerged field value.
-     * 
+     *
      */
     public void setFFirstMerged(boolean value)
     {
         field_1_rgf = (short)fFirstMerged.setBoolean(field_1_rgf, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fFirstMerged field value.
      */
     public boolean isFFirstMerged()
     {
         return fFirstMerged.isSet(field_1_rgf);
-        
+
     }
 
     /**
      * Sets the fMerged field value.
-     * 
+     *
      */
     public void setFMerged(boolean value)
     {
         field_1_rgf = (short)fMerged.setBoolean(field_1_rgf, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fMerged field value.
      */
     public boolean isFMerged()
     {
         return fMerged.isSet(field_1_rgf);
-        
+
     }
 
     /**
      * Sets the fVertical field value.
-     * 
+     *
      */
     public void setFVertical(boolean value)
     {
         field_1_rgf = (short)fVertical.setBoolean(field_1_rgf, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fVertical field value.
      */
     public boolean isFVertical()
     {
         return fVertical.isSet(field_1_rgf);
-        
+
     }
 
     /**
      * Sets the fBackward field value.
-     * 
+     *
      */
     public void setFBackward(boolean value)
     {
         field_1_rgf = (short)fBackward.setBoolean(field_1_rgf, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fBackward field value.
      */
     public boolean isFBackward()
     {
         return fBackward.isSet(field_1_rgf);
-        
+
     }
 
     /**
      * Sets the fRotateFont field value.
-     * 
+     *
      */
     public void setFRotateFont(boolean value)
     {
         field_1_rgf = (short)fRotateFont.setBoolean(field_1_rgf, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fRotateFont field value.
      */
     public boolean isFRotateFont()
     {
         return fRotateFont.isSet(field_1_rgf);
-        
+
     }
 
     /**
      * Sets the fVertMerge field value.
-     * 
+     *
      */
     public void setFVertMerge(boolean value)
     {
         field_1_rgf = (short)fVertMerge.setBoolean(field_1_rgf, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fVertMerge field value.
      */
     public boolean isFVertMerge()
     {
         return fVertMerge.isSet(field_1_rgf);
-        
+
     }
 
     /**
      * Sets the fVertRestart field value.
-     * 
+     *
      */
     public void setFVertRestart(boolean value)
     {
         field_1_rgf = (short)fVertRestart.setBoolean(field_1_rgf, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the fVertRestart field value.
      */
     public boolean isFVertRestart()
     {
         return fVertRestart.isSet(field_1_rgf);
-        
+
     }
 
     /**
      * Sets the vertAlign field value.
-     * 
+     *
      */
     public void setVertAlign(byte value)
     {
         field_1_rgf = (short)vertAlign.setValue(field_1_rgf, value);
 
-        
+
     }
 
     /**
-     * 
+     *
      * @return  the vertAlign field value.
      */
     public byte getVertAlign()
     {
         return ( byte )vertAlign.getValue(field_1_rgf);
-        
+
     }
 
 
index a6ee4e6d8c1f0e81876ea4346b9ef197b433fadd..2938df8ab66683385bc900ca4a7c321df500fb01 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.hwpf.sprm;
 
@@ -26,7 +24,7 @@ import java.util.Arrays;
 import org.apache.poi.hwpf.usermodel.CharacterProperties;
 import org.apache.poi.util.LittleEndian;
 
-public class CharacterSprmCompressor
+public final class CharacterSprmCompressor
 {
   public CharacterSprmCompressor()
   {
index c49ac1b9e2ac2dfd70c514de6b5c82a9b976f8cf..aa989209661c0130a0623c455f8dc975922c4a9d 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.hwpf.sprm;
 
@@ -26,7 +24,7 @@ import org.apache.poi.hwpf.usermodel.ShadingDescriptor;
 import org.apache.poi.hwpf.model.StyleSheet;
 import org.apache.poi.util.LittleEndian;
 
-public class CharacterSprmUncompressor
+public final class CharacterSprmUncompressor
 {
   public CharacterSprmUncompressor()
   {
index de2c23994a03266ec3aac709bd10a2930dde0ad5..c3e48d522691ac612917e5b58e560f987ae6d070 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.hwpf.sprm;
 
@@ -27,7 +25,7 @@ import org.apache.poi.util.LittleEndian;
 
 import org.apache.poi.hwpf.usermodel.ParagraphProperties;
 
-public class ParagraphSprmCompressor
+public final class ParagraphSprmCompressor
 {
   public ParagraphSprmCompressor()
   {
index a7d5690e2e9fb720e1afde87e9396bde7eb055f7..235f435c2cce8a0e77107cf8d32561384417ed4e 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
@@ -16,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.sprm;
 
 import org.apache.poi.hwpf.usermodel.ParagraphProperties;
@@ -33,7 +31,7 @@ import java.util.Iterator;
 import java.util.Collections;
 import java.util.ArrayList;
 
-public class ParagraphSprmUncompressor
+public final class ParagraphSprmUncompressor
   extends SprmUncompressor
 {
   public ParagraphSprmUncompressor()
index 4b18dafb789fd7f8f0cf5e4758798c6a952e9870..ad47cdfdc0e3a0dc84403e26f2b6755d43318380 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,8 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-//
+
 package org.apache.poi.hwpf.sprm;
 
 //
@@ -246,7 +244,7 @@ import org.apache.poi.hwpf.usermodel.SectionProperties;
 import org.apache.poi.util.LittleEndian;
 
 
-public class SectionSprmCompressor
+public final class SectionSprmCompressor
 {
   private final static SectionProperties DEFAULT_SEP = new SectionProperties();
   public SectionSprmCompressor()
index 30805346b6fdd3f1e7ff4b6e49822611447c635c..802b9fcbc2992d34eeca2ef41a9165d960dde2a6 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.hwpf.sprm;
 
 import org.apache.poi.hwpf.usermodel.SectionProperties;
 import org.apache.poi.hwpf.usermodel.BorderCode;
 
-public class SectionSprmUncompressor extends SprmUncompressor
+public final class SectionSprmUncompressor extends SprmUncompressor
 {
   public SectionSprmUncompressor()
   {
index bef06d43c9f4b984a934b7cb6f3fe7a7ea7f6cc5..6b1ef436575db29202c4d3c9d2673ae30c0a58c5 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.hwpf.sprm;
 
@@ -23,7 +21,7 @@ import org.apache.poi.util.LittleEndian;
 
 import java.util.Arrays;
 
-public class SprmBuffer
+public final class SprmBuffer
   implements Cloneable
 {
   byte[] _buf;
index 5a1c4b45d85b060bd167e0e770c0a0b0eb5fa9b2..1a6f23fdfb56a83f352182bf00a524ea469532b1 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.hwpf.sprm;
 
@@ -26,7 +24,7 @@ package org.apache.poi.hwpf.sprm;
  * @version 1.0
  */
 
-public class SprmIterator
+public final class SprmIterator
 {
   private byte[] _grpprl;
   int _offset;
index 764fc06c4dcf5cee54c5f925af8649cf63d5885c..41478c80ecf29b4e133fb7a6465c932c92fcd1b1 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.hwpf.sprm;
 
@@ -29,7 +27,7 @@ import org.apache.poi.util.LittleEndian;
  * @author Ryan Ackley
  * @version 1.0
  */
-public class SprmOperation
+public final class SprmOperation
 {
   final static private BitField OP_BITFIELD = BitFieldFactory.getInstance(0x1ff);
   final static private BitField SPECIAL_BITFIELD = BitFieldFactory.getInstance(0x200);
@@ -102,7 +100,7 @@ public class SprmOperation
         return LittleEndian.getInt(_grpprl, _gOffset);
       case 6:
           byte operandLength = _grpprl[_gOffset + 1];   //surely shorter than an int...
-         
+
           byte [] codeBytes = new byte[LittleEndian.INT_SIZE]; //initialized to zeros by JVM
           for(int i = 0; i < operandLength; i++)
               if(_gOffset + i < _grpprl.length)
index adae2078fb5870a109ee48d0e587619e0fb625b7..a2ff38855e7a87298d4df509266a05097a6e4774 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.hwpf.sprm;
 
 
 
-public class SprmUncompressor
+public abstract class SprmUncompressor
 {
-  public SprmUncompressor()
+  protected SprmUncompressor()
   {
   }
 
@@ -41,10 +39,7 @@ public class SprmUncompressor
     {
       return true;
     }
-    else
-    {
-      return false;
-    }
+       return false;
   }
 
 
index b5cd08eb93c34b6aec2ee10b4ef63b157be088fc..9f0abda0f924c9b4d2ca9ce9fad82003889556d3 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.hwpf.sprm;
 
@@ -24,7 +22,7 @@ import java.util.List;
 import org.apache.poi.util.LittleEndian;
 
 
-public class SprmUtils
+public final class SprmUtils
 {
   public SprmUtils()
   {
index a13d59b921b35eeac7e33b0984cac2edd9bacf5f..13580fa090ed645f4fdae27da603d5aa935954d2 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.hwpf.sprm;
 
@@ -28,7 +26,7 @@ import org.apache.poi.hwpf.usermodel.BorderCode;
 import java.util.ArrayList;
 import java.util.Arrays;
 
-public class TableSprmCompressor
+public final class TableSprmCompressor
 {
   public TableSprmCompressor()
   {
index f8fc91f1232b865beaf0377e1fc62c9d14c083c6..56de089e990a8debb5b6196cc0e766ad54ff6c9c 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
@@ -16,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.sprm;
 
 import org.apache.poi.hwpf.usermodel.TableProperties;
@@ -25,7 +23,7 @@ import org.apache.poi.hwpf.usermodel.BorderCode;
 
 import org.apache.poi.util.LittleEndian;
 
-public class TableSprmUncompressor
+public final class TableSprmUncompressor
   extends SprmUncompressor
 {
   public TableSprmUncompressor()
index 053d3600df730b53d8d67da06cd4cf96f209369e..63e534581ff6f2b408e621ec963d3c73d7975b0e 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.hwpf.usermodel;
 
@@ -23,7 +21,7 @@ import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
 
-public class BorderCode
+public final class BorderCode
   implements Cloneable
 {
   public static final int SIZE = 4;
index 62a384c0ebe4630ce580ef8d3c8f259d7addf2c7..540b30000ab453cac6eeafbee7260f4d47be09cd 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
@@ -16,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.usermodel;
 
 import org.apache.poi.hwpf.model.types.CHPAbstractType;
@@ -24,7 +22,7 @@ import org.apache.poi.hwpf.model.types.CHPAbstractType;
 /**
  * @author Ryan Ackley
  */
-public class CharacterProperties
+public final class CharacterProperties
   extends CHPAbstractType implements Cloneable
 {
   public final static short SPRM_FRMARKDEL = (short)0x0800;
index 601c5fa6842bd99a9e0c90c8501ae7df27ffe7da..9a779643a6aa9343decf0ab1215cf528cc641958 100644 (file)
@@ -15,8 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
-
 package org.apache.poi.hwpf.usermodel;
 
 import org.apache.poi.hwpf.model.CHPX;
@@ -28,7 +26,7 @@ import org.apache.poi.hwpf.sprm.SprmBuffer;
  *
  * @author Ryan Ackley
  */
-public class CharacterRun
+public final class CharacterRun
   extends Range
   implements Cloneable
 {
@@ -530,7 +528,7 @@ public class CharacterRun
        return (CharacterProperties)_props.clone();
     } catch(java.lang.CloneNotSupportedException e) {
        throw new RuntimeException(e);
-    } 
+    }
   }
 
   /**
index 99cc8658b830dcf42421962c9cd7b540a915c62e..27626a515d9544a8197ddf0f19b0d66abe73586d 100644 (file)
@@ -15,8 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
-
 package org.apache.poi.hwpf.usermodel;
 
 import org.apache.poi.util.BitField;
@@ -28,7 +26,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Ryan Ackley
  */
-public class DateAndTime
+public final class DateAndTime
   implements Cloneable
 {
   public static final int SIZE = 4;
index 234f39e4eced2fe55603045ad0f762f9d6297356..eb90d5569e48f36de9bac6dd44dbbe8a3a1872c5 100644 (file)
    limitations under the License.
 ==================================================================== */
 
-/**
- * @author Ryan Ackley
- */
 package org.apache.poi.hwpf.usermodel;
 
 import org.apache.poi.hwpf.HWPFDocument;
 
-public class DocumentPosition
+public final class DocumentPosition
   extends Range
 {
   public DocumentPosition(HWPFDocument doc, int pos)
@@ -30,4 +27,4 @@ public class DocumentPosition
     super(pos, pos, doc);
   }
 
-}
\ No newline at end of file
+}
index 9793e056ac88b25b78a2e17a17aebf156e5abf95..b2da9f5eac7f54d1ced834cf8079d3fa82eda560 100644 (file)
@@ -29,7 +29,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Ryan Ackley
  */
-public class DropCapSpecifier
+public final class DropCapSpecifier
 {
   private short _info;
     private static BitField _type = BitFieldFactory.getInstance(0x07);
index 4fdb184f100d12e7362c95b807159ba30fa1e36e..91c993fd7a0f46d556cffb79e7ff9e90b356d664 100644 (file)
@@ -43,7 +43,7 @@ import org.apache.poi.hwpf.sprm.ParagraphSprmCompressor;
  *
  * @author Ryan Ackley
  */
-public class HWPFList
+public final class HWPFList
 {
   private ListData _listData;
   private ListFormatOverride _override;
index e8f231b6c1be6a6ba6b8eceb1c0831734095757d..4afaba9d1e302290225fb338e32f6d07f9422994 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hwpf.usermodel;
 
 import org.apache.poi.hwpf.HWPFDocument;
@@ -22,25 +23,25 @@ import org.apache.poi.hwpf.model.GenericPropertyNode;
 import org.apache.poi.hwpf.model.PlexOfCps;
 
 /**
- * A HeaderStory is a Header, a Footer, or footnote/endnote 
+ * A HeaderStory is a Header, a Footer, or footnote/endnote
  *  separator.
  * All the Header Stories get stored in the same Range in the
  *  document, and this handles getting out all the individual
  *  parts.
- * 
+ *
  * WARNING - you shouldn't change the headers or footers,
  *  as offsets are not yet updated!
  */
-public class HeaderStories {
+public final class HeaderStories {
        private Range headerStories;
        private PlexOfCps plcfHdd;
-       
+
        private boolean stripFields = false;
-       
+
        public HeaderStories(HWPFDocument doc) {
                this.headerStories = doc.getHeaderStoryRange();
                FileInformationBlock fib = doc.getFileInformationBlock();
-               
+
                // If there's no PlcfHdd, nothing to do
                if(fib.getCcpHdd() == 0) {
                        return;
@@ -48,14 +49,14 @@ public class HeaderStories {
                if(fib.getPlcfHddSize() == 0) {
                        return;
                }
-               
+
                // Handle the PlcfHdd
                plcfHdd = new PlexOfCps(
                                doc.getTableStream(), fib.getPlcfHddOffset(),
                                fib.getPlcfHddSize(), 0
                );
        }
-       
+
        public String getFootnoteSeparator() {
                return getAt(0);
        }
@@ -74,8 +75,8 @@ public class HeaderStories {
        public String getEndnoteContNote() {
                return getAt(5);
        }
-       
-       
+
+
        public String getEvenHeader() {
                return getAt(6+0);
        }
@@ -108,8 +109,8 @@ public class HeaderStories {
                // Odd is the default
                return getOddHeader();
        }
-       
-       
+
+
        public String getEvenFooter() {
                return getAt(6+2);
        }
@@ -142,25 +143,25 @@ public class HeaderStories {
                // Odd is the default
                return getOddFooter();
        }
-       
-       
+
+
        /**
         * Get the string that's pointed to by the
-        *  given plcfHdd index 
+        *  given plcfHdd index
         */
        private String getAt(int plcfHddIndex) {
                if(plcfHdd == null) return null;
-               
+
                GenericPropertyNode prop = plcfHdd.getProperty(plcfHddIndex);
                if(prop.getStart() == prop.getEnd()) {
                        // Empty story
                        return "";
                }
-               
+
                // Grab the contents
                String text =
                        headerStories.text().substring(prop.getStart(), prop.getEnd());
-               
+
                // Strip off fields and macros if requested
                if(stripFields) {
                        return Range.stripFields(text);
@@ -171,17 +172,17 @@ public class HeaderStories {
                if(text.equals("\r\r")) {
                        return "";
                }
-               
+
                return text;
        }
-       
+
        public Range getRange() {
                return headerStories;
        }
        protected PlexOfCps getPlcfHdd() {
                return plcfHdd;
        }
-       
+
        /**
         * Are fields currently being stripped from
         *  the text that this {@link HeaderStories} returns?
index c89332e668bc5d73cfcc3750e9723d67b3303d9b..d969d5e1e11d81ae9457e0fc4bbc5880718713cc 100644 (file)
@@ -24,7 +24,7 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Ryan Ackley
  */
-public class LineSpacingDescriptor
+public final class LineSpacingDescriptor
   implements Cloneable
 {
   short _dyaLine;
index 9bafce792761a3e6c6fb604d28e7f4b0693632f3..6f29cf0d3cce20ce2c2644da5fd11f18e80b0afa 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf.usermodel;
 
 import org.apache.poi.hwpf.model.ListFormatOverride;
@@ -26,18 +25,18 @@ import org.apache.poi.hwpf.model.PAPX;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 
-public class ListEntry
+public final class ListEntry
   extends Paragraph
 {
        private static POILogger log = POILogFactory.getLogger(ListEntry.class);
-       
+
        ListLevel _level;
        ListFormatOverrideLevel _overrideLevel;
 
   ListEntry(PAPX papx, Range parent, ListTables tables)
   {
     super(papx, parent);
-    
+
     if(tables != null) {
            ListFormatOverride override = tables.getOverride(_props.getIlfo());
            _overrideLevel = override.getOverrideLevel(_props.getIlvl());
index 107180b86cb808a91fe366a53b5cfd2200507182..a1462ffe0afe2a4d27db36626915e60344b786fe 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
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.usermodel;
 
 import org.apache.poi.hwpf.model.PAPX;
 import org.apache.poi.hwpf.sprm.SprmBuffer;
 import org.apache.poi.hwpf.sprm.TableSprmCompressor;
 
-public class Paragraph
-  extends Range
-    implements Cloneable
-{
+public class Paragraph extends Range implements Cloneable {
   public final static short SPRM_JC = 0x2403;
   public final static short SPRM_FSIDEBYSIDE = 0x2404;
   public final static short SPRM_FKEEP = 0x2405;
@@ -457,7 +452,7 @@ public class Paragraph
   /**
    * clone the ParagraphProperties object associated with this Paragraph so
    * that you can apply the same properties to another paragraph.
-   * 
+   *
    */
   public ParagraphProperties cloneProperties() {
     try {
index 2b43ff12b44b0d5cfe87c0e5fd5c6185bf4336c7..167d0837d4a18d0215f8b3670baa24c0a667f948 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.hwpf.usermodel;
 
@@ -24,7 +22,7 @@ import org.apache.poi.hwpf.model.StyleDescription;
 
 import org.apache.poi.hwpf.sprm.SprmBuffer;
 
-public class ParagraphProperties
+public final class ParagraphProperties
   extends PAPAbstractType
     implements Cloneable
 {
index 8a3737865bbf408e7f8f2ff0b1a96df36be0c3cf..e485bd01021b5f740dd2dc17129d2e7758016def 100644 (file)
@@ -15,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.usermodel;
 
 import org.apache.poi.util.LittleEndian;
@@ -32,7 +31,7 @@ import java.util.zip.InflaterInputStream;
  * Represents embedded picture extracted from Word Document
  * @author Dmitry Romanov
  */
-public class Picture
+public final class Picture
 {
   private static final POILogger log = POILogFactory.getLogger(Picture.class);
 
@@ -98,7 +97,7 @@ public class Picture
       fillImageContent();
     }
   }
-  
+
   public Picture(byte[] _dataStream)
   {
       this._dataStream = _dataStream;
index d9b679e42d72a2e9b2bd1d5deaeaa438159cb282..eb97077e832effa136713fd0710065daba931d61 100644 (file)
@@ -15,8 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
-
 package org.apache.poi.hwpf.usermodel;
 
 
@@ -60,8 +58,7 @@ import java.lang.ref.WeakReference;
  *
  * @author Ryan Ackley
  */
-public class Range
-{
+public class Range { // TODO -instantiable superclass
 
   public static final int TYPE_PARAGRAPH = 0;
   public static final int TYPE_CHARACTER= 1;
@@ -155,7 +152,7 @@ public class Range
     _characters = _doc.getCharacterTable().getTextRuns();
     _text = _doc.getTextTable().getTextPieces();
     _parent = new WeakReference(null);
-    
+
     sanityCheckStartEnd();
   }
 
@@ -177,7 +174,7 @@ public class Range
     _characters = parent._characters;
     _text = parent._text;
     _parent = new WeakReference(parent);
-    
+
     sanityCheckStartEnd();
   }
 
@@ -230,10 +227,10 @@ public class Range
         _textRangeFound = true;
         break;
     }
-    
+
     sanityCheckStartEnd();
   }
-  
+
   /**
    * Ensures that the start and end were were given
    *  are actually valid, to avoid issues later on
@@ -281,7 +278,7 @@ public class Range
     for (int x = _textStart; x < _textEnd; x++)
     {
       TextPiece piece = (TextPiece)_text.get(x);
-      
+
       // Figure out where in this piece the text
       //  we're after lives
       int rStart = 0;
@@ -292,14 +289,14 @@ public class Range
       if(_end < piece.getEnd()) {
          rEnd -= (piece.getEnd() - _end);
       }
-      
+
       // Luckily TextPieces work in characters, so we don't
       //  need to worry about unicode here
       sb.append(piece.substring(rStart, rEnd));
     }
     return sb.toString();
   }
-  
+
   /**
    * Removes any fields (eg macros, page markers etc)
    *  from the string.
@@ -311,10 +308,10 @@ public class Range
          // First up, fields can be nested...
          // A field can be 0x13 [contents] 0x15
          // Or it can be 0x13 [contents] 0x14 [real text] 0x15
-         
+
          // If there are no fields, all easy
          if(text.indexOf('\u0013') == -1) return text;
-         
+
          // Loop over until they're all gone
          // That's when we're out of both 0x13s and 0x15s
          while( text.indexOf('\u0013') > -1 &&
@@ -323,19 +320,19 @@ public class Range
                  int next13 = text.indexOf('\u0013', first13+1);
                  int first14 = text.indexOf('\u0014', first13+1);
                  int last15 = text.lastIndexOf('\u0015');
-                 
+
                  // If they're the wrong way around, give up
                  if(last15 < first13) {
                          break;
                  }
-                 
+
                  // If no more 13s and 14s, just zap
                  if(next13 == -1 && first14 == -1) {
                          text = text.substring(0, first13) +
                                                text.substring(last15+1);
                          break;
                  }
-                 
+
                  // If a 14 comes before the next 13, then
                  //  zap from the 13 to the 14, and remove
                  //  the 15
@@ -345,7 +342,7 @@ public class Range
                                                text.substring(last15+1);
                          continue;
                  }
-                 
+
                  // Another 13 comes before the next 14.
                  // This means there's nested stuff, so we
                  //  can just zap the lot
@@ -626,7 +623,7 @@ public class Range
       sepx.adjustForDelete(_start, _end - _start);
       //System.err.println("Section " + x + " is now " + sepx.getStart() + " -> " + sepx.getEnd());
     }
-    
+
     for (int x = _textStart; x < numTextPieces; x++)
     {
        TextPiece piece = (TextPiece)_text.get(x);
@@ -728,7 +725,7 @@ public class Range
   {
        int absPlaceHolderIndex = getStartOffset() + pOffset;
     Range subRange = new Range(
-                absPlaceHolderIndex, 
+                absPlaceHolderIndex,
                                (absPlaceHolderIndex + pPlaceHolder.length()), getDocument()
     );
 
@@ -744,7 +741,7 @@ public class Range
     // re-create the sub-range so we can delete it
     subRange = new Range(
             (absPlaceHolderIndex + pValue.length()),
-            (absPlaceHolderIndex + pPlaceHolder.length() + pValue.length()), 
+            (absPlaceHolderIndex + pPlaceHolder.length() + pValue.length()),
                        getDocument()
     );
 
@@ -1005,7 +1002,7 @@ public class Range
   /**
    * Adjust the value of the various FIB character count fields,
    *  eg <code>FIB.CCPText</code> after an insert or a delete...
-   *  
+   *
    * Works on all CCP fields from this range onwards
    *
    * @param    adjustment      The (signed) value that should be added to the FIB CCP fields
@@ -1017,12 +1014,12 @@ public class Range
 
        CPSplitCalculator cpS = _doc.getCPSplitCalculator();
        FileInformationBlock fib = _doc.getFileInformationBlock();
-       
+
        // Do for each affected part
        if(_start < cpS.getMainDocumentEnd()) {
                fib.setCcpText(fib.getCcpText() + adjustment);
        }
-       
+
        if(_start < cpS.getCommentsEnd()) {
                fib.setCcpAtn(fib.getCcpAtn() + adjustment);
        }
index 050ac9532edab7cd493eae2ae696852b9439757c..2e471d52f11acfe2e98fabb2fa02ad5d014baa8e 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
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.usermodel;
 
 import org.apache.poi.hwpf.model.SEPX;
 
-public class Section
+public final class Section
   extends Range
 {
 
index 71c705c8ca0cfd9d9b13b24cb31aedcad777e0ef..4f89fe3216e292ce7f255df9c34925539b3a0b3b 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.hwpf.usermodel;
 
@@ -24,7 +22,7 @@ import org.apache.poi.hwpf.model.types.SEPAbstractType;
 import java.lang.reflect.Field;
 import java.lang.reflect.AccessibleObject;
 
-public class SectionProperties
+public final class SectionProperties
   extends SEPAbstractType
 {
   public SectionProperties()
index 22809be7a8bac553473ae09592bf4709a2709857..3e9d2b3ca9d7682ca8b91c092ebdb5c8482c7337 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.hwpf.usermodel;
 
@@ -23,7 +21,7 @@ import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
 
-public class ShadingDescriptor
+public final class ShadingDescriptor
   implements Cloneable
 {
   public static final int SIZE = 2;
index 1f798b620c53c05925620f449841f218d3516faf..aecc0d3461c41ff926596c7bd373b670f41635c2 100644 (file)
@@ -20,14 +20,14 @@ package org.apache.poi.hwpf.usermodel;
 import org.apache.poi.hwpf.model.GenericPropertyNode;
 import org.apache.poi.util.LittleEndian;
 
-public class Shape {
+public final class Shape {
         int _id, _left, _right, _top, _bottom;
         /**
          * true if the Shape bounds are within document (for
          * example, it's false if the image left corner is outside the doc, like for
          * embedded documents)
          */
-        boolean _inDoc; 
+        boolean _inDoc;
 
         public Shape(GenericPropertyNode nodo) {
                 byte [] contenuto = nodo.getBytes();
index 29193edf0370e68c62201ad7ce4c0f4f18a96f33..4fb4d1636e54cf9a75280b23f96ed5e5e7735151 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,7 +19,7 @@ package org.apache.poi.hwpf.usermodel;
 
 import java.util.ArrayList;
 
-public class Table
+public final class Table
   extends Range
 {
   ArrayList _rows;
index 4db9da7a95acc0c13f1c2dbbd4fd0b90ce12eda8..19c0f7d064aa8f69cb4a8bb14874c1acb18e0f4a 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.hwpf.usermodel;
 
-public class TableCell
+public final class TableCell
   extends Range
 {
   private int _levelNum;
index 1c78f5f82a6ea508b9b41778111bff2c540eb10d..8d196fce7292ab8e6d604a893011d6db35e8811b 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.hwpf.usermodel;
 
 import org.apache.poi.hwpf.model.types.TCAbstractType;
 
-public class TableCellDescriptor
+public final class TableCellDescriptor
   extends TCAbstractType
 {
   public static final int SIZE = 20;
index c836af1f343b27f90e9e65416304d9cf931316c7..f19a340351d0ed481592191fb5113b06538419ef 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.hwpf.usermodel;
 
 
 import java.util.ArrayList;
 
-public class TableIterator
+public final class TableIterator
 {
   Range _range;
   int _index;
index a7d485b8a839ca56705ae15438a5884bf56cacfd..b06526ccd1bd41c59d9e6e8bd75fed7dbd89c0ba 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.hwpf.usermodel;
 
 import org.apache.poi.hwpf.model.types.TAPAbstractType;
 
-public class TableProperties
+public final class TableProperties
   extends TAPAbstractType
     implements Cloneable
 {
index a88e32360ee433114c6a2ad79c357102f22edba8..857a92cfbe2d22a056633273850c9a65c8cdecc5 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,7 +19,7 @@ package org.apache.poi.hwpf.usermodel;
 
 import org.apache.poi.hwpf.sprm.TableSprmUncompressor;
 
-public class TableRow
+public final class TableRow
   extends Paragraph
 {
   private final static char TABLE_CELL_MARK = '\u0007';
index ae0ff35939a2e5d8c334c0dd4d921132ed82cf3f..ae2fb7c7da884b4341e623ef3f2268e7eb275223 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface AutoShape extends SimpleShape {
index 6211667d0ef49d6f95ded13dff2c0cbc49828c32..f67c57b95afac8e07ff21c6ce1afaaa6b041cc3a 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface Background extends Shape {
index 5a5568a774e303e17fd0d542a4eaffe55fa7be0b..e62b0480d6e1e396bfe203739ecab816ce090578 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface Fill extends org.apache.poi.common.usermodel.Fill {
index 289872a4031dfdc7775b94c2a95dc24e473ad1d1..61278f4618e93768cdcd096c3a9e1e866fd4f051 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface FontCollection {
index 66a84d5131881ce80b5cb55524577b306d2e68b2..cde288492c5dd9b87bf9dd0d481380094d0a1ada 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 /**
index 7136f7f3cf8990a6e14d943408e1fb97c4125413..630c37de45af6f37945ca0f490eb3661ad29bfd6 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface Line extends AutoShape {
index 28a1293863c022805497013f8b2c4cfaf20dd89e..43ef4a7b785aa633267646c58dd2cb6d9419c61c 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface LineStyle extends org.apache.poi.common.usermodel.LineStyle {
index 711a6fd5df17597bc2fec5dc287bc31088cf7181..61792cd5bbc7b399fcdff35cbc9f970d93732358 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface MasterSheet extends Sheet {
index ff99ef01f8a3b913484c41591e46741d74ae38e6..5d5ba98e7eb8408de36b9f62ce42de186156fb25 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface Notes extends Sheet {
index 26615ff91ca661601dae5a3f102cb80b3c41af1b..9a553139635807aa0d772278011ec23f91fbd580 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface Picture extends SimpleShape {
index d002cf7981f28bc882ee64557477776530769d89..e325e5a8db7a44a07f5e364e911ff4fe393c82ad 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface PictureData {
        public int getType();
        public byte[] getUID();
-       
+
        public byte[] getData();
        public void setData(byte[] data);
 }
index 28f5edb6b66bf87a3b86a94431628e9b7c5c3140..96170e50bd4984a21c117c37d9b75416b7ead935 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 /**
@@ -22,7 +23,7 @@ package org.apache.poi.sl.usermodel;
  */
 public interface Resources {
        public FontCollection getFontCollection();
-       
+
        public PictureData[] getPictureData();
        public int addPictureData(PictureData pict);
 }
index 0d68501167b35fe47602f41f687afdc612660bbb..11c0bf6251501f117d5bacefcd2032cdd837edef 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 import java.awt.geom.Rectangle2D;
 
 public interface Shape {
        public int getShapeType();
-       
+
        public Rectangle2D getAnchor();
        public void setAnchor(Rectangle2D anchor);
-       
+
        public void moveTo(float x, float y);
-       
+
        public Shape getParent();
 }
index ea295a4932085d3dac42f085f5b2abfdfd722e3d..cabcf4bc89b11faefcca81eb8cc405d7ebe11ab1 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface ShapeContainer {
index e5b6ab9ca5498f705175ec4570b0665344954772..3c2ff6b8cd395f60264783dde720b3dac8fbc722 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface ShapeGroup extends ShapeContainer {
index f4e06bc80645b586797186ff4a38ec1579d57ea3..69325fe13a453e242e04c4964687005b1460212a 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface ShapeTypes {
index 4a78a403fd0302fc22f56ec05e2ac8f564362cad..7959838cc17ad4c7921416faaf0baae9de565702 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 /**
@@ -23,6 +24,6 @@ public interface Sheet extends ShapeContainer {
        public SlideShow getSlideShow();
 
        public MasterSheet getMasterSheet();
-       
+
        public Background getBackground();
 }
index c5be4f5df8e9cbd203fd02e3db3fbe31ad1e199e..449433a7e83a76ee866f4a3bf7368d0a662c4c4a 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface SimpleShape extends Shape {
        public Fill getFill();
        public LineStyle getLineStyle();
-       
+
        public Hyperlink getHyperlink();
        public void setHyperlink(Hyperlink hyperlink);
 }
index a1e224749da161cedaf45ec322522a3ec9a6ede1..d3c4af25a4161682dc83cb38fa6c50f459b68c0b 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface Slide extends Sheet {
        public Notes getNotes();
        public void setNotes(Notes notes);
-       
+
        public boolean getFollowMasterBackground();
        public void setFollowMasterBackground(boolean follow);
-       
+
        public boolean getFollowMasterColourScheme();
        public void setFollowMasterColourScheme(boolean follow);
-       
+
        public boolean getFollowMasterObjects();
        public void setFollowMasterObjects(boolean follow);
 }
index 39cd4d500f11fb5a3cd3e2f81fa737bb40d79047..8239bb91ffa9c6c5fd6d0ffd927cb3874c876210 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 import java.io.IOException;
@@ -21,9 +22,9 @@ import java.io.IOException;
 public interface SlideShow {
        public Slide createSlide() throws IOException;
        public MasterSheet createMasterSheet() throws IOException;
-       
+
        public Slide[] getSlides();
        public MasterSheet[] getMasterSheet();
-       
+
        public Resources getResources();
 }
index eef7cfc2e46ad32735fc9343560aad32c099c795..5a88815ee7d45d8ddd248f3dcf8d4ea5c66f4894 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 public interface TextBox extends AutoShape {
index 5941b18df653a15397bf138068c8f78ffae0abfa..ae1a1347712e0fe0898d7cb7c5b0e63656758a60 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.sl.usermodel;
 
 /**
  * Some text.
- * 
+ *
  * TODO - decide on how we do rich text stuff
  */
 public interface TextRun {
        public String getText();
        public void setText(String text);
-       
+
        // TODO - rich text formatting stuff
 }
index 520409fcacba6f966c4b28ebb4703d884110e468..e66a26266482ac6beedf657326ea6689ef07190d 100644 (file)
@@ -15,7 +15,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 
 
 package org.apache.poi;
@@ -34,10 +34,10 @@ import org.apache.poi.poifs.filesystem.*;
  *
  * This is part 2 of 2 of the tests - it only does the POIDocuments
  *  which are part of the scratchpad (not main)
- *  
+ *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestPOIDocumentScratchpad extends TestCase {
+public final class TestPOIDocumentScratchpad extends TestCase {
        // The POI Documents to work on
        private POIDocument doc;
        private POIDocument doc2;
@@ -46,7 +46,7 @@ public class TestPOIDocumentScratchpad extends TestCase {
        private POIFSFileSystem pfs2;
 
        /**
-        * Set things up, using a PowerPoint document and 
+        * Set things up, using a PowerPoint document and
         *  a Word Document for our testing
         */
     public void setUp() throws Exception {
@@ -56,31 +56,31 @@ public class TestPOIDocumentScratchpad extends TestCase {
                String filenameHSSF = dirnameHSLF + "/DateFormats.ppt";
                String dirnameHWPF = System.getProperty("HWPF.testdata.path");
                String filenameHWPF = dirnameHWPF + "/test2.doc";
-               
+
                FileInputStream fisHSLF = new FileInputStream(filenameHSLF);
                pfs = new POIFSFileSystem(fisHSLF);
                doc = new HSLFSlideShow(pfs);
-               
+
                FileInputStream fisHWPF = new FileInputStream(filenameHWPF);
                pfs2 = new POIFSFileSystem(fisHWPF);
                doc2 = new HWPFDocument(pfs2);
        }
-    
+
     public void testReadProperties() throws Exception {
        // We should have both sets
        assertNotNull(doc.getDocumentSummaryInformation());
        assertNotNull(doc.getSummaryInformation());
-       
+
        // Check they are as expected for the test doc
        assertEquals("Hogwarts", doc.getSummaryInformation().getAuthor());
        assertEquals(10598, doc.getDocumentSummaryInformation().getByteCount());
     }
-       
-    public void testReadProperties2() throws Exception {       
+
+    public void testReadProperties2() throws Exception {
        // Check again on the word one
        assertNotNull(doc2.getDocumentSummaryInformation());
        assertNotNull(doc2.getSummaryInformation());
-       
+
        assertEquals("Hogwarts", doc2.getSummaryInformation().getAuthor());
        assertEquals("", doc2.getSummaryInformation().getKeywords());
        assertEquals(0, doc2.getDocumentSummaryInformation().getByteCount());
@@ -90,7 +90,7 @@ public class TestPOIDocumentScratchpad extends TestCase {
        // Just check we can write them back out into a filesystem
        POIFSFileSystem outFS = new POIFSFileSystem();
        doc.writeProperties(outFS);
-       
+
        // Should now hold them
        assertNotNull(
                        outFS.createDocumentInputStream("\005SummaryInformation")
@@ -102,20 +102,20 @@ public class TestPOIDocumentScratchpad extends TestCase {
 
     public void testWriteReadProperties() throws Exception {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-               
+
        // Write them out
        POIFSFileSystem outFS = new POIFSFileSystem();
        doc.writeProperties(outFS);
        outFS.writeFilesystem(baos);
-       
+
        // Create a new version
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        POIFSFileSystem inFS = new POIFSFileSystem(bais);
-       
+
        // Check they're still there
        doc.filesystem = inFS;
        doc.readProperties();
-       
+
        // Delegate test
        testReadProperties();
     }
index 6b9b1a24dc62eb7b38593995dce36d5b8829ec57..84ff605096cfd6421189282d8e2ae7767745516f 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hdf.model;
 
@@ -32,7 +29,7 @@ import java.io.IOException;
  *
  * @author Bob Otterberg
  */
-public class TestHDFDocument
+public final class TestHDFDocument
         extends TestCase
 {
 
index 85f64df220642fdf72e6c3c6c8404d2d44598281..e98c8110a0a9953f86e2d17ec223b725094902d3 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf;
 
 import java.io.FileInputStream;
@@ -24,35 +25,35 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
 import junit.framework.TestCase;
 
-public class TestHDGFCore extends TestCase {
+public final class TestHDGFCore extends TestCase {
        private POIFSFileSystem fs;
        private String dirname;
        private String filename;
-       
+
        protected void setUp() throws Exception {
                dirname = System.getProperty("HDGF.testdata.path");
                filename = dirname + "/Test_Visio-Some_Random_Text.vsd";
                fs = new POIFSFileSystem(new FileInputStream(filename));
        }
-       
+
        public void testCreate() throws Exception {
                new HDGFDiagram(fs);
        }
-       
+
        public void testTrailer() throws Exception {
                HDGFDiagram hdgf = new HDGFDiagram(fs);
                assertNotNull(hdgf);
                assertNotNull(hdgf.getTrailerStream());
-               
+
                // Check it has what we'd expect
                TrailerStream trailer = hdgf.getTrailerStream();
                assertEquals(0x8a94, trailer.getPointer().getOffset());
-               
+
                assertNotNull(trailer.getPointedToStreams());
                assertEquals(20, trailer.getPointedToStreams().length);
-               
+
                assertEquals(20, hdgf.getTopLevelStreams().length);
-               
+
                // 9th one should have children
                assertNotNull(trailer.getPointedToStreams()[8]);
                assertNotNull(trailer.getPointedToStreams()[8].getPointer());
@@ -61,7 +62,7 @@ public class TestHDGFCore extends TestCase {
                assertNotNull(ps8.getPointedToStreams());
                assertEquals(8, ps8.getPointedToStreams().length);
        }
-       
+
        /**
         * Tests that we can open a problematic file, that initially
         *  appears to have a negative chunk length
@@ -69,7 +70,7 @@ public class TestHDGFCore extends TestCase {
        public void DISABLEDtestNegativeChunkLength() throws Exception {
                filename = dirname + "/NegativeChunkLength.vsd";
                fs = new POIFSFileSystem(new FileInputStream(filename));
-               
+
                HDGFDiagram hdgf = new HDGFDiagram(fs);
                assertNotNull(hdgf);
        }
index f8f0f25558705d71730b8a1a11edde13f8242b21..bbdeadad0914a5861d18cef3d280f78362b0a769 100644 (file)
    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.hdgf;
 
 import java.io.ByteArrayInputStream;
 
 import junit.framework.TestCase;
 
-public class TestHDGFLZW extends TestCase {
+public final class TestHDGFLZW extends TestCase {
        public static final byte[] testTrailerComp = new byte[] {
                123,      // *mask bit*
-               -60, 2, 
+               -60, 2,
                -21, -16, // 3 @ 4093
-               1, 0, 0, -72, 
+               1, 0, 0, -72,
                -13, -16, // 3 @ 5
                78,       // *mask bit*
-               -32, -5,  // 14 @ 4082 
-               1, 0, 3, 
+               -32, -5,  // 14 @ 4082
+               1, 0, 3,
                -21, -16, // 3 @ 4093
                10, 5,    // 8 @ 28
-               4, 
+               4,
+               -21, -16, // 3 @ 4093
+               21,       // *mask bit*
+               9,
                -21, -16, // 3 @ 4093
-               21,       // *mask bit* 
-               9, 
-               -21, -16, // 3 @ 4093 
-               103, -21, -16, 34, 
+               103, -21, -16, 34,
                -36, -1,  // 18 @ 4078
-               52, 15,   // 18 @ 70 
-               70, 15,   // 18 @ 88 
+               52, 15,   // 18 @ 70
+               70, 15,   // 18 @ 88
                120,      // *mask bit*
-               88, 15,   // 18 @ 106 
-               -7, -2,   // 17 @ 11 
+               88, 15,   // 18 @ 106
+               -7, -2,   // 17 @ 11
                -28, -9,  // 10 @ 4086
-               -123, 21, 0, 44, 
-               -122, 1,  // 4 @ 152 
-               -4,       // *mask bit* 
-               104, 15,  // 18 @ 122 
-               -24, -13, 40, -98, 32, 
-               78, 102, -67, -1, -2, -30, 64, 40, -67, -113, -73, 116, -98, 
-               -85, 2, 66, 123, 9, 109, -85, 2, -89, 14, -56, -69, -83, -79, 
-               -34, -3, 120, 110, 75, -9, -10, 20, -6, -25, -12, 22, -21, -16, 
-               -12, -81, 67, 1, -128, -70, -21, -16, 84, -21, -16, 70, 0, 23, 
-               -21, -16, 76, 47, -40, 79, 1, -44, -21, -16, 32, 3, 18, 12, 17, 
-               -43, -68, 17, 16, -8, 21, 22, -1, -21, -16, -84, -1, -35, 79, 
-               -9, -10, 96, 0, 46, -21, -16, 44, -39, -41, 79, 1, 119, -13, 
-               -16, -106, -13, -16, 84, 0, 125, 26, -21, -16, 68, -38, 79, 1, 
-               17, 10, 0, -97, 50, 10, 0, 0, -42, -108, 15, 118, 31, 0, -3, 29, 
-               -21, -16, -100, -25, 79, 1, -18, 97, -36, 76, 16, -21, -16, 86, 
-               0, 36, -5, 1, -5, 79, 63, 1, -124, 98, 0, 0, 28, 3, 20, -34, -3, 
-               125, 33, -21, -16, 100, -4, 79, 1, -92, -91, 16, -22, 24, 19, 41, 
-               -21, -16, -44, -59, 16, 108, 100, 0, -21, 0, 71, -105, 18, 39, 85, 
-               17, -3, 79, 1, 95, -108, 113, 0, 0, 104, 3, 18, 49, 49, 17, -1, 64, 
-               85, 1, 0, 114, 0, 0, -93, -36, -21, -16, 100, 31, 0, 0, -40, -21, 
-               -16, -92, 66, 127, 85, 1, 98, 119, 0, 0, -48, 79, 18, -3, 50, -17, 
-               1, 67, 85, 1, 81, -127, 0, -41, 0, 14, 6, 4, 17, 63, -63, 17, 68, 
-               85, -65, 1, 30, -120, 0, 0, 42, 79, 18, 68, 126, -21, -16, -76, 69, 
+               -123, 21, 0, 44,
+               -122, 1,  // 4 @ 152
+               -4,       // *mask bit*
+               104, 15,  // 18 @ 122
+               -24, -13, 40, -98, 32,
+               78, 102, -67, -1, -2, -30, 64, 40, -67, -113, -73, 116, -98,
+               -85, 2, 66, 123, 9, 109, -85, 2, -89, 14, -56, -69, -83, -79,
+               -34, -3, 120, 110, 75, -9, -10, 20, -6, -25, -12, 22, -21, -16,
+               -12, -81, 67, 1, -128, -70, -21, -16, 84, -21, -16, 70, 0, 23,
+               -21, -16, 76, 47, -40, 79, 1, -44, -21, -16, 32, 3, 18, 12, 17,
+               -43, -68, 17, 16, -8, 21, 22, -1, -21, -16, -84, -1, -35, 79,
+               -9, -10, 96, 0, 46, -21, -16, 44, -39, -41, 79, 1, 119, -13,
+               -16, -106, -13, -16, 84, 0, 125, 26, -21, -16, 68, -38, 79, 1,
+               17, 10, 0, -97, 50, 10, 0, 0, -42, -108, 15, 118, 31, 0, -3, 29,
+               -21, -16, -100, -25, 79, 1, -18, 97, -36, 76, 16, -21, -16, 86,
+               0, 36, -5, 1, -5, 79, 63, 1, -124, 98, 0, 0, 28, 3, 20, -34, -3,
+               125, 33, -21, -16, 100, -4, 79, 1, -92, -91, 16, -22, 24, 19, 41,
+               -21, -16, -44, -59, 16, 108, 100, 0, -21, 0, 71, -105, 18, 39, 85,
+               17, -3, 79, 1, 95, -108, 113, 0, 0, 104, 3, 18, 49, 49, 17, -1, 64,
+               85, 1, 0, 114, 0, 0, -93, -36, -21, -16, 100, 31, 0, 0, -40, -21,
+               -16, -92, 66, 127, 85, 1, 98, 119, 0, 0, -48, 79, 18, -3, 50, -17,
+               1, 67, 85, 1, 81, -127, 0, -41, 0, 14, 6, 4, 17, 63, -63, 17, 68,
+               85, -65, 1, 30, -120, 0, 0, 42, 79, 18, 68, 126, -21, -16, -76, 69,
                85, 1, 102, -119, 72, 37, 0, 97, 33 };
        public static final byte[] testTrailerDecomp = new byte[] {
-               -60, 2, 0, 0, 0, 1, 0, 0, -72, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 
-               0, 9, 0, 0, 0, 103, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               -123, 21, 0, 44, -123, 21, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, -98, 32, 78, 102, -67, 
-               -2, -30, 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, 40, 66, 
-               123, 9, 109, -67, -2, -30, 64, 40, -98, 32, 78, 102, -67, -2, -30, 
-               64, 40, -67, -113, -73, 116, -67, -2, -30, 64, -56, -83, -79, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 110, 75, 1, 0, 0, 0, 
-               0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, -12, -81, 67, 
-               1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0, 23, 0, 0, 0, 76, -40, 79, 1, 
-               -44, 0, 0, 0, 32, 0, 0, 0, 84, 0, 23, 0, 0, 0, -68, -40, 79, 1, -8, 
-               0, 0, 0, 32, 0, 0, 0, 84, 0, -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0, 
-               0, 0, 0, 0, 0, 96, 0, 46, 0, 0, 0, 44, -39, 79, 1, 119, 1, 0, 0, 
-               -106, 1, 0, 0, 84, 0, 26, 0, 0, 0, 68, -38, 79, 1, 17, 3, 0, 0, 
-               50, 10, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               29, 0, 0, 0, -100, -25, 79, 1, -18, 97, 0, 0, -106, 0, 0, 0, 86, 0, 
-               36, 0, 0, 0, -12, -5, 79, 1, -124, 98, 0, 0, 28, 0, 0, 0, 84, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 100, 
-               -4, 79, 1, -92, 98, 0, 0, 32, 0, 0, 0, 84, 0, 41, 0, 0, 0, -44, -4, 
-               79, 1, 108, 100, 0, 0, 71, 0, 0, 0, 86, 0, 39, 0, 0, 0, 68, -3, 79, 
-               1, -108, 113, 0, 0, 104, 0, 0, 0, 84, 0, 49, 0, 0, 0, -84, 64, 85, 
-               1, 0, 114, 0, 0, -93, 0, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, -40, 0, 0, 0, -92, 66, 85, 1, 98, 119, 
-               0, 0, -48, 1, 0, 0, 84, 0, 50, 0, 0, 0, 20, 67, 85, 1, 81, -127, 
-               0, 0, 14, 6, 0, 0, 84, 0, 63, 0, 0, 0, 100, 68, 85, 1, 30, -120, 
-               0, 0, 42, 1, 0, 0, 84, 0, 68, 0, 0, 0, -76, 69, 85, 1, 102, -119, 
+               -60, 2, 0, 0, 0, 1, 0, 0, -72, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0,
+               0, 9, 0, 0, 0, 103, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               -123, 21, 0, 44, -123, 21, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, -98, 32, 78, 102, -67,
+               -2, -30, 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, 40, 66,
+               123, 9, 109, -67, -2, -30, 64, 40, -98, 32, 78, 102, -67, -2, -30,
+               64, 40, -67, -113, -73, 116, -67, -2, -30, 64, -56, -83, -79, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 110, 75, 1, 0, 0, 0,
+               0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, -12, -81, 67,
+               1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0, 23, 0, 0, 0, 76, -40, 79, 1,
+               -44, 0, 0, 0, 32, 0, 0, 0, 84, 0, 23, 0, 0, 0, -68, -40, 79, 1, -8,
+               0, 0, 0, 32, 0, 0, 0, 84, 0, -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0,
+               0, 0, 0, 0, 0, 96, 0, 46, 0, 0, 0, 44, -39, 79, 1, 119, 1, 0, 0,
+               -106, 1, 0, 0, 84, 0, 26, 0, 0, 0, 68, -38, 79, 1, 17, 3, 0, 0,
+               50, 10, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               29, 0, 0, 0, -100, -25, 79, 1, -18, 97, 0, 0, -106, 0, 0, 0, 86, 0,
+               36, 0, 0, 0, -12, -5, 79, 1, -124, 98, 0, 0, 28, 0, 0, 0, 84, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 100,
+               -4, 79, 1, -92, 98, 0, 0, 32, 0, 0, 0, 84, 0, 41, 0, 0, 0, -44, -4,
+               79, 1, 108, 100, 0, 0, 71, 0, 0, 0, 86, 0, 39, 0, 0, 0, 68, -3, 79,
+               1, -108, 113, 0, 0, 104, 0, 0, 0, 84, 0, 49, 0, 0, 0, -84, 64, 85,
+               1, 0, 114, 0, 0, -93, 0, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, -40, 0, 0, 0, -92, 66, 85, 1, 98, 119,
+               0, 0, -48, 1, 0, 0, 84, 0, 50, 0, 0, 0, 20, 67, 85, 1, 81, -127,
+               0, 0, 14, 6, 0, 0, 84, 0, 63, 0, 0, 0, 100, 68, 85, 1, 30, -120,
+               0, 0, 42, 1, 0, 0, 84, 0, 68, 0, 0, 0, -76, 69, 85, 1, 102, -119,
                0, 0, 42, 1, 0, 0, 84, 0, 0, 0, 0, 0
        };
-       
+
        public void testFromToInt() throws Exception {
                byte b255 = -1;
                assertEquals(255, HDGFLZW.fromByte(b255));
                assertEquals(-1, HDGFLZW.fromInt( HDGFLZW.fromByte(b255) ));
                assertEquals(-1, HDGFLZW.fromInt( 255 ));
-               
+
                byte b11 = 11;
                assertEquals(11, HDGFLZW.fromByte(b11));
                assertEquals(11, HDGFLZW.fromInt( HDGFLZW.fromByte(b11) ));
                assertEquals(11, HDGFLZW.fromInt( 11 ));
-               
+
                byte b0 = 0;
                assertEquals(0, HDGFLZW.fromByte(b0));
                assertEquals(0, HDGFLZW.fromInt( HDGFLZW.fromByte(b0) ));
                assertEquals(0, HDGFLZW.fromInt( 0 ));
-               
+
                byte b127 = 127;
                assertEquals(127, HDGFLZW.fromByte(b127));
                assertEquals(127, HDGFLZW.fromInt( HDGFLZW.fromByte(b127) ));
                assertEquals(127, HDGFLZW.fromInt( 127 ));
-               
+
                byte b128 = -128;
                assertEquals(128, HDGFLZW.fromByte(b128));
                assertEquals(-128, HDGFLZW.fromInt( HDGFLZW.fromByte(b128) ));
                assertEquals(-128, HDGFLZW.fromInt( 128 ));
        }
-       
+
        public void testCounts() throws Exception {
                assertEquals(339, testTrailerComp.length);
                assertEquals(632, testTrailerDecomp.length);
-               
+
                // Decode it using our engine
                HDGFLZW lzw = new HDGFLZW();
                byte[] dec = lzw.decode(new ByteArrayInputStream(testTrailerComp));
-               
+
                // Check it's of the right size
                assertEquals(632, dec.length);
 
-/*             
+/*
                // Encode it again using our engine
                byte[] comp = lzw.compress(new ByteArrayInputStream(testTrailerDecomp));
-               
+
                // Check it's of the right size
                assertEquals(339, comp.length);
 */
        }
-       
+
        public void testDecompress() throws Exception {
                assertEquals(339, testTrailerComp.length);
                assertEquals(632, testTrailerDecomp.length);
-               
+
                // Decode it using our engine
                HDGFLZW lzw = new HDGFLZW();
                byte[] dec = lzw.decode(new ByteArrayInputStream(testTrailerComp));
-               
+
                // Now check it's the right data
                assertEquals(632, dec.length);
                for(int i=0; i<dec.length; i++) {
-                       if(dec[i] != testTrailerDecomp[i]) 
+                       if(dec[i] != testTrailerDecomp[i])
                                System.err.println(i + "\t" + dec[i] + "\t" + testTrailerDecomp[i]);
                }
        }
-       
+
        public void DISABLEDtestCompress() throws Exception {
                assertEquals(339, testTrailerComp.length);
                assertEquals(632, testTrailerDecomp.length);
-               
+
                // Compress it using our engine
                HDGFLZW lzw = new HDGFLZW();
                byte[] comp = lzw.compress(new ByteArrayInputStream(testTrailerDecomp));
-               
+
                // Now check it's the right data
                assertEquals(339, comp.length);
                for(int i=0; i<comp.length; i++) {
-                       if(comp[i] != testTrailerComp[i]) 
+                       if(comp[i] != testTrailerComp[i])
                                System.err.println(i + "\t" + comp[i] + "\t" + testTrailerComp[i]);
                }
        }
index fabe9cd8bf62c60b16c5826b6fb20b70690e9e1e..f4107c8e3a5d3105bd348cd01b1ffdeb61220716 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.chunks;
 
 import junit.framework.TestCase;
 
-public class TestChunks extends TestCase {
+public final class TestChunks extends TestCase {
 public static final byte[] data_a = new byte[] { 70, 0, 0, 0,
-       -1, -1, -1, -1, 2, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 
-       0, 0, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
-       -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 
-       0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 
-       0, 36, 0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 
-       0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       -124, 0, 0, 0, 2, 0, 85, 73, 0, 0, 0, 0, 0, 0, -56, 63, 73, 0, 0, 0, 
-       0, 0, 0, -64, 63, 63, 0, 0, 0, 0, 0, 0, -64, 63, 63, 0, 0, 0, 0, 0, 0, 
-       -64, -65, 73, 0, 0, 0, 0, 0, 0, -16, 63, 73, 0, 0, 0, 0, 0, 0, -16, 63, 
-       4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -16, 63, 0, 0, 0, 0, 0, 0, 0, 
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       1, -1, 3, 0, 0, 32, 0, 0, 0, 0, 0, -73, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 
-       79, 0, 0, 0, 2, 0, 85, 32, 32, 64, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 
-       0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 
-       8, 8, 65, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 
-       0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 1, -13, 15, 0, 0, 0, 0, 
-       -56, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 2, 0, 85, 63, 0, 0, 
-       0, 0, 0, 0, -48, 63, 63, 0, 0, 0, 0, 0, 0, -48, 63, 63, 0, 0, 0, 0, 0, 
-       0, -48, 63, 63, 0, 0, 0, 0, 0, 0, -48, 63, 0, 0, 0, 0, 0, 0, -16, 63, 
-       0, 0, 0, 0, 0, 0, -16, 63, 1, 0, 1, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 
-       0, 1, -1, 15, 7, 0, 0, 0, 0, 101, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 28, 
-       0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       -125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 2, 0, 85, 5, 0, 0, 
+       -1, -1, -1, -1, 2, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0,
+       0, 0, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0,
+       0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
+       0, 36, 0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
+       0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       -124, 0, 0, 0, 2, 0, 85, 73, 0, 0, 0, 0, 0, 0, -56, 63, 73, 0, 0, 0,
+       0, 0, 0, -64, 63, 63, 0, 0, 0, 0, 0, 0, -64, 63, 63, 0, 0, 0, 0, 0, 0,
+       -64, -65, 73, 0, 0, 0, 0, 0, 0, -16, 63, 73, 0, 0, 0, 0, 0, 0, -16, 63,
+       4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -16, 63, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       1, -1, 3, 0, 0, 32, 0, 0, 0, 0, 0, -73, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
+       79, 0, 0, 0, 2, 0, 85, 32, 32, 64, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0,
+       0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0,
+       8, 8, 65, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0,
+       0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 1, -13, 15, 0, 0, 0, 0,
+       -56, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 2, 0, 85, 63, 0, 0,
+       0, 0, 0, 0, -48, 63, 63, 0, 0, 0, 0, 0, 0, -48, 63, 63, 0, 0, 0, 0, 0,
+       0, -48, 63, 63, 0, 0, 0, 0, 0, 0, -48, 63, 0, 0, 0, 0, 0, 0, -16, 63,
+       0, 0, 0, 0, 0, 0, -16, 63, 1, 0, 1, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0,
+       0, 1, -1, 15, 7, 0, 0, 0, 0, 101, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 28,
+       0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       -125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 2, 0, 85, 5, 0, 0,
        0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
 };
 public static final byte[] data_b = new byte[] { 70, 0, 0, 0,
-       -1, -1, -1, -1, 3, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 
-       0, 0, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
+       -1, -1, -1, -1, 3, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0,
+       0, 0, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0,      0, 0, 0, -1, -1, -1, -1,
        0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, 0, 0, 0, 0, 0, 0,
-       0, 2, 0, 0, 0, 32, 0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       0, 1, 0, 0, 0, 0, 0, 0, 0, -110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -124, 
-       0, 0, 0, 2, 0, 85, 63, 0, 0, 0, 0, 0, 0, 33, 64, 63, 0, 0, 0, 0, 0, 0, 
-       38, 64, 63, 0, 0, 0, 0, 0, 0, -64, 63, 63, 0, 0, 0, 0, 0, 0, -64, -65, 
-       73, 0, 0, 0, 0, 0, 0, -16, 63, 73, 0, 0, 0, 0, 0, 0, -16, 63, 0, 0, 0, 
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -16, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 3, 
-       0, 4, 32, 0, 0, 0, 0, 0, -56, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 
-       0, 2, 0, 85, 63, 0, 0, 0, 0, 0, 0, -48, 63, 63, 0, 0, 0, 0, 0, 0, -48, 
-       63, 63, 0, 0, 0, 0, 0, 0, -48, 63, 63, 0, 0, 0, 0, 0, 0, -48, 63, 0, 0, 
-       0, 0, 0, 0, -16, 63, 0, 0, 0, 0, 0, 0, -16, 63, 1, 0, 1, 0, 0, 1, 1, 0, 
-       7, 0, 0, 0, 0, 0, 0, 0, 1, -1, 15, 7, 0, 0, 0, 0, 101, 0, 0, 0, 1, 0, 0, 
-       0, 1, 0, 0, 0, 28, 0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       0, 0, 0, 0, 0, -125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 2, 0, 
-       85, 5, 0, 0, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, -55, 0, 0, 0, 2, 0, 0, 0, 
-       0, 0, 0, 0, -122, 0, 0, 0, 1, 0, 80, 1, 0, 0, 0, 60, 0, 0, 0, 60, 0, 0, 
-       0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+       0, 2, 0, 0, 0, 32, 0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 1, 0, 0, 0, 0, 0, 0, 0, -110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -124,
+       0, 0, 0, 2, 0, 85, 63, 0, 0, 0, 0, 0, 0, 33, 64, 63, 0, 0, 0, 0, 0, 0,
+       38, 64, 63, 0, 0, 0, 0, 0, 0, -64, 63, 63, 0, 0, 0, 0, 0, 0, -64, -65,
+       73, 0, 0, 0, 0, 0, 0, -16, 63, 73, 0, 0, 0, 0, 0, 0, -16, 63, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -16, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 3,
+       0, 4, 32, 0, 0, 0, 0, 0, -56, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
+       0, 2, 0, 85, 63, 0, 0, 0, 0, 0, 0, -48, 63, 63, 0, 0, 0, 0, 0, 0, -48,
+       63, 63, 0, 0, 0, 0, 0, 0, -48, 63, 63, 0, 0, 0, 0, 0, 0, -48, 63, 0, 0,
+       0, 0, 0, 0, -16, 63, 0, 0, 0, 0, 0, 0, -16, 63, 1, 0, 1, 0, 0, 1, 1, 0,
+       7, 0, 0, 0, 0, 0, 0, 0, 1, -1, 15, 7, 0, 0, 0, 0, 101, 0, 0, 0, 1, 0, 0,
+       0, 1, 0, 0, 0, 28, 0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, -125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 2, 0,
+       85, 5, 0, 0, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, -55, 0, 0, 0, 2, 0, 0, 0,
+       0, 0, 0, 0, -122, 0, 0, 0, 1, 0, 80, 1, 0, 0, 0, 60, 0, 0, 0, 60, 0, 0,
+       0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0
 };
 
        public void testChunkHeaderA() throws Exception {
                ChunkFactory cf = new ChunkFactory(11);
-               ChunkHeader h = 
+               ChunkHeader h =
                        ChunkHeader.createChunkHeader(11, data_a, 0);
-               
+
                assertTrue(h instanceof ChunkHeaderV11);
                ChunkHeaderV11 header = (ChunkHeaderV11)h;
-               
+
                assertEquals(70, header.getType());
                assertEquals(-1, header.getId());
                assertEquals(2, header.getUnknown1());
                assertEquals(68, header.getLength());
                assertEquals(0, header.getUnknown2());
                assertEquals(0, header.getUnknown3());
-               
+
                assertTrue(header.hasTrailer());
                assertTrue(header.hasSeparator());
        }
        public void testChunkHeaderB() throws Exception {
                ChunkFactory cf = new ChunkFactory(11);
-               ChunkHeader h = 
+               ChunkHeader h =
                        ChunkHeader.createChunkHeader(11, data_b, 0);
-               
+
                assertTrue(h instanceof ChunkHeaderV11);
                ChunkHeaderV11 header = (ChunkHeaderV11)h;
-               
+
                assertEquals(70, header.getType());
                assertEquals(-1, header.getId());
                assertEquals(3, header.getUnknown1());
                assertEquals(68, header.getLength());
                assertEquals(0, header.getUnknown2());
                assertEquals(0, header.getUnknown3());
-               
+
                assertTrue(header.hasTrailer());
                assertTrue(header.hasSeparator());
        }
-       
+
        public void testOneChunk() throws Exception {
                ChunkFactory cf = new ChunkFactory(11);
                cf.createChunk(data_a, 0);
                cf.createChunk(data_b, 0);
-               
+
                Chunk chunk = cf.createChunk(data_a, 0);
                assertNotNull(chunk.getHeader());
                assertNotNull(chunk.getTrailer());
                assertNotNull(chunk.getSeparator());
-               
+
                // Should be 19 + length + 8 + 4 big
                assertEquals(68, chunk.getHeader().getLength());
                assertEquals(68+19+8+4, chunk.getOnDiskSize());
-               
+
                // Type is 70, or 0x46
                assertEquals(70, chunk.getHeader().getType());
                assertEquals(0x46, chunk.getHeader().getType());
-               
+
                // Should have two virtual chunk commands, a
                //  10 (page sheet) and an 18
                assertEquals(2, chunk.commandDefinitions.length);
                assertEquals(0, chunk.getCommands().length);
-               
+
                assertEquals(10, chunk.commandDefinitions[0].getType());
                assertEquals(0, chunk.commandDefinitions[0].getOffset());
                assertEquals("PageSheet", chunk.commandDefinitions[0].getName());
-               
+
                assertEquals(18, chunk.commandDefinitions[1].getType());
                assertEquals(0, chunk.commandDefinitions[1].getOffset());
                assertEquals("0", chunk.commandDefinitions[1].getName());
        }
-       
+
        public void testAnotherChunk() throws Exception {
                ChunkFactory cf = new ChunkFactory(11);
-               
+
                // Go for the 2nd chunk in the stream
                int offset = 0;
                Chunk chunk = cf.createChunk(data_b, offset);
                offset += chunk.getOnDiskSize();
                chunk = cf.createChunk(data_b, offset);
-               
+
                assertNotNull(chunk.getHeader());
                assertNotNull(chunk.getTrailer());
                assertNotNull(chunk.getSeparator());
-               
+
                // Should be 19 + length + 8 + 4 big
                assertEquals(32, chunk.getHeader().getLength());
                assertEquals(32+19+8+4, chunk.getOnDiskSize());
-               
+
                // Type is 104, or 0x68
                assertEquals(104, chunk.getHeader().getType());
                assertEquals(0x68, chunk.getHeader().getType());
-               
+
                // Should have two virtual chunk commands, a
                //  10 (Unknown) and an 18
                assertEquals(2, chunk.commandDefinitions.length);
                assertEquals(0, chunk.getCommands().length);
-               
+
                assertEquals(10, chunk.commandDefinitions[0].getType());
                assertEquals(0, chunk.commandDefinitions[0].getOffset());
                assertEquals("PropList", chunk.commandDefinitions[0].getName());
-               
+
                assertEquals(18, chunk.commandDefinitions[1].getType());
                assertEquals(0, chunk.commandDefinitions[1].getOffset());
                assertEquals("0", chunk.commandDefinitions[1].getName());
        }
-       
+
        public void testManyChunks() throws Exception {
                ChunkFactory cf = new ChunkFactory(11);
                Chunk chunk;
                int offset = 0;
-               
+
                chunk = cf.createChunk(data_a, offset);
                assertNotNull(chunk.getHeader());
                assertNotNull(chunk.getTrailer());
                assertNotNull(chunk.getSeparator());
                offset += chunk.getOnDiskSize();
-               
+
                chunk = cf.createChunk(data_a, offset);
                assertNotNull(chunk.getHeader());
                assertNotNull(chunk.getTrailer());
                assertNotNull(chunk.getSeparator());
                offset += chunk.getOnDiskSize();
-               
+
                // Has a separator but no trailer
                chunk = cf.createChunk(data_a, offset);
                assertNotNull(chunk.getHeader());
                assertNull(chunk.getTrailer());
                assertNotNull(chunk.getSeparator());
                offset += chunk.getOnDiskSize();
-               
+
                chunk = cf.createChunk(data_a, offset);
                assertNotNull(chunk.getHeader());
                assertNull(chunk.getTrailer());
                assertNotNull(chunk.getSeparator());
                offset += chunk.getOnDiskSize();
-               
+
                chunk = cf.createChunk(data_a, offset);
                assertNotNull(chunk.getHeader());
                assertNull(chunk.getTrailer());
index 8f890db3aa3d049fd4a17da554f8572595a7063d..a24733c919a2491d4c2b5111d67146328e86e10a 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.extractor;
 
 import java.io.ByteArrayOutputStream;
@@ -26,25 +27,25 @@ import junit.framework.TestCase;
 import org.apache.poi.hdgf.HDGFDiagram;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
-public class TestVisioExtractor extends TestCase {
+public final class TestVisioExtractor extends TestCase {
        private String dirname;
        private String defFilename;
        protected void setUp() throws Exception {
                dirname = System.getProperty("HDGF.testdata.path");
                defFilename = dirname + "/Test_Visio-Some_Random_Text.vsd";
        }
-       
+
        /**
         * Test the 3 different ways of creating one
         */
        public void testCreation() throws Exception {
                VisioTextExtractor extractor;
-               
+
                extractor = new VisioTextExtractor(new FileInputStream(defFilename));
                assertNotNull(extractor);
                assertNotNull(extractor.getAllText());
                assertEquals(3, extractor.getAllText().length);
-               
+
                extractor = new VisioTextExtractor(
                                new POIFSFileSystem(
                                                new FileInputStream(defFilename)
@@ -53,7 +54,7 @@ public class TestVisioExtractor extends TestCase {
                assertNotNull(extractor);
                assertNotNull(extractor.getAllText());
                assertEquals(3, extractor.getAllText().length);
-               
+
                extractor = new VisioTextExtractor(
                        new HDGFDiagram(
                                new POIFSFileSystem(
@@ -65,53 +66,53 @@ public class TestVisioExtractor extends TestCase {
                assertNotNull(extractor.getAllText());
                assertEquals(3, extractor.getAllText().length);
        }
-       
+
        public void testExtraction() throws Exception {
                VisioTextExtractor extractor =
                        new VisioTextExtractor(new FileInputStream(defFilename));
-               
+
                // Check the array fetch
                String[] text = extractor.getAllText();
                assertNotNull(text);
                assertEquals(3, text.length);
-               
+
                assertEquals("Test View\n", text[0]);
                assertEquals("I am a test view\n", text[1]);
                assertEquals("Some random text, on a page\n", text[2]);
-               
+
                // And the all-in fetch
                String textS = extractor.getText();
                assertEquals("Test View\nI am a test view\nSome random text, on a page\n", textS);
        }
-       
+
        public void testProblemFiles() throws Exception {
                File a = new File(dirname, "44594.vsd");
                VisioTextExtractor.main(new String[] {a.toString()});
-               
+
                File b = new File(dirname, "44594-2.vsd");
                VisioTextExtractor.main(new String[] {b.toString()});
-               
+
                File c = new File(dirname, "ShortChunk1.vsd");
                VisioTextExtractor.main(new String[] {c.toString()});
-               
+
                File d = new File(dirname, "ShortChunk2.vsd");
                VisioTextExtractor.main(new String[] {d.toString()});
-               
+
                File e = new File(dirname, "ShortChunk3.vsd");
                VisioTextExtractor.main(new String[] {e.toString()});
        }
-       
+
        public void testMain() throws Exception {
                PrintStream oldOut = System.out;
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                PrintStream capture = new PrintStream(baos);
                System.setOut(capture);
-               
+
                VisioTextExtractor.main(new String[] {defFilename});
-               
+
                // Put things back
                System.setOut(oldOut);
-               
+
                // Check
                capture.flush();
                String text = baos.toString();
index 25316b39b8f89bab469e242deedf38c131e258aa..aaed0fd6f86efda25a36fb1a8b3e9956332c1453 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.pointers;
 
 import junit.framework.TestCase;
@@ -21,14 +22,14 @@ import junit.framework.TestCase;
 /**
  * Tests for the pointer factory, and the pointers themselves
  */
-public class TestPointerFactory extends TestCase {
+public final class TestPointerFactory extends TestCase {
        // Type: 16   Addr: 0143aff4  Offset: 80   Len: 54   Format: 46   From: 8a94
        private static byte[] vp6_a = new byte[] {
                22, 0, 0, 0, -12, -81, 67, 1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0
        };
        // Type: 17   Addr: 014fd84c  Offset: d4   Len: 20   Format: 54   From: 8a94
        private static byte[] vp6_b = new byte[] {
-               23, 0, 0, 0, 76, -40, 79, 1, -44, 0, 0, 0, 32, 0, 0, 0, 84, 0 
+               23, 0, 0, 0, 76, -40, 79, 1, -44, 0, 0, 0, 32, 0, 0, 0, 84, 0
        };
        // Type: 17   Addr: 014fd8bc  Offset: f8   Len: 20   Format: 54   From: 8a94
        private static byte[] vp6_c = new byte[] {
@@ -38,7 +39,7 @@ public class TestPointerFactory extends TestCase {
        private static byte[] vp6_d = new byte[] {
                -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0
        };
-       
+
        public void testCreateV4() throws Exception {
                PointerFactory pf = new PointerFactory(4);
                try {
@@ -48,7 +49,7 @@ public class TestPointerFactory extends TestCase {
                        // As expected
                }
        }
-       
+
        public void testCreateV5() throws Exception {
                PointerFactory pf = new PointerFactory(5);
                try {
@@ -62,46 +63,46 @@ public class TestPointerFactory extends TestCase {
 
        public void testCreateV6() throws Exception {
                PointerFactory pf = new PointerFactory(6);
-               
+
                Pointer a = pf.createPointer(vp6_a, 0);
                assertEquals(0x16, a.getType());
                assertEquals(0x0143aff4, a.getAddress());
                assertEquals(0x80, a.getOffset());
                assertEquals(0x54, a.getLength());
                assertEquals(0x46, a.getFormat());
-               
+
                assertTrue(a.destinationCompressed());
                assertTrue(a.destinationHasStrings());
                assertFalse(a.destinationHasChunks());
                assertFalse(a.destinationHasPointers());
-               
+
                assertEquals(18, a.getSizeInBytes());
-               
-               
+
+
                Pointer b = pf.createPointer(vp6_b, 0);
                assertEquals(0x17, b.getType());
                assertEquals(0x014fd84c, b.getAddress());
                assertEquals(0xd4, b.getOffset());
                assertEquals(0x20, b.getLength());
                assertEquals(0x54, b.getFormat());
-               
+
                assertFalse(b.destinationCompressed());
                assertFalse(b.destinationHasStrings());
                assertFalse(b.destinationHasChunks());
                assertTrue(b.destinationHasPointers());
-               
+
                Pointer c = pf.createPointer(vp6_c, 0);
                assertEquals(0x17, c.getType());
                assertEquals(0x014fd8bc, c.getAddress());
                assertEquals(0xf8, c.getOffset());
                assertEquals(0x20, c.getLength());
                assertEquals(0x54, c.getFormat());
-               
+
                assertFalse(c.destinationCompressed());
                assertFalse(c.destinationHasStrings());
                assertFalse(c.destinationHasChunks());
                assertTrue(c.destinationHasPointers());
-               
+
                // Type: ff   Addr: 014fffac  Offset: 0    Len:  0   Format: 60   From: 8a94
                Pointer d = pf.createPointer(vp6_d, 0);
                assertEquals(0xff, d.getType());
@@ -109,7 +110,7 @@ public class TestPointerFactory extends TestCase {
                assertEquals(0x00, d.getOffset());
                assertEquals(0x00, d.getLength());
                assertEquals(0x60, d.getFormat());
-               
+
                assertFalse(d.destinationCompressed());
                assertFalse(d.destinationHasStrings());
                assertFalse(d.destinationHasChunks());
@@ -118,19 +119,19 @@ public class TestPointerFactory extends TestCase {
 
        public void testCreateV6FromMid() throws Exception {
                PointerFactory pf = new PointerFactory(11);
-               
+
                // Create a from part way down the byte stream
                byte[] bytes = new byte[28];
                System.arraycopy(vp6_b, 0, bytes, 0, 10);
                System.arraycopy(vp6_a, 0, bytes, 10, 18);
-               
+
                Pointer a = pf.createPointer(bytes, 10);
                assertEquals(0x16, a.getType());
                assertEquals(0x0143aff4, a.getAddress());
                assertEquals(0x80, a.getOffset());
                assertEquals(0x54, a.getLength());
                assertEquals(0x46, a.getFormat());
-               
+
                assertTrue(a.destinationCompressed());
                assertTrue(a.destinationHasStrings());
                assertFalse(a.destinationHasChunks());
index f71af640ed72b3c94677926ede0790a07530e9b8..41d1132782020280d88b726e959bb193a5e4ac30 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.streams;
 
 import org.apache.poi.hdgf.pointers.Pointer;
index 6c4024db9dad506d72827de6984cb603e0ad93b1..26c91d0d191f1075730c5e9b4c2b124db70b6325 100644 (file)
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.streams;
 
 import org.apache.poi.hdgf.pointers.Pointer;
 
-public class TestStreamBasics extends StreamTest {
+public final class TestStreamBasics extends StreamTest {
        /** The header from when compressedStream is decompressed */
        public static final byte[] compressedStreamDCHeader = new byte[] {
                -60, 2, 0, 0
        };
        public static final byte[] compressedStream = new byte[] {
-               123, -60, 2, -21, -16, 1, 0, 0, -72, -13, -16, 78, -32, -5, 1, 
-               0, 3, -21, -16, 10, 5, 4, -21, -16, 21, 9, -21, -16, 103, -21, 
-               -16, 34, -36, -1, 52, 15, 70, 15, 120, 88, 15, -7, -2, -28, -9, 
-               -123, 21, 0, 44, -122, 1, -4, 104, 15, -24, -13, 40, -98, 32, 
-               78, 102, -67, -1, -2, -30, 64, 40, -67, -113, -73, 116, -98, 
-               -85, 2, 66, 123, 9, 109, -85, 2, -89, 14, -56, -69, -83, -79, 
-               -34, -3, 120, 110, 75, -9, -10, 20, -6, -25, -12, 22, -21, -16, 
-               -12, -81, 67, 1, -128, -70, -21, -16, 84, -21, -16, 70, 0, 23, 
-               -21, -16, 76, 47, -40, 79, 1, -44, -21, -16, 32, 3, 18, 12, 17, 
-               -43, -68, 17, 16, -8, 21, 22, -1, -21, -16, -84, -1, -35, 79, 
-               -9, -10, 96, 0, 46, -21, -16, 44, -39, -41, 79, 1, 119, -13, 
-               -16, -106, -13, -16, 84, 0, 125, 26, -21, -16, 68, -38, 79, 1, 
-               17, 10, 0, -97, 50, 10, 0, 0, -42, -108, 15, 118, 31, 0, -3, 29, 
-               -21, -16, -100, -25, 79, 1, -18, 97, -36, 76, 16, -21, -16, 86, 
-               0, 36, -5, 1, -5, 79, 63, 1, -124, 98, 0, 0, 28, 3, 20, -34, -3, 
-               125, 33, -21, -16, 100, -4, 79, 1, -92, -91, 16, -22, 24, 19, 41, 
-               -21, -16, -44, -59, 16, 108, 100, 0, -21, 0, 71, -105, 18, 39, 85, 
-               17, -3, 79, 1, 95, -108, 113, 0, 0, 104, 3, 18, 49, 49, 17, -1, 64, 
-               85, 1, 0, 114, 0, 0, -93, -36, -21, -16, 100, 31, 0, 0, -40, -21, 
-               -16, -92, 66, 127, 85, 1, 98, 119, 0, 0, -48, 79, 18, -3, 50, -17, 
-               1, 67, 85, 1, 81, -127, 0, -41, 0, 14, 6, 4, 17, 63, -63, 17, 68, 
-               85, -65, 1, 30, -120, 0, 0, 42, 79, 18, 68, 126, -21, -16, -76, 69, 
+               123, -60, 2, -21, -16, 1, 0, 0, -72, -13, -16, 78, -32, -5, 1,
+               0, 3, -21, -16, 10, 5, 4, -21, -16, 21, 9, -21, -16, 103, -21,
+               -16, 34, -36, -1, 52, 15, 70, 15, 120, 88, 15, -7, -2, -28, -9,
+               -123, 21, 0, 44, -122, 1, -4, 104, 15, -24, -13, 40, -98, 32,
+               78, 102, -67, -1, -2, -30, 64, 40, -67, -113, -73, 116, -98,
+               -85, 2, 66, 123, 9, 109, -85, 2, -89, 14, -56, -69, -83, -79,
+               -34, -3, 120, 110, 75, -9, -10, 20, -6, -25, -12, 22, -21, -16,
+               -12, -81, 67, 1, -128, -70, -21, -16, 84, -21, -16, 70, 0, 23,
+               -21, -16, 76, 47, -40, 79, 1, -44, -21, -16, 32, 3, 18, 12, 17,
+               -43, -68, 17, 16, -8, 21, 22, -1, -21, -16, -84, -1, -35, 79,
+               -9, -10, 96, 0, 46, -21, -16, 44, -39, -41, 79, 1, 119, -13,
+               -16, -106, -13, -16, 84, 0, 125, 26, -21, -16, 68, -38, 79, 1,
+               17, 10, 0, -97, 50, 10, 0, 0, -42, -108, 15, 118, 31, 0, -3, 29,
+               -21, -16, -100, -25, 79, 1, -18, 97, -36, 76, 16, -21, -16, 86,
+               0, 36, -5, 1, -5, 79, 63, 1, -124, 98, 0, 0, 28, 3, 20, -34, -3,
+               125, 33, -21, -16, 100, -4, 79, 1, -92, -91, 16, -22, 24, 19, 41,
+               -21, -16, -44, -59, 16, 108, 100, 0, -21, 0, 71, -105, 18, 39, 85,
+               17, -3, 79, 1, 95, -108, 113, 0, 0, 104, 3, 18, 49, 49, 17, -1, 64,
+               85, 1, 0, 114, 0, 0, -93, -36, -21, -16, 100, 31, 0, 0, -40, -21,
+               -16, -92, 66, 127, 85, 1, 98, 119, 0, 0, -48, 79, 18, -3, 50, -17,
+               1, 67, 85, 1, 81, -127, 0, -41, 0, 14, 6, 4, 17, 63, -63, 17, 68,
+               85, -65, 1, 30, -120, 0, 0, 42, 79, 18, 68, 126, -21, -16, -76, 69,
                85, 1, 102, -119, 72, 37, 0, 97, 33 };
        public static final byte[] uncompressedStream = new byte[] {
-               0, 1, 0, 0, -72, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 
-               0, 9, 0, 0, 0, 103, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               -123, 21, 0, 44, -123, 21, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, -98, 32, 78, 102, -67, 
-               -2, -30, 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, 40, 66, 
-               123, 9, 109, -67, -2, -30, 64, 40, -98, 32, 78, 102, -67, -2, -30, 
-               64, 40, -67, -113, -73, 116, -67, -2, -30, 64, -56, -83, -79, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 110, 75, 1, 0, 0, 0, 
-               0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, -12, -81, 67, 
-               1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0, 23, 0, 0, 0, 76, -40, 79, 1, 
-               -44, 0, 0, 0, 32, 0, 0, 0, 84, 0, 23, 0, 0, 0, -68, -40, 79, 1, -8, 
-               0, 0, 0, 32, 0, 0, 0, 84, 0, -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0, 
-               0, 0, 0, 0, 0, 96, 0, 46, 0, 0, 0, 44, -39, 79, 1, 119, 1, 0, 0, 
-               -106, 1, 0, 0, 84, 0, 26, 0, 0, 0, 68, -38, 79, 1, 17, 3, 0, 0, 
-               50, 10, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               29, 0, 0, 0, -100, -25, 79, 1, -18, 97, 0, 0, -106, 0, 0, 0, 86, 0, 
-               36, 0, 0, 0, -12, -5, 79, 1, -124, 98, 0, 0, 28, 0, 0, 0, 84, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 100, 
-               -4, 79, 1, -92, 98, 0, 0, 32, 0, 0, 0, 84, 0, 41, 0, 0, 0, -44, -4, 
-               79, 1, 108, 100, 0, 0, 71, 0, 0, 0, 86, 0, 39, 0, 0, 0, 68, -3, 79, 
-               1, -108, 113, 0, 0, 104, 0, 0, 0, 84, 0, 49, 0, 0, 0, -84, 64, 85, 
-               1, 0, 114, 0, 0, -93, 0, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-               0, 0, 0, 0, 0, 0, 0, 0, 0, -40, 0, 0, 0, -92, 66, 85, 1, 98, 119, 
-               0, 0, -48, 1, 0, 0, 84, 0, 50, 0, 0, 0, 20, 67, 85, 1, 81, -127, 
-               0, 0, 14, 6, 0, 0, 84, 0, 63, 0, 0, 0, 100, 68, 85, 1, 30, -120, 
-               0, 0, 42, 1, 0, 0, 84, 0, 68, 0, 0, 0, -76, 69, 85, 1, 102, -119, 
+               0, 1, 0, 0, -72, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0,
+               0, 9, 0, 0, 0, 103, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               -123, 21, 0, 44, -123, 21, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, -98, 32, 78, 102, -67,
+               -2, -30, 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, 40, 66,
+               123, 9, 109, -67, -2, -30, 64, 40, -98, 32, 78, 102, -67, -2, -30,
+               64, 40, -67, -113, -73, 116, -67, -2, -30, 64, -56, -83, -79, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 110, 75, 1, 0, 0, 0,
+               0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, -12, -81, 67,
+               1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0, 23, 0, 0, 0, 76, -40, 79, 1,
+               -44, 0, 0, 0, 32, 0, 0, 0, 84, 0, 23, 0, 0, 0, -68, -40, 79, 1, -8,
+               0, 0, 0, 32, 0, 0, 0, 84, 0, -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0,
+               0, 0, 0, 0, 0, 96, 0, 46, 0, 0, 0, 44, -39, 79, 1, 119, 1, 0, 0,
+               -106, 1, 0, 0, 84, 0, 26, 0, 0, 0, 68, -38, 79, 1, 17, 3, 0, 0,
+               50, 10, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               29, 0, 0, 0, -100, -25, 79, 1, -18, 97, 0, 0, -106, 0, 0, 0, 86, 0,
+               36, 0, 0, 0, -12, -5, 79, 1, -124, 98, 0, 0, 28, 0, 0, 0, 84, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 100,
+               -4, 79, 1, -92, 98, 0, 0, 32, 0, 0, 0, 84, 0, 41, 0, 0, 0, -44, -4,
+               79, 1, 108, 100, 0, 0, 71, 0, 0, 0, 86, 0, 39, 0, 0, 0, 68, -3, 79,
+               1, -108, 113, 0, 0, 104, 0, 0, 0, 84, 0, 49, 0, 0, 0, -84, 64, 85,
+               1, 0, 114, 0, 0, -93, 0, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, -40, 0, 0, 0, -92, 66, 85, 1, 98, 119,
+               0, 0, -48, 1, 0, 0, 84, 0, 50, 0, 0, 0, 20, 67, 85, 1, 81, -127,
+               0, 0, 14, 6, 0, 0, 84, 0, 63, 0, 0, 0, 100, 68, 85, 1, 30, -120,
+               0, 0, 42, 1, 0, 0, 84, 0, 68, 0, 0, 0, -76, 69, 85, 1, 102, -119,
                0, 0, 42, 1, 0, 0, 84, 0, 0, 0, 0, 0
        };
 
@@ -88,31 +89,31 @@ public class TestStreamBasics extends StreamTest {
                Pointer ptr = new TestPointer(true, 0, compressedStream.length, -1, (short)-1);
                // Now the stream
                Stream stream = Stream.createStream(ptr, compressedStream, null, null);
-               
+
                // Check
                assertNotNull(stream.getPointer());
                assertNotNull(stream.getStore());
                assertTrue(stream.getStore() instanceof StreamStore);
                assertTrue(stream.getStore() instanceof CompressedStreamStore);
                assertTrue(stream instanceof UnknownStream);
-               
+
                // Check the stream store
                CompressedStreamStore ss = (CompressedStreamStore)stream.getStore();
                assertEquals(4, ss._getBlockHeader().length);
                assertEquals(compressedStream.length, ss._getCompressedContents().length);
                assertEquals(uncompressedStream.length, ss.getContents().length);
-               
+
                for(int i=0; i<uncompressedStream.length; i++) {
                        assertEquals(uncompressedStream[i], ss.getContents()[i]);
                }
        }
-       
+
        public void testUncompressedStream() {
                // Create a fake pointer
                Pointer ptr = new TestPointer(false, 0, uncompressedStream.length, -1, (short)-1);
                // Now the stream
                Stream stream = Stream.createStream(ptr, uncompressedStream, null, null);
-               
+
                // Check
                assertNotNull(stream.getPointer());
                assertNotNull(stream.getStore());
@@ -120,4 +121,4 @@ public class TestStreamBasics extends StreamTest {
                assertFalse(stream.getStore() instanceof CompressedStreamStore);
                assertTrue(stream instanceof UnknownStream);
        }
-}
\ No newline at end of file
+}
index 9d4cac1689235d48adbea34cc8412c815937f3e5..507c2e9579bc0d32d14bd2f27f3950ca7351cb0a 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.streams;
 
 import java.io.FileInputStream;
@@ -28,7 +29,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 /**
  * Tests for bugs with streams
  */
-public class TestStreamBugs extends StreamTest {
+public final class TestStreamBugs extends StreamTest {
        private byte[] contents;
        private ChunkFactory chunkFactory;
        private PointerFactory ptrFactory;
@@ -42,7 +43,7 @@ public class TestStreamBugs extends StreamTest {
 
                FileInputStream fin = new FileInputStream(filename);
                filesystem = new POIFSFileSystem(fin);
-               
+
                DocumentEntry docProps =
                        (DocumentEntry)filesystem.getRoot().getEntry("VisioDocument");
 
@@ -50,41 +51,41 @@ public class TestStreamBugs extends StreamTest {
                contents = new byte[docProps.getSize()];
                filesystem.createDocumentInputStream("VisioDocument").read(contents);
        }
-       
+
        public void testGetTrailer() throws Exception {
                Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
                Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
        }
-       
+
        public void TOIMPLEMENTtestGetCertainChunks() throws Exception {
                int offsetA = 3708;
                int offsetB = 3744;
        }
-       
+
        public void testGetChildren() throws Exception {
                Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
                TrailerStream trailer = (TrailerStream)
                        Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
-               
+
                // Get without recursing
                Pointer[] ptrs = trailer.getChildPointers();
                for(int i=0; i<ptrs.length; i++) {
                        Stream.createStream(ptrs[i], contents, chunkFactory, ptrFactory);
                }
-               
+
                // Get with recursing into chunks
                for(int i=0; i<ptrs.length; i++) {
-                       Stream stream = 
+                       Stream stream =
                                Stream.createStream(ptrs[i], contents, chunkFactory, ptrFactory);
                        if(stream instanceof ChunkStream) {
                                ChunkStream cStream = (ChunkStream)stream;
                                cStream.findChunks();
                        }
                }
-               
+
                // Get with recursing into chunks and pointers
                for(int i=0; i<ptrs.length; i++) {
-                       Stream stream = 
+                       Stream stream =
                                Stream.createStream(ptrs[i], contents, chunkFactory, ptrFactory);
                        if(stream instanceof PointerContainingStream) {
                                PointerContainingStream pStream =
@@ -92,7 +93,7 @@ public class TestStreamBugs extends StreamTest {
                                pStream.findChildren(contents);
                        }
                }
-               
+
                trailer.findChildren(contents);
        }
 
index 5ea21d1a1c016e4e6501d5ed9a8b2cbbedac6a7c..8f1897e00efe93d3d4e2e228bb0d678508111704 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hdgf.streams;
 
 import java.io.FileInputStream;
@@ -25,7 +26,7 @@ import org.apache.poi.hdgf.pointers.PointerFactory;
 import org.apache.poi.poifs.filesystem.DocumentEntry;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
-public class TestStreamComplex extends StreamTest {
+public final class TestStreamComplex extends StreamTest {
        private byte[] contents;
        private int trailerPointerAt = 0x24;
        private int trailerDataAt = 0x8a94;
@@ -40,7 +41,7 @@ public class TestStreamComplex extends StreamTest {
 
                FileInputStream fin = new FileInputStream(filename);
                POIFSFileSystem filesystem = new POIFSFileSystem(fin);
-               
+
                DocumentEntry docProps =
                        (DocumentEntry)filesystem.getRoot().getEntry("VisioDocument");
 
@@ -55,71 +56,71 @@ public class TestStreamComplex extends StreamTest {
        public void testTrailer() {
                // Find the trailer
                Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
-               
+
                assertEquals(20, trailerPtr.getType());
                assertEquals(trailerDataAt, trailerPtr.getOffset());
-               
+
                Stream stream = Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
                assertTrue(stream instanceof TrailerStream);
                TrailerStream ts = (TrailerStream)stream;
-               
+
                assertNotNull(ts.getChildPointers());
                assertNull(ts.getPointedToStreams());
-               
+
                assertEquals(20, ts.getChildPointers().length);
                assertEquals(0x16, ts.getChildPointers()[0].getType());
                assertEquals(0x17, ts.getChildPointers()[1].getType());
                assertEquals(0x17, ts.getChildPointers()[2].getType());
                assertEquals(0xff, ts.getChildPointers()[3].getType());
        }
-       
+
        public void testChunks() {
                Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
                TrailerStream ts = (TrailerStream)
                        Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
-               
+
                // Should be 7th one
                Pointer chunkPtr = ts.getChildPointers()[5];
                assertFalse(chunkPtr.destinationHasStrings());
                assertTrue(chunkPtr.destinationHasChunks());
                assertFalse(chunkPtr.destinationHasPointers());
-               
+
                Stream stream = Stream.createStream(chunkPtr, contents, chunkFactory, ptrFactory);
                assertNotNull(stream);
                assertTrue(stream instanceof ChunkStream);
-               
+
                // Now find the chunks within it
                ChunkStream cs = (ChunkStream)stream;
                cs.findChunks();
        }
-       
+
        public void testStrings() {
                Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
                TrailerStream ts = (TrailerStream)
                        Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
-               
+
                // Should be the 1st one
                Pointer stringPtr = ts.getChildPointers()[0];
                assertTrue(stringPtr.destinationHasStrings());
                assertFalse(stringPtr.destinationHasChunks());
                assertFalse(stringPtr.destinationHasPointers());
-               
+
                Stream stream = Stream.createStream(stringPtr, contents, chunkFactory, ptrFactory);
                assertNotNull(stream);
                assertTrue(stream instanceof StringsStream);
        }
-       
+
        public void testPointerToStrings() {
                // The stream at 0x347f has strings
                // The stream at 0x4312 has a pointer to 0x347f
                // The stream at 0x44d3 has a pointer to 0x4312
                //  (it's the 2nd one of 3, and the block is compressed)
-               
+
                TestPointer ptr44d3 = new TestPointer(true, 0x44d3, 0x51, 0x4e, (short)0x56);
                ptr44d3.hasPointers = true;
                PointerContainingStream s44d3 = (PointerContainingStream)
                        Stream.createStream(ptr44d3, contents, chunkFactory, ptrFactory);
-               
+
                // Type: 0d  Addr: 014ff644  Offset: 4312  Len: 48  Format: 54  From: 44d3
                Pointer ptr4312 = s44d3.getChildPointers()[1];
                assertEquals(0x0d, ptr4312.getType());
@@ -128,10 +129,10 @@ public class TestStreamComplex extends StreamTest {
                assertEquals(0x54, ptr4312.getFormat());
                assertTrue(ptr4312.destinationHasPointers());
                assertFalse(ptr4312.destinationHasStrings());
-               
+
                PointerContainingStream s4312 = (PointerContainingStream)
                        Stream.createStream(ptr4312, contents, chunkFactory, ptrFactory);
-               
+
                // Check it has 0x347f
                // Type: 1f  Addr: 01540004  Offset: 347f  Len: 8e8  Format: 46  From: 4312
                assertEquals(2, s4312.getChildPointers().length);
@@ -142,7 +143,7 @@ public class TestStreamComplex extends StreamTest {
                assertEquals(0x46, ptr347f.getFormat());
                assertFalse(ptr347f.destinationHasPointers());
                assertTrue(ptr347f.destinationHasStrings());
-               
+
                // Find the children of 0x4312
                assertNull(s4312.getPointedToStreams());
                s4312.findChildren(contents);
@@ -152,89 +153,89 @@ public class TestStreamComplex extends StreamTest {
                assertTrue(s4312.getPointedToStreams()[0] instanceof StringsStream);
                assertTrue(s4312.getPointedToStreams()[1] instanceof StringsStream);
        }
-       
+
        public void testTrailerContents() {
                Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
                TrailerStream ts = (TrailerStream)
                        Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
-               
+
                assertNotNull(ts.getChildPointers());
                assertNull(ts.getPointedToStreams());
                assertEquals(20, ts.getChildPointers().length);
-               
+
                ts.findChildren(contents);
-               
+
                assertNotNull(ts.getChildPointers());
                assertNotNull(ts.getPointedToStreams());
                assertEquals(20, ts.getChildPointers().length);
                assertEquals(20, ts.getPointedToStreams().length);
-               
+
                // Step down:
                // 8 -> 4 -> 5 -> 1 -> 0 == String
                assertNotNull(ts.getPointedToStreams()[8]);
                assertTrue(ts.getPointedToStreams()[8] instanceof PointerContainingStream);
-               
-               PointerContainingStream s8 = 
+
+               PointerContainingStream s8 =
                        (PointerContainingStream)ts.getPointedToStreams()[8];
                assertNotNull(s8.getPointedToStreams());
-               
+
                assertNotNull(s8.getPointedToStreams()[4]);
                assertTrue(s8.getPointedToStreams()[4] instanceof PointerContainingStream);
-               
-               PointerContainingStream s84 = 
+
+               PointerContainingStream s84 =
                        (PointerContainingStream)s8.getPointedToStreams()[4];
                assertNotNull(s84.getPointedToStreams());
-               
+
                assertNotNull(s84.getPointedToStreams()[5]);
                assertTrue(s84.getPointedToStreams()[5] instanceof PointerContainingStream);
-               
-               PointerContainingStream s845 = 
+
+               PointerContainingStream s845 =
                        (PointerContainingStream)s84.getPointedToStreams()[5];
                assertNotNull(s845.getPointedToStreams());
-               
+
                assertNotNull(s845.getPointedToStreams()[1]);
                assertTrue(s845.getPointedToStreams()[1] instanceof PointerContainingStream);
-               
-               PointerContainingStream s8451 = 
+
+               PointerContainingStream s8451 =
                        (PointerContainingStream)s845.getPointedToStreams()[1];
                assertNotNull(s8451.getPointedToStreams());
-               
+
                assertNotNull(s8451.getPointedToStreams()[0]);
                assertTrue(s8451.getPointedToStreams()[0] instanceof StringsStream);
                assertTrue(s8451.getPointedToStreams()[1] instanceof StringsStream);
        }
-       
+
        public void testChunkWithText() throws Exception {
                // Parent ChunkStream is at 0x7194
                // This is one of the last children of the trailer
                Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
                TrailerStream ts = (TrailerStream)
                        Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
-               
+
                ts.findChildren(contents);
-               
+
                assertNotNull(ts.getChildPointers());
                assertNotNull(ts.getPointedToStreams());
                assertEquals(20, ts.getChildPointers().length);
                assertEquals(20, ts.getPointedToStreams().length);
-               
+
                assertEquals(0x7194, ts.getChildPointers()[13].getOffset());
                assertEquals(0x7194, ts.getPointedToStreams()[13].getPointer().getOffset());
-               
+
                PointerContainingStream ps7194 = (PointerContainingStream)
                        ts.getPointedToStreams()[13];
-               
+
                // First child is at 0x64b3
                assertEquals(0x64b3, ps7194.getChildPointers()[0].getOffset());
                assertEquals(0x64b3, ps7194.getPointedToStreams()[0].getPointer().getOffset());
-               
+
                ChunkStream cs = (ChunkStream)ps7194.getPointedToStreams()[0];
-               
+
                // Should be 26bc bytes un-compressed
                assertEquals(0x26bc, cs.getStore().getContents().length);
                // And should have lots of children
                assertEquals(131, cs.getChunks().length);
-               
+
                // One of which is Text
                boolean hasText = false;
                for(int i=0; i<cs.getChunks().length; i++) {
@@ -245,20 +246,20 @@ public class TestStreamComplex extends StreamTest {
                assertTrue(hasText);
                // Which is the 72nd command
                assertEquals("Text", cs.getChunks()[72].getName());
-               
+
                Chunk text = cs.getChunks()[72];
                assertEquals("Text", text.getName());
-               
+
                // Which contains our text
                assertEquals(1, text.getCommands().length);
                assertEquals("Test View\n", text.getCommands()[0].getValue());
-               
-               
+
+
                // Almost at the end is some more text
                assertEquals("Text", cs.getChunks()[128].getName());
                text = cs.getChunks()[128];
                assertEquals("Text", text.getName());
-               
+
                assertEquals(1, text.getCommands().length);
                assertEquals("Some random text, on a page\n", text.getCommands()[0].getValue());
        }
index c0186dd8d1867028cf77e65c907c398e35646c1c..29ab7a8aca12f7855a817d7ebb00ee4d386989b8 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf;
 
 import java.io.File;
@@ -21,7 +22,7 @@ import java.io.FileInputStream;
 
 import junit.framework.TestCase;
 
-public class TestHPBFDocument extends TestCase {
+public final class TestHPBFDocument extends TestCase {
        private String dir;
 
        protected void setUp() throws Exception {
@@ -33,10 +34,10 @@ public class TestHPBFDocument extends TestCase {
                HPBFDocument doc = new HPBFDocument(
                                new FileInputStream(f)
                );
-               
+
                assertNotNull(doc);
        }
-       
+
        public void testBits() throws Exception {
                File f = new File(dir, "Sample.pub");
                HPBFDocument doc = new HPBFDocument(
@@ -47,13 +48,13 @@ public class TestHPBFDocument extends TestCase {
                assertNotNull(doc.getQuillContents());
                assertNotNull(doc.getEscherStm());
                assertNotNull(doc.getEscherDelayStm());
-               
+
                assertTrue(doc.getMainContents().getData().length > 0);
                assertTrue(doc.getQuillContents().getData().length > 0);
                assertTrue(doc.getEscherStm().getData().length > 0);
                assertTrue(doc.getEscherDelayStm().getData().length == 0);
        }
-       
+
        // TODO
 //     public void testWrite() throws Exception {
 //     }
index 1289882254ddbb32f068adfcb8d96be9754fc977..6bd05612e0adfe7c3985228984f5b1030700ca62 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.extractor;
 
 import java.io.File;
@@ -23,7 +24,7 @@ import org.apache.poi.hpbf.HPBFDocument;
 
 import junit.framework.TestCase;
 
-public class TextPublisherTextExtractor extends TestCase {
+public final class TextPublisherTextExtractor extends TestCase {
        private String dir;
 
        protected void setUp() throws Exception {
@@ -36,27 +37,27 @@ public class TextPublisherTextExtractor extends TestCase {
                                new FileInputStream(f)
                );
 
-               PublisherTextExtractor ext = 
+               PublisherTextExtractor ext =
                        new PublisherTextExtractor(doc);
                ext.getText();
-               
+
                f = new File(dir, "Simple.pub");
                ext = new PublisherTextExtractor(
                                new FileInputStream(f)
                );
                ext.getText();
        }
-       
+
        public void testContents() throws Exception {
                File f = new File(dir, "Sample.pub");
                HPBFDocument doc = new HPBFDocument(
                                new FileInputStream(f)
                );
 
-               PublisherTextExtractor ext = 
+               PublisherTextExtractor ext =
                        new PublisherTextExtractor(doc);
                String text = ext.getText();
-               
+
                assertEquals(
 "This is some text on the first page\n" +
 "It\u2019s in times new roman, font size 10, all normal\n" +
@@ -84,7 +85,7 @@ public class TextPublisherTextExtractor extends TestCase {
 "Within doc to page 1\n"
                                , text
                );
-               
+
                // Now a simpler one
                f = new File(dir, "Simple.pub");
                ext = new PublisherTextExtractor(
@@ -102,7 +103,7 @@ public class TextPublisherTextExtractor extends TestCase {
                                , text
                );
        }
-       
+
        /**
         * We have the same file saved for Publisher 98, Publisher
         *  2000 and Publisher 2007. Check they all agree.
@@ -111,30 +112,30 @@ public class TextPublisherTextExtractor extends TestCase {
        public void testMultipleVersions() throws Exception {
                File f;
                HPBFDocument doc;
-               
+
                f = new File(dir, "Sample.pub");
                doc = new HPBFDocument(
                                new FileInputStream(f)
                );
                String s2007 = (new PublisherTextExtractor(doc)).getText();
-               
+
                f = new File(dir, "Sample2000.pub");
                doc = new HPBFDocument(
                                new FileInputStream(f)
                );
                String s2000 = (new PublisherTextExtractor(doc)).getText();
-               
+
                f = new File(dir, "Sample98.pub");
                doc = new HPBFDocument(
                                new FileInputStream(f)
                );
                String s98 = (new PublisherTextExtractor(doc)).getText();
-               
+
                // Check they all agree
                assertEquals(s2007, s2000);
                assertEquals(s2007, s98);
        }
-       
+
        /**
         * Test that the hyperlink extraction stuff works as well
         *  as we can hope it to.
@@ -145,24 +146,24 @@ public class TextPublisherTextExtractor extends TestCase {
                                new FileInputStream(f)
                );
 
-               PublisherTextExtractor ext = 
+               PublisherTextExtractor ext =
                        new PublisherTextExtractor(doc);
                ext.getText();
-               
+
                // Default is no hyperlinks
                assertEquals("1234567890LINK\n", ext.getText());
-               
+
                // Turn on
                ext.setHyperlinksByDefault(true);
                assertEquals("1234567890LINK\n<http://poi.apache.org/>\n", ext.getText());
-               
-               
+
+
                // Now a much more complex document
                f = new File(dir, "Sample.pub");
                ext = new PublisherTextExtractor(new FileInputStream(f));
                ext.setHyperlinksByDefault(true);
                String text = ext.getText();
-               
+
                assertTrue(text.endsWith(
                                "<http://poi.apache.org/>\n" +
                                "<C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx>\n" +
index 631095007d6ac8f0f7ef23b3d66dc7a405781857..e803cae15602c71e3e8653956c62c9c2eb69b5cd 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model;
 
 import java.io.File;
@@ -23,7 +24,7 @@ import org.apache.poi.hpbf.HPBFDocument;
 
 import junit.framework.TestCase;
 
-public class TestEscherParts extends TestCase {
+public final class TestEscherParts extends TestCase {
        private String dir;
 
        protected void setUp() throws Exception {
@@ -38,16 +39,16 @@ public class TestEscherParts extends TestCase {
 
                EscherStm es = doc.getEscherStm();
                EscherDelayStm eds = doc.getEscherDelayStm();
-               
+
                assertNotNull(es);
                assertNotNull(eds);
-               
+
                assertEquals(13, es.getEscherRecords().length);
                assertEquals(0, eds.getEscherRecords().length);
-               
+
                // TODO - check the contents
        }
-       
+
        public void testComplex() throws Exception {
                File f = new File(dir, "SampleBrochure.pub");
                HPBFDocument doc = new HPBFDocument(
@@ -56,16 +57,16 @@ public class TestEscherParts extends TestCase {
 
                EscherStm es = doc.getEscherStm();
                EscherDelayStm eds = doc.getEscherDelayStm();
-               
+
                assertNotNull(es);
                assertNotNull(eds);
-               
+
                assertEquals(30, es.getEscherRecords().length);
                assertEquals(19, eds.getEscherRecords().length);
-               
+
                // TODO - check contents
-               
-               
+
+
                // Now do another complex file
                f = new File(dir, "SampleNewsletter.pub");
                doc = new HPBFDocument(
@@ -74,10 +75,10 @@ public class TestEscherParts extends TestCase {
 
                es = doc.getEscherStm();
                eds = doc.getEscherDelayStm();
-               
+
                assertNotNull(es);
                assertNotNull(eds);
-               
+
                assertEquals(51, es.getEscherRecords().length);
                assertEquals(92, eds.getEscherRecords().length);
        }
index 1ba45813c333c021d4a8c7467691916384861b7c..69d46d0923693fe0ac59a74ae953c3bafcce95bb 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hpbf.model;
 
 import java.io.File;
@@ -28,7 +29,7 @@ import org.apache.poi.hpbf.model.qcbits.QCPLCBit.Type8;
 
 import junit.framework.TestCase;
 
-public class TestQuillContents extends TestCase {
+public final class TestQuillContents extends TestCase {
        private String dir;
 
        protected void setUp() throws Exception {
@@ -40,7 +41,7 @@ public class TestQuillContents extends TestCase {
                HPBFDocument doc = new HPBFDocument(
                                new FileInputStream(f)
                );
-               
+
                QuillContents qc = doc.getQuillContents();
                assertEquals(20, qc.getBits().length);
                for(int i=0; i<19; i++) {
@@ -48,88 +49,88 @@ public class TestQuillContents extends TestCase {
                }
                // Last one is blank
                assertNull(qc.getBits()[19]);
-               
+
                // Should be text, then three STSHs
                assertEquals("TEXT", qc.getBits()[0].getThingType());
                assertEquals("TEXT", qc.getBits()[0].getBitType());
                assertEquals(0, qc.getBits()[0].getOptA());
-               
+
                assertEquals("STSH", qc.getBits()[1].getThingType());
                assertEquals("STSH", qc.getBits()[1].getBitType());
                assertEquals(0, qc.getBits()[1].getOptA());
-               
+
                assertEquals("STSH", qc.getBits()[2].getThingType());
                assertEquals("STSH", qc.getBits()[2].getBitType());
                assertEquals(1, qc.getBits()[2].getOptA());
-               
+
                assertEquals("STSH", qc.getBits()[3].getThingType());
                assertEquals("STSH", qc.getBits()[3].getBitType());
                assertEquals(2, qc.getBits()[3].getOptA());
        }
-       
+
        public void testText() throws Exception {
                File f = new File(dir, "Sample.pub");
                HPBFDocument doc = new HPBFDocument(
                                new FileInputStream(f)
                );
-               
+
                QuillContents qc = doc.getQuillContents();
                assertEquals(20, qc.getBits().length);
-               
+
                QCTextBit text = (QCTextBit)qc.getBits()[0];
                String t = text.getText();
                assertTrue(t.startsWith("This is some text on the first page"));
                assertTrue(t.endsWith("Within doc to page 1\r"));
        }
-       
+
        public void testPLC() throws Exception {
                File f = new File(dir, "Simple.pub");
                HPBFDocument doc = new HPBFDocument(
                                new FileInputStream(f)
                );
-               
+
                QuillContents qc = doc.getQuillContents();
                assertEquals(20, qc.getBits().length);
-               
+
                assertTrue(qc.getBits()[9] instanceof Type4);
                assertTrue(qc.getBits()[10] instanceof Type4);
                assertTrue(qc.getBits()[12] instanceof Type8);
-               
+
                Type4 plc9 = (Type4)qc.getBits()[9];
                Type4 plc10 = (Type4)qc.getBits()[10];
                Type8 plc12 = (Type8)qc.getBits()[12];
-               
-               
+
+
                assertEquals(1, plc9.getNumberOfPLCs());
                assertEquals(4, plc9.getPreData().length);
                assertEquals(1, plc9.getPlcValA().length);
                assertEquals(1, plc9.getPlcValB().length);
-               
+
                assertEquals(0, plc9.getPreData()[0]);
                assertEquals(0, plc9.getPreData()[1]);
                assertEquals(0, plc9.getPreData()[2]);
                assertEquals(0, plc9.getPreData()[3]);
                assertEquals(0x356, plc9.getPlcValA()[0]);
                assertEquals(0x600, plc9.getPlcValB()[0]);
-               
-               
+
+
                assertEquals(1, plc10.getNumberOfPLCs());
                assertEquals(4, plc10.getPreData().length);
                assertEquals(1, plc10.getPlcValA().length);
                assertEquals(1, plc10.getPlcValB().length);
-               
+
                assertEquals(0, plc10.getPreData()[0]);
                assertEquals(0, plc10.getPreData()[1]);
                assertEquals(0, plc10.getPreData()[2]);
                assertEquals(0, plc10.getPreData()[3]);
                assertEquals(0x356, plc10.getPlcValA()[0]);
                assertEquals(0x800, plc10.getPlcValB()[0]);
-               
+
                assertEquals(2, plc12.getNumberOfPLCs());
                assertEquals(7, plc12.getPreData().length);
                assertEquals(2, plc12.getPlcValA().length);
                assertEquals(2, plc12.getPlcValB().length);
-               
+
                assertEquals(0xff, plc12.getPreData()[0]);
                assertEquals(0, plc12.getPreData()[1]);
                assertEquals(0x3d, plc12.getPreData()[2]);
@@ -142,49 +143,49 @@ public class TestQuillContents extends TestCase {
                assertEquals(0x05, plc12.getPlcValA()[1]);
                assertEquals(0x04, plc12.getPlcValB()[1]);
        }
-       
+
        public void testComplexPLC() throws Exception {
                File f = new File(dir, "Sample.pub");
                HPBFDocument doc = new HPBFDocument(
                                new FileInputStream(f)
                );
-               
+
                QuillContents qc = doc.getQuillContents();
                assertEquals(20, qc.getBits().length);
-               
+
                assertTrue(qc.getBits()[10] instanceof Type4);
                assertTrue(qc.getBits()[11] instanceof Type4);
                assertTrue(qc.getBits()[13] instanceof Type0);
                assertTrue(qc.getBits()[14] instanceof Type12);
                assertTrue(qc.getBits()[15] instanceof Type12);
                assertTrue(qc.getBits()[16] instanceof Type8);
-               
+
                Type4 plc10 = (Type4)qc.getBits()[10];
                Type4 plc11 = (Type4)qc.getBits()[11];
                Type0 plc13 = (Type0)qc.getBits()[13];
                Type12 plc14 = (Type12)qc.getBits()[14];
                Type12 plc15 = (Type12)qc.getBits()[15];
                Type8 plc16 = (Type8)qc.getBits()[16];
-               
-               
+
+
                assertEquals(1, plc10.getNumberOfPLCs());
                assertEquals(4, plc10.getPreData().length);
                assertEquals(1, plc10.getPlcValA().length);
                assertEquals(1, plc10.getPlcValB().length);
-               
+
                assertEquals(0, plc10.getPreData()[0]);
                assertEquals(0, plc10.getPreData()[1]);
                assertEquals(0, plc10.getPreData()[2]);
                assertEquals(0, plc10.getPreData()[3]);
                assertEquals(0x5d0, plc10.getPlcValA()[0]);
                assertEquals(0x800, plc10.getPlcValB()[0]);
-               
-               
+
+
                assertEquals(2, plc11.getNumberOfPLCs());
                assertEquals(4, plc11.getPreData().length);
                assertEquals(2, plc11.getPlcValA().length);
                assertEquals(2, plc11.getPlcValB().length);
-               
+
                assertEquals(0, plc11.getPreData()[0]);
                assertEquals(0, plc11.getPreData()[1]);
                assertEquals(0, plc11.getPreData()[2]);
@@ -193,13 +194,13 @@ public class TestQuillContents extends TestCase {
                assertEquals(0x5d0, plc11.getPlcValB()[0]);
                assertEquals(0xa00, plc11.getPlcValA()[1]);
                assertEquals(0xc00, plc11.getPlcValB()[1]);
-               
-               
+
+
                assertEquals(5, plc13.getNumberOfPLCs());
                assertEquals(4, plc13.getPreData().length);
                assertEquals(5, plc13.getPlcValA().length);
                assertEquals(5, plc13.getPlcValB().length);
-               
+
                assertEquals(0xff00, plc13.getPreData()[0]);
                assertEquals(0, plc13.getPreData()[1]);
                assertEquals(0xf, plc13.getPreData()[2]);
@@ -214,16 +215,16 @@ public class TestQuillContents extends TestCase {
                assertEquals(0x00, plc13.getPlcValB()[3]);
                assertEquals(0x50, plc13.getPlcValA()[4]);
                assertEquals(0x00, plc13.getPlcValB()[4]);
-               
-               
+
+
                // TODO - test the type 12s
-               
-               
+
+
                assertEquals(6, plc16.getNumberOfPLCs());
                assertEquals(7, plc16.getPreData().length);
                assertEquals(6, plc16.getPlcValA().length);
                assertEquals(6, plc16.getPlcValB().length);
-               
+
                assertEquals(0xff, plc16.getPreData()[0]);
                assertEquals(0, plc16.getPreData()[1]);
                assertEquals(0x56, plc16.getPreData()[2]);
@@ -244,127 +245,127 @@ public class TestQuillContents extends TestCase {
                assertEquals(0x000004, plc16.getPlcValA()[5]);
                assertEquals(0x000004, plc16.getPlcValB()[5]);
        }
-       
+
        public void testNoHyperlinks() throws Exception {
                File f = new File(dir, "SampleNewsletter.pub");
                HPBFDocument doc = new HPBFDocument(
                                new FileInputStream(f)
                );
-               
+
                QuillContents qc = doc.getQuillContents();
                assertEquals(20, qc.getBits().length);
-               
+
                Type12 plc18 = (Type12)qc.getBits()[18];
-               
+
                assertEquals(1, plc18.getNumberOfPLCs());
                assertEquals(0, plc18.getNumberOfHyperlinks());
                assertEquals(0, plc18.getTextStartAt(0));
                assertEquals(601, plc18.getAllTextEndAt());
        }
-       
+
        public void testSimpleHyperlink() throws Exception {
                File f;
                HPBFDocument doc;
                QuillContents qc;
                Type12 hlBit;
-               
+
                // Link at 10
                f = new File(dir, "LinkAt10.pub");
                doc = new HPBFDocument(
                                new FileInputStream(f)
                );
                qc = doc.getQuillContents();
-               
+
                hlBit = (Type12)qc.getBits()[12];
                assertEquals(1, hlBit.getNumberOfPLCs());
                assertEquals(1, hlBit.getNumberOfHyperlinks());
-               
+
                assertEquals(10, hlBit.getTextStartAt(0));
                assertEquals(15, hlBit.getAllTextEndAt());
                assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
-               
+
                // Longer link at 10
                f = new File(dir, "LinkAt10Longer.pub");
                doc = new HPBFDocument(
                                new FileInputStream(f)
                );
                qc = doc.getQuillContents();
-               
+
                hlBit = (Type12)qc.getBits()[12];
                assertEquals(1, hlBit.getNumberOfPLCs());
                assertEquals(1, hlBit.getNumberOfHyperlinks());
-               
+
                assertEquals(10, hlBit.getTextStartAt(0));
                assertEquals(15, hlBit.getAllTextEndAt());
                assertEquals("http://poi.apache.org/hpbf/", hlBit.getHyperlink(0));
-               
+
                // Link at 20
                f = new File(dir, "LinkAt20.pub");
                doc = new HPBFDocument(
                                new FileInputStream(f)
                );
                qc = doc.getQuillContents();
-               
+
                hlBit = (Type12)qc.getBits()[12];
                assertEquals(1, hlBit.getNumberOfPLCs());
                assertEquals(1, hlBit.getNumberOfHyperlinks());
-               
+
                assertEquals(20, hlBit.getTextStartAt(0));
                assertEquals(25, hlBit.getAllTextEndAt());
                assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
        }
-       
+
        public void testManyHyperlinks() throws Exception {
                File f;
                HPBFDocument doc;
                QuillContents qc;
                Type12 hlBit;
-               
+
                // Link at 10
                f = new File(dir, "LinkAt10.pub");
                doc = new HPBFDocument(
                                new FileInputStream(f)
                );
                qc = doc.getQuillContents();
-               
+
                hlBit = (Type12)qc.getBits()[12];
                assertEquals(1, hlBit.getNumberOfPLCs());
                assertEquals(1, hlBit.getNumberOfHyperlinks());
-               
+
                assertEquals(10, hlBit.getTextStartAt(0));
                assertEquals(15, hlBit.getAllTextEndAt());
                assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
-               
+
        }
-       
+
        public void testHyperlinkDifferentVersions() throws Exception {
                File f;
                HPBFDocument doc;
                QuillContents qc;
                Type12 hlBitA;
                Type12 hlBitB;
-               
+
                // Latest version
                f = new File(dir, "Sample.pub");
                doc = new HPBFDocument(
                                new FileInputStream(f)
                );
                qc = doc.getQuillContents();
-               
+
                hlBitA = (Type12)qc.getBits()[14];
                assertEquals(2, hlBitA.getNumberOfPLCs());
                assertEquals(2, hlBitA.getNumberOfHyperlinks());
-               
+
                assertEquals(25, hlBitA.getTextStartAt(0));
                assertEquals(72, hlBitA.getTextStartAt(1));
                assertEquals(87, hlBitA.getAllTextEndAt());
                assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
                assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
-               
+
                hlBitB = (Type12)qc.getBits()[15];
                assertEquals(3, hlBitB.getNumberOfPLCs());
                assertEquals(3, hlBitB.getNumberOfHyperlinks());
-               
+
                assertEquals(27, hlBitB.getTextStartAt(0));
                assertEquals(37, hlBitB.getTextStartAt(1));
                assertEquals(54, hlBitB.getTextStartAt(2));
@@ -372,28 +373,28 @@ public class TestQuillContents extends TestCase {
                assertEquals("", hlBitB.getHyperlink(0));
                assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
                assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
-               
+
                // 2000 version
                f = new File(dir, "Sample2000.pub");
                doc = new HPBFDocument(
                                new FileInputStream(f)
                );
                qc = doc.getQuillContents();
-               
+
                hlBitA = (Type12)qc.getBits()[13];
                assertEquals(2, hlBitA.getNumberOfPLCs());
                assertEquals(2, hlBitA.getNumberOfHyperlinks());
-               
+
                assertEquals(25, hlBitA.getTextStartAt(0));
                assertEquals(72, hlBitA.getTextStartAt(1));
                assertEquals(87, hlBitA.getAllTextEndAt());
                assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
                assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
-               
+
                hlBitB = (Type12)qc.getBits()[14];
                assertEquals(3, hlBitB.getNumberOfPLCs());
                assertEquals(3, hlBitB.getNumberOfHyperlinks());
-               
+
                assertEquals(27, hlBitB.getTextStartAt(0));
                assertEquals(37, hlBitB.getTextStartAt(1));
                assertEquals(54, hlBitB.getTextStartAt(2));
@@ -401,28 +402,28 @@ public class TestQuillContents extends TestCase {
                assertEquals("", hlBitB.getHyperlink(0));
                assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
                assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));
-               
+
                // 98 version
                f = new File(dir, "Sample98.pub");
                doc = new HPBFDocument(
                                new FileInputStream(f)
                );
                qc = doc.getQuillContents();
-               
+
                hlBitA = (Type12)qc.getBits()[13];
                assertEquals(2, hlBitA.getNumberOfPLCs());
                assertEquals(2, hlBitA.getNumberOfHyperlinks());
-               
+
                assertEquals(25, hlBitA.getTextStartAt(0));
                assertEquals(72, hlBitA.getTextStartAt(1));
                assertEquals(87, hlBitA.getAllTextEndAt());
                assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
                assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));
-               
+
                hlBitB = (Type12)qc.getBits()[14];
                assertEquals(3, hlBitB.getNumberOfPLCs());
                assertEquals(3, hlBitB.getNumberOfHyperlinks());
-               
+
                assertEquals(27, hlBitB.getTextStartAt(0));
                assertEquals(37, hlBitB.getTextStartAt(1));
                assertEquals(54, hlBitB.getTextStartAt(2));
index 218b9f269762a8eb3e8b4c44a6c49c55622b5ce7..6daeab1b2050313b6b2f896c77fdbc1c6276237d 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf;
 
@@ -31,7 +28,7 @@ import org.apache.poi.hslf.record.*;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestEncryptedFile extends TestCase {
+public final class TestEncryptedFile extends TestCase {
        // A non encrypted file
        private String ss_ne;
        // An encrypted file, with encrypted properties
@@ -40,23 +37,23 @@ public class TestEncryptedFile extends TestCase {
        private String ss_np_e;
        // An encrypted file, with a 56 bit key
        private String ss_56_e;
-       
+
 
     public TestEncryptedFile() throws Exception {
                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);
-       
+
        assertNotNull(hss);
     }
-    
+
     public void testLoadEncrypted() throws Exception {
        try {
                new HSLFSlideShow(ss_e);
@@ -64,14 +61,14 @@ public class TestEncryptedFile extends TestCase {
        } catch(EncryptedPowerPointFileException e) {
                // Good
        }
-       
+
        try {
                new HSLFSlideShow(ss_np_e);
                fail();
        } catch(EncryptedPowerPointFileException e) {
                // Good
        }
-       
+
        try {
                new HSLFSlideShow(ss_56_e);
                fail();
index 541b7a3a24772e62fae9caafb9f3be743a9dc99f..b1468f2c5535dcf1c27447bd2ef9be44ebcfb552 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf;
 
@@ -33,7 +30,7 @@ import org.apache.poi.poifs.filesystem.*;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestReWrite extends TestCase {
+public final class TestReWrite extends TestCase {
        // HSLFSlideShow primed on the test data
        private HSLFSlideShow hssA;
        private HSLFSlideShow hssB;
@@ -45,17 +42,17 @@ public class TestReWrite extends TestCase {
 
     public void setUp() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
-               
+
                String filenameA = dirname + "/basic_test_ppt_file.ppt";
                FileInputStream fisA = new FileInputStream(filenameA);
                pfsA = new POIFSFileSystem(fisA);
                hssA = new HSLFSlideShow(pfsA);
-               
+
                String filenameB = dirname + "/ParagraphStylesShorterThanCharStyles.ppt";
                FileInputStream fisB = new FileInputStream(filenameB);
                pfsB = new POIFSFileSystem(fisB);
                hssB = new HSLFSlideShow(pfsB);
-               
+
                String filenameC = dirname + "/WithMacros.ppt";
                FileInputStream fisC = new FileInputStream(filenameC);
                pfsC = new POIFSFileSystem(fisC);
@@ -92,27 +89,27 @@ public class TestReWrite extends TestCase {
                        assertEquals(_oData[i], _nData[i]);
                }
        }
-    
+
     public void testWithMacroStreams() throws Exception {
        // Check that they're apparently the same
        assertSlideShowWritesOutTheSame(hssC, pfsC);
-       
+
        // Currently has a Macros stream
        assertNotNull( pfsC.getRoot().getEntry("Macros") );
-       
+
        // Write out normally, will loose the macro stream
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        hssC.write(baos);
        POIFSFileSystem pfsNew = new POIFSFileSystem(
                        new ByteArrayInputStream(baos.toByteArray()) );
-       
+
        try {
                pfsNew.getRoot().getEntry("Macros");
                fail();
        } catch(FileNotFoundException e) {
                // Good, as expected
        }
-       
+
        // But if we write out with nodes preserved, will be there
        baos = new ByteArrayOutputStream();
        hssC.write(baos, true);
@@ -123,11 +120,11 @@ public class TestReWrite extends TestCase {
 
     /**
      * Ensure that simply opening a slideshow (usermodel) view of it
-     *  doesn't change things 
+     *  doesn't change things
      */
     public void testSlideShowWritesOutTheSame() throws Exception {
        assertSlideShowWritesOutTheSame(hssA, pfsA);
-       
+
        // Some bug in StyleTextPropAtom rewriting means this will fail
        // We need to identify and fix that first
        //assertSlideShowWritesOutTheSame(hssB, pfsB);
@@ -137,7 +134,7 @@ public class TestReWrite extends TestCase {
        SlideShow ss = new SlideShow(hss);
        ss.getSlides();
        ss.getNotes();
-       
+
                // Now write out to a byte array
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                hss.write(baos);
index 373611e73d048e801d19851420563fd556d48dd3..7467021544289fd5a2664e11d52338e29669c35b 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf;
 
@@ -33,7 +30,7 @@ import org.apache.poi.poifs.filesystem.*;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestReWriteSanity extends TestCase {
+public final class TestReWriteSanity extends TestCase {
        // HSLFSlideShow primed on the test data
        private HSLFSlideShow ss;
        // POIFS primed on the test data
@@ -58,7 +55,7 @@ public class TestReWriteSanity extends TestCase {
                // Create a new one from that
                HSLFSlideShow wss = new HSLFSlideShow(bais);
 
-               // Find the location of the PersistPtrIncrementalBlocks and 
+               // Find the location of the PersistPtrIncrementalBlocks and
                // UserEditAtoms
                Record[] r = wss.getRecords();
                Hashtable pp = new Hashtable();
@@ -75,7 +72,7 @@ public class TestReWriteSanity extends TestCase {
                                ue.put(new Integer(pos), r[i]);
                                lastUEPos = pos;
                        }
-                       
+
                        ByteArrayOutputStream bc = new ByteArrayOutputStream();
                        r[i].writeOut(bc);
                        pos += bc.size();
index 1b76b726537af657701cef8c9f25d5a5b0d79e9a..60b93dea6431a8780f01086ea2e62c33496557da 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf;
 
@@ -30,7 +27,7 @@ import org.apache.poi.hslf.record.*;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestRecordCounts extends TestCase {
+public final class TestRecordCounts extends TestCase {
        // HSLFSlideShow primed on the test data
        private HSLFSlideShow ss;
 
index 66672cdcb842833077dd70b63a4a016a10e3ee72..e45ca51d125ab2fc44e4cfdc123e38a5d6a669a5 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.extractor;
 
@@ -29,7 +26,7 @@ import java.util.Vector;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestCruddyExtractor extends TestCase {
+public final class TestCruddyExtractor extends TestCase {
        // Extractor primed on the test data
        private QuickButCruddyTextExtractor te;
        // All the text to be found in the file
index ebfaccf8bfba358cb18db16d196a522845beb609..7871b059769267fc69ed37b07f3a24841b43bc6a 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import junit.framework.TestCase;
@@ -26,10 +27,10 @@ import org.apache.poi.hslf.HSLFSlideShow;
 
 /**
  * Test <code>Fill</code> object.
- * 
+ *
  * @author Yegor Kozlov
  */
-public class TestBackground extends TestCase {
+public final class TestBackground extends TestCase {
 
     /**
      * Default background for slide, shape and slide master.
index 56d5a099cb08de70eaba7fe7e9e71f49c77d9c4c..77a58844deefe775cb06b2aaf57ac1f6e8a833fb 100755 (executable)
@@ -1,80 +1,81 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import junit.framework.TestCase;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.usermodel.RichTextRun;\r
-import org.apache.poi.hslf.HSLFSlideShow;\r
-\r
-import java.awt.*;\r
-import java.awt.Rectangle;\r
-import java.awt.geom.*;\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.ByteArrayInputStream;\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-\r
-/**\r
- * Test Freeform object.\r
- * The Freeform shape is constructed from java.awt.GeneralPath.\r
- * Check that the get/set path accessors are consistent.\r
- * (TODO: verification of Bezier curves is more difficult due to rounding error.  Figure out a test approach for that)\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestFreeform extends TestCase {\r
-\r
-    public void testClosedPath() throws Exception {\r
-\r
-        GeneralPath path1 = new GeneralPath();\r
-        path1.moveTo(100, 100);\r
-        path1.lineTo(200, 100);\r
-        path1.lineTo(200, 200);\r
-        path1.lineTo(100, 200);\r
-        path1.closePath();\r
-\r
-        Freeform p = new Freeform();\r
-        p.setPath(path1);\r
-\r
-        java.awt.Shape path2 = p.getOutline();\r
-        assertTrue(new Area(path1).equals(new Area(path2)));\r
-    }\r
-\r
-    public void testLine() throws Exception {\r
-\r
-        GeneralPath path1 = new GeneralPath(new Line2D.Double(100, 100, 200, 100));\r
-\r
-        Freeform p = new Freeform();\r
-        p.setPath(path1);\r
-\r
-        java.awt.Shape path2 = p.getOutline();\r
-        assertTrue(new Area(path1).equals(new Area(path2)));\r
-    }\r
-\r
-    public void testRectangle() throws Exception {\r
-\r
-        GeneralPath path1 = new GeneralPath(new Rectangle2D.Double(100, 100, 200, 50));\r
-\r
-        Freeform p = new Freeform();\r
-        p.setPath(path1);\r
-\r
-        java.awt.Shape path2 = p.getOutline();\r
-        assertTrue(new Area(path1).equals(new Area(path2)));\r
-   }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+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.
+ * The Freeform shape is constructed from java.awt.GeneralPath.
+ * Check that the get/set path accessors are consistent.
+ * (TODO: verification of Bezier curves is more difficult due to rounding error.  Figure out a test approach for that)
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestFreeform extends TestCase {
+
+    public void testClosedPath() throws Exception {
+
+        GeneralPath path1 = new GeneralPath();
+        path1.moveTo(100, 100);
+        path1.lineTo(200, 100);
+        path1.lineTo(200, 200);
+        path1.lineTo(100, 200);
+        path1.closePath();
+
+        Freeform p = new Freeform();
+        p.setPath(path1);
+
+        java.awt.Shape path2 = p.getOutline();
+        assertTrue(new Area(path1).equals(new Area(path2)));
+    }
+
+    public void testLine() throws Exception {
+
+        GeneralPath path1 = new GeneralPath(new Line2D.Double(100, 100, 200, 100));
+
+        Freeform p = new Freeform();
+        p.setPath(path1);
+
+        java.awt.Shape path2 = p.getOutline();
+        assertTrue(new Area(path1).equals(new Area(path2)));
+    }
+
+    public void testRectangle() throws Exception {
+
+        GeneralPath path1 = new GeneralPath(new Rectangle2D.Double(100, 100, 200, 50));
+
+        Freeform p = new Freeform();
+        p.setPath(path1);
+
+        java.awt.Shape path2 = p.getOutline();
+        assertTrue(new Area(path1).equals(new Area(path2)));
+   }
+}
index 39255d3e8b03b52f2f34d42d4e79542a0b4e5568..cf94e0453964b17e362bd656b1971efb3e10e44b 100644 (file)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-\r
-package org.apache.poi.hslf.model;\r
-\r
-import java.io.*;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-\r
-import junit.framework.TestCase;\r
-\r
-/**\r
- * Test {@link org.apache.poi.hslf.model.HeadersFooters} object\r
- */\r
-public class TestHeadersFooters extends TestCase\r
-{\r
-\r
-    public static final String cwd = System.getProperty("HSLF.testdata.path");\r
-\r
-    public void testRead() throws Exception\r
-    {\r
-        File file = new File(cwd, "headers_footers.ppt");\r
-        FileInputStream is = new FileInputStream(file);\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        HeadersFooters slideHdd = ppt.getSlideHeadersFooters();\r
-        assertTrue(slideHdd.isFooterVisible());\r
-        assertEquals("Global Slide Footer", slideHdd.getFooterText());\r
-        assertTrue(slideHdd.isSlideNumberVisible());\r
-        assertFalse(slideHdd.isHeaderVisible());\r
-        assertNull(slideHdd.getHeaderText());\r
-        assertFalse(slideHdd.isUserDateVisible());\r
-        assertNull(slideHdd.getDateTimeText());\r
-\r
-\r
-        HeadersFooters notesHdd = ppt.getNotesHeadersFooters();\r
-        assertTrue(notesHdd.isFooterVisible());\r
-        assertEquals("Notes Footer", notesHdd.getFooterText());\r
-        assertTrue(notesHdd.isHeaderVisible());\r
-        assertEquals("Notes Header", notesHdd.getHeaderText());\r
-        assertTrue(notesHdd.isUserDateVisible());\r
-        assertNull(notesHdd.getDateTimeText());\r
-\r
-        Slide[] slide = ppt.getSlides();\r
-        //the first slide uses presentation-scope headers / footers\r
-        HeadersFooters hd1 = slide[0].getHeadersFooters();\r
-        assertEquals(slideHdd.isFooterVisible(), hd1.isFooterVisible());\r
-        assertEquals(slideHdd.getFooterText(), hd1.getFooterText());\r
-        assertEquals(slideHdd.isSlideNumberVisible(), hd1.isSlideNumberVisible());\r
-        assertEquals(slideHdd.isHeaderVisible(), hd1.isHeaderVisible());\r
-        assertEquals(slideHdd.getHeaderText(), hd1.getHeaderText());\r
-        assertEquals(slideHdd.isUserDateVisible(), hd1.isUserDateVisible());\r
-        assertEquals(slideHdd.getDateTimeText(), hd1.getDateTimeText());\r
-\r
-        //the first slide uses per-slide headers / footers\r
-        HeadersFooters hd2 = slide[1].getHeadersFooters();\r
-        assertEquals(true, hd2.isFooterVisible());\r
-        assertEquals("per-slide footer", hd2.getFooterText());\r
-        assertEquals(true, hd2.isUserDateVisible());\r
-        assertEquals("custom date format", hd2.getDateTimeText());\r
-    }\r
-\r
-    /**\r
-     * If Headers / Footers are not set, all the getters should return <code>false</code> or <code>null</code>\r
-     */\r
-    public void testReadNoHeadersFooters() throws Exception\r
-    {\r
-        File file = new File(cwd, "basic_test_ppt_file.ppt");\r
-        FileInputStream is = new FileInputStream(file);\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        HeadersFooters slideHdd = ppt.getSlideHeadersFooters();\r
-        assertFalse(slideHdd.isFooterVisible());\r
-        assertNull(slideHdd.getFooterText());\r
-        assertFalse(slideHdd.isSlideNumberVisible());\r
-        assertFalse(slideHdd.isHeaderVisible());\r
-        assertNull(slideHdd.getHeaderText());\r
-        assertFalse(slideHdd.isUserDateVisible());\r
-        assertNull(slideHdd.getDateTimeText());\r
-\r
-\r
-        HeadersFooters notesHdd = ppt.getNotesHeadersFooters();\r
-        assertFalse(notesHdd.isFooterVisible());\r
-        assertNull(notesHdd.getFooterText());\r
-        assertFalse(notesHdd.isHeaderVisible());\r
-        assertNull(notesHdd.getHeaderText());\r
-        assertFalse(notesHdd.isUserDateVisible());\r
-        assertNull(notesHdd.getDateTimeText());\r
-\r
-        Slide[] slide = ppt.getSlides();\r
-        for(int i=0 ; i < slide.length; i++){\r
-            HeadersFooters hd1 = slide[i].getHeadersFooters();\r
-            assertFalse(hd1.isFooterVisible());\r
-            assertNull(hd1.getFooterText());\r
-            assertFalse(hd1.isHeaderVisible());\r
-            assertNull(hd1.getHeaderText());\r
-            assertFalse(hd1.isUserDateVisible());\r
-            assertNull(hd1.getDateTimeText());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Test extraction of headers / footers from PPTs saved in Office 2007\r
-     */\r
-    public void testRead2007() throws Exception\r
-    {\r
-        File file = new File(cwd, "headers_footers_2007.ppt");\r
-        FileInputStream is = new FileInputStream(file);\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        HeadersFooters slideHdd = ppt.getSlideHeadersFooters();\r
-        assertTrue(slideHdd.isFooterVisible());\r
-        assertEquals("THE FOOTER TEXT", slideHdd.getFooterText());\r
-        assertTrue(slideHdd.isSlideNumberVisible());\r
-        assertFalse(slideHdd.isHeaderVisible());\r
-        assertNull(slideHdd.getHeaderText());\r
-        assertTrue(slideHdd.isUserDateVisible());\r
-        assertEquals("Wednesday, August 06, 2008", slideHdd.getDateTimeText());\r
-\r
-\r
-        HeadersFooters notesHdd = ppt.getNotesHeadersFooters();\r
-        assertTrue(notesHdd.isFooterVisible());\r
-        assertEquals("THE NOTES FOOTER TEXT", notesHdd.getFooterText());\r
-        assertTrue(notesHdd.isHeaderVisible());\r
-        assertEquals("THE NOTES HEADER TEXT", notesHdd.getHeaderText());\r
-        assertTrue(notesHdd.isUserDateVisible());\r
-        assertTrue(notesHdd.isDateTimeVisible());\r
-        //TODO: depending on the formatId getDateTimeText() should return formatted date\r
-        //assertEquals("08/12/08", notesHdd.getDateTimeText());\r
-\r
-        //per-slide headers / footers\r
-        Slide[] slide = ppt.getSlides();\r
-        //the first slide uses presentation-scope headers / footers\r
-        HeadersFooters hd1 = slide[0].getHeadersFooters();\r
-        assertTrue(hd1.isFooterVisible());\r
-        assertEquals("THE FOOTER TEXT", hd1.getFooterText());\r
-        assertTrue(hd1.isSlideNumberVisible());\r
-        assertFalse(hd1.isHeaderVisible());\r
-        assertNull(hd1.getHeaderText());\r
-        assertTrue(hd1.isUserDateVisible());\r
-        assertTrue(hd1.isDateTimeVisible());\r
-        assertEquals("Wednesday, August 06, 2008", hd1.getDateTimeText());\r
-\r
-        //the second slide uses custom per-slide headers / footers\r
-        HeadersFooters hd2 = slide[1].getHeadersFooters();\r
-        assertTrue(hd2.isFooterVisible());\r
-        assertEquals("THE FOOTER TEXT FOR SLIDE 2", hd2.getFooterText());\r
-        assertTrue(hd2.isSlideNumberVisible());\r
-        assertFalse(hd2.isHeaderVisible());\r
-        assertNull(hd2.getHeaderText());\r
-        assertTrue(hd2.isUserDateVisible());\r
-        assertTrue(hd2.isDateTimeVisible());\r
-        assertEquals("August 06, 2008", hd2.getDateTimeText());\r
-\r
-        //the third slide uses per-slide headers / footers\r
-        HeadersFooters hd3 = slide[2].getHeadersFooters();\r
-        assertTrue(hd3.isFooterVisible());\r
-        assertEquals("THE FOOTER TEXT", hd3.getFooterText());\r
-        assertTrue(hd3.isSlideNumberVisible());\r
-        assertFalse(hd3.isHeaderVisible());\r
-        assertNull(hd3.getHeaderText());\r
-        assertTrue(hd3.isUserDateVisible());\r
-        assertTrue(hd3.isDateTimeVisible());\r
-        assertEquals("Wednesday, August 06, 2008", hd3.getDateTimeText());\r
-    }\r
-\r
-    public void testCreateSlideFooters() throws Exception\r
-    {\r
-        SlideShow ppt = new SlideShow();\r
-        HeadersFooters hdd = ppt.getSlideHeadersFooters();\r
-        hdd.setFootersText("My slide footer");\r
-        hdd.setSlideNumberVisible(true);\r
-\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        ppt.write(out);\r
-        byte[] b = out.toByteArray();\r
-\r
-        SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b));\r
-        HeadersFooters hdd2 = ppt2.getSlideHeadersFooters();\r
-        assertTrue(hdd2.isSlideNumberVisible());\r
-        assertTrue(hdd2.isFooterVisible());\r
-        assertEquals("My slide footer", hdd2.getFooterText());\r
-    }\r
-\r
-    public void testCreateNotesFooters() throws Exception\r
-    {\r
-        SlideShow ppt = new SlideShow();\r
-        HeadersFooters hdd = ppt.getNotesHeadersFooters();\r
-        hdd.setFootersText("My notes footer");\r
-        hdd.setHeaderText("My notes header");\r
-        hdd.setSlideNumberVisible(true);\r
-\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        ppt.write(out);\r
-        byte[] b = out.toByteArray();\r
-\r
-        SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b));\r
-        HeadersFooters hdd2 = ppt2.getNotesHeadersFooters();\r
-        assertTrue(hdd2.isSlideNumberVisible());\r
-        assertTrue(hdd2.isFooterVisible());\r
-        assertEquals("My notes footer", hdd2.getFooterText());\r
-        assertTrue(hdd2.isHeaderVisible());\r
-        assertEquals("My notes header", hdd2.getHeaderText());\r
-    }\r
-}
\ No newline at end of file
+/* ====================================================================
+   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.hslf.model;
+
+import java.io.*;
+import org.apache.poi.hslf.usermodel.SlideShow;
+
+import junit.framework.TestCase;
+
+/**
+ * Test {@link org.apache.poi.hslf.model.HeadersFooters} object
+ */
+public final class TestHeadersFooters extends TestCase
+{
+
+    public static final String cwd = System.getProperty("HSLF.testdata.path");
+
+    public void testRead() throws Exception
+    {
+        File file = new File(cwd, "headers_footers.ppt");
+        FileInputStream is = new FileInputStream(file);
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
+        assertTrue(slideHdd.isFooterVisible());
+        assertEquals("Global Slide Footer", slideHdd.getFooterText());
+        assertTrue(slideHdd.isSlideNumberVisible());
+        assertFalse(slideHdd.isHeaderVisible());
+        assertNull(slideHdd.getHeaderText());
+        assertFalse(slideHdd.isUserDateVisible());
+        assertNull(slideHdd.getDateTimeText());
+
+
+        HeadersFooters notesHdd = ppt.getNotesHeadersFooters();
+        assertTrue(notesHdd.isFooterVisible());
+        assertEquals("Notes Footer", notesHdd.getFooterText());
+        assertTrue(notesHdd.isHeaderVisible());
+        assertEquals("Notes Header", notesHdd.getHeaderText());
+        assertTrue(notesHdd.isUserDateVisible());
+        assertNull(notesHdd.getDateTimeText());
+
+        Slide[] slide = ppt.getSlides();
+        //the first slide uses presentation-scope headers / footers
+        HeadersFooters hd1 = slide[0].getHeadersFooters();
+        assertEquals(slideHdd.isFooterVisible(), hd1.isFooterVisible());
+        assertEquals(slideHdd.getFooterText(), hd1.getFooterText());
+        assertEquals(slideHdd.isSlideNumberVisible(), hd1.isSlideNumberVisible());
+        assertEquals(slideHdd.isHeaderVisible(), hd1.isHeaderVisible());
+        assertEquals(slideHdd.getHeaderText(), hd1.getHeaderText());
+        assertEquals(slideHdd.isUserDateVisible(), hd1.isUserDateVisible());
+        assertEquals(slideHdd.getDateTimeText(), hd1.getDateTimeText());
+
+        //the first slide uses per-slide headers / footers
+        HeadersFooters hd2 = slide[1].getHeadersFooters();
+        assertEquals(true, hd2.isFooterVisible());
+        assertEquals("per-slide footer", hd2.getFooterText());
+        assertEquals(true, hd2.isUserDateVisible());
+        assertEquals("custom date format", hd2.getDateTimeText());
+    }
+
+    /**
+     * If Headers / Footers are not set, all the getters should return <code>false</code> or <code>null</code>
+     */
+    public void testReadNoHeadersFooters() throws Exception
+    {
+        File file = new File(cwd, "basic_test_ppt_file.ppt");
+        FileInputStream is = new FileInputStream(file);
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
+        assertFalse(slideHdd.isFooterVisible());
+        assertNull(slideHdd.getFooterText());
+        assertFalse(slideHdd.isSlideNumberVisible());
+        assertFalse(slideHdd.isHeaderVisible());
+        assertNull(slideHdd.getHeaderText());
+        assertFalse(slideHdd.isUserDateVisible());
+        assertNull(slideHdd.getDateTimeText());
+
+
+        HeadersFooters notesHdd = ppt.getNotesHeadersFooters();
+        assertFalse(notesHdd.isFooterVisible());
+        assertNull(notesHdd.getFooterText());
+        assertFalse(notesHdd.isHeaderVisible());
+        assertNull(notesHdd.getHeaderText());
+        assertFalse(notesHdd.isUserDateVisible());
+        assertNull(notesHdd.getDateTimeText());
+
+        Slide[] slide = ppt.getSlides();
+        for(int i=0 ; i < slide.length; i++){
+            HeadersFooters hd1 = slide[i].getHeadersFooters();
+            assertFalse(hd1.isFooterVisible());
+            assertNull(hd1.getFooterText());
+            assertFalse(hd1.isHeaderVisible());
+            assertNull(hd1.getHeaderText());
+            assertFalse(hd1.isUserDateVisible());
+            assertNull(hd1.getDateTimeText());
+        }
+    }
+
+    /**
+     * Test extraction of headers / footers from PPTs saved in Office 2007
+     */
+    public void testRead2007() throws Exception
+    {
+        File file = new File(cwd, "headers_footers_2007.ppt");
+        FileInputStream is = new FileInputStream(file);
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
+        assertTrue(slideHdd.isFooterVisible());
+        assertEquals("THE FOOTER TEXT", slideHdd.getFooterText());
+        assertTrue(slideHdd.isSlideNumberVisible());
+        assertFalse(slideHdd.isHeaderVisible());
+        assertNull(slideHdd.getHeaderText());
+        assertTrue(slideHdd.isUserDateVisible());
+        assertEquals("Wednesday, August 06, 2008", slideHdd.getDateTimeText());
+
+
+        HeadersFooters notesHdd = ppt.getNotesHeadersFooters();
+        assertTrue(notesHdd.isFooterVisible());
+        assertEquals("THE NOTES FOOTER TEXT", notesHdd.getFooterText());
+        assertTrue(notesHdd.isHeaderVisible());
+        assertEquals("THE NOTES HEADER TEXT", notesHdd.getHeaderText());
+        assertTrue(notesHdd.isUserDateVisible());
+        assertTrue(notesHdd.isDateTimeVisible());
+        //TODO: depending on the formatId getDateTimeText() should return formatted date
+        //assertEquals("08/12/08", notesHdd.getDateTimeText());
+
+        //per-slide headers / footers
+        Slide[] slide = ppt.getSlides();
+        //the first slide uses presentation-scope headers / footers
+        HeadersFooters hd1 = slide[0].getHeadersFooters();
+        assertTrue(hd1.isFooterVisible());
+        assertEquals("THE FOOTER TEXT", hd1.getFooterText());
+        assertTrue(hd1.isSlideNumberVisible());
+        assertFalse(hd1.isHeaderVisible());
+        assertNull(hd1.getHeaderText());
+        assertTrue(hd1.isUserDateVisible());
+        assertTrue(hd1.isDateTimeVisible());
+        assertEquals("Wednesday, August 06, 2008", hd1.getDateTimeText());
+
+        //the second slide uses custom per-slide headers / footers
+        HeadersFooters hd2 = slide[1].getHeadersFooters();
+        assertTrue(hd2.isFooterVisible());
+        assertEquals("THE FOOTER TEXT FOR SLIDE 2", hd2.getFooterText());
+        assertTrue(hd2.isSlideNumberVisible());
+        assertFalse(hd2.isHeaderVisible());
+        assertNull(hd2.getHeaderText());
+        assertTrue(hd2.isUserDateVisible());
+        assertTrue(hd2.isDateTimeVisible());
+        assertEquals("August 06, 2008", hd2.getDateTimeText());
+
+        //the third slide uses per-slide headers / footers
+        HeadersFooters hd3 = slide[2].getHeadersFooters();
+        assertTrue(hd3.isFooterVisible());
+        assertEquals("THE FOOTER TEXT", hd3.getFooterText());
+        assertTrue(hd3.isSlideNumberVisible());
+        assertFalse(hd3.isHeaderVisible());
+        assertNull(hd3.getHeaderText());
+        assertTrue(hd3.isUserDateVisible());
+        assertTrue(hd3.isDateTimeVisible());
+        assertEquals("Wednesday, August 06, 2008", hd3.getDateTimeText());
+    }
+
+    public void testCreateSlideFooters() throws Exception
+    {
+        SlideShow ppt = new SlideShow();
+        HeadersFooters hdd = ppt.getSlideHeadersFooters();
+        hdd.setFootersText("My slide footer");
+        hdd.setSlideNumberVisible(true);
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ppt.write(out);
+        byte[] b = out.toByteArray();
+
+        SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b));
+        HeadersFooters hdd2 = ppt2.getSlideHeadersFooters();
+        assertTrue(hdd2.isSlideNumberVisible());
+        assertTrue(hdd2.isFooterVisible());
+        assertEquals("My slide footer", hdd2.getFooterText());
+    }
+
+    public void testCreateNotesFooters() throws Exception
+    {
+        SlideShow ppt = new SlideShow();
+        HeadersFooters hdd = ppt.getNotesHeadersFooters();
+        hdd.setFootersText("My notes footer");
+        hdd.setHeaderText("My notes header");
+        hdd.setSlideNumberVisible(true);
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ppt.write(out);
+        byte[] b = out.toByteArray();
+
+        SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b));
+        HeadersFooters hdd2 = ppt2.getNotesHeadersFooters();
+        assertTrue(hdd2.isSlideNumberVisible());
+        assertTrue(hdd2.isFooterVisible());
+        assertEquals("My notes footer", hdd2.getFooterText());
+        assertTrue(hdd2.isHeaderVisible());
+        assertEquals("My notes header", hdd2.getHeaderText());
+    }
+}
index 9108d3c36c6a3e12cc1d0dcefff86d7ef7f3eff2..48de8804e9f4b2142071d2d5e84b9277cdeb5129 100644 (file)
@@ -1,89 +1,90 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import junit.framework.TestCase;\r
-\r
-import java.io.FileInputStream;\r
-import java.io.File;\r
-\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-\r
-/**\r
- * Test Hyperlink.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestHyperlink extends TestCase {\r
-    protected String cwd = System.getProperty("HSLF.testdata.path");\r
-\r
-    public void testTextRunHyperlinks() throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "WithLinks.ppt"));\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        TextRun[] run;\r
-        Slide slide;\r
-        slide = ppt.getSlides()[0];\r
-        run = slide.getTextRuns();\r
-        for (int i = 0; i < run.length; i++) {\r
-            String text = run[i].getText();\r
-            if (text.equals(\r
-                    "This page has two links:\n" +\r
-                    "http://jakarta.apache.org/poi/\n" +\r
-                    "\n" +\r
-                    "http://slashdot.org/\n" +\r
-                    "\n" +\r
-                    "In addition, its notes has one link")){\r
-\r
-                Hyperlink[] links = run[i].getHyperlinks();\r
-                assertNotNull(links);\r
-                assertEquals(2, links.length);\r
-\r
-                assertEquals("http://jakarta.apache.org/poi/", links[0].getTitle());\r
-                assertEquals("http://jakarta.apache.org/poi/", links[0].getAddress());\r
-                assertEquals("http://jakarta.apache.org/poi/", text.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));\r
-\r
-                assertEquals("http://slashdot.org/", links[1].getTitle());\r
-                assertEquals("http://slashdot.org/", links[1].getAddress());\r
-                assertEquals("http://slashdot.org/", text.substring(links[1].getStartIndex(), links[1].getEndIndex()-1));\r
-\r
-            }\r
-        }\r
-\r
-        slide = ppt.getSlides()[1];\r
-        run = slide.getTextRuns();\r
-        for (int i = 0; i < run.length; i++) {\r
-            String text = run[i].getText();\r
-            if (text.equals(\r
-                    "I have the one link:\n" +\r
-                    "Jakarta HSSF")){\r
-\r
-                Hyperlink[] links = run[i].getHyperlinks();\r
-                assertNotNull(links);\r
-                assertEquals(1, links.length);\r
-\r
-                assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getTitle());\r
-                assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getAddress());\r
-                assertEquals("Jakarta HSSF", text.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));\r
-\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import junit.framework.TestCase;
+
+import java.io.FileInputStream;
+import java.io.File;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+
+/**
+ * Test Hyperlink.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestHyperlink extends TestCase {
+    protected String cwd = System.getProperty("HSLF.testdata.path");
+
+    public void testTextRunHyperlinks() throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "WithLinks.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        TextRun[] run;
+        Slide slide;
+        slide = ppt.getSlides()[0];
+        run = slide.getTextRuns();
+        for (int i = 0; i < run.length; i++) {
+            String text = run[i].getText();
+            if (text.equals(
+                    "This page has two links:\n" +
+                    "http://jakarta.apache.org/poi/\n" +
+                    "\n" +
+                    "http://slashdot.org/\n" +
+                    "\n" +
+                    "In addition, its notes has one link")){
+
+                Hyperlink[] links = run[i].getHyperlinks();
+                assertNotNull(links);
+                assertEquals(2, links.length);
+
+                assertEquals("http://jakarta.apache.org/poi/", links[0].getTitle());
+                assertEquals("http://jakarta.apache.org/poi/", links[0].getAddress());
+                assertEquals("http://jakarta.apache.org/poi/", text.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));
+
+                assertEquals("http://slashdot.org/", links[1].getTitle());
+                assertEquals("http://slashdot.org/", links[1].getAddress());
+                assertEquals("http://slashdot.org/", text.substring(links[1].getStartIndex(), links[1].getEndIndex()-1));
+
+            }
+        }
+
+        slide = ppt.getSlides()[1];
+        run = slide.getTextRuns();
+        for (int i = 0; i < run.length; i++) {
+            String text = run[i].getText();
+            if (text.equals(
+                    "I have the one link:\n" +
+                    "Jakarta HSSF")){
+
+                Hyperlink[] links = run[i].getHyperlinks();
+                assertNotNull(links);
+                assertEquals(1, links.length);
+
+                assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getTitle());
+                assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getAddress());
+                assertEquals("Jakarta HSSF", text.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));
+
+            }
+        }
+
+    }
+
+}
index d10dd135307119489ea91c1eab2079fe8cb79c7e..b230679bd31dff8d0da87d270368517e1a93b698 100755 (executable)
@@ -1,57 +1,58 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import junit.framework.*;\r
-\r
-import java.io.FileOutputStream;\r
-import java.io.File;\r
-import java.awt.*;\r
-\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.usermodel.PictureData;\r
-import org.apache.poi.hslf.HSLFSlideShow;\r
-import org.apache.poi.hslf.blip.ImagePainter;\r
-import org.apache.poi.hslf.blip.BitmapPainter;\r
-import org.apache.poi.ddf.EscherBSERecord;\r
-\r
-/**\r
- * Test Picture shape.\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class TestImagePainter extends TestCase {\r
-\r
-    private static class CustomImagePainer implements ImagePainter{\r
-        public void paint(Graphics2D graphics, PictureData pict, Picture parent){\r
-            //do noting\r
-        }\r
-\r
-    }\r
-\r
-    public void testImagePainter() throws Exception {\r
-\r
-        ImagePainter pntr = PictureData.getImagePainter(Picture.PNG);\r
-        assertTrue(PictureData.getImagePainter(Picture.PNG) instanceof BitmapPainter);\r
-        assertTrue(PictureData.getImagePainter(Picture.JPEG) instanceof BitmapPainter);\r
-        assertTrue(PictureData.getImagePainter(Picture.DIB) instanceof BitmapPainter);\r
-\r
-        PictureData.setImagePainter(Picture.WMF, new CustomImagePainer());\r
-        assertTrue(PictureData.getImagePainter(Picture.WMF) instanceof CustomImagePainer);\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import junit.framework.*;
+
+import java.io.FileOutputStream;
+import java.io.File;
+import java.awt.*;
+
+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;
+
+/**
+ * Test Picture shape.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestImagePainter extends TestCase {
+
+    private static class CustomImagePainer implements ImagePainter{
+        public void paint(Graphics2D graphics, PictureData pict, Picture parent){
+            //do noting
+        }
+
+    }
+
+    public void testImagePainter() throws Exception {
+
+        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);
+    }
+
+}
index 0138fb4192bb63191df0733a37ebf845da9a21cb..7e7c5d3b3b60bc9cd1dc0c0b221bff7b74442e8c 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import junit.framework.*;
@@ -26,10 +27,10 @@ import org.apache.poi.hslf.HSLFSlideShow;
 
 /**
  * Test Line shape.
- * 
+ *
  * @author Yegor Kozlov
  */
-public class TestLine extends TestCase {
+public final class TestLine extends TestCase {
 
     public void setUp() throws Exception {
 
index 9e0bfaf7722cc868a914fa7c580761091b71484d..8555bce98302215e24fcb0cea49f278b496e885d 100755 (executable)
@@ -1,66 +1,67 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import junit.framework.TestCase;\r
-\r
-import java.io.*;\r
-import java.awt.*;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.HSLFSlideShow;\r
-\r
-/**\r
- * Test <code>MovieShape</code> object.\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class TestMovieShape extends TestCase {\r
-\r
-    protected String cwd = System.getProperty("HSLF.testdata.path");\r
-\r
-    public void testCreate() throws Exception {\r
-        SlideShow ppt = new SlideShow();\r
-\r
-        Slide slide = ppt.createSlide();\r
-\r
-        String path = cwd + "/test-movie.mpg";\r
-        int movieIdx = ppt.addMovie(path, MovieShape.MOVIE_MPEG);\r
-        int thumbnailIdx = ppt.addPicture(new File(cwd, "tomcat.png"), Picture.PNG);\r
-\r
-        MovieShape shape = new MovieShape(movieIdx, thumbnailIdx);\r
-        shape.setAnchor(new Rectangle2D.Float(300,225,120,90));\r
-        slide.addShape(shape);\r
-\r
-        assertEquals(path, shape.getPath());\r
-        assertTrue(shape.isAutoPlay());\r
-        shape.setAutoPlay(false);\r
-        assertFalse(shape.isAutoPlay());\r
-\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        ppt.write(out);\r
-\r
-        ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));\r
-        slide = ppt.getSlides()[0];\r
-        shape = (MovieShape)slide.getShapes()[0];\r
-        assertEquals(path, shape.getPath());\r
-        assertFalse(shape.isAutoPlay());\r
-\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import junit.framework.TestCase;
+
+import java.io.*;
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.HSLFSlideShow;
+
+/**
+ * Test <code>MovieShape</code> object.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestMovieShape extends TestCase {
+
+    protected String cwd = System.getProperty("HSLF.testdata.path");
+
+    public void testCreate() throws Exception {
+        SlideShow ppt = new SlideShow();
+
+        Slide slide = ppt.createSlide();
+
+        String path = cwd + "/test-movie.mpg";
+        int movieIdx = ppt.addMovie(path, MovieShape.MOVIE_MPEG);
+        int thumbnailIdx = ppt.addPicture(new File(cwd, "tomcat.png"), Picture.PNG);
+
+        MovieShape shape = new MovieShape(movieIdx, thumbnailIdx);
+        shape.setAnchor(new Rectangle2D.Float(300,225,120,90));
+        slide.addShape(shape);
+
+        assertEquals(path, shape.getPath());
+        assertTrue(shape.isAutoPlay());
+        shape.setAutoPlay(false);
+        assertFalse(shape.isAutoPlay());
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ppt.write(out);
+
+        ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+        slide = ppt.getSlides()[0];
+        shape = (MovieShape)slide.getShapes()[0];
+        assertEquals(path, shape.getPath());
+        assertFalse(shape.isAutoPlay());
+
+    }
+
+}
index 9d0288c752ed8fa42b4202ff8cd4452f591d6212..e8fae8a37e2739000828e68cd5a9dfa2cb0cdba4 100644 (file)
@@ -1,92 +1,92 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.model;\r
-\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-\r
-import junit.framework.TestCase;\r
-\r
-import org.apache.poi.hslf.HSLFSlideShow;\r
-import org.apache.poi.hslf.usermodel.ObjectData;\r
-import org.apache.poi.hslf.usermodel.PictureData;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hssf.usermodel.HSSFSheet;\r
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;\r
-import org.apache.poi.hwpf.HWPFDocument;\r
-\r
-public final class TestOleEmbedding extends TestCase {\r
-    /**\r
-     * Tests support for OLE objects.\r
-     *\r
-     * @throws Exception if an error occurs.\r
-     */\r
-    public void testOleEmbedding2003() throws Exception {\r
-        String dirname = System.getProperty("HSLF.testdata.path");\r
-        File file = new File(dirname, "ole2-embedding-2003.ppt");\r
-        HSLFSlideShow slideShow = new HSLFSlideShow(new FileInputStream(file));\r
-        // Placeholder EMFs for clients that don't support the OLE components.\r
-        PictureData[] pictures = slideShow.getPictures();\r
-        assertEquals("Should be two pictures", 2, pictures.length);\r
-        //assertDigestEquals("Wrong data for picture 1", "8d1fbadf4814f321bb1ccdd056e3c788", pictures[0].getData());\r
-        //assertDigestEquals("Wrong data for picture 2", "987a698e83559cf3d38a0deeba1cc63b", pictures[1].getData());\r
-\r
-        // Actual embedded objects.\r
-        ObjectData[] objects = slideShow.getEmbeddedObjects();\r
-        assertEquals("Should be two objects", 2, objects.length);\r
-        //assertDigestEquals("Wrong data for objecs 1", "0d1fcc61a83de5c4894dc0c88e9a019d", objects[0].getData());\r
-        //assertDigestEquals("Wrong data for object 2", "b323604b2003a7299c77c2693b641495", objects[1].getData());\r
-    }\r
-\r
-    public void testOLEShape() throws Exception {\r
-        String dirname = System.getProperty("HSLF.testdata.path");\r
-        File file = new File(dirname, "ole2-embedding-2003.ppt");\r
-        FileInputStream is = new FileInputStream(file);\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        Slide slide = ppt.getSlides()[0];\r
-        Shape[] sh = slide.getShapes();\r
-        int cnt = 0;\r
-        for (int i = 0; i < sh.length; i++) {\r
-            if(sh[i] instanceof OLEShape){\r
-                cnt++;\r
-                OLEShape ole = (OLEShape)sh[i];\r
-                ObjectData data = ole.getObjectData();\r
-                if("Worksheet".equals(ole.getInstanceName())){\r
-                    //Voila! we created a workbook from the embedded OLE data\r
-                    HSSFWorkbook wb = new HSSFWorkbook(data.getData());\r
-                    HSSFSheet sheet = wb.getSheetAt(0);\r
-                    //verify we can access the xls data\r
-                    assertEquals(1, sheet.getRow(0).getCell(0).getNumericCellValue(), 0);\r
-                    assertEquals(1, sheet.getRow(1).getCell(0).getNumericCellValue(), 0);\r
-                    assertEquals(2, sheet.getRow(2).getCell(0).getNumericCellValue(), 0);\r
-                    assertEquals(3, sheet.getRow(3).getCell(0).getNumericCellValue(), 0);\r
-                    assertEquals(8, sheet.getRow(5).getCell(0).getNumericCellValue(), 0);\r
-                } else if ("Document".equals(ole.getInstanceName())){\r
-                    //creating a HWPF document \r
-                    HWPFDocument doc = new HWPFDocument(data.getData());\r
-                    String txt = doc.getRange().getParagraph(0).text();\r
-                    assertEquals("OLE embedding is thoroughly unremarkable.\r", txt);\r
-                }\r
-            }\r
-\r
-        }\r
-        assertEquals("Expected 2 OLE shapes", 2, cnt);\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.ObjectData;
+import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.hwpf.HWPFDocument;
+
+public final class TestOleEmbedding extends TestCase {
+    /**
+     * Tests support for OLE objects.
+     *
+     * @throws Exception if an error occurs.
+     */
+    public void testOleEmbedding2003() throws Exception {
+        String dirname = System.getProperty("HSLF.testdata.path");
+        File file = new File(dirname, "ole2-embedding-2003.ppt");
+        HSLFSlideShow slideShow = new HSLFSlideShow(new FileInputStream(file));
+        // Placeholder EMFs for clients that don't support the OLE components.
+        PictureData[] pictures = slideShow.getPictures();
+        assertEquals("Should be two pictures", 2, pictures.length);
+        //assertDigestEquals("Wrong data for picture 1", "8d1fbadf4814f321bb1ccdd056e3c788", pictures[0].getData());
+        //assertDigestEquals("Wrong data for picture 2", "987a698e83559cf3d38a0deeba1cc63b", pictures[1].getData());
+
+        // Actual embedded objects.
+        ObjectData[] objects = slideShow.getEmbeddedObjects();
+        assertEquals("Should be two objects", 2, objects.length);
+        //assertDigestEquals("Wrong data for objecs 1", "0d1fcc61a83de5c4894dc0c88e9a019d", objects[0].getData());
+        //assertDigestEquals("Wrong data for object 2", "b323604b2003a7299c77c2693b641495", objects[1].getData());
+    }
+
+    public void testOLEShape() throws Exception {
+        String dirname = System.getProperty("HSLF.testdata.path");
+        File file = new File(dirname, "ole2-embedding-2003.ppt");
+        FileInputStream is = new FileInputStream(file);
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        Slide slide = ppt.getSlides()[0];
+        Shape[] sh = slide.getShapes();
+        int cnt = 0;
+        for (int i = 0; i < sh.length; i++) {
+            if(sh[i] instanceof OLEShape){
+                cnt++;
+                OLEShape ole = (OLEShape)sh[i];
+                ObjectData data = ole.getObjectData();
+                if("Worksheet".equals(ole.getInstanceName())){
+                    //Voila! we created a workbook from the embedded OLE data
+                    HSSFWorkbook wb = new HSSFWorkbook(data.getData());
+                    HSSFSheet sheet = wb.getSheetAt(0);
+                    //verify we can access the xls data
+                    assertEquals(1, sheet.getRow(0).getCell(0).getNumericCellValue(), 0);
+                    assertEquals(1, sheet.getRow(1).getCell(0).getNumericCellValue(), 0);
+                    assertEquals(2, sheet.getRow(2).getCell(0).getNumericCellValue(), 0);
+                    assertEquals(3, sheet.getRow(3).getCell(0).getNumericCellValue(), 0);
+                    assertEquals(8, sheet.getRow(5).getCell(0).getNumericCellValue(), 0);
+                } else if ("Document".equals(ole.getInstanceName())){
+                    //creating a HWPF document
+                    HWPFDocument doc = new HWPFDocument(data.getData());
+                    String txt = doc.getRange().getParagraph(0).text();
+                    assertEquals("OLE embedding is thoroughly unremarkable.\r", txt);
+                }
+            }
+
+        }
+        assertEquals("Expected 2 OLE shapes", 2, cnt);
+    }
+}
index b6864ea16bc8965e0858d4517fde1881a51628c2..f445f2b62b3747ad6cc1f654f84c0522d502022c 100755 (executable)
@@ -1,56 +1,55 @@
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.model;\r
-\r
-import junit.framework.TestCase;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-\r
-import java.io.IOException;\r
-\r
-/**\r
- * Test adding fonts to the presenataion resources\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class TestPPFont extends TestCase{\r
-\r
-    public void testCreate() throws IOException {\r
-        SlideShow ppt = new SlideShow();\r
-        assertEquals(1, ppt.getNumberOfFonts());\r
-        assertEquals("Arial", ppt.getFont(0).getFontName());\r
-\r
-        //adding the same font twice\r
-        assertEquals(0, ppt.addFont(PPFont.ARIAL));\r
-        assertEquals(1, ppt.getNumberOfFonts());\r
-\r
-        assertEquals(1, ppt.addFont(PPFont.TIMES_NEW_ROMAN));\r
-        assertEquals(2, ppt.addFont(PPFont.COURIER_NEW));\r
-        assertEquals(3, ppt.addFont(PPFont.WINGDINGS));\r
-\r
-        assertEquals(4, ppt.getNumberOfFonts());\r
-\r
-        assertEquals(PPFont.TIMES_NEW_ROMAN.getFontName(), ppt.getFont(1).getFontName());\r
-        assertEquals(PPFont.COURIER_NEW.getFontName(), ppt.getFont(2).getFontName());\r
-\r
-        PPFont font3 = ppt.getFont(3);\r
-        assertEquals(PPFont.WINGDINGS.getFontName(), font3.getFontName());\r
-        assertEquals(PPFont.SYMBOL_CHARSET, font3.getCharSet());\r
-        assertEquals(PPFont.VARIABLE_PITCH, font3.getPitchAndFamily());\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import junit.framework.TestCase;
+import org.apache.poi.hslf.usermodel.SlideShow;
+
+import java.io.IOException;
+
+/**
+ * Test adding fonts to the presenataion resources
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestPPFont extends TestCase{
+
+    public void testCreate() throws IOException {
+        SlideShow ppt = new SlideShow();
+        assertEquals(1, ppt.getNumberOfFonts());
+        assertEquals("Arial", ppt.getFont(0).getFontName());
+
+        //adding the same font twice
+        assertEquals(0, ppt.addFont(PPFont.ARIAL));
+        assertEquals(1, ppt.getNumberOfFonts());
+
+        assertEquals(1, ppt.addFont(PPFont.TIMES_NEW_ROMAN));
+        assertEquals(2, ppt.addFont(PPFont.COURIER_NEW));
+        assertEquals(3, ppt.addFont(PPFont.WINGDINGS));
+
+        assertEquals(4, ppt.getNumberOfFonts());
+
+        assertEquals(PPFont.TIMES_NEW_ROMAN.getFontName(), ppt.getFont(1).getFontName());
+        assertEquals(PPFont.COURIER_NEW.getFontName(), ppt.getFont(2).getFontName());
+
+        PPFont font3 = ppt.getFont(3);
+        assertEquals(PPFont.WINGDINGS.getFontName(), font3.getFontName());
+        assertEquals(PPFont.SYMBOL_CHARSET, font3.getCharSet());
+        assertEquals(PPFont.VARIABLE_PITCH, font3.getPitchAndFamily());
+    }
+}
index 7efe956e201ab033e07e74d226918850349118d5..521230077e250b82757c010b463316de54d792b3 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import junit.framework.TestCase;
@@ -30,7 +31,7 @@ import java.io.ByteArrayInputStream;
  *
  * @author Yegor Kozlov
  */
-public class TestPPGraphics2D extends TestCase {
+public final class TestPPGraphics2D extends TestCase {
     private SlideShow ppt;
 
     protected void setUp() throws Exception {
@@ -42,7 +43,7 @@ public class TestPPGraphics2D extends TestCase {
     public void testGraphics() throws Exception {
        // Starts off empty
        assertEquals(0, ppt.getSlides().length);
-       
+
        // Add a slide
         Slide slide = ppt.createSlide();
        assertEquals(1, ppt.getSlides().length);
index b4a362ae8dced821e36ae1817b46df838bb6d0a1..b3f5942f39776375dfee2575dab67a331a743caf 100755 (executable)
@@ -1,96 +1,97 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import junit.framework.*;\r
-\r
-import java.io.FileOutputStream;\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.awt.*;\r
-import java.awt.image.BufferedImage;\r
-\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.usermodel.PictureData;\r
-import org.apache.poi.hslf.HSLFSlideShow;\r
-import org.apache.poi.ddf.EscherBSERecord;\r
-\r
-/**\r
- * Test Picture shape.\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class TestPicture extends TestCase {\r
-\r
-    /**\r
-     * Test that the reference count of a blip is incremented every time the picture is inserted.\r
-     * This is important when the same image appears multiple times in a slide show.\r
-     *\r
-     */\r
-    public void testMultiplePictures() throws Exception {\r
-        String cwd = System.getProperty("HSLF.testdata.path");\r
-        SlideShow ppt = new SlideShow();\r
-\r
-        Slide s = ppt.createSlide();\r
-        Slide s2 = ppt.createSlide();\r
-        Slide s3 = ppt.createSlide();\r
-\r
-        int idx = ppt.addPicture(new File(cwd, "clock.jpg"), Picture.JPEG);\r
-        Picture pict = new Picture(idx);\r
-        Picture pict2 = new Picture(idx);\r
-        Picture pict3 = new Picture(idx);\r
-\r
-        pict.setAnchor(new Rectangle(10,10,100,100));\r
-        s.addShape(pict);\r
-        EscherBSERecord bse1 = pict.getEscherBSERecord();\r
-        assertEquals(1, bse1.getRef());\r
-\r
-        pict2.setAnchor(new Rectangle(10,10,100,100));\r
-        s2.addShape(pict2);\r
-        EscherBSERecord bse2 = pict.getEscherBSERecord();\r
-        assertSame(bse1, bse2);\r
-        assertEquals(2, bse1.getRef());\r
-\r
-        pict3.setAnchor(new Rectangle(10,10,100,100));\r
-        s3.addShape(pict3);\r
-        EscherBSERecord bse3 = pict.getEscherBSERecord();\r
-        assertSame(bse2, bse3);\r
-        assertEquals(3, bse1.getRef());\r
-\r
-    }\r
-\r
-    /**\r
-     * Picture#getEscherBSERecord threw NullPointerException if EscherContainerRecord.BSTORE_CONTAINER\r
-     * was not found. The correct behaviour is to return null.\r
-     */\r
-    public void test46122() throws IOException {\r
-        SlideShow ppt = new SlideShow();\r
-        Slide slide = ppt.createSlide();\r
-\r
-        Picture pict = new Picture(-1); //index to non-existing picture data\r
-        pict.setSheet(slide);\r
-        PictureData data = pict.getPictureData();\r
-        assertNull(data);\r
-\r
-        BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);\r
-        Graphics2D graphics = img.createGraphics();\r
-        pict.draw(graphics);\r
-\r
-        assertTrue("no errors rendering Picture with null data", true);\r
-    }\r
-\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import junit.framework.*;
+
+import java.io.FileOutputStream;
+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 org.apache.poi.ddf.EscherBSERecord;
+
+/**
+ * Test Picture shape.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestPicture extends TestCase {
+
+    /**
+     * Test that the reference count of a blip is incremented every time the picture is inserted.
+     * This is important when the same image appears multiple times in a slide show.
+     *
+     */
+    public void testMultiplePictures() throws Exception {
+        String cwd = System.getProperty("HSLF.testdata.path");
+        SlideShow ppt = new SlideShow();
+
+        Slide s = ppt.createSlide();
+        Slide s2 = ppt.createSlide();
+        Slide s3 = ppt.createSlide();
+
+        int idx = ppt.addPicture(new File(cwd, "clock.jpg"), Picture.JPEG);
+        Picture pict = new Picture(idx);
+        Picture pict2 = new Picture(idx);
+        Picture pict3 = new Picture(idx);
+
+        pict.setAnchor(new Rectangle(10,10,100,100));
+        s.addShape(pict);
+        EscherBSERecord bse1 = pict.getEscherBSERecord();
+        assertEquals(1, bse1.getRef());
+
+        pict2.setAnchor(new Rectangle(10,10,100,100));
+        s2.addShape(pict2);
+        EscherBSERecord bse2 = pict.getEscherBSERecord();
+        assertSame(bse1, bse2);
+        assertEquals(2, bse1.getRef());
+
+        pict3.setAnchor(new Rectangle(10,10,100,100));
+        s3.addShape(pict3);
+        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 {
+        SlideShow ppt = new SlideShow();
+        Slide slide = ppt.createSlide();
+
+        Picture pict = new Picture(-1); //index to non-existing picture data
+        pict.setSheet(slide);
+        PictureData data = pict.getPictureData();
+        assertNull(data);
+
+        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 a75c2e73ab705d62b6d207fc304cc5e9ad270667..572dbd035c708d8202d1dd204a068e9a28ecde58 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import junit.framework.TestCase;
@@ -29,7 +30,7 @@ import java.io.ByteArrayInputStream;
  *
  * @author Yegor Kozlov
  */
-public class TestSetBoldItalic extends TestCase {
+public final class TestSetBoldItalic extends TestCase {
     /**
      * Verify that we can add TextBox shapes to a slide
      * and set some of the style attributes
index 3ce6b91caf285bed18a5313b35342b1e36a9514c..77e2efa08a4d816b41f9daba300cb88ad1c99754 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import junit.framework.TestCase;
@@ -36,7 +37,7 @@ import java.util.ArrayList;
  *
  * @author Yegor Kozlov
  */
-public class TestShapes extends TestCase {
+public final class TestShapes extends TestCase {
     private SlideShow ppt;
     private SlideShow pptB;
 
@@ -44,7 +45,7 @@ public class TestShapes extends TestCase {
                String dirname = System.getProperty("HSLF.testdata.path");
                String filename = dirname + "/empty.ppt";
                ppt = new SlideShow(new HSLFSlideShow(filename));
-               
+
                String filenameB = dirname + "/empty_textbox.ppt";
                pptB = new SlideShow(new HSLFSlideShow(filenameB));
     }
@@ -166,7 +167,7 @@ public class TestShapes extends TestCase {
 
         ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
         sl = ppt.getSlides()[0];
-        
+
         txtbox = (TextBox)sl.getShapes()[0];
         rt = txtbox.getTextRun().getRichTextRuns()[0];
 
@@ -179,7 +180,7 @@ public class TestShapes extends TestCase {
         assertEquals("Arial", rt.getFontName());
         assertEquals(Color.red, rt.getFontColor());
     }
-    
+
     /**
      * Test with an empty text box
      */
@@ -187,7 +188,7 @@ public class TestShapes extends TestCase {
        assertEquals(2, pptB.getSlides().length);
        Slide s1 = pptB.getSlides()[0];
        Slide s2 = pptB.getSlides()[1];
-       
+
        // Check we can get the shapes count
        assertEquals(2, s1.getShapes().length);
        assertEquals(2, s2.getShapes().length);
index 1fe9ada7fc328bc9134f09f9978c1b2039100361..0282c2a7e6e5ea3bed147543362dc209ca3fc11b 100644 (file)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import junit.framework.TestCase;\r
-\r
-import java.io.FileInputStream;\r
-import java.io.File;\r
-\r
-import org.apache.poi.hslf.HSLFSlideShow;\r
-import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;\r
-import org.apache.poi.hslf.record.ColorSchemeAtom;\r
-import org.apache.poi.hslf.record.PPDrawing;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-\r
-/**\r
- * Test common functionality of the <code>Sheet</code> object.\r
- * For each ppt in the test directory check that all sheets are properly initialized\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestSheet extends TestCase{\r
-\r
-    /**\r
-     * For each ppt in the test directory check that all sheets are properly initialized\r
-     */\r
-    public void testSheet() throws Exception {\r
-        File home = new File(System.getProperty("HSLF.testdata.path"));\r
-        File[] files = home.listFiles();\r
-        for (int i = 0; i < files.length; i++) {\r
-            if(!files[i].getName().endsWith(".ppt")) continue;\r
-            if(files[i].getName().endsWith("PPT95.ppt")) continue;\r
-            \r
-            try {\r
-                FileInputStream is = new FileInputStream(files[i]);\r
-                HSLFSlideShow hslf = new HSLFSlideShow(is);\r
-                is.close();\r
-\r
-                SlideShow ppt = new SlideShow(hslf);\r
-                doSlideShow(ppt);\r
-            } catch (EncryptedPowerPointFileException e){\r
-                ; //skip encrypted ppt\r
-            }\r
-        }\r
-    }\r
-\r
-    private void doSlideShow(SlideShow ppt) throws Exception {\r
-        Slide[] slide = ppt.getSlides();\r
-        for (int i = 0; i < slide.length; i++) {\r
-            verify(slide[i]);\r
-\r
-            Notes notes = slide[i].getNotesSheet();\r
-            if(notes != null) verify(notes);\r
-\r
-            MasterSheet master = slide[i].getMasterSheet();\r
-            assertNotNull(master);\r
-            verify(master);\r
-        }\r
-    }\r
-\r
-    private void verify(Sheet sheet){\r
-        assertNotNull(sheet.getSlideShow());\r
-\r
-        ColorSchemeAtom colorscheme = sheet.getColorScheme();\r
-        assertNotNull(colorscheme);\r
-\r
-        PPDrawing ppdrawing = sheet.getPPDrawing();\r
-        assertNotNull(ppdrawing);\r
-\r
-        Background background = sheet.getBackground();\r
-        assertNotNull(background);\r
-\r
-        assertTrue(sheet._getSheetNumber() != 0);\r
-        assertTrue(sheet._getSheetRefId() != 0);\r
-\r
-        TextRun[] txt = sheet.getTextRuns();\r
-        assertTrue(txt != null);\r
-        for (int i = 0; i < txt.length; i++) {\r
-            assertNotNull(txt[i].getSheet());\r
-        }\r
-\r
-        Shape[] shape = sheet.getShapes();\r
-        assertTrue(shape != null);\r
-        for (int i = 0; i < shape.length; i++) {\r
-            assertNotNull(shape[i].getSpContainer());\r
-            assertNotNull(shape[i].getSheet());\r
-            assertNotNull(shape[i].getShapeName());\r
-            assertNotNull(shape[i].getAnchor());\r
-        }\r
-\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import junit.framework.TestCase;
+
+import java.io.FileInputStream;
+import java.io.File;
+
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
+import org.apache.poi.hslf.record.ColorSchemeAtom;
+import org.apache.poi.hslf.record.PPDrawing;
+import org.apache.poi.hslf.usermodel.SlideShow;
+
+/**
+ * Test common functionality of the <code>Sheet</code> object.
+ * For each ppt in the test directory check that all sheets are properly initialized
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestSheet extends TestCase{
+
+    /**
+     * For each ppt in the test directory check that all sheets are properly initialized
+     */
+    public void testSheet() throws Exception {
+        File home = new File(System.getProperty("HSLF.testdata.path"));
+        File[] files = home.listFiles();
+        for (int i = 0; i < files.length; i++) {
+            if(!files[i].getName().endsWith(".ppt")) continue;
+            if(files[i].getName().endsWith("PPT95.ppt")) continue;
+
+            try {
+                FileInputStream is = new FileInputStream(files[i]);
+                HSLFSlideShow hslf = new HSLFSlideShow(is);
+                is.close();
+
+                SlideShow ppt = new SlideShow(hslf);
+                doSlideShow(ppt);
+            } catch (EncryptedPowerPointFileException e){
+                ; //skip encrypted ppt
+            }
+        }
+    }
+
+    private void doSlideShow(SlideShow ppt) throws Exception {
+        Slide[] slide = ppt.getSlides();
+        for (int i = 0; i < slide.length; i++) {
+            verify(slide[i]);
+
+            Notes notes = slide[i].getNotesSheet();
+            if(notes != null) verify(notes);
+
+            MasterSheet master = slide[i].getMasterSheet();
+            assertNotNull(master);
+            verify(master);
+        }
+    }
+
+    private void verify(Sheet sheet){
+        assertNotNull(sheet.getSlideShow());
+
+        ColorSchemeAtom colorscheme = sheet.getColorScheme();
+        assertNotNull(colorscheme);
+
+        PPDrawing ppdrawing = sheet.getPPDrawing();
+        assertNotNull(ppdrawing);
+
+        Background background = sheet.getBackground();
+        assertNotNull(background);
+
+        assertTrue(sheet._getSheetNumber() != 0);
+        assertTrue(sheet._getSheetRefId() != 0);
+
+        TextRun[] txt = sheet.getTextRuns();
+        assertTrue(txt != null);
+        for (int i = 0; i < txt.length; i++) {
+            assertNotNull(txt[i].getSheet());
+        }
+
+        Shape[] shape = sheet.getShapes();
+        assertTrue(shape != null);
+        for (int i = 0; i < shape.length; i++) {
+            assertNotNull(shape[i].getSpContainer());
+            assertNotNull(shape[i].getSheet());
+            assertNotNull(shape[i].getShapeName());
+            assertNotNull(shape[i].getAnchor());
+        }
+
+    }
+}
index 0b09e44f62da25788c61232ef2b8bc1148351701..a6b17ec41c645974f92f5f6b3a8007f078478bbc 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.model;
 
@@ -32,7 +29,7 @@ import org.apache.poi.hslf.record.SlideAtom;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestSlideChangeNotes extends TestCase {
+public final class TestSlideChangeNotes extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
 
index 9a733b565d232b77845e84f2a5fcab8901f60bb3..9799eb0069ce70920af630356f881e75345bea00 100644 (file)
@@ -31,10 +31,10 @@ import java.awt.*;
 
 /**
  * Tests for SlideMaster
- * 
+ *
  * @author Yegor Kozlov
  */
-public class TestSlideMaster extends TestCase{
+public final class TestSlideMaster extends TestCase{
     String home;
 
     public void setUp() throws Exception {
index 4b8035355d337cffd5a2160fdd9dd5579973a84d..f60cfed57d5fa74b20e374f1ead9fd9192a52726 100644 (file)
@@ -26,12 +26,12 @@ import java.io.ByteArrayInputStream;
 
 /**
  * Test adding new slides to a ppt.
- * 
- * Note - uses the same empty PPT file as the core "new Slideshow" 
+ *
+ * Note - uses the same empty PPT file as the core "new Slideshow"
  *  stuff does
  * @author Yegor Kozlov
  */
-public class TestSlides extends TestCase {
+public final class TestSlides extends TestCase {
 
     /**
      * Add 1 slide to an empty ppt.
@@ -40,7 +40,7 @@ public class TestSlides extends TestCase {
     public void testAddSlides1() throws Exception {
         SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
         assertTrue(ppt.getSlides().length == 0);
-        
+
         Slide s1 = ppt.createSlide();
         assertTrue(ppt.getSlides().length == 1);
         assertEquals(3, s1._getSheetRefId());
@@ -63,13 +63,13 @@ public class TestSlides extends TestCase {
     public void testAddSlides2() throws Exception {
         SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
         assertTrue(ppt.getSlides().length == 0);
-        
+
         Slide s1 = ppt.createSlide();
         assertTrue(ppt.getSlides().length == 1);
         assertEquals(3, s1._getSheetRefId());
         assertEquals(256, s1._getSheetNumber());
         assertEquals(1, s1.getSlideNumber());
-        
+
         Slide s2 = ppt.createSlide();
         assertTrue(ppt.getSlides().length == 2);
         assertEquals(4, s2._getSheetRefId());
@@ -92,13 +92,13 @@ public class TestSlides extends TestCase {
     public void testAddSlides3() throws Exception {
         SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
         assertTrue(ppt.getSlides().length == 0);
-        
+
         Slide s1 = ppt.createSlide();
         assertTrue(ppt.getSlides().length == 1);
         assertEquals(3, s1._getSheetRefId());
         assertEquals(256, s1._getSheetNumber());
         assertEquals(1, s1.getSlideNumber());
-        
+
         Slide s2 = ppt.createSlide();
         assertTrue(ppt.getSlides().length == 2);
         assertEquals(4, s2._getSheetRefId());
@@ -111,7 +111,7 @@ public class TestSlides extends TestCase {
         assertEquals(258, s3._getSheetNumber());
         assertEquals(3, s3.getSlideNumber());
 
-        
+
         //serialize and read again
          ByteArrayOutputStream out = new ByteArrayOutputStream();
         ppt.write(out);
@@ -119,7 +119,7 @@ public class TestSlides extends TestCase {
 
         ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
         assertTrue(ppt.getSlides().length == 3);
-        
+
         // Check IDs are still right
         s1 = ppt.getSlides()[0];
         assertEquals(256, s1._getSheetNumber());
@@ -139,26 +139,26 @@ public class TestSlides extends TestCase {
     public void testAddSlides2to3() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
         SlideShow ppt = new SlideShow(new HSLFSlideShow(dirname + "/basic_test_ppt_file.ppt"));
-        
+
         assertTrue(ppt.getSlides().length == 2);
-        
+
         // First slide is 256 / 4
         Slide s1 = ppt.getSlides()[0];
         assertEquals(256, s1._getSheetNumber());
         assertEquals(4, s1._getSheetRefId());
-        
+
         // Last slide is 257 / 6
         Slide s2 = ppt.getSlides()[1];
         assertEquals(257, s2._getSheetNumber());
         assertEquals(6, s2._getSheetRefId());
-        
+
         // Add another slide, goes in at the end
         Slide s3 = ppt.createSlide();
         assertTrue(ppt.getSlides().length == 3);
         assertEquals(258, s3._getSheetNumber());
         assertEquals(8, s3._getSheetRefId());
 
-        
+
         // Serialize and read again
          ByteArrayOutputStream out = new ByteArrayOutputStream();
         ppt.write(out);
@@ -166,8 +166,8 @@ public class TestSlides extends TestCase {
 
         ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
         assertTrue(ppt.getSlides().length == 3);
-        
-        
+
+
         // Check IDs are still right
         s1 = ppt.getSlides()[0];
         assertEquals(256, s1._getSheetNumber());
index 8a9cf7da27a36dea4e2e6b09e3b7b93aeed3e320..d3c10cbea10106f6597f015c3efb8d99b626eb4e 100755 (executable)
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.model;\r
-\r
-import junit.framework.TestCase;\r
-\r
-import java.io.*;\r
-import java.awt.*;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.HSLFSlideShow;\r
-import org.apache.poi.hslf.record.TextHeaderAtom;\r
-\r
-/**\r
- * Test <code>Table</code> object.\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class TestTable extends TestCase {\r
-\r
-    /**\r
-     * Test that ShapeFactory works properly and returns <code>Table</code>\r
-     */\r
-    public void testShapeFactory() throws Exception {\r
-        SlideShow ppt = new SlideShow();\r
-\r
-        Slide slide = ppt.createSlide();\r
-\r
-        Table tbl = new Table(2, 5);\r
-        slide.addShape(tbl);\r
-\r
-        TableCell cell = tbl.getCell(0, 0);\r
-        //table cells have type=TextHeaderAtom.OTHER_TYPE, see bug #46033\r
-        assertEquals(TextHeaderAtom.OTHER_TYPE, cell.getTextRun().getRunType());\r
-\r
-        assertTrue(slide.getShapes()[0] instanceof Table);\r
-        Table tbl2 = (Table)slide.getShapes()[0];\r
-        assertEquals(tbl.getNumberOfColumns(), tbl2.getNumberOfColumns());\r
-        assertEquals(tbl.getNumberOfRows(), tbl2.getNumberOfRows());\r
-\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        ppt.write(out);\r
-        out.close();\r
-\r
-        ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));\r
-        slide = ppt.getSlides()[0];\r
-        assertTrue(slide.getShapes()[0] instanceof Table);\r
-        Table tbl3 = (Table)slide.getShapes()[0];\r
-        assertEquals(tbl.getNumberOfColumns(), tbl3.getNumberOfColumns());\r
-        assertEquals(tbl.getNumberOfRows(), tbl3.getNumberOfRows());\r
-    }\r
-\r
-    /**\r
-     * Error constructing Table when rownum=1\r
-     */\r
-    public void test45889(){\r
-        SlideShow ppt = new SlideShow();\r
-        Slide slide = ppt.createSlide();\r
-        Shape[] shapes;\r
-        Table tbl1 = new Table(1, 5);\r
-        assertEquals(5, tbl1.getNumberOfColumns());\r
-        assertEquals(1, tbl1.getNumberOfRows());\r
-        slide.addShape(tbl1);\r
-\r
-        shapes = slide.getShapes();\r
-        assertEquals(1, shapes.length);\r
-\r
-        Table tbl2 = (Table)shapes[0];\r
-        assertSame(tbl1.getSpContainer(), tbl2.getSpContainer());\r
-\r
-        assertEquals(tbl1.getNumberOfColumns(), tbl2.getNumberOfColumns());\r
-        assertEquals(tbl1.getNumberOfRows(), tbl2.getNumberOfRows());\r
-    }\r
-\r
-    public void testIllegalCOnstruction(){\r
-        try {\r
-            Table tbl = new Table(0, 5);\r
-            fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");\r
-        } catch (IllegalArgumentException e){\r
-\r
-        }\r
-        try {\r
-            Table tbl = new Table(5, 0);\r
-            fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");\r
-        } catch (IllegalArgumentException e){\r
-\r
-        }\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import junit.framework.TestCase;
+
+import java.io.*;
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+
+/**
+ * Test <code>Table</code> object.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestTable extends TestCase {
+
+    /**
+     * Test that ShapeFactory works properly and returns <code>Table</code>
+     */
+    public void testShapeFactory() throws Exception {
+        SlideShow ppt = new SlideShow();
+
+        Slide slide = ppt.createSlide();
+
+        Table tbl = new Table(2, 5);
+        slide.addShape(tbl);
+
+        TableCell cell = tbl.getCell(0, 0);
+        //table cells have type=TextHeaderAtom.OTHER_TYPE, see bug #46033
+        assertEquals(TextHeaderAtom.OTHER_TYPE, cell.getTextRun().getRunType());
+
+        assertTrue(slide.getShapes()[0] instanceof Table);
+        Table tbl2 = (Table)slide.getShapes()[0];
+        assertEquals(tbl.getNumberOfColumns(), tbl2.getNumberOfColumns());
+        assertEquals(tbl.getNumberOfRows(), tbl2.getNumberOfRows());
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ppt.write(out);
+        out.close();
+
+        ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+        slide = ppt.getSlides()[0];
+        assertTrue(slide.getShapes()[0] instanceof Table);
+        Table tbl3 = (Table)slide.getShapes()[0];
+        assertEquals(tbl.getNumberOfColumns(), tbl3.getNumberOfColumns());
+        assertEquals(tbl.getNumberOfRows(), tbl3.getNumberOfRows());
+    }
+
+    /**
+     * Error constructing Table when rownum=1
+     */
+    public void test45889(){
+        SlideShow ppt = new SlideShow();
+        Slide slide = ppt.createSlide();
+        Shape[] shapes;
+        Table tbl1 = new Table(1, 5);
+        assertEquals(5, tbl1.getNumberOfColumns());
+        assertEquals(1, tbl1.getNumberOfRows());
+        slide.addShape(tbl1);
+
+        shapes = slide.getShapes();
+        assertEquals(1, shapes.length);
+
+        Table tbl2 = (Table)shapes[0];
+        assertSame(tbl1.getSpContainer(), tbl2.getSpContainer());
+
+        assertEquals(tbl1.getNumberOfColumns(), tbl2.getNumberOfColumns());
+        assertEquals(tbl1.getNumberOfRows(), tbl2.getNumberOfRows());
+    }
+
+    public void testIllegalCOnstruction(){
+        try {
+            Table tbl = 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);
+            fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");
+        } catch (IllegalArgumentException e){
+
+        }
+    }
+}
index 6463da4c317b1daa993e588bd26d88c17772d4b3..2fcc6927c70d046a325ead39e0904cf17eab93f2 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.model;
 
@@ -36,7 +33,7 @@ import org.apache.poi.hslf.usermodel.SlideShow;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestTextRun extends TestCase {
+public final class TestTextRun extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
        private SlideShow ssRich;
@@ -45,12 +42,12 @@ public class TestTextRun extends TestCase {
 
     protected void setUp() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
-               
+
                // Basic (non rich) test file
                String filename = dirname + "/basic_test_ppt_file.ppt";
                hss = new HSLFSlideShow(filename);
                ss = new SlideShow(hss);
-               
+
                // Rich test file
                filename = dirname + "/Single_Coloured_Page.ppt";
                hssRich = new HSLFSlideShow(filename);
@@ -65,16 +62,16 @@ public class TestTextRun extends TestCase {
                TextRun[] textRuns = slideOne.getTextRuns();
 
                assertEquals(2, textRuns.length);
-               
+
                // Get text works with \n
                assertEquals("This is a test title", textRuns[0].getText());
                assertEquals("This is a test subtitle\nThis is on page 1", textRuns[1].getText());
-               
+
                // Raw text has \r instead
                assertEquals("This is a test title", textRuns[0].getRawText());
                assertEquals("This is a test subtitle\rThis is on page 1", textRuns[1].getRawText());
-               
-               
+
+
                // Now check on a rich text run
                Slide slideOneR = ssRich.getSlides()[0];
                TextRun[] textRunsR = slideOneR.getTextRuns();
@@ -85,7 +82,7 @@ public class TestTextRun extends TestCase {
                assertEquals("This is a title, it\u2019s in black", textRunsR[0].getRawText());
                assertEquals("This is the subtitle, in bold\rThis bit is blue and italic\rThis bit is red (normal)", textRunsR[1].getRawText());
     }
-    
+
     /**
      * Test to ensure changing non rich text bytes->bytes works correctly
      */
@@ -96,12 +93,12 @@ public class TestTextRun extends TestCase {
 
                // Check current text
                assertEquals("This is a test title", run.getText());
-               
+
                // Change
                String changeTo = "New test title";
                run.setText(changeTo);
                assertEquals(changeTo, run.getText());
-               
+
                // Ensure trailing \n's get stripped
                run.setText(changeTo + "\n");
                assertEquals(changeTo, run.getText());
@@ -114,7 +111,7 @@ public class TestTextRun extends TestCase {
     public void testAdvancedSetText() throws Exception {
                Slide slideOne = ss.getSlides()[0];
                TextRun run = slideOne.getTextRuns()[0];
-               
+
                TextHeaderAtom tha = run._headerAtom;
                TextBytesAtom tba = run._byteAtom;
                TextCharsAtom tca = run._charAtom;
@@ -124,50 +121,50 @@ public class TestTextRun extends TestCase {
                assertNotNull(tba);
                assertFalse(run._isUnicode);
                assertEquals("This is a test title", run.getText());
-               
+
                String changeBytesOnly = "New Test Title";
                run.setText(changeBytesOnly);
                tba = run._byteAtom;
                tca = run._charAtom;
-               
+
                assertEquals(changeBytesOnly, run.getText());
                assertFalse(run._isUnicode);
                assertNull(tca);
                assertNotNull(tba);
-               
+
        // Bytes -> Chars
                assertNull(tca);
                assertNotNull(tba);
                assertFalse(run._isUnicode);
                assertEquals(changeBytesOnly, run.getText());
-               
+
                String changeByteChar = "This is a test title with a '\u0121' g with a dot";
                run.setText(changeByteChar);
                tba = run._byteAtom;
                tca = run._charAtom;
-               
+
                assertEquals(changeByteChar, run.getText());
                assertTrue(run._isUnicode);
                assertNotNull(tca);
                assertNull(tba);
-               
+
        // Chars -> Chars
                assertNull(tba);
                assertNotNull(tca);
                assertTrue(run._isUnicode);
                assertEquals(changeByteChar, run.getText());
-               
+
                String changeCharChar = "This is a test title with a '\u0147' N with a hat";
                run.setText(changeCharChar);
                tba = run._byteAtom;
                tca = run._charAtom;
-               
+
                assertEquals(changeCharChar, run.getText());
                assertTrue(run._isUnicode);
                assertNotNull(tca);
                assertNull(tba);
     }
-    
+
     /**
      * Tests to ensure that non rich text has the right default rich text run
      *  set up for it
@@ -180,22 +177,22 @@ public class TestTextRun extends TestCase {
 
                TextRun trA = textRuns[0];
                TextRun trB = textRuns[1];
-               
+
                assertEquals(1, trA.getRichTextRuns().length);
                assertEquals(1, trB.getRichTextRuns().length);
-               
+
                RichTextRun rtrA = trA.getRichTextRuns()[0];
                RichTextRun rtrB = trB.getRichTextRuns()[0];
-               
+
                assertEquals(trA.getText(), rtrA.getText());
                assertEquals(trB.getText(), rtrB.getText());
-               
+
                assertNull(rtrA._getRawCharacterStyle());
                assertNull(rtrA._getRawParagraphStyle());
                assertNull(rtrB._getRawCharacterStyle());
                assertNull(rtrB._getRawParagraphStyle());
     }
-    
+
     /**
      * Tests to ensure that the rich text runs are built up correctly
      */
@@ -207,21 +204,21 @@ public class TestTextRun extends TestCase {
 
                TextRun trA = textRuns[0];
                TextRun trB = textRuns[1];
-               
+
                assertEquals(1, trA.getRichTextRuns().length);
                assertEquals(3, trB.getRichTextRuns().length);
-               
+
                RichTextRun rtrA = trA.getRichTextRuns()[0];
                RichTextRun rtrB = trB.getRichTextRuns()[0];
                RichTextRun rtrC = trB.getRichTextRuns()[1];
                RichTextRun rtrD = trB.getRichTextRuns()[2];
-               
+
                assertEquals(trA.getText(), rtrA.getText());
-               
+
                assertEquals(trB.getText().substring(0, 30), rtrB.getText());
                assertEquals(trB.getText().substring(30,58), rtrC.getText());
                assertEquals(trB.getText().substring(58,82), rtrD.getText());
-               
+
                assertNull(rtrA._getRawCharacterStyle());
                assertNull(rtrA._getRawParagraphStyle());
                assertNotNull(rtrB._getRawCharacterStyle());
@@ -230,17 +227,17 @@ public class TestTextRun extends TestCase {
                assertNotNull(rtrC._getRawParagraphStyle());
                assertNotNull(rtrD._getRawCharacterStyle());
                assertNotNull(rtrD._getRawParagraphStyle());
-               
+
                // Same paragraph styles
                assertEquals(rtrB._getRawParagraphStyle(), rtrC._getRawParagraphStyle());
                assertEquals(rtrB._getRawParagraphStyle(), rtrD._getRawParagraphStyle());
-               
+
                // Different char styles
                assertFalse( rtrB._getRawCharacterStyle().equals( rtrC._getRawCharacterStyle() ));
                assertFalse( rtrB._getRawCharacterStyle().equals( rtrD._getRawCharacterStyle() ));
                assertFalse( rtrC._getRawCharacterStyle().equals( rtrD._getRawCharacterStyle() ));
     }
-    
+
     /**
      * Tests to ensure that setting the text where the text isn't rich,
      *  ensuring that everything stays with the same default styling
@@ -250,12 +247,12 @@ public class TestTextRun extends TestCase {
                TextRun[] textRuns = slideOne.getTextRuns();
                TextRun trB = textRuns[1];
                assertEquals(1, trB.getRichTextRuns().length);
-               
+
                RichTextRun rtrB = trB.getRichTextRuns()[0];
                assertEquals(trB.getText(), rtrB.getText());
                assertNull(rtrB._getRawCharacterStyle());
                assertNull(rtrB._getRawParagraphStyle());
-               
+
                // Change text via normal
                trB.setText("Test Foo Test");
                rtrB = trB.getRichTextRuns()[0];
@@ -264,7 +261,7 @@ public class TestTextRun extends TestCase {
                assertNull(rtrB._getRawCharacterStyle());
                assertNull(rtrB._getRawParagraphStyle());
     }
-    
+
     /**
      * Tests to ensure that setting the text where the text is rich
      *  sets everything to the same styling
@@ -274,7 +271,7 @@ public class TestTextRun extends TestCase {
                TextRun[] textRuns = slideOne.getTextRuns();
                TextRun trB = textRuns[1];
                assertEquals(3, trB.getRichTextRuns().length);
-               
+
                RichTextRun rtrB = trB.getRichTextRuns()[0];
                RichTextRun rtrC = trB.getRichTextRuns()[1];
                RichTextRun rtrD = trB.getRichTextRuns()[2];
@@ -284,7 +281,7 @@ public class TestTextRun extends TestCase {
                TextPropCollection tpCC = rtrC._getRawCharacterStyle();
                TextPropCollection tpDP = rtrD._getRawParagraphStyle();
                TextPropCollection tpDC = rtrD._getRawCharacterStyle();
-               
+
                assertEquals(trB.getText().substring(0, 30), rtrB.getText());
                assertNotNull(tpBP);
                assertNotNull(tpBC);
@@ -298,10 +295,10 @@ public class TestTextRun extends TestCase {
                assertFalse(tpBC.equals(tpCC));
                assertFalse(tpBC.equals(tpDC));
                assertFalse(tpCC.equals(tpDC));
-               
+
                // Change text via normal
                trB.setText("Test Foo Test");
-               
+
                // Ensure now have first style
                assertEquals(1, trB.getRichTextRuns().length);
                rtrB = trB.getRichTextRuns()[0];
@@ -312,7 +309,7 @@ public class TestTextRun extends TestCase {
                assertEquals( tpBP, rtrB._getRawParagraphStyle() );
                assertEquals( tpBC, rtrB._getRawCharacterStyle() );
     }
-    
+
     /**
      * Test to ensure the right stuff happens if we change the text
      *  in a rich text run, that doesn't happen to actually be rich
@@ -322,17 +319,17 @@ public class TestTextRun extends TestCase {
                TextRun[] textRuns = slideOne.getTextRuns();
                TextRun trB = textRuns[1];
                assertEquals(1, trB.getRichTextRuns().length);
-               
+
                RichTextRun rtrB = trB.getRichTextRuns()[0];
                assertEquals(trB.getText(), rtrB.getText());
                assertNull(rtrB._getRawCharacterStyle());
                assertNull(rtrB._getRawParagraphStyle());
-               
+
                // Change text via rich
                rtrB.setText("Test Test Test");
                assertEquals("Test Test Test", trB.getText());
                assertEquals("Test Test Test", rtrB.getText());
-               
+
                // Will now have dummy props
                assertNotNull(rtrB._getRawCharacterStyle());
                assertNotNull(rtrB._getRawParagraphStyle());
@@ -347,7 +344,7 @@ public class TestTextRun extends TestCase {
                TextRun[] textRuns = slideOne.getTextRuns();
                TextRun trB = textRuns[1];
                assertEquals(3, trB.getRichTextRuns().length);
-               
+
                // We start with 3 text runs, each with their own set of styles,
                //  but all sharing the same paragraph styles
                RichTextRun rtrB = trB.getRichTextRuns()[0];
@@ -359,7 +356,7 @@ public class TestTextRun extends TestCase {
                TextPropCollection tpCC = rtrC._getRawCharacterStyle();
                TextPropCollection tpDP = rtrD._getRawParagraphStyle();
                TextPropCollection tpDC = rtrD._getRawCharacterStyle();
-               
+
                // Check text and stylings
                assertEquals(trB.getText().substring(0, 30), rtrB.getText());
                assertNotNull(tpBP);
@@ -374,12 +371,12 @@ public class TestTextRun extends TestCase {
                assertFalse(tpBC.equals(tpCC));
                assertFalse(tpBC.equals(tpDC));
                assertFalse(tpCC.equals(tpDC));
-               
+
                // Check text in the rich runs
                assertEquals("This is the subtitle, in bold\n", rtrB.getText());
                assertEquals("This bit is blue and italic\n", rtrC.getText());
                assertEquals("This bit is red (normal)", rtrD.getText());
-               
+
                String newBText = "New Subtitle, will still be bold\n";
                String newCText = "New blue and italic text\n";
                String newDText = "Funky new normal red text";
@@ -389,22 +386,22 @@ public class TestTextRun extends TestCase {
                assertEquals(newBText, rtrB.getText());
                assertEquals(newCText, rtrC.getText());
                assertEquals(newDText, rtrD.getText());
-               
+
                assertEquals(newBText + newCText + newDText, trB.getText());
-               
+
                // The styles should have been updated for the new sizes
                assertEquals(newBText.length(), tpBC.getCharactersCovered());
                assertEquals(newCText.length(), tpCC.getCharactersCovered());
                assertEquals(newDText.length()+1, tpDC.getCharactersCovered()); // Last one is always one larger
-               
+
                assertEquals(
-                               newBText.length() + newCText.length() + newDText.length(), 
+                               newBText.length() + newCText.length() + newDText.length(),
                                tpBP.getCharactersCovered()
                );
-               
+
                // Paragraph style should be sum of text length
                assertEquals(newBText.length() + newCText.length() + newDText.length(), tpBP.getCharactersCovered());
-               
+
                // Check stylings still as expected
                TextPropCollection ntpBC = rtrB._getRawCharacterStyle();
                TextPropCollection ntpCC = rtrC._getRawCharacterStyle();
@@ -413,7 +410,7 @@ public class TestTextRun extends TestCase {
                assertEquals(tpCC.getTextPropList(), ntpCC.getTextPropList());
                assertEquals(tpDC.getTextPropList(), ntpDC.getTextPropList());
     }
-    
+
 
        /**
         * Test case for Bug 41015.
@@ -424,17 +421,17 @@ public class TestTextRun extends TestCase {
         */
        public void testBug41015() throws Exception {
                RichTextRun[] rt;
-               
+
                SlideShow ppt = new SlideShow(new HSLFSlideShow(System.getProperty("HSLF.testdata.path") + "/bug-41015.ppt"));
                Slide sl = ppt.getSlides()[0];
                TextRun[] txt = sl.getTextRuns();
                assertEquals(2, txt.length);
-               
+
                rt = txt[0].getRichTextRuns();
                assertEquals(1, rt.length);
                assertEquals(0, rt[0].getIndentLevel());
                assertEquals("sdfsdfsdf", rt[0].getText());
-               
+
                rt = txt[1].getRichTextRuns();
                assertEquals(2, rt.length);
                assertEquals(0, rt[0].getIndentLevel());
index 8967ae16109765b789715b9fe28f9826e55ee83b..2a2a10bb45c61ccf57838568674cebd0cb07592f 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.model;
 
@@ -32,11 +29,11 @@ import org.apache.poi.poifs.filesystem.*;
 /**
  * Tests that if we load something up, get a TextRun, set the text
  *  to be the same as it was before, and write it all back out again,
- *  that we don't break anything in the process. 
+ *  that we don't break anything in the process.
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestTextRunReWrite extends TestCase {
+public final class TestTextRunReWrite extends TestCase {
        // HSLFSlideShow primed on the test data
        private HSLFSlideShow hss;
        // HSLFSlideShow primed on the test data
@@ -60,33 +57,33 @@ public class TestTextRunReWrite extends TestCase {
        // Grab the first text run on the first sheet
        TextRun tr1 = ss.getSlides()[0].getTextRuns()[0];
        TextRun tr2 = ss.getSlides()[0].getTextRuns()[1];
-       
+
        // Ensure the text lengths are as we'd expect to start with
        assertEquals(1, ss.getSlides().length);
        assertEquals(2, ss.getSlides()[0].getTextRuns().length);
        assertEquals(30, tr1.getText().length());
        assertEquals(179, tr2.getText().length());
-       
+
        assertEquals(1, tr1.getRichTextRuns().length);
        assertEquals(30, tr1.getRichTextRuns()[0].getLength());
        assertEquals(30, tr1.getRichTextRuns()[0].getText().length());
        assertEquals(31, tr1.getRichTextRuns()[0]._getRawCharacterStyle().getCharactersCovered());
        assertEquals(31, tr1.getRichTextRuns()[0]._getRawParagraphStyle().getCharactersCovered());
-       
+
        // Set the text to be as it is now
        tr1.setText( tr1.getText() );
-       
+
        // Check the text lengths are still right
        assertEquals(30, tr1.getText().length());
        assertEquals(179, tr2.getText().length());
-       
+
        assertEquals(1, tr1.getRichTextRuns().length);
        assertEquals(30, tr1.getRichTextRuns()[0].getLength());
        assertEquals(30, tr1.getRichTextRuns()[0].getText().length());
        assertEquals(31, tr1.getRichTextRuns()[0]._getRawCharacterStyle().getCharactersCovered());
        assertEquals(31, tr1.getRichTextRuns()[0]._getRawParagraphStyle().getCharactersCovered());
-       
-       
+
+
                // Write the slideshow out to a byte array
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ss.write(baos);
@@ -116,11 +113,11 @@ public class TestTextRunReWrite extends TestCase {
     public void testWritesOutTheSameRich() throws Exception {
        // Grab the first text run on the first sheet
        TextRun tr1 = ss.getSlides()[0].getTextRuns()[0];
-       
+
        // Get the first rich text run
        RichTextRun rtr1 = tr1.getRichTextRuns()[0];
-       
-       
+
+
        // Check that the text sizes are as expected
        assertEquals(1, tr1.getRichTextRuns().length);
        assertEquals(30, tr1.getText().length());
@@ -129,11 +126,11 @@ public class TestTextRunReWrite extends TestCase {
        assertEquals(30, rtr1.getText().length());
        assertEquals(31, rtr1._getRawCharacterStyle().getCharactersCovered());
        assertEquals(31, rtr1._getRawParagraphStyle().getCharactersCovered());
-       
+
        // Set the text to be as it is now
        rtr1.setText( rtr1.getText() );
        rtr1 = tr1.getRichTextRuns()[0];
-       
+
        // Check that the text sizes are still as expected
        assertEquals(1, tr1.getRichTextRuns().length);
        assertEquals(30, tr1.getText().length());
@@ -142,8 +139,8 @@ public class TestTextRunReWrite extends TestCase {
        assertEquals(30, rtr1.getText().length());
        assertEquals(31, rtr1._getRawCharacterStyle().getCharactersCovered());
        assertEquals(31, rtr1._getRawParagraphStyle().getCharactersCovered());
-       
-       
+
+
                // Write the slideshow out to a byte array
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ss.write(baos);
index 7fc878756741ae720e8086962eaf050917a16108..07ed6d2da6e77333d7bbacb80c0a021080220636 100755 (executable)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-\r
-package org.apache.poi.hslf.model;\r
-\r
-import junit.framework.TestCase;\r
-\r
-import java.io.*;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.hslf.record.TextHeaderAtom;\r
-\r
-/**\r
- * Verify behavior of <code>TextShape</code> and its sub-classes\r
- * \r
- * @author Yegor Kozlov\r
- */\r
-public class TestTextShape extends TestCase {\r
-    protected String cwd = System.getProperty("HSLF.testdata.path");\r
-\r
-    public void testCreateAutoShape(){\r
-        TextShape shape = new AutoShape(ShapeTypes.Trapezoid);\r
-        assertNull(shape.getTextRun());\r
-        assertNull(shape.getText());\r
-        assertNull(shape.getEscherTextboxWrapper());\r
-\r
-        TextRun run = shape.createTextRun();\r
-        assertNotNull(run);\r
-        assertNotNull(shape.getTextRun());\r
-        assertNotNull(shape.getEscherTextboxWrapper());\r
-        assertEquals("", shape.getText());\r
-        assertSame(run, shape.createTextRun());\r
-\r
-    }\r
-\r
-    public void testCreateTextBox(){\r
-        TextShape shape = new TextBox();\r
-        TextRun run = shape.getTextRun();\r
-        assertNotNull(run);\r
-        assertNotNull(shape.getText());\r
-        assertNotNull(shape.getEscherTextboxWrapper());\r
-\r
-        assertSame(run, shape.createTextRun());\r
-        assertNotNull(shape.getTextRun());\r
-        assertNotNull(shape.getEscherTextboxWrapper());\r
-        assertEquals("", shape.getText());\r
-\r
-    }\r
-\r
-    /**\r
-     * Verify we can get text from TextShape in the following cases:\r
-     *  - placeholders\r
-     *  - normal TextBox object\r
-     *  - text in auto-shapes\r
-     */\r
-    public void testRead() throws IOException {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "text_shapes.ppt"));\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        ArrayList lst1 = new ArrayList();\r
-        Slide slide = ppt.getSlides()[0];\r
-        Shape[] shape = slide.getShapes();\r
-        for (int i = 0; i < shape.length; i++) {\r
-            assertTrue("Expected TextShape but found " + shape[i].getClass().getName(), shape[i] instanceof TextShape);\r
-            TextShape tx = (TextShape)shape[i];\r
-            TextRun run = tx.getTextRun();\r
-            assertNotNull(run);\r
-            int runType = run.getRunType();\r
-\r
-            int type = shape[i].getShapeType();\r
-            switch (type){\r
-                case ShapeTypes.TextBox:\r
-                    assertEquals("Text in a TextBox", run.getText());\r
-                    break;\r
-                case ShapeTypes.Rectangle:\r
-                    if(runType == TextHeaderAtom.OTHER_TYPE)\r
-                        assertEquals("Rectangle", run.getText());\r
-                    else if(runType == TextHeaderAtom.TITLE_TYPE)\r
-                        assertEquals("Title Placeholder", run.getText());\r
-                    break;\r
-                case ShapeTypes.Octagon:\r
-                    assertEquals("Octagon", run.getText());\r
-                    break;\r
-                case ShapeTypes.Ellipse:\r
-                    assertEquals("Ellipse", run.getText());\r
-                    break;\r
-                case ShapeTypes.RoundRectangle:\r
-                    assertEquals("RoundRectangle", run.getText());\r
-                    break;\r
-                default:\r
-                    fail("Unexpected shape: " + shape[i].getShapeName());\r
-\r
-            }\r
-            lst1.add(run.getText());\r
-        }\r
-\r
-        ArrayList lst2 = new ArrayList();\r
-        TextRun[] run = slide.getTextRuns();\r
-        for (int i = 0; i < run.length; i++) {\r
-            lst2.add(run[i].getText());\r
-        }\r
-\r
-        assertTrue(lst1.containsAll(lst2));\r
-    }\r
-\r
-    public void testReadWrite() throws IOException {\r
-        SlideShow ppt = new SlideShow();\r
-        Slide slide =  ppt.createSlide();\r
-\r
-        TextShape shape1 = new TextBox();\r
-        TextRun run1 = shape1.createTextRun();\r
-        run1.setText("Hello, World!");\r
-        slide.addShape(shape1);\r
-\r
-        shape1.moveTo(100, 100);\r
-\r
-        TextShape shape2 = new AutoShape(ShapeTypes.Arrow);\r
-        TextRun run2 = shape2.createTextRun();\r
-        run2.setText("Testing TextShape");\r
-        slide.addShape(shape2);\r
-        shape2.moveTo(300, 300);\r
-\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        ppt.write(out);\r
-        out.close();\r
-\r
-        ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));\r
-        slide = ppt.getSlides()[0];\r
-        Shape[] shape = slide.getShapes();\r
-\r
-        assertTrue(shape[0] instanceof TextShape);\r
-        shape1 = (TextShape)shape[0];\r
-        assertEquals(ShapeTypes.TextBox, shape1.getShapeType());\r
-        assertEquals("Hello, World!", shape1.getTextRun().getText());\r
-\r
-        assertTrue(shape[1] instanceof TextShape);\r
-        shape1 = (TextShape)shape[1];\r
-        assertEquals(ShapeTypes.Arrow, shape1.getShapeType());\r
-        assertEquals("Testing TextShape", shape1.getTextRun().getText());\r
-    }\r
-\r
-    public void testMargins() throws IOException {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "text-margins.ppt"));\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        Slide slide = ppt.getSlides()[0];\r
-\r
-        HashMap map = new HashMap();\r
-        Shape[] shape = slide.getShapes();\r
-        for (int i = 0; i < shape.length; i++) {\r
-            if(shape[i] instanceof TextShape){\r
-                TextShape tx = (TextShape)shape[i];\r
-                map.put(tx.getText(), tx);\r
-            }\r
-        }\r
-\r
-        TextShape tx;\r
-\r
-        tx = (TextShape)map.get("TEST1");\r
-        assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.39, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-\r
-        tx = (TextShape)map.get("TEST2");\r
-        assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.39, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-\r
-        tx = (TextShape)map.get("TEST3");\r
-        assertEquals(0.39, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-\r
-        tx = (TextShape)map.get("TEST4");\r
-        assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.39, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-        assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.model;
+
+import junit.framework.TestCase;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+
+/**
+ * Verify behavior of <code>TextShape</code> and its sub-classes
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestTextShape extends TestCase {
+    protected String cwd = System.getProperty("HSLF.testdata.path");
+
+    public void testCreateAutoShape(){
+        TextShape shape = new AutoShape(ShapeTypes.Trapezoid);
+        assertNull(shape.getTextRun());
+        assertNull(shape.getText());
+        assertNull(shape.getEscherTextboxWrapper());
+
+        TextRun run = shape.createTextRun();
+        assertNotNull(run);
+        assertNotNull(shape.getTextRun());
+        assertNotNull(shape.getEscherTextboxWrapper());
+        assertEquals("", shape.getText());
+        assertSame(run, shape.createTextRun());
+
+    }
+
+    public void testCreateTextBox(){
+        TextShape shape = new TextBox();
+        TextRun run = shape.getTextRun();
+        assertNotNull(run);
+        assertNotNull(shape.getText());
+        assertNotNull(shape.getEscherTextboxWrapper());
+
+        assertSame(run, shape.createTextRun());
+        assertNotNull(shape.getTextRun());
+        assertNotNull(shape.getEscherTextboxWrapper());
+        assertEquals("", shape.getText());
+
+    }
+
+    /**
+     * Verify we can get text from TextShape in the following cases:
+     *  - placeholders
+     *  - normal TextBox object
+     *  - text in auto-shapes
+     */
+    public void testRead() throws IOException {
+        FileInputStream is = new FileInputStream(new File(cwd, "text_shapes.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        ArrayList lst1 = new ArrayList();
+        Slide slide = ppt.getSlides()[0];
+        Shape[] shape = slide.getShapes();
+        for (int i = 0; i < shape.length; i++) {
+            assertTrue("Expected TextShape but found " + shape[i].getClass().getName(), shape[i] instanceof TextShape);
+            TextShape tx = (TextShape)shape[i];
+            TextRun run = tx.getTextRun();
+            assertNotNull(run);
+            int runType = run.getRunType();
+
+            int type = shape[i].getShapeType();
+            switch (type){
+                case ShapeTypes.TextBox:
+                    assertEquals("Text in a TextBox", run.getText());
+                    break;
+                case ShapeTypes.Rectangle:
+                    if(runType == TextHeaderAtom.OTHER_TYPE)
+                        assertEquals("Rectangle", run.getText());
+                    else if(runType == TextHeaderAtom.TITLE_TYPE)
+                        assertEquals("Title Placeholder", run.getText());
+                    break;
+                case ShapeTypes.Octagon:
+                    assertEquals("Octagon", run.getText());
+                    break;
+                case ShapeTypes.Ellipse:
+                    assertEquals("Ellipse", run.getText());
+                    break;
+                case ShapeTypes.RoundRectangle:
+                    assertEquals("RoundRectangle", run.getText());
+                    break;
+                default:
+                    fail("Unexpected shape: " + shape[i].getShapeName());
+
+            }
+            lst1.add(run.getText());
+        }
+
+        ArrayList lst2 = new ArrayList();
+        TextRun[] run = slide.getTextRuns();
+        for (int i = 0; i < run.length; i++) {
+            lst2.add(run[i].getText());
+        }
+
+        assertTrue(lst1.containsAll(lst2));
+    }
+
+    public void testReadWrite() throws IOException {
+        SlideShow ppt = new SlideShow();
+        Slide slide =  ppt.createSlide();
+
+        TextShape shape1 = new TextBox();
+        TextRun run1 = shape1.createTextRun();
+        run1.setText("Hello, World!");
+        slide.addShape(shape1);
+
+        shape1.moveTo(100, 100);
+
+        TextShape shape2 = new AutoShape(ShapeTypes.Arrow);
+        TextRun run2 = shape2.createTextRun();
+        run2.setText("Testing TextShape");
+        slide.addShape(shape2);
+        shape2.moveTo(300, 300);
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ppt.write(out);
+        out.close();
+
+        ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+        slide = ppt.getSlides()[0];
+        Shape[] shape = slide.getShapes();
+
+        assertTrue(shape[0] instanceof TextShape);
+        shape1 = (TextShape)shape[0];
+        assertEquals(ShapeTypes.TextBox, shape1.getShapeType());
+        assertEquals("Hello, World!", shape1.getTextRun().getText());
+
+        assertTrue(shape[1] instanceof TextShape);
+        shape1 = (TextShape)shape[1];
+        assertEquals(ShapeTypes.Arrow, shape1.getShapeType());
+        assertEquals("Testing TextShape", shape1.getTextRun().getText());
+    }
+
+    public void testMargins() throws IOException {
+        FileInputStream is = new FileInputStream(new File(cwd, "text-margins.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        Slide slide = ppt.getSlides()[0];
+
+        HashMap map = new HashMap();
+        Shape[] shape = slide.getShapes();
+        for (int i = 0; i < shape.length; i++) {
+            if(shape[i] instanceof TextShape){
+                TextShape tx = (TextShape)shape[i];
+                map.put(tx.getText(), tx);
+            }
+        }
+
+        TextShape tx;
+
+        tx = (TextShape)map.get("TEST1");
+        assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.39, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+
+        tx = (TextShape)map.get("TEST2");
+        assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.39, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+
+        tx = (TextShape)map.get("TEST3");
+        assertEquals(0.39, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+
+        tx = (TextShape)map.get("TEST4");
+        assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.39, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+        assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
+    }
+}
index 3b8cf756da9b3c688d793aafd09aac67413dcbe5..a8402a333ababc546161be71cee7c19ae759b66a 100755 (executable)
@@ -1,91 +1,88 @@
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.util.Arrays;\r
-\r
-import org.apache.poi.util.HexDump;\r
-\r
-/**\r
- * Tests that {@link HeadersFootersAtom} works properly\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestAnimationInfoAtom extends TestCase {\r
-    // From a real file\r
-    /*\r
-     <AnimationInfoAtom info="1" type="4081" size="28" offset="4015" header="01 00 F1 0F 1C 00 00 00 ">\r
-       00 00 00 07 04 05 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00\r
-       00 00 00\r
-     </AnimationInfoAtom>\r
-     */\r
-    private byte[] data = new byte[] {\r
-         0x01, 0x00, (byte)0xF1, 0x0F, 0x1C, 0x00, 0x00, 0x00,\r
-            0x00, 0x00, 0x00, 0x07, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
-            0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r
-    };\r
-\r
-    public void testRead() throws Exception {\r
-        AnimationInfoAtom record = new AnimationInfoAtom(data, 0, data.length);\r
-        assertEquals(RecordTypes.AnimationInfoAtom.typeID, record.getRecordType());\r
-        assertTrue(record.getFlag(AnimationInfoAtom.Automatic));\r
-        assertTrue(record.getFlag(AnimationInfoAtom.Play));\r
-        assertTrue(record.getFlag(AnimationInfoAtom.Synchronous));\r
-        assertFalse(record.getFlag(AnimationInfoAtom.Reverse));\r
-        assertFalse(record.getFlag(AnimationInfoAtom.Sound));\r
-        assertFalse(record.getFlag(AnimationInfoAtom.StopSound));\r
-        assertFalse(record.getFlag(AnimationInfoAtom.Hide));\r
-        assertFalse(record.getFlag(AnimationInfoAtom.AnimateBg));\r
-        assertEquals(0x07000000, record.getDimColor());\r
-        assertEquals(0, record.getSoundIdRef());\r
-        assertEquals(0, record.getDelayTime());\r
-        assertEquals(2, record.getOrderID());\r
-        assertEquals(0, record.getSlideCount());\r
-    }\r
-\r
-    public void testWrite() throws Exception {\r
-        AnimationInfoAtom record = new AnimationInfoAtom(data, 0, data.length);\r
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-        record.writeOut(baos);\r
-        byte[] b = baos.toByteArray();\r
-\r
-        assertTrue(Arrays.equals(data, b));\r
-    }\r
-\r
-    public void testNewRecord() throws Exception {\r
-        AnimationInfoAtom record = new AnimationInfoAtom();\r
-        record.setDimColor(0x07000000);\r
-        record.setOrderID(2);\r
-        record.setFlag(AnimationInfoAtom.Automatic, true);\r
-        record.setFlag(AnimationInfoAtom.Play, true);\r
-        record.setFlag(AnimationInfoAtom.Synchronous, true);\r
-\r
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-        record.writeOut(baos);\r
-        byte[] b = baos.toByteArray();\r
-\r
-        assertTrue(Arrays.equals(data, b));\r
-    }\r
-\r
-}
\ No newline at end of file
+/* ====================================================================
+   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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+import org.apache.poi.util.HexDump;
+
+/**
+ * Tests that {@link HeadersFootersAtom} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestAnimationInfoAtom extends TestCase {
+    // From a real file
+    /*
+     <AnimationInfoAtom info="1" type="4081" size="28" offset="4015" header="01 00 F1 0F 1C 00 00 00 ">
+       00 00 00 07 04 05 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00
+       00 00 00
+     </AnimationInfoAtom>
+     */
+    private byte[] data = new byte[] {
+         0x01, 0x00, (byte)0xF1, 0x0F, 0x1C, 0x00, 0x00, 0x00,
+            0x00, 0x00, 0x00, 0x07, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+            0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+    };
+
+    public void testRead() throws Exception {
+        AnimationInfoAtom record = new AnimationInfoAtom(data, 0, data.length);
+        assertEquals(RecordTypes.AnimationInfoAtom.typeID, record.getRecordType());
+        assertTrue(record.getFlag(AnimationInfoAtom.Automatic));
+        assertTrue(record.getFlag(AnimationInfoAtom.Play));
+        assertTrue(record.getFlag(AnimationInfoAtom.Synchronous));
+        assertFalse(record.getFlag(AnimationInfoAtom.Reverse));
+        assertFalse(record.getFlag(AnimationInfoAtom.Sound));
+        assertFalse(record.getFlag(AnimationInfoAtom.StopSound));
+        assertFalse(record.getFlag(AnimationInfoAtom.Hide));
+        assertFalse(record.getFlag(AnimationInfoAtom.AnimateBg));
+        assertEquals(0x07000000, record.getDimColor());
+        assertEquals(0, record.getSoundIdRef());
+        assertEquals(0, record.getDelayTime());
+        assertEquals(2, record.getOrderID());
+        assertEquals(0, record.getSlideCount());
+    }
+
+    public void testWrite() throws Exception {
+        AnimationInfoAtom record = new AnimationInfoAtom(data, 0, data.length);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        record.writeOut(baos);
+        byte[] b = baos.toByteArray();
+
+        assertTrue(Arrays.equals(data, b));
+    }
+
+    public void testNewRecord() throws Exception {
+        AnimationInfoAtom record = new AnimationInfoAtom();
+        record.setDimColor(0x07000000);
+        record.setOrderID(2);
+        record.setFlag(AnimationInfoAtom.Automatic, true);
+        record.setFlag(AnimationInfoAtom.Play, true);
+        record.setFlag(AnimationInfoAtom.Synchronous, true);
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        record.writeOut(baos);
+        byte[] b = baos.toByteArray();
+
+        assertTrue(Arrays.equals(data, b));
+    }
+
+}
index df8e1a3dae8e092915d49c493f79837d7cfa36b4..5fffb13427920db4173def8b094be79c8f88b094 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -29,7 +26,7 @@ import java.io.ByteArrayOutputStream;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestCString extends TestCase {
+public final class TestCString extends TestCase {
        // From a real file
        private byte[] data_a = new byte[] { 0, 0, 0xBA-256, 0x0f, 0x10, 0, 0, 0,
                0x48, 00, 0x6F, 00, 0x67, 00, 0x77, 00,
@@ -37,7 +34,7 @@ public class TestCString extends TestCase {
        private byte[] data_b = new byte[] { 0x10, 0, 0xBA-256, 0x0f, 0x10, 0, 0, 0,
                0x43, 00, 0x6F, 00, 0x6D, 00, 0x6D, 00,
                0x65, 00, 0x6E, 00, 0x74, 00, 0x73, 00 };
-       
+
     public void testRecordType() throws Exception {
                CString ca = new CString(data_a, 0, data_a.length);
                assertEquals(4026l, ca.getRecordType());
@@ -49,17 +46,17 @@ public class TestCString extends TestCase {
                assertEquals(0, ca.getOptions());
                CString cb = new CString(data_b, 0, data_a.length);
                assertEquals(0x10, cb.getOptions());
-               
+
                ca.setOptions(28);
                assertEquals(28, ca.getOptions());
        }
-       
+
        public void testText() throws Exception {
                CString ca = new CString(data_a, 0, data_a.length);
                assertEquals("Hogwarts", ca.getText());
                CString cb = new CString(data_b, 0, data_a.length);
                assertEquals("Comments", cb.getText());
-               
+
                ca.setText("FooBar");
                assertEquals("FooBar", ca.getText());
        }
@@ -74,7 +71,7 @@ public class TestCString extends TestCase {
                for(int i=0; i<data_a.length; i++) {
                        assertEquals(data_a[i],b[i]);
                }
-               
+
                CString cb = new CString(data_b, 0, data_a.length);
                ByteArrayOutputStream baosB = new ByteArrayOutputStream();
                cb.writeOut(baosB);
@@ -85,13 +82,13 @@ public class TestCString extends TestCase {
                        assertEquals(data_b[i],b[i]);
                }
        }
-       
+
        // Turn data_a into data_b
        public void testChange() throws Exception {
                CString ca = new CString(data_a, 0, data_a.length);
                ca.setText("Comments");
                ca.setOptions(0x10);
-               
+
                try {
                        for(int i=0; i<data_a.length; i++) {
                                assertEquals(data_a[i],data_b[i]);
@@ -100,11 +97,11 @@ public class TestCString extends TestCase {
                } catch(Error e) {
                        // Good, they're not the same
                }
-               
+
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ca.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 776b268c033c56f5862eacd5e803522b91053349..22e6347dec565acd4d44bdd0ee9fa502a9e60517 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -29,10 +26,10 @@ import java.io.ByteArrayOutputStream;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestColorSchemeAtom extends TestCase {
+public final class TestColorSchemeAtom extends TestCase {
        // From a real file
-       private byte[] data_a = new byte[] { 60, 0, 0xF0-256, 0x07, 0x20, 0, 0, 0, 
-               0xFF-256, 0xFF-256, 0xFF-256, 00,   00, 00, 00, 00, 
+       private byte[] data_a = new byte[] { 60, 0, 0xF0-256, 0x07, 0x20, 0, 0, 0,
+               0xFF-256, 0xFF-256, 0xFF-256, 00,   00, 00, 00, 00,
                0x80-256, 0x80-256, 0x80-256, 00,   00, 00, 00, 00,
                0xBB-256, 0xE0-256, 0xE3-256, 00,   0x33, 0x33, 0x99-256, 00,
                00, 0x99-256, 0x99-256, 00,         0x99-256, 0xCC-256, 00, 00
index 9477c4d13c8adf4cf9f83b8a008c78261ddf3ca8..f4fff8ca5952ffd7b0ca165cff43dc399f4b88e7 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -32,34 +29,34 @@ import java.util.Date;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestComment2000 extends TestCase {
+public final class TestComment2000 extends TestCase {
        // From a real file
-       private byte[] data_a = new byte[] { 
+       private byte[] data_a = new byte[] {
                0x0F, 00, 0xE0-256, 0x2E, 0x9C-256, 00, 00, 00,
                00, 00, 0xBA-256, 0x0F, 0x14, 00, 00, 00,
                0x44, 00, 0x75, 00, 0x6D, 00, 0x62, 00,
-               0x6C, 00, 0x65, 00, 0x64, 00, 0x6F, 00, 
+               0x6C, 00, 0x65, 00, 0x64, 00, 0x6F, 00,
                0x72, 00, 0x65, 00,
-               0x10, 00, 0xBA-256, 0x0F, 0x4A, 00, 00, 00, 
-               0x59, 00, 0x65, 00, 0x73, 00, 0x2C, 00, 
+               0x10, 00, 0xBA-256, 0x0F, 0x4A, 00, 00, 00,
+               0x59, 00, 0x65, 00, 0x73, 00, 0x2C, 00,
                0x20, 00, 0x74, 00, 0x68, 00, 0x65, 00,
                0x79, 00, 0x20, 00, 0x63, 00, 0x65, 00,
                0x72, 00, 0x74, 00,     0x61, 00, 0x69, 00,
                0x6E, 00, 0x6C, 00, 0x79, 00, 0x20, 00,
-               0x61, 00, 0x72, 00, 0x65, 00, 0x2C, 00, 
-               0x20, 00, 0x61, 00, 0x72, 00, 0x65, 00, 
+               0x61, 00, 0x72, 00, 0x65, 00, 0x2C, 00,
+               0x20, 00, 0x61, 00, 0x72, 00, 0x65, 00,
                0x6E, 00, 0x27, 00, 0x74, 00, 0x20, 00,
                0x74, 00, 0x68, 00, 0x65, 00, 0x79, 00, 0x21, 00,
                0x20, 00, 0xBA-256, 0x0F, 0x02, 00, 00, 00,
                0x44, 00,
                00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00,
                01, 00, 00, 00, 0xD6-256, 07, 01, 00,
-               02, 00, 0x18, 00, 0x0A, 00, 0x1A, 00, 
-               0x0F, 00, 0xCD-256, 00, 0x92-256, 00, 
+               02, 00, 0x18, 00, 0x0A, 00, 0x1A, 00,
+               0x0F, 00, 0xCD-256, 00, 0x92-256, 00,
                00,     00, 0x92-256, 00, 00, 00
        };
-       private byte[] data_b = new byte[] { 
-               0x0F, 00, 0xE0-256, 0x2E, 0xAC-256, 00, 00, 00, 
+       private byte[] data_b = new byte[] {
+               0x0F, 00, 0xE0-256, 0x2E, 0xAC-256, 00, 00, 00,
                00, 00, 0xBA-256, 0x0F, 0x10, 00, 00, 00,
                0x48, 00, 0x6F, 00, 0x67, 00, 0x77, 00,
                0x61, 00, 0x72, 00, 0x74, 00, 0x73, 00,
@@ -76,17 +73,17 @@ public class TestComment2000 extends TestCase {
                0x72, 00, 0x65, 00, 0x6E, 00, 0x27, 00,
                0x74, 00, 0x20, 00, 0x74, 00, 0x68, 00,
                0x65, 00, 0x79, 00, 0x3F, 00,
-               0x20, 00, 0xBA-256, 0x0F, 0x02, 00, 00, 00, 
+               0x20, 00, 0xBA-256, 0x0F, 0x02, 00, 00, 00,
                0x48, 00,
                00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00,
-               01, 00, 00, 00, 0xD6-256, 0x07, 01, 00, 
+               01, 00, 00, 00, 0xD6-256, 0x07, 01, 00,
                02, 00, 0x18, 00, 0x16, 00, 0x19, 00, 03,
-               00, 0xD5-256, 02, 0x0A, 00, 00, 00, 
+               00, 0xD5-256, 02, 0x0A, 00, 00, 00,
                0x0A, 00, 00, 00
                };
-       
+
        private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-       
+
     public void testRecordType() throws Exception {
                Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
                assertEquals(12000l, ca.getRecordType());
@@ -103,7 +100,7 @@ public class TestComment2000 extends TestCase {
        public void testCommentAtom() throws Exception {
                Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
                Comment2000Atom c2a = ca.getComment2000Atom();
-               
+
                assertEquals(1, c2a.getNumber());
                assertEquals(0x92, c2a.getXOffset());
                assertEquals(0x92, c2a.getYOffset());
@@ -113,7 +110,7 @@ public class TestComment2000 extends TestCase {
        public void testCommentAtomB() throws Exception {
                Comment2000 cb = new Comment2000(data_b, 0, data_b.length);
                Comment2000Atom c2b = cb.getComment2000Atom();
-               
+
                assertEquals(1, c2b.getNumber());
                assertEquals(0x0a, c2b.getXOffset());
                assertEquals(0x0a, c2b.getYOffset());
@@ -132,7 +129,7 @@ public class TestComment2000 extends TestCase {
                        assertEquals(data_a[i],b[i]);
                }
        }
-       
+
        // Change a few things
        public void testChange() throws Exception {
                Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
@@ -144,7 +141,7 @@ public class TestComment2000 extends TestCase {
                cn.setAuthor("Hogwarts");
                cn.setAuthorInitials("H");
                cn.setText("Comments are fun things to add in, aren't they?");
-               
+
                // Change the Comment2000Atom
                Comment2000Atom c2a = ca.getComment2000Atom();
                Comment2000Atom c2n = cn.getComment2000Atom();
@@ -154,11 +151,11 @@ public class TestComment2000 extends TestCase {
                c2n.setNumber(1);
                c2n.setXOffset(0x0a);
                c2n.setYOffset(0x0a);
-               
+
                Date new_date = sdf.parse("2006-01-24 22:25:03.725");
                c2a.setDate(new_date);
                c2n.setDate(new_date);
-               
+
                // Check now the same
                assertEquals(ca.getText(), cb.getText());
                assertEquals(cn.getText(), cb.getText());
@@ -166,7 +163,7 @@ public class TestComment2000 extends TestCase {
                assertEquals(cn.getAuthor(), cb.getAuthor());
                assertEquals(ca.getAuthorInitials(), cb.getAuthorInitials());
                assertEquals(cn.getAuthorInitials(), cb.getAuthorInitials());
-               
+
                // Check bytes weren't the same
                try {
                        for(int i=0; i<data_a.length; i++) {
@@ -176,7 +173,7 @@ public class TestComment2000 extends TestCase {
                } catch(Error e) {
                        // Good, they're not the same
                }
-               
+
                // Check bytes are now the same
                ByteArrayOutputStream baosa = new ByteArrayOutputStream();
                ByteArrayOutputStream baosn = new ByteArrayOutputStream();
@@ -184,7 +181,7 @@ public class TestComment2000 extends TestCase {
                cn.writeOut(baosn);
                byte[] ba = baosa.toByteArray();
                byte[] bn = baosn.toByteArray();
-               
+
                // Should now be the same
                assertEquals(data_b.length, ba.length);
                for(int i=0; i<data_b.length; i++) {
index 73ee11d4cfba37ca448a4fafcb85e0a95dfea86f..a5749ee2e7c133b2f4dadb75ea15acfab6b01577 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -31,30 +28,30 @@ import java.util.Date;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestComment2000Atom extends TestCase {
+public final class TestComment2000Atom extends TestCase {
        // From a real file
-       private byte[] data_a = new byte[] { 
+       private byte[] data_a = new byte[] {
                00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00,
                01, 00, 00, 00, 0xD6-256, 07, 01, 00,
-               02, 00, 0x18, 00, 0x0A, 00, 0x1A, 00, 
-               0x0F, 00, 0xCD-256, 00, 0x92-256, 00, 
+               02, 00, 0x18, 00, 0x0A, 00, 0x1A, 00,
+               0x0F, 00, 0xCD-256, 00, 0x92-256, 00,
                00,     00, 0x92-256, 00, 00, 00
        };
-       private byte[] data_b = new byte[] { 
+       private byte[] data_b = new byte[] {
                00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00,
-               05, 00, 00, 00, 0xD6-256, 0x07, 01, 00, 
+               05, 00, 00, 00, 0xD6-256, 0x07, 01, 00,
                02, 00, 0x18, 00, 0x15, 00, 0x19, 00, 03,
-               00, 0xD5-256, 02, 0x0A, 00, 00, 00, 
+               00, 0xD5-256, 02, 0x0A, 00, 00, 00,
                0x0E, 00, 00, 00
                };
-       
+
        private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-       
+
     public void testRecordType() throws Exception {
                Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
                assertEquals(12001l, ca.getRecordType());
        }
-    
+
     public void testGetDate() throws Exception {
                Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
                Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
@@ -63,11 +60,11 @@ public class TestComment2000Atom extends TestCase {
                Date exp_a = sdf.parse("2006-01-24 10:26:15.205");
                // B is 2006-01-24 (2nd day of week) 21:25:03.725
                Date exp_b = sdf.parse("2006-01-24 21:25:03.725");
-               
+
                assertEquals(exp_a, ca.getDate());
                assertEquals(exp_b, cb.getDate());
     }
-    
+
     public void testGetNums() throws Exception {
                Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
                Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
@@ -77,7 +74,7 @@ public class TestComment2000Atom extends TestCase {
        // B is number 5
                assertEquals(5, cb.getNumber());
     }
-    
+
     public void testGetPos() throws Exception {
                Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
                Comment2000Atom cb = new Comment2000Atom(data_b, 0, data_b.length);
@@ -85,12 +82,12 @@ public class TestComment2000Atom extends TestCase {
                // A is at 0x92, 0x92
                assertEquals(0x92, ca.getXOffset());
                assertEquals(0x92, ca.getYOffset());
-               
+
                // B is at 0x0A, 0x0E
                assertEquals(0x0A, cb.getXOffset());
                assertEquals(0x0E, cb.getYOffset());
     }
-    
+
        public void testWrite() throws Exception {
                Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -106,21 +103,21 @@ public class TestComment2000Atom extends TestCase {
        // Create A from scratch
     public void testCreate() throws Exception {
        Comment2000Atom a = new Comment2000Atom();
-       
+
        // Set number, x and y
        a.setNumber(1);
        a.setXOffset(0x92);
        a.setYOffset(0x92);
-       
+
        // Set the date
                Date date_a = sdf.parse("2006-01-24 10:26:15.205");
                a.setDate(date_a);
-               
+
                // Check it's now the same as a
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                a.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]);
@@ -133,11 +130,11 @@ public class TestComment2000Atom extends TestCase {
 
                // Change the number
                ca.setNumber(5);
-               
+
                // Change the date
                Date new_date = sdf.parse("2006-01-24 21:25:03.725");
                ca.setDate(new_date);
-               
+
                // Change the x and y
                ca.setXOffset(0x0A);
                ca.setYOffset(0x0E);
@@ -146,7 +143,7 @@ public class TestComment2000Atom extends TestCase {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ca.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 e92998eabf43b206acbf192e95a789c5bae6376e..5d7355e585a6327d76847e31e0bedb0d42923d8d 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -40,7 +37,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestCurrentUserAtom extends TestCase {
+public final class TestCurrentUserAtom extends TestCase {
        /** Not encrypted */
        private String normalFile;
        /** Encrypted */
@@ -48,7 +45,7 @@ public class TestCurrentUserAtom extends TestCase {
 
        protected void setUp() throws Exception {
                super.setUp();
-               
+
                String dirname = System.getProperty("HSLF.testdata.path");
                normalFile = dirname + "/basic_test_ppt_file.ppt";
                encFile = dirname + "/Password_Protected-hello.ppt";
@@ -58,27 +55,27 @@ public class TestCurrentUserAtom extends TestCase {
                POIFSFileSystem fs = new POIFSFileSystem(
                                new FileInputStream(normalFile)
                );
-               
+
                CurrentUserAtom cu = new CurrentUserAtom(fs);
-               
+
                // Check the contents
                assertEquals("Hogwarts", cu.getLastEditUsername());
                assertEquals(0x2942, cu.getCurrentEditOffset());
-               
+
                // Round trip
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                cu.writeOut(baos);
-               
+
                CurrentUserAtom cu2 = new CurrentUserAtom(baos.toByteArray());
                assertEquals("Hogwarts", cu2.getLastEditUsername());
                assertEquals(0x2942, cu2.getCurrentEditOffset());
        }
-       
+
        public void testReadEnc() throws Exception {
                POIFSFileSystem fs = new POIFSFileSystem(
                                new FileInputStream(encFile)
                );
-               
+
                try {
                        new CurrentUserAtom(fs);
                        fail();
@@ -86,7 +83,7 @@ public class TestCurrentUserAtom extends TestCase {
                        // Good
                }
        }
-       
+
        public void testWriteNormal() throws Exception {
                // Get raw contents from a known file
                POIFSFileSystem fs = new POIFSFileSystem(
@@ -96,17 +93,17 @@ public class TestCurrentUserAtom extends TestCase {
                byte[] contents = new byte[docProps.getSize()];
                InputStream in = fs.getRoot().createDocumentInputStream("Current User");
                in.read(contents);
-               
+
                // Now build up a new one
                CurrentUserAtom cu = new CurrentUserAtom();
                cu.setLastEditUsername("Hogwarts");
                cu.setCurrentEditOffset(0x2942);
-               
+
                // Check it matches
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                cu.writeOut(baos);
                byte[] out = baos.toByteArray();
-               
+
                assertEquals(contents.length, out.length);
                for(int i=0; i<contents.length; i++) {
                        assertEquals("Byte " + i, contents[i], out[i]);
index 182976bdbc54c332a01b426315060583e89743e1..e068e8984bd23a8ee24049e12eb7a1be41cdabc9 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -33,7 +30,7 @@ import org.apache.poi.poifs.filesystem.*;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestDocument extends TestCase {
+public final class TestDocument extends TestCase {
        // HSLFSlideShow primed on the test data
        private HSLFSlideShow ss;
        // POIFS primed on the test data
@@ -46,7 +43,7 @@ public class TestDocument extends TestCase {
                pfs = new POIFSFileSystem(fis);
                ss = new HSLFSlideShow(pfs);
     }
-    
+
     private Document getDocRecord() {
        Record[] r = ss.getRecords();
        for(int i=(r.length-1); i>=0; i--) {
@@ -61,15 +58,15 @@ public class TestDocument extends TestCase {
        Document dr = getDocRecord();
        assertEquals(1000, dr.getRecordType());
        }
-    
+
     public void testChildRecords() throws Exception {
        Document dr = getDocRecord();
        assertNotNull(dr.getDocumentAtom());
        assertTrue(dr.getDocumentAtom() instanceof DocumentAtom);
-       
+
        assertNotNull(dr.getEnvironment());
        assertTrue(dr.getEnvironment() instanceof Environment);
-       
+
        assertNotNull(dr.getSlideListWithTexts());
        assertEquals(3, dr.getSlideListWithTexts().length);
        assertNotNull(dr.getSlideListWithTexts()[0]);
@@ -79,15 +76,15 @@ public class TestDocument extends TestCase {
        assertNotNull(dr.getSlideListWithTexts()[2]);
        assertTrue(dr.getSlideListWithTexts()[2] instanceof SlideListWithText);
     }
-    
+
     public void testEnvironment() throws Exception {
        Document dr = getDocRecord();
        Environment env = dr.getEnvironment();
-       
+
        assertEquals(1010, env.getRecordType());
        assertNotNull(env.getFontCollection());
        assertTrue(env.getFontCollection() instanceof FontCollection);
     }
-    
+
     // No need to check re-writing - hslf.TestReWrite does all that for us
 }
index 19a7c7a41670f2f3a15b66b54f4c136d6a5e9138..9b28d431adf947b53c0e5219e5e0f3e1994e5d96 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -29,10 +26,10 @@ import java.io.ByteArrayOutputStream;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestDocumentAtom extends TestCase {
+public final class TestDocumentAtom extends TestCase {
        // From a real file
        private byte[] data_a = new byte[] { 1, 0, 0xE9-256, 3, 0x28, 0, 0, 0,
-               0x80-256, 0x16, 0, 0, 0xE0-256, 0x10, 0, 0, 
+               0x80-256, 0x16, 0, 0, 0xE0-256, 0x10, 0, 0,
                0xE0-256, 0x10, 0, 0, 0x80-256, 0x16, 0, 0,
                0x05, 0, 0, 0, 0x0A, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
                1, 0, 0, 0, 0, 0, 0, 1 };
index 9189db27431ade9f5ce8630adf9b881b4b929845..c93b77876f0d9c8db12d69fbf25e9e1b23d91278 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -28,80 +25,80 @@ import junit.framework.TestCase;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestDocumentEncryptionAtom extends TestCase {
+public final class TestDocumentEncryptionAtom extends TestCase {
        // From a real file
-       private byte[] data_a = new byte[] { 
+       private byte[] data_a = new byte[] {
                0x0F, 00, 0x14, 0x2F, 0xBE-256, 00, 00, 00,
-               02, 00, 02, 00, 0x0C, 00, 00, 00, 
+               02, 00, 02, 00, 0x0C, 00, 00, 00,
                0x76, 00, 00, 00, 0x0C, 00, 00, 00,
-               00, 00, 00, 00, 01, 0x68, 00, 00, 
+               00, 00, 00, 00, 01, 0x68, 00, 00,
                04, 0x80-256, 00, 00, 0x28, 00, 00, 00,
-               01, 00, 00, 00, 0x30, 00, 0x26, 01, 
+               01, 00, 00, 00, 0x30, 00, 0x26, 01,
                00, 00, 00, 00,
-               
+
                0x4D, 00, 0x69, 00,
-               0x63, 00, 0x72, 00, 0x6F, 00, 0x73, 00, 
+               0x63, 00, 0x72, 00, 0x6F, 00, 0x73, 00,
                0x6F, 00, 0x66, 00, 0x74, 00, 0x20, 00,
-               0x42, 00, 0x61, 00, 0x73, 00, 0x65, 00, 
+               0x42, 00, 0x61, 00, 0x73, 00, 0x65, 00,
                0x20, 00, 0x43, 00, 0x72, 00, 0x79, 00,
-               0x70, 00, 0x74, 00, 0x6F, 00, 0x67, 00, 
+               0x70, 00, 0x74, 00, 0x6F, 00, 0x67, 00,
                0x72, 00, 0x61, 00, 0x70, 00, 0x68, 00,
-               0x69, 00, 0x63, 00, 0x20, 00, 0x50, 00, 
+               0x69, 00, 0x63, 00, 0x20, 00, 0x50, 00,
                0x72, 00, 0x6F, 00, 0x76, 00, 0x69, 00,
-               0x64, 00, 0x65, 00, 0x72, 00, 0x20, 00, 
+               0x64, 00, 0x65, 00, 0x72, 00, 0x20, 00,
                0x76, 00, 0x31, 00, 0x2E, 00, 0x30, 00,
                0x00, 0x00,
-               
-               0x10, 00, 0x00, 00, 
-               0x62, 0xA6-256, 
-               0xDF-256, 0xEA-256, 0x96-256, 0x84-256, 
+
+               0x10, 00, 0x00, 00,
+               0x62, 0xA6-256,
+               0xDF-256, 0xEA-256, 0x96-256, 0x84-256,
                0xFB-256, 0x89-256, 0x93-256, 0xCA-256,
-               0xBA-256, 0xEE-256, 0x8E-256, 0x43, 
-               0xC8-256, 0x71, 0xD1-256, 0x89-256, 
-               0xF6-256, 0x4B, 0x2B, 0xD9-256, 
+               0xBA-256, 0xEE-256, 0x8E-256, 0x43,
+               0xC8-256, 0x71, 0xD1-256, 0x89-256,
+               0xF6-256, 0x4B, 0x2B, 0xD9-256,
                0x7E, 0x0B, 0x52, 0xFB-256,
-               0x68, 0xD7-256, 0x5A, 0x4E, 0x45, 0xDF-256, 0x14, 0x00, 
+               0x68, 0xD7-256, 0x5A, 0x4E, 0x45, 0xDF-256, 0x14, 0x00,
                0x00, 0x00, 0x93-256, 0x15, 0x27, 0xEB-256, 0x21, 0x54,
-               0x7F, 0x0B, 0x56, 0x07, 0xEE-256, 0x66, 0xEB-256, 0x6F, 
+               0x7F, 0x0B, 0x56, 0x07, 0xEE-256, 0x66, 0xEB-256, 0x6F,
                0xB2-256, 0x8E-256, 0x67, 0x54, 0x07, 0x04, 0x00
        };
-       
+
        private byte[] data_b = new byte[] {
                        15, 0, 20, 47, -66, 0, 0, 0,
-                       2, 0, 2, 0, 4, 
-                       0, 0, 0, 118, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 
-                       0, 1, 104, 0, 0, 4, -128, 0, 0, 56, 0, 0, 0, 
-                       1, 0, 0, 0, 48, 0, 38, 1, 0, 0, 0, 0, 77, 0, 
-                       105, 0, 99, 0, 114, 0, 111, 0, 115, 0, 111, 
-                       0, 102, 0, 116, 0, 32, 0, 66, 0, 97, 0, 115, 
-                       0, 101, 0, 32, 0, 67, 0, 114, 0, 121, 0, 112, 
-                       0, 116, 0, 111, 0, 103, 0, 114, 0, 97, 0, 
-                       112, 0, 104, 0, 105, 0, 99, 0, 32, 0, 80, 0, 
-                       114, 0, 111, 0, 118, 0, 105, 0, 100, 0, 101, 
-                       0, 114, 0, 32, 0, 118, 0, 49, 0, 46, 0, 48, 
-                       0, 0, 0, 16, 0, 0, 0, -80, -66, 112, -40, 57, 
-                       110, 54, 80, 64, 61, -73, -29, 48, -35, -20, 
-                       17, -40, 84, 54, 6, -103, 125, -22, -72, 53, 
-                       103, -114, 13, -48, 111, 29, 78, 20, 0, 0, 
-                       0, -97, -67, 55, -62, -94, 14, 15, -21, 37, 
+                       2, 0, 2, 0, 4,
+                       0, 0, 0, 118, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0,
+                       0, 1, 104, 0, 0, 4, -128, 0, 0, 56, 0, 0, 0,
+                       1, 0, 0, 0, 48, 0, 38, 1, 0, 0, 0, 0, 77, 0,
+                       105, 0, 99, 0, 114, 0, 111, 0, 115, 0, 111,
+                       0, 102, 0, 116, 0, 32, 0, 66, 0, 97, 0, 115,
+                       0, 101, 0, 32, 0, 67, 0, 114, 0, 121, 0, 112,
+                       0, 116, 0, 111, 0, 103, 0, 114, 0, 97, 0,
+                       112, 0, 104, 0, 105, 0, 99, 0, 32, 0, 80, 0,
+                       114, 0, 111, 0, 118, 0, 105, 0, 100, 0, 101,
+                       0, 114, 0, 32, 0, 118, 0, 49, 0, 46, 0, 48,
+                       0, 0, 0, 16, 0, 0, 0, -80, -66, 112, -40, 57,
+                       110, 54, 80, 64, 61, -73, -29, 48, -35, -20,
+                       17, -40, 84, 54, 6, -103, 125, -22, -72, 53,
+                       103, -114, 13, -48, 111, 29, 78, 20, 0, 0,
+                       0, -97, -67, 55, -62, -94, 14, 15, -21, 37,
                        3, -104, 22, 6, 102, -61, -98, 62, 40, 61, 21
        };
 
     public void testRecordType() {
                DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length);
                assertEquals(12052l, dea1.getRecordType());
-               
+
                DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length);
                assertEquals(12052l, dea2.getRecordType());
-               
+
                assertEquals(199, data_a.length);
                assertEquals(198, data_b.length);
        }
-    
+
     public void testEncryptionTypeName() {
                DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length);
                assertEquals("Microsoft Base Cryptographic Provider v1.0", dea1.getEncryptionProviderName());
-               
+
                DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length);
                assertEquals("Microsoft Base Cryptographic Provider v1.0", dea2.getEncryptionProviderName());
     }
index 82255d9734248d6d943fe1ccd6aac28bf2d343e7..9aa03a98874216f1e7bc4dd286cfdb73770b228e 100755 (executable)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.util.Arrays;\r
-\r
-/**\r
- * Tests that {@link org.apache.poi.hslf.record.ExControl} works properly\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestExControl extends TestCase {\r
-\r
-       // From a real file (embedded SWF control)\r
-    /*\r
-     <ExControl info="15" type="4078" size="218" offset="76" header="0F 00 EE 0F DA 00 00 00 ">\r
-       <ExControlAtom info="0" type="4091" size="4" offset="84" header="00 00 FB 0F 04 00 00 00 ">\r
-         00 01 00 00\r
-       </ExControlAtom>\r
-       <ExOleObjAtom info="1" type="4035" size="24" offset="96" header="01 00 C3 0F 18 00 00 00 ">\r
-         01 00 00 00 02 00 00 00 01 00 00 00 00 00 00 00 02 00 00 00 00 96 13 00\r
-       </ExOleObjAtom>\r
-       <CString info="16" type="4026" size="44" offset="128" header="10 00 BA 0F 2C 00 00 00 ">\r
-         53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 20 00 46 00 6C 00 61\r
-         00 73 00 68 00 20 00 4F 00 62 00 6A 00 65 00 63 00 74 00\r
-       </CString>\r
-       <CString info="32" type="4026" size="62" offset="180" header="20 00 BA 0F 3E 00 00 00 ">\r
-         53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 46 00 6C 00 61 00 73\r
-         00 68 00 2E 00 53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 46 00\r
-         6C 00 61 00 73 00 68 00 2E 00 39 00\r
-       </CString>\r
-       <CString info="48" type="4026" size="44" offset="250" header="30 00 BA 0F 2C 00 00 00 ">\r
-         53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 20 00 46 00 6C 00 61\r
-         00 73 00 68 00 20 00 4F 00 62 00 6A 00 65 00 63 00 74 00\r
-       </CString>\r
-     </ExControl>\r
-     */\r
-    private byte[] data = new byte[] {\r
-            0x0F, 0x00, (byte)0xEE, 0x0F, (byte)0xDA, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xFB, 0x0F, 0x04, 0x00, 0x00, 0x00,\r
-            0x00, 0x01, 0x00, 0x00, 0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,\r
-            0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00,\r
-            0x10, 0x00, (byte)0xBA, 0x0F, 0x2C, 0x00, 0x00, 0x00, 0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00,\r
-            0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x20, 0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68,\r
-            0x00, 0x20, 0x00, 0x4F, 0x00, 0x62, 0x00, 0x6A, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x20, 0x00, (byte)0xBA,\r
-            0x0F, 0x3E, 0x00, 0x00, 0x00, 0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00,\r
-            0x76, 0x00, 0x65, 0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x2E, 0x00, 0x53, 0x00, 0x68,\r
-            0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x46, 0x00, 0x6C, 0x00,\r
-            0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x2E, 0x00, 0x39, 0x00, 0x30, 0x00, (byte)0xBA, 0x0F, 0x2C, 0x00, 0x00, 0x00,\r
-            0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x20,\r
-            0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x20, 0x00, 0x4F, 0x00, 0x62, 0x00, 0x6A, 0x00,\r
-            0x65, 0x00, 0x63, 0x00, 0x74, 0x00\r
-    };\r
-\r
-    public void testRead() throws Exception {\r
-               ExControl record = new ExControl(data, 0, data.length);\r
-               assertEquals(RecordTypes.ExControl.typeID, record.getRecordType());\r
-\r
-        assertNotNull(record.getExControlAtom());\r
-        assertEquals(256, record.getExControlAtom().getSlideId());\r
-\r
-        ExOleObjAtom oleObj = record.getExOleObjAtom();\r
-        assertNotNull(oleObj);\r
-        assertEquals(oleObj.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);\r
-        assertEquals(oleObj.getType(), ExOleObjAtom.TYPE_CONTROL);\r
-        assertEquals(oleObj.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);\r
-\r
-        assertEquals("Shockwave Flash Object", record.getMenuName());\r
-        assertEquals("ShockwaveFlash.ShockwaveFlash.9", record.getProgId());\r
-        assertEquals("Shockwave Flash Object", record.getClipboardName());\r
-    }\r
-\r
-       public void testWrite() throws Exception {\r
-               ExControl record = new ExControl(data, 0, data.length);\r
-               ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-               record.writeOut(baos);\r
-               byte[] b = baos.toByteArray();\r
-\r
-        assertTrue(Arrays.equals(data, b));\r
-       }\r
-\r
-    public void testNewRecord() throws Exception {\r
-        ExControl record = new ExControl();\r
-        ExControlAtom ctrl = record.getExControlAtom();\r
-        ctrl.setSlideId(256);\r
-\r
-        ExOleObjAtom oleObj = record.getExOleObjAtom();\r
-        oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);\r
-        oleObj.setType(ExOleObjAtom.TYPE_CONTROL);\r
-        oleObj.setObjID(1);\r
-        oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);\r
-        oleObj.setObjStgDataRef(2);\r
-        oleObj.setOptions(1283584);\r
-\r
-        record.setMenuName("Shockwave Flash Object");\r
-        record.setProgId("ShockwaveFlash.ShockwaveFlash.9");\r
-        record.setClipboardName("Shockwave Flash Object");\r
-\r
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-        record.writeOut(baos);\r
-        byte[] b = baos.toByteArray();\r
-\r
-        assertEquals(data.length, b.length);\r
-        assertTrue(Arrays.equals(data, b));\r
-    }\r
-\r
-}
\ No newline at end of file
+/* ====================================================================
+   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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link org.apache.poi.hslf.record.ExControl} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestExControl extends TestCase {
+
+       // From a real file (embedded SWF control)
+    /*
+     <ExControl info="15" type="4078" size="218" offset="76" header="0F 00 EE 0F DA 00 00 00 ">
+       <ExControlAtom info="0" type="4091" size="4" offset="84" header="00 00 FB 0F 04 00 00 00 ">
+         00 01 00 00
+       </ExControlAtom>
+       <ExOleObjAtom info="1" type="4035" size="24" offset="96" header="01 00 C3 0F 18 00 00 00 ">
+         01 00 00 00 02 00 00 00 01 00 00 00 00 00 00 00 02 00 00 00 00 96 13 00
+       </ExOleObjAtom>
+       <CString info="16" type="4026" size="44" offset="128" header="10 00 BA 0F 2C 00 00 00 ">
+         53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 20 00 46 00 6C 00 61
+         00 73 00 68 00 20 00 4F 00 62 00 6A 00 65 00 63 00 74 00
+       </CString>
+       <CString info="32" type="4026" size="62" offset="180" header="20 00 BA 0F 3E 00 00 00 ">
+         53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 46 00 6C 00 61 00 73
+         00 68 00 2E 00 53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 46 00
+         6C 00 61 00 73 00 68 00 2E 00 39 00
+       </CString>
+       <CString info="48" type="4026" size="44" offset="250" header="30 00 BA 0F 2C 00 00 00 ">
+         53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 20 00 46 00 6C 00 61
+         00 73 00 68 00 20 00 4F 00 62 00 6A 00 65 00 63 00 74 00
+       </CString>
+     </ExControl>
+     */
+    private byte[] data = new byte[] {
+            0x0F, 0x00, (byte)0xEE, 0x0F, (byte)0xDA, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xFB, 0x0F, 0x04, 0x00, 0x00, 0x00,
+            0x00, 0x01, 0x00, 0x00, 0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,
+            0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00,
+            0x10, 0x00, (byte)0xBA, 0x0F, 0x2C, 0x00, 0x00, 0x00, 0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00,
+            0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x20, 0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68,
+            0x00, 0x20, 0x00, 0x4F, 0x00, 0x62, 0x00, 0x6A, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x20, 0x00, (byte)0xBA,
+            0x0F, 0x3E, 0x00, 0x00, 0x00, 0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00,
+            0x76, 0x00, 0x65, 0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x2E, 0x00, 0x53, 0x00, 0x68,
+            0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x46, 0x00, 0x6C, 0x00,
+            0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x2E, 0x00, 0x39, 0x00, 0x30, 0x00, (byte)0xBA, 0x0F, 0x2C, 0x00, 0x00, 0x00,
+            0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x20,
+            0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x20, 0x00, 0x4F, 0x00, 0x62, 0x00, 0x6A, 0x00,
+            0x65, 0x00, 0x63, 0x00, 0x74, 0x00
+    };
+
+    public void testRead() throws Exception {
+               ExControl record = new ExControl(data, 0, data.length);
+               assertEquals(RecordTypes.ExControl.typeID, record.getRecordType());
+
+        assertNotNull(record.getExControlAtom());
+        assertEquals(256, record.getExControlAtom().getSlideId());
+
+        ExOleObjAtom oleObj = record.getExOleObjAtom();
+        assertNotNull(oleObj);
+        assertEquals(oleObj.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+        assertEquals(oleObj.getType(), ExOleObjAtom.TYPE_CONTROL);
+        assertEquals(oleObj.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
+
+        assertEquals("Shockwave Flash Object", record.getMenuName());
+        assertEquals("ShockwaveFlash.ShockwaveFlash.9", record.getProgId());
+        assertEquals("Shockwave Flash Object", record.getClipboardName());
+    }
+
+       public void testWrite() throws Exception {
+               ExControl record = new ExControl(data, 0, data.length);
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               record.writeOut(baos);
+               byte[] b = baos.toByteArray();
+
+        assertTrue(Arrays.equals(data, b));
+       }
+
+    public void testNewRecord() throws Exception {
+        ExControl record = new ExControl();
+        ExControlAtom ctrl = record.getExControlAtom();
+        ctrl.setSlideId(256);
+
+        ExOleObjAtom oleObj = record.getExOleObjAtom();
+        oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+        oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
+        oleObj.setObjID(1);
+        oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
+        oleObj.setObjStgDataRef(2);
+        oleObj.setOptions(1283584);
+
+        record.setMenuName("Shockwave Flash Object");
+        record.setProgId("ShockwaveFlash.ShockwaveFlash.9");
+        record.setClipboardName("Shockwave Flash Object");
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        record.writeOut(baos);
+        byte[] b = baos.toByteArray();
+
+        assertEquals(data.length, b.length);
+        assertTrue(Arrays.equals(data, b));
+    }
+
+}
index d5b7b9f969ef64eca392c3f9eb60e01f4d30f0d9..3f63a42a22117fc9255218d5e9833abe6a63f119 100755 (executable)
@@ -1,91 +1,91 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.util.Arrays;\r
-\r
-/**\r
- * Tests that {@link org.apache.poi.hslf.record.HeadersFootersAtom} works properly\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public final class TestExMediaAtom extends TestCase {\r
-       // From a real file\r
-    private static final byte[] data = {\r
-            0x00, 0x00, (byte)0x04, 0x10, 0x08, 0x00, 0x00, 00,\r
-            0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };\r
-\r
-    public void testRead() {\r
-               ExMediaAtom record = new ExMediaAtom(data, 0, data.length);\r
-               assertEquals(RecordTypes.ExMediaAtom.typeID, record.getRecordType());\r
-\r
-        assertEquals(1, record.getObjectId());\r
-        assertFalse(record.getFlag(ExMediaAtom.fLoop));\r
-        assertFalse(record.getFlag(ExMediaAtom.fNarration));\r
-        assertFalse(record.getFlag(ExMediaAtom.fRewind));\r
-    }\r
-\r
-       public void testWrite() throws Exception {\r
-               ExMediaAtom record = new ExMediaAtom(data, 0, data.length);\r
-               ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-               record.writeOut(baos);\r
-               byte[] b = baos.toByteArray();\r
-\r
-               assertTrue(Arrays.equals(data, b));\r
-       }\r
-\r
-    public void testNewRecord() throws Exception {\r
-        ExMediaAtom ref = new ExMediaAtom(data, 0, data.length);\r
-        assertEquals(0, ref.getMask()); //\r
-\r
-        ExMediaAtom record = new ExMediaAtom();\r
-        record.setObjectId(1);\r
-        record.setFlag(HeadersFootersAtom.fHasDate, false);\r
-        record.setFlag(HeadersFootersAtom.fHasTodayDate, false);\r
-        record.setFlag(HeadersFootersAtom.fHasFooter, false);\r
-\r
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-        record.writeOut(baos);\r
-        byte[] b = baos.toByteArray();\r
-\r
-        assertTrue(Arrays.equals(data, b));\r
-    }\r
-\r
-    public void testFlags() {\r
-        ExMediaAtom record = new ExMediaAtom();\r
-\r
-        //in a new record all the bits are 0\r
-        for(int i = 0; i < 3; i++) assertFalse(record.getFlag(1 << i));\r
-\r
-        record.setFlag(ExMediaAtom.fLoop, true);\r
-        assertTrue(record.getFlag(ExMediaAtom.fLoop));\r
-\r
-        record.setFlag(ExMediaAtom.fNarration, true);\r
-        assertTrue(record.getFlag(ExMediaAtom.fNarration));\r
-\r
-        record.setFlag(ExMediaAtom.fNarration, false);\r
-        assertFalse(record.getFlag(ExMediaAtom.fNarration));\r
-\r
-        record.setFlag(ExMediaAtom.fNarration, false);\r
-        assertFalse(record.getFlag(ExMediaAtom.fNarration));\r
-\r
-    }\r
-}
\ No newline at end of file
+/* ====================================================================
+   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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link org.apache.poi.hslf.record.HeadersFootersAtom} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestExMediaAtom extends TestCase {
+       // From a real file
+       private static final byte[] data = {
+                       0x00, 0x00, (byte)0x04, 0x10, 0x08, 0x00, 0x00, 00,
+                       0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+       public void testRead() {
+               ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
+               assertEquals(RecordTypes.ExMediaAtom.typeID, record.getRecordType());
+
+               assertEquals(1, record.getObjectId());
+               assertFalse(record.getFlag(ExMediaAtom.fLoop));
+               assertFalse(record.getFlag(ExMediaAtom.fNarration));
+               assertFalse(record.getFlag(ExMediaAtom.fRewind));
+       }
+
+       public void testWrite() throws Exception {
+               ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               record.writeOut(baos);
+               byte[] b = baos.toByteArray();
+
+               assertTrue(Arrays.equals(data, b));
+       }
+
+       public void testNewRecord() throws Exception {
+               ExMediaAtom ref = new ExMediaAtom(data, 0, data.length);
+               assertEquals(0, ref.getMask()); //
+
+               ExMediaAtom record = new ExMediaAtom();
+               record.setObjectId(1);
+               record.setFlag(HeadersFootersAtom.fHasDate, false);
+               record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
+               record.setFlag(HeadersFootersAtom.fHasFooter, false);
+
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               record.writeOut(baos);
+               byte[] b = baos.toByteArray();
+
+               assertTrue(Arrays.equals(data, b));
+       }
+
+       public void testFlags() {
+               ExMediaAtom record = new ExMediaAtom();
+
+               //in a new record all the bits are 0
+               for(int i = 0; i < 3; i++) assertFalse(record.getFlag(1 << i));
+
+               record.setFlag(ExMediaAtom.fLoop, true);
+               assertTrue(record.getFlag(ExMediaAtom.fLoop));
+
+               record.setFlag(ExMediaAtom.fNarration, true);
+               assertTrue(record.getFlag(ExMediaAtom.fNarration));
+
+               record.setFlag(ExMediaAtom.fNarration, false);
+               assertFalse(record.getFlag(ExMediaAtom.fNarration));
+
+               record.setFlag(ExMediaAtom.fNarration, false);
+               assertFalse(record.getFlag(ExMediaAtom.fNarration));
+
+       }
+}
index a7c15812c12dd2ff370f601d38488d3361f1f063..cdd91b91cc261e163ed7ecfca455dcc6218c52d5 100755 (executable)
@@ -1,73 +1,72 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.util.Arrays;\r
-\r
-/**\r
- * Tests that {@link ExOleObjAtom} works properly\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public final class TestExOleObjAtom extends TestCase {\r
-       // From a real file (embedded SWF control)\r
-    private byte[] data = {\r
-            0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00,\r
-            0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,\r
-            0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00  };\r
-\r
-    public void testRead() {\r
-               ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);\r
-               assertEquals(RecordTypes.ExOleObjAtom.typeID, record.getRecordType());\r
-\r
-        assertEquals(record.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);\r
-        assertEquals(record.getType(), ExOleObjAtom.TYPE_CONTROL);\r
-        assertEquals(record.getObjID(), 1);\r
-        assertEquals(record.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);\r
-        assertEquals(record.getObjStgDataRef(), 2);\r
-        assertEquals(record.getOptions(), 1283584); //ther meaning is unknown\r
-    }\r
-\r
-       public void testWrite() throws Exception {\r
-               ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);\r
-               ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-               record.writeOut(baos);\r
-               byte[] b = baos.toByteArray();\r
-\r
-               assertTrue(Arrays.equals(data, b));\r
-       }\r
-\r
-    public void testNewRecord() throws Exception {\r
-        ExOleObjAtom record = new ExOleObjAtom();\r
-        record.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);\r
-        record.setType(ExOleObjAtom.TYPE_CONTROL);\r
-        record.setObjID(1);\r
-        record.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);\r
-        record.setObjStgDataRef(2);\r
-        record.setOptions(1283584);\r
-\r
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-        record.writeOut(baos);\r
-        byte[] b = baos.toByteArray();\r
-\r
-        assertTrue(Arrays.equals(data, b));\r
-    }\r
-\r
-}
\ No newline at end of file
+/* ====================================================================
+   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.hslf.record;
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link ExOleObjAtom} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestExOleObjAtom extends TestCase {
+       // From a real file (embedded SWF control)
+       private byte[] data = {
+                       0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00,
+                       0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00  };
+
+       public void testRead() {
+               ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
+               assertEquals(RecordTypes.ExOleObjAtom.typeID, record.getRecordType());
+
+               assertEquals(record.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+               assertEquals(record.getType(), ExOleObjAtom.TYPE_CONTROL);
+               assertEquals(record.getObjID(), 1);
+               assertEquals(record.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
+               assertEquals(record.getObjStgDataRef(), 2);
+               assertEquals(record.getOptions(), 1283584); //ther meaning is unknown
+       }
+
+       public void testWrite() throws Exception {
+               ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               record.writeOut(baos);
+               byte[] b = baos.toByteArray();
+
+               assertTrue(Arrays.equals(data, b));
+       }
+
+       public void testNewRecord() throws Exception {
+               ExOleObjAtom record = new ExOleObjAtom();
+               record.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+               record.setType(ExOleObjAtom.TYPE_CONTROL);
+               record.setObjID(1);
+               record.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
+               record.setObjStgDataRef(2);
+               record.setOptions(1283584);
+
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               record.writeOut(baos);
+               byte[] b = baos.toByteArray();
+
+               assertTrue(Arrays.equals(data, b));
+       }
+}
index 4ce08c7564ece1acecb773b09f444818bb90291e..1365691d41cf6a4aa86bcf1ed6af350f9cc1844b 100755 (executable)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.FileOutputStream;\r
-import java.io.InputStream;\r
-import java.io.IOException;\r
-import java.util.Arrays;\r
-\r
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;\r
-import org.apache.poi.poifs.filesystem.DirectoryNode;\r
-import org.apache.poi.poifs.filesystem.DocumentEntry;\r
-\r
-/**\r
- * Tests that {@link ExOleObjStg} works properly\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestExOleObjStg extends TestCase {\r
-\r
-    // From a real file (embedded SWF control)\r
-    /*\r
-    <ExOleObjStg info="16" type="4113" size="347" offset="4322" header="10 00 11 10 5B 01 00 00 ">\r
-      00 0E 00 00 78 9C BB 70 5E F0 C1 C2 8D 52 0F 19 D0 80 1D 03 33 C3 BF FF 9C\r
-      0C 6C 48 62 8C 40 CC 04 E3 08 30 30 B0 40 C5 FE FD FF FF 1F 24 C4 0C C4 FF\r
-      47 C1 90 02 41 0C F9 40 58 C2 A0 C0 E0 CA 90 07 A4 8B 18 2A D1 93 02 5E 20\r
-      C6 C0 0A 8F 73 50 5A C8 BB 5D 73 29 77 DD 79 C1 69 3B 5C 5C 83 43 50 D5 06\r
-      BC 48 2F 2B 66 38 C9 C8 0E 64 3B 30 42 C4 9C 81 B6 83 EC 4D 05 93 C5 24 D9\r
-      0D 02 42 0C 4C 8C C8 FE 21 56 9F 02 23 C9 56 E1 04 E4 D8 4F 4D 40 89 FD A0\r
-      BC FB 17 4B BA F8 07 C5 A3 60 78 03 7A E6 FF 09 67 59 1B 41 F9 9F 95 61 34\r
-      FF 53 13 50 62 3F 4C 1F AC 1C 18 CD F7 23 0B C0 DA 74 A0 B6 1B A8 3D 37 1A\r
-      F7 23 0B A4 87 A6 85 0A 00 1B 64 6F 38 21 98 03 DA C2 E7 60 90 01 92 69 0C\r
-      39 0C 65 0C 05 40 32 11 58 2F A4 02 6B 07 3D 60 19 5D 0E 14 27 4E 05 1F 90\r
-      0C 67 C8 04 96 ED 29 C0 72 BE 1C C8 E3 06 E3 FF FF 39 18 B8 80 2C 0F A0 5C\r
-      3A 43 06 58 2D A8 A7 E1 C3 10 02 97 87 B8 02 E6 1A 60 77 83 21 18 A8 12 64\r
-      8A 23 D0 B6 1C B8 59 C8 AA 90 F5 F0 62 94 75 DC C0 DE 0A 37 5C 1D 33 54 35\r
-      88 97 08 35 91 83 81 07 EC 27 10 BF 18 E8 9B E1 0F 00 BD 65 3D D4\r
-    </ExOleObjStg>\r
-     */\r
-    private byte[] data = new byte[] {\r
-            0x10, 0x00, 0x11, 0x10, 0x5B, 0x01, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x78, (byte)0x9C, (byte)0xBB, 0x70,\r
-            0x5E, (byte)0xF0, (byte)0xC1, (byte)0xC2, (byte)0x8D, 0x52, 0x0F, 0x19, (byte)0xD0, (byte)0x80, 0x1D, 0x03,\r
-            0x33, (byte)0xC3, (byte)0xBF, (byte)0xFF, (byte)0x9C, 0x0C, 0x6C, 0x48, 0x62, (byte)0x8C, 0x40, (byte)0xCC,\r
-            0x04, (byte)0xE3, 0x08, 0x30, 0x30, (byte)0xB0, 0x40, (byte)0xC5, (byte)0xFE, (byte)0xFD, (byte)0xFF, (byte)0xFF,\r
-            0x1F, 0x24, (byte)0xC4, (byte)0x0C, (byte)0xC4, (byte)0xFF, 0x47, (byte)0xC1, (byte)0x90, 0x02, 0x41, 0x0C,\r
-            (byte)0xF9, 0x40, 0x58, (byte)0xC2, (byte)0xA0, (byte)0xC0, (byte)0xE0, (byte)0xCA, (byte)0x90, 0x07, (byte)0xA4,\r
-            (byte)0x8B, 0x18, 0x2A, (byte)0xD1, (byte)0x93, 0x02, 0x5E, 0x20, (byte)0xC6, (byte)0xC0, 0x0A, (byte)0x8F,\r
-            0x73, 0x50, 0x5A, (byte)0xC8, (byte)0xBB, 0x5D, 0x73, 0x29, 0x77, (byte)0xDD, 0x79, (byte)0xC1, 0x69, 0x3B,\r
-            0x5C, 0x5C, (byte)0x83, 0x43, 0x50, (byte)0xD5, 0x06, (byte)0xBC, 0x48, 0x2F, 0x2B, 0x66, 0x38, (byte)0xC9,\r
-            (byte)0xC8, 0x0E, 0x64, 0x3B, 0x30, 0x42, (byte)0xC4, (byte)0x9C, (byte)0x81, (byte)0xB6, (byte)0x83, (byte)0xEC,\r
-            0x4D, 0x05, (byte)0x93, (byte)0xC5, 0x24, (byte)0xD9, 0x0D, 0x02, 0x42, 0x0C, 0x4C, (byte)0x8C, (byte)0xC8,\r
-            (byte)0xFE, 0x21, 0x56, (byte)0x9F, 0x02, 0x23, (byte)0xC9, 0x56, (byte)0xE1, 0x04, (byte)0xE4, (byte)0xD8,\r
-            0x4F, 0x4D, 0x40, (byte)0x89, (byte)0xFD, (byte)0xA0, (byte)0xBC, (byte)0xFB, 0x17, 0x4B, (byte)0xBA, (byte)0xF8,\r
-            0x07, (byte)0xC5, (byte)0xA3, 0x60, 0x78, 0x03, 0x7A, (byte)0xE6, (byte)0xFF, 0x09, 0x67, 0x59, 0x1B, 0x41,\r
-            (byte)0xF9, (byte)0x9F, (byte)0x95, 0x61, 0x34, (byte)0xFF, 0x53, 0x13, 0x50, 0x62, 0x3F, 0x4C, 0x1F, (byte)0xAC,\r
-            0x1C, 0x18, (byte)0xCD, (byte)0xF7, 0x23, 0x0B, (byte)0xC0, (byte)0xDA, 0x74, (byte)0xA0, (byte)0xB6, 0x1B,\r
-            (byte)0xA8, 0x3D, 0x37, 0x1A, (byte)0xF7, 0x23, 0x0B, (byte)0xA4, (byte)0x87, (byte)0xA6, (byte)0x85, 0x0A,\r
-            0x00, 0x1B, 0x64, 0x6F, 0x38, 0x21, (byte)0x98, 0x03, (byte)0xDA, (byte)0xC2, (byte)0xE7, 0x60, (byte)0x90,\r
-            0x01, (byte)0x92, 0x69, 0x0C, 0x39, 0x0C, 0x65, 0x0C, 0x05, 0x40, 0x32, 0x11, 0x58, 0x2F, (byte)0xA4, 0x02,\r
-            0x6B, 0x07, 0x3D, 0x60, 0x19, 0x5D, 0x0E, 0x14, 0x27, 0x4E, 0x05, 0x1F, (byte)0x90, 0x0C, 0x67, (byte)0xC8,\r
-            0x04, (byte)0x96, (byte)0xED, 0x29, (byte)0xC0, 0x72, (byte)0xBE, 0x1C, (byte)0xC8, (byte)0xE3, 0x06, (byte)0xE3,\r
-            (byte)0xFF, (byte)0xFF, 0x39, 0x18, (byte)0xB8, (byte)0x80, 0x2C, 0x0F, (byte)0xA0, 0x5C, 0x3A, 0x43, 0x06, 0x58,\r
-            0x2D, (byte)0xA8, (byte)0xA7, (byte)0xE1, (byte)0xC3, 0x10, 0x02, (byte)0x97, (byte)0x87, (byte)0xB8, 0x02,\r
-            (byte)0xE6, 0x1A, 0x60, 0x77, (byte)0x83, 0x21, 0x18, (byte)0xA8, 0x12, 0x64, (byte)0x8A, 0x23, (byte)0xD0,\r
-            (byte)0xB6, 0x1C, (byte)0xB8, 0x59, (byte)0xC8, (byte)0xAA, (byte)0x90, (byte)0xF5, (byte)0xF0, 0x62, (byte)0x94,\r
-            0x75, (byte)0xDC, (byte)0xC0, (byte)0xDE, 0x0A, 0x37, 0x5C, 0x1D, 0x33, 0x54, 0x35, (byte)0x88, (byte)0x97, 0x08,\r
-            0x35, (byte)0x91, (byte)0x83, (byte)0x81, 0x07, (byte)0xEC, 0x27, 0x10, (byte)0xBF, 0x18, (byte)0xE8, (byte)0x9B,\r
-            (byte)0xE1, 0x0F, 0x00, (byte)0xBD, 0x65, 0x3D, (byte)0xD4\r
-                };\r
-\r
-    public void testRead() throws Exception {\r
-        ExOleObjStg record = new ExOleObjStg(data, 0, data.length);\r
-        assertEquals(RecordTypes.ExOleObjStg.typeID, record.getRecordType());\r
-\r
-        int len = record.getDataLength();\r
-        byte[] oledata = readAll(record.getData());\r
-        assertEquals(len, oledata.length);\r
-\r
-        POIFSFileSystem fs = new POIFSFileSystem(record.getData());\r
-        assertTrue("Constructed POIFS from ExOleObjStg data", true);\r
-        DocumentEntry doc = (DocumentEntry)fs.getRoot().getEntry("Contents");\r
-        assertNotNull(doc);\r
-        assertTrue("Fetched the Contents stream containing OLE properties", true);\r
-    }\r
-\r
-    public void testWrite() throws Exception {\r
-        ExOleObjStg record = new ExOleObjStg(data, 0, data.length);\r
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-        record.writeOut(baos);\r
-        byte[] b = baos.toByteArray();\r
-\r
-        assertTrue(Arrays.equals(data, b));\r
-    }\r
-\r
-    public void testNewRecord() throws Exception {\r
-        ExOleObjStg src = new ExOleObjStg(data, 0, data.length);\r
-        byte[] oledata = readAll(src.getData());\r
-\r
-        ExOleObjStg tgt = new ExOleObjStg();\r
-        tgt.setData(oledata);\r
-\r
-\r
-        assertEquals(src.getDataLength(), tgt.getDataLength());\r
-\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        tgt.writeOut(out);\r
-        byte[] b = out.toByteArray();\r
-\r
-        assertEquals(data.length, b.length);\r
-        assertTrue(Arrays.equals(data, b));\r
-    }\r
-\r
-    private byte[] readAll(InputStream is) throws IOException {\r
-        int pos;\r
-        byte[] chunk = new byte[1024];\r
-        ByteArrayOutputStream out = new  ByteArrayOutputStream();\r
-        while((pos = is.read(chunk)) > 0){\r
-            out.write(chunk, 0, pos);\r
-        }\r
-        return out.toByteArray();\r
-\r
-    }\r
-}
\ No newline at end of file
+/* ====================================================================
+   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.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;
+
+/**
+ * Tests that {@link ExOleObjStg} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestExOleObjStg extends TestCase {
+
+    // From a real file (embedded SWF control)
+    /*
+    <ExOleObjStg info="16" type="4113" size="347" offset="4322" header="10 00 11 10 5B 01 00 00 ">
+      00 0E 00 00 78 9C BB 70 5E F0 C1 C2 8D 52 0F 19 D0 80 1D 03 33 C3 BF FF 9C
+      0C 6C 48 62 8C 40 CC 04 E3 08 30 30 B0 40 C5 FE FD FF FF 1F 24 C4 0C C4 FF
+      47 C1 90 02 41 0C F9 40 58 C2 A0 C0 E0 CA 90 07 A4 8B 18 2A D1 93 02 5E 20
+      C6 C0 0A 8F 73 50 5A C8 BB 5D 73 29 77 DD 79 C1 69 3B 5C 5C 83 43 50 D5 06
+      BC 48 2F 2B 66 38 C9 C8 0E 64 3B 30 42 C4 9C 81 B6 83 EC 4D 05 93 C5 24 D9
+      0D 02 42 0C 4C 8C C8 FE 21 56 9F 02 23 C9 56 E1 04 E4 D8 4F 4D 40 89 FD A0
+      BC FB 17 4B BA F8 07 C5 A3 60 78 03 7A E6 FF 09 67 59 1B 41 F9 9F 95 61 34
+      FF 53 13 50 62 3F 4C 1F AC 1C 18 CD F7 23 0B C0 DA 74 A0 B6 1B A8 3D 37 1A
+      F7 23 0B A4 87 A6 85 0A 00 1B 64 6F 38 21 98 03 DA C2 E7 60 90 01 92 69 0C
+      39 0C 65 0C 05 40 32 11 58 2F A4 02 6B 07 3D 60 19 5D 0E 14 27 4E 05 1F 90
+      0C 67 C8 04 96 ED 29 C0 72 BE 1C C8 E3 06 E3 FF FF 39 18 B8 80 2C 0F A0 5C
+      3A 43 06 58 2D A8 A7 E1 C3 10 02 97 87 B8 02 E6 1A 60 77 83 21 18 A8 12 64
+      8A 23 D0 B6 1C B8 59 C8 AA 90 F5 F0 62 94 75 DC C0 DE 0A 37 5C 1D 33 54 35
+      88 97 08 35 91 83 81 07 EC 27 10 BF 18 E8 9B E1 0F 00 BD 65 3D D4
+    </ExOleObjStg>
+     */
+    private byte[] data = new byte[] {
+            0x10, 0x00, 0x11, 0x10, 0x5B, 0x01, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x78, (byte)0x9C, (byte)0xBB, 0x70,
+            0x5E, (byte)0xF0, (byte)0xC1, (byte)0xC2, (byte)0x8D, 0x52, 0x0F, 0x19, (byte)0xD0, (byte)0x80, 0x1D, 0x03,
+            0x33, (byte)0xC3, (byte)0xBF, (byte)0xFF, (byte)0x9C, 0x0C, 0x6C, 0x48, 0x62, (byte)0x8C, 0x40, (byte)0xCC,
+            0x04, (byte)0xE3, 0x08, 0x30, 0x30, (byte)0xB0, 0x40, (byte)0xC5, (byte)0xFE, (byte)0xFD, (byte)0xFF, (byte)0xFF,
+            0x1F, 0x24, (byte)0xC4, (byte)0x0C, (byte)0xC4, (byte)0xFF, 0x47, (byte)0xC1, (byte)0x90, 0x02, 0x41, 0x0C,
+            (byte)0xF9, 0x40, 0x58, (byte)0xC2, (byte)0xA0, (byte)0xC0, (byte)0xE0, (byte)0xCA, (byte)0x90, 0x07, (byte)0xA4,
+            (byte)0x8B, 0x18, 0x2A, (byte)0xD1, (byte)0x93, 0x02, 0x5E, 0x20, (byte)0xC6, (byte)0xC0, 0x0A, (byte)0x8F,
+            0x73, 0x50, 0x5A, (byte)0xC8, (byte)0xBB, 0x5D, 0x73, 0x29, 0x77, (byte)0xDD, 0x79, (byte)0xC1, 0x69, 0x3B,
+            0x5C, 0x5C, (byte)0x83, 0x43, 0x50, (byte)0xD5, 0x06, (byte)0xBC, 0x48, 0x2F, 0x2B, 0x66, 0x38, (byte)0xC9,
+            (byte)0xC8, 0x0E, 0x64, 0x3B, 0x30, 0x42, (byte)0xC4, (byte)0x9C, (byte)0x81, (byte)0xB6, (byte)0x83, (byte)0xEC,
+            0x4D, 0x05, (byte)0x93, (byte)0xC5, 0x24, (byte)0xD9, 0x0D, 0x02, 0x42, 0x0C, 0x4C, (byte)0x8C, (byte)0xC8,
+            (byte)0xFE, 0x21, 0x56, (byte)0x9F, 0x02, 0x23, (byte)0xC9, 0x56, (byte)0xE1, 0x04, (byte)0xE4, (byte)0xD8,
+            0x4F, 0x4D, 0x40, (byte)0x89, (byte)0xFD, (byte)0xA0, (byte)0xBC, (byte)0xFB, 0x17, 0x4B, (byte)0xBA, (byte)0xF8,
+            0x07, (byte)0xC5, (byte)0xA3, 0x60, 0x78, 0x03, 0x7A, (byte)0xE6, (byte)0xFF, 0x09, 0x67, 0x59, 0x1B, 0x41,
+            (byte)0xF9, (byte)0x9F, (byte)0x95, 0x61, 0x34, (byte)0xFF, 0x53, 0x13, 0x50, 0x62, 0x3F, 0x4C, 0x1F, (byte)0xAC,
+            0x1C, 0x18, (byte)0xCD, (byte)0xF7, 0x23, 0x0B, (byte)0xC0, (byte)0xDA, 0x74, (byte)0xA0, (byte)0xB6, 0x1B,
+            (byte)0xA8, 0x3D, 0x37, 0x1A, (byte)0xF7, 0x23, 0x0B, (byte)0xA4, (byte)0x87, (byte)0xA6, (byte)0x85, 0x0A,
+            0x00, 0x1B, 0x64, 0x6F, 0x38, 0x21, (byte)0x98, 0x03, (byte)0xDA, (byte)0xC2, (byte)0xE7, 0x60, (byte)0x90,
+            0x01, (byte)0x92, 0x69, 0x0C, 0x39, 0x0C, 0x65, 0x0C, 0x05, 0x40, 0x32, 0x11, 0x58, 0x2F, (byte)0xA4, 0x02,
+            0x6B, 0x07, 0x3D, 0x60, 0x19, 0x5D, 0x0E, 0x14, 0x27, 0x4E, 0x05, 0x1F, (byte)0x90, 0x0C, 0x67, (byte)0xC8,
+            0x04, (byte)0x96, (byte)0xED, 0x29, (byte)0xC0, 0x72, (byte)0xBE, 0x1C, (byte)0xC8, (byte)0xE3, 0x06, (byte)0xE3,
+            (byte)0xFF, (byte)0xFF, 0x39, 0x18, (byte)0xB8, (byte)0x80, 0x2C, 0x0F, (byte)0xA0, 0x5C, 0x3A, 0x43, 0x06, 0x58,
+            0x2D, (byte)0xA8, (byte)0xA7, (byte)0xE1, (byte)0xC3, 0x10, 0x02, (byte)0x97, (byte)0x87, (byte)0xB8, 0x02,
+            (byte)0xE6, 0x1A, 0x60, 0x77, (byte)0x83, 0x21, 0x18, (byte)0xA8, 0x12, 0x64, (byte)0x8A, 0x23, (byte)0xD0,
+            (byte)0xB6, 0x1C, (byte)0xB8, 0x59, (byte)0xC8, (byte)0xAA, (byte)0x90, (byte)0xF5, (byte)0xF0, 0x62, (byte)0x94,
+            0x75, (byte)0xDC, (byte)0xC0, (byte)0xDE, 0x0A, 0x37, 0x5C, 0x1D, 0x33, 0x54, 0x35, (byte)0x88, (byte)0x97, 0x08,
+            0x35, (byte)0x91, (byte)0x83, (byte)0x81, 0x07, (byte)0xEC, 0x27, 0x10, (byte)0xBF, 0x18, (byte)0xE8, (byte)0x9B,
+            (byte)0xE1, 0x0F, 0x00, (byte)0xBD, 0x65, 0x3D, (byte)0xD4
+                };
+
+    public void testRead() throws Exception {
+        ExOleObjStg record = new ExOleObjStg(data, 0, data.length);
+        assertEquals(RecordTypes.ExOleObjStg.typeID, record.getRecordType());
+
+        int len = record.getDataLength();
+        byte[] oledata = readAll(record.getData());
+        assertEquals(len, oledata.length);
+
+        POIFSFileSystem fs = new POIFSFileSystem(record.getData());
+        assertTrue("Constructed POIFS from ExOleObjStg data", true);
+        DocumentEntry doc = (DocumentEntry)fs.getRoot().getEntry("Contents");
+        assertNotNull(doc);
+        assertTrue("Fetched the Contents stream containing OLE properties", true);
+    }
+
+    public void testWrite() throws Exception {
+        ExOleObjStg record = new ExOleObjStg(data, 0, data.length);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        record.writeOut(baos);
+        byte[] b = baos.toByteArray();
+
+        assertTrue(Arrays.equals(data, b));
+    }
+
+    public void testNewRecord() throws Exception {
+        ExOleObjStg src = new ExOleObjStg(data, 0, data.length);
+        byte[] oledata = readAll(src.getData());
+
+        ExOleObjStg tgt = new ExOleObjStg();
+        tgt.setData(oledata);
+
+
+        assertEquals(src.getDataLength(), tgt.getDataLength());
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        tgt.writeOut(out);
+        byte[] b = out.toByteArray();
+
+        assertEquals(data.length, b.length);
+        assertTrue(Arrays.equals(data, b));
+    }
+
+    private byte[] readAll(InputStream is) throws IOException {
+        int pos;
+        byte[] chunk = new byte[1024];
+        ByteArrayOutputStream out = new  ByteArrayOutputStream();
+        while((pos = is.read(chunk)) > 0){
+            out.write(chunk, 0, pos);
+        }
+        return out.toByteArray();
+
+    }
+}
index 224aedf61c97d4ccae2cc639cb1a5634212785ee..3c903f41eed7b71879228ffc78515c4c73524232 100755 (executable)
@@ -1,90 +1,87 @@
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.util.Arrays;\r
-\r
-/**\r
- * Tests that {@link HeadersFootersAtom} works properly\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestExVideoContainer extends TestCase {\r
-\r
-    // From a real file\r
-    private byte[] data = new byte[]{\r
-            0x0F, 0x00, 0x05, 0x10, (byte) 0x9E, 0x00, 0x00, 0x00,\r
-            0x00, 0x00, 0x04, 0x10, 0x08, 0x00, 0x00, 0x00,\r
-            0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
-            0x00, 0x00, (byte)0xBA, 0x0F, (byte)0x86, 0x00, 0x00, 0x00,\r
-            0x44, 0x00, 0x3A, 0x00, 0x5C, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x6A, 0x00, 0x65, 0x00,\r
-            0x63, 0x00, 0x74, 0x00, 0x73, 0x00, 0x5C, 0x00, 0x53, 0x00, 0x63, 0x00, 0x68, 0x00, 0x75, 0x00,\r
-            0x6C, 0x00, 0x65, 0x00, 0x72, 0x00, 0x41, 0x00, 0x47, 0x00, 0x5C, 0x00, 0x6D, 0x00, 0x63, 0x00,\r
-            0x6F, 0x00, 0x6D, 0x00, 0x5F, 0x00, 0x76, 0x00, 0x5F, 0x00, 0x31, 0x00, 0x5F, 0x00, 0x30, 0x00,\r
-            0x5F, 0x00, 0x34, 0x00, 0x5C, 0x00, 0x76, 0x00, 0x69, 0x00, 0x65, 0x00, 0x77, 0x00, 0x5C, 0x00,\r
-            0x64, 0x00, 0x61, 0x00, 0x74, 0x00, 0x61, 0x00, 0x5C, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00,\r
-            0x74, 0x00, 0x73, 0x00, 0x5C, 0x00, 0x69, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x67, 0x00, 0x65, 0x00,\r
-            0x73, 0x00, 0x5C, 0x00, 0x63, 0x00, 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x73, 0x00, 0x2E, 0x00,\r
-            0x6D, 0x00, 0x70, 0x00, 0x67, 0x00};\r
-\r
-\r
-\r
-\r
-    public void testRead() throws Exception {\r
-               ExVideoContainer record = new ExVideoContainer(data, 0, data.length);\r
-               assertEquals(RecordTypes.ExVideoContainer.typeID, record.getRecordType());\r
-\r
-        ExMediaAtom exMedia = record.getExMediaAtom();\r
-        assertEquals(1, exMedia.getObjectId());\r
-        assertNotNull(exMedia);\r
-        assertFalse(exMedia.getFlag(ExMediaAtom.fLoop));\r
-        assertFalse(exMedia.getFlag(ExMediaAtom.fNarration));\r
-        assertFalse(exMedia.getFlag(ExMediaAtom.fRewind));\r
-\r
-        CString path = record.getPathAtom();\r
-        assertNotNull(exMedia);\r
-        assertEquals("D:\\projects\\SchulerAG\\mcom_v_1_0_4\\view\\data\\tests\\images\\cards.mpg", path.getText());\r
-    }\r
-\r
-       public void testWrite() throws Exception {\r
-               ExVideoContainer record = new ExVideoContainer(data, 0, data.length);\r
-               ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-               record.writeOut(baos);\r
-               byte[] b = baos.toByteArray();\r
-\r
-               assertTrue(Arrays.equals(data, b));\r
-       }\r
-\r
-    public void testNewRecord() throws Exception {\r
-        ExVideoContainer record = new ExVideoContainer();\r
-        record.getExMediaAtom().setObjectId(1);\r
-        record.getPathAtom().setText("D:\\projects\\SchulerAG\\mcom_v_1_0_4\\view\\data\\tests\\images\\cards.mpg");\r
-\r
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-        record.writeOut(baos);\r
-        byte[] b = baos.toByteArray();\r
-\r
-        assertTrue(Arrays.equals(data, b));\r
-    }\r
-}
\ No newline at end of file
+/* ====================================================================
+   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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link HeadersFootersAtom} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestExVideoContainer extends TestCase {
+
+    // From a real file
+    private byte[] data = new byte[]{
+            0x0F, 0x00, 0x05, 0x10, (byte) 0x9E, 0x00, 0x00, 0x00,
+            0x00, 0x00, 0x04, 0x10, 0x08, 0x00, 0x00, 0x00,
+            0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+            0x00, 0x00, (byte)0xBA, 0x0F, (byte)0x86, 0x00, 0x00, 0x00,
+            0x44, 0x00, 0x3A, 0x00, 0x5C, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x6A, 0x00, 0x65, 0x00,
+            0x63, 0x00, 0x74, 0x00, 0x73, 0x00, 0x5C, 0x00, 0x53, 0x00, 0x63, 0x00, 0x68, 0x00, 0x75, 0x00,
+            0x6C, 0x00, 0x65, 0x00, 0x72, 0x00, 0x41, 0x00, 0x47, 0x00, 0x5C, 0x00, 0x6D, 0x00, 0x63, 0x00,
+            0x6F, 0x00, 0x6D, 0x00, 0x5F, 0x00, 0x76, 0x00, 0x5F, 0x00, 0x31, 0x00, 0x5F, 0x00, 0x30, 0x00,
+            0x5F, 0x00, 0x34, 0x00, 0x5C, 0x00, 0x76, 0x00, 0x69, 0x00, 0x65, 0x00, 0x77, 0x00, 0x5C, 0x00,
+            0x64, 0x00, 0x61, 0x00, 0x74, 0x00, 0x61, 0x00, 0x5C, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00,
+            0x74, 0x00, 0x73, 0x00, 0x5C, 0x00, 0x69, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x67, 0x00, 0x65, 0x00,
+            0x73, 0x00, 0x5C, 0x00, 0x63, 0x00, 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x73, 0x00, 0x2E, 0x00,
+            0x6D, 0x00, 0x70, 0x00, 0x67, 0x00};
+
+
+
+
+    public void testRead() throws Exception {
+               ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
+               assertEquals(RecordTypes.ExVideoContainer.typeID, record.getRecordType());
+
+        ExMediaAtom exMedia = record.getExMediaAtom();
+        assertEquals(1, exMedia.getObjectId());
+        assertNotNull(exMedia);
+        assertFalse(exMedia.getFlag(ExMediaAtom.fLoop));
+        assertFalse(exMedia.getFlag(ExMediaAtom.fNarration));
+        assertFalse(exMedia.getFlag(ExMediaAtom.fRewind));
+
+        CString path = record.getPathAtom();
+        assertNotNull(exMedia);
+        assertEquals("D:\\projects\\SchulerAG\\mcom_v_1_0_4\\view\\data\\tests\\images\\cards.mpg", path.getText());
+    }
+
+       public void testWrite() throws Exception {
+               ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               record.writeOut(baos);
+               byte[] b = baos.toByteArray();
+
+               assertTrue(Arrays.equals(data, b));
+       }
+
+    public void testNewRecord() throws Exception {
+        ExVideoContainer record = new ExVideoContainer();
+        record.getExMediaAtom().setObjectId(1);
+        record.getPathAtom().setText("D:\\projects\\SchulerAG\\mcom_v_1_0_4\\view\\data\\tests\\images\\cards.mpg");
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        record.writeOut(baos);
+        byte[] b = baos.toByteArray();
+
+        assertTrue(Arrays.equals(data, b));
+    }
+}
index 1e174fffb783dc4ebc6733334ae5d285bc3f83c7..75af7afa0c98a57ce88e1936a7f93868ff69db2a 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
@@ -28,7 +27,7 @@ import java.util.Arrays;
  *
  * @author Yegor Kozlov
  */
-public class TestFontCollection extends TestCase {
+public final class TestFontCollection extends TestCase {
     // From a real file
     private byte[] data = new byte[]  {
         0x0F, 0x00, 0xD5-256, 0x07, 0x4C, 0x00, 0x00, 0x00,
@@ -64,7 +63,7 @@ public class TestFontCollection extends TestCase {
         // Font collection should contain 3 fonts
         Record[] child = fonts.getChildRecords();
         assertEquals(child.length, 3);
-        
+
         // Check we get the right font name for the indicies
         assertEquals("Times New Roman", fonts.getFontWithId(0));
         assertEquals("Helvetica", fonts.getFontWithId(1));
index 8c6972c6a582e860b5b59998b88f713f55328d5e..5db87e136d6b9cdcbb16ae410a6c5c78616c2f3d 100644 (file)
@@ -1,95 +1,92 @@
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.util.Arrays;\r
-\r
-/**\r
- * Tests that {@link HeadersFootersAtom} works properly\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestHeadersFootersAtom extends TestCase {\r
-       // From a real file\r
-       private byte[] data = new byte[] {\r
-            0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 00,\r
-            0x00, 0x00, 0x23, 0x00 };\r
-\r
-    public void testRead() throws Exception {\r
-               HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);\r
-               assertEquals(RecordTypes.HeadersFootersAtom.typeID, record.getRecordType());\r
-\r
-        assertEquals(0, record.getFormatId());\r
-        assertEquals(0x23, record.getMask());\r
-\r
-        assertTrue(record.getFlag(HeadersFootersAtom.fHasDate));\r
-        assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));\r
-        assertFalse(record.getFlag(HeadersFootersAtom.fHasUserDate));\r
-        assertFalse(record.getFlag(HeadersFootersAtom.fHasSlideNumber));\r
-        assertFalse(record.getFlag(HeadersFootersAtom.fHasHeader));\r
-        assertTrue(record.getFlag(HeadersFootersAtom.fHasFooter));\r
-    }\r
-\r
-       public void testWrite() throws Exception {\r
-               HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);\r
-               ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-               record.writeOut(baos);\r
-               byte[] b = baos.toByteArray();\r
-\r
-               assertTrue(Arrays.equals(data, b));\r
-       }\r
-\r
-    public void testNewRecord() throws Exception {\r
-        HeadersFootersAtom record = new HeadersFootersAtom();\r
-        record.setFlag(HeadersFootersAtom.fHasDate, true);\r
-        record.setFlag(HeadersFootersAtom.fHasTodayDate, true);\r
-        record.setFlag(HeadersFootersAtom.fHasFooter, true);\r
-\r
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-        record.writeOut(baos);\r
-        byte[] b = baos.toByteArray();\r
-\r
-        assertTrue(Arrays.equals(data, b));\r
-    }\r
-\r
-    public void testFlags() throws Exception {\r
-        HeadersFootersAtom record = new HeadersFootersAtom();\r
-\r
-        //in a new record all the bits are 0\r
-        for(int i = 0; i < 6; i++) assertFalse(record.getFlag(1 << i));\r
-\r
-        record.setFlag(HeadersFootersAtom.fHasTodayDate, true);\r
-        assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));\r
-\r
-        record.setFlag(HeadersFootersAtom.fHasTodayDate, true);\r
-        assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));\r
-\r
-        record.setFlag(HeadersFootersAtom.fHasTodayDate, false);\r
-        assertFalse(record.getFlag(HeadersFootersAtom.fHasTodayDate));\r
-\r
-        record.setFlag(HeadersFootersAtom.fHasTodayDate, false);\r
-        assertFalse(record.getFlag(HeadersFootersAtom.fHasTodayDate));\r
-\r
-    }\r
-}
\ No newline at end of file
+/* ====================================================================
+   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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link HeadersFootersAtom} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestHeadersFootersAtom extends TestCase {
+       // From a real file
+       private byte[] data = new byte[] {
+            0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 00,
+            0x00, 0x00, 0x23, 0x00 };
+
+    public void testRead() throws Exception {
+               HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
+               assertEquals(RecordTypes.HeadersFootersAtom.typeID, record.getRecordType());
+
+        assertEquals(0, record.getFormatId());
+        assertEquals(0x23, record.getMask());
+
+        assertTrue(record.getFlag(HeadersFootersAtom.fHasDate));
+        assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));
+        assertFalse(record.getFlag(HeadersFootersAtom.fHasUserDate));
+        assertFalse(record.getFlag(HeadersFootersAtom.fHasSlideNumber));
+        assertFalse(record.getFlag(HeadersFootersAtom.fHasHeader));
+        assertTrue(record.getFlag(HeadersFootersAtom.fHasFooter));
+    }
+
+       public void testWrite() throws Exception {
+               HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               record.writeOut(baos);
+               byte[] b = baos.toByteArray();
+
+               assertTrue(Arrays.equals(data, b));
+       }
+
+    public void testNewRecord() throws Exception {
+        HeadersFootersAtom record = new HeadersFootersAtom();
+        record.setFlag(HeadersFootersAtom.fHasDate, true);
+        record.setFlag(HeadersFootersAtom.fHasTodayDate, true);
+        record.setFlag(HeadersFootersAtom.fHasFooter, true);
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        record.writeOut(baos);
+        byte[] b = baos.toByteArray();
+
+        assertTrue(Arrays.equals(data, b));
+    }
+
+    public void testFlags() throws Exception {
+        HeadersFootersAtom record = new HeadersFootersAtom();
+
+        //in a new record all the bits are 0
+        for(int i = 0; i < 6; i++) assertFalse(record.getFlag(1 << i));
+
+        record.setFlag(HeadersFootersAtom.fHasTodayDate, true);
+        assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));
+
+        record.setFlag(HeadersFootersAtom.fHasTodayDate, true);
+        assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));
+
+        record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
+        assertFalse(record.getFlag(HeadersFootersAtom.fHasTodayDate));
+
+        record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
+        assertFalse(record.getFlag(HeadersFootersAtom.fHasTodayDate));
+
+    }
+}
index d24ca05f656c56d194fb98a486d995d9c3c0f84a..921b08929b32e62d87475eeac37826c178e21c4f 100644 (file)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.util.Arrays;\r
-\r
-/**\r
- * Tests that {@link HeadersFootersContainer} works properly\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestHeadersFootersContainer extends TestCase {\r
-       // SlideHeadersFootersContainer\r
-       private byte[] slideData = new byte[] {\r
-            0x3F, 0x00, (byte)0xD9, 0x0F, 0x2E, 0x00, 0x00, 0x00,\r
-            0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00,\r
-            0x20, 0x00, (byte)0xBA, 0x0F, 0x1A, 0x00, 0x00, 0x00,\r
-            0x4D, 0x00, 0x79, 0x00, 0x20, 0x00, 0x46, 0x00, 0x6F, 0x00, 0x6F, 0x00, 0x74,\r
-            0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x2D, 0x00, 0x20, 0x00, 0x31, 0x00\r
-\r
-    };\r
-\r
-    // NotesHeadersFootersContainer\r
-    private byte[] notesData = new byte[] {\r
-            0x4F, 0x00, (byte)0xD9, 0x0F, 0x48, 0x00, 0x00, 0x00,\r
-            0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x00,\r
-            0x10, 0x00, (byte)0xBA, 0x0F, 0x16, 0x00, 0x00, 0x00,\r
-            0x4E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x48, 0x00,\r
-            0x65, 0x00, 0x61, 0x00, 0x64, 0x00, 0x65, 0x00, 0x72, 0x00,\r
-            0x20, 0x00, (byte)0xBA, 0x0F, 0x16, 0x00, 0x00, 0x00,\r
-            0x4E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x46, 0x00,\r
-            0x6F, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00\r
-    };\r
-\r
-    public void testReadSlideHeadersFootersContainer() throws Exception {\r
-               HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);\r
-               assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());\r
-        assertEquals(HeadersFootersContainer.SlideHeadersFootersContainer, record.getOptions());\r
-        assertEquals(2, record.getChildRecords().length);\r
-\r
-        HeadersFootersAtom hdd = record.getHeadersFootersAtom();\r
-        assertNotNull(hdd);\r
-\r
-        CString csFooter = record.getFooterAtom();\r
-        assertNotNull(csFooter);\r
-        assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);\r
-\r
-        assertEquals("My Footer - 1", csFooter.getText());\r
-\r
-        assertNull(record.getUserDateAtom());\r
-        assertNull(record.getHeaderAtom());\r
-    }\r
-\r
-       public void testWriteSlideHeadersFootersContainer() throws Exception {\r
-               HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);\r
-               ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-               record.writeOut(baos);\r
-               byte[] b = baos.toByteArray();\r
-\r
-               assertTrue(Arrays.equals(slideData, b));\r
-       }\r
-\r
-    public void testNewSlideHeadersFootersContainer() throws Exception {\r
-        HeadersFootersContainer record = new HeadersFootersContainer(HeadersFootersContainer.SlideHeadersFootersContainer);\r
-\r
-        assertNotNull(record.getHeadersFootersAtom());\r
-        assertNull(record.getUserDateAtom());\r
-        assertNull(record.getHeaderAtom());\r
-        assertNull(record.getFooterAtom());\r
-\r
-        HeadersFootersAtom hd = record.getHeadersFootersAtom();\r
-        hd.setFlag(HeadersFootersAtom.fHasDate, true);\r
-        hd.setFlag(HeadersFootersAtom.fHasTodayDate, true);\r
-        hd.setFlag(HeadersFootersAtom.fHasFooter, true);\r
-\r
-        CString csFooter = record.addFooterAtom();\r
-        assertNotNull(csFooter);\r
-        assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);\r
-        csFooter.setText("My Footer - 1");\r
-\r
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-        record.writeOut(baos);\r
-        byte[] b = baos.toByteArray();\r
-\r
-        assertTrue(Arrays.equals(slideData, b));\r
-    }\r
-\r
-    public void testReadNotesHeadersFootersContainer() throws Exception {\r
-               HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);\r
-               assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());\r
-        assertEquals(HeadersFootersContainer.NotesHeadersFootersContainer, record.getOptions());\r
-        assertEquals(3, record.getChildRecords().length);\r
-\r
-        HeadersFootersAtom hdd = record.getHeadersFootersAtom();\r
-        assertNotNull(hdd);\r
-\r
-        CString csHeader = record.getHeaderAtom();\r
-        assertNotNull(csHeader);\r
-        assertEquals(HeadersFootersContainer.HEADERATOM, csHeader.getOptions() >> 4);\r
-        assertEquals("Note Header", csHeader.getText());\r
-\r
-        CString csFooter = record.getFooterAtom();\r
-        assertNotNull(csFooter);\r
-        assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);\r
-        assertEquals("Note Footer", csFooter.getText());\r
-    }\r
-\r
-       public void testWriteNotesHeadersFootersContainer() throws Exception {\r
-               HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);\r
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-               record.writeOut(baos);\r
-               byte[] b = baos.toByteArray();\r
-\r
-               assertTrue(Arrays.equals(notesData, b));\r
-       }\r
-\r
-    public void testNewNotesHeadersFootersContainer() throws Exception {\r
-        HeadersFootersContainer record = new HeadersFootersContainer(HeadersFootersContainer.NotesHeadersFootersContainer);\r
-\r
-        assertNotNull(record.getHeadersFootersAtom());\r
-        assertNull(record.getUserDateAtom());\r
-        assertNull(record.getHeaderAtom());\r
-        assertNull(record.getFooterAtom());\r
-\r
-        HeadersFootersAtom hd = record.getHeadersFootersAtom();\r
-        hd.setFlag(HeadersFootersAtom.fHasDate, true);\r
-        hd.setFlag(HeadersFootersAtom.fHasTodayDate, false);\r
-        hd.setFlag(HeadersFootersAtom.fHasUserDate, true);\r
-        hd.setFlag(HeadersFootersAtom.fHasSlideNumber, true);\r
-        hd.setFlag(HeadersFootersAtom.fHasHeader, true);\r
-        hd.setFlag(HeadersFootersAtom.fHasFooter, true);\r
-\r
-        CString csHeader = record.addHeaderAtom();\r
-        assertNotNull(csHeader);\r
-        assertEquals(HeadersFootersContainer.HEADERATOM, csHeader.getOptions() >> 4);\r
-        csHeader.setText("Note Header");\r
-\r
-        CString csFooter = record.addFooterAtom();\r
-        assertNotNull(csFooter);\r
-        assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);\r
-        csFooter.setText("Note Footer");\r
-\r
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-        record.writeOut(baos);\r
-        byte[] b = baos.toByteArray();\r
-\r
-        assertTrue(Arrays.equals(notesData, b));\r
-    }\r
-\r
-}
\ No newline at end of file
+/* ====================================================================
+   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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link HeadersFootersContainer} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestHeadersFootersContainer extends TestCase {
+       // SlideHeadersFootersContainer
+       private byte[] slideData = new byte[] {
+            0x3F, 0x00, (byte)0xD9, 0x0F, 0x2E, 0x00, 0x00, 0x00,
+            0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00,
+            0x20, 0x00, (byte)0xBA, 0x0F, 0x1A, 0x00, 0x00, 0x00,
+            0x4D, 0x00, 0x79, 0x00, 0x20, 0x00, 0x46, 0x00, 0x6F, 0x00, 0x6F, 0x00, 0x74,
+            0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x2D, 0x00, 0x20, 0x00, 0x31, 0x00
+
+    };
+
+    // NotesHeadersFootersContainer
+    private byte[] notesData = new byte[] {
+            0x4F, 0x00, (byte)0xD9, 0x0F, 0x48, 0x00, 0x00, 0x00,
+            0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x00,
+            0x10, 0x00, (byte)0xBA, 0x0F, 0x16, 0x00, 0x00, 0x00,
+            0x4E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x48, 0x00,
+            0x65, 0x00, 0x61, 0x00, 0x64, 0x00, 0x65, 0x00, 0x72, 0x00,
+            0x20, 0x00, (byte)0xBA, 0x0F, 0x16, 0x00, 0x00, 0x00,
+            0x4E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x46, 0x00,
+            0x6F, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00
+    };
+
+    public void testReadSlideHeadersFootersContainer() throws Exception {
+               HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
+               assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
+        assertEquals(HeadersFootersContainer.SlideHeadersFootersContainer, record.getOptions());
+        assertEquals(2, record.getChildRecords().length);
+
+        HeadersFootersAtom hdd = record.getHeadersFootersAtom();
+        assertNotNull(hdd);
+
+        CString csFooter = record.getFooterAtom();
+        assertNotNull(csFooter);
+        assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
+
+        assertEquals("My Footer - 1", csFooter.getText());
+
+        assertNull(record.getUserDateAtom());
+        assertNull(record.getHeaderAtom());
+    }
+
+       public void testWriteSlideHeadersFootersContainer() throws Exception {
+               HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               record.writeOut(baos);
+               byte[] b = baos.toByteArray();
+
+               assertTrue(Arrays.equals(slideData, b));
+       }
+
+    public void testNewSlideHeadersFootersContainer() throws Exception {
+        HeadersFootersContainer record = new HeadersFootersContainer(HeadersFootersContainer.SlideHeadersFootersContainer);
+
+        assertNotNull(record.getHeadersFootersAtom());
+        assertNull(record.getUserDateAtom());
+        assertNull(record.getHeaderAtom());
+        assertNull(record.getFooterAtom());
+
+        HeadersFootersAtom hd = record.getHeadersFootersAtom();
+        hd.setFlag(HeadersFootersAtom.fHasDate, true);
+        hd.setFlag(HeadersFootersAtom.fHasTodayDate, true);
+        hd.setFlag(HeadersFootersAtom.fHasFooter, true);
+
+        CString csFooter = record.addFooterAtom();
+        assertNotNull(csFooter);
+        assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
+        csFooter.setText("My Footer - 1");
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        record.writeOut(baos);
+        byte[] b = baos.toByteArray();
+
+        assertTrue(Arrays.equals(slideData, b));
+    }
+
+    public void testReadNotesHeadersFootersContainer() throws Exception {
+               HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
+               assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
+        assertEquals(HeadersFootersContainer.NotesHeadersFootersContainer, record.getOptions());
+        assertEquals(3, record.getChildRecords().length);
+
+        HeadersFootersAtom hdd = record.getHeadersFootersAtom();
+        assertNotNull(hdd);
+
+        CString csHeader = record.getHeaderAtom();
+        assertNotNull(csHeader);
+        assertEquals(HeadersFootersContainer.HEADERATOM, csHeader.getOptions() >> 4);
+        assertEquals("Note Header", csHeader.getText());
+
+        CString csFooter = record.getFooterAtom();
+        assertNotNull(csFooter);
+        assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
+        assertEquals("Note Footer", csFooter.getText());
+    }
+
+       public void testWriteNotesHeadersFootersContainer() throws Exception {
+               HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               record.writeOut(baos);
+               byte[] b = baos.toByteArray();
+
+               assertTrue(Arrays.equals(notesData, b));
+       }
+
+    public void testNewNotesHeadersFootersContainer() throws Exception {
+        HeadersFootersContainer record = new HeadersFootersContainer(HeadersFootersContainer.NotesHeadersFootersContainer);
+
+        assertNotNull(record.getHeadersFootersAtom());
+        assertNull(record.getUserDateAtom());
+        assertNull(record.getHeaderAtom());
+        assertNull(record.getFooterAtom());
+
+        HeadersFootersAtom hd = record.getHeadersFootersAtom();
+        hd.setFlag(HeadersFootersAtom.fHasDate, true);
+        hd.setFlag(HeadersFootersAtom.fHasTodayDate, false);
+        hd.setFlag(HeadersFootersAtom.fHasUserDate, true);
+        hd.setFlag(HeadersFootersAtom.fHasSlideNumber, true);
+        hd.setFlag(HeadersFootersAtom.fHasHeader, true);
+        hd.setFlag(HeadersFootersAtom.fHasFooter, true);
+
+        CString csHeader = record.addHeaderAtom();
+        assertNotNull(csHeader);
+        assertEquals(HeadersFootersContainer.HEADERATOM, csHeader.getOptions() >> 4);
+        csHeader.setText("Note Header");
+
+        CString csFooter = record.addFooterAtom();
+        assertNotNull(csFooter);
+        assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
+        csFooter.setText("Note Footer");
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        record.writeOut(baos);
+        byte[] b = baos.toByteArray();
+
+        assertTrue(Arrays.equals(notesData, b));
+    }
+
+}
index 44be07ad5e2f770659e8cbba89ae428bd16f2378..90deb5253e38b726cf333e9e311ede34195b5d21 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -29,7 +26,7 @@ import java.io.ByteArrayOutputStream;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestNotesAtom extends TestCase {
+public final class TestNotesAtom extends TestCase {
        // From a real file
        private byte[] data_a = new byte[] { 1, 0, 0xF1-256, 3, 8, 0, 0, 0,
                0, 0, 0, 0x80-256, 0, 0, 0x0D, 0x30 };
index 255e4442c550fcc673b05876fb080ac372dc1ddd..89e63872061132d6ab5969a2ef23848f69300fa8 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -30,123 +27,123 @@ import org.apache.poi.hslf.HSLFSlideShow;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestRecordContainer extends TestCase {
+public final class TestRecordContainer extends TestCase {
        private RecordContainer recordContainer;
 
        public void testIsAnAtom() {
                assertFalse( recordContainer.isAnAtom() );
        }
-       
+
        public void testAppendChildRecord() {
                // Grab records for testing with
                Record r = recordContainer.getChildRecords()[0];
                Record rb = recordContainer.getChildRecords()[1];
                Record rc = recordContainer.getChildRecords()[2];
                Record rd = recordContainer.getChildRecords()[3];
-               
+
                // Start with an empty set
                Record[] rs = new Record[0];
                recordContainer._children = rs;
                recordContainer.appendChildRecord(r);
                Record[] nrs = recordContainer.getChildRecords();
-               
+
                assertEquals(1, nrs.length);
                assertEquals(r, nrs[0]);
-               
+
                // Now start with one with 3 entries
                rs = new Record[3];
                recordContainer._children = rs;
                rs[0] = rb;
                rs[1] = rc;
                rs[2] = rd;
-               
+
                recordContainer.appendChildRecord(r);
                nrs = recordContainer.getChildRecords();
-               
+
                assertEquals(4, nrs.length);
                assertEquals(rb, nrs[0]);
                assertEquals(rc, nrs[1]);
                assertEquals(rd, nrs[2]);
                assertEquals(r, nrs[3]);
        }
-       
+
        public void testAddChildAfter() {
                // Working with new StyleTextPropAtom
                Record newRecord = new StyleTextPropAtom(0);
-               
+
                // Try to add after a mid-record
                Record[] cr = recordContainer.getChildRecords();
                Record after = cr[2];
                Record before = cr[3];
-               
+
                recordContainer.addChildAfter(newRecord, after);
                Record[] ncr = recordContainer.getChildRecords();
-               
+
                assertEquals(cr.length+1, ncr.length);
                assertEquals(after, ncr[2]);
                assertEquals(newRecord, ncr[3]);
                assertEquals(before, ncr[4]);
-               
+
                // Try again at the end
                recordContainer._children = cr;
                after = cr[cr.length-1];
-               
+
                recordContainer.addChildAfter(newRecord, after);
                ncr = recordContainer.getChildRecords();
-               
+
                assertEquals(cr.length+1, ncr.length);
                assertEquals(after, ncr[cr.length-1]);
                assertEquals(newRecord, ncr[cr.length]);
        }
-       
+
        public void testAddChildBefore() {
                // Working with new StyleTextPropAtom
                Record newRecord = new StyleTextPropAtom(0);
-               
+
                // Try to add before a mid-record
                Record[] cr = recordContainer.getChildRecords();
                Record before = cr[2];
-               
+
                recordContainer.addChildBefore(newRecord, before);
                Record[] ncr = recordContainer.getChildRecords();
-               
+
                assertEquals(cr.length+1, ncr.length);
                assertEquals(newRecord, ncr[2]);
                assertEquals(before, ncr[3]);
-               
-               
+
+
                // Try again at the end
                recordContainer._children = cr;
                before = cr[cr.length-1];
-               
+
                recordContainer.addChildBefore(newRecord, before);
                ncr = recordContainer.getChildRecords();
-               
+
                assertEquals(cr.length+1, ncr.length);
                assertEquals(newRecord, ncr[cr.length-1]);
                assertEquals(before, ncr[cr.length]);
-               
-               
+
+
                // And at the start
                recordContainer._children = cr;
                before = cr[0];
-               
+
                recordContainer.addChildBefore(newRecord, before);
                ncr = recordContainer.getChildRecords();
-               
+
                assertEquals(cr.length+1, ncr.length);
                assertEquals(newRecord, ncr[0]);
                assertEquals(before, ncr[1]);
        }
-       
+
        protected void setUp() throws Exception {
                super.setUp();
-               
+
                // Find a real RecordContainer record
                String dirname = System.getProperty("HSLF.testdata.path");
                String filename = dirname + "/basic_test_ppt_file.ppt";
                HSLFSlideShow hss = new HSLFSlideShow(filename);
-               
+
                Record[] r = hss.getRecords();
                for(int i=0; i<r.length; i++) {
                        if(r[i] instanceof RecordContainer) {
index ca8312936ae409f8aed1e0055e53551c0ca2e2f6..464cac41dd095cd9bf1477d0dc636a5fe52bdf57 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -28,7 +25,7 @@ import junit.framework.TestCase;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestRecordTypes extends TestCase {
+public final class TestRecordTypes extends TestCase {
     public void testPPTNameLookups() throws Exception {
                assertEquals("MainMaster", RecordTypes.recordName(1016));
                assertEquals("TextBytesAtom", RecordTypes.recordName(4008));
index 18ed06cd9e9527490800fcb1952a802ae4c55a76..d9840d22d340a6735146e8fec4fb269f493ee0ed 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -30,10 +27,10 @@ import java.io.ByteArrayOutputStream;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestSlideAtom extends TestCase {
+public final class TestSlideAtom extends TestCase {
        // From a real file
        private byte[] data_a = new byte[] { 1, 0, 0xEF-256, 3, 0x18, 0, 0, 0,
-               0, 0, 0, 0, 0x0F, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80-256, 
+               0, 0, 0, 0, 0x0F, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80-256,
                0, 1, 0, 0, 7, 0, 0x0C, 0x30 };
 
     public void testRecordType() throws Exception {
index 7f0485c2db6aff72d12e904b0311f36eecdfcbfc..aad4aec623bf9bae184018c8ca2dfe2cc90607e4 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -29,7 +26,7 @@ import java.io.ByteArrayOutputStream;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestSlidePersistAtom extends TestCase {
+public final class TestSlidePersistAtom extends TestCase {
        // From a real file
        private byte[] data_a = new byte[] { 0, 0, 0xF3-256, 3, 0x14, 0, 0, 0,
                4, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 0,
index 97a4b7c5b580465b6361b999fbd996c630fd7c32..056cbaac9cb0b023fa3638c26869c84a7674403b 100755 (executable)
@@ -1,86 +1,83 @@
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.text.SimpleDateFormat;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.Arrays;\r
-\r
-import org.apache.poi.hslf.HSLFSlideShow;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-\r
-/**\r
- * Tests Sound-related records: SoundCollection(2020), Sound(2022) and SoundData(2023)).\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestSound extends TestCase {\r
-       public void testRealFile() throws Exception {\r
-               String cwd = System.getProperty("HSLF.testdata.path");\r
-               FileInputStream is = new FileInputStream(new File(cwd, "sound.ppt"));\r
-               SlideShow ppt = new SlideShow(is);\r
-               is.close();\r
-\r
-               // Get the document\r
-               Document doc = ppt.getDocumentRecord();\r
-        SoundCollection soundCollection = null;\r
-        Record[] doc_ch = doc.getChildRecords();\r
-        for (int i = 0; i < doc_ch.length; i++) {\r
-            if(doc_ch[i] instanceof SoundCollection){\r
-                soundCollection = (SoundCollection)doc_ch[i];\r
-                break;\r
-            }\r
-        }\r
-        assertNotNull(soundCollection);\r
-\r
-        Sound sound = null;\r
-        Record[] sound_ch = soundCollection.getChildRecords();\r
-        int k = 0;\r
-        for (int i = 0; i < sound_ch.length; i++) {\r
-            if(sound_ch[i] instanceof Sound){\r
-                sound = (Sound)sound_ch[i];\r
-                k++;\r
-            }\r
-        }\r
-        assertNotNull(sound);\r
-        assertEquals(1, k);\r
-\r
-        assertEquals("ringin.wav", sound.getSoundName());\r
-        assertEquals(".WAV", sound.getSoundType());\r
-        assertNotNull(sound.getSoundData());\r
-\r
-        File f = new File(cwd, "ringin.wav");\r
-        int length = (int)f.length();\r
-        byte[] ref_data = new byte[length];\r
-        is = new FileInputStream(f);\r
-        is.read(ref_data);\r
-        is.close();\r
-\r
-        assertTrue(Arrays.equals(ref_data, sound.getSoundData()));\r
-\r
-       }\r
-}\r
+/* ====================================================================
+   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.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 org.apache.poi.hslf.usermodel.SlideShow;
+
+/**
+ * Tests Sound-related records: SoundCollection(2020), Sound(2022) and SoundData(2023)).
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestSound extends TestCase {
+       public void testRealFile() throws Exception {
+               String cwd = System.getProperty("HSLF.testdata.path");
+               FileInputStream is = new FileInputStream(new File(cwd, "sound.ppt"));
+               SlideShow ppt = new SlideShow(is);
+               is.close();
+
+               // 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);
+
+        assertEquals("ringin.wav", sound.getSoundName());
+        assertEquals(".WAV", sound.getSoundType());
+        assertNotNull(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 a31ddeb3ff81b4800689d2b2e1c19cdb280c7b2f..2e11d0d16b6aaa672797aa407b861756f02d49f3 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -38,11 +35,11 @@ import java.util.Arrays;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestStyleTextPropAtom extends TestCase {
+public final class TestStyleTextPropAtom extends TestCase {
     /** From a real file: a paragraph with 4 different styles */
     private byte[] data_a = new byte[] {
       0, 0, 0xA1-256, 0x0F, 0x2A, 0, 0, 0,
-      0x36, 00, 00, 00, // paragraph is 54 long 
+      0x36, 00, 00, 00, // paragraph is 54 long
       00, 00,           // (paragraph reserved field)
       00, 00, 00, 00,   // it doesn't have any styles
       0x15, 00, 00, 00, // first char run is 21 long
@@ -759,7 +756,7 @@ public class TestStyleTextPropAtom extends TestCase {
                 0x50, 0x00, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
                 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00,
                 0x01, 0x04, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00,
-                0x01, 0x08, 0x0C, 0x00, 0x00, 0x00, 0x01, 0x0C, 0x00, 0x00, 
+                0x01, 0x08, 0x0C, 0x00, 0x00, 0x00, 0x01, 0x0C, 0x00, 0x00,
                 0x01, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00,
                 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x01, 0x14, 0x00, 0x00,
                 0x01, 0x14, 0x01, 0x00, 0x00, 0x00, 0x01, 0x18, 0x00, 0x00,
index 5eaad2e9a29286ac88cb81334bda0fb29c6962c8..1df2ad0c5103db7b17750164f44c8583f8ae750e 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -29,15 +26,15 @@ import java.io.ByteArrayOutputStream;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestTextBytesAtom extends TestCase {
+public final class TestTextBytesAtom extends TestCase {
        // From a real file
-       private byte[] data = new byte[]  { 0, 0, 0xA8-256, 0x0f, 0x1c, 0, 0, 0, 
-               0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 
+       private byte[] data = new byte[]  { 0, 0, 0xA8-256, 0x0f, 0x1c, 0, 0, 0,
+               0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
                0x65, 0x20, 0x74, 0x69, 0x74, 0x6C,     0x65, 0x20, 0x6F, 0x6E,
                0x20, 0x70, 0x61, 0x67, 0x65, 0x20, 0x32 };
        private String data_text = "This is the title on page 2";
        private byte[] alt_data = new byte[] { 0, 0, 0xA8-256, 0x0F, 0x14, 0, 0, 0,
-               0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 
+               0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20,
                0x74, 0x65, 0x73, 0x74, 0x20, 0x74, 0x69, 0x74, 0x6C, 0x65 };
        private String alt_text = "This is a test title";
 
index b03a19798d3e9733fd5d8d3c5851d5175bba1b27..2f29dfd3c7f86e5e04b2b845a4d3b8f388eff5c9 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -29,9 +26,9 @@ import java.io.ByteArrayOutputStream;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestTextCharsAtom extends TestCase {
+public final class TestTextCharsAtom extends TestCase {
        // From a real file
-       private byte[] data = new byte[]  { 0, 0, 0xA0-256, 0x0f, 0x08, 0, 0, 0, 
+       private byte[] data = new byte[]  { 0, 0, 0xA0-256, 0x0f, 0x08, 0, 0, 0,
                0x54, 0x00, 0x68, 0x00, 0x69, 0x00, 0x73, 0x00 };
        private String data_text = "This";
        private byte[] alt_data = new byte[] { 0, 0, 0xA0-256, 0x0F, 0x0a, 0, 0, 0,
@@ -66,7 +63,7 @@ public class TestTextCharsAtom extends TestCase {
                        assertEquals(alt_data[i],b[i]);
                }
        }
-       
+
        public void testWrite() throws Exception {
                TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -78,14 +75,14 @@ public class TestTextCharsAtom extends TestCase {
                        assertEquals(data[i],b[i]);
                }
        }
-       
+
        public void testCreateNew() throws Exception {
                TextCharsAtom tca = new TextCharsAtom();
                assertEquals(0, tca.getText().length());
-               
+
                tca.setText(data_text);
                assertEquals(data_text, tca.getText());
-               
+
                // Check it's now like data
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                tca.writeOut(baos);
index 6ee694c6850992c0cab1b57fea80bcefdfbe051b..22947132d486da5c8a39836e8b61fa4215c473a7 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -29,7 +26,7 @@ import java.io.ByteArrayOutputStream;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestTextHeaderAtom extends TestCase {
+public final class TestTextHeaderAtom extends TestCase {
        // From a real file
        private byte[] notes_data = new byte[] { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 2, 0, 0, 0};
        private byte[] title_data = new byte[] { 0, 0, 0x9f-256, 0x0f, 4, 0, 0, 0, 0, 0, 0, 0 };
index 3579ace5905d7dcf372d242150dce1b70f561580..fa2f664e32a9c0302c8b80e732de401107e3d2a0 100755 (executable)
@@ -1,92 +1,89 @@
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import org.apache.poi.hslf.HSLFSlideShow;\r
-import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp;\r
-import org.apache.poi.hslf.model.textproperties.TextProp;\r
-import org.apache.poi.hslf.model.textproperties.TextPropCollection;\r
-import org.apache.poi.hslf.record.StyleTextPropAtom.*;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.util.HexDump;\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.util.LinkedList;\r
-import java.util.Arrays;\r
-\r
-/**\r
- * Tests TextRulerAtom\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestTextRulerAtom extends TestCase {\r
-\r
-    //from a real file\r
-       private byte[] data_1 = new byte[] {\r
-               0x00, 0x00, (byte)0xA6, 0x0F, 0x18, 0x00, 0x00, 0x00,\r
-        (byte)0xF8, 0x1F, 0x00, 0x00, 0x75, 0x00, (byte)0xE2, 0x00, 0x59,\r
-        0x01, (byte)0xC3, 0x01, 0x1A, 0x03, (byte)0x87, 0x03, (byte)0xF8,\r
-        0x03, 0x69, 0x04, (byte)0xF6, 0x05, (byte)0xF6, 0x05\r
-       };\r
-\r
-    private byte[] data_2 = new byte[] {\r
-        0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00,\r
-        0x10, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01\r
-    };\r
-\r
-    public void testReadRuler() throws Exception {\r
-               TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length);\r
-        assertEquals(ruler.getNumberOfLevels(), 0);\r
-        assertEquals(ruler.getDefaultTabSize(), 0);\r
-\r
-        int[] tabStops = ruler.getTabStops();\r
-        assertNull(tabStops);\r
-\r
-        int[] textOffsets = ruler.getTextOffsets();\r
-        assertTrue(Arrays.equals(new int[]{226, 451, 903, 1129, 1526}, textOffsets));\r
-\r
-        int[] bulletOffsets = ruler.getBulletOffsets();\r
-        assertTrue(Arrays.equals(new int[]{117, 345, 794, 1016, 1526}, bulletOffsets));\r
-\r
-       }\r
-\r
-    public void testWriteRuler() throws Exception {\r
-               TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length);\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        ruler.writeOut(out);\r
-\r
-        byte[] result = out.toByteArray();\r
-        assertTrue(Arrays.equals(result, data_1));\r
-       }\r
-\r
-    public void testRead2() throws Exception {\r
-               TextRulerAtom ruler = TextRulerAtom.getParagraphInstance();\r
-        ruler.setParagraphIndent((short)249, (short)321);\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        ruler.writeOut(out);\r
-\r
-        byte[] result = out.toByteArray();\r
-        assertTrue(Arrays.equals(result, data_2));\r
-\r
-       }\r
-\r
-}\r
+/* ====================================================================
+   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.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;
+
+/**
+ * Tests TextRulerAtom
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestTextRulerAtom extends TestCase {
+
+    //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
+       };
+
+    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 {
+               TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length);
+        assertEquals(ruler.getNumberOfLevels(), 0);
+        assertEquals(ruler.getDefaultTabSize(), 0);
+
+        int[] tabStops = ruler.getTabStops();
+        assertNull(tabStops);
+
+        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));
+
+       }
+
+    public void testWriteRuler() throws Exception {
+               TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length);
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ruler.writeOut(out);
+
+        byte[] result = out.toByteArray();
+        assertTrue(Arrays.equals(result, data_1));
+       }
+
+    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));
+
+       }
+
+}
index 5079628aec6afab3d420ce39da188dc7c3ecc91e..62fb5ee285609bd5e1dfa9f4b6e06694d5657721 100755 (executable)
@@ -1,95 +1,92 @@
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-import org.apache.poi.hslf.HSLFSlideShow;\r
-import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp;\r
-import org.apache.poi.hslf.model.textproperties.TextProp;\r
-import org.apache.poi.hslf.model.textproperties.TextPropCollection;\r
-import org.apache.poi.hslf.record.StyleTextPropAtom.*;\r
-import org.apache.poi.hslf.usermodel.SlideShow;\r
-import org.apache.poi.util.HexDump;\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.util.LinkedList;\r
-import java.util.Arrays;\r
-\r
-/**\r
- * Tests TextSpecInfoAtom\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestTextSpecInfoAtom extends TestCase {\r
-\r
-    //from a real file\r
-       private byte[] data_1 = new byte[] {\r
-        0x00, 0x00, (byte)0xAA, 0x0F, 0x2C, 0x00, 0x00, 0x00,\r
-        0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\r
-        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00,\r
-        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x01,\r
-        0x00, 0x00, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r
-       };\r
-\r
-\r
-    public void testRead() throws Exception {\r
-               TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);\r
-        TextSpecInfoAtom.TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();\r
-        assertEquals(5, run.length);\r
-\r
-        assertEquals(10, run[0].length());\r
-        assertEquals(1, run[1].length());\r
-        assertEquals(70, run[2].length());\r
-        assertEquals(9, run[3].length());\r
-        assertEquals(32, run[4].length());\r
-\r
-    }\r
-\r
-    public void testWrite() throws Exception {\r
-        TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        spec.writeOut(out);\r
-\r
-        byte[] result = out.toByteArray();\r
-        assertTrue(Arrays.equals(result, data_1));\r
-       }\r
-\r
-    public void testReset() throws Exception {\r
-        TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);\r
-        spec.reset(32);  //length of the parent text\r
-\r
-        TextSpecInfoAtom.TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();\r
-        assertEquals(1, run.length);\r
-\r
-        assertEquals(32, run[0].length());\r
-\r
-        //serialize and read again\r
-        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
-        spec.writeOut(out);\r
-\r
-        byte[] result = out.toByteArray();\r
-        TextSpecInfoAtom spec2 = new TextSpecInfoAtom(result, 0, result.length);\r
-        TextSpecInfoAtom.TextSpecInfoRun[] run2 = spec2.getTextSpecInfoRuns();\r
-        assertEquals(1, run2.length);\r
-\r
-        assertEquals(32, run2[0].length());\r
-    }\r
-}\r
+/* ====================================================================
+   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.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;
+
+/**
+ * Tests TextSpecInfoAtom
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestTextSpecInfoAtom extends TestCase {
+
+    //from a real file
+       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);
+        TextSpecInfoAtom.TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();
+        assertEquals(5, run.length);
+
+        assertEquals(10, run[0].length());
+        assertEquals(1, run[1].length());
+        assertEquals(70, run[2].length());
+        assertEquals(9, run[3].length());
+        assertEquals(32, run[4].length());
+
+    }
+
+    public void testWrite() throws Exception {
+        TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        spec.writeOut(out);
+
+        byte[] result = out.toByteArray();
+        assertTrue(Arrays.equals(result, data_1));
+       }
+
+    public void testReset() throws Exception {
+        TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
+        spec.reset(32);  //length of the parent text
+
+        TextSpecInfoAtom.TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();
+        assertEquals(1, run.length);
+
+        assertEquals(32, run[0].length());
+
+        //serialize and read again
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        spec.writeOut(out);
+
+        byte[] result = out.toByteArray();
+        TextSpecInfoAtom spec2 = new TextSpecInfoAtom(result, 0, result.length);
+        TextSpecInfoAtom.TextSpecInfoRun[] run2 = spec2.getTextSpecInfoRuns();
+        assertEquals(1, run2.length);
+
+        assertEquals(32, run2[0].length());
+    }
+}
index 9cb53d762ff4a56026753e201195f713a8f2dc78..9f3d575c22e79f55e8b558082f5de77c5218e7f7 100644 (file)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-        \r
-\r
-\r
-package org.apache.poi.hslf.record;\r
-\r
-\r
-import junit.framework.TestCase;\r
-import java.io.ByteArrayOutputStream;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Date;\r
-\r
-/**\r
- * Tests that TxInteractiveInfoAtom works properly.\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestTxInteractiveInfoAtom extends TestCase {\r
-       // From WithLinks.ppt \r
-       private byte[] data_a = new byte[] { \r
-               00, 00, (byte)0xDF, 0x0F, 0x08, 00, 00, 00,\r
-               0x19, 00, 00, 00, 0x38, 00, 00, 00\r
-       };\r
-\r
-    private byte[] data_b = new byte[] {\r
-        00, 00, (byte)0xDF, 0x0F, 0x08, 00, 00, 00,\r
-        0x39, 00, 00, 00, 0x4E, 00, 00, 00\r
-    };\r
-\r
-    public void testRead() throws Exception {\r
-        TxInteractiveInfoAtom ia1 = new TxInteractiveInfoAtom(data_a, 0, data_a.length);\r
-\r
-        assertEquals(4063, ia1.getRecordType());\r
-               assertEquals(25, ia1.getStartIndex());\r
-               assertEquals(56, ia1.getEndIndex());\r
-\r
-        TxInteractiveInfoAtom ia2 = new TxInteractiveInfoAtom(data_b, 0, data_b.length);\r
-\r
-        assertEquals(4063, ia2.getRecordType());\r
-               assertEquals(57, ia2.getStartIndex());\r
-               assertEquals(78, ia2.getEndIndex());\r
-    }\r
-    \r
-       public void testWrite() throws Exception {\r
-               TxInteractiveInfoAtom atom = new TxInteractiveInfoAtom(data_a, 0, data_a.length);\r
-               ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-               atom.writeOut(baos);\r
-               byte[] b = baos.toByteArray();\r
-\r
-               assertEquals(data_a.length, b.length);\r
-               for(int i=0; i<data_a.length; i++) {\r
-                       assertEquals(data_a[i],b[i]);\r
-               }\r
-       }\r
-\r
-       // Create A from scratch\r
-    public void testCreate() throws Exception {\r
-       TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom();\r
-       \r
-       // Set values\r
-        ia.setStartIndex(25);\r
-       ia.setEndIndex(56);\r
-\r
-               // Check it's now the same as a\r
-               ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-               ia.writeOut(baos);\r
-               byte[] b = baos.toByteArray();\r
-               \r
-               assertEquals(data_a.length, b.length);\r
-               for(int i=0; i<data_a.length; i++) {\r
-                       assertEquals(data_a[i],b[i]);\r
-               }\r
-    }\r
-\r
-       // Try to turn a into b\r
-       public void testChange() throws Exception {\r
-               TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom(data_a, 0, data_a.length);\r
-\r
-               // Change the number\r
-               ia.setStartIndex(57);\r
-        ia.setEndIndex(78);\r
-\r
-               // Check bytes are now the same\r
-               ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-               ia.writeOut(baos);\r
-               byte[] b = baos.toByteArray();\r
-\r
-               // Should now be the same\r
-               assertEquals(data_b.length, b.length);\r
-               for(int i=0; i<data_b.length; i++) {\r
-                       assertEquals(data_b[i],b[i]);\r
-               }\r
-       }\r
-}\r
+/* ====================================================================
+   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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Tests that TxInteractiveInfoAtom works properly.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestTxInteractiveInfoAtom extends TestCase {
+       // From WithLinks.ppt
+       private byte[] data_a = new byte[] {
+               00, 00, (byte)0xDF, 0x0F, 0x08, 00, 00, 00,
+               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
+    };
+
+    public void testRead() throws Exception {
+        TxInteractiveInfoAtom ia1 = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
+
+        assertEquals(4063, ia1.getRecordType());
+               assertEquals(25, ia1.getStartIndex());
+               assertEquals(56, ia1.getEndIndex());
+
+        TxInteractiveInfoAtom ia2 = new TxInteractiveInfoAtom(data_b, 0, data_b.length);
+
+        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);
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               atom.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]);
+               }
+       }
+
+       // Create A from scratch
+    public void testCreate() throws Exception {
+       TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom();
+
+       // Set values
+        ia.setStartIndex(25);
+       ia.setEndIndex(56);
+
+               // 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 {
+               TxInteractiveInfoAtom ia = new TxInteractiveInfoAtom(data_a, 0, data_a.length);
+
+               // Change the number
+               ia.setStartIndex(57);
+        ia.setEndIndex(78);
+
+               // 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++) {
+                       assertEquals(data_b[i],b[i]);
+               }
+       }
+}
index ce6e0edb08b757cd4984a0b53a3660abd32c1ee9..5072a30332d6c43a29a2ddcce792d84ec3b7b591 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,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.record;
 
 import junit.framework.TestCase;
@@ -33,7 +33,7 @@ import java.util.ArrayList;
  *
  * @author Yegor Kozlov
  */
-public class TestTxMasterStyleAtom extends TestCase {
+public final class TestTxMasterStyleAtom extends TestCase {
     protected SlideShow _ppt;
 
     public void setUp() throws Exception{
index ea54965a45f41d23a73d81f09f5c930942d00bfd..b82e29b5c457916c695f5cb7ee340d84add1c697 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.record;
 
@@ -29,11 +26,11 @@ import java.io.ByteArrayOutputStream;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestUserEditAtom extends TestCase {
+public final class TestUserEditAtom extends TestCase {
        // From a real file
        private byte[] data_a = new byte[] { 0, 0, 0xF5-256, 0x0F, 0x1C, 0, 0, 0,
                00, 01, 00, 00, 0xD9-256, 18, 00, 03,
-               00, 00, 00, 00, 00, 0x18, 00, 00, 01, 00, 00, 00, 
+               00, 00, 00, 00, 00, 0x18, 00, 00, 01, 00, 00, 00,
                05, 00, 00, 00, 01, 00, 0xF6-256, 77 };
 
     public void testRecordType() throws Exception {
index 17f8fcb68c5529ab4a50b46f337e7f02b6f6a0b2..52a1da7ce68ce76e09b25eb168e7b02e779c83ba 100644 (file)
@@ -37,40 +37,40 @@ public final class TestAddingSlides extends TestCase {
        // An empty SlideShow
        private HSLFSlideShow hss_empty;
        private SlideShow ss_empty;
-       
+
        // A SlideShow with one slide
        private HSLFSlideShow hss_one;
        private SlideShow ss_one;
-       
+
        // A SlideShow with two slides
        private HSLFSlideShow hss_two;
        private SlideShow ss_two;
-       
+
        /**
         * Create/open the slideshows
         */
        public void setUp() throws Exception {
                hss_empty = HSLFSlideShow.create();
                ss_empty = new SlideShow(hss_empty);
-               
+
                String dirname = System.getProperty("HSLF.testdata.path");
-               
+
                String filename = dirname + "/Single_Coloured_Page.ppt";
                hss_one = new HSLFSlideShow(filename);
                ss_one = new SlideShow(hss_one);
-               
+
                filename = dirname + "/basic_test_ppt_file.ppt";
                hss_two = new HSLFSlideShow(filename);
                ss_two = new SlideShow(hss_two);
        }
-       
+
        /**
         * Test adding a slide to an empty slideshow
         */
        public void testAddSlideToEmpty() throws Exception {
                // Doesn't have any slides
                assertEquals(0, ss_empty.getSlides().length);
-               
+
                // Should only have a master SLWT
                assertEquals(1, ss_empty.getDocumentRecord().getSlideListWithTexts().length);
 
@@ -97,23 +97,23 @@ public final class TestAddingSlides extends TestCase {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                hss_empty.write(baos);
                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-               
+
                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
                SlideShow ss_read = new SlideShow(hss_read);
-               
+
                // Check it now has a slide
                assertEquals(1, ss_read.getSlides().length);
 
                // Check it now has two SLWTs
                assertEquals(2, ss_empty.getDocumentRecord().getSlideListWithTexts().length);
-               
+
                // And check it's as expected
                slide = ss_read.getSlides()[0];
                assertEquals(256, slide._getSheetNumber());
                assertEquals(3, slide._getSheetRefId());
                assertEquals(1, slide.getSlideNumber());
        }
-       
+
        /**
         * Test adding a slide to an existing slideshow
         */
@@ -121,36 +121,36 @@ public final class TestAddingSlides extends TestCase {
                // Has one slide
                assertEquals(1, ss_one.getSlides().length);
                Slide s1 = ss_one.getSlides()[0];
-               
+
                // Should have two SLTWs
                assertEquals(2, ss_one.getDocumentRecord().getSlideListWithTexts().length);
-               
+
                // Check slide 1 is as expected
                assertEquals(256, s1._getSheetNumber());
                assertEquals(3, s1._getSheetRefId());
                assertEquals(1, s1.getSlideNumber());
-               
+
                // Add a second one
                Slide s2 = ss_one.createSlide();
                assertEquals(2, ss_one.getSlides().length);
                assertEquals(257, s2._getSheetNumber());
                assertEquals(4, s2._getSheetRefId());
                assertEquals(2, s2.getSlideNumber());
-               
+
                // Write out, and read back in
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                hss_one.write(baos);
                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-               
+
                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
                SlideShow ss_read = new SlideShow(hss_read);
-               
+
                // Check it now has two slides
                assertEquals(2, ss_read.getSlides().length);
-               
+
                // Should still have two SLTWs
                assertEquals(2, ss_read.getDocumentRecord().getSlideListWithTexts().length);
-               
+
                // And check it's as expected
                s1 = ss_read.getSlides()[0];
                s2 = ss_read.getSlides()[1];
@@ -161,7 +161,7 @@ public final class TestAddingSlides extends TestCase {
                assertEquals(4, s2._getSheetRefId());
                assertEquals(2, s2.getSlideNumber());
        }
-       
+
        /**
         * Test adding a slide to an existing slideshow,
         *  with two slides already
@@ -182,7 +182,7 @@ public final class TestAddingSlides extends TestCase {
                assertEquals(2, ss_two.getSlides().length);
                Slide s1 = ss_two.getSlides()[0];
                Slide s2 = ss_two.getSlides()[1];
-               
+
                // Check slide 1 is as expected
                assertEquals(256, s1._getSheetNumber());
                assertEquals(4, s1._getSheetRefId()); // master has notes
@@ -204,13 +204,13 @@ public final class TestAddingSlides extends TestCase {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                hss_two.write(baos);
                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-               
+
                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
                SlideShow ss_read = new SlideShow(hss_read);
-               
+
                // Check it now has three slides
                assertEquals(3, ss_read.getSlides().length);
-               
+
                // And check it's as expected
                s1 = ss_read.getSlides()[0];
                s2 = ss_read.getSlides()[1];
index 820a5390a5760f9d37229392d06eefd179d48795..742131a9358fe1bbcb068abd912b85bc59e3d969 100644 (file)
-\r
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-package org.apache.poi.hslf.usermodel;\r
-\r
-import junit.framework.TestCase;\r
-import org.apache.poi.hslf.HSLFSlideShow;\r
-import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;\r
-import org.apache.poi.hslf.model.*;\r
-import org.apache.poi.hslf.model.Shape;\r
-\r
-import java.io.*;\r
-import java.util.HashSet;\r
-import java.util.HashMap;\r
-import java.util.ArrayList;\r
-import java.awt.*;\r
-\r
-/**\r
- * Testcases for bugs entered in bugzilla\r
- * the Test name contains the bugzilla bug id\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestBugs extends TestCase {\r
-    protected String cwd = System.getProperty("HSLF.testdata.path");\r
-\r
-    /**\r
-     * Bug 41384: Array index wrong in record creation\r
-     */\r
-    public void test41384() throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "41384.ppt"));\r
-        HSLFSlideShow hslf = new HSLFSlideShow(is);\r
-        is.close();\r
-\r
-        SlideShow ppt = new SlideShow(hslf);\r
-        assertTrue("No Exceptions while reading file", true);\r
-\r
-        assertEquals(1, ppt.getSlides().length);\r
-\r
-        PictureData[] pict = ppt.getPictureData();\r
-        assertEquals(2, pict.length);\r
-        assertEquals(Picture.JPEG, pict[0].getType());\r
-        assertEquals(Picture.JPEG, pict[1].getType());\r
-    }\r
-\r
-    /**\r
-     * First fix from Bug 42474: NPE in RichTextRun.isBold()\r
-     * when the RichTextRun comes from a Notes model object\r
-     */\r
-    public void test42474_1() throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "42474-1.ppt"));\r
-        HSLFSlideShow hslf = new HSLFSlideShow(is);\r
-        is.close();\r
-\r
-        SlideShow ppt = new SlideShow(hslf);\r
-        assertTrue("No Exceptions while reading file", true);\r
-        assertEquals(2, ppt.getSlides().length);\r
-\r
-        TextRun txrun;\r
-        Notes notes;\r
-\r
-        notes = ppt.getSlides()[0].getNotesSheet();\r
-        assertNotNull(notes);\r
-        txrun = notes.getTextRuns()[0];\r
-        assertEquals("Notes-1", txrun.getRawText());\r
-        assertEquals(false, txrun.getRichTextRuns()[0].isBold());\r
-\r
-        //notes for the second slide are in bold\r
-        notes = ppt.getSlides()[1].getNotesSheet();\r
-        assertNotNull(notes);\r
-        txrun = notes.getTextRuns()[0];\r
-        assertEquals("Notes-2", txrun.getRawText());\r
-        assertEquals(true, txrun.getRichTextRuns()[0].isBold());\r
-\r
-    }\r
-\r
-    /**\r
-     * Second fix from Bug 42474: Incorrect matching of notes to slides\r
-     */\r
-    public void test42474_2() throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "42474-2.ppt"));\r
-        HSLFSlideShow hslf = new HSLFSlideShow(is);\r
-        is.close();\r
-\r
-        SlideShow ppt = new SlideShow(hslf);\r
-\r
-        //map slide number and starting phrase of its notes\r
-        HashMap notesMap = new HashMap();\r
-        notesMap.put(new Integer(4), "For  decades before calculators");\r
-        notesMap.put(new Integer(5), "Several commercial applications");\r
-        notesMap.put(new Integer(6), "There are three variations of LNS that are discussed here");\r
-        notesMap.put(new Integer(7), "Although multiply and square root are easier");\r
-        notesMap.put(new Integer(8), "The bus Z is split into Z_H and Z_L");\r
-\r
-        Slide[] slide = ppt.getSlides();\r
-        for (int i = 0; i < slide.length; i++) {\r
-            Integer slideNumber = new Integer(slide[i].getSlideNumber());\r
-            Notes notes = slide[i].getNotesSheet();\r
-            if (notesMap.containsKey(slideNumber)){\r
-                assertNotNull(notes);\r
-                String text = notes.getTextRuns()[0].getRawText();\r
-                String startingPhrase = (String)notesMap.get(slideNumber);\r
-                assertTrue("Notes for slide " + slideNumber + " must start with " +\r
-                        startingPhrase , text.startsWith(startingPhrase));\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Bug 42485: All TextBoxes inside ShapeGroups have null TextRuns\r
-     */\r
-    public void test42485 () throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "42485.ppt"));\r
-        HSLFSlideShow hslf = new HSLFSlideShow(is);\r
-        is.close();\r
-\r
-        SlideShow ppt = new SlideShow(hslf);\r
-        Shape[] shape = ppt.getSlides()[0].getShapes();\r
-        for (int i = 0; i < shape.length; i++) {\r
-            if(shape[i] instanceof ShapeGroup){\r
-                ShapeGroup  group = (ShapeGroup)shape[i];\r
-                Shape[] sh = group.getShapes();\r
-                for (int j = 0; j < sh.length; j++) {\r
-                    if( sh[j] instanceof TextBox){\r
-                        TextBox txt = (TextBox)sh[j];\r
-                        assertNotNull(txt.getTextRun());\r
-                    }\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Bug 42484: NullPointerException from ShapeGroup.getAnchor()\r
-     */\r
-    public void test42484 () throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "42485.ppt")); //test file is the same as for bug 42485\r
-        HSLFSlideShow hslf = new HSLFSlideShow(is);\r
-        is.close();\r
-\r
-        SlideShow ppt = new SlideShow(hslf);\r
-        Shape[] shape = ppt.getSlides()[0].getShapes();\r
-        for (int i = 0; i < shape.length; i++) {\r
-            if(shape[i] instanceof ShapeGroup){\r
-                ShapeGroup  group = (ShapeGroup)shape[i];\r
-                assertNotNull(group.getAnchor());\r
-                Shape[] sh = group.getShapes();\r
-                for (int j = 0; j < sh.length; j++) {\r
-                    assertNotNull(sh[j].getAnchor());\r
-                }\r
-            }\r
-        }\r
-        assertTrue("No Exceptions while reading file", true);\r
-    }\r
-\r
-    /**\r
-     * Bug 41381: Exception from Slide.getMasterSheet() on a seemingly valid PPT file\r
-     */\r
-    public void test41381() throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "alterman_security.ppt"));\r
-        HSLFSlideShow hslf = new HSLFSlideShow(is);\r
-        is.close();\r
-\r
-        SlideShow ppt = new SlideShow(hslf);\r
-        assertTrue("No Exceptions while reading file", true);\r
-\r
-        assertEquals(1, ppt.getSlidesMasters().length);\r
-        assertEquals(1, ppt.getTitleMasters().length);\r
-        Slide[] slide = ppt.getSlides();\r
-        for (int i = 0; i < slide.length; i++) {\r
-            MasterSheet master = slide[i].getMasterSheet();\r
-            if (i == 0) assertTrue(master instanceof TitleMaster); //the first slide follows TitleMaster\r
-            else assertTrue(master instanceof SlideMaster);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Bug 42486:  Failure parsing a seemingly valid PPT\r
-     */\r
-    public void test42486 () throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "42486.ppt"));\r
-        HSLFSlideShow hslf = new HSLFSlideShow(is);\r
-        is.close();\r
-\r
-        SlideShow ppt = new SlideShow(hslf);\r
-        Slide[] slide = ppt.getSlides();\r
-        for (int i = 0; i < slide.length; i++) {\r
-            Shape[] shape = slide[i].getShapes();\r
-        }\r
-        assertTrue("No Exceptions while reading file", true);\r
-\r
-    }\r
-\r
-    /**\r
-     * Bug 42524:  NPE in Shape.getShapeType()\r
-     */\r
-    public void test42524 () throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "42486.ppt")); //test file is the same as for Bug 42486\r
-        HSLFSlideShow hslf = new HSLFSlideShow(is);\r
-        is.close();\r
-\r
-        SlideShow ppt = new SlideShow(hslf);\r
-        //walk down the tree and see if there were no errors while reading\r
-        Slide[] slide = ppt.getSlides();\r
-        for (int i = 0; i < slide.length; i++) {\r
-            Shape[] shape = slide[i].getShapes();\r
-            for (int j = 0; j < shape.length; j++) {\r
-                assertNotNull(shape[j].getShapeName());\r
-                if (shape[j] instanceof ShapeGroup){\r
-                    ShapeGroup group = (ShapeGroup)shape[j];\r
-                    Shape[] comps = group.getShapes();\r
-                    for (int k = 0; k < comps.length; k++) {\r
-                        assertNotNull(comps[k].getShapeName());\r
-                   }\r
-                }\r
-            }\r
-\r
-        }\r
-        assertTrue("No Exceptions while reading file", true);\r
-\r
-    }\r
-\r
-    /**\r
-     * Bug 42520:  NPE in Picture.getPictureData()\r
-     */\r
-    public void test42520 () throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "42520.ppt")); //test file is the same as for Bug 42486\r
-        HSLFSlideShow hslf = new HSLFSlideShow(is);\r
-        is.close();\r
-\r
-        SlideShow ppt = new SlideShow(hslf);\r
-\r
-        //test case from the bug report\r
-        ShapeGroup shapeGroup = (ShapeGroup)ppt.getSlides()[11].getShapes()[10];\r
-        Picture picture = (Picture)shapeGroup.getShapes()[0];\r
-        picture.getPictureData();\r
-\r
-        //walk down the tree and see if there were no errors while reading\r
-        Slide[] slide = ppt.getSlides();\r
-        for (int i = 0; i < slide.length; i++) {\r
-            Shape[] shape = slide[i].getShapes();\r
-            for (int j = 0; j < shape.length; j++) {\r
-              if (shape[j] instanceof ShapeGroup){\r
-                    ShapeGroup group = (ShapeGroup)shape[j];\r
-                    Shape[] comps = group.getShapes();\r
-                    for (int k = 0; k < comps.length; k++) {\r
-                        Shape comp = comps[k];\r
-                        if (comp instanceof Picture){\r
-                            PictureData pict = ((Picture)comp).getPictureData();\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-\r
-        }\r
-        assertTrue("No Exceptions while reading file", true);\r
-\r
-    }\r
-\r
-    /**\r
-     * Bug 38256:  RuntimeException: Couldn't instantiate the class for type with id 0.\r
-     * ( also fixed followup: getTextRuns() returns no text )\r
-     */\r
-    public void test38256 () throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "38256.ppt"));\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-         \r
-        assertTrue("No Exceptions while reading file", true);\r
-\r
-        Slide[] slide = ppt.getSlides();\r
-        assertEquals(1, slide.length);\r
-        TextRun[] runs = slide[0].getTextRuns();\r
-        assertEquals(4, runs.length);\r
-\r
-        HashSet txt = new HashSet();\r
-        txt.add("\u201CHAPPY BIRTHDAY SCOTT\u201D");\r
-        txt.add("Have a HAPPY DAY");\r
-        txt.add("PS Nobody is allowed to hassle Scott TODAY\u2026");\r
-        txt.add("Drinks will be in the Boardroom at 5pm today to celebrate Scott\u2019s B\u2019Day\u2026  See you all there!");\r
-\r
-        for (int i = 0; i < runs.length; i++) {\r
-            String text = runs[i].getRawText();\r
-            assertTrue(text, txt.contains(text));\r
-        }\r
-\r
-    }\r
-\r
-    /**\r
-     * Bug 38256:  RuntimeException: Couldn't instantiate the class for type with id 0.\r
-     * ( also fixed followup: getTextRuns() returns no text )\r
-     */\r
-    public void test43781 () throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "43781.ppt"));\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        assertTrue("No Exceptions while reading file", true);\r
-\r
-        Slide slide = ppt.getSlides()[0];\r
-        TextRun[] tr1 = slide.getTextRuns();\r
-\r
-        ArrayList lst = new ArrayList();\r
-        Shape[] shape = slide.getShapes();\r
-        for (int i = 0; i < shape.length; i++) {\r
-            if( shape[i] instanceof TextShape){\r
-                TextRun textRun = ((TextShape)shape[i]).getTextRun();\r
-                if(textRun != null) lst.add(textRun);\r
-            }\r
-\r
-        }\r
-        TextRun[] tr2 = new TextRun[lst.size()];\r
-        lst.toArray(tr2);\r
-\r
-        assertEquals(tr1.length, tr2.length);\r
-        for (int i = 0; i < tr1.length; i++) {\r
-            assertEquals(tr1[i].getText(), tr2[i].getText());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Bug 44296: HSLF Not Extracting Slide Background Image\r
-     */\r
-    public void test44296  () throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "44296.ppt"));\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        Slide slide = ppt.getSlides()[0];\r
-\r
-        Background b = slide.getBackground();\r
-        Fill f = b.getFill();\r
-        assertEquals(Fill.FILL_PICTURE, f.getFillType());\r
-\r
-        PictureData pict = f.getPictureData();\r
-        assertNotNull(pict);\r
-        assertEquals(Picture.JPEG, pict.getType());\r
-    }\r
-\r
-    /**\r
-     * Bug 44770: java.lang.RuntimeException: Couldn't instantiate the class for type with id 1036 on class class org.apache.poi.hslf.record.PPDrawing\r
-     */\r
-    public void test44770() throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "44770.ppt"));\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        assertTrue("No Exceptions while reading file", true);\r
-    }\r
-\r
-    /**\r
-     * Bug 41071: Will not extract text from Powerpoint TextBoxes\r
-     */\r
-    public void test41071() throws Exception {\r
-        FileInputStream is = new FileInputStream(new File(cwd, "41071.ppt"));\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        Slide slide = ppt.getSlides()[0];\r
-        Shape[] sh = slide.getShapes();\r
-        assertEquals(1, sh.length);\r
-        assertTrue(sh[0] instanceof TextShape);\r
-        TextShape tx = (TextShape)sh[0];\r
-        assertEquals("Fundera, planera och involvera.", tx.getTextRun().getText());\r
-\r
-        TextRun[] run = slide.getTextRuns();\r
-        assertEquals(1, run.length);\r
-        assertEquals("Fundera, planera och involvera.", run[0].getText());\r
-    }\r
-    \r
-    /**\r
-     * PowerPoint 95 files should throw a more helpful exception\r
-     * @throws Exception\r
-     */\r
-    public void test41711() throws Exception {\r
-       // New file is fine\r
-        FileInputStream is = new FileInputStream(new File(cwd, "SampleShow.ppt"));\r
-        SlideShow ppt = new SlideShow(is);\r
-        \r
-        // PowerPoint 95 gives an old format exception\r
-        is = new FileInputStream(new File(cwd, "PPT95.ppt"));\r
-        try {\r
-               new SlideShow(is);\r
-               fail("OldPowerPointFormatException should've been thrown");\r
-        } catch(OldPowerPointFormatException e) {\r
-               // Good\r
-        }\r
-    }\r
-}\r
+/* ====================================================================
+   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.hslf.usermodel;
+
+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.Shape;
+
+import java.io.*;
+import java.util.HashSet;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.awt.*;
+
+/**
+ * Testcases for bugs entered in bugzilla
+ * the Test name contains the bugzilla bug id
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestBugs extends TestCase {
+    protected String cwd = System.getProperty("HSLF.testdata.path");
+
+    /**
+     * Bug 41384: Array index wrong in record creation
+     */
+    public void test41384() throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "41384.ppt"));
+        HSLFSlideShow hslf = new HSLFSlideShow(is);
+        is.close();
+
+        SlideShow ppt = new SlideShow(hslf);
+        assertTrue("No Exceptions while reading file", true);
+
+        assertEquals(1, ppt.getSlides().length);
+
+        PictureData[] pict = ppt.getPictureData();
+        assertEquals(2, pict.length);
+        assertEquals(Picture.JPEG, pict[0].getType());
+        assertEquals(Picture.JPEG, pict[1].getType());
+    }
+
+    /**
+     * First fix from Bug 42474: NPE in RichTextRun.isBold()
+     * when the RichTextRun comes from a Notes model object
+     */
+    public void test42474_1() throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "42474-1.ppt"));
+        HSLFSlideShow hslf = new HSLFSlideShow(is);
+        is.close();
+
+        SlideShow ppt = new SlideShow(hslf);
+        assertTrue("No Exceptions while reading file", true);
+        assertEquals(2, ppt.getSlides().length);
+
+        TextRun txrun;
+        Notes notes;
+
+        notes = ppt.getSlides()[0].getNotesSheet();
+        assertNotNull(notes);
+        txrun = notes.getTextRuns()[0];
+        assertEquals("Notes-1", txrun.getRawText());
+        assertEquals(false, txrun.getRichTextRuns()[0].isBold());
+
+        //notes for the second slide are in bold
+        notes = ppt.getSlides()[1].getNotesSheet();
+        assertNotNull(notes);
+        txrun = notes.getTextRuns()[0];
+        assertEquals("Notes-2", txrun.getRawText());
+        assertEquals(true, txrun.getRichTextRuns()[0].isBold());
+
+    }
+
+    /**
+     * Second fix from Bug 42474: Incorrect matching of notes to slides
+     */
+    public void test42474_2() throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "42474-2.ppt"));
+        HSLFSlideShow hslf = new HSLFSlideShow(is);
+        is.close();
+
+        SlideShow ppt = new SlideShow(hslf);
+
+        //map slide number and starting phrase of its notes
+        HashMap notesMap = new HashMap();
+        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");
+        notesMap.put(new Integer(7), "Although multiply and square root are easier");
+        notesMap.put(new Integer(8), "The bus Z is split into Z_H and Z_L");
+
+        Slide[] slide = ppt.getSlides();
+        for (int i = 0; i < slide.length; i++) {
+            Integer slideNumber = new Integer(slide[i].getSlideNumber());
+            Notes notes = slide[i].getNotesSheet();
+            if (notesMap.containsKey(slideNumber)){
+                assertNotNull(notes);
+                String text = notes.getTextRuns()[0].getRawText();
+                String startingPhrase = (String)notesMap.get(slideNumber);
+                assertTrue("Notes for slide " + slideNumber + " must start with " +
+                        startingPhrase , text.startsWith(startingPhrase));
+            }
+        }
+    }
+
+    /**
+     * Bug 42485: All TextBoxes inside ShapeGroups have null TextRuns
+     */
+    public void test42485 () throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "42485.ppt"));
+        HSLFSlideShow hslf = new HSLFSlideShow(is);
+        is.close();
+
+        SlideShow ppt = new SlideShow(hslf);
+        Shape[] shape = ppt.getSlides()[0].getShapes();
+        for (int i = 0; i < shape.length; i++) {
+            if(shape[i] instanceof ShapeGroup){
+                ShapeGroup  group = (ShapeGroup)shape[i];
+                Shape[] sh = group.getShapes();
+                for (int j = 0; j < sh.length; j++) {
+                    if( sh[j] instanceof TextBox){
+                        TextBox txt = (TextBox)sh[j];
+                        assertNotNull(txt.getTextRun());
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Bug 42484: NullPointerException from ShapeGroup.getAnchor()
+     */
+    public void test42484 () throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "42485.ppt")); //test file is the same as for bug 42485
+        HSLFSlideShow hslf = new HSLFSlideShow(is);
+        is.close();
+
+        SlideShow ppt = new SlideShow(hslf);
+        Shape[] shape = ppt.getSlides()[0].getShapes();
+        for (int i = 0; i < shape.length; i++) {
+            if(shape[i] instanceof ShapeGroup){
+                ShapeGroup  group = (ShapeGroup)shape[i];
+                assertNotNull(group.getAnchor());
+                Shape[] sh = group.getShapes();
+                for (int j = 0; j < sh.length; j++) {
+                    assertNotNull(sh[j].getAnchor());
+                }
+            }
+        }
+        assertTrue("No Exceptions while reading file", true);
+    }
+
+    /**
+     * Bug 41381: Exception from Slide.getMasterSheet() on a seemingly valid PPT file
+     */
+    public void test41381() throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "alterman_security.ppt"));
+        HSLFSlideShow hslf = new HSLFSlideShow(is);
+        is.close();
+
+        SlideShow ppt = new SlideShow(hslf);
+        assertTrue("No Exceptions while reading file", true);
+
+        assertEquals(1, ppt.getSlidesMasters().length);
+        assertEquals(1, ppt.getTitleMasters().length);
+        Slide[] slide = ppt.getSlides();
+        for (int i = 0; i < slide.length; i++) {
+            MasterSheet master = slide[i].getMasterSheet();
+            if (i == 0) assertTrue(master instanceof TitleMaster); //the first slide follows TitleMaster
+            else assertTrue(master instanceof SlideMaster);
+        }
+    }
+
+    /**
+     * Bug 42486:  Failure parsing a seemingly valid PPT
+     */
+    public void test42486 () throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "42486.ppt"));
+        HSLFSlideShow hslf = new HSLFSlideShow(is);
+        is.close();
+
+        SlideShow ppt = new SlideShow(hslf);
+        Slide[] slide = ppt.getSlides();
+        for (int i = 0; i < slide.length; i++) {
+            Shape[] shape = slide[i].getShapes();
+        }
+        assertTrue("No Exceptions while reading file", true);
+
+    }
+
+    /**
+     * Bug 42524:  NPE in Shape.getShapeType()
+     */
+    public void test42524 () throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "42486.ppt")); //test file is the same as for Bug 42486
+        HSLFSlideShow hslf = new HSLFSlideShow(is);
+        is.close();
+
+        SlideShow ppt = new SlideShow(hslf);
+        //walk down the tree and see if there were no errors while reading
+        Slide[] slide = ppt.getSlides();
+        for (int i = 0; i < slide.length; i++) {
+            Shape[] shape = slide[i].getShapes();
+            for (int j = 0; j < shape.length; j++) {
+                assertNotNull(shape[j].getShapeName());
+                if (shape[j] instanceof ShapeGroup){
+                    ShapeGroup group = (ShapeGroup)shape[j];
+                    Shape[] comps = group.getShapes();
+                    for (int k = 0; k < comps.length; k++) {
+                        assertNotNull(comps[k].getShapeName());
+                   }
+                }
+            }
+
+        }
+        assertTrue("No Exceptions while reading file", true);
+
+    }
+
+    /**
+     * Bug 42520:  NPE in Picture.getPictureData()
+     */
+    public void test42520 () throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "42520.ppt")); //test file is the same as for Bug 42486
+        HSLFSlideShow hslf = new HSLFSlideShow(is);
+        is.close();
+
+        SlideShow ppt = new SlideShow(hslf);
+
+        //test case from the bug report
+        ShapeGroup shapeGroup = (ShapeGroup)ppt.getSlides()[11].getShapes()[10];
+        Picture picture = (Picture)shapeGroup.getShapes()[0];
+        picture.getPictureData();
+
+        //walk down the tree and see if there were no errors while reading
+        Slide[] slide = ppt.getSlides();
+        for (int i = 0; i < slide.length; i++) {
+            Shape[] shape = slide[i].getShapes();
+            for (int j = 0; j < shape.length; j++) {
+              if (shape[j] instanceof ShapeGroup){
+                    ShapeGroup group = (ShapeGroup)shape[j];
+                    Shape[] comps = group.getShapes();
+                    for (int k = 0; k < comps.length; k++) {
+                        Shape comp = comps[k];
+                        if (comp instanceof Picture){
+                            PictureData pict = ((Picture)comp).getPictureData();
+                        }
+                    }
+                }
+            }
+
+        }
+        assertTrue("No Exceptions while reading file", true);
+
+    }
+
+    /**
+     * Bug 38256:  RuntimeException: Couldn't instantiate the class for type with id 0.
+     * ( also fixed followup: getTextRuns() returns no text )
+     */
+    public void test38256 () throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "38256.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        assertTrue("No Exceptions while reading file", true);
+
+        Slide[] slide = ppt.getSlides();
+        assertEquals(1, slide.length);
+        TextRun[] runs = slide[0].getTextRuns();
+        assertEquals(4, runs.length);
+
+        HashSet txt = new HashSet();
+        txt.add("\u201CHAPPY BIRTHDAY SCOTT\u201D");
+        txt.add("Have a HAPPY DAY");
+        txt.add("PS Nobody is allowed to hassle Scott TODAY\u2026");
+        txt.add("Drinks will be in the Boardroom at 5pm today to celebrate Scott\u2019s B\u2019Day\u2026  See you all there!");
+
+        for (int i = 0; i < runs.length; i++) {
+            String text = runs[i].getRawText();
+            assertTrue(text, txt.contains(text));
+        }
+
+    }
+
+    /**
+     * Bug 38256:  RuntimeException: Couldn't instantiate the class for type with id 0.
+     * ( also fixed followup: getTextRuns() returns no text )
+     */
+    public void test43781 () throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "43781.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        assertTrue("No Exceptions while reading file", true);
+
+        Slide slide = ppt.getSlides()[0];
+        TextRun[] tr1 = slide.getTextRuns();
+
+        ArrayList lst = new ArrayList();
+        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);
+            }
+
+        }
+        TextRun[] tr2 = new TextRun[lst.size()];
+        lst.toArray(tr2);
+
+        assertEquals(tr1.length, tr2.length);
+        for (int i = 0; i < tr1.length; i++) {
+            assertEquals(tr1[i].getText(), tr2[i].getText());
+        }
+    }
+
+    /**
+     * Bug 44296: HSLF Not Extracting Slide Background Image
+     */
+    public void test44296  () throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "44296.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        Slide slide = ppt.getSlides()[0];
+
+        Background b = slide.getBackground();
+        Fill f = b.getFill();
+        assertEquals(Fill.FILL_PICTURE, f.getFillType());
+
+        PictureData pict = f.getPictureData();
+        assertNotNull(pict);
+        assertEquals(Picture.JPEG, pict.getType());
+    }
+
+    /**
+     * Bug 44770: java.lang.RuntimeException: Couldn't instantiate the class for type with id 1036 on class class org.apache.poi.hslf.record.PPDrawing
+     */
+    public void test44770() throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "44770.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        assertTrue("No Exceptions while reading file", true);
+    }
+
+    /**
+     * Bug 41071: Will not extract text from Powerpoint TextBoxes
+     */
+    public void test41071() throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "41071.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        Slide slide = ppt.getSlides()[0];
+        Shape[] sh = slide.getShapes();
+        assertEquals(1, sh.length);
+        assertTrue(sh[0] instanceof TextShape);
+        TextShape tx = (TextShape)sh[0];
+        assertEquals("Fundera, planera och involvera.", tx.getTextRun().getText());
+
+        TextRun[] run = slide.getTextRuns();
+        assertEquals(1, run.length);
+        assertEquals("Fundera, planera och involvera.", run[0].getText());
+    }
+
+    /**
+     * PowerPoint 95 files should throw a more helpful exception
+     * @throws Exception
+     */
+    public void test41711() throws Exception {
+       // New file is fine
+        FileInputStream is = new FileInputStream(new File(cwd, "SampleShow.ppt"));
+        SlideShow ppt = new SlideShow(is);
+
+        // PowerPoint 95 gives an old format exception
+        is = new FileInputStream(new File(cwd, "PPT95.ppt"));
+        try {
+               new SlideShow(is);
+               fail("OldPowerPointFormatException should've been thrown");
+        } catch(OldPowerPointFormatException e) {
+               // Good
+        }
+    }
+}
index 1acc59f487bb3d371fbf18dc412c5ae897281c32..5b43a6ad5097dc561eb6592013ddfe3520e56e76 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.usermodel;
 
@@ -30,7 +27,7 @@ import org.apache.poi.hslf.model.*;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestCounts extends TestCase {
+public final class TestCounts extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
 
@@ -45,15 +42,15 @@ public class TestCounts extends TestCase {
                Slide[] slides = ss.getSlides();
                // Two sheets - master sheet is seperate
                assertEquals(2, slides.length);
-               
+
                // They are slides 1+2
                assertEquals(1, slides[0].getSlideNumber());
                assertEquals(2, slides[1].getSlideNumber());
-               
+
                // The ref IDs are 4 and 6
                assertEquals(4, slides[0]._getSheetRefId());
                assertEquals(6, slides[1]._getSheetRefId());
-               
+
                // These are slides 1+2 -> 256+257
                assertEquals(256, slides[0]._getSheetNumber());
                assertEquals(257, slides[1]._getSheetNumber());
@@ -65,14 +62,14 @@ public class TestCounts extends TestCase {
                // Note: there are also notes on the slide master
                //assertEquals(3, notes.length); // When we do slide masters
                assertEquals(2, notes.length);
-               
+
                // First is for master
                //assertEquals(-2147483648, notes[0]._getSheetNumber());  // When we do slide masters
-               
+
                // Next two are for the two slides
                assertEquals(256, notes[0]._getSheetNumber());
                assertEquals(257, notes[1]._getSheetNumber());
-               
+
                // They happen to go between the two slides in Ref terms
                assertEquals(5, notes[0]._getSheetRefId());
                assertEquals(7, notes[1]._getSheetRefId());
index c11515e24da2a0f8bab8b83a8681cfe0124bd663..78c29357277b8093b0980aac766696da4a939a0d 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.usermodel;
 
@@ -30,7 +27,7 @@ import org.apache.poi.hslf.record.*;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestMostRecentRecords extends TestCase {
+public final class TestMostRecentRecords extends TestCase {
        // HSLFSlideShow primed on the test data
        private HSLFSlideShow hss;
        // SlideShow primed on the test data
index fde1da57ae4cff6cafd4888a2c0a14a5c5944f74..56638e2e987508ad02ddae0e43a12af1924831f5 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.usermodel;
 
@@ -30,7 +27,7 @@ import org.apache.poi.hslf.model.*;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestNotesText extends TestCase {
+public final class TestNotesText extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
 
index 2944a74664f4d3ab9ef5000eab30811dfc882e9e..24189ad2c8551ae663d7d561ddd38dc1af249bbb 100644 (file)
@@ -30,7 +30,7 @@ import java.util.Arrays;
  *
  * @author Yegor Kozlov
  */
-public class TestPictures extends TestCase{
+public final class TestPictures extends TestCase{
 
     protected File cwd;
 
@@ -258,10 +258,10 @@ public class TestPictures extends TestCase{
 
         Slide slide = ppt.createSlide();
         File img = new File(cwd, "sci_cec.dib");
-        
+
         // Check we can read the test DIB image
         assertTrue(img.exists());
-        
+
         // Add the image
         int idx = ppt.addPicture(img, Picture.DIB);
         Picture pict = new Picture(idx);
@@ -375,7 +375,7 @@ public class TestPictures extends TestCase{
     }
 
        /**
-        * Test that on a party corrupt powerpoint document, which has 
+        * Test that on a party corrupt powerpoint document, which has
         *  crazy pictures of type 0, we do our best.
         */
        public void testZeroPictureType() throws Exception {
@@ -393,21 +393,21 @@ public class TestPictures extends TestCase{
         PictureData[] pictures = ppt.getPictureData();
         assertEquals(12, slides.length);
         assertEquals(2, pictures.length);
-        
+
                Picture pict;
                PictureData pdata;
-               
+
         pict = (Picture)slides[0].getShapes()[1]; // 2nd object on 1st slide
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
         assertEquals(Picture.WMF, pdata.getType());
-               
+
         pict = (Picture)slides[0].getShapes()[2]; // 3rd object on 1st slide
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
         assertEquals(Picture.WMF, pdata.getType());
        }
-       
+
        public void testZeroPictureLength() throws Exception {
                HSLFSlideShow hslf = new HSLFSlideShow(new File(cwd, "PictureLengthZero.ppt").getPath());
 
@@ -416,22 +416,22 @@ public class TestPictures extends TestCase{
                // Both are real pictures, both WMF
                assertEquals(Picture.WMF, hslf.getPictures()[0].getType());
                assertEquals(Picture.WMF, hslf.getPictures()[1].getType());
-               
+
                // Now test what happens when we use the SlideShow interface
                SlideShow ppt = new SlideShow(hslf);
         Slide[] slides = ppt.getSlides();
         PictureData[] pictures = ppt.getPictureData();
         assertEquals(27, slides.length);
         assertEquals(2, pictures.length);
-        
+
                Picture pict;
                PictureData pdata;
-               
+
         pict = (Picture)slides[6].getShapes()[13];
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
         assertEquals(Picture.WMF, pdata.getType());
-               
+
         pict = (Picture)slides[7].getShapes()[13];
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
index e039781cc8968328cc2e4aebc5035e94b935f728..d8437d80d2ca45251589e8e5a6f40aca9a724f07 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.usermodel;
 
@@ -33,33 +30,33 @@ import org.apache.poi.hslf.model.*;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestReOrderingSlides extends TestCase {
+public final class TestReOrderingSlides extends TestCase {
        // A SlideShow with one slide
        private HSLFSlideShow hss_one;
        private SlideShow ss_one;
-       
+
        // A SlideShow with two slides
        private HSLFSlideShow hss_two;
        private SlideShow ss_two;
-       
+
        // A SlideShow with three slides
        private HSLFSlideShow hss_three;
        private SlideShow ss_three;
-       
+
        /**
         * Create/open the slideshows
         */
        public void setUp() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
-               
+
                String filename = dirname + "/Single_Coloured_Page.ppt";
                hss_one = new HSLFSlideShow(filename);
                ss_one = new SlideShow(hss_one);
-               
+
                filename = dirname + "/basic_test_ppt_file.ppt";
                hss_two = new HSLFSlideShow(filename);
                ss_two = new SlideShow(hss_two);
-               
+
                filename = dirname + "/incorrect_slide_order.ppt";
                hss_three = new HSLFSlideShow(filename);
                ss_three = new SlideShow(hss_three);
@@ -72,33 +69,33 @@ public class TestReOrderingSlides extends TestCase {
                // Has one slide
                assertEquals(1, ss_one.getSlides().length);
                Slide s1 = ss_one.getSlides()[0];
-               
+
                // Check slide 1 is as expected
                assertEquals(256, s1._getSheetNumber());
                assertEquals(3, s1._getSheetRefId());
                assertEquals(1, s1.getSlideNumber());
-               
+
                // Now move it to one
                ss_one.reorderSlide(1, 1);
-                               
+
                // Write out, and read back in
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                hss_one.write(baos);
                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-               
+
                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
                SlideShow ss_read = new SlideShow(hss_read);
-               
+
                // Check it still has 1 slide
                assertEquals(1, ss_read.getSlides().length);
-               
+
                // And check it's as expected
                s1 = ss_read.getSlides()[0];
                assertEquals(256, s1._getSheetNumber());
                assertEquals(3, s1._getSheetRefId());
                assertEquals(1, s1.getSlideNumber());
        }
-       
+
        /**
         * Test doing a dummy re-order on a slideshow with
         *  two slides in it
@@ -108,7 +105,7 @@ public class TestReOrderingSlides extends TestCase {
                assertEquals(2, ss_two.getSlides().length);
                Slide s1 = ss_two.getSlides()[0];
                Slide s2 = ss_two.getSlides()[1];
-               
+
                // Check slide 1 is as expected
                assertEquals(256, s1._getSheetNumber());
                assertEquals(4, s1._getSheetRefId()); // master has notes
@@ -117,21 +114,21 @@ public class TestReOrderingSlides extends TestCase {
                assertEquals(257, s2._getSheetNumber());
                assertEquals(6, s2._getSheetRefId()); // master and 1 have notes
                assertEquals(2, s2.getSlideNumber());
-               
+
                // Don't swap them around
                ss_two.reorderSlide(2, 2);
-               
+
                // Write out, and read back in
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                hss_two.write(baos);
                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-               
+
                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
                SlideShow ss_read = new SlideShow(hss_read);
-               
+
                // Check it still has 2 slides
                assertEquals(2, ss_read.getSlides().length);
-               
+
                // And check it's as expected
                s1 = ss_read.getSlides()[0];
                s2 = ss_read.getSlides()[1];
@@ -142,7 +139,7 @@ public class TestReOrderingSlides extends TestCase {
                assertEquals(6, s2._getSheetRefId());
                assertEquals(2, s2.getSlideNumber());
        }
-       
+
        /**
         * Test re-ordering slides in a slideshow with 2 slides on it
         */
@@ -151,7 +148,7 @@ public class TestReOrderingSlides extends TestCase {
                assertEquals(2, ss_two.getSlides().length);
                Slide s1 = ss_two.getSlides()[0];
                Slide s2 = ss_two.getSlides()[1];
-               
+
                // Check slide 1 is as expected
                assertEquals(256, s1._getSheetNumber());
                assertEquals(4, s1._getSheetRefId()); // master has notes
@@ -160,21 +157,21 @@ public class TestReOrderingSlides extends TestCase {
                assertEquals(257, s2._getSheetNumber());
                assertEquals(6, s2._getSheetRefId()); // master and 1 have notes
                assertEquals(2, s2.getSlideNumber());
-               
+
                // Swap them around
                ss_two.reorderSlide(2, 1);
-               
+
                // Write out, and read back in
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                hss_two.write(baos);
                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-               
+
                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
                SlideShow ss_read = new SlideShow(hss_read);
-               
+
                // Check it still has 2 slides
                assertEquals(2, ss_read.getSlides().length);
-               
+
                // And check it's as expected
                s1 = ss_read.getSlides()[0];
                s2 = ss_read.getSlides()[1];
@@ -185,7 +182,7 @@ public class TestReOrderingSlides extends TestCase {
                assertEquals(4, s2._getSheetRefId());
                assertEquals(2, s2.getSlideNumber());
        }
-       
+
        /**
         * Test doing a dummy re-order on a slideshow with
         *  three slides in it
@@ -196,7 +193,7 @@ public class TestReOrderingSlides extends TestCase {
                Slide s1 = ss_three.getSlides()[0];
                Slide s2 = ss_three.getSlides()[1];
                Slide s3 = ss_three.getSlides()[2];
-               
+
                // Check slide 1 is as expected
                assertEquals(256, s1._getSheetNumber());
                assertEquals(3, s1._getSheetRefId()); // no notes on master
@@ -209,26 +206,26 @@ public class TestReOrderingSlides extends TestCase {
                assertEquals(257, s3._getSheetNumber());
                assertEquals(4, s3._getSheetRefId()); // no notes on slide
                assertEquals(3, s3.getSlideNumber());
-               
+
                // Don't swap them around
                ss_three.reorderSlide(2, 2);
-               
+
                // Write out, and read back in
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                hss_three.write(baos);
                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-               
+
                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
                SlideShow ss_read = new SlideShow(hss_read);
-               
+
                // Check it still has 3 slides
                assertEquals(3, ss_read.getSlides().length);
-               
+
                // And check it's as expected
                s1 = ss_read.getSlides()[0];
                s2 = ss_read.getSlides()[1];
                s3 = ss_read.getSlides()[2];
-               
+
                assertEquals(256, s1._getSheetNumber());
                assertEquals(3, s1._getSheetRefId());
                assertEquals(1, s1.getSlideNumber());
@@ -239,7 +236,7 @@ public class TestReOrderingSlides extends TestCase {
                assertEquals(4, s3._getSheetRefId());
                assertEquals(3, s3.getSlideNumber());
        }
-       
+
        /**
         * Test re-ordering slides in a slideshow with 3 slides on it
         */
@@ -249,7 +246,7 @@ public class TestReOrderingSlides extends TestCase {
                Slide s1 = ss_three.getSlides()[0];
                Slide s2 = ss_three.getSlides()[1];
                Slide s3 = ss_three.getSlides()[2];
-               
+
                // Check slide 1 is as expected
                assertEquals(256, s1._getSheetNumber());
                assertEquals(3, s1._getSheetRefId()); // no notes on master
@@ -262,22 +259,22 @@ public class TestReOrderingSlides extends TestCase {
                assertEquals(257, s3._getSheetNumber());
                assertEquals(4, s3._getSheetRefId()); // no notes on slide
                assertEquals(3, s3.getSlideNumber());
-               
+
                // Put 3 in place of 1
                // (1 -> 2, 2 -> 3)
                ss_three.reorderSlide(3, 1);
-               
+
                // Write out, and read back in
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                hss_three.write(baos);
                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-               
+
                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
                SlideShow ss_read = new SlideShow(hss_read);
-               
+
                // Check it still has 3 slides
                assertEquals(3, ss_read.getSlides().length);
-               
+
                // And check it's as expected
                Slide _s1 = ss_read.getSlides()[0];
                Slide _s2 = ss_read.getSlides()[1];
index 4cb34ba476a7cafaa1f3f7e101906c63fe599956..c5f3063fe8e6a59e2cc611ebee1b63b127e39e34 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.usermodel;
 
@@ -29,13 +26,13 @@ import org.apache.poi.hslf.record.Record;
 import org.apache.poi.hslf.record.RecordContainer;
 
 /**
- * Tests that the record setup done by SlideShow 
+ * Tests that the record setup done by SlideShow
  *  has worked correctly
  * Note: most recent record stuff has its own test
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestRecordSetup extends TestCase {
+public final class TestRecordSetup extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
        private HSLFSlideShow hss;
index 5177977af1ee4742001ac46e66b789b859271c24..47d2461f55c56460d797a3dcb667260a327bdda2 100644 (file)
@@ -37,7 +37,7 @@ import org.apache.poi.hslf.record.SlideListWithText;
  * (model.TestTextRun tests the other functionality)
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestRichTextRun extends TestCase {
+public final class TestRichTextRun extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
        private SlideShow ssRichA;
index ae532dd0349afcf8fa4117696442c9f3293dafae..9c10f8b0369cde3cd6e2e6d72e241eb88e3944c9 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.usermodel;
 
@@ -30,7 +27,7 @@ import org.apache.poi.hslf.model.*;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestSheetText extends TestCase {
+public final class TestSheetText extends TestCase {
        // SlideShow primed on the test data
        private SlideShow ss;
 
@@ -59,7 +56,7 @@ public class TestSheetText extends TestCase {
                        assertEquals(expectText[i], slideTwo.getTextRuns()[i].getText());
                }
        }
-       
+
        /**
         * Check we can still get the text from a file where the
         *  TextProps don't have enough data.
@@ -70,14 +67,14 @@ public class TestSheetText extends TestCase {
                String filename = dirname + "/iisd_report.ppt";
                HSLFSlideShow hss = new HSLFSlideShow(filename);
                SlideShow sss = new SlideShow(hss);
-               
+
                // Should come out with 10 slides, no notes
                assertEquals(10, sss.getSlides().length);
                assertEquals(0, sss.getNotes().length);
-               
+
                // Check text on first slide
                Slide s = sss.getSlides()[0];
-               String exp = 
+               String exp =
                        "Realizing the Development Dividend:\n" +
                        "Community Capacity Building and CDM.\n" +
                        "Can they co-exist?\n\n" +
index 3d89d0272f4f7b15c53b56e9a8fd297aa8591760..7eab827f1c93e0608598bd46fbde38aa92f29830 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.usermodel;
 
@@ -30,7 +27,7 @@ import org.apache.poi.hslf.model.*;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestSlideOrdering extends TestCase {
+public final class TestSlideOrdering extends TestCase {
        // Simple slideshow, record order matches slide order
        private SlideShow ssA;
        // Complex slideshow, record order doesn't match slide order
@@ -38,11 +35,11 @@ public class TestSlideOrdering extends TestCase {
 
     public TestSlideOrdering() throws Exception {
                String dirname = System.getProperty("HSLF.testdata.path");
-               
+
                String filenameA = dirname + "/basic_test_ppt_file.ppt";
                HSLFSlideShow hssA = new HSLFSlideShow(filenameA);
                ssA = new SlideShow(hssA);
-               
+
                String filenameB = dirname + "/incorrect_slide_order.ppt";
                HSLFSlideShow hssB = new HSLFSlideShow(filenameB);
                ssB = new SlideShow(hssB);
@@ -53,15 +50,15 @@ public class TestSlideOrdering extends TestCase {
      */
     public void testSimpleCase() throws Exception {
        assertEquals(2, ssA.getSlides().length);
-       
+
        Slide s1 = ssA.getSlides()[0];
        Slide s2 = ssA.getSlides()[1];
-       
+
        String[] firstTRs = new String[] {
                        "This is a test title",
                        "This is the title on page 2"
        };
-       
+
        assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
        assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
     }
@@ -71,17 +68,17 @@ public class TestSlideOrdering extends TestCase {
      */
     public void testComplexCase() throws Exception {
        assertEquals(3, ssB.getSlides().length);
-       
+
        Slide s1 = ssB.getSlides()[0];
        Slide s2 = ssB.getSlides()[1];
        Slide s3 = ssB.getSlides()[2];
-       
+
        String[] firstTRs = new String[] {
                        "Slide 1",
                        "Slide 2",
                        "Slide 3"
        };
-       
+
        assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
        assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
        assertEquals(firstTRs[2], s3.getTextRuns()[0].getText());
index 95de38f8ba5d1ff3064a0c162339760e0548a922..eea37695c478702990f90add5febd7ef1981c948 100755 (executable)
@@ -1,63 +1,63 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hslf.usermodel;\r
-\r
-import org.apache.poi.hslf.*;\r
-import org.apache.poi.hslf.exceptions.HSLFException;\r
-import org.apache.poi.hslf.blip.*;\r
-import org.apache.poi.hslf.model.*;\r
-import junit.framework.TestCase;\r
-\r
-import java.io.*;\r
-import java.util.Arrays;\r
-\r
-/**\r
- * Test reading sound data from a ppt\r
- *\r
- * @author Yegor Kozlov\r
- */\r
-public class TestSoundData extends TestCase{\r
-\r
-    protected File cwd;\r
-\r
-    public void setUp() throws Exception {\r
-        cwd = new File(System.getProperty("HSLF.testdata.path"));\r
-    }\r
-\r
-    /**\r
-     * Read a reference sound file from disk and compare it from the data extracted from the slide show\r
-     */ \r
-    public void testSounds() throws Exception {\r
-        //read the reference sound file\r
-        File f = new File(cwd, "ringin.wav");\r
-        int length = (int)f.length();\r
-        byte[] ref_data = new byte[length];\r
-        FileInputStream is = new FileInputStream(f);\r
-        is.read(ref_data);\r
-        is.close();\r
-\r
-        is = new FileInputStream(new File(cwd, "sound.ppt"));\r
-        SlideShow ppt = new SlideShow(is);\r
-        is.close();\r
-\r
-        SoundData[] sound = ppt.getSoundData();\r
-        assertEquals("Expected 1 sound", 1, sound.length);\r
-\r
-        assertTrue(Arrays.equals(ref_data, sound[0].getData()));\r
-    }\r
-}\r
+/* ====================================================================
+   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.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.util.Arrays;
+
+/**
+ * Test reading sound data from a ppt
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestSoundData extends TestCase{
+
+    protected File cwd;
+
+    public void setUp() throws Exception {
+        cwd = new File(System.getProperty("HSLF.testdata.path"));
+    }
+
+    /**
+     * Read a reference sound file from disk and compare it from the data extracted from the slide show
+     */
+    public void testSounds() throws Exception {
+        //read the reference sound file
+        File f = new File(cwd, "ringin.wav");
+        int length = (int)f.length();
+        byte[] ref_data = new byte[length];
+        FileInputStream is = new FileInputStream(f);
+        is.read(ref_data);
+        is.close();
+
+        is = new FileInputStream(new File(cwd, "sound.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        SoundData[] sound = ppt.getSoundData();
+        assertEquals("Expected 1 sound", 1, sound.length);
+
+        assertTrue(Arrays.equals(ref_data, sound[0].getData()));
+    }
+}
index d2b0e20f4ccd3b7c9e2ce27519d208ae9527bcdd..46a7284691ac8531fc8388f7a72a9b5bca8d83ca 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,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.util;
 
@@ -31,26 +28,26 @@ import junit.framework.TestCase;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestSystemTimeUtils extends TestCase {
+public final class TestSystemTimeUtils extends TestCase {
        // From real files
-       private byte[] data_a = new byte[] { 
+       private byte[] data_a = new byte[] {
                0xD6-256, 07, 01, 00,
-               02, 00, 0x18, 00, 0x0A, 00, 0x1A, 00, 
+               02, 00, 0x18, 00, 0x0A, 00, 0x1A, 00,
                0x0F, 00, 0xCD-256, 00
        };
        private byte[] data_b = new byte[] {
                00, 00, 0xE1-256, 0x2E, 0x1C, 00, 00, 00,
-               01, 00, 00, 00, 0xD6-256, 0x07, 01, 00, 
+               01, 00, 00, 00, 0xD6-256, 0x07, 01, 00,
                02, 00, 0x18, 00, 0x15, 00, 0x19, 00, 03,
-               00, 0xD5-256, 02, 0x0A, 00, 00, 00, 
+               00, 0xD5-256, 02, 0x0A, 00, 00, 00,
                0x0A, 00, 00, 00
        };
-       
+
        private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
 
        public void testGetDateA() throws Exception {
                Date date = SystemTimeUtils.getDate(data_a);
-               
+
                // Is 2006-01-24 (2nd day of week) 10:26:15.205
                Date exp = sdf.parse("2006-01-24 10:26:15.205");
                assertEquals(exp.getTime(), date.getTime());
@@ -59,32 +56,32 @@ public class TestSystemTimeUtils extends TestCase {
 
        public void testGetDateB() throws Exception {
                Date date = SystemTimeUtils.getDate(data_b, 8+4);
-               
+
                // Is 2006-01-24 (2nd day of week) 21:25:03.725
                Date exp = sdf.parse("2006-01-24 21:25:03.725");
                assertEquals(exp.getTime(), date.getTime());
                assertEquals(exp, date);
        }
-       
+
        public void testWriteDateA() throws Exception {
                byte[] out_a = new byte[data_a.length];
                Date date = sdf.parse("2006-01-24 10:26:15.205");
                SystemTimeUtils.storeDate(date, out_a);
-               
+
                for(int i=0; i<out_a.length; i++) {
                        assertEquals(data_a[i], out_a[i]);
                }
        }
-       
+
        public void testWriteDateB() throws Exception {
                byte[] out_b = new byte[data_b.length];
                // Copy over start and end, ignoring the 16 byte date field in the middle
                System.arraycopy(data_b, 0, out_b, 0, 12);
                System.arraycopy(data_b, 12+16, out_b, 12+16, data_b.length-12-16);
-               
+
                Date date = sdf.parse("2006-01-24 21:25:03.725");
                SystemTimeUtils.storeDate(date, out_b, 12);
-               
+
                for(int i=0; i<out_b.length; i++) {
                        assertEquals(data_b[i], out_b[i]);
                }
index 8f5dd47773c55a60d1fd9ef22e53068f363849c3..fe9a370ab375e5ac01b7c9f2d12cfaed33d26d0e 100644 (file)
@@ -26,28 +26,28 @@ import junit.framework.TestCase;
 /**
  * Verifies that the Chunks class is actually setup properly and hasn't been changed in ways
  * that will break the library.
- * 
+ *
  * @author Travis Ferguson
  *
  */
-public class TestChunkData extends TestCase {
+public final class TestChunkData extends TestCase {
        private Chunks chunks = Chunks.getInstance(false);
-       
+
        public void testChunkCreate() {
                StringChunk chunk = new StringChunk(0x0200, false);
                TestCase.assertEquals("__substg1.0_0200001E", chunk.getEntryName());
-               
+
                /* test the lower and upper limits of the chunk ids */
                chunk = new StringChunk(0x0000, false);
                TestCase.assertEquals("__substg1.0_0000001E", chunk.getEntryName());
-               
+
                chunk = new StringChunk(0xFFFF, false);
                TestCase.assertEquals("__substg1.0_FFFF001E", chunk.getEntryName());
-               
+
                chunk = new StringChunk(0xFFFF, true);
                TestCase.assertEquals("__substg1.0_FFFF001F", chunk.getEntryName());
        }
-       
+
        public void testTextBodyChunk() {
                StringChunk chunk = new StringChunk(0x1000, false);
                TestCase.assertEquals(chunk.getEntryName(), chunks.textBodyChunk.getEntryName());
@@ -57,7 +57,7 @@ public class TestChunkData extends TestCase {
                StringChunk chunk = new StringChunk(0x0E04, false);
                TestCase.assertEquals(chunk.getEntryName(), chunks.displayToChunk.getEntryName());
        }
-       
+
 
        public void testDisplayCCChunk() {
                StringChunk chunk = new StringChunk(0x0E03, false);
@@ -68,10 +68,10 @@ public class TestChunkData extends TestCase {
                StringChunk chunk = new StringChunk(0x0E02, false);
                TestCase.assertEquals(chunk.getEntryName(), chunks.displayBCCChunk.getEntryName());
        }
-       
+
        public void testSubjectChunk() {
                Chunk chunk = new StringChunk(0x0037, false);
                TestCase.assertEquals(chunk.getEntryName(), chunks.subjectChunk.getEntryName());
        }
-       
+
 }
index 7e94405e083c80b57b0fc5ae029f747268d434ee..da160671882b66a46e40fffecbde36cf45cefbfa 100644 (file)
@@ -27,109 +27,109 @@ import junit.framework.TestCase;
 /**
  * Tests to verify that we can still work on the newer Outlook 3.0 files.
  */
-public class TestOutlook30FileRead extends TestCase {
+public final class TestOutlook30FileRead extends TestCase {
 private MAPIMessage mapiMessage;
-       
+
        /**
         * Initialize this test, load up the blank.msg mapi message.
-        * @throws Exception 
+        * @throws Exception
         */
        public TestOutlook30FileRead() throws IOException {
                String dirname = System.getProperty("HSMF.testdata.path");
                this.mapiMessage = new MAPIMessage(dirname + "/outlook_30_msg.msg");
        }
-       
+
        /**
         * Test to see if we can read the CC Chunk.
-        * @throws ChunkNotFoundException 
-        * 
+        * @throws ChunkNotFoundException
+        *
         */
        public void testReadDisplayCC() throws ChunkNotFoundException {
                String obtained = mapiMessage.getDisplayCC();
                String expected = "";
-               
+
                TestCase.assertEquals(obtained, expected);
        }
-       
+
        /**
         * Test to see if we can read the CC Chunk.
-        * @throws ChunkNotFoundException 
-        * 
+        * @throws ChunkNotFoundException
+        *
         */
        public void testReadDisplayTo() throws ChunkNotFoundException {
                String obtained = mapiMessage.getDisplayTo();
-               
+
                assertTrue(obtained.startsWith("Bohn, Shawn"));
        }
-       
+
        /**
         * Test to see if we can read the From Chunk.
-        * @throws ChunkNotFoundException 
-        * 
+        * @throws ChunkNotFoundException
+        *
         */
        public void testReadDisplayFrom() throws ChunkNotFoundException {
                String obtained = mapiMessage.getDisplayFrom();
                String expected = "Cramer, Nick";
-               
+
                TestCase.assertEquals(obtained, expected);
        }
-       
+
        /**
         * Test to see if we can read the CC Chunk.
-        * @throws ChunkNotFoundException 
-        * 
+        * @throws ChunkNotFoundException
+        *
         */
        public void testReadDisplayBCC() throws ChunkNotFoundException {
                String obtained = mapiMessage.getDisplayBCC();
                String expected = "";
-               
+
                TestCase.assertEquals(obtained, expected);
        }
-       
-       
-       /** 
+
+
+       /**
         * Check if we can read the body of the blank message, we expect "".
-        * 
+        *
         * @throws Exception
         */
        public void testReadBody() throws Exception {
                String obtained = mapiMessage.getTextBody();
                assertTrue(obtained.startsWith("I am shutting down"));
        }
-       
+
        /**
         * Check if we can read the subject line of the blank message, we expect ""
-        * 
+        *
         * @throws Exception
         */
        public void testReadSubject() throws Exception {
                String obtained = mapiMessage.getSubject();
                String expected = "IN-SPIRE servers going down for a bit, back up around 8am";
-               
+
                TestCase.assertEquals(expected, obtained);
        }
 
        /**
         * Check if we can read the subject line of the blank message, we expect ""
-        * 
+        *
         * @throws Exception
         */
        public void testReadConversationTopic() throws Exception {
                String obtained = mapiMessage.getConversationTopic();
                TestCase.assertEquals("IN-SPIRE servers going down for a bit, back up around 8am", obtained);
        }
-       
+
 
        /**
         * Check if we can read the subject line of the blank message, we expect ""
-        * 
+        *
         * @throws Exception
         */
        public void testReadMessageClass() throws Exception {
                String obtained = mapiMessage.getMessageClass();
                TestCase.assertEquals("IPM.Note", obtained);
        }
-       
-       
-       
+
+
+
 }
index 925685218d5d98662fab0487a384fd277efaf472..2d822bb10ccf57f83b56c83934548789bba2ab28 100644 (file)
@@ -27,115 +27,115 @@ import junit.framework.TestCase;
 /**
  * Tests to verify that we can read a simple msg file, that is in plain/text format with no attachments
  * or extra recipents.
- * 
+ *
  * @author Travis Ferguson
  */
-public class TestSimpleFileRead extends TestCase {
+public final class TestSimpleFileRead extends TestCase {
 private MAPIMessage mapiMessage;
-       
+
        /**
         * Initialize this test, load up the blank.msg mapi message.
-        * @throws Exception 
+        * @throws Exception
         */
        public TestSimpleFileRead() throws IOException {
                String dirname = System.getProperty("HSMF.testdata.path");
                this.mapiMessage = new MAPIMessage(dirname + "/simple_test_msg.msg");
        }
-       
+
        /**
         * Test to see if we can read the CC Chunk.
-        * @throws ChunkNotFoundException 
-        * 
+        * @throws ChunkNotFoundException
+        *
         */
        public void testReadDisplayCC() throws ChunkNotFoundException {
                String obtained = mapiMessage.getDisplayCC();
                String expected = "";
-               
+
                TestCase.assertEquals(obtained, expected);
        }
-       
+
        /**
         * Test to see if we can read the CC Chunk.
-        * @throws ChunkNotFoundException 
-        * 
+        * @throws ChunkNotFoundException
+        *
         */
        public void testReadDisplayTo() throws ChunkNotFoundException {
                String obtained = mapiMessage.getDisplayTo();
                String expected = "travis@overwrittenstack.com";
-               
+
                TestCase.assertEquals(obtained, expected);
        }
-       
+
        /**
         * Test to see if we can read the From Chunk.
-        * @throws ChunkNotFoundException 
-        * 
+        * @throws ChunkNotFoundException
+        *
         */
        public void testReadDisplayFrom() throws ChunkNotFoundException {
                String obtained = mapiMessage.getDisplayFrom();
                String expected = "Travis Ferguson";
-               
+
                TestCase.assertEquals(obtained, expected);
        }
-       
+
        /**
         * Test to see if we can read the CC Chunk.
-        * @throws ChunkNotFoundException 
-        * 
+        * @throws ChunkNotFoundException
+        *
         */
        public void testReadDisplayBCC() throws ChunkNotFoundException {
                String obtained = mapiMessage.getDisplayBCC();
                String expected = "";
-               
+
                TestCase.assertEquals(obtained, expected);
        }
-       
-       
-       /** 
+
+
+       /**
         * Check if we can read the body of the blank message, we expect "".
-        * 
+        *
         * @throws Exception
         */
        public void testReadBody() throws Exception {
                String obtained = mapiMessage.getTextBody();
                String expected = "This is a test message.";
-               
+
                TestCase.assertEquals(obtained, expected);
        }
-       
+
        /**
         * Check if we can read the subject line of the blank message, we expect ""
-        * 
+        *
         * @throws Exception
         */
        public void testReadSubject() throws Exception {
                String obtained = mapiMessage.getSubject();
                String expected = "test message";
-               
+
                TestCase.assertEquals(expected, obtained);
        }
 
        /**
         * Check if we can read the subject line of the blank message, we expect ""
-        * 
+        *
         * @throws Exception
         */
        public void testReadConversationTopic() throws Exception {
                String obtained = mapiMessage.getConversationTopic();
                TestCase.assertEquals("test message", obtained);
        }
-       
+
 
        /**
         * Check if we can read the subject line of the blank message, we expect ""
-        * 
+        *
         * @throws Exception
         */
        public void testReadMessageClass() throws Exception {
                String obtained = mapiMessage.getMessageClass();
                TestCase.assertEquals("IPM.Note", obtained);
        }
-       
-       
-       
+
+
+
 }
index 8baac01d37d6e707c032769c662d433aeaf6e90a..5e2a34f1ed2cc4fd27928c4055e6913a27b5b76b 100644 (file)
@@ -29,26 +29,26 @@ public final class TestHSSFChart extends TestCase {
 
        public void testSingleChart() {
                HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("WithChart.xls");
-               
+
                HSSFSheet s1 = wb.getSheetAt(0);
                HSSFSheet s2 = wb.getSheetAt(1);
                HSSFSheet s3 = wb.getSheetAt(2);
-               
+
                assertEquals(0, HSSFChart.getSheetCharts(s1).length);
                assertEquals(1, HSSFChart.getSheetCharts(s2).length);
                assertEquals(0, HSSFChart.getSheetCharts(s3).length);
-               
+
                HSSFChart[] charts;
-               
+
                // Check the chart on the 2nd sheet
                charts = HSSFChart.getSheetCharts(s2);
                assertEquals(1, charts.length);
-               
+
                assertEquals(2, charts[0].getSeries().length);
                assertEquals("1st Column", charts[0].getSeries()[0].getSeriesTitle());
                assertEquals("2nd Column", charts[0].getSeries()[1].getSeriesTitle());
                assertEquals(null, charts[0].getChartTitle());
-               
+
                // Check x, y, width, height
                assertEquals(0, charts[0].getChartX());
                assertEquals(0, charts[0].getChartY());
@@ -58,53 +58,53 @@ public final class TestHSSFChart extends TestCase {
 
        public void testTwoCharts() {
                HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("WithTwoCharts.xls");
-               
+
                HSSFSheet s1 = wb.getSheetAt(0);
                HSSFSheet s2 = wb.getSheetAt(1);
                HSSFSheet s3 = wb.getSheetAt(2);
-               
+
                assertEquals(0, HSSFChart.getSheetCharts(s1).length);
                assertEquals(1, HSSFChart.getSheetCharts(s2).length);
                assertEquals(1, HSSFChart.getSheetCharts(s3).length);
-               
+
                HSSFChart[] charts;
-               
+
                // Check the chart on the 2nd sheet
                charts = HSSFChart.getSheetCharts(s2);
                assertEquals(1, charts.length);
-               
+
                assertEquals(2, charts[0].getSeries().length);
                assertEquals("1st Column", charts[0].getSeries()[0].getSeriesTitle());
                assertEquals("2nd Column", charts[0].getSeries()[1].getSeriesTitle());
                assertEquals(null, charts[0].getChartTitle());
-               
+
                // And the third sheet
                charts = HSSFChart.getSheetCharts(s3);
                assertEquals(1, charts.length);
-               
+
                assertEquals(2, charts[0].getSeries().length);
                assertEquals("Squares", charts[0].getSeries()[0].getSeriesTitle());
                assertEquals("Base Numbers", charts[0].getSeries()[1].getSeriesTitle());
                assertEquals(null, charts[0].getChartTitle());
        }
-       
+
        public void testThreeCharts() {
                HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("WithThreeCharts.xls");
-               
+
                HSSFSheet s1 = wb.getSheetAt(0);
                HSSFSheet s2 = wb.getSheetAt(1);
                HSSFSheet s3 = wb.getSheetAt(2);
-               
+
                assertEquals(0, HSSFChart.getSheetCharts(s1).length);
                assertEquals(2, HSSFChart.getSheetCharts(s2).length);
                assertEquals(1, HSSFChart.getSheetCharts(s3).length);
-               
+
                HSSFChart[] charts;
-               
+
                // Check the charts on the 2nd sheet
                charts = HSSFChart.getSheetCharts(s2);
                assertEquals(2, charts.length);
-               
+
                assertEquals(2, charts[0].getSeries().length);
                assertEquals("1st Column", charts[0].getSeries()[0].getSeriesTitle());
                assertEquals("2nd Column", charts[0].getSeries()[1].getSeriesTitle());
@@ -113,15 +113,15 @@ public final class TestHSSFChart extends TestCase {
                assertEquals(SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC, charts[0].getSeries()[0].getValueType());
                assertEquals(SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC, charts[0].getSeries()[1].getValueType());
                assertEquals(null, charts[0].getChartTitle());
-               
+
                assertEquals(1, charts[1].getSeries().length);
                assertEquals(null, charts[1].getSeries()[0].getSeriesTitle());
                assertEquals("Pie Chart Title Thingy", charts[1].getChartTitle());
-               
+
                // And the third sheet
                charts = HSSFChart.getSheetCharts(s3);
                assertEquals(1, charts.length);
-               
+
                assertEquals(2, charts[0].getSeries().length);
                assertEquals("Squares", charts[0].getSeries()[0].getSeriesTitle());
                assertEquals("Base Numbers", charts[0].getSeries()[1].getSeriesTitle());
index 27c347bc72f6fa948abd7b4030c0014d7f533836..3b30c4b904fca8aad825af8236636917a3c3b3a4 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.hwpf;
 
 import junit.framework.*;
 
-public class AllTests
+public final class AllTests
   extends TestCase
 {
 
index 1a71d1c2998e463604c7fa64a64d4fccc4337c6a..c0dc9d41b54611e8cc083bf79f8ba919e016d132 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf;
 
 import java.io.FileInputStream;
@@ -27,7 +26,7 @@ import org.apache.poi.hwpf.model.*;
 import java.io.File;
 
 
-public class HWPFDocFixture
+public final class HWPFDocFixture
 {
   public byte[] _tableStream;
   public byte[] _mainStream;
index dcfa99aecd57deea3f0e90defb76c190f7d327ab..b750e52af81db1b927a93d995edee099f2937183 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf;
 
 import java.io.ByteArrayInputStream;
index bcf02a8a1da3c6b3f74ac686fc53f4e932bef3de..1adb68b809b5eb52a69a1e2d68bc7fdef4d1d2a6 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf;
 
 import java.io.ByteArrayOutputStream;
@@ -31,31 +30,31 @@ import junit.framework.TestCase;
  * Test picture support in HWPF
  * @author nick
  */
-public class TestHWPFPictures extends TestCase {
+public final class TestHWPFPictures extends TestCase {
        private String docAFile;
        private String docBFile;
        private String docCFile;
     private String docDFile;
-       
+
        private String imgAFile;
        private String imgBFile;
        private String imgCFile;
     private String imgDFile;
-       
+
        protected void setUp() throws Exception {
                String dirname = System.getProperty("HWPF.testdata.path");
-               
+
                docAFile = dirname + "/testPictures.doc";
                docBFile = dirname + "/two_images.doc";
                docCFile = dirname + "/vector_image.doc";
         docDFile = dirname + "/GaiaTest.doc";
-               
+
                imgAFile = dirname + "/simple_image.jpg";
                imgBFile = dirname + "/simple_image.png";
                imgCFile = dirname + "/vector_image.emf";
         imgDFile = dirname + "/GaiaTestImg.png";
        }
-       
+
        /**
         * Test just opening the files
         */
@@ -63,27 +62,27 @@ public class TestHWPFPictures extends TestCase {
                HWPFDocument docA = new HWPFDocument(new FileInputStream(docAFile));
                HWPFDocument docB = new HWPFDocument(new FileInputStream(docBFile));
        }
-       
+
        /**
         * Test that we have the right numbers of images in each file
         */
        public void testImageCount() throws Exception {
                HWPFDocument docA = new HWPFDocument(new FileInputStream(docAFile));
                HWPFDocument docB = new HWPFDocument(new FileInputStream(docBFile));
-               
+
                assertNotNull(docA.getPicturesTable());
                assertNotNull(docB.getPicturesTable());
-               
+
                PicturesTable picA = docA.getPicturesTable();
                PicturesTable picB = docB.getPicturesTable();
-               
+
                List picturesA = picA.getAllPictures();
                List picturesB = picB.getAllPictures();
-               
+
                assertEquals(7, picturesA.size());
                assertEquals(2, picturesB.size());
        }
-       
+
        /**
         * Test that we have the right images in at least one file
         */
@@ -91,26 +90,26 @@ public class TestHWPFPictures extends TestCase {
                HWPFDocument docB = new HWPFDocument(new FileInputStream(docBFile));
                PicturesTable picB = docB.getPicturesTable();
                List picturesB = picB.getAllPictures();
-               
+
                assertEquals(2, picturesB.size());
-               
+
                Picture pic1 = (Picture)picturesB.get(0);
                Picture pic2 = (Picture)picturesB.get(1);
-               
+
                assertNotNull(pic1);
                assertNotNull(pic2);
-               
+
                // Check the same
                byte[] pic1B = readFile(imgAFile);
                byte[] pic2B = readFile(imgBFile);
-               
+
                assertEquals(pic1B.length, pic1.getContent().length);
                assertEquals(pic2B.length, pic2.getContent().length);
 
                assertBytesSame(pic1B, pic1.getContent());
                assertBytesSame(pic2B, pic2.getContent());
        }
-       
+
        /**
         * Test that compressed image data is correctly returned.
         */
@@ -118,19 +117,19 @@ public class TestHWPFPictures extends TestCase {
                HWPFDocument docC = new HWPFDocument(new FileInputStream(docCFile));
                PicturesTable picC = docC.getPicturesTable();
                List picturesC = picC.getAllPictures();
-               
+
                assertEquals(1, picturesC.size());
-               
+
                Picture pic = (Picture)picturesC.get(0);
                assertNotNull(pic);
-               
+
                // Check the same
                byte[] picBytes = readFile(imgCFile);
-               
+
                assertEquals(picBytes.length, pic.getContent().length);
                assertBytesSame(picBytes, pic.getContent());
        }
-    
+
        /**
         * Pending the missing files being uploaded to
         *  bug #44937
@@ -139,30 +138,30 @@ public class TestHWPFPictures extends TestCase {
     {
         HWPFDocument docD = new HWPFDocument(new FileInputStream(docDFile));
         List allPictures = docD.getPicturesTable().getAllPictures();
-        
+
         assertEquals(1, allPictures.size());
-        
+
         Picture pic = (Picture) allPictures.get(0);
         assertNotNull(pic);
         byte[] picD = readFile(imgDFile);
-        
+
         assertEquals(picD.length, pic.getContent().length);
-        
+
         assertBytesSame(picD, pic.getContent());
     }
-       
+
        private void assertBytesSame(byte[] a, byte[] b) {
                assertEquals(a.length, b.length);
                for(int i=0; i<a.length; i++) {
                        assertEquals(a[i],b[i]);
                }
        }
-       
+
        private byte[] readFile(String file) throws Exception {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                FileInputStream fis = new FileInputStream(file);
                byte[] buffer = new byte[1024];
-               
+
                int read = 0;
                while(read > -1) {
                        read = fis.read(buffer);
@@ -170,7 +169,7 @@ public class TestHWPFPictures extends TestCase {
                                baos.write(buffer,0,read);
                        }
                }
-               
+
                return baos.toByteArray();
        }
 }
index af0faf96c9f417963102bc9dc548bec299d7c038..283cae027f8448b297acd5ca944dcda860a32d0a 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf;
 
 import java.io.FileInputStream;
@@ -28,9 +27,9 @@ import junit.framework.TestCase;
  * Test that we pull out the right bits of a file into
  *  the different ranges
  */
-public class TestHWPFRangeParts extends TestCase {
+public final class TestHWPFRangeParts extends TestCase {
        private static final char page_break = (char)12;
-       private static final String headerDef = 
+       private static final String headerDef =
                "\u0003\r\r" +
                "\u0004\r\r" +
                "\u0003\r\r" +
@@ -39,11 +38,11 @@ public class TestHWPFRangeParts extends TestCase {
        private static final String footerDef = "\r";
        private static final String endHeaderFooter = "\r\r";
 
-       
+
        private static final String a_page_1 =
                "This is a sample word document. It has two pages. It has a three column heading, and a three column footer\r" +
                "\r" +
-               "HEADING TEXT\r" + 
+               "HEADING TEXT\r" +
                "\r" +
                "More on page one\r" +
                "\r\r" +
@@ -52,15 +51,15 @@ public class TestHWPFRangeParts extends TestCase {
        private static final String a_page_2 =
                "This is page two. It also has a three column heading, and a three column footer.\r"
        ;
-       
+
        private static final String a_header =
                "First header column!\tMid header Right header!\r"
        ;
        private static final String a_footer =
                "Footer Left\tFooter Middle Footer Right\r"
        ;
-       
-       
+
+
        private static final String u_page_1 =
                "This is a fairly simple word document, over two pages, with headers and footers.\r" +
                "The trick with this one is that it contains some Unicode based strings in it.\r" +
@@ -76,7 +75,7 @@ public class TestHWPFRangeParts extends TestCase {
        private static final String u_page_2 =
                "This is page two. Les Pr\u00e9cieuses ridicules. The end.\r"
        ;
-       
+
        private static final String u_header =
                "\r\r" +
                "This is a simple header, with a \u20ac euro symbol in it.\r"
@@ -86,7 +85,7 @@ public class TestHWPFRangeParts extends TestCase {
                "The footer, with Moli\u00e8re, has Unicode in it.\r" +
                "\r\r\r\r"
        ;
-       
+
        /**
         * A document made up only of basic ASCII text
         */
@@ -95,21 +94,21 @@ public class TestHWPFRangeParts extends TestCase {
         * A document with some unicode in it too
         */
        private HWPFDocument docUnicode;
-       
+
        public void setUp() throws Exception {
                String dirname = System.getProperty("HWPF.testdata.path");
-               
+
                String filename = dirname + "/HeaderFooterUnicode.doc";
                docUnicode = new HWPFDocument(
                                new FileInputStream(filename)
                );
-               
+
                filename = dirname + "/ThreeColHeadFoot.doc";
                docAscii = new HWPFDocument(
                                new FileInputStream(filename)
                );
        }
-       
+
        public void testBasics() throws Exception {
                // First check the start and end bits
                assertEquals(
@@ -122,7 +121,7 @@ public class TestHWPFRangeParts extends TestCase {
                                a_page_2.length(),
                                docAscii._cpSplit.getMainDocumentEnd()
                );
-               
+
                assertEquals(
                                238,
                                docAscii._cpSplit.getFootnoteStart()
@@ -131,7 +130,7 @@ public class TestHWPFRangeParts extends TestCase {
                                238,
                                docAscii._cpSplit.getFootnoteEnd()
                );
-               
+
                assertEquals(
                                238,
                                docAscii._cpSplit.getHeaderStoryStart()
@@ -142,10 +141,10 @@ public class TestHWPFRangeParts extends TestCase {
                                docAscii._cpSplit.getHeaderStoryEnd()
                );
        }
-       
+
        public void testContents() throws Exception {
                Range r;
-               
+
                // Now check the real ranges
                r = docAscii.getRange();
                assertEquals(
@@ -154,32 +153,32 @@ public class TestHWPFRangeParts extends TestCase {
                                a_page_2,
                                r.text()
                );
-               
+
                r = docAscii.getHeaderStoryRange();
                assertEquals(
                                headerDef +
                                a_header +
                                footerDef +
-                               a_footer + 
+                               a_footer +
                                endHeaderFooter,
                                r.text()
                );
-               
+
                r = docAscii.getOverallRange();
                assertEquals(
                                a_page_1 +
                                page_break + "\r" +
-                               a_page_2 + 
+                               a_page_2 +
                                headerDef +
                                a_header +
                                footerDef +
-                               a_footer + 
+                               a_footer +
                                endHeaderFooter +
                                "\r",
                                r.text()
                );
        }
-       
+
        public void testBasicsUnicode() throws Exception {
                // First check the start and end bits
                assertEquals(
@@ -192,7 +191,7 @@ public class TestHWPFRangeParts extends TestCase {
                                u_page_2.length(),
                                docUnicode._cpSplit.getMainDocumentEnd()
                );
-               
+
                assertEquals(
                                408,
                                docUnicode._cpSplit.getFootnoteStart()
@@ -201,7 +200,7 @@ public class TestHWPFRangeParts extends TestCase {
                                408,
                                docUnicode._cpSplit.getFootnoteEnd()
                );
-               
+
                assertEquals(
                                408,
                                docUnicode._cpSplit.getHeaderStoryStart()
@@ -213,10 +212,10 @@ public class TestHWPFRangeParts extends TestCase {
                                docUnicode._cpSplit.getHeaderStoryEnd()
                );
        }
-       
+
        public void testContentsUnicode() throws Exception {
                Range r;
-               
+
                // Now check the real ranges
                r = docUnicode.getRange();
                assertEquals(
@@ -225,26 +224,26 @@ public class TestHWPFRangeParts extends TestCase {
                                u_page_2,
                                r.text()
                );
-               
+
                r = docUnicode.getHeaderStoryRange();
                assertEquals(
                                headerDef +
                                u_header +
                                footerDef +
-                               u_footer + 
+                               u_footer +
                                endHeaderFooter,
                                r.text()
                );
-               
+
                r = docUnicode.getOverallRange();
                assertEquals(
                                u_page_1 +
                                page_break + "\r" +
-                               u_page_2 + 
+                               u_page_2 +
                                headerDef +
                                u_header +
                                footerDef +
-                               u_footer + 
+                               u_footer +
                                endHeaderFooter +
                                "\r",
                                r.text()
index 786fc807dba3dd01da420e8455c9813192e5129e..685ce949bb86bd44df359d5a05ab7b0ec8b7c152 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hwpf.extractor;
 
 import java.io.FileInputStream;
@@ -31,7 +32,7 @@ import junit.framework.TestCase;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestDifferentRoutes extends TestCase {
+public final class TestDifferentRoutes extends TestCase {
        private String[] p_text = new String[] {
                        "This is a simple word document\r",
                        "\r",
@@ -48,40 +49,40 @@ public class TestDifferentRoutes extends TestCase {
                        "\r",
                        "It is otherwise very very boring.\r"
        };
-       
+
        private HWPFDocument doc;
-       
+
     protected void setUp() throws Exception {
                String dirname = System.getProperty("HWPF.testdata.path");
-               
+
                String filename = dirname + "/test2.doc";
                doc = new HWPFDocument(new FileInputStream(filename));
-    }                  
-    
+    }
+
     /**
      * Test model based extraction
      */
     public void testExtractFromModel() {
        Range r = doc.getRange();
-       
+
        String[] text = new String[r.numParagraphs()];
        for(int i=0; i < r.numParagraphs(); i++) {
                Paragraph p = r.getParagraph(i);
                text[i] = p.text();
        }
-       
+
        assertEquals(p_text.length, text.length);
        for(int i=0; i<p_text.length; i++) {
                assertEquals(p_text[i], text[i]);
        }
     }
-    
+
     /**
      * Test textPieces based extraction
      */
     public void testExtractFromTextPieces() throws Exception {
        StringBuffer textBuf = new StringBuffer();
-       
+
        Iterator textPieces = doc.getTextTable().getTextPieces().iterator();
        while (textPieces.hasNext()) {
                TextPiece piece = (TextPiece) textPieces.next();
@@ -93,7 +94,7 @@ public class TestDifferentRoutes extends TestCase {
                String text = new String(piece.getRawBytes(), encoding);
                textBuf.append(text);
        }
-       
+
        StringBuffer exp = new StringBuffer();
        for(int i=0; i<p_text.length; i++) {
                exp.append(p_text[i]);
index a1b78752f818d4807b5049d5c616f4bc306afb84..0eef5fc9c2b7afc376dcd121c466e7063354a797 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hwpf.extractor;
 
 import java.io.FileInputStream;
@@ -29,7 +30,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestWordExtractor extends TestCase {
+public final class TestWordExtractor extends TestCase {
        private String[] p_text1 = new String[] {
                        "This is a simple word document\r\n",
                        "\r\n",
@@ -47,63 +48,63 @@ public class TestWordExtractor extends TestCase {
                        "It is otherwise very very boring.\r\n"
        };
        private String p_text1_block = new String();
-               
+
        // Well behaved document
        private WordExtractor extractor;
        // Corrupted document - can't do paragraph based stuff
        private WordExtractor extractor2;
        // A word doc embeded in an excel file
        private String filename3;
-       
+
        // With header and footer
        private String filename4;
        // With unicode header and footer
        private String filename5;
-       
+
     protected void setUp() throws Exception {
                String dirname = System.getProperty("HWPF.testdata.path");
                String pdirname = System.getProperty("POIFS.testdata.path");
-               
+
                String filename = dirname + "/test2.doc";
                String filename2 = dirname + "/test.doc";
                filename3 = pdirname + "/excel_with_embeded.xls";
                filename4 = dirname + "/ThreeColHeadFoot.doc";
                filename5 = dirname + "/HeaderFooterUnicode.doc";
-               
+
                extractor = new WordExtractor(new FileInputStream(filename));
                extractor2 = new WordExtractor(new FileInputStream(filename2));
-               
+
                // Build splat'd out text version
                for(int i=0; i<p_text1.length; i++) {
                        p_text1_block += p_text1[i];
                }
-    }                  
-    
+    }
+
     /**
      * Test paragraph based extraction
      */
     public void testExtractFromParagraphs() {
        String[] text = extractor.getParagraphText();
-       
+
        assertEquals(p_text1.length, text.length);
        for(int i=0; i<p_text1.length; i++) {
                assertEquals(p_text1[i], text[i]);
        }
-       
+
        // On second one, should fall back
        assertEquals(1, extractor2.getParagraphText().length);
     }
-    
+
     /**
      * Test the paragraph -> flat extraction
      */
     public void testGetText() {
        assertEquals(p_text1_block, extractor.getText());
-       
+
        // On second one, should fall back to text piece
        assertEquals(extractor2.getTextFromPieces(), extractor2.getText());
     }
-    
+
     /**
      * Test textPieces based extraction
      */
@@ -111,8 +112,8 @@ public class TestWordExtractor extends TestCase {
        String text = extractor.getTextFromPieces();
        assertEquals(p_text1_block, text);
     }
-    
-    
+
+
     /**
      * Test that we can get data from two different
      *  embeded word documents
@@ -122,23 +123,23 @@ public class TestWordExtractor extends TestCase {
        POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename3));
        HWPFDocument doc;
        WordExtractor extractor3;
-       
+
        DirectoryNode dirA = (DirectoryNode)
                        fs.getRoot().getEntry("MBD0000A3B7");
        DirectoryNode dirB = (DirectoryNode)
                fs.getRoot().getEntry("MBD0000A3B2");
-       
+
        // Should have WordDocument and 1Table
        assertNotNull(dirA.getEntry("1Table"));
        assertNotNull(dirA.getEntry("WordDocument"));
-       
+
        assertNotNull(dirB.getEntry("1Table"));
        assertNotNull(dirB.getEntry("WordDocument"));
-       
+
        // Check each in turn
        doc = new HWPFDocument(dirA, fs);
        extractor3 = new WordExtractor(doc);
-               
+
        assertNotNull(extractor3.getText());
        assertTrue(extractor3.getText().length() > 20);
        assertEquals("I am a sample document\r\nNot much on me\r\nI am document 1\r\n",
@@ -146,42 +147,42 @@ public class TestWordExtractor extends TestCase {
        assertEquals("Sample Doc 1", extractor3.getSummaryInformation().getTitle());
        assertEquals("Sample Test", extractor3.getSummaryInformation().getSubject());
 
-       
+
        doc = new HWPFDocument(dirB, fs);
        extractor3 = new WordExtractor(doc);
-               
+
        assertNotNull(extractor3.getText());
        assertTrue(extractor3.getText().length() > 20);
-       assertEquals("I am another sample document\r\nNot much on me\r\nI am document 2\r\n", 
+       assertEquals("I am another sample document\r\nNot much on me\r\nI am document 2\r\n",
                        extractor3.getText());
        assertEquals("Sample Doc 2", extractor3.getSummaryInformation().getTitle());
        assertEquals("Another Sample Test", extractor3.getSummaryInformation().getSubject());
     }
-    
+
     public void testWithHeader() throws Exception {
        // Non-unicode
        HWPFDocument doc = new HWPFDocument(
                        new FileInputStream(filename4)
        );
        extractor = new WordExtractor(doc);
-       
+
        assertEquals(
                        "First header column!\tMid header Right header!\n",
                        extractor.getHeaderText()
        );
-       
+
        String text = extractor.getText();
        assertTrue(
                        text.indexOf("First header column!") > -1
        );
-       
-       
+
+
        // Unicode
        doc = new HWPFDocument(
                        new FileInputStream(filename5)
        );
        extractor = new WordExtractor(doc);
-       
+
        assertEquals(
                        "This is a simple header, with a \u20ac euro symbol in it.\n\n",
                        extractor.getHeaderText()
@@ -191,31 +192,31 @@ public class TestWordExtractor extends TestCase {
                        text.indexOf("This is a simple header") > -1
        );
     }
-    
+
     public void testWithFooter() throws Exception {
        // Non-unicode
        HWPFDocument doc = new HWPFDocument(
                        new FileInputStream(filename4)
        );
        extractor = new WordExtractor(doc);
-       
+
        assertEquals(
                        "Footer Left\tFooter Middle Footer Right\n",
                        extractor.getFooterText()
        );
-       
+
        String text = extractor.getText();
        assertTrue(
                        text.indexOf("Footer Left") > -1
        );
-       
-       
+
+
        // Unicode
        doc = new HWPFDocument(
                        new FileInputStream(filename5)
        );
        extractor = new WordExtractor(doc);
-       
+
        assertEquals(
                        "The footer, with Moli\u00e8re, has Unicode in it.\n",
                        extractor.getFooterText()
index b87f586d36258ec90b4fa693353062ca96f9280b..585c534ed942bc570705452b1f3e0e31a28d9b4a 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hwpf.extractor;
 
 import java.io.FileInputStream;
@@ -25,21 +26,21 @@ import junit.framework.TestCase;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestWordExtractorBugs extends TestCase {
+public final class TestWordExtractorBugs extends TestCase {
        private String dirname;
     protected void setUp() throws Exception {
                dirname = System.getProperty("HWPF.testdata.path");
     }
-    
+
     public void testProblemMetadata() throws Exception {
                String filename = dirname + "/ProblemExtracting.doc";
-               WordExtractor extractor = 
+               WordExtractor extractor =
                        new WordExtractor(new FileInputStream(filename));
-               
+
                // Check it gives text without error
                extractor.getText();
                extractor.getParagraphText();
                extractor.getTextFromPieces();
-    }                  
-    
+    }
+
 }
index d1f1451acd34a52794cc624ce09d0e1b97996024..d121666ae1906d33dd60b061761cefd933d61380 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.hwpf.model;
 
@@ -27,12 +25,12 @@ import junit.framework.*;
 import org.apache.poi.hwpf.*;
 import org.apache.poi.hwpf.model.io.*;
 
-public class TestCHPBinTable
+public final class TestCHPBinTable
   extends TestCase
 {
   private CHPBinTable _cHPBinTable = null;
   private HWPFDocFixture _hWPFDocFixture;
-  
+
   private TextPieceTable fakeTPT = new TextPieceTable();
 
   public TestCHPBinTable(String name)
index 1395b9887019e639b4ecf8f0e9c7f1199fe64ccc..c897944e5c70d318719f5e3fea658d2a1b940b9c 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf.model;
 
 import junit.framework.*;
@@ -24,7 +23,7 @@ import org.apache.poi.hwpf.*;
 import java.lang.reflect.*;
 import java.util.Arrays;
 
-public class TestDocumentProperties
+public final class TestDocumentProperties
   extends TestCase
 {
   private DocumentProperties _documentProperties = null;
index 31c99173de9ae3a87cefb2d433e4ccc8a36b70fd..5c848ff87a321cd6f92f00d2e4680e55aae1e5ce 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf.model;
 
 import junit.framework.*;
@@ -23,7 +22,7 @@ import org.apache.poi.hwpf.*;
 
 import java.lang.reflect.*;
 
-public class TestFileInformationBlock
+public final class TestFileInformationBlock
   extends TestCase
 {
   private FileInformationBlock _fileInformationBlock = null;
index 90296400086e1ed0c605449bf3a212a15604a813..73b4298431e4264ec2a4a8e45458e1868166fd75 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.hwpf.model;
 
@@ -23,7 +21,7 @@ import junit.framework.*;
 import org.apache.poi.hwpf.*;
 import org.apache.poi.hwpf.model.io.*;
 
-public class TestFontTable
+public final class TestFontTable
   extends TestCase
 {
   private FontTable _fontTable = null;
index c3fb63d374160156e6912e195b6c88fb2a8e0460..08cf5dc5fd7db4f04922ea18680b2a3a63aef8f6 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.hwpf.model;
 
 import org.apache.poi.hwpf.*;
 import org.apache.poi.hwpf.model.io.*;
 
 
-public class TestListTables
+public final class TestListTables
   extends HWPFTestCase
 {
 
index 446b5232a5a203fc358a4476db344a09860f84c2..008058b5cfd4e3fe8aa83319bfe6ee936e490ac5 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.hwpf.model;
 
@@ -26,7 +24,7 @@ import org.apache.poi.hwpf.model.io.*;
 import java.io.*;
 import java.util.*;
 
-public class TestPAPBinTable
+public final class TestPAPBinTable
   extends TestCase
 {
   private PAPBinTable _pAPBinTable = null;
index edaf88b999a38bbf9ed2170a3c37447b6bbd07b7..de585efba1819f326ac06e6a71884cb418cf3848 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.hwpf.model;
 
@@ -24,7 +22,7 @@ import org.apache.poi.hwpf.*;
 
 import org.apache.poi.util.LittleEndian;
 
-public class TestPlexOfCps
+public final class TestPlexOfCps
   extends TestCase
 {
   private PlexOfCps _plexOfCps = null;
index df5f216fe39ac6550f54d256e26ba31aab344b6f..c2607f1ac3ddcc8cf43e1ff935ec5348867fda01 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
@@ -16,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hwpf.model;
 
 import java.io.*;
@@ -32,7 +30,7 @@ import org.apache.poi.util.*;
  *
  * @author Daniel Noll
  */
-public class TestSavedByTable
+public final class TestSavedByTable
   extends TestCase
 {
   /** Data dir */
index 2f5ad1ccbc78415d64df80cad0f773d382594101..da0eb00b8ef7fd7cdc44559e0fce3d01134c05ff 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.hwpf.model;
 
@@ -27,7 +25,7 @@ import java.util.ArrayList;
 import org.apache.poi.hwpf.*;
 import org.apache.poi.hwpf.model.io.*;
 
-public class TestSectionTable
+public final class TestSectionTable
   extends TestCase
 {
   private HWPFDocFixture _hWPFDocFixture;
@@ -46,7 +44,7 @@ public class TestSectionTable
     int fcMin = fib.getFcMin();
 
     CPSplitCalculator cps = new CPSplitCalculator(fib);
-    
+
     ComplexFileTable cft = new ComplexFileTable(mainStream, tableStream, fib.getFcClx(), fcMin);
     TextPieceTable tpt = cft.getTextPieceTable();
 
@@ -64,7 +62,7 @@ public class TestSectionTable
     byte[] newMainStream = mainOut.toByteArray();
 
     SectionTable newSectionTable = new SectionTable(
-               newMainStream, newTableStream, 0, 
+               newMainStream, newTableStream, 0,
                newTableStream.length, 0, tpt, cps);
 
     ArrayList oldSections = sectionTable.getSections();
index a93eaa3d156fd02151f9d915ef72e846d73b7f40..e9d70370df6b05d7fe3686ed2345c5e8fe5e477e 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.hwpf.model;
 
@@ -24,7 +22,7 @@ import junit.framework.*;
 import org.apache.poi.hwpf.*;
 import org.apache.poi.hwpf.model.io.*;
 
-public class TestStyleSheet
+public final class TestStyleSheet
   extends TestCase
 {
   private StyleSheet _styleSheet = null;
index 4595c4ce0e4796deed56be44e1301b30a18c03da..e69f0dec045cb2570dc44a54d059fcb68f918a42 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,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hwpf.model;
 
 import java.io.ByteArrayInputStream;
@@ -30,7 +29,7 @@ import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
 
 
-public class TestTextPieceTable extends TestCase {
+public final class TestTextPieceTable extends TestCase {
   private HWPFDocFixture _hWPFDocFixture;
   private String dirname;
 
@@ -76,25 +75,25 @@ public class TestTextPieceTable extends TestCase {
                                new FileInputStream(new File(dirname, "ThreeColHeadFoot.doc"))
                );
                TextPieceTable tbl = doc.getTextTable();
-               
+
                // All ascii, so stored in one big lump
                assertEquals(1, tbl.getTextPieces().size());
                TextPiece tp = (TextPiece)tbl.getTextPieces().get(0);
-               
+
                assertEquals(0, tp.getStart());
                assertEquals(339, tp.getEnd());
                assertEquals(339, tp.characterLength());
                assertEquals(339, tp.bytesLength());
                assertTrue(tp.getStringBuffer().toString().startsWith("This is a sample word document"));
 
-               
+
                // Save and re-load
                HWPFDocument docB = saveAndReload(doc);
                tbl = docB.getTextTable();
-               
+
                assertEquals(1, tbl.getTextPieces().size());
                tp = (TextPiece)tbl.getTextPieces().get(0);
-               
+
                assertEquals(0, tp.getStart());
                assertEquals(339, tp.getEnd());
                assertEquals(339, tp.characterLength());
@@ -111,54 +110,54 @@ public class TestTextPieceTable extends TestCase {
                                new FileInputStream(new File(dirname, "HeaderFooterUnicode.doc"))
                );
                TextPieceTable tbl = doc.getTextTable();
-               
+
                // In three bits, split every 512 bytes
                assertEquals(3, tbl.getTextPieces().size());
                TextPiece tpA = (TextPiece)tbl.getTextPieces().get(0);
                TextPiece tpB = (TextPiece)tbl.getTextPieces().get(1);
                TextPiece tpC = (TextPiece)tbl.getTextPieces().get(2);
-               
+
                assertTrue(tpA.isUnicode());
                assertTrue(tpB.isUnicode());
                assertTrue(tpC.isUnicode());
-               
+
                assertEquals(256, tpA.characterLength());
                assertEquals(256, tpB.characterLength());
                assertEquals(19, tpC.characterLength());
-               
+
                assertEquals(512, tpA.bytesLength());
                assertEquals(512, tpB.bytesLength());
                assertEquals(38, tpC.bytesLength());
-               
+
                assertEquals(0, tpA.getStart());
                assertEquals(256, tpA.getEnd());
                assertEquals(256, tpB.getStart());
                assertEquals(512, tpB.getEnd());
                assertEquals(512, tpC.getStart());
                assertEquals(531, tpC.getEnd());
-               
-               
+
+
                // Save and re-load
                HWPFDocument docB = saveAndReload(doc);
                tbl = docB.getTextTable();
-               
+
                assertEquals(3, tbl.getTextPieces().size());
                tpA = (TextPiece)tbl.getTextPieces().get(0);
                tpB = (TextPiece)tbl.getTextPieces().get(1);
                tpC = (TextPiece)tbl.getTextPieces().get(2);
-               
+
                assertTrue(tpA.isUnicode());
                assertTrue(tpB.isUnicode());
                assertTrue(tpC.isUnicode());
-               
+
                assertEquals(256, tpA.characterLength());
                assertEquals(256, tpB.characterLength());
                assertEquals(19, tpC.characterLength());
-               
+
                assertEquals(512, tpA.bytesLength());
                assertEquals(512, tpB.bytesLength());
                assertEquals(38, tpC.bytesLength());
-               
+
                assertEquals(0, tpA.getStart());
                assertEquals(256, tpA.getEnd());
                assertEquals(256, tpB.getStart());
@@ -170,12 +169,12 @@ public class TestTextPieceTable extends TestCase {
        protected HWPFDocument saveAndReload(HWPFDocument doc) throws Exception {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                doc.write(baos);
-               
+
                return new HWPFDocument(
                                new ByteArrayInputStream(baos.toByteArray())
                );
        }
-  
+
   protected void setUp()
     throws Exception
   {
@@ -183,7 +182,7 @@ public class TestTextPieceTable extends TestCase {
 
     _hWPFDocFixture = new HWPFDocFixture(this);
     _hWPFDocFixture.setUp();
-    
+
     dirname = System.getProperty("HWPF.testdata.path");
   }
 
index e68352b508676ef70c4ae5ea95b71c901d4719b4..1a48ab6b605a5fdf997ee65eb9c1d7b0b6a6169a 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hwpf.usermodel;
 
 import java.io.File;
@@ -27,19 +28,19 @@ import org.apache.poi.hwpf.HWPFDocument;
  * Tests for the handling of header stories into
  *  headers, footers etc
  */
-public class TestHeaderStories extends TestCase {
+public final class TestHeaderStories extends TestCase {
        private HWPFDocument none;
-       private HWPFDocument header; 
-       private HWPFDocument footer; 
-       private HWPFDocument headerFooter; 
-       private HWPFDocument oddEven; 
-       private HWPFDocument diffFirst; 
+       private HWPFDocument header;
+       private HWPFDocument footer;
+       private HWPFDocument headerFooter;
+       private HWPFDocument oddEven;
+       private HWPFDocument diffFirst;
        private HWPFDocument unicode;
        private HWPFDocument withFields;
-       
+
     protected void setUp() throws Exception {
                String dirname = System.getProperty("HWPF.testdata.path");
-               
+
                none = new HWPFDocument(
                                new FileInputStream(new File(dirname, "NoHeadFoot.doc"))
                );
@@ -65,138 +66,138 @@ public class TestHeaderStories extends TestCase {
                                new FileInputStream(new File(dirname, "HeaderWithMacros.doc"))
                );
     }
-    
+
     public void testNone() throws Exception {
        HeaderStories hs = new HeaderStories(none);
-       
+
        assertNull(hs.getPlcfHdd());
        assertEquals(0, hs.getRange().text().length());
     }
-    
+
     public void testHeader() throws Exception {
        HeaderStories hs = new HeaderStories(header);
-       
+
        assertEquals(60, hs.getRange().text().length());
-       
+
        // Should have the usual 6 separaters
        // Then all 6 of the different header/footer kinds
        // Finally a terminater
        assertEquals(13, hs.getPlcfHdd().length());
-       
+
        assertEquals(215, hs.getRange().getStartOffset());
-       
+
        assertEquals(0, hs.getPlcfHdd().getProperty(0).getStart());
        assertEquals(3, hs.getPlcfHdd().getProperty(1).getStart());
        assertEquals(6, hs.getPlcfHdd().getProperty(2).getStart());
        assertEquals(6, hs.getPlcfHdd().getProperty(3).getStart());
        assertEquals(9, hs.getPlcfHdd().getProperty(4).getStart());
        assertEquals(12, hs.getPlcfHdd().getProperty(5).getStart());
-       
+
        assertEquals(12, hs.getPlcfHdd().getProperty(6).getStart());
        assertEquals(12, hs.getPlcfHdd().getProperty(7).getStart());
        assertEquals(59, hs.getPlcfHdd().getProperty(8).getStart());
        assertEquals(59, hs.getPlcfHdd().getProperty(9).getStart());
        assertEquals(59, hs.getPlcfHdd().getProperty(10).getStart());
        assertEquals(59, hs.getPlcfHdd().getProperty(11).getStart());
-       
+
        assertEquals(59, hs.getPlcfHdd().getProperty(12).getStart());
-       
+
        assertEquals("\u0003\r\r", hs.getFootnoteSeparator());
                assertEquals("\u0004\r\r", hs.getFootnoteContSeparator());
                assertEquals("", hs.getFootnoteContNote());
                assertEquals("\u0003\r\r", hs.getEndnoteSeparator());
                assertEquals("\u0004\r\r", hs.getEndnoteContSeparator());
                assertEquals("", hs.getEndnoteContNote());
-               
+
                assertEquals("", hs.getFirstHeader());
                assertEquals("", hs.getEvenHeader());
                assertEquals("First header column!\tMid header Right header!\r\r", hs.getOddHeader());
 
-               
+
                assertEquals("", hs.getFirstFooter());
                assertEquals("", hs.getEvenFooter());
                assertEquals("", hs.getOddFooter());
     }
-    
+
     public void testFooter() throws Exception {
        HeaderStories hs = new HeaderStories(footer);
-       
+
                assertEquals("", hs.getFirstHeader());
                assertEquals("", hs.getEvenHeader());
                assertEquals("", hs.getOddHeader()); // Was \r\r but gets emptied
 
-               
+
                assertEquals("", hs.getFirstFooter());
                assertEquals("", hs.getEvenFooter());
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
     }
-    
+
     public void testHeaderFooter() throws Exception {
        HeaderStories hs = new HeaderStories(headerFooter);
-       
+
                assertEquals("", hs.getFirstHeader());
                assertEquals("", hs.getEvenHeader());
                assertEquals("I am some simple header text here\r\r\r", hs.getOddHeader());
 
-               
+
                assertEquals("", hs.getFirstFooter());
                assertEquals("", hs.getEvenFooter());
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
     }
-    
+
     public void testOddEven() throws Exception {
        HeaderStories hs = new HeaderStories(oddEven);
-       
+
                assertEquals("", hs.getFirstHeader());
                assertEquals("[This is an Even Page, with a Header]\u0007August 20, 2008\u0007\u0007\r\r", hs.getEvenHeader());
                assertEquals("August 20, 2008\u0007[ODD Page Header text]\u0007\u0007\r\r", hs.getOddHeader());
 
-               
+
                assertEquals("", hs.getFirstFooter());
                assertEquals("\u0007Page \u0013 PAGE  \\* MERGEFORMAT \u00142\u0015\u0007\u0007\u0007\u0007\u0007\u0007\u0007This is a simple footer on the second page\r\r", hs.getEvenFooter());
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
-               
+
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(1));
                assertEquals("\u0007Page \u0013 PAGE  \\* MERGEFORMAT \u00142\u0015\u0007\u0007\u0007\u0007\u0007\u0007\u0007This is a simple footer on the second page\r\r", hs.getFooter(2));
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(3));
     }
-    
+
     public void testFirst() throws Exception {
        HeaderStories hs = new HeaderStories(diffFirst);
-       
+
                assertEquals("I am the header on the first page, and I\u2019m nice and simple\r\r", hs.getFirstHeader());
                assertEquals("", hs.getEvenHeader());
                assertEquals("First header column!\tMid header Right header!\r\r", hs.getOddHeader());
 
-               
+
                assertEquals("The footer of the first page\r\r", hs.getFirstFooter());
                assertEquals("", hs.getEvenFooter());
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getOddFooter());
-               
+
                assertEquals("The footer of the first page\r\r", hs.getFooter(1));
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(2));
                assertEquals("Footer Left\tFooter Middle Footer Right\r\r", hs.getFooter(3));
     }
-    
+
     public void testUnicode() throws Exception {
        HeaderStories hs = new HeaderStories(unicode);
-       
+
                assertEquals("", hs.getFirstHeader());
                assertEquals("", hs.getEvenHeader());
                assertEquals("This is a simple header, with a \u20ac euro symbol in it.\r\r\r", hs.getOddHeader());
 
-               
+
                assertEquals("", hs.getFirstFooter());
                assertEquals("", hs.getEvenFooter());
                assertEquals("The footer, with Moli\u00e8re, has Unicode in it.\r\r", hs.getOddFooter());
     }
-    
+
     public void testWithFields() throws Exception {
        HeaderStories hs = new HeaderStories(withFields);
        assertFalse(hs.areFieldsStripped());
-       
+
        assertEquals("HEADER GOES HERE. 8/12/2008 \u0013 AUTHOR   \\* MERGEFORMAT \u0014Eric Roch\u0015\r\r\r", hs.getOddHeader());
-       
+
        // Now turn on stripping
        hs.setAreFieldsStripped(true);
        assertEquals("HEADER GOES HERE. 8/12/2008 Eric Roch\r\r\r", hs.getOddHeader());
index 3656b2ff5f6d4b6d49c71020840a1bdedea402a0..2dd669e7c3b3a4a3df02c658a49231ad8e2b126f 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hwpf.usermodel;
 
 import java.io.ByteArrayOutputStream;
@@ -31,54 +32,54 @@ import org.apache.poi.util.LittleEndian;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestPictures extends TestCase {
+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());
@@ -86,22 +87,22 @@ public class TestPictures extends TestCase {
        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();
@@ -110,32 +111,32 @@ public class TestPictures extends TestCase {
                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()));
@@ -154,7 +155,7 @@ public class TestPictures extends TestCase {
     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 ) {
index 2cc47474f8084995f1f23f0fb14ea90a6afa90b4..54e9b42a0c120d4dc9862984f307517a0becefca 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hwpf.usermodel;
 
 import java.io.File;
@@ -29,17 +30,17 @@ import org.apache.poi.hwpf.model.StyleSheet;
  *
  * @author Nick Burch (nick at torchbox dot com)
  */
-public class TestProblems extends HWPFTestCase {
+public final class TestProblems extends HWPFTestCase {
 
        private String dirname = System.getProperty("HWPF.testdata.path");
-       
+
     /**
      * ListEntry passed no ListTable
      */
     public void testListEntryNoListTable() throws Exception {
        HWPFDocument doc = new HWPFDocument(new FileInputStream(
                        new File(dirname, "ListEntryNoListTable.doc")));
-       
+
        Range r = doc.getRange();
        StyleSheet styleSheet = doc.getStyleSheet();
        for (int x = 0; x < r.numSections(); x++) {
@@ -57,7 +58,7 @@ public class TestProblems extends HWPFTestCase {
        public void testSprmAIOOB() throws Exception {
        HWPFDocument doc = new HWPFDocument(new FileInputStream(
                        new File(dirname, "AIOOB-Tap.doc")));
-       
+
        Range r = doc.getRange();
        StyleSheet styleSheet = doc.getStyleSheet();
        for (int x = 0; x < r.numSections(); x++) {
@@ -80,32 +81,32 @@ public class TestProblems extends HWPFTestCase {
                assertEquals(6, r.numParagraphs());
                assertEquals(0, r.getStartOffset());
                assertEquals(87, r.getEndOffset());
-                       
+
                // Paragraph with table
                Paragraph p = r.getParagraph(0);
                assertEquals(0, p.getStartOffset());
                assertEquals(20, p.getEndOffset());
-               
+
                // Get the table
                Table t = r.getTable(p);
-               
+
                //get the only row
                assertEquals(1, t.numRows());
                TableRow row = t.getRow(0);
-               
+
                //get the first cell
                TableCell cell = row.getCell(0);
                // First cell should have one paragraph
                assertEquals(1, cell.numParagraphs());
                assertEquals("One paragraph is ok\7", cell.getParagraph(0).text());
-               
+
                //get the second
                cell = row.getCell(1);
                // Second cell should be detected as having two paragraphs
                assertEquals(2, cell.numParagraphs());
                assertEquals("First para is ok\r", cell.getParagraph(0).text());
                assertEquals("Second paragraph is skipped\7", cell.getParagraph(1).text());
-                               
+
                //get the last cell
                cell = row.getCell(2);
                // Last cell should have one paragraph
@@ -119,9 +120,9 @@ public class TestProblems extends HWPFTestCase {
 
        Range range = doc.getRange();
                int numParagraphs = range.numParagraphs();
-               
+
                int totalLength = 0, deletedLength = 0;
-               
+
                for (int i = 0; i < numParagraphs; i++) {
                        Paragraph para = range.getParagraph(i);
                        String text = para.text();
@@ -132,22 +133,22 @@ public class TestProblems extends HWPFTestCase {
                                deletedLength = text.length();
                        }
                }
-               
+
                // check the text length after deletion
                int newLength = 0;
        range = doc.getRange();
                numParagraphs = range.numParagraphs();
-               
+
                for (int i = 0; i < numParagraphs; i++) {
                        Paragraph para = range.getParagraph(i);
                        String text = para.text();
 
-                       newLength += text.length();                     
+                       newLength += text.length();
                }
-               
+
                assertEquals(newLength, totalLength - deletedLength);
        }
-       
+
        /**
         * With an encrypted file, we should give a suitable
         *  exception, and not OOM
@@ -161,12 +162,12 @@ public class TestProblems extends HWPFTestCase {
                        // Good
                }
        }
-       
+
        public void testWriteProperties() throws Exception {
                HWPFDocument doc = new HWPFDocument(new FileInputStream(
                        new File(dirname, "SampleDoc.doc")));
                assertEquals("Nick Burch", doc.getSummaryInformation().getAuthor());
-               
+
                // Write and read
                HWPFDocument doc2 = writeOutAndRead(doc);
                assertEquals("Nick Burch", doc.getSummaryInformation().getAuthor());
index bcb03996ab8852a184d4240ea1102577c5a1271f..7fc362e3b7521b38410921ee4c504d69a76f373e 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hwpf.usermodel;
 
 import junit.framework.TestCase;
@@ -22,19 +23,19 @@ import junit.framework.TestCase;
  * Tests for Range which aren't around deletion, insertion,
  *  text replacement or textual contents
  */
-public class TestRange extends TestCase {
+public final class TestRange extends TestCase {
        public void testFieldStripping() throws Exception {
                String exp = "This is some text.";
-               
+
                String single = "This is some \u0013Blah!\u0015text.";
                String with14 = "This is \u0013Blah!\u0014some\u0015 text.";
                String withNested =
                        "This is \u0013Blah!\u0013Blah!\u0015\u0015some text.";
                String withNested14 =
                        "This is \u0013Blah!\u0013Blah!\u0014don't see me\u0015 blah!\u0015some text.";
-               String withNestedIn14 = 
+               String withNestedIn14 =
                        "This is \u0013Blah!\u0014some\u0013Blah!\u0015 \u0015text.";
-               
+
                // Check all comes out right
                assertEquals(exp, Range.stripFields(exp));
                assertEquals(exp, Range.stripFields(single));
@@ -42,11 +43,11 @@ public class TestRange extends TestCase {
                assertEquals(exp, Range.stripFields(withNested));
                assertEquals(exp, Range.stripFields(withNested14));
                assertEquals(exp, Range.stripFields(withNestedIn14));
-               
+
                // Ones that are odd and we won't change
                String odd1 = "This\u0015 is \u0013 odd";
                String odd2 = "This\u0015 is \u0014 also \u0013 odd";
-               
+
                assertEquals(odd1, Range.stripFields(odd1));
                assertEquals(odd2, Range.stripFields(odd2));
        }
index 4adc5b9cf8e08dddc6c32b622f8039bb2ac3a673..6468e3e370f0dbef2e34ed31ed298348d7982b7d 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
@@ -7,7 +6,7 @@
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
 
-          http://www.apache.org/licenses/LICENSE-2.0
+       http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
@@ -29,12 +28,12 @@ import org.apache.poi.hwpf.model.PAPX;
  *     Test to see if Range.delete() works even if the Range contains a
  *     CharacterRun that uses Unicode characters.
  */
-public class TestRangeDelete extends TestCase {
+public final class TestRangeDelete extends TestCase {
 
        // u201c and u201d are "smart-quotes"
-       private String introText = 
+       private String introText =
                "Introduction\r";
-       private String fillerText = 
+       private String fillerText =
                "${delete} This is an MS-Word 97 formatted document created using NeoOffice v. 2.2.4 Patch 0 (OpenOffice.org v. 2.2.1).\r";
        private String originalText =
                "It is used to confirm that text delete works even if Unicode characters (such as \u201c\u2014\u201d (U+2014), \u201c\u2e8e\u201d (U+2E8E), or \u201c\u2714\u201d (U+2714)) are present.  Everybody should be thankful to the ${organization} ${delete} and all the POI contributors for their assistance in this matter.\r";
@@ -78,48 +77,48 @@ public class TestRangeDelete extends TestCase {
                range = daDoc.getOverallRange();
                assertEquals(1, range.numSections());
                assertEquals(5, range.numParagraphs());
-               
-               
+
+
                // Now, onto just the doc bit
                range = daDoc.getRange();
 
                assertEquals(1, range.numSections());
                assertEquals(1, daDoc.getSectionTable().getSections().size());
                section = range.getSection(0);
-               
+
                assertEquals(5, section.numParagraphs());
-               
+
                para = section.getParagraph(0);
                assertEquals(1, para.numCharacterRuns());
                assertEquals(introText, para.text());
-               
+
                para = section.getParagraph(1);
                assertEquals(5, para.numCharacterRuns());
                assertEquals(fillerText, para.text());
-               
-               
+
+
                paraDef = (PAPX)daDoc.getParagraphTable().getParagraphs().get(2);
                assertEquals(132, paraDef.getStart());
                assertEquals(400, paraDef.getEnd());
-               
+
                para = section.getParagraph(2);
                assertEquals(5, para.numCharacterRuns());
                assertEquals(originalText, para.text());
-               
-               
+
+
                paraDef = (PAPX)daDoc.getParagraphTable().getParagraphs().get(3);
                assertEquals(400, paraDef.getStart());
                assertEquals(438, paraDef.getEnd());
-               
+
                para = section.getParagraph(3);
                assertEquals(1, para.numCharacterRuns());
                assertEquals(lastText, para.text());
-               
-               
+
+
                // Check things match on text length
                assertEquals(439, range.text().length());
                assertEquals(439, section.text().length());
-               assertEquals(439, 
+               assertEquals(439,
                                section.getParagraph(0).text().length() +
                                section.getParagraph(1).text().length() +
                                section.getParagraph(2).text().length() +
index a520b953f7e3fbe1f79964a89e9f64edf749e8f5..76452622f7fc9202ecfdbd6f911ce49cb48d1ca9 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
@@ -7,7 +6,7 @@
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
 
-          http://www.apache.org/licenses/LICENSE-2.0
+       http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
@@ -30,7 +29,7 @@ import org.apache.poi.hwpf.HWPFDocument;
  *
  * TODO - re-enable me when unicode paragraph stuff is fixed!
  */
-public class TestRangeInsertion extends TestCase {
+public final class TestRangeInsertion extends TestCase {
 
        // u201c and u201d are "smart-quotes"
        private String originalText =
@@ -72,14 +71,14 @@ public class TestRangeInsertion extends TestCase {
                assertEquals(originalText, para.text());
 
                assertEquals(3, para.numCharacterRuns());
-               String text = 
-                       para.getCharacterRun(0).text() + 
+               String text =
+                       para.getCharacterRun(0).text() +
                        para.getCharacterRun(1).text() +
                        para.getCharacterRun(2).text()
                ;
 
                assertEquals(originalText, text);
-               
+
                assertEquals(insertionPoint, para.getStartOffset());
        }
 
@@ -114,8 +113,8 @@ public class TestRangeInsertion extends TestCase {
                assertEquals((textToInsert + originalText), para.text());
 
                assertEquals(3, para.numCharacterRuns());
-               String text = 
-                       para.getCharacterRun(0).text() + 
+               String text =
+                       para.getCharacterRun(0).text() +
                        para.getCharacterRun(1).text() +
                        para.getCharacterRun(2).text()
                ;
index 1578ebdaf00bac09dd670be34d5987519093e7ab..05e3d2ca24fee7711ee78e49bcf0ffaa3e495565 100644 (file)
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hwpf.usermodel;
 
 import java.io.File;
@@ -32,9 +33,9 @@ import junit.framework.TestCase;
  *
  * TODO - re-enable me when unicode paragraph stuff is fixed!
  */
-public class TestRangeProperties extends TestCase {
+public final class TestRangeProperties extends TestCase {
        private static final char page_break = (char)12;
-       
+
        private static final String u_page_1 =
                "This is a fairly simple word document, over two pages, with headers and footers.\r" +
                "The trick with this one is that it contains some Unicode based strings in it.\r" +
@@ -50,23 +51,23 @@ public class TestRangeProperties extends TestCase {
        private static final String u_page_2 =
                "This is page two. Les Pr\u00e9cieuses ridicules. The end.\r"
        ;
-       
-       private static final String a_page_1 = 
+
+       private static final String a_page_1 =
                "I am a test document\r" +
-               "This is page 1\r" + 
+               "This is page 1\r" +
                "I am Calibri (Body) in font size 11\r"
        ;
-       private static final String a_page_2 = 
-               "This is page two\r" + 
+       private static final String a_page_2 =
+               "This is page two\r" +
                "It\u2019s Arial Black in 16 point\r" +
                "It\u2019s also in blue\r"
        ;
-       
+
        private HWPFDocument u;
        private HWPFDocument a;
-       
+
        private String dirname;
-       
+
        protected void setUp() throws Exception {
                dirname = System.getProperty("HWPF.testdata.path");
                u = new HWPFDocument(
@@ -76,34 +77,34 @@ public class TestRangeProperties extends TestCase {
                                new FileInputStream(new File(dirname, "SampleDoc.doc"))
                );
        }
-       
-       
+
+
        public void testAsciiTextParagraphs() throws Exception {
                Range r = a.getRange();
                assertEquals(
                                a_page_1 +
-                               page_break + "\r" + 
+                               page_break + "\r" +
                                a_page_2,
                                r.text()
                );
-               
+
                assertEquals(1, r.numSections());
                assertEquals(1, a.getSectionTable().getSections().size());
                Section s = r.getSection(0);
                assertEquals(
                                a_page_1 +
-                               page_break + "\r" + 
+                               page_break + "\r" +
                                a_page_2,
                                s.text()
                );
-               
+
                assertEquals(
                                7,
                                r.numParagraphs()
                );
                String[] p1_parts = a_page_1.split("\r");
                String[] p2_parts = a_page_2.split("\r");
-               
+
                // Check paragraph contents
                assertEquals(
                                p1_parts[0] + "\r",
@@ -117,12 +118,12 @@ public class TestRangeProperties extends TestCase {
                                p1_parts[2] + "\r",
                                r.getParagraph(2).text()
                );
-               
+
                assertEquals(
                                page_break + "\r",
                                r.getParagraph(3).text()
                );
-               
+
                assertEquals(
                                p2_parts[0] + "\r",
                                r.getParagraph(4).text()
@@ -136,19 +137,19 @@ public class TestRangeProperties extends TestCase {
                                r.getParagraph(6).text()
                );
        }
-       
+
        public void testAsciiStyling() throws Exception {
                Range r = a.getRange();
-               
+
                Paragraph p1 = r.getParagraph(0);
                Paragraph p7 = r.getParagraph(6);
-               
+
                assertEquals(1, p1.numCharacterRuns());
                assertEquals(1, p7.numCharacterRuns());
-               
+
                CharacterRun c1 = p1.getCharacterRun(0);
                CharacterRun c7 = p7.getCharacterRun(0);
-               
+
                assertEquals("Times New Roman", c1.getFontName()); // No Calibri
                assertEquals("Arial Black", c7.getFontName());
                assertEquals(22, c1.getFontSize());
@@ -163,7 +164,7 @@ public class TestRangeProperties extends TestCase {
                Range r = u.getRange();
                String[] p1_parts = u_page_1.split("\r");
                String[] p2_parts = u_page_2.split("\r");
-               
+
                assertEquals(
                                u_page_1 + page_break + "\r" + u_page_2,
                                r.text()
@@ -171,37 +172,37 @@ public class TestRangeProperties extends TestCase {
                assertEquals(
                                408, r.text().length()
                );
-       
-               
+
+
                assertEquals(1, r.numSections());
                assertEquals(1, u.getSectionTable().getSections().size());
                Section s = r.getSection(0);
                assertEquals(
                                u_page_1 +
-                               page_break + "\r" + 
+                               page_break + "\r" +
                                u_page_2,
                                s.text()
                );
                assertEquals(0, s.getStartOffset());
                assertEquals(408, s.getEndOffset());
 
-               
+
                List pDefs = r._paragraphs;
                assertEquals(35, pDefs.size());
-               
+
                // Check that the last paragraph ends where it should do
                assertEquals(531, u.getOverallRange().text().length());
                assertEquals(530, u.getCPSplitCalculator().getHeaderTextboxEnd());
                PropertyNode pLast = (PropertyNode)pDefs.get(34);
 //             assertEquals(530, pLast.getEnd());
-               
+
                // Only care about the first few really though
                PropertyNode p0 = (PropertyNode)pDefs.get(0);
                PropertyNode p1 = (PropertyNode)pDefs.get(1);
                PropertyNode p2 = (PropertyNode)pDefs.get(2);
                PropertyNode p3 = (PropertyNode)pDefs.get(3);
                PropertyNode p4 = (PropertyNode)pDefs.get(4);
-               
+
                // 5 paragraphs should get us to the end of our text
                assertTrue(p0.getStart() < 408);
                assertTrue(p0.getEnd() < 408);
@@ -213,7 +214,7 @@ public class TestRangeProperties extends TestCase {
                assertTrue(p3.getEnd() < 408);
                assertTrue(p4.getStart() < 408);
                assertTrue(p4.getEnd() < 408);
-               
+
                // Paragraphs should match with lines
                assertEquals(
                                0,
@@ -223,17 +224,17 @@ public class TestRangeProperties extends TestCase {
                                p1_parts[0].length() + 1,
                                p0.getEnd()
                );
-               
+
                assertEquals(
                                p1_parts[0].length() + 1,
                                p1.getStart()
-               );              
+               );
                assertEquals(
                                p1_parts[0].length() + 1 +
                                p1_parts[1].length() + 1,
                                p1.getEnd()
                );
-               
+
                assertEquals(
                                p1_parts[0].length() + 1 +
                                p1_parts[1].length() + 1,
@@ -254,18 +255,18 @@ public class TestRangeProperties extends TestCase {
                Range r = u.getRange();
                assertEquals(
                                u_page_1 +
-                               page_break + "\r" + 
+                               page_break + "\r" +
                                u_page_2,
                                r.text()
                );
-               
+
                assertEquals(
                                12,
                                r.numParagraphs()
                );
                String[] p1_parts = u_page_1.split("\r");
                String[] p2_parts = u_page_2.split("\r");
-               
+
                // Check text all matches up properly
                assertEquals(p1_parts[0] + "\r", r.getParagraph(0).text());
                assertEquals(p1_parts[1] + "\r", r.getParagraph(1).text());
@@ -283,86 +284,86 @@ public class TestRangeProperties extends TestCase {
        public void testUnicodeStyling() throws Exception {
                Range r = u.getRange();
                String[] p1_parts = u_page_1.split("\r");
-               
+
                Paragraph p1 = r.getParagraph(0);
                Paragraph p7 = r.getParagraph(6);
-               
+
                // Line ending in its own run each time!
                assertEquals(2, p1.numCharacterRuns());
                assertEquals(2, p7.numCharacterRuns());
-               
+
                CharacterRun c1a = p1.getCharacterRun(0);
                CharacterRun c1b = p1.getCharacterRun(1);
                CharacterRun c7a = p7.getCharacterRun(0);
                CharacterRun c7b = p7.getCharacterRun(1);
-               
+
                assertEquals("Times New Roman", c1a.getFontName()); // No Calibri
                assertEquals(22, c1a.getFontSize());
-               
+
                assertEquals("Times New Roman", c1b.getFontName()); // No Calibri
                assertEquals(22, c1b.getFontSize());
-               
+
                assertEquals("Times New Roman", c7a.getFontName());
                assertEquals(48, c7a.getFontSize());
-               
+
                assertEquals("Times New Roman", c7b.getFontName());
                assertEquals(48, c7b.getFontSize());
-               
+
                // Now check where they crop up
                assertEquals(
-                               0, 
+                               0,
                                c1a.getStartOffset()
                );
                assertEquals(
-                               p1_parts[0].length(), 
+                               p1_parts[0].length(),
                                c1a.getEndOffset()
                );
-               
+
                assertEquals(
-                               p1_parts[0].length(), 
+                               p1_parts[0].length(),
                                c1b.getStartOffset()
                );
                assertEquals(
-                               p1_parts[0].length()+1, 
+                               p1_parts[0].length()+1,
                                c1b.getEndOffset()
                );
-               
+
                assertEquals(
-                               p1_parts[0].length() + 1 + 
-                               p1_parts[1].length() + 1 + 
-                               p1_parts[2].length() + 1 + 
-                               p1_parts[3].length() + 1 + 
-                               p1_parts[4].length() + 1 + 
-                               p1_parts[5].length() + 1, 
+                               p1_parts[0].length() + 1 +
+                               p1_parts[1].length() + 1 +
+                               p1_parts[2].length() + 1 +
+                               p1_parts[3].length() + 1 +
+                               p1_parts[4].length() + 1 +
+                               p1_parts[5].length() + 1,
                                c7a.getStartOffset()
                );
                assertEquals(
-                               p1_parts[0].length() + 1 + 
-                               p1_parts[1].length() + 1 + 
-                               p1_parts[2].length() + 1 + 
-                               p1_parts[3].length() + 1 + 
-                               p1_parts[4].length() + 1 + 
+                               p1_parts[0].length() + 1 +
+                               p1_parts[1].length() + 1 +
+                               p1_parts[2].length() + 1 +
+                               p1_parts[3].length() + 1 +
+                               p1_parts[4].length() + 1 +
                                p1_parts[5].length() + 1 +
                                1,
                                c7a.getEndOffset()
                );
-               
+
                assertEquals(
-                               p1_parts[0].length() + 1 + 
-                               p1_parts[1].length() + 1 + 
-                               p1_parts[2].length() + 1 + 
-                               p1_parts[3].length() + 1 + 
-                               p1_parts[4].length() + 1 + 
+                               p1_parts[0].length() + 1 +
+                               p1_parts[1].length() + 1 +
+                               p1_parts[2].length() + 1 +
+                               p1_parts[3].length() + 1 +
+                               p1_parts[4].length() + 1 +
                                p1_parts[5].length() + 1 +
-                               1, 
+                               1,
                                c7b.getStartOffset()
                );
                assertEquals(
-                               p1_parts[0].length() + 1 + 
-                               p1_parts[1].length() + 1 + 
-                               p1_parts[2].length() + 1 + 
-                               p1_parts[3].length() + 1 + 
-                               p1_parts[4].length() + 1 + 
+                               p1_parts[0].length() + 1 +
+                               p1_parts[1].length() + 1 +
+                               p1_parts[2].length() + 1 +
+                               p1_parts[3].length() + 1 +
+                               p1_parts[4].length() + 1 +
                                p1_parts[5].length() + 1 +
                                p1_parts[6].length() + 1,
                                c7b.getEndOffset()
index 7c47668445ccc836038b43a474fd74ff98fa5263..794979d0fad4f609f4619ea8d2a3939b8d87748f 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
@@ -7,7 +6,7 @@
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
 
-          http://www.apache.org/licenses/LICENSE-2.0
+       http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
@@ -30,7 +29,7 @@ import org.apache.poi.hwpf.HWPFDocument;
  *
  * TODO - re-enable me when unicode paragraph stuff is fixed!
  */
-public class TestRangeReplacement extends TestCase {
+public final class TestRangeReplacement extends TestCase {
 
        // u201c and u201d are "smart-quotes"
        private String originalText =
@@ -76,8 +75,8 @@ public class TestRangeReplacement extends TestCase {
                Paragraph para = section.getParagraph(2);
 
                assertEquals(5, para.numCharacterRuns());
-               String text = 
-                       para.getCharacterRun(0).text() + 
+               String text =
+                       para.getCharacterRun(0).text() +
                        para.getCharacterRun(1).text() +
                        para.getCharacterRun(2).text() +
                        para.getCharacterRun(3).text() +
index 273a03432bd76b21b36dba2fb43fee68401408d8..7749e77224d0f91211174a137d41e558c37faf9e 100644 (file)
@@ -1,19 +1,20 @@
-/*
-* 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.
-*/
+/* ====================================================================
+   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.hwpf.usermodel;
 
 import java.io.ByteArrayInputStream;
@@ -29,7 +30,7 @@ import org.apache.poi.hwpf.HWPFDocument;
 /**
  * Test the shapes handling
  */
-public class TestShapes extends TestCase {
+public final class TestShapes extends TestCase {
        private String dirname = System.getProperty("HWPF.testdata.path");
 
     /**
@@ -54,14 +55,14 @@ public class TestShapes extends TestCase {
                assertEquals(4817, s2.getWidth());
                assertEquals(2164, s2.getHeight());
                assertEquals(true, s2.isWithinDocument());
-       
-               
+
+
                // Re-serialisze, check still there
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                doc.write(baos);
                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
                doc = new HWPFDocument(bais);
-               
+
                shapes = doc.getShapesTable().getAllShapes();
                vshapes = doc.getShapesTable().getVisibleShapes();