Ejemplo n.º 1
0
        private void CreateParagraphProperties()
        {
            // StyleParagraphProperties :
            // AdjustRightIndent, AutoSpaceDE, AutoSpaceDN, BiDi, ContextualSpacing, FrameProperties, Indentation, Justification, KeepLines, KeepNext, Kinsoku, MirrorIndents, NumberingProperties,
            // OutlineLevel, OverflowPunctuation, PageBreakBefore, ParagraphBorders, ParagraphPropertiesChange, Shading, SnapToGrid, SuppressAutoHyphens, SuppressLineNumbers, SuppressOverlap, TextBoxTightWrap, TextDirection,
            // TopLinePunctuation, WidowControl, WordWrap


            //StyleParagraphProperties
            BsonDocument spp = _sourceElement.zGet("StyleParagraphProperties").zAsBsonDocument();

            if (spp == null)
            {
                return;
            }

            //_paragraphProperties = new StyleParagraphProperties();
            _paragraphProperties = new OXmlStyleParagraphProperties();

            CreateSpacingBetweenLines(spp);

            BsonValue v = spp.zGet("TextAlignment");

            if (v != null)
            {
                // TextAlignment, <w:textAlignment>, Top, Center, Baseline, Bottom, Auto
                //_paragraphProperties.TextAlignment = new TextAlignment { Val = v.zAsString().zParseEnum<VerticalTextAlignmentValues>(ignoreCase: true) };
                _paragraphProperties.TextAlignment = v.zAsString().zParseEnum <VerticalTextAlignmentValues>(ignoreCase: true);
            }
            CreateTabs(spp);

            //if (_spacingBetweenLines != null)
            //{
            //    _paragraphProperties = new StyleParagraphProperties();
            //    //if (_spacingBetweenLines != null)
            //    //    _paragraphProperties.SpacingBetweenLines = _spacingBetweenLines;
            //    //if (_textAlignment != null)
            //    //    _paragraphProperties.TextAlignment = _textAlignment;
            //}
        }
Ejemplo n.º 2
0
 private static void WriteStyleParagraphProperties(BsonWriter bsonWriter, OXmlStyleParagraphProperties element)
 {
     if (element.AdjustRightIndent != null)
         bsonWriter.WriteBoolean("AdjustRightIndent", (bool)element.AdjustRightIndent);
     if (element.AutoSpaceDE != null)
         bsonWriter.WriteBoolean("AutoSpaceDE", (bool)element.AutoSpaceDE);
     if (element.AutoSpaceDN != null)
         bsonWriter.WriteBoolean("AutoSpaceDN", (bool)element.AutoSpaceDN);
     if (element.BiDi != null)
         bsonWriter.WriteBoolean("BiDi", (bool)element.BiDi);
     if (element.ContextualSpacing != null)
         bsonWriter.WriteBoolean("ContextualSpacing", (bool)element.ContextualSpacing);
     if (element.Justification != null)
         bsonWriter.WriteString("Justification", element.Justification.ToString());
     if (element.KeepLines != null)
         bsonWriter.WriteBoolean("KeepLines", (bool)element.KeepLines);
     if (element.KeepNext != null)
         bsonWriter.WriteBoolean("KeepNext", (bool)element.KeepNext);
     if (element.Kinsoku != null)
         bsonWriter.WriteBoolean("Kinsoku", (bool)element.Kinsoku);
     if (element.MirrorIndents != null)
         bsonWriter.WriteBoolean("MirrorIndents", (bool)element.MirrorIndents);
     if (element.OutlineLevel != null)
         bsonWriter.WriteInt32("OutlineLevel", (int)element.OutlineLevel);
     if (element.OverflowPunctuation != null)
         bsonWriter.WriteBoolean("OverflowPunctuation", (bool)element.OverflowPunctuation);
     if (element.PageBreakBefore != null)
         bsonWriter.WriteBoolean("PageBreakBefore", (bool)element.PageBreakBefore);
     if (element.SnapToGrid != null)
         bsonWriter.WriteBoolean("SnapToGrid", (bool)element.SnapToGrid);
     if (element.SpacingBetweenLines != null)
     {
         bsonWriter.WriteStartDocument("SpacingBetweenLines");
         WriteSpacingBetweenLines(bsonWriter, element.SpacingBetweenLines);
         bsonWriter.WriteEndDocument();
     }
     if (element.SuppressAutoHyphens != null)
         bsonWriter.WriteBoolean("SuppressAutoHyphens", (bool)element.SuppressAutoHyphens);
     if (element.SuppressLineNumbers != null)
         bsonWriter.WriteBoolean("SuppressLineNumbers", (bool)element.SuppressLineNumbers);
     if (element.SuppressOverlap != null)
         bsonWriter.WriteBoolean("SuppressOverlap", (bool)element.SuppressOverlap);
     if (element.Tabs != null)
     {
         bsonWriter.WriteStartArray("Tabs");
         WriteTabs(bsonWriter, element.Tabs);
         bsonWriter.WriteEndArray();
     }
     if (element.TextAlignment != null)
         bsonWriter.WriteString("TextAlignment", element.TextAlignment.ToString());
     if (element.TextBoxTightWrap != null)
         bsonWriter.WriteString("TextBoxTightWrap", element.TextBoxTightWrap.ToString());
     if (element.TextDirection != null)
         bsonWriter.WriteString("TextDirection", element.TextDirection.ToString());
     if (element.TopLinePunctuation != null)
         bsonWriter.WriteBoolean("TopLinePunctuation", (bool)element.TopLinePunctuation);
     if (element.WidowControl != null)
         bsonWriter.WriteBoolean("WidowControl", (bool)element.WidowControl);
     if (element.WordWrap != null)
         bsonWriter.WriteBoolean("WordWrap", (bool)element.WordWrap);
 }
Ejemplo n.º 3
0
        private void CreateParagraphProperties()
        {
            // StyleParagraphProperties :
            // AdjustRightIndent, AutoSpaceDE, AutoSpaceDN, BiDi, ContextualSpacing, FrameProperties, Indentation, Justification, KeepLines, KeepNext, Kinsoku, MirrorIndents, NumberingProperties,
            // OutlineLevel, OverflowPunctuation, PageBreakBefore, ParagraphBorders, ParagraphPropertiesChange, Shading, SnapToGrid, SuppressAutoHyphens, SuppressLineNumbers, SuppressOverlap, TextBoxTightWrap, TextDirection,
            // TopLinePunctuation, WidowControl, WordWrap


            //StyleParagraphProperties
            BsonDocument spp = _sourceElement.zGet("StyleParagraphProperties").zAsBsonDocument();
            if (spp == null)
                return;

            //_paragraphProperties = new StyleParagraphProperties();
            _paragraphProperties = new OXmlStyleParagraphProperties();

            CreateSpacingBetweenLines(spp);

            BsonValue v = spp.zGet("TextAlignment");
            if (v != null)
                // TextAlignment, <w:textAlignment>, Top, Center, Baseline, Bottom, Auto
                //_paragraphProperties.TextAlignment = new TextAlignment { Val = v.zAsString().zParseEnum<VerticalTextAlignmentValues>(ignoreCase: true) };
                _paragraphProperties.TextAlignment = v.zAsString().zParseEnum<VerticalTextAlignmentValues>(ignoreCase: true);
            CreateTabs(spp);

            //if (_spacingBetweenLines != null)
            //{
            //    _paragraphProperties = new StyleParagraphProperties();
            //    //if (_spacingBetweenLines != null)
            //    //    _paragraphProperties.SpacingBetweenLines = _spacingBetweenLines;
            //    //if (_textAlignment != null)
            //    //    _paragraphProperties.TextAlignment = _textAlignment;
            //}
        }
Ejemplo n.º 4
0
 private static OXmlStyleParagraphProperties ReadStyleParagraphProperties(BsonReader bsonReader)
 {
     bsonReader.ReadStartDocument();
     OXmlStyleParagraphProperties value = new OXmlStyleParagraphProperties();
     while (true)
     {
         BsonType bsonType = bsonReader.ReadBsonType();
         if (bsonType == BsonType.EndOfDocument)
             break;
         string name = bsonReader.ReadName();
         switch (name.ToLower())
         {
             case "adjustrightindent":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties AdjustRightIndent value {bsonType}");
                 value.AdjustRightIndent = bsonReader.ReadBoolean();
                 break;
             case "autospacede":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties AutoSpaceDE value {bsonType}");
                 value.AutoSpaceDE = bsonReader.ReadBoolean();
                 break;
             case "autospacedn":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties AutoSpaceDN value {bsonType}");
                 value.AutoSpaceDN = bsonReader.ReadBoolean();
                 break;
             case "bidi":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties BiDi value {bsonType}");
                 value.BiDi = bsonReader.ReadBoolean();
                 break;
             case "contextualspacing":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties ContextualSpacing value {bsonType}");
                 value.ContextualSpacing = bsonReader.ReadBoolean();
                 break;
             case "justification":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong StyleParagraphProperties Justification value {bsonType}");
                 value.Justification = bsonReader.ReadString().zParseEnum<JustificationValues>(ignoreCase: true);
                 break;
             case "keeplines":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties KeepLines value {bsonType}");
                 value.KeepLines = bsonReader.ReadBoolean();
                 break;
             case "keepnext":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties KeepNext value {bsonType}");
                 value.KeepNext = bsonReader.ReadBoolean();
                 break;
             case "kinsoku":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties Kinsoku value {bsonType}");
                 value.Kinsoku = bsonReader.ReadBoolean();
                 break;
             case "mirrorindents":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties MirrorIndents value {bsonType}");
                 value.MirrorIndents = bsonReader.ReadBoolean();
                 break;
             case "outlinelevel":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Int32)
                     throw new PBException($"wrong StyleParagraphProperties OutlineLevel value {bsonType}");
                 value.OutlineLevel = bsonReader.ReadInt32();
                 break;
             case "overflowpunctuation":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties OverflowPunctuation value {bsonType}");
                 value.OverflowPunctuation = bsonReader.ReadBoolean();
                 break;
             case "pagebreakbefore":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties PageBreakBefore value {bsonType}");
                 value.PageBreakBefore = bsonReader.ReadBoolean();
                 break;
             case "snaptogrid":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties SnapToGrid value {bsonType}");
                 value.SnapToGrid = bsonReader.ReadBoolean();
                 break;
             case "spacingbetweenlines":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Document)
                     throw new PBException($"wrong StyleParagraphProperties SpacingBetweenLines value {bsonType}");
                 value.SpacingBetweenLines = ReadSpacingBetweenLines(bsonReader);
                 break;
             case "suppressautohyphens":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties SuppressAutoHyphens value {bsonType}");
                 value.SuppressAutoHyphens = bsonReader.ReadBoolean();
                 break;
             case "suppresslinenumbers":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties SuppressLineNumbers value {bsonType}");
                 value.SuppressLineNumbers = bsonReader.ReadBoolean();
                 break;
             case "suppressoverlap":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties SuppressOverlap value {bsonType}");
                 value.SuppressOverlap = bsonReader.ReadBoolean();
                 break;
             case "tabs":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Array)
                     throw new PBException($"wrong StyleParagraphProperties Tabs value {bsonType}");
                 value.Tabs = ReadTabs(bsonReader);
                 break;
             case "textalignment":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong StyleParagraphProperties TextAlignment value {bsonType}");
                 value.TextAlignment = bsonReader.ReadString().zParseEnum<VerticalTextAlignmentValues>(ignoreCase: true);
                 break;
             case "textboxtightwrap":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong StyleParagraphProperties TextBoxTightWrap value {bsonType}");
                 value.TextBoxTightWrap = bsonReader.ReadString().zParseEnum<TextBoxTightWrapValues>(ignoreCase: true);
                 break;
             case "textdirection":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong StyleParagraphProperties TextDirection value {bsonType}");
                 value.TextDirection = bsonReader.ReadString().zParseEnum<TextDirectionValues>(ignoreCase: true);
                 break;
             case "toplinepunctuation":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties TopLinePunctuation value {bsonType}");
                 value.TopLinePunctuation = bsonReader.ReadBoolean();
                 break;
             case "widowcontrol":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties WidowControl value {bsonType}");
                 value.WidowControl = bsonReader.ReadBoolean();
                 break;
             case "wordwrap":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleParagraphProperties WordWrap value {bsonType}");
                 value.WordWrap = bsonReader.ReadBoolean();
                 break;
             default:
                 throw new PBException($"unknow PageSize value \"{name}\"");
         }
     }
     bsonReader.ReadEndDocument();
     return value;
 }