diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2020-06-04 23:17:44 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2020-06-04 23:17:44 +0000 |
commit | 5a18307eb051603509c8b8147f4dfdf0e8fe56b2 (patch) | |
tree | 70a5e2c1ff908c4a98a614b92f5992c8c2891060 /src/scratchpad | |
parent | 84330c6aa3a96fff4bbd5593b7173209187ec474 (diff) | |
download | poi-5a18307eb051603509c8b8147f4dfdf0e8fe56b2.tar.gz poi-5a18307eb051603509c8b8147f4dfdf0e8fe56b2.zip |
63290 - PPTX To Png changes font sizes and colors
various fixes to HSLF
moved line spacing to the following line
refactored PropertyFetcher with lambdas
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1878492 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad')
3 files changed, 30 insertions, 12 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java index df11586b95..c50f18fe77 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java @@ -202,14 +202,14 @@ public final class TextRulerAtom extends RecordAtom { * Paragraph's distance from shape's left margin, in master coordinates (576 dpi). */ public Integer[] getTextOffsets(){ - return indent; + return leftMargin; } /** * First line of paragraph's distance from shape's left margin, in master coordinates (576 dpi). */ public Integer[] getBulletOffsets(){ - return leftMargin; + return indent; } public static TextRulerAtom getParagraphInstance(){ diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java index 6e1b7611d1..6a763101f6 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java @@ -357,8 +357,18 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText @Override public Double getLeftMargin() { - TextProp tp = getPropVal(_paragraphStyle, "text.offset"); - return (tp == null) ? null : Units.masterToPoints(tp.getValue()); + Integer val = null; + if (_ruler != null) { + Integer[] toList = _ruler.getTextOffsets(); + val = (toList.length > getIndentLevel()) ? toList[getIndentLevel()] : null; + } + + if (val == null) { + TextProp tp = getPropVal(_paragraphStyle, "text.offset"); + val = (tp == null) ? null : tp.getValue(); + } + + return (val == null) ? null : Units.masterToPoints(val); } @Override @@ -380,8 +390,18 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText @Override public Double getIndent() { - TextProp tp = getPropVal(_paragraphStyle, "bullet.offset"); - return (tp == null) ? null : Units.masterToPoints(tp.getValue()); + Integer val = null; + if (_ruler != null) { + Integer[] toList = _ruler.getBulletOffsets(); + val = (toList.length > getIndentLevel()) ? toList[getIndentLevel()] : null; + } + + if (val == null) { + TextProp tp = getPropVal(_paragraphStyle, "bullet.offset"); + val = (tp == null) ? null : tp.getValue(); + } + + return (val == null) ? null : Units.masterToPoints(val); } @Override @@ -592,8 +612,8 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText @Override public void setIndentLevel(int level) { if( _paragraphStyle != null ) { - _paragraphStyle.setIndentLevel((short)level); - } + _paragraphStyle.setIndentLevel((short)level); + } } /** diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java index eee4ffe88c..df8db98c78 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java @@ -20,7 +20,6 @@ package org.apache.poi.hslf.record; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import java.io.ByteArrayOutputStream; import java.util.List; @@ -53,11 +52,10 @@ public final class TestTextRulerAtom { assertNotNull(tabStops); Integer[] textOffsets = ruler.getTextOffsets(); - assertArrayEquals(new Integer[]{226, 451, 903, 1129, 1526}, textOffsets); + assertArrayEquals(new Integer[]{117, 345, 794, 1016, 1526}, textOffsets); Integer[] bulletOffsets = ruler.getBulletOffsets(); - assertArrayEquals(new Integer[]{117, 345, 794, 1016, 1526}, bulletOffsets); - + assertArrayEquals(new Integer[]{226, 451, 903, 1129, 1526}, bulletOffsets); } @Test |