Changed CRLF to LF in scratchpad. Minor fixes for compiler warnings and formatting

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@777204 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-05-21 18:12:22 +00:00
parent 5a4ac88a81
commit 5c061765b8
487 changed files with 13554 additions and 14056 deletions

View File

@ -1,62 +1,62 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF 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 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();
}
}
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF 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();
}
}

View File

@ -1,59 +1,60 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.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 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();
}
}
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF 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();
}
}

View File

@ -1,149 +1,148 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.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 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");
}
}
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF 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");
}
}

View File

@ -1,80 +1,80 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF 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 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();
}
}
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF 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();
}
}

View File

@ -1,80 +1,81 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.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 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);
}
}
}
}
}
}
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF 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);
}
}
}
}
}
}

View File

@ -1,108 +1,107 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF 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 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");
}
}
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF 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");
}
}

View File

@ -1,127 +1,127 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.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 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();
}
}
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF 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();
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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,17 +14,16 @@
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;

View File

@ -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,17 +14,16 @@
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;

View File

@ -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,

View File

@ -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,18 +14,16 @@
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

View File

@ -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,18 +14,16 @@
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;

View File

@ -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,18 +14,16 @@
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;

View File

@ -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;

View File

@ -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;

View File

@ -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,18 +14,16 @@
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;

View File

@ -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,18 +14,16 @@
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;

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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,18 +14,16 @@
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)

View File

@ -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=\"" +

View File

@ -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,18 +14,16 @@
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;

View File

@ -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,18 +14,16 @@
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;

View File

@ -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,18 +14,16 @@
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;

View File

@ -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,18 +14,16 @@
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;

View File

@ -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,19 +14,17 @@
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;

View File

@ -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;

View File

@ -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

View File

@ -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
{

View File

@ -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;

View File

@ -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,18 +14,16 @@
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
{

View File

@ -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,19 +14,16 @@
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;

View File

@ -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,18 +14,16 @@
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;
}
}

View File

@ -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;

View File

@ -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,12 +14,6 @@
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*/

View File

@ -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 */

View File

@ -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
{

View File

@ -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()

View File

@ -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
{

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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,12 +14,6 @@
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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
{
/**

View File

@ -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
{

View File

@ -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
{

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
{

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
{
/*

View File

@ -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;

View File

@ -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,12 +14,12 @@
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();

View 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
*/

View 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; }
}

View 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;
}

View 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
*/

View File

@ -14,20 +14,21 @@
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;
}
}

View File

@ -14,12 +14,13 @@
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?
*/

View 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?
*/

View File

@ -14,20 +14,21 @@
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 + ">";
}

View File

@ -14,19 +14,20 @@
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 + ">";
}

View 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()
);

View File

@ -1,44 +1,43 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hdgf.exceptions;
/**
* The superclass of all HDGF exceptions
*
* @author Yegor Kozlov
*/
public 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);
}
}
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF 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);
}
}

View 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());
}

View File

@ -14,10 +14,11 @@
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();

View 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");

View File

@ -14,12 +14,13 @@
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
*/

View 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()]);
}
}

View 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;
}
}
}

View 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);
}

View 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);
}

View 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; }
}
}

View 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);

View 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);
}

Some files were not shown because too many files have changed in this diff Show More