Beispiel #1
0
        private OXmlStyleElement _Create()
        {
            OXmlStyleElement style = new OXmlStyleElement();

            style.Id   = _sourceElement.zGet("Id").zAsString();
            style.Name = _sourceElement.zGet("Name").zAsString();
            if (style.Name == null)
            {
                style.Name = style.Id;
            }
            style.StyleType          = _sourceElement.zGet("StyleType").zAsString().zTryParseEnum(StyleValues.Paragraph);
            style.Aliases            = _sourceElement.zGet("Aliases").zAsString();
            style.CustomStyle        = _sourceElement.zGet("CustomStyle").zAsBoolean();
            style.DefaultStyle       = _sourceElement.zGet("DefaultStyle").zAsBoolean();
            style.Locked             = _sourceElement.zGet("Locked").zAsNullableBoolean();
            style.SemiHidden         = _sourceElement.zGet("SemiHidden").zAsNullableBoolean();
            style.StyleHidden        = _sourceElement.zGet("StyleHidden").zAsNullableBoolean();
            style.UnhideWhenUsed     = _sourceElement.zGet("UnhideWhenUsed").zAsNullableBoolean();
            style.UIPriority         = _sourceElement.zGet("UIPriority").zAsNullableInt();
            style.LinkedStyle        = _sourceElement.zGet("LinkedStyle").zAsString();
            style.BasedOn            = _sourceElement.zGet("BasedOn").zAsString();
            style.NextParagraphStyle = _sourceElement.zGet("NextParagraphStyle").zAsString();

            CreateParagraphProperties();
            if (_paragraphProperties != null)
            {
                style.StyleParagraphProperties = _paragraphProperties;
            }

            return(style);
        }
Beispiel #2
0
        private void AddStyle(OXmlStyleElement element)
        {
            Styles styles = CreateStyles();
            Style style = new Style();

            style.StyleId = element.Id;
            style.StyleName = new StyleName() { Val = element.Name };
            style.Type = element.StyleType;

            if (element.Aliases != null)
                style.Aliases = new Aliases { Val = element.Aliases };

            style.CustomStyle = element.CustomStyle;
            style.Default = element.DefaultStyle;
            if (element.Locked != null)
                style.Locked = new Locked { Val = GetOnOffValue((bool)element.Locked) };
            if (element.SemiHidden != null)
                style.SemiHidden = new SemiHidden { Val = GetOnOffValue((bool)element.SemiHidden) };
            if (element.StyleHidden != null)
                style.StyleHidden = new StyleHidden { Val = GetOnOffValue((bool)element.StyleHidden) };
            if (element.UnhideWhenUsed != null)
                style.UnhideWhenUsed = new UnhideWhenUsed { Val = GetOnOffValue((bool)element.UnhideWhenUsed) };
            if (element.UIPriority != null)
                style.UIPriority = new UIPriority { Val = element.UIPriority };
            if (element.LinkedStyle != null)
                style.LinkedStyle = new LinkedStyle { Val = element.LinkedStyle };
            if (element.BasedOn != null)
                style.BasedOn = new BasedOn { Val = element.BasedOn };
            if (element.NextParagraphStyle != null)
                style.NextParagraphStyle = new NextParagraphStyle { Val = element.NextParagraphStyle };
            if (element.StyleParagraphProperties != null)
                style.StyleParagraphProperties = element.StyleParagraphProperties.ToStyleParagraphProperties();
            if (element.StyleRunProperties != null)
                style.StyleRunProperties = element.StyleRunProperties.ToStyleRunProperties();

            styles.Append(style);
        }
Beispiel #3
0
        private void AddStyle(OXmlStyleElement element)
        {
            Styles styles = CreateStyles();
            Style  style  = new Style();

            style.StyleId   = element.Id;
            style.StyleName = new StyleName()
            {
                Val = element.Name
            };
            style.Type = element.StyleType;

            if (element.Aliases != null)
            {
                style.Aliases = new Aliases {
                    Val = element.Aliases
                }
            }
            ;

            style.CustomStyle = element.CustomStyle;
            style.Default     = element.DefaultStyle;
            if (element.Locked != null)
            {
                style.Locked = new Locked {
                    Val = GetOnOffValue((bool)element.Locked)
                }
            }
            ;
            if (element.SemiHidden != null)
            {
                style.SemiHidden = new SemiHidden {
                    Val = GetOnOffValue((bool)element.SemiHidden)
                }
            }
            ;
            if (element.StyleHidden != null)
            {
                style.StyleHidden = new StyleHidden {
                    Val = GetOnOffValue((bool)element.StyleHidden)
                }
            }
            ;
            if (element.UnhideWhenUsed != null)
            {
                style.UnhideWhenUsed = new UnhideWhenUsed {
                    Val = GetOnOffValue((bool)element.UnhideWhenUsed)
                }
            }
            ;
            if (element.UIPriority != null)
            {
                style.UIPriority = new UIPriority {
                    Val = element.UIPriority
                }
            }
            ;
            if (element.LinkedStyle != null)
            {
                style.LinkedStyle = new LinkedStyle {
                    Val = element.LinkedStyle
                }
            }
            ;
            if (element.BasedOn != null)
            {
                style.BasedOn = new BasedOn {
                    Val = element.BasedOn
                }
            }
            ;
            if (element.NextParagraphStyle != null)
            {
                style.NextParagraphStyle = new NextParagraphStyle {
                    Val = element.NextParagraphStyle
                }
            }
            ;
            if (element.StyleParagraphProperties != null)
            {
                style.StyleParagraphProperties = element.StyleParagraphProperties.ToStyleParagraphProperties();
            }
            if (element.StyleRunProperties != null)
            {
                style.StyleRunProperties = element.StyleRunProperties.ToStyleRunProperties();
            }

            styles.Append(style);
        }
Beispiel #4
0
        private OXmlStyleElement _Create()
        {
            OXmlStyleElement style = new OXmlStyleElement();
            style.Id = _sourceElement.zGet("Id").zAsString();
            style.Name = _sourceElement.zGet("Name").zAsString();
            if (style.Name == null)
                style.Name = style.Id;
            style.StyleType = _sourceElement.zGet("StyleType").zAsString().zTryParseEnum(StyleValues.Paragraph);
            style.Aliases = _sourceElement.zGet("Aliases").zAsString();
            style.CustomStyle = _sourceElement.zGet("CustomStyle").zAsBoolean();
            style.DefaultStyle = _sourceElement.zGet("DefaultStyle").zAsBoolean();
            style.Locked = _sourceElement.zGet("Locked").zAsNullableBoolean();
            style.SemiHidden = _sourceElement.zGet("SemiHidden").zAsNullableBoolean();
            style.StyleHidden = _sourceElement.zGet("StyleHidden").zAsNullableBoolean();
            style.UnhideWhenUsed = _sourceElement.zGet("UnhideWhenUsed").zAsNullableBoolean();
            style.UIPriority = _sourceElement.zGet("UIPriority").zAsNullableInt();
            style.LinkedStyle = _sourceElement.zGet("LinkedStyle").zAsString();
            style.BasedOn = _sourceElement.zGet("BasedOn").zAsString();
            style.NextParagraphStyle = _sourceElement.zGet("NextParagraphStyle").zAsString();

            CreateParagraphProperties();
            if (_paragraphProperties != null)
                style.StyleParagraphProperties = _paragraphProperties;

            return style;
        }
 public OXmlStyleElement _Deserialize(BsonReader bsonReader, IBsonSerializationOptions options)
 {
     OXmlStyleElement element = new OXmlStyleElement();
     while (true)
     {
         BsonType bsonType = bsonReader.ReadBsonType();
         if (bsonType == BsonType.EndOfDocument)
             break;
         string name = bsonReader.ReadName();
         switch (name.ToLower())
         {
             case "type":
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong type value {bsonType}");
                 string type = bsonReader.ReadString();
                 if (type.ToLower() != "style")
                     throw new PBException($"invalid Type {type} when deserialize OXmlStyleElement");
                 break;
             case "id":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong Id value {bsonType}");
                 element.Id = bsonReader.ReadString();
                 break;
             case "name":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong Name value {bsonType}");
                 element.Name = bsonReader.ReadString();
                 break;
             case "styletype":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong StyleType value {bsonType}");
                 element.StyleType = bsonReader.ReadString().zParseEnum<StyleValues>(ignoreCase: true);
                 break;
             case "aliases":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong Aliases value {bsonType}");
                 element.Aliases = bsonReader.ReadString();
                 break;
             case "customstyle":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong CustomStyle value {bsonType}");
                 element.CustomStyle = bsonReader.ReadBoolean();
                 break;
             case "defaultstyle":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong DefaultStyle value {bsonType}");
                 element.DefaultStyle = bsonReader.ReadBoolean();
                 break;
             case "locked":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong Locked value {bsonType}");
                 element.Locked = bsonReader.ReadBoolean();
                 break;
             case "semihidden":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong SemiHidden value {bsonType}");
                 element.SemiHidden = bsonReader.ReadBoolean();
                 break;
             case "stylehidden":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong StyleHidden value {bsonType}");
                 element.StyleHidden = bsonReader.ReadBoolean();
                 break;
             case "unhidewhenused":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong UnhideWhenUsed value {bsonType}");
                 element.UnhideWhenUsed = bsonReader.ReadBoolean();
                 break;
             case "uipriority":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Int32)
                     throw new PBException($"wrong UIPriority value {bsonType}");
                 element.UIPriority = bsonReader.ReadInt32();
                 break;
             case "linkedstyle":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong LinkedStyle value {bsonType}");
                 element.LinkedStyle = bsonReader.ReadString();
                 break;
             case "basedon":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong BasedOn value {bsonType}");
                 element.BasedOn = bsonReader.ReadString();
                 break;
             case "nextparagraphstyle":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong NextParagraphStyle value {bsonType}");
                 element.NextParagraphStyle = bsonReader.ReadString();
                 break;
             case "styleparagraphproperties":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Document)
                     throw new PBException($"wrong StyleParagraphProperties value {bsonType}");
                 element.StyleParagraphProperties = ReadStyleParagraphProperties(bsonReader);
                 break;
             case "stylerunproperties":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Document)
                     throw new PBException($"wrong StyleRunProperties value {bsonType}");
                 element.StyleRunProperties = ReadStyleRunProperties(bsonReader);
                 break;
             default:
                 throw new PBException($"unknow Style value \"{name}\"");
         }
     }
     return element;
 }