You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/06/18 00:21:14 UTC
svn commit: r1686117 [3/3] - in /poi/branches/common_sl:
src/examples/src/org/apache/poi/hslf/examples/
src/examples/src/org/apache/poi/xslf/usermodel/
src/java/org/apache/poi/util/ src/ooxml/java/org/apache/poi/xslf/usermodel/
src/ooxml/testcases/org/...
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TextParagraph.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TextParagraph.java?rev=1686117&r1=1686116&r2=1686117&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TextParagraph.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TextParagraph.java Wed Jun 17 22:21:13 2015
@@ -104,10 +104,18 @@ public interface TextParagraph<T extends
public interface BulletStyle {
String getBulletCharacter();
String getBulletFont();
- double getBulletFontSize();
+
+ /**
+ * The bullet point font size
+ * If bulletFontSize >= 0, then space is a percentage of normal line height.
+ * If bulletFontSize < 0, the absolute value in points
+ *
+ * @return the bullet point font size
+ */
+ Double getBulletFontSize();
Color getBulletFontColor();
}
-
+
/**
* The amount of vertical white space before the paragraph
* This may be specified in two different ways, percentage spacing and font point spacing:
@@ -116,9 +124,30 @@ public interface TextParagraph<T extends
* If spaceBefore < 0, the absolute value in points
* </p>
*
- * @return the vertical white space before the paragraph
+ * @return the vertical white space before the paragraph, or null if unset
*/
- double getSpaceBefore();
+ Double getSpaceBefore();
+
+ /**
+ * Set the amount of vertical white space that will be present before the paragraph.
+ * This space is specified in either percentage or points:
+ * <p>
+ * If spaceBefore >= 0, then space is a percentage of normal line height.
+ * If spaceBefore < 0, the absolute value of linespacing is the spacing in points
+ * </p>
+ * Examples:
+ * <pre><code>
+ * // The paragraph will be formatted to have a spacing before the paragraph text.
+ * // The spacing will be 200% of the size of the largest text on each line
+ * paragraph.setSpaceBefore(200);
+ *
+ * // The spacing will be a size of 48 points
+ * paragraph.setSpaceBefore(-48.0);
+ * </code></pre>
+ *
+ * @param spaceBefore the vertical white space before the paragraph, null to unset
+ */
+ void setSpaceBefore(Double spaceBefore);
/**
* The amount of vertical white space after the paragraph
@@ -128,40 +157,74 @@ public interface TextParagraph<T extends
* If spaceBefore < 0, the absolute value of linespacing is the spacing in points
* </p>
*
- * @return the vertical white space after the paragraph
+ * @return the vertical white space after the paragraph or null, if unset
*/
- double getSpaceAfter();
+ Double getSpaceAfter();
/**
- * @return the left margin (in points) of the paragraph
+ * Set the amount of vertical white space that will be present after the paragraph.
+ * This space is specified in either percentage or points:
+ * <p>
+ * If spaceAfter >= 0, then space is a percentage of normal line height.
+ * If spaceAfter < 0, the absolute value of linespacing is the spacing in points
+ * </p>
+ * Examples:
+ * <pre><code>
+ * // The paragraph will be formatted to have a spacing after the paragraph text.
+ * // The spacing will be 200% of the size of the largest text on each line
+ * paragraph.setSpaceAfter(200);
+ *
+ * // The spacing will be a size of 48 points
+ * paragraph.setSpaceAfter(-48.0);
+ * </code></pre>
+ *
+ * @param spaceAfter the vertical white space after the paragraph, null to unset
+ */
+ public void setSpaceAfter(Double spaceAfter);
+
+ /**
+ * @return the left margin (in points) of the paragraph or null, if unset
*/
- double getLeftMargin();
+ Double getLeftMargin();
/**
- * @param leftMargin the left margin (in points)
+ * Specifies the left margin of the paragraph. This is specified in addition to the text body
+ * inset and applies only to this text paragraph. That is the text body Inset and the LeftMargin
+ * attributes are additive with respect to the text position.
+ *
+ * @param leftMargin the left margin (in points) or null to unset
*/
- void setLeftMargin(double leftMargin);
+ void setLeftMargin(Double leftMargin);
/**
- * @return the right margin (in points) of the paragraph
+ * Specifies the right margin of the paragraph. This is specified in addition to the text body
+ * inset and applies only to this text paragraph. That is the text body Inset and the RightMargin
+ * attributes are additive with respect to the text position.
+ *
+ * The right margin is not support and therefore ignored by the HSLF implementation.
+ *
+ * @return the right margin (in points) of the paragraph or null, if unset
*/
- double getRightMargin();
+ Double getRightMargin();
/**
* @param rightMargin the right margin (in points) of the paragraph
*/
- void setRightMargin(double rightMargin);
+ void setRightMargin(Double rightMargin);
/**
* @return the indent (in points) applied to the first line of text in the paragraph.
+ * or null, if unset
*/
- double getIndent();
+ Double getIndent();
/**
+ * Specifies the indent size that will be applied to the first line of text in the paragraph.
+ *
* @param indent the indent (in points) applied to the first line of text in the paragraph
*/
- void setIndent(double indent);
+ void setIndent(Double indent);
/**
* Returns the vertical line spacing that is to be used within a paragraph.
@@ -171,9 +234,9 @@ public interface TextParagraph<T extends
* If linespacing < 0, the absolute value of linespacing is the spacing in points
* </p>
*
- * @return the vertical line spacing.
+ * @return the vertical line spacing or null, if unset
*/
- double getLineSpacing();
+ Double getLineSpacing();
/**
* This element specifies the vertical line spacing that is to be used within a paragraph.
@@ -196,14 +259,14 @@ public interface TextParagraph<T extends
*
* @param linespacing the vertical line spacing
*/
- void setLineSpacing(double lineSpacing);
+ void setLineSpacing(Double lineSpacing);
String getDefaultFontFamily();
/**
- * @return the default font size, in case its not set in the textrun
+ * @return the default font size, in case its not set in the textrun or null, if unset
*/
- double getDefaultFontSize();
+ Double getDefaultFontSize();
/**
* Returns the alignment that is applied to the paragraph.
@@ -217,8 +280,10 @@ public interface TextParagraph<T extends
/**
* Returns the font alignment that is applied to the paragraph.
*
- * If this attribute is omitted, then a value of auto (~ left) is implied.
- * @return ??? alignment that is applied to the paragraph
+ * If this attribute is omitted, then null is return,
+ * user code can imply the a value of {@link FontAlign#AUTO}
+ *
+ * @return alignment that is applied to the paragraph
*/
FontAlign getFontAlign();
@@ -227,5 +292,11 @@ public interface TextParagraph<T extends
*/
BulletStyle getBulletStyle();
+ /**
+ * @return the default size for a tab character within this paragraph in points, null if unset
+ */
+ Double getDefaultTabSize();
+
+
TextShape<? extends TextParagraph<T>> getParentShape();
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TextRun.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TextRun.java?rev=1686117&r1=1686116&r2=1686117&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TextRun.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TextRun.java Wed Jun 17 22:21:13 2015
@@ -21,8 +21,6 @@ import java.awt.Color;
/**
* Some text.
- *
- * TODO - decide on how we do rich text stuff
*/
public interface TextRun {
enum TextCap {
@@ -31,13 +29,13 @@ public interface TextRun {
ALL
}
- public String getRawText();
- public void setText(String text);
+ String getRawText();
+ void setText(String text);
TextCap getTextCap();
Color getFontColor();
- double getFontSize();
+ Double getFontSize();
String getFontFamily();
boolean isBold();
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java?rev=1686117&r1=1686116&r2=1686117&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java Wed Jun 17 22:21:13 2015
@@ -22,8 +22,7 @@ import static org.junit.Assert.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
import javax.imageio.ImageIO;
@@ -35,7 +34,6 @@ import org.apache.poi.sl.usermodel.Slide
import org.apache.poi.sl.usermodel.SlideShow;
import org.apache.poi.util.JvmBugs;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -142,29 +140,43 @@ public final class TestPicture {
@Test
// @Ignore("Just for visual validation - antialiasing is different on various systems")
public void bug54541() throws Exception {
- String file = new String[]{
- "54542_cropped_bitmap.pptx",
- "54541_cropped_bitmap.ppt",
- "54541_cropped_bitmap2.ppt",
- "sample_pptx_grouping_issues.pptx"
- }[3];
- InputStream is = _slTests.openResourceAsStream(file);
- SlideShow ss = file.endsWith("pptx") ? new XMLSlideShow(is) : new HSLFSlideShow(is);
- is.close();
+ String files[] = {
+// "sample_pptx_grouping_issues.pptx",
+// "54542_cropped_bitmap.pptx",
+// "54541_cropped_bitmap.ppt",
+// "54541_cropped_bitmap2.ppt",
+// "alterman_security.ppt",
+ "alterman_security2.pptx",
+ };
+
+ BitSet pages = new BitSet();
+ pages.set(2);
- boolean debugOut = false;
- Dimension pg = ss.getPageSize();
- int i=1;
- for(Slide<?,?,?> slide : ss.getSlides()) {
- if (debugOut) {
- DummyGraphics2d graphics = new DummyGraphics2d();
- slide.draw(graphics);
- } else {
- BufferedImage img = new BufferedImage(pg.width, pg.height, BufferedImage.TYPE_INT_RGB);
- Graphics2D graphics = img.createGraphics();
- fixFonts(graphics);
- slide.draw(graphics);
- ImageIO.write(img, "PNG", new File("test"+(i++)+"hslf.png"));
+ for (String file : files) {
+ InputStream is = _slTests.openResourceAsStream(file);
+ SlideShow ss = file.endsWith("pptx") ? new XMLSlideShow(is) : new HSLFSlideShow(is);
+ is.close();
+
+ boolean debugOut = false;
+ Dimension pg = ss.getPageSize();
+ for (Slide<?,?,?> slide : ss.getSlides()) {
+ int slideNo = slide.getSlideNumber();
+ if (!pages.get(slideNo-1)) {
+ if (pages.nextSetBit(slideNo-1) == -1) break; else continue;
+ }
+ if (debugOut) {
+ DummyGraphics2d graphics = new DummyGraphics2d();
+ slide.draw(graphics);
+ } else {
+ BufferedImage img = new BufferedImage(pg.width, pg.height, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D graphics = img.createGraphics();
+ fixFonts(graphics);
+ slide.draw(graphics);
+ graphics.setColor(Color.BLACK);
+ graphics.setStroke(new BasicStroke(1));
+ graphics.drawRect(0, 0, (int)pg.getWidth()-1, (int)pg.getHeight()-1);
+ ImageIO.write(img, "PNG", new File(file.replaceFirst(".pptx?", "-")+slideNo+".png"));
+ }
}
}
}
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java?rev=1686117&r1=1686116&r2=1686117&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java Wed Jun 17 22:21:13 2015
@@ -470,7 +470,7 @@ public final class TestRichTextRun {
assertEquals(expected, HSLFTextParagraph.getRawText(txt.get(1)));
assertEquals(4, txt.get(1).size());
rt = txt.get(1).get(0);
- assertEquals('\u2022', rt.getBulletChar());
+ assertEquals('\u2022', (char)rt.getBulletChar());
assertTrue(rt.isBullet());
@@ -486,7 +486,7 @@ public final class TestRichTextRun {
assertEquals(4, txt.get(0).size());
rt = txt.get(0).get(0);
assertTrue(rt.isBullet());
- assertEquals('\u2022', rt.getBulletChar());
+ assertEquals('\u2022', (char)rt.getBulletChar());
expected =
"I\u2019m a text box with user-defined\r" +
@@ -495,7 +495,7 @@ public final class TestRichTextRun {
assertEquals(2, txt.get(1).size());
rt = txt.get(1).get(0);
assertTrue(rt.isBullet());
- assertEquals('\u263A', rt.getBulletChar());
+ assertEquals('\u263A', (char)rt.getBulletChar());
}
@Test
@@ -513,8 +513,8 @@ public final class TestRichTextRun {
HSLFTextRun tr = rt.getTextRuns().get(0);
tr.setFontSize(42);
rt.setBullet(true);
- rt.setLeftMargin(50);
- rt.setIndent(0);
+ rt.setLeftMargin(50d);
+ rt.setIndent(0d);
rt.setBulletChar('\u263A');
slide.addShape(shape);
@@ -522,7 +522,7 @@ public final class TestRichTextRun {
assertEquals(true, rt.isBullet());
assertEquals(50.0, rt.getLeftMargin(), 0);
assertEquals(0, rt.getIndent(), 0);
- assertEquals('\u263A', rt.getBulletChar());
+ assertEquals('\u263A', (char)rt.getBulletChar());
shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300));
slide.addShape(shape);
@@ -541,7 +541,7 @@ public final class TestRichTextRun {
assertEquals(true, rt.isBullet());
assertEquals(50.0, rt.getLeftMargin(), 0);
assertEquals(0, rt.getIndent(), 0);
- assertEquals('\u263A', rt.getBulletChar());
+ assertEquals('\u263A', (char)rt.getBulletChar());
}
@Test
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextRun.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextRun.java?rev=1686117&r1=1686116&r2=1686117&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextRun.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextRun.java Wed Jun 17 22:21:13 2015
@@ -556,7 +556,7 @@ public final class TestTextRun {
int i=0;
for (List<HSLFTextParagraph> textParas : slide.getTextParagraphs()) {
assertEquals("Arial", textParas.get(0).getTextRuns().get(0).getFontFamily());
- assertEquals(sizes[i++], (int)textParas.get(0).getTextRuns().get(0).getFontSize());
+ assertEquals(sizes[i++], textParas.get(0).getTextRuns().get(0).getFontSize().intValue());
}
}
Added: poi/branches/common_sl/test-data/slideshow/alterman_security2.pptx
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/test-data/slideshow/alterman_security2.pptx?rev=1686117&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/branches/common_sl/test-data/slideshow/alterman_security2.pptx
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org