View | Details | Raw Unified | Return to bug 53979
Collapse All | Expand All

(-)src/scratchpad/src/org/apache/poi/hslf/record/TextAutoNumberSchemeEnum.java (+109 lines)
Line 0 Link Here
1
package org.apache.poi.hslf.record;
2
3
public enum TextAutoNumberSchemeEnum {
4
	//Name Value Meaning
5
	ANM_AlphaLcPeriod 			((short) 0x0000), // "Lowercase Latin character followed by a period. Example: a., b., c., ..."),
6
	ANM_AlphaUcPeriod 			((short) 0x0001), // "Uppercase Latin character followed by a period. Example: A., B., C., ..."),
7
	ANM_ArabicParenRight		((short) 0x0002), // "Arabic numeral followed by a closing parenthesis. Example: 1), 2), 3), ..."),
8
	ANM_ArabicPeriod			((short) 0x0003), // "Arabic numeral followed by a period. Example: 1., 2., 3., ..."),
9
	ANM_RomanLcParenBoth		((short) 0x0004), // "Lowercase Roman numeral enclosed in parentheses. Example: (i), (ii), (iii), ..."),            
10
	ANM_RomanLcParenRight		((short) 0x0005), // "Lowercase Roman numeral followed by a closing parenthesis. Example: i), ii), iii), ..."),     
11
	ANM_RomanLcPeriod			((short) 0x0006), // "Lowercase Roman numeral followed by a period. Example: i., ii., iii., ..."), 
12
	ANM_RomanUcPeriod			((short) 0x0007), // "Uppercase Roman numeral followed by a period. Example: I., II., III., ..."),
13
	ANM_AlphaLcParenBoth		((short) 0x0008), // "Lowercase alphabetic character enclosed in parentheses. Example: (a), (b), (c), ..."),
14
	ANM_AlphaLcParenRight		((short) 0x0009), // "Lowercase alphabetic character followed by a closing parenthesis. Example: a), b), c), ..."),
15
	ANM_AlphaUcParenBoth		((short) 0x000A), // "Uppercase alphabetic character enclosed in parentheses. Example: (A), (B), (C), ..."),
16
	ANM_AlphaUcParenRight		((short) 0x000B), // "Uppercase alphabetic character followed by a closing parenthesis. Example: A), B), C), ..."), 
17
	ANM_ArabicParenBoth			((short) 0x000C), // "Arabic numeral enclosed in parentheses. Example: (1), (2), (3), ..."),
18
	ANM_ArabicPlain				((short) 0x000D), // "Arabic numeral. Example: 1, 2, 3, ..."),
19
	ANM_RomanUcParenBoth		((short) 0x000E), // "Uppercase Roman numeral enclosed in parentheses. Example: (I), (II), (III), ..."),
20
	ANM_RomanUcParenRight		((short) 0x000F), // "Uppercase Roman numeral followed by a closing parenthesis. Example: I), II), III), ..."),
21
	ANM_ChsPlain				((short) 0x0010), // "Simplified Chinese."),
22
	ANM_ChsPeriod				((short) 0x0011), // "Simplified Chinese with single-byte period."),
23
	ANM_CircleNumDBPlain		((short) 0x0012), // "Double byte circle numbers."),
24
	ANM_CircleNumWDBWhitePlain	((short) 0x0013), // "Wingdings white circle numbers."),
25
	ANM_CircleNumWDBBlackPlain	((short) 0x0014), // "Wingdings black circle numbers."),
26
	ANM_ChtPlain				((short) 0x0015), // "Traditional Chinese."),
27
	ANM_ChtPeriod				((short) 0x0016), // "Traditional Chinese with single-byte period."),
28
	ANM_Arabic1Minus			((short) 0x0017), // "Bidi Arabic 1 (AraAlpha) with ANSI minus symbol."),
29
	ANM_Arabic2Minus			((short) 0x0018), // "Bidi Arabic 2 (AraAbjad) with ANSI minus symbol."),
30
	ANM_Hebrew2Minus			((short) 0x0019), // "Bidi Hebrew 2 with ANSI minus symbol."),
31
	ANM_JpnKorPlain				((short) 0x001A), // "Japanese/Korean."),
32
	ANM_JpnKorPeriod			((short) 0x001B), // "Japanese/Korean with single-byte period."),
33
	ANM_ArabicDbPlain			((short) 0x001C), // "Double-byte Arabic numbers."),
34
	ANM_ArabicDbPeriod			((short) 0x001D), // "Double-byte Arabic numbers with double-byte period."),
35
	ANM_ThaiAlphaPeriod			((short) 0x001E), // "Thai alphabetic character followed by a period."),
36
	ANM_ThaiAlphaParenRight		((short) 0x001F), // "Thai alphabetic character followed by a closing parenthesis."),
37
	ANM_ThaiAlphaParenBoth		((short) 0x0020), // "Thai alphabetic character enclosed by parentheses."),
38
	ANM_ThaiNumPeriod			((short) 0x0021), // "Thai numeral followed by a period."),
39
	ANM_ThaiNumParenRight		((short) 0x0022), // "Thai numeral followed by a closing parenthesis."),
40
	ANM_ThaiNumParenBoth		((short) 0x0023), // "Thai numeral enclosed in parentheses."),
41
	ANM_HindiAlphaPeriod		((short) 0x0024), // "Hindi alphabetic character followed by a period."),
42
	ANM_HindiNumPeriod			((short) 0x0025), // "Hindi numeric character followed by a period."),
43
	ANM_JpnChsDBPeriod			((short) 0x0026), // "Japanese with double-byte period."),
44
	ANM_HindiNumParenRight		((short) 0x0027), // "Hindi numeric character followed by a closing parenthesis."),
45
	ANM_HindiAlpha1Period		((short) 0x0028); // "Hindi alphabetic character followed by a period.");
46
47
	private final short value;
48
	private TextAutoNumberSchemeEnum(final short code) {
49
		this.value = code;
50
	}
51
	private short getValue() { return value; }
52
	public String getDescription() {
53
		return TextAutoNumberSchemeEnum.getDescription(this);
54
	}
55
	public static String getDescription(final TextAutoNumberSchemeEnum code) {
56
		switch (code) {
57
		case ANM_AlphaLcPeriod			: return "Lowercase Latin character followed by a period. Example: a., b., c., ...";
58
		case ANM_AlphaUcPeriod 			: return "Uppercase Latin character followed by a period. Example: A., B., C., ...";
59
		case ANM_ArabicParenRight		: return "Arabic numeral followed by a closing parenthesis. Example: 1), 2), 3), ...";
60
		case ANM_ArabicPeriod			: return "Arabic numeral followed by a period. Example: 1., 2., 3., ...";
61
		case ANM_RomanLcParenBoth		: return "Lowercase Roman numeral enclosed in parentheses. Example: (i), (ii), (iii), ...";            
62
		case ANM_RomanLcParenRight		: return "Lowercase Roman numeral followed by a closing parenthesis. Example: i), ii), iii), ...";     
63
		case ANM_RomanLcPeriod			: return "Lowercase Roman numeral followed by a period. Example: i., ii., iii., ...";
64
		case ANM_RomanUcPeriod			: return "Uppercase Roman numeral followed by a period. Example: I., II., III., ...";
65
		case ANM_AlphaLcParenBoth		: return "Lowercase alphabetic character enclosed in parentheses. Example: (a), (b), (c), ...";
66
		case ANM_AlphaLcParenRight		: return "Lowercase alphabetic character followed by a closing parenthesis. Example: a), b), c), ...";
67
		case ANM_AlphaUcParenBoth		: return "Uppercase alphabetic character enclosed in parentheses. Example: (A), (B), (C), ...";
68
		case ANM_AlphaUcParenRight		: return "Uppercase alphabetic character followed by a closing parenthesis. Example: A), B), C), ..."; 
69
		case ANM_ArabicParenBoth		: return "Arabic numeral enclosed in parentheses. Example: (1), (2), (3), ...";
70
		case ANM_ArabicPlain			: return "Arabic numeral. Example: 1, 2, 3, ...";
71
		case ANM_RomanUcParenBoth		: return "Uppercase Roman numeral enclosed in parentheses. Example: (I), (II), (III), ...";
72
		case ANM_RomanUcParenRight		: return "Uppercase Roman numeral followed by a closing parenthesis. Example: I), II), III), ...";
73
		case ANM_ChsPlain				: return "Simplified Chinese.";
74
		case ANM_ChsPeriod				: return "Simplified Chinese with single-byte period.";
75
		case ANM_CircleNumDBPlain		: return "Double byte circle numbers.";
76
		case ANM_CircleNumWDBWhitePlain	: return "Wingdings white circle numbers.";
77
		case ANM_CircleNumWDBBlackPlain	: return "Wingdings black circle numbers.";
78
		case ANM_ChtPlain				: return "Traditional Chinese.";
79
		case ANM_ChtPeriod				: return "Traditional Chinese with single-byte period.";
80
		case ANM_Arabic1Minus			: return "Bidi Arabic 1 (AraAlpha) with ANSI minus symbol.";
81
		case ANM_Arabic2Minus			: return "Bidi Arabic 2 (AraAbjad) with ANSI minus symbol.";
82
		case ANM_Hebrew2Minus			: return "Bidi Hebrew 2 with ANSI minus symbol.";
83
		case ANM_JpnKorPlain			: return "Japanese/Korean.";
84
		case ANM_JpnKorPeriod			: return "Japanese/Korean with single-byte period.";
85
		case ANM_ArabicDbPlain			: return "Double-byte Arabic numbers.";
86
		case ANM_ArabicDbPeriod			: return "Double-byte Arabic numbers with double-byte period.";
87
		case ANM_ThaiAlphaPeriod		: return "Thai alphabetic character followed by a period.";
88
		case ANM_ThaiAlphaParenRight	: return "Thai alphabetic character followed by a closing parenthesis.";
89
		case ANM_ThaiAlphaParenBoth		: return "Thai alphabetic character enclosed by parentheses.";
90
		case ANM_ThaiNumPeriod			: return "Thai numeral followed by a period.";
91
		case ANM_ThaiNumParenRight		: return "Thai numeral followed by a closing parenthesis.";
92
		case ANM_ThaiNumParenBoth		: return "Thai numeral enclosed in parentheses.";
93
		case ANM_HindiAlphaPeriod		: return "Hindi alphabetic character followed by a period.";
94
		case ANM_HindiNumPeriod			: return "Hindi numeric character followed by a period.";
95
		case ANM_JpnChsDBPeriod			: return "Japanese with double-byte period.";
96
		case ANM_HindiNumParenRight		: return "Hindi numeric character followed by a closing parenthesis.";
97
		case ANM_HindiAlpha1Period		: return "Hindi alphabetic character followed by a period.";
98
		default							: return "Unknown Numbered Scheme";
99
		}
100
	}
101
	public static TextAutoNumberSchemeEnum valueOf(short autoNumberScheme) {
102
		for (TextAutoNumberSchemeEnum item: TextAutoNumberSchemeEnum.values()) {
103
			if (autoNumberScheme == item.getValue()) {
104
				return item;
105
			}
106
		}
107
		return null;
108
	}
109
}
(-)src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPFException9.java (+117 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
/**
19
 * A structure that specifies additional paragraph-level formatting
20
 * such as Bullet Auto Number Scheme.
21
 */
22
package org.apache.poi.hslf.model.textproperties;
23
24
import org.apache.poi.hslf.record.TextAutoNumberSchemeEnum;
25
import org.apache.poi.util.LittleEndian;
26
27
/**
28
 * This structure store text autonumber scheme and start number.
29
 * If a paragraph has an autonumber(fBulletHasAutoNumber = 0x0001) but start number and scheme are empty,
30
 * this means the default values will be used: statNumber=1 and sheme=ANM_ArabicPeriod
31
 * @see http://social.msdn.microsoft.com/Forums/mr-IN/os_binaryfile/thread/650888db-fabd-4b95-88dc-f0455f6e2d28
32
 *
33
 * @author Alex Nikiforov [mailto:anikif@gmail.com]
34
 *
35
 */
36
public class TextPFException9 {
37
	//private final byte mask1;
38
	//private final byte mask2;
39
	private final byte mask3;
40
	private final byte mask4;
41
	private final Short bulletBlipRef;
42
	private final Short fBulletHasAutoNumber;
43
	private final TextAutoNumberSchemeEnum autoNumberScheme;
44
	private final static TextAutoNumberSchemeEnum DEFAULT_AUTONUMBER_SHEME = TextAutoNumberSchemeEnum.ANM_ArabicPeriod;
45
	private final Short autoNumberStartNumber;
46
	private final static Short DEFAULT_START_NUMBER = new Short((short)1);
47
	private final int recordLength;
48
	public TextPFException9(final byte[] source, final int startIndex) {
49
		//this.mask1 = source[startIndex];
50
		//this.mask2 = source[startIndex + 1];
51
		this.mask3 = source[startIndex + 2];
52
		this.mask4 = source[startIndex + 3];
53
		int length = 4;
54
		int index = startIndex + 4;
55
		if (0 == (mask3 & (byte)0x80 )) {
56
			this.bulletBlipRef = null;
57
		} else {
58
			this.bulletBlipRef = LittleEndian.getShort(source, index);
59
			index +=2;
60
			length = 6;
61
		}
62
		if (0 == (mask4 & 2)) {
63
			this.fBulletHasAutoNumber = null;
64
		} else {
65
			this.fBulletHasAutoNumber = LittleEndian.getShort(source, index);
66
			index +=2;
67
			length +=2;
68
		}
69
		if (0 == (mask4 & 1)) {
70
			this.autoNumberScheme = null;
71
			this.autoNumberStartNumber = null;
72
		} else {
73
			this.autoNumberScheme = TextAutoNumberSchemeEnum.valueOf(LittleEndian.getShort(source, index));
74
			index +=2;
75
			this.autoNumberStartNumber = LittleEndian.getShort(source, index);
76
			index +=2;
77
			length +=4;
78
		}
79
		this.recordLength = length;
80
	}
81
	public Short getBulletBlipRef() {
82
		return bulletBlipRef;
83
	}
84
	public Short getfBulletHasAutoNumber() {
85
		return fBulletHasAutoNumber;
86
	}
87
	public TextAutoNumberSchemeEnum getAutoNumberScheme() {
88
		if (null != this.autoNumberScheme) {
89
			return this.autoNumberScheme;
90
		}
91
		if (null != this.fBulletHasAutoNumber && 1 == this.fBulletHasAutoNumber.shortValue()) {
92
			return DEFAULT_AUTONUMBER_SHEME;
93
		}
94
		return null;
95
	}
96
	public Short getAutoNumberStartNumber() {
97
		if (null != this.autoNumberStartNumber) {
98
			return this.autoNumberStartNumber;
99
		}
100
		if (null != this.fBulletHasAutoNumber && 1 == this.fBulletHasAutoNumber.shortValue()) {
101
			return DEFAULT_START_NUMBER;
102
		}
103
		return null;
104
	}
105
	public int getRecordLength() {
106
		return recordLength;
107
	}
108
	@Override
109
	public String toString() {
110
		final StringBuilder sb = new StringBuilder("Record length: ").append(this.recordLength).append(" bytes\n");
111
		sb.append("bulletBlipRef: ").append(this.bulletBlipRef).append("\n");
112
		sb.append("fBulletHasAutoNumber: ").append(this.fBulletHasAutoNumber).append("\n");
113
		sb.append("autoNumberScheme: ").append(this.autoNumberScheme).append("\n");
114
		sb.append("autoNumberStartNumber: ").append(this.autoNumberStartNumber).append("\n");
115
		return sb.toString();
116
	}
117
}
(-)src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java (-2 / +2 lines)
Lines 169-175 Link Here
169
                    TextBytesAtom tba = (TextBytesAtom) records[i + 1];
169
                    TextBytesAtom tba = (TextBytesAtom) records[i + 1];
170
                    trun = new TextRun(tha, tba, stpa);
170
                    trun = new TextRun(tha, tba, stpa);
171
                } else if (records[i + 1].getRecordType() == 4001l) {
171
                } else if (records[i + 1].getRecordType() == 4001l) {
172
                    // StyleTextPropAtom - Safe to ignore
172
                	stpa = (StyleTextPropAtom) records[i + 1];
173
                } else if (records[i + 1].getRecordType() == 4010l) {
173
                } else if (records[i + 1].getRecordType() == 4010l) {
174
                    // TextSpecInfoAtom - Safe to ignore
174
                    // TextSpecInfoAtom - Safe to ignore
175
                } else {
175
                } else {
Lines 177-183 Link Here
177
                }
