--- /dev/null
+/* ====================================================================\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================== */\r
+\r
+package org.apache.poi.hwpf.usermodel;\r
+\r
+import java.io.IOException;\r
+import junit.framework.TestCase;\r
+\r
+import org.apache.poi.hwpf.HWPFDocument;\r
+import org.apache.poi.hwpf.HWPFTestDataSamples;\r
+import org.apache.poi.hwpf.model.StyleSheet;\r
+\r
+public final class TestBug49820 extends TestCase {\r
+\r
+ public void test() throws IOException {\r
+ HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug49820.doc");\r
+ \r
+ Range documentRange = doc.getRange();\r
+ StyleSheet styleSheet = doc.getStyleSheet();\r
+ \r
+ // JUnit asserts\r
+ assertLevels(documentRange, styleSheet, 0, 0, 0);\r
+ assertLevels(documentRange, styleSheet, 1, 1, 1);\r
+ assertLevels(documentRange, styleSheet, 2, 2, 2);\r
+ assertLevels(documentRange, styleSheet, 3, 3, 3);\r
+ assertLevels(documentRange, styleSheet, 4, 4, 4);\r
+ assertLevels(documentRange, styleSheet, 5, 5, 5);\r
+ assertLevels(documentRange, styleSheet, 6, 6, 6);\r
+ assertLevels(documentRange, styleSheet, 7, 7, 7);\r
+ assertLevels(documentRange, styleSheet, 8, 8, 8);\r
+ assertLevels(documentRange, styleSheet, 9, 9, 9);\r
+ assertLevels(documentRange, styleSheet, 10, 9, 0);\r
+ assertLevels(documentRange, styleSheet, 11, 9, 4);\r
+ \r
+ // output to console\r
+ /*for (int i=0; i<documentRange.numParagraphs(); i++) {\r
+ Paragraph par = documentRange.getParagraph(i);\r
+ int styleLvl = styleSheet.getParagraphStyle(par.getStyleIndex()).getLvl();\r
+ int parLvl = par.getLvl();\r
+ System.out.println("Style level: " + styleLvl + ", paragraph level: " + parLvl + ", text: " + par.text());\r
+ }*/\r
+ }\r
+\r
+ private void assertLevels(Range documentRange, StyleSheet styleSheet, int parIndex, int expectedStyleLvl, int expectedParLvl) {\r
+ Paragraph par = documentRange.getParagraph(parIndex);\r
+ assertEquals(expectedStyleLvl, styleSheet.getParagraphStyle(par.getStyleIndex()).getLvl());\r
+ assertEquals(expectedParLvl, par.getLvl());\r
+ }\r
+}
\ No newline at end of file