Пример #1
0
        private void OpenFooter(OXmlOpenFooterElement element)
        {
            CreateSectionProperties();
            //if (element.Header)
            //{
            //HeaderPart headerPart = _mainPart.AddNewPart<HeaderPart>();
            //OpenXmlCompositeElement header = new Header();
            //headerPart.Header = (Header)header;
            //string headerPartId = _mainPart.GetIdOfPart(headerPart);
            //_sectionProperties.AppendChild(new HeaderReference { Id = headerPartId, Type = element.HeaderType });
            //}
            //else
            //{
            FooterPart footerPart          = _mainPart.AddNewPart <FooterPart>();
            OpenXmlCompositeElement footer = new Footer();

            footerPart.Footer = (Footer)footer;
            string footerPartId = _mainPart.GetIdOfPart(footerPart);

            _sectionProperties.AppendChild(new FooterReference {
                Id = footerPartId, Type = element.FooterType
            });
            //}
            AddHeaderFooterNamespaceDeclaration((OpenXmlPartRootElement)footer);

            SetHeaderFooterProperties(element.FooterType);

            _element = footer;
            //_headerFooter = true;
            _currentElement = OXmlDocElementType.Footer;
        }
 public OXmlOpenFooterElement _Deserialize(BsonReader bsonReader, IBsonSerializationOptions options)
 {
     OXmlOpenFooterElement element = new OXmlOpenFooterElement();
     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() != "openfooter")
                     throw new PBException($"invalid Type {type} when deserialize OXmlOpenFooter");
                 break;
             case "footertype":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong FooterType value {bsonType}");
                 element.FooterType = bsonReader.ReadString().zParseEnum<HeaderFooterValues>();
                 break;
             default:
                 throw new PBException($"unknow OpenFooter value \"{name}\"");
         }
     }
     return element;
 }
Пример #3
0
        private OXmlElement CreateOpenFooter(BsonDocument element)
        {
            if (_headerFooter)
            {
                throw new PBException("header-footer cant contain nested header-footer");
            }
            OXmlOpenFooterElement openFooter = new OXmlOpenFooterElement();

            openFooter.FooterType = element.zGet("FooterType").zAsString().zTryParseEnum(HeaderFooterValues.Default);
            _headerFooter         = true;
            return(openFooter);
        }
Пример #4
0
        private void OpenFooter(OXmlOpenFooterElement element)
        {
            CreateSectionProperties();
            //if (element.Header)
            //{
            //HeaderPart headerPart = _mainPart.AddNewPart<HeaderPart>();
            //OpenXmlCompositeElement header = new Header();
            //headerPart.Header = (Header)header;
            //string headerPartId = _mainPart.GetIdOfPart(headerPart);
            //_sectionProperties.AppendChild(new HeaderReference { Id = headerPartId, Type = element.HeaderType });
            //}
            //else
            //{
            FooterPart footerPart = _mainPart.AddNewPart<FooterPart>();
            OpenXmlCompositeElement footer = new Footer();
            footerPart.Footer = (Footer)footer;
            string footerPartId = _mainPart.GetIdOfPart(footerPart);
            _sectionProperties.AppendChild(new FooterReference { Id = footerPartId, Type = element.FooterType });
            //}
            AddHeaderFooterNamespaceDeclaration((OpenXmlPartRootElement)footer);

            SetHeaderFooterProperties(element.FooterType);

            _element = footer;
            //_headerFooter = true;
            _currentElement = OXmlDocElementType.Footer;
        }
Пример #5
0
 private OXmlElement CreateOpenFooter(BsonDocument element)
 {
     if (_headerFooter)
         throw new PBException("header-footer cant contain nested header-footer");
     OXmlOpenFooterElement openFooter = new OXmlOpenFooterElement();
     openFooter.FooterType = element.zGet("FooterType").zAsString().zTryParseEnum(HeaderFooterValues.Default);
     _headerFooter = true;
     return openFooter;
 }