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/04/29 22:26:06 UTC
svn commit: r1676849 - in /poi/branches/common_sl/src/scratchpad:
src/org/apache/poi/hslf/model/textproperties/
src/org/apache/poi/hslf/record/ src/org/apache/poi/hslf/usermodel/
src/org/apache/poi/sl/usermodel/ testcases/org/apache/poi/hslf/model/
Author: kiwiwings
Date: Wed Apr 29 20:26:05 2015
New Revision: 1676849
URL: http://svn.apache.org/r1676849
Log:
Added Distributed option to TextAlignment
Added FontAlignment
Added:
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java
- copied, changed from r1676380, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/AlignmentTextProp.java
Removed:
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/AlignmentTextProp.java
Modified:
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TextParagraph.java
poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
Added: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java?rev=1676849&view=auto
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java (added)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/FontAlignmentProp.java Wed Apr 29 20:26:05 2015
@@ -0,0 +1,32 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model.textproperties;
+
+/**
+ * Definition for the font alignment property.
+ */
+public class FontAlignmentProp extends TextProp {
+ public static final int BASELINE = 0;
+ public static final int TOP = 1;
+ public static final int CENTER = 2;
+ public static final int BOTTOM = 3;
+
+ public FontAlignmentProp() {
+ super(2, 0x10000, "fontAlign");
+ }
+}
\ No newline at end of file
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java (from r1676380, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/AlignmentTextProp.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/AlignmentTextProp.java&r1=1676380&r2=1676849&rev=1676849&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/AlignmentTextProp.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextAlignmentProp.java Wed Apr 29 20:26:05 2015
@@ -18,17 +18,49 @@
package org.apache.poi.hslf.model.textproperties;
/**
- * Definition for the alignment text property.
+ * Definition for the text alignment property.
*/
-public class AlignmentTextProp extends TextProp {
- public static final int LEFT = 0;
+public class TextAlignmentProp extends TextProp {
+ /**
+ * For horizontal text, left aligned.
+ * For vertical text, top aligned.
+ */
+ public static final int LEFT = 0;
+
+ /**
+ * For horizontal text, centered.
+ * For vertical text, middle aligned.
+ */
public static final int CENTER = 1;
+
+ /**
+ * For horizontal text, right aligned.
+ * For vertical text, bottom aligned.
+ */
public static final int RIGHT = 2;
+
+ /**
+ * For horizontal text, flush left and right.
+ * For vertical text, flush top and bottom.
+ */
public static final int JUSTIFY = 3;
+
+ /**
+ * Distribute space between characters.
+ */
+ public static final int DISTRIBUTED = 4;
+
+ /**
+ * Thai distribution justification.
+ */
public static final int THAIDISTRIBUTED = 5;
+
+ /**
+ * Kashida justify low.
+ */
public static final int JUSTIFYLOW = 6;
- public AlignmentTextProp() {
+ public TextAlignmentProp() {
super(2, 0x800, "alignment");
}
}
\ No newline at end of file
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java?rev=1676849&r1=1676848&r2=1676849&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java Wed Apr 29 20:26:05 2015
@@ -126,7 +126,7 @@ public final class StyleTextPropAtom ext
new TextProp(2, 0x10, "bullet.font"),
new TextProp(2, 0x40, "bullet.size"),
new TextProp(4, 0x20, "bullet.color"),
- new AlignmentTextProp(),
+ new TextAlignmentProp(),
new TextProp(2, 0x1000, "linespacing"),
new TextProp(2, 0x2000, "spacebefore"),
new TextProp(2, 0x4000, "spaceafter"),
@@ -135,7 +135,7 @@ public final class StyleTextPropAtom ext
new TextProp(2, 0x400, "bullet.offset"), // indent
new TextProp(2, 0x8000, "defaultTabSize"),
new TabStopPropCollection(), // tabstops size is variable!
- new TextProp(2, 0x10000, "fontAlign"),
+ new FontAlignmentProp(),
new TextProp(2, 0xE0000, "wrapFlags"), // charWrap | wordWrap | overflow
new TextProp(2, 0x200000, "textDirection"),
// 0x400000 MUST be zero and MUST be ignored
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java?rev=1676849&r1=1676848&r2=1676849&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java Wed Apr 29 20:26:05 2015
@@ -20,6 +20,7 @@ package org.apache.poi.hslf.usermodel;
import java.awt.Color;
import java.util.*;
+import org.apache.poi.hslf.model.PPFont;
import org.apache.poi.hslf.model.textproperties.*;
import org.apache.poi.hslf.record.*;
import org.apache.poi.sl.usermodel.TextParagraph;
@@ -367,13 +368,13 @@ public final class HSLFTextParagraph imp
int alignInt;
switch (align) {
default:
- case LEFT: alignInt = AlignmentTextProp.LEFT; break;
- case CENTER: alignInt = AlignmentTextProp.CENTER; break;
- case RIGHT: alignInt = AlignmentTextProp.RIGHT; break;
- case DIST: // TODO: DIST doesn't not exist within hslf, check mapping
- case JUSTIFY: alignInt = AlignmentTextProp.JUSTIFY; break;
- case JUSTIFY_LOW: alignInt = AlignmentTextProp.JUSTIFYLOW; break;
- case THAI_DIST: alignInt = AlignmentTextProp.THAIDISTRIBUTED; break;
+ case LEFT: alignInt = TextAlignmentProp.LEFT; break;
+ case CENTER: alignInt = TextAlignmentProp.CENTER; break;
+ case RIGHT: alignInt = TextAlignmentProp.RIGHT; break;
+ case DIST: alignInt = TextAlignmentProp.DISTRIBUTED; break;
+ case JUSTIFY: alignInt = TextAlignmentProp.JUSTIFY; break;
+ case JUSTIFY_LOW: alignInt = TextAlignmentProp.JUSTIFYLOW; break;
+ case THAI_DIST: alignInt = TextAlignmentProp.THAIDISTRIBUTED; break;
}
setParaTextPropVal("alignment", alignInt);
}
@@ -382,23 +383,53 @@ public final class HSLFTextParagraph imp
public org.apache.poi.sl.usermodel.TextParagraph.TextAlign getTextAlign() {
switch (getParaTextPropVal("alignment")) {
default:
- case AlignmentTextProp.LEFT: return TextAlign.LEFT;
- case AlignmentTextProp.CENTER: return TextAlign.CENTER;
- case AlignmentTextProp.RIGHT: return TextAlign.RIGHT;
- case AlignmentTextProp.JUSTIFY: return TextAlign.JUSTIFY;
- case AlignmentTextProp.JUSTIFYLOW: return TextAlign.JUSTIFY_LOW;
- case AlignmentTextProp.THAIDISTRIBUTED: return TextAlign.THAI_DIST;
+ case TextAlignmentProp.LEFT: return TextAlign.LEFT;
+ case TextAlignmentProp.CENTER: return TextAlign.CENTER;
+ case TextAlignmentProp.RIGHT: return TextAlign.RIGHT;
+ case TextAlignmentProp.JUSTIFY: return TextAlign.JUSTIFY;
+ case TextAlignmentProp.JUSTIFYLOW: return TextAlign.JUSTIFY_LOW;
+ case TextAlignmentProp.DISTRIBUTED: return TextAlign.DIST;
+ case TextAlignmentProp.THAIDISTRIBUTED: return TextAlign.THAI_DIST;
}
}
- public org.apache.poi.sl.usermodel.TextParagraph.FontAlign getFontAlign() {
- // TODO Auto-generated method stub
- return null;
+ @Override
+ public FontAlign getFontAlign() {
+ switch(getParaTextPropVal("fontAlign")) {
+ default:
+ case -1: return FontAlign.AUTO;
+ case FontAlignmentProp.BASELINE: return FontAlign.BASELINE;
+ case FontAlignmentProp.TOP: return FontAlign.TOP;
+ case FontAlignmentProp.CENTER: return FontAlign.CENTER;
+ case FontAlignmentProp.BOTTOM: return FontAlign.BOTTOM;
+ }
}
- public org.apache.poi.sl.usermodel.TextParagraph.BulletStyle getBulletStyle() {
- // TODO Auto-generated method stub
- return null;
+ @Override
+ public BulletStyle getBulletStyle() {
+ if (getBulletChar() == 0) return null;
+
+ return new BulletStyle() {
+ public String getBulletCharacter() {
+ char chr = HSLFTextParagraph.this.getBulletChar();
+ return (chr == 0 ? "" : ""+chr);
+ }
+
+ public String getBulletFont() {
+ int fontIdx = HSLFTextParagraph.this.getBulletFont();
+ if (fontIdx == -1) return getDefaultFontFamily();
+ PPFont ppFont = getSheet().getSlideShow().getFont(fontIdx);
+ return ppFont.getFontName();
+ }
+
+ public double getBulletFontSize() {
+ return HSLFTextParagraph.this.getBulletSize();
+ }
+
+ public Color getBulletFontColor() {
+ return HSLFTextParagraph.this.getBulletColor();
+ }
+ };
}
@Override
@@ -460,7 +491,8 @@ public final class HSLFTextParagraph imp
* Returns the bullet character
*/
public char getBulletChar() {
- return (char)getParaTextPropVal("bullet.char");
+ int val = getParaTextPropVal("bullet.char");
+ return (char)(val == -1 ? 0 : val);
}
/**
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=1676849&r1=1676848&r2=1676849&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 Apr 29 20:26:05 2015
@@ -21,21 +21,26 @@ import java.awt.Color;
public interface TextParagraph<T extends TextRun> extends Iterable<T> {
+
/**
* Specifies a list of text alignment types
*/
public enum TextAlign {
/**
- * Align text to the left margin.
+ * For horizontal text, left aligned.
+ * For vertical text, top aligned.
*/
LEFT,
+
/**
- * Align text in the center.
+ * For horizontal text, centered.
+ * For vertical text, middle aligned.
*/
CENTER,
/**
- * Align text to the right margin.
+ * For horizontal text, right aligned.
+ * For vertical text, bottom aligned.
*/
RIGHT,
@@ -43,10 +48,25 @@ public interface TextParagraph<T extends
* Align text so that it is justified across the whole line. It
* is smart in the sense that it will not justify sentences
* which are short
+ *
+ * For horizontal text, flush left and right.
+ * For vertical text, flush top and bottom.
*/
JUSTIFY,
+
+ /**
+ * Kashida justify low.
+ */
JUSTIFY_LOW,
+
+ /**
+ * Distribute space between characters.
+ */
DIST,
+
+ /**
+ * Thai distribution justification.
+ */
THAI_DIST
}
@@ -54,7 +74,31 @@ public interface TextParagraph<T extends
*
*/
public enum FontAlign {
- AUTO, TOP, CENTER, BASELINE, BOTTOM;
+ AUTO,
+
+ /**
+ * Characters hang from top of line height.
+ * Also known as "Hanging"
+ */
+ TOP,
+
+ /**
+ * Characters centered within line height.
+ */
+ CENTER,
+
+ /**
+ * Place characters on font baseline.
+ * Also known as "Roman"
+ */
+ BASELINE,
+
+ /**
+ * Characters are anchored to the very bottom of a single line.
+ * This is different than BASELINE because of letters such as "g", "q", and "y".
+ * Also known as "UpholdFixed"
+ */
+ BOTTOM;
}
public interface BulletStyle {
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java?rev=1676849&r1=1676848&r2=1676849&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java Wed Apr 29 20:26:05 2015
@@ -27,8 +27,11 @@ import java.util.List;
import org.apache.poi.POIDataSamples;
import org.apache.poi.ddf.*;
import org.apache.poi.hslf.usermodel.*;
-import org.apache.poi.sl.usermodel.ShapeType;
+import org.apache.poi.sl.usermodel.*;
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
+import org.apache.poi.sl.usermodel.TextParagraph.BulletStyle;
+import org.apache.poi.sl.usermodel.TextParagraph.FontAlign;
+import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
import org.junit.Before;
import org.junit.Test;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org