public void TestParagraphPropertiesOtherThanBoolProperties() { using (Stream sIn = new FileStream(TESTFILE_DIR + "ParagraphPropertiesOtherThanBoolProperties.xml", FileMode.Open)) { DocXReaderTestWriter writerOut = new DocXReaderTestWriter(null); ParsingContext context = new ParsingContext(); context.StyleSheet = new StyleSheet(); pPr_Handler objectConsumer = new pPr_Handler(context); Helper_ParseFileIntoConsumer(sIn, writerOut, objectConsumer); Assert.IsTrue(objectConsumer.HasNonDocElements(), "pPr should generate a nondoc element"); Queue<object> nonDocs = objectConsumer.GetNonDocElements(); Assert.AreEqual(1, nonDocs.Count, "pPr should generate 1 nondoc element"); FCSFormatting fmt = nonDocs.Dequeue() as FCSFormatting; Assert.IsNotNull(fmt); Assert.IsNotNull(fmt.CharacterProperties, "Not essential but may be assumed elsewhere in code"); ParagraphProperties pProps = fmt.ParagraphProperties; Assert.IsNotNull(pProps); Assert.AreEqual( 3, pProps.OutlineLevel); Assert.AreEqual(100, pProps.IndentLeft); Assert.AreEqual(200, pProps.IndentRight); Assert.AreEqual(300, pProps.Hanging); // NOTE That this is a contrived example! Assert.AreEqual(400, pProps.IndentFirst); Assert.AreEqual( 50, pProps.SpaceBefore); Assert.AreEqual( 70, pProps.SpaceAfter); Assert.AreEqual( 90, pProps.LineSpacing); Assert.AreEqual("HereBeDragons", pProps.StyleId); Assert.IsTrue(pProps.ParaAlignment == ParagraphProperties.AlignmentStyles.Centre); // TODO a couple of more tricky properties // Assert.AreEqual(2, pProps.Level); - List level is in the numbering and needs to be pulled up here // DirectAccessMember OptionalValue<KashidaJustificationPercentages> KashidaJustificationAmount; // DirectAccessMember OptionalValue<FontAlignments> FontAlignment; } }
public void TestParagraphPropertiesWithSimpleList() { using (Stream sIn = new FileStream(TESTFILE_DIR + "ParagraphPropertiesSimpleList.xml", FileMode.Open)) { DocXReaderTestWriter writerOut = new DocXReaderTestWriter(null); pPr_Handler objectConsumer = new pPr_Handler(null); Helper_ParseFileIntoConsumer(sIn, writerOut, objectConsumer); Assert.IsTrue(objectConsumer.HasNonDocElements(), "pPr should generate a nondoc element"); Queue<object> nonDocs = objectConsumer.GetNonDocElements(); Assert.AreEqual(1, nonDocs.Count, "pPr should generate 1 nondoc element"); FCSFormatting fmt = nonDocs.Dequeue() as FCSFormatting; Assert.IsNotNull(fmt); Assert.IsNotNull(fmt.CharacterProperties, "Not essential but may be assumed elsewhere in code"); ParagraphProperties pProps = fmt.ParagraphProperties; Assert.IsNotNull(pProps); Assert.AreEqual(2, pProps.NumberingProperties.NumberingLevelRef); Assert.AreEqual(3, pProps.NumberingProperties.NumberingDefinitionRef); } }
public void TestParagraphPropertiesAllBoolFlagsOn() { using (Stream sIn = new FileStream(TESTFILE_DIR + "ParagraphPropertiesAllBoolFlagsOn.xml", FileMode.Open)) { DocXReaderTestWriter writerOut = new DocXReaderTestWriter(null); pPr_Handler objectConsumer = new pPr_Handler(null); Helper_ParseFileIntoConsumer(sIn, writerOut, objectConsumer); Assert.IsTrue(objectConsumer.HasNonDocElements(), "pPr should generate a nondoc element"); Queue<object> nonDocs = objectConsumer.GetNonDocElements(); Assert.AreEqual(1, nonDocs.Count, "pPr should generate 1 nondoc element"); FCSFormatting fmt = nonDocs.Dequeue() as FCSFormatting; Assert.IsNotNull(fmt); Assert.IsNotNull(fmt.CharacterProperties, "Not essential but may be assumed elsewhere in code"); ParagraphProperties pProps = fmt.ParagraphProperties; Assert.IsNotNull(pProps); Assert.IsTrue(pProps.NoAutoHyphenate); Assert.IsTrue(pProps.KeepIntact); Assert.IsTrue(pProps.KeepWithNext); Assert.IsTrue(pProps.BreakBeforePara); Assert.IsTrue(pProps.WidowOrOrphanControl); // Assert.IsTrue(pProps.NoWidowOrOrphanControl); // not sure we need both Assert.IsTrue(pProps.SuppressLineNumbersForThisParagraph); Assert.IsTrue(pProps.SpaceBeforeAuto); Assert.IsTrue(pProps.SpaceAfterAuto); // TODO revisit this for the following booleans //Assert.IsTrue(pProps.ParagraphAlwaysHidden); //Assert.IsTrue(pProps.SideBySide); //Assert.IsTrue(pProps.TreatLeftIndentAsRightForRightToLeftParagraphs); //Assert.IsTrue(pProps.TreatRightIndentAsLeftForRightToLeftParagraphs); //Assert.IsTrue(pProps.AutoAdjustRightIndent); //Assert.IsTrue(pProps.LineSpacingIsMultiple); //Assert.IsTrue(pProps.DisableSnapToGrid); //Assert.IsTrue(pProps.ReadsRightToLeft); //Assert.IsTrue(pProps.NoAsianCharacterWrapping); //Assert.IsTrue(pProps.NoAsianWordWrapping); //Assert.IsTrue(pProps.NoAsianOverflowPeriodAndComma); //Assert.IsTrue(pProps.AutoSpacingBetweenDoubleByteAndEnglish); //Assert.IsTrue(pProps.AutoSpacingBetweenDoubleByteAndNumbers); //Assert.IsTrue(pProps.CollapsedInPocketWord); } }