public void TestAsciiStyling() { Range r = a.GetRange(); Paragraph p1 = r.GetParagraph(0); Paragraph p7 = r.GetParagraph(6); Assert.AreEqual(1, p1.NumCharacterRuns); Assert.AreEqual(1, p7.NumCharacterRuns); CharacterRun c1 = p1.GetCharacterRun(0); CharacterRun c7 = p7.GetCharacterRun(0); Assert.AreEqual("Times New Roman", c1.GetFontName()); // No Calibri Assert.AreEqual("Arial Black", c7.GetFontName()); Assert.AreEqual(20, c1.GetFontSize()); Assert.AreEqual(32, c7.GetFontSize()); // This document has 15 styles Assert.AreEqual(15, a.GetStyleSheet().NumStyles()); // Ensure none of the paragraphs refer to one that isn't there, // and none of their character Runs either for (int i = 0; i < a.GetRange().NumParagraphs; i++) { Paragraph p = a.GetRange().GetParagraph(i); Assert.IsTrue(p.GetStyleIndex() < 15); } }
public void TestSprmPJc() { Stream resourceAsStream = POIDataSamples.GetDocumentInstance() .OpenResourceAsStream("Bug49820.doc"); HWPFDocument hwpfDocument = new HWPFDocument(resourceAsStream); resourceAsStream.Close(); Assert.AreEqual(1, hwpfDocument.GetStyleSheet().GetParagraphStyle(8) .GetJustification()); hwpfDocument = Reload(hwpfDocument); Assert.AreEqual(1, hwpfDocument.GetStyleSheet().GetParagraphStyle(8) .GetJustification()); }
public void Test49820() { HWPFDocument doc = HWPFTestDataSamples.OpenSampleFile("Bug49820.doc"); Range documentRange = doc.GetRange(); StyleSheet styleSheet = doc.GetStyleSheet(); // JUnit asserts assertLevels(documentRange, styleSheet, 0, 0, 0); assertLevels(documentRange, styleSheet, 1, 1, 1); assertLevels(documentRange, styleSheet, 2, 2, 2); assertLevels(documentRange, styleSheet, 3, 3, 3); assertLevels(documentRange, styleSheet, 4, 4, 4); assertLevels(documentRange, styleSheet, 5, 5, 5); assertLevels(documentRange, styleSheet, 6, 6, 6); assertLevels(documentRange, styleSheet, 7, 7, 7); assertLevels(documentRange, styleSheet, 8, 8, 8); assertLevels(documentRange, styleSheet, 9, 9, 9); assertLevels(documentRange, styleSheet, 10, 9, 0); assertLevels(documentRange, styleSheet, 11, 9, 4); // output to console for (int i = 0; i < documentRange.NumParagraphs; i++) { Paragraph par = documentRange.GetParagraph(i); int styleLvl = styleSheet.GetParagraphStyle(par.GetStyleIndex()).GetLvl(); int parLvl = par.GetLvl(); Console.WriteLine("Style level: " + styleLvl + ", paragraph level: " + parLvl + ", text: " + par.Text); } }
public void TestSprmAIOOB() { HWPFDocument doc = HWPFTestDataSamples.OpenSampleFile("AIOOB-Tap.doc"); Range r = doc.GetRange(); StyleSheet styleSheet = doc.GetStyleSheet(); for (int x = 0; x < r.NumSections; x++) { Section s = r.GetSection(x); for (int y = 0; y < s.NumParagraphs; y++) { Paragraph paragraph = s.GetParagraph(y); // Console.WriteLine(paragraph.GetCharacterRun(0).Text); } } }