internal Footer(FooterPart part, DocX document, HeaderFooterValues type) { footer = part.Footer; footerPart = part; this.document = document; this.type = type; }
internal Header(HeaderPart part, DocX document, HeaderFooterValues type) { headerPart = part; header = part.Header; this.document = document; this.type = type; }
private Header AddHeader(HeaderFooterValues type) { var part = MainDocumentPart.AddNewPart <HeaderPart>(); var id = MainDocumentPart.GetIdOfPart(part); GenerateHeaderPartContent(part); GetBodySectionProperty().PrependChild(new HeaderReference() { Id = id, Type = type }); return(new Header(part, this, type)); }
protected override HeaderFooterReferenceType AddNew(HeaderFooterValues valueType) { var mainDocumentPart = Doc.MainDocumentPart; var pageFooterPart = mainDocumentPart.AddNewPart <FooterPart>(); var pageFooterPartId = mainDocumentPart.GetIdOfPart(pageFooterPart); var footer = new Footer(); pageFooterPart.Footer = footer; var wordFooter = new WordDocumentFooter(Doc, footer); Items.Add(Items.Count, wordFooter); ItemsByType.Add((int)valueType, wordFooter); return(new FooterReference { Id = pageFooterPartId, Type = valueType }); }
private void SetHeaderFooterProperties(HeaderFooterValues type) { if (!_sectionPropertiesTitlePage && type == HeaderFooterValues.First) { // TitlePage, <w:titlePg />, mandatory for first page header _sectionProperties.AppendChild(new TitlePage { Val = true }); _sectionPropertiesTitlePage = true; } if (!_settingsEvenAndOddHeaders && type == HeaderFooterValues.Even) { CreateSettings(); // option for even odd headers footers, WARNING this option dont work for google doc _settings.AppendChild(new EvenAndOddHeaders()); _settingsEvenAndOddHeaders = true; } }
protected override HeaderFooterReferenceType AddNew(HeaderFooterValues valueType) { var mainDocumentPart = Doc.MainDocumentPart; var pageHeaderPart = mainDocumentPart.AddNewPart <HeaderPart>(); var pageHeaderPartId = mainDocumentPart.GetIdOfPart(pageHeaderPart); var header = new Header { MCAttributes = new MarkupCompatibilityAttributes { Ignorable = "w14 w15 wp14" } }; header.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); header.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); header.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); header.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); header.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); header.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); header.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); header.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); header.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); header.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); header.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); header.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml"); header.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); header.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); header.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); header.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); pageHeaderPart.Header = header; var wordHeader = new WordDocumentHeader(Doc, header); Items.Add(Items.Count, wordHeader); ItemsByType.Add((int)valueType, wordHeader); return(new HeaderReference { Id = pageHeaderPartId, Type = valueType }); }
public void EnumValueTest() { EnumValue <M.BooleanValues> onoffEnum = new EnumValue <M.BooleanValues>(); Assert.False(onoffEnum.HasValue); Assert.Null(onoffEnum.InnerText); Assert.Null(onoffEnum.ToString()); onoffEnum.InnerText = "error value"; Assert.False(onoffEnum.HasValue); Assert.Equal("error value", onoffEnum.InnerText); Assert.Equal("error value", onoffEnum.ToString()); onoffEnum.InnerText = string.Empty; Assert.False(onoffEnum.HasValue); Assert.Equal(string.Empty, onoffEnum.InnerText); Assert.Equal(string.Empty, onoffEnum.ToString()); onoffEnum.InnerText = "on"; Assert.True(onoffEnum.HasValue); Assert.Equal("on", onoffEnum.InnerText); Assert.Equal(M.BooleanValues.On, onoffEnum.Value); Assert.Equal(M.BooleanValues.On, (M.BooleanValues)onoffEnum); Assert.Equal("on", onoffEnum.ToString()); var newEnum = new EnumValue <M.BooleanValues>(onoffEnum); Assert.True(newEnum.HasValue); newEnum.Value = M.BooleanValues.Off; Assert.True(newEnum.HasValue); Assert.Equal("off", newEnum.InnerText); Assert.Equal(M.BooleanValues.Off, newEnum.Value); Assert.Equal(M.BooleanValues.Off, (M.BooleanValues)newEnum); Assert.Equal("off", newEnum.ToString()); // the onoffEnum should not be changed. Assert.True(onoffEnum.HasValue); Assert.Equal("on", onoffEnum.InnerText); Assert.Equal(M.BooleanValues.On, onoffEnum.Value); Assert.Equal(M.BooleanValues.On, (M.BooleanValues)onoffEnum); Assert.Equal("on", onoffEnum.ToString()); // test special case - the enum can be empty string "" var truefalseEmpty = new EnumValue <xvml.BooleanEntryWithBlankValues>(xvml.BooleanEntryWithBlankValues.Empty); Assert.True(truefalseEmpty.HasValue); Assert.Equal(string.Empty, truefalseEmpty.InnerText); Assert.Equal(xvml.BooleanEntryWithBlankValues.Empty, truefalseEmpty.Value); Assert.Equal(xvml.BooleanEntryWithBlankValues.Empty, (xvml.BooleanEntryWithBlankValues)truefalseEmpty); Assert.Equal(string.Empty, truefalseEmpty.ToString()); truefalseEmpty = xvml.BooleanEntryWithBlankValues.T; Assert.True(truefalseEmpty.HasValue); Assert.Equal("t", truefalseEmpty.InnerText); Assert.Equal(xvml.BooleanEntryWithBlankValues.T, truefalseEmpty.Value); Assert.Equal(xvml.BooleanEntryWithBlankValues.T, (xvml.BooleanEntryWithBlankValues)truefalseEmpty); Assert.Equal("t", truefalseEmpty.ToString()); truefalseEmpty.InnerText = string.Empty; Assert.True(truefalseEmpty.HasValue); Assert.Equal(string.Empty, truefalseEmpty.InnerText); Assert.Equal(xvml.BooleanEntryWithBlankValues.Empty, truefalseEmpty.Value); Assert.Equal(xvml.BooleanEntryWithBlankValues.Empty, (xvml.BooleanEntryWithBlankValues)truefalseEmpty); Assert.Equal(string.Empty, truefalseEmpty.ToString()); // Clone constructor for EnumValue HeaderFooterValues validValue0 = HeaderFooterValues.Default; var objA = new EnumValue <HeaderFooterValues>(validValue0); var objB = new EnumValue <HeaderFooterValues>(objA); Assert.True(objA.HasValue); Assert.True(objB.HasValue); Assert.Equal("default", objA.InnerText); Assert.Equal("default", objB.InnerText); // Clone() for EnumValue. objA = new EnumValue <HeaderFooterValues>(validValue0); objB = (EnumValue <HeaderFooterValues>)objA.Clone(); Assert.True(objA.HasValue); Assert.True(objB.HasValue); Assert.Equal("default", objA.InnerText); Assert.Equal("default", objB.InnerText); }
private DqFooter Convert(IReadOnlyCollection <FooterReference> footerReferences, HeaderFooterValues headerFooter) => Convert(footerReferences.FirstOrDefault(fr => fr.Type == headerFooter));
public HeaderFooterRef(string id, HeaderFooterValues type) { this.Id = id; this.Type = type; }
protected abstract HeaderFooterReferenceType AddNew(HeaderFooterValues valueType);