private static void WriteSpacingBetweenLines(BsonWriter bsonWriter, OXmlSpacingBetweenLines element) { if (element.After != null) bsonWriter.WriteString("After", element.After); if (element.AfterAutoSpacing != null) bsonWriter.WriteBoolean("AfterAutoSpacing", (bool)element.AfterAutoSpacing); if (element.AfterLines != null) bsonWriter.WriteInt32("AfterLines", (int)element.AfterLines); if (element.Before != null) bsonWriter.WriteString("Before", element.Before); if (element.BeforeAutoSpacing != null) bsonWriter.WriteBoolean("BeforeAutoSpacing", (bool)element.BeforeAutoSpacing); if (element.BeforeLines != null) bsonWriter.WriteInt32("BeforeLines", (int)element.BeforeLines); if (element.Line != null) bsonWriter.WriteString("Line", element.Line); if (element.LineRule != null) bsonWriter.WriteString("LineRule", element.LineRule.ToString()); }
private void CreateSpacingBetweenLines(BsonDocument spp) { BsonDocument elementSpacingBetweenLines = spp.zGet("SpacingBetweenLines").zAsBsonDocument(); if (elementSpacingBetweenLines == null) return; //SpacingBetweenLines spacingBetweenLines = new SpacingBetweenLines { }; OXmlSpacingBetweenLines spacingBetweenLines = new OXmlSpacingBetweenLines(); //BsonValue v; //BsonValue v = elementSpacingBetweenLines.zGet("After"); //if (v != null) // // Spacing Below Paragraph, <w:spacing w:after>, 1 line = 240 // spacingBetweenLines.After = v.zAsString(); // Spacing Below Paragraph, <w:spacing w:after>, 1 line = 240 spacingBetweenLines.After = elementSpacingBetweenLines.zGet("After").zAsString(); //v = elementSpacingBetweenLines.zGet("AfterAutoSpacing"); //if (v != null) // // Automatically Determine Spacing Below Paragraph, <w:spacing w:afterAutospacing> // spacingBetweenLines.AfterAutoSpacing = new OnOffValue(v.zAsBoolean()); // Automatically Determine Spacing Below Paragraph, <w:spacing w:afterAutospacing> spacingBetweenLines.AfterAutoSpacing = elementSpacingBetweenLines.zGet("AfterAutoSpacing").zAsNullableBoolean(); //v = elementSpacingBetweenLines.zGet("AfterLines"); //if (v != null) // // Spacing Below Paragraph in Line Units, <w:spacing w:afterLines> // spacingBetweenLines.AfterLines = v.zAsInt(); // Spacing Below Paragraph in Line Units, <w:spacing w:afterLines> spacingBetweenLines.AfterLines = elementSpacingBetweenLines.zGet("AfterLines").zAsNullableInt(); //v = elementSpacingBetweenLines.zGet("Before"); //if (v != null) // // Spacing Above Paragraph, <w:spacing w:before>, 1 line = 240 // spacingBetweenLines.Before = v.zAsString(); // Spacing Above Paragraph, <w:spacing w:before>, 1 line = 240 spacingBetweenLines.Before = elementSpacingBetweenLines.zGet("Before").zAsString(); //v = elementSpacingBetweenLines.zGet("BeforeAutoSpacing"); //if (v != null) // // Automatically Determine Spacing Above Paragraph, <w:spacing w:beforeAutospacing> // spacingBetweenLines.BeforeAutoSpacing = new OnOffValue(v.zAsBoolean()); // Automatically Determine Spacing Above Paragraph, <w:spacing w:beforeAutospacing> spacingBetweenLines.BeforeAutoSpacing = elementSpacingBetweenLines.zGet("BeforeAutoSpacing").zAsNullableBoolean(); //v = elementSpacingBetweenLines.zGet("BeforeLines"); //if (v != null) // // Spacing Above Paragraph IN Line Units, <w:spacing w:beforeLines> // spacingBetweenLines.BeforeLines = v.zAsInt(); // Spacing Above Paragraph IN Line Units, <w:spacing w:beforeLines> spacingBetweenLines.BeforeLines = elementSpacingBetweenLines.zGet("BeforeLines").zAsNullableInt(); //v = elementSpacingBetweenLines.zGet("Line"); //if (v != null) // // Spacing Between Lines in Paragraph, <w:spacing w:line>, 1 line = 240 // spacingBetweenLines.Line = v.zAsString(); // Spacing Between Lines in Paragraph, <w:spacing w:line>, 1 line = 240 spacingBetweenLines.Line = elementSpacingBetweenLines.zGet("Line").zAsString(); //v = elementSpacingBetweenLines.zGet("LineRule"); //if (v != null) // // Type of Spacing Between Lines, <w:spacing w:lineRule>, Auto, Exact, AtLeast // spacingBetweenLines.LineRule = v.zAsString().zParseEnum<LineSpacingRuleValues>(true); // Type of Spacing Between Lines, <w:spacing w:lineRule>, Auto, Exact, AtLeast spacingBetweenLines.LineRule = elementSpacingBetweenLines.zGet("LineRule").zAsNullableEnum<LineSpacingRuleValues>(true); //_paragraphProperties.SpacingBetweenLines = spacingBetweenLines; _paragraphProperties.SpacingBetweenLines = spacingBetweenLines; }
private static OXmlSpacingBetweenLines ReadSpacingBetweenLines(BsonReader bsonReader) { bsonReader.ReadStartDocument(); OXmlSpacingBetweenLines value = new OXmlSpacingBetweenLines(); while (true) { BsonType bsonType = bsonReader.ReadBsonType(); if (bsonType == BsonType.EndOfDocument) break; string name = bsonReader.ReadName(); switch (name.ToLower()) { case "after": if (bsonType == BsonType.Null) break; if (bsonType != BsonType.String) throw new PBException($"wrong SpacingBetweenLines After value {bsonType}"); value.After = bsonReader.ReadString(); break; case "afterautospacing": if (bsonType == BsonType.Null) break; if (bsonType != BsonType.Boolean) throw new PBException($"wrong SpacingBetweenLines AfterAutoSpacing value {bsonType}"); value.AfterAutoSpacing = bsonReader.ReadBoolean(); break; case "afterlines": if (bsonType == BsonType.Null) break; if (bsonType != BsonType.Int32) throw new PBException($"wrong SpacingBetweenLines AfterLines value {bsonType}"); value.AfterLines = bsonReader.ReadInt32(); break; case "before": if (bsonType == BsonType.Null) break; if (bsonType != BsonType.String) throw new PBException($"wrong SpacingBetweenLines Before value {bsonType}"); value.Before = bsonReader.ReadString(); break; case "beforeautospacing": if (bsonType == BsonType.Null) break; if (bsonType != BsonType.Boolean) throw new PBException($"wrong SpacingBetweenLines BeforeAutoSpacing value {bsonType}"); value.BeforeAutoSpacing = bsonReader.ReadBoolean(); break; case "beforelines": if (bsonType == BsonType.Null) break; if (bsonType != BsonType.Int32) throw new PBException($"wrong SpacingBetweenLines BeforeLines value {bsonType}"); value.BeforeLines = bsonReader.ReadInt32(); break; case "line": if (bsonType == BsonType.Null) break; if (bsonType != BsonType.String) throw new PBException($"wrong SpacingBetweenLines Line value {bsonType}"); value.Line = bsonReader.ReadString(); break; default: throw new PBException($"unknow PageMargin value \"{name}\""); } } bsonReader.ReadEndDocument(); return value; }