177
                }
178
178
179
                if (trun != null) {
179
                if (trun != null) {
180
                    ArrayList lst = new ArrayList();
180
                    List<Record> lst = new ArrayList<Record>();
181
                    for (int j = i; j < records.length; j++) {
181
                    for (int j = i; j < records.length; j++) {
182
                        if(j > i && records[j] instanceof TextHeaderAtom) break;
182
                        if(j > i && records[j] instanceof TextHeaderAtom) break;
183
                        lst.add(records[j]);
183
                        lst.add(records[j]);
(-)src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java (+125 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
package org.apache.poi.hslf.usermodel;
19
20
import java.util.List;
21
22
import junit.framework.TestCase;
23
24
import org.apache.poi.hslf.model.Slide;
25
import org.apache.poi.hslf.model.TextRun;
26
import org.apache.poi.hslf.model.textproperties.TextPFException9;
27
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
28
import org.apache.poi.hslf.record.EscherTextboxWrapper;
29
import org.apache.poi.hslf.record.StyleTextProp9Atom;
30
import org.apache.poi.hslf.record.StyleTextPropAtom;
31
import org.apache.poi.hslf.record.TextAutoNumberSchemeEnum;
32
import org.apache.poi.POIDataSamples;
33
34
35
/**
36
 * Test that checks numbered list functionality.
37
 * if a paragraph has autonumber ()
38
 * @see http://social.msdn.microsoft.com/Forums/mr-IN/os_binaryfile/thread/650888db-fabd-4b95-88dc-f0455f6e2d28
39
 * 
40
 * @author Alex Nikiforov [mailto:anikif@gmail.com]
41
 */
42
public final class TestNumberedList2 extends TestCase {
43
    private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
44
45
	protected void setUp() throws Exception {
46
	}
47
48
	public void testNumberedList() throws Exception {
49
		SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("numbers2.ppt"));
50
		assertTrue("No Exceptions while reading file", true);
51
52
		final Slide[] slides = ppt.getSlides();
53
		assertEquals(2, slides.length);
54
		checkSlide0(slides[0]);
55
		checkSlide1(slides[1]);
56
	}
57
	private void checkSlide0(final Slide s) {
58
		final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
59
		assertNotNull(numberedListArray);
60
		assertEquals(2, numberedListArray.length);
61
		final StyleTextProp9Atom numberedListInfoForTextBox0 = numberedListArray[0];
62
		final StyleTextProp9Atom numberedListInfoForTextBox1 = numberedListArray[1];
63
		assertNotNull(numberedListInfoForTextBox0);
64
		assertNotNull(numberedListInfoForTextBox1);
65
		final TextPFException9[] autoNumbersOfTextBox0 = numberedListInfoForTextBox0.getAutoNumberTypes();
66
		assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getfBulletHasAutoNumber());
67
		assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getAutoNumberStartNumber());//Default value = 1 will be used 
68
		assertTrue(TextAutoNumberSchemeEnum.ANM_ArabicPeriod == autoNumbersOfTextBox0[0].getAutoNumberScheme());
69
		final TextPFException9[] autoNumbersOfTextBox1 = numberedListInfoForTextBox1.getAutoNumberTypes();
70
		assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox1[0].getfBulletHasAutoNumber());
71
		assertEquals(Short.valueOf((short)6), autoNumbersOfTextBox1[0].getAutoNumberStartNumber());//Default value = 1 will be used 
72
		assertTrue(TextAutoNumberSchemeEnum.ANM_ArabicPeriod == autoNumbersOfTextBox1[0].getAutoNumberScheme());
73
74
		
75
		TextRun[] textRuns = s.getTextRuns();
76
		assertEquals(2, textRuns.length);
77
78
		RichTextRun textRun = textRuns[0].getRichTextRuns()[0];
79
		assertEquals("List Item One\rList Item Two\rList Item Three", textRun.getRawText());
80
		assertEquals(1, textRuns[0].getRichTextRuns().length);
81
		assertTrue(textRun.isBullet());
82
83
		assertEquals("A numbered list may start at any number \rThis would be used as a continuation list on another page\rThis list should start with #6", textRuns[1].getRawText());
84
		
85
		final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
86
		assertEquals(textRuns.length, styleAtoms.length);
87
		checkSingleRunWrapper(44, styleAtoms[0]);
88
		checkSingleRunWrapper(130, styleAtoms[1]);
89
	}
90
	private void checkSlide1(final Slide s) {
91
		final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
92
		assertNotNull(numberedListArray);
93
		assertEquals(1, numberedListArray.length);
94
		final StyleTextProp9Atom numberedListInfoForTextBox = numberedListArray[0];
95
		assertNotNull(numberedListInfoForTextBox);
96
		final TextPFException9[] autoNumbersOfTextBox = numberedListInfoForTextBox.getAutoNumberTypes();
97
		assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox[0].getfBulletHasAutoNumber());
98
		assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox[0].getAutoNumberStartNumber());//Default value = 1 will be used 
99
		assertTrue(TextAutoNumberSchemeEnum.ANM_ArabicPeriod == autoNumbersOfTextBox[0].getAutoNumberScheme());
100
			
101
		TextRun[] textRuns = s.getTextRuns();
102
		assertEquals(3, textRuns.length);
103
104
		RichTextRun textRun = textRuns[0].getRichTextRuns()[0];
105
		assertEquals("Bulleted list\rMore bullets", textRun.getRawText());
106
		assertEquals(1, textRuns[0].getRichTextRuns().length);
107
		assertTrue(textRun.isBullet());
108
109
		assertEquals("Numbered list between two bulleted lists\rSecond numbered list item", textRuns[1].getRawText());
110
		assertEquals("Second bulleted list � should appear after numbered list\rMore bullets", textRuns[2].getRawText());
111
		
112
		final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
113
		assertEquals(textRuns.length, styleAtoms.length);
114
		checkSingleRunWrapper(27, styleAtoms[0]);
115
		checkSingleRunWrapper(67, styleAtoms[1]);
116
		checkSingleRunWrapper(70, styleAtoms[2]);
117
	}
118
	private void checkSingleRunWrapper(final int exceptedLength, final EscherTextboxWrapper wrapper) {
119
		final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
120
		final List<TextPropCollection> textProps = styleTextPropAtom.getCharacterStyles();
121
		assertEquals(1, textProps.size());
122
		final TextPropCollection[] props = (TextPropCollection[]) textProps.toArray(new TextPropCollection[textProps.size()]);
123
		assertEquals(exceptedLength, props[0].getCharactersCovered());
124
	}
125
}
(-)src/scratchpad/src/org/apache/poi/hslf/record/StyleTextProp9Atom.java (+128 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
package org.apache.poi.hslf.record;
19
20
import java.io.IOException;
21
import java.io.OutputStream;
22
import java.util.LinkedList;
23
import java.util.List;
24
25
import org.apache.poi.hslf.model.textproperties.TextPFException9;
26
import org.apache.poi.util.LittleEndian;
27
28
/**
29
 * The atom record that specifies additional text formatting.
30
 *
31
 * @author Alex Nikiforov [mailto:anikif@gmail.com]
32
 */
33
public final class StyleTextProp9Atom extends RecordAtom {
34
	private final TextPFException9[] autoNumberSchemes;
35
    /** Record header. */
36
    private byte[] header;
37
    /** Record data. */
38
    private byte[] data;
39
    private short version;
40
    private short recordId;
41
    private int length;
42
    
43
    /**
44
     * Constructs the link related atom record from its
45
     *  source data.
46
     *
47
     * @param source the source data as a byte array.
48
     * @param start the start offset into the byte array.
49
     * @param len the length of the slice in the byte array.
50
     */
51
    protected StyleTextProp9Atom(byte[] source, int start, int len) {
52
        // Get the header.
53
    	final List<TextPFException9> schemes = new LinkedList<TextPFException9>();
54
        header = new byte[8];
55
        System.arraycopy(source,start, header,0,8);
56
        this.version  = LittleEndian.getShort(header, 0);
57
        this.recordId = LittleEndian.getShort(header, 2);
58
        this.length   = LittleEndian.getInt(header, 4);
59
        
60
        // Get the record data.
61
        data = new byte[len-8];
62
        System.arraycopy(source, start+8, data, 0, len-8);
63
        for (int i = 0; i < data.length; ) {
64
        	final TextPFException9 item = new TextPFException9(data, i);
65
        	schemes.add(item);
66
        	i += item.getRecordLength() + 8;//TextCFException9 + SIException
67
        	if (i >= data.length) {
68
        		break;
69
        	}
70
        }
71
        this.autoNumberSchemes = (TextPFException9[]) schemes.toArray(new TextPFException9[schemes.size()]);
72
    }
73
74
	/**
75
     * Gets the record type.
76
     * @return the record type.
77
     */
78
    public long getRecordType() { return this.recordId; }
79
80
    public short getVersion() {
81
		return version;
82
	}
83
84
	public int getLength() {
85
		return length;
86
	}
87
	public TextPFException9[] getAutoNumberTypes() {
88
		return this.autoNumberSchemes;
89
	}
90
91
	/**
92
     * Write the contents of the record back, so it can be written
93
     * to disk
94
     *
95
     * @param out the output stream to write to.
96
     * @throws java.io.IOException if an error occurs.
97
     */
98
    public void writeOut(OutputStream out) throws IOException {
99
        out.write(header);
100
        out.write(data);
101
    }
102
103
    /**
104
     * Update the text length
105
     *
106
     * @param size the text length
107
     */
108
    public void setTextSize(int size){
109
        LittleEndian.putInt(data, 0, size);
110
    }
111
112
    /**
113
     * Reset the content to one info run with the default values
114
     * @param size  the site of parent text
115
     */
116
    public void reset(int size){
117
        data = new byte[10];
118
        // 01 00 00 00
119
        LittleEndian.putInt(data, 0, size);
120
        // 01 00 00 00
121
        LittleEndian.putInt(data, 4, 1); //mask
122
        // 00 00
123
        LittleEndian.putShort(data, 8, (short)0); //langId
124
125
        // Update the size (header bytes 5-8)
126
        LittleEndian.putInt(header, 4, data.length);
127
    }
128
}
(-)src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java (-2 / +3 lines)
Lines 84-90 Link Here
84
    public static final Type OutlineTextRefAtom = new Type(3998,OutlineTextRefAtom.class);
84
    public static final Type OutlineTextRefAtom = new Type(3998,OutlineTextRefAtom.class);
85
    public static final Type TextHeaderAtom = new Type(3999,TextHeaderAtom.class);
85
    public static final Type TextHeaderAtom = new Type(3999,TextHeaderAtom.class);
86
    public static final Type TextCharsAtom = new Type(4000,TextCharsAtom.class);
86
    public static final Type TextCharsAtom = new Type(4000,TextCharsAtom.class);
87
    public static final Type StyleTextPropAtom = new Type(4001,StyleTextPropAtom.class);
87
    public static final Type StyleTextPropAtom = new Type(4001, StyleTextPropAtom.class);//0x0fa1 RT_StyleTextPropAtom
88
    public static final Type BaseTextPropAtom = new Type(4002,null);
88
    public static final Type BaseTextPropAtom = new Type(4002,null);
89
    public static final Type TxMasterStyleAtom = new Type(4003,TxMasterStyleAtom.class);
89
    public static final Type TxMasterStyleAtom = new Type(4003,TxMasterStyleAtom.class);
90
    public static final Type TxCFStyleAtom = new Type(4004,null);
90
    public static final Type TxCFStyleAtom = new Type(4004,null);
Lines 95-100 Link Here
95
    public static final Type TxSIStyleAtom = new Type(4009,null);
95
    public static final Type TxSIStyleAtom = new Type(4009,null);
96
    public static final Type TextSpecInfoAtom = new Type(4010, TextSpecInfoAtom.class);
96
    public static final Type TextSpecInfoAtom = new Type(4010, TextSpecInfoAtom.class);
97
    public static final Type DefaultRulerAtom = new Type(4011,null);
97
    public static final Type DefaultRulerAtom = new Type(4011,null);
98
    public static final Type StyleTextProp9Atom = new Type(4012, StyleTextProp9Atom.class); //0x0FAC RT_StyleTextProp9Atom
98
    public static final Type FontEntityAtom = new Type(4023,FontEntityAtom.class);
99
    public static final Type FontEntityAtom = new Type(4023,FontEntityAtom.class);
99
    public static final Type FontEmbeddedData = new Type(4024,null);
100
    public static final Type FontEmbeddedData = new Type(4024,null);
100
    public static final Type CString = new Type(4026,CString.class);
101
    public static final Type CString = new Type(4026,CString.class);
Lines 146-152 Link Here
146
    public static final Type ProgTags = new Type(5000,DummyPositionSensitiveRecordWithChildren.class);
147
    public static final Type ProgTags = new Type(5000,DummyPositionSensitiveRecordWithChildren.class);
147
    public static final Type ProgStringTag = new Type(5001,null);
148
    public static final Type ProgStringTag = new Type(5001,null);
148
    public static final Type ProgBinaryTag = new Type(5002,DummyPositionSensitiveRecordWithChildren.class);
149
    public static final Type ProgBinaryTag = new Type(5002,DummyPositionSensitiveRecordWithChildren.class);
149
    public static final Type BinaryTagData = new Type(5003,DummyPositionSensitiveRecordWithChildren.class);
150
    public static final Type BinaryTagData = new Type(5003, BinaryTagDataBlob.class);//0x138b RT_BinaryTagDataBlob
150
    public static final Type PrpublicintOptions = new Type(6000,null);
151
    public static final Type PrpublicintOptions = new Type(6000,null);
151
    public static final Type PersistPtrFullBlock = new Type(6001,PersistPtrHolder.class);
152
    public static final Type PersistPtrFullBlock = new Type(6001,PersistPtrHolder.class);
152
    public static final Type PersistPtrIncrementalBlock = new Type(6002,PersistPtrHolder.class);
153
    public static final Type PersistPtrIncrementalBlock = new Type(6002,PersistPtrHolder.class);
(-)src/scratchpad/src/org/apache/poi/hslf/model/Slide.java (-3 / +82 lines)
Lines 18-38 Link Here
18
package org.apache.poi.hslf.model;
18
package org.apache.poi.hslf.model;
19
19
20
import java.awt.Graphics2D;
20
import java.awt.Graphics2D;
21
import java.util.Vector;
21
import java.util.LinkedList;
22
import java.util.List;
22
23
23
import org.apache.poi.ddf.EscherContainerRecord;
24
import org.apache.poi.ddf.EscherContainerRecord;
24
import org.apache.poi.ddf.EscherDgRecord;
25
import org.apache.poi.ddf.EscherDgRecord;
25
import org.apache.poi.ddf.EscherDggRecord;
26
import org.apache.poi.ddf.EscherDggRecord;
27
import org.apache.poi.ddf.EscherRecord;
26
import org.apache.poi.ddf.EscherSpRecord;
28
import org.apache.poi.ddf.EscherSpRecord;
29
import org.apache.poi.ddf.UnknownEscherRecord;
30
import org.apache.poi.hslf.record.BinaryTagDataBlob;
31
import org.apache.poi.hslf.record.CString;
27
import org.apache.poi.hslf.record.ColorSchemeAtom;
32
import org.apache.poi.hslf.record.ColorSchemeAtom;
28
import org.apache.poi.hslf.record.Comment2000;
33
import org.apache.poi.hslf.record.Comment2000;
34
import org.apache.poi.hslf.record.EscherTextboxWrapper;
29
import org.apache.poi.hslf.record.HeadersFootersContainer;
35
import org.apache.poi.hslf.record.HeadersFootersContainer;
36
import org.apache.poi.hslf.record.PPDrawing;
30
import org.apache.poi.hslf.record.Record;
37
import org.apache.poi.hslf.record.Record;
31
import org.apache.poi.hslf.record.RecordContainer;
38
import org.apache.poi.hslf.record.RecordContainer;
32
import org.apache.poi.hslf.record.RecordTypes;
39
import org.apache.poi.hslf.record.RecordTypes;
33
import org.apache.poi.hslf.record.SlideAtom;
40
import org.apache.poi.hslf.record.SlideAtom;
41
import org.apache.poi.hslf.record.StyleTextProp9Atom;
34
import org.apache.poi.hslf.record.TextHeaderAtom;
42
import org.apache.poi.hslf.record.TextHeaderAtom;
35
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
43
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
44
import org.apache.poi.util.LittleEndian;
36
45
37
/**
46
/**
38
 * This class represents a slide in a PowerPoint Document. It allows
47
 * This class represents a slide in a PowerPoint Document. It allows
Lines 53-59 Link Here
53
	/**
62
	/**
54
	 * Constructs a Slide from the Slide record, and the SlideAtomsSet
63
	 * Constructs a Slide from the Slide record, and the SlideAtomsSet
55
	 *  containing the text.
64
	 *  containing the text.
56
	 * Initialises TextRuns, to provide easier access to the text
65
	 * Initializes TextRuns, to provide easier access to the text
57
	 *
66
	 *
58
	 * @param slide the Slide record we're based on
67
	 * @param slide the Slide record we're based on
59
	 * @param notes the Notes sheet attached to us
68
	 * @param notes the Notes sheet attached to us
Lines 72-78 Link Here
72
		// For the text coming in from the SlideAtomsSet:
81
		// For the text coming in from the SlideAtomsSet:
73
		// Build up TextRuns from pairs of TextHeaderAtom and
82
		// Build up TextRuns from pairs of TextHeaderAtom and
74
		//  one of TextBytesAtom or TextCharsAtom
83
		//  one of TextBytesAtom or TextCharsAtom
75
		Vector textRuns = new Vector();
84
		final List<TextRun> textRuns = new LinkedList<TextRun>();
76
		if(_atomSet != null) {
85
		if(_atomSet != null) {
77
			findTextRuns(_atomSet.getSlideRecords(),textRuns);
86
			findTextRuns(_atomSet.getSlideRecords(),textRuns);
78
		} else {
87
		} else {
Lines 476-479 Link Here
476
            _runs = tmp;
485
            _runs = tmp;
477
        }
486
        }
478
    }
487
    }
488
    protected EscherContainerRecord findFirstEscherContainerRecordOfType(short type, EscherContainerRecord parent) {
489
    	if (null == parent) { return null; }
490
		final List<EscherContainerRecord> children = parent.getChildContainers();
491
		for (EscherContainerRecord child : children) {
492
			if (type == child.getRecordId()) {
493
				return child;
494
			}
495
		}
496
		return null;
497
    }
498
    protected EscherContainerRecord[] findAllEscherContainerRecordOfType(short type, EscherContainerRecord parent) {
499
    	if (null == parent) { return new EscherContainerRecord[0]; }
500
		final List<EscherContainerRecord> children = parent.getChildContainers();
501
		final List<EscherContainerRecord> result = new LinkedList<EscherContainerRecord>();
502
		for (EscherContainerRecord child : children) {
503
			if (type == child.getRecordId()) {
504
				result.add(child);
505
			}
506
		}
507
		return (EscherContainerRecord[]) result.toArray(new EscherContainerRecord[result.size()]);
508
    }
509
510
    protected Record buildFromUnknownEscherRecord(UnknownEscherRecord unknown) {
511
		byte[] bingo = unknown.getData();
512
		byte[] restoredRecord = new byte[8 + bingo.length];
513
		System.arraycopy(bingo, 0, restoredRecord, 8, bingo.length);
514
		short recordVersion = unknown.getVersion();
515
		short recordId = unknown.getRecordId();
516
		int recordLength = unknown.getRecordSize();
517
		LittleEndian.putShort(restoredRecord, 0, recordVersion);
518
		LittleEndian.putShort(restoredRecord, 2, recordId);
519
		LittleEndian.putInt(restoredRecord, 4, recordLength);
520
		return Record.createRecordForType(recordId, restoredRecord, 0, restoredRecord.length);
521
    }
522
    /** This will return an atom per TextBox, so if the page has two text boxes the method should return two atoms. */
523
    public StyleTextProp9Atom[] getNumberedListInfo() {
524
    	final List<StyleTextProp9Atom> result = new LinkedList<StyleTextProp9Atom>();
525
    	PPDrawing drawing = this.getPPDrawing();
526
    	EscherRecord[] escherRecords = drawing.getEscherRecords();
527
    	for (EscherRecord escherRecord : escherRecords) {
528
			if (escherRecord instanceof EscherContainerRecord && (short)0xf002 == escherRecord.getRecordId()) {
529
				EscherContainerRecord escherContainerF002 = (EscherContainerRecord) escherRecord;
530
				final EscherContainerRecord escherContainerF003 = findFirstEscherContainerRecordOfType((short)0xf003, escherContainerF002);
531
				final EscherContainerRecord[] escherContainersF004 = findAllEscherContainerRecordOfType((short)0xf004, escherContainerF003);
532
				for (EscherContainerRecord containerF004 : escherContainersF004) {
533
					final EscherContainerRecord escherContainerF011 = findFirstEscherContainerRecordOfType((short)0xf011, containerF004);
534
					if (null == escherContainerF011) { continue; }
535
					final EscherContainerRecord escherContainer1388 = findFirstEscherContainerRecordOfType((short)0x1388, escherContainerF011);
536
					if (null == escherContainer1388) { continue; }
537
					final EscherContainerRecord escherContainer138A = findFirstEscherContainerRecordOfType((short)0x138A, escherContainer1388);
538
					if (null == escherContainer138A) { continue; }
539
					int size = escherContainer138A.getChildRecords().size();
540
					if (2 != size) { continue; }
541
					final Record r0 = buildFromUnknownEscherRecord((UnknownEscherRecord) escherContainer138A.getChild(0));
542
					final Record r1 = buildFromUnknownEscherRecord((UnknownEscherRecord) escherContainer138A.getChild(1));
543
					if (!(r0 instanceof CString)) { continue; }
544
					if (!("___PPT9".equals(((CString) r0).getText()))) { continue; };
545
					if (!(r1 instanceof BinaryTagDataBlob )) { continue; }
546
					final BinaryTagDataBlob blob = (BinaryTagDataBlob) r1;
547
					if (1 != blob.getChildRecords().length) { continue; }
548
					result.add((StyleTextProp9Atom) blob.findFirstOfType(0x0FACL));
549
				}
550
			}
551
    	}
552
    	return (StyleTextProp9Atom[]) result.toArray(new StyleTextProp9Atom[result.size()]);
553
    }
554
555
	public EscherTextboxWrapper[] getTextboxWrappers() {
556
		return this.getPPDrawing().getTextboxWrappers();
557
	}
479
}
558
}
(-)src/scratchpad/src/org/apache/poi/hslf/record/EscherTextboxWrapper.java (+8 lines)
Lines 36-41 Link Here
36
	private EscherTextboxRecord _escherRecord;
36
	private EscherTextboxRecord _escherRecord;
37
	private long _type;
37
	private long _type;
38
	private int shapeId;
38
	private int shapeId;
39
	private StyleTextPropAtom styleTextPropAtom;
39
40
40
	/**
41
	/**
41
	 * Returns the underlying DDF Escher Record
42
	 * Returns the underlying DDF Escher Record
Lines 52-57 Link Here
52
		// Find the child records in the escher data
53
		// Find the child records in the escher data
53
		byte[] data = _escherRecord.getData();
54
		byte[] data = _escherRecord.getData();
54
		_children = Record.findChildRecords(data,0,data.length);
55
		_children = Record.findChildRecords(data,0,data.length);
56
		for (Record r : this._children) {
57
			if (r instanceof StyleTextPropAtom) { this.styleTextPropAtom = (StyleTextPropAtom) r; }
58
		}
55
	}
59
	}
56
60
57
	/**
61
	/**
Lines 104-107 Link Here
104
	public void setShapeId(int id){
108
	public void setShapeId(int id){
105
		shapeId = id;
109
		shapeId = id;
106
	}
110
	}
111
112
	public StyleTextPropAtom getStyleTextPropAtom() {
113
		return styleTextPropAtom;
114
	}
107
}
115
}
(-)src/scratchpad/src/org/apache/poi/hslf/record/BinaryTagDataBlob.java (+67 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
package org.apache.poi.hslf.record;
19
20
import org.apache.poi.util.LittleEndian;
21
import java.io.IOException;
22
import java.io.OutputStream;
23
24
/**
25
 * If we come across a record we know has children of (potential)
26
 *  interest, but where the record itself is boring, but where other
27
 *  records may care about where this one lives, we create one
28
 *  of these. It allows us to get at the children, and track where on
29
 *  disk this is, but not much else.
30
 * Anything done using this should quite quickly be transitioned to its
31
 *  own proper record class!
32
 *
33
 * @author Nick Burch
34
 */
35
36
public final class BinaryTagDataBlob extends PositionDependentRecordContainer
37
{
38
	private byte[] _header;
39
	private long _type;
40
41
	/**
42
	 * Create a new holder for a boring record with children, but with
43
	 *  position dependent characteristics
44
	 */
45
	protected BinaryTagDataBlob(byte[] source, int start, int len) {
46
		// Just grab the header, not the whole contents
47
		_header = new byte[8];
48
		System.arraycopy(source,start,_header,0,8);
49
		_type = LittleEndian.getUShort(_header,2);
50
51
		// Find our children
52
		_children = Record.findChildRecords(source,start+8,len-8);
53
	}
54
55
	/**
56
	 * Return the value we were given at creation
57
	 */
58
	public long getRecordType() { return _type; }
59
60
	/**
61
	 * Write the contents of the record back, so it can be written
62
	 *  to disk
63
	 */
64
	public void writeOut(OutputStream out) throws IOException {
65
		writeOut(_header[0],_header[1],_type,_children,out);
66
	}
67
}
(-)src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java (+128 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
package org.apache.poi.hslf.usermodel;
19
20
import java.util.List;
21
22
import junit.framework.TestCase;
23
24
import org.apache.poi.hslf.model.Slide;
25
import org.apache.poi.hslf.model.TextRun;
26
import org.apache.poi.hslf.model.textproperties.TextPFException9;
27
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
28
import org.apache.poi.hslf.record.EscherTextboxWrapper;
29
import org.apache.poi.hslf.record.StyleTextProp9Atom;
30
import org.apache.poi.hslf.record.StyleTextPropAtom;
31
import org.apache.poi.hslf.record.TextAutoNumberSchemeEnum;
32
import org.apache.poi.POIDataSamples;
33
34
35
/**
36
 * Test that checks numbered list functionality.
37
 * 
38
 * @author Alex Nikiforov [mailto:anikif@gmail.com]
39
 */
40
public final class TestNumberedList extends TestCase {
41
    private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
42
43
	protected void setUp() throws Exception {
44
	}
45
46
	public void testNumberedList() throws Exception {
47
		SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("numbers.ppt"));
48
		assertTrue("No Exceptions while reading file", true);
49
50
		final Slide[] slides = ppt.getSlides();
51
		assertEquals(2, slides.length);
52
		checkSlide0(slides[0]);
53
		checkSlide1(slides[1]);
54
	}
55
	private void checkSlide0(final Slide s) {
56
		final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
57
		assertNotNull(numberedListArray);
58
		assertEquals(1, numberedListArray.length);//Just one text box here
59
		final StyleTextProp9Atom numberedListInfo = numberedListArray[0];
60
		assertNotNull(numberedListInfo);
61
		final TextPFException9[] autoNumbers = numberedListInfo.getAutoNumberTypes();
62
		assertNotNull(autoNumbers);
63
		assertEquals(4, autoNumbers.length);
64
		assertTrue(4 == autoNumbers[0].getAutoNumberStartNumber());
65
		assertNull(autoNumbers[1].getAutoNumberStartNumber());
66
		assertTrue(3 == autoNumbers[2].getAutoNumberStartNumber());
67
		assertTrue(TextAutoNumberSchemeEnum.ANM_ArabicPeriod == autoNumbers[0].getAutoNumberScheme());
68
		assertNull(autoNumbers[1].getAutoNumberScheme());
69
		assertTrue(TextAutoNumberSchemeEnum.ANM_AlphaLcParenRight == autoNumbers[2].getAutoNumberScheme());
70
			
71
		TextRun[] textRuns = s.getTextRuns();
72
		assertEquals(2, textRuns.length);
73
74
		RichTextRun textRun = textRuns[0].getRichTextRuns()[0];
75
		assertEquals("titTe", textRun.getRawText());
76
		assertEquals(1, textRuns[0].getRichTextRuns().length);
77
		assertFalse(textRun.isBullet());
78
79
		assertEquals("This is a text placeholder that \rfollows the design pattern\rJust a test\rWithout any paragraph\rSecond paragraph first line c) ;\rSecond paragraph second line d) . \r", textRuns[1].getRawText());
80
		
81
		final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
82
		assertEquals(textRuns.length, styleAtoms.length);
83
		final EscherTextboxWrapper wrapper =  styleAtoms[1];
84
		final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
85
		final List<TextPropCollection> textProps = styleTextPropAtom.getCharacterStyles();
86
		final TextPropCollection[] props = (TextPropCollection[]) textProps.toArray(new TextPropCollection[textProps.size()]);
87
		assertEquals(60, props[0].getCharactersCovered());
88
		assertEquals(34, props[1].getCharactersCovered());
89
		assertEquals(68, props[2].getCharactersCovered());
90
	}
91
	private void checkSlide1(final Slide s) {
92
		final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
93
		assertNotNull(numberedListArray);
94
		assertEquals(1, numberedListArray.length);//Just one text box here
95
		final StyleTextProp9Atom numberedListInfo = numberedListArray[0];
96
		assertNotNull(numberedListInfo);
97
		final TextPFException9[] autoNumbers = numberedListInfo.getAutoNumberTypes();
98
		assertNotNull(autoNumbers);
99
		assertEquals(4, autoNumbers.length);
100
		assertTrue(9 == autoNumbers[0].getAutoNumberStartNumber());
101
		assertNull(autoNumbers[1].getAutoNumberStartNumber());
102
		assertTrue(3 == autoNumbers[2].getAutoNumberStartNumber());
103
		assertTrue(TextAutoNumberSchemeEnum.ANM_ArabicParenRight == autoNumbers[0].getAutoNumberScheme());
104
		assertNull(autoNumbers[1].getAutoNumberScheme());
105
		assertTrue(TextAutoNumberSchemeEnum.ANM_AlphaUcPeriod == autoNumbers[2].getAutoNumberScheme());
106
107
		final TextRun[] textRuns = s.getTextRuns();
108
		assertEquals(2, textRuns.length);
109
110
		RichTextRun textRun = textRuns[0].getRichTextRuns()[0];
111
		assertEquals("Second Slide Title", textRun.getRawText());
112
		assertEquals(1, textRuns[0].getRichTextRuns().length);
113
		assertFalse(textRun.isBullet());
114
115
		assertEquals("This is a text placeholder that \rfollows the design pattern\rJust a test\rWithout any paragraph\rSecond paragraph first line c) ;\rSecond paragraph second line d) . \r", textRuns[1].getRawText());
116
		
117
		final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
118
		assertEquals(textRuns.length, styleAtoms.length);
119
		final EscherTextboxWrapper wrapper =  styleAtoms[1];
120
		final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
121
		final List<TextPropCollection> textProps = styleTextPropAtom.getCharacterStyles();
122
		
123
		final TextPropCollection[] props = (TextPropCollection[]) textProps.toArray(new TextPropCollection[textProps.size()]);
124
		assertEquals(33, props[0].getCharactersCovered());
125
		assertEquals(61, props[1].getCharactersCovered());
126
		assertEquals(68, props[2].getCharactersCovered());
127
	}
128
}

Return to bug 53979