From 07c22ee428b52d090dc70daa0f61fc796930c7a2 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 16 Jun 2006 16:32:07 +0000 Subject: [PATCH] Tweak rich text handling git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@414857 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hslf/model/TextRun.java | 2 +- .../apache/poi/hslf/usermodel/TestRichTextRun.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java b/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java index 0a9144fd90..8ff24cd682 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java @@ -88,7 +88,7 @@ public class TextRun LinkedList cStyles = new LinkedList(); if(_styleAtom != null) { // Get the style atom to grok itself - _styleAtom.setParentTextSize(runRawText.length()+1); + _styleAtom.setParentTextSize(runRawText.length()); pStyles = _styleAtom.getParagraphStyles(); cStyles = _styleAtom.getCharacterStyles(); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java index fce7e82642..599f39d4aa 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java @@ -182,6 +182,11 @@ public class TestRichTextRun extends TestCase { rtr.setFontSize(18); rtr.setFontName("Courier"); + // Check it took those + assertEquals(true, rtr.isBold()); + assertEquals(18, rtr.getFontSize()); + assertEquals("Courier", rtr.getFontName()); + // Write out and back in ByteArrayOutputStream baos = new ByteArrayOutputStream(); h[i].write(baos); @@ -195,8 +200,14 @@ public class TestRichTextRun extends TestCase { rtr.setFontSize(17); rtr.setFontName("CourierZZ"); + // Check it took those changes + assertEquals(false, rtr.isBold()); + assertEquals(17, rtr.getFontSize()); + assertEquals("CourierZZ", rtr.getFontName()); + - // Check written out/back ing one contains modifications + // Now, look at the one we changed, wrote out, and read back in + // Ensure it does contain our original modifications Slide slideOneRR = readS.getSlides()[0]; TextRun[] textRunsRR = slideOneRR.getTextRuns(); RichTextRun rtrRRa = textRunsRR[0].getRichTextRuns()[0]; -- 2.39.5