+++ /dev/null
-/* ====================================================================
- 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 alignment text property.
- */
-public class AlignmentTextProp extends TextProp {
- public static final int LEFT = 0;
- public static final int CENTER = 1;
- public static final int RIGHT = 2;
- public static final int JUSTIFY = 3;
- public static final int THAIDISTRIBUTED = 5;
- public static final int JUSTIFYLOW = 6;
-
- public AlignmentTextProp() {
- super(2, 0x800, "alignment");
- }
-}
\ No newline at end of file
--- /dev/null
+/* ====================================================================
+ 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
--- /dev/null
+/* ====================================================================
+ 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 text alignment property.
+ */
+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 TextAlignmentProp() {
+ super(2, 0x800, "alignment");
+ }
+}
\ No newline at end of file
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"),
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
import java.awt.Color;\r
import java.util.*;\r
\r
+import org.apache.poi.hslf.model.PPFont;\r
import org.apache.poi.hslf.model.textproperties.*;\r
import org.apache.poi.hslf.record.*;\r
import org.apache.poi.sl.usermodel.TextParagraph;\r
int alignInt;\r
switch (align) {\r
default:\r
- case LEFT: alignInt = AlignmentTextProp.LEFT; break;\r
- case CENTER: alignInt = AlignmentTextProp.CENTER; break;\r
- case RIGHT: alignInt = AlignmentTextProp.RIGHT; break;\r
- case DIST: // TODO: DIST doesn't not exist within hslf, check mapping\r
- case JUSTIFY: alignInt = AlignmentTextProp.JUSTIFY; break;\r
- case JUSTIFY_LOW: alignInt = AlignmentTextProp.JUSTIFYLOW; break;\r
- case THAI_DIST: alignInt = AlignmentTextProp.THAIDISTRIBUTED; break;\r
+ case LEFT: alignInt = TextAlignmentProp.LEFT; break;\r
+ case CENTER: alignInt = TextAlignmentProp.CENTER; break;\r
+ case RIGHT: alignInt = TextAlignmentProp.RIGHT; break;\r
+ case DIST: alignInt = TextAlignmentProp.DISTRIBUTED; break;\r
+ case JUSTIFY: alignInt = TextAlignmentProp.JUSTIFY; break;\r
+ case JUSTIFY_LOW: alignInt = TextAlignmentProp.JUSTIFYLOW; break;\r
+ case THAI_DIST: alignInt = TextAlignmentProp.THAIDISTRIBUTED; break;\r
}\r
setParaTextPropVal("alignment", alignInt);\r
}\r
public org.apache.poi.sl.usermodel.TextParagraph.TextAlign getTextAlign() {\r
switch (getParaTextPropVal("alignment")) {\r
default:\r
- case AlignmentTextProp.LEFT: return TextAlign.LEFT;\r
- case AlignmentTextProp.CENTER: return TextAlign.CENTER;\r
- case AlignmentTextProp.RIGHT: return TextAlign.RIGHT;\r
- case AlignmentTextProp.JUSTIFY: return TextAlign.JUSTIFY;\r
- case AlignmentTextProp.JUSTIFYLOW: return TextAlign.JUSTIFY_LOW;\r
- case AlignmentTextProp.THAIDISTRIBUTED: return TextAlign.THAI_DIST;\r
+ case TextAlignmentProp.LEFT: return TextAlign.LEFT;\r
+ case TextAlignmentProp.CENTER: return TextAlign.CENTER;\r
+ case TextAlignmentProp.RIGHT: return TextAlign.RIGHT;\r
+ case TextAlignmentProp.JUSTIFY: return TextAlign.JUSTIFY;\r
+ case TextAlignmentProp.JUSTIFYLOW: return TextAlign.JUSTIFY_LOW;\r
+ case TextAlignmentProp.DISTRIBUTED: return TextAlign.DIST;\r
+ case TextAlignmentProp.THAIDISTRIBUTED: return TextAlign.THAI_DIST;\r
}\r
}\r
\r
- public org.apache.poi.sl.usermodel.TextParagraph.FontAlign getFontAlign() {\r
- // TODO Auto-generated method stub\r
- return null;\r
+ @Override\r
+ public FontAlign getFontAlign() {\r
+ switch(getParaTextPropVal("fontAlign")) {\r
+ default:\r
+ case -1: return FontAlign.AUTO;\r
+ case FontAlignmentProp.BASELINE: return FontAlign.BASELINE;\r
+ case FontAlignmentProp.TOP: return FontAlign.TOP;\r
+ case FontAlignmentProp.CENTER: return FontAlign.CENTER;\r
+ case FontAlignmentProp.BOTTOM: return FontAlign.BOTTOM;\r
+ }\r
}\r
\r
- public org.apache.poi.sl.usermodel.TextParagraph.BulletStyle getBulletStyle() {\r
- // TODO Auto-generated method stub\r
- return null;\r
+ @Override\r
+ public BulletStyle getBulletStyle() {\r
+ if (getBulletChar() == 0) return null;\r
+ \r
+ return new BulletStyle() {\r
+ public String getBulletCharacter() {\r
+ char chr = HSLFTextParagraph.this.getBulletChar();\r
+ return (chr == 0 ? "" : ""+chr);\r
+ }\r
+\r
+ public String getBulletFont() {\r
+ int fontIdx = HSLFTextParagraph.this.getBulletFont();\r
+ if (fontIdx == -1) return getDefaultFontFamily();\r
+ PPFont ppFont = getSheet().getSlideShow().getFont(fontIdx);\r
+ return ppFont.getFontName();\r
+ }\r
+\r
+ public double getBulletFontSize() {\r
+ return HSLFTextParagraph.this.getBulletSize();\r
+ }\r
+\r
+ public Color getBulletFontColor() {\r
+ return HSLFTextParagraph.this.getBulletColor();\r
+ }\r
+ };\r
}\r
\r
@Override\r
* Returns the bullet character\r
*/\r
public char getBulletChar() {\r
- return (char)getParaTextPropVal("bullet.char");\r
+ int val = getParaTextPropVal("bullet.char");\r
+ return (char)(val == -1 ? 0 : val);\r
}\r
\r
/**\r
\r
\r
public interface TextParagraph<T extends TextRun> extends Iterable<T> {\r
+\r
/**\r
* Specifies a list of text alignment types\r
*/\r
public enum TextAlign {\r
/**\r
- * Align text to the left margin.\r
+ * For horizontal text, left aligned.\r
+ * For vertical text, top aligned.\r
*/\r
LEFT,\r
+\r
/**\r
- * Align text in the center.\r
+ * For horizontal text, centered.\r
+ * For vertical text, middle aligned.\r
*/\r
CENTER,\r
\r
/**\r
- * Align text to the right margin.\r
+ * For horizontal text, right aligned.\r
+ * For vertical text, bottom aligned.\r
*/\r
RIGHT,\r
\r
* Align text so that it is justified across the whole line. It\r
* is smart in the sense that it will not justify sentences\r
* which are short\r
+ * \r
+ * For horizontal text, flush left and right.\r
+ * For vertical text, flush top and bottom.\r
*/\r
JUSTIFY,\r
+ \r
+ /**\r
+ * Kashida justify low.\r
+ */ \r
JUSTIFY_LOW,\r
+\r
+ /**\r
+ * Distribute space between characters.\r
+ */\r
DIST,\r
+ \r
+ /**\r
+ * Thai distribution justification.\r
+ */\r
THAI_DIST\r
}\r
\r
* \r
*/\r
public enum FontAlign {\r
- AUTO, TOP, CENTER, BASELINE, BOTTOM; \r
+ AUTO,\r
+ \r
+ /**\r
+ * Characters hang from top of line height.\r
+ * Also known as "Hanging"\r
+ */\r
+ TOP,\r
+ \r
+ /**\r
+ * Characters centered within line height.\r
+ */\r
+ CENTER,\r
+ \r
+ /**\r
+ * Place characters on font baseline.\r
+ * Also known as "Roman" \r
+ */\r
+ BASELINE,\r
+ \r
+ /**\r
+ * Characters are anchored to the very bottom of a single line.\r
+ * This is different than BASELINE because of letters such as "g", "q", and "y".\r
+ * Also known as "UpholdFixed"\r
+ */\r
+ BOTTOM; \r
}\r
\r
public interface BulletStyle {\r
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;