Пример #1
0
        private void SetHeaderReference(ST_HdrFtr type, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtrRef ref1 = doc.Document.body.sectPr.AddNewHeaderReference();

            ref1.type = (type);
            ref1.id   = (doc.GetRelationId(wrapper));
        }
Пример #2
0
        private void SetHeaderReference(ST_HdrFtr type, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtrRef ref1 = doc.Document.body.sectPr.AddNewHeaderReference();

            ref1.type = (type);
            ref1.id   = (wrapper.GetPackageRelationship().Id);
        }
Пример #3
0
        private XmlSerializerNamespaces Commit(XWPFHeaderFooter wrapper)
        {
            //    XmlOptions xmlOptions = new XmlOptions(wrapper.DEFAULT_XML_OPTIONS);
            //    Dictionary<String, String> map = new Dictionary<String, String>();
            //    map.Put("http://schemas.Openxmlformats.org/officeDocument/2006/math", "m");
            //    map.Put("urn:schemas-microsoft-com:office:office", "o");
            //    map.Put("http://schemas.Openxmlformats.org/officeDocument/2006/relationships", "r");
            //    map.Put("urn:schemas-microsoft-com:vml", "v");
            //    map.Put("http://schemas.Openxmlformats.org/markup-compatibility/2006", "ve");
            //    map.Put("http://schemas.Openxmlformats.org/wordProcessingml/2006/main", "w");
            //    map.Put("urn:schemas-microsoft-com:office:word", "w10");
            //    map.Put("http://schemas.microsoft.com/office/word/2006/wordml", "wne");
            //    map.Put("http://schemas.Openxmlformats.org/drawingml/2006/wordProcessingDrawing", "wp");
            //    xmlOptions.SaveSuggestedPrefixes=(map);
            //    return xmlOptions;
            XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(new XmlQualifiedName[] {
                new XmlQualifiedName("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006"),
                new XmlQualifiedName("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
                new XmlQualifiedName("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"),
                new XmlQualifiedName("v", "urn:schemas-microsoft-com:vml"),
                new XmlQualifiedName("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"),
                new XmlQualifiedName("w10", "urn:schemas-microsoft-com:office:word"),
                new XmlQualifiedName("wne", "http://schemas.microsoft.com/office/word/2006/wordml"),
                new XmlQualifiedName("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
            });

            return(namespaces);
        }
Пример #4
0
        /**
         * MB 24 May 2010. Created this overloaded buildHdrFtr() method because testing demonstrated
         * that the XWPFFooter or XWPFHeader object returned by calls to the CreateHeader(int, XWPFParagraph[])
         * and CreateFooter(int, XWPFParagraph[]) methods or the GetXXXXXHeader/Footer methods where
         * headers or footers had been Added to a document since it had been Created/opened, returned
         * an object that Contained no XWPFParagraph objects even if the header/footer itself did contain
         * text. The reason was that this line of code; CTHdrFtr ftr = CTHdrFtr.Factory.NewInstance();
         * Created a brand new instance of the CTHDRFtr class which was then populated with data when
         * it should have recovered the CTHdrFtr object encapsulated within the XWPFHeaderFooter object
         * that had previoulsy been instantiated in the CreateHeader(int, XWPFParagraph[]) or
         * CreateFooter(int, XWPFParagraph[]) methods.
         */
        private CT_HdrFtr buildHdrFtr(String pStyle, XWPFParagraph[] paragraphs, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtr ftr = wrapper._getHdrFtr();

            if (paragraphs != null)
            {
                for (int i = 0; i < paragraphs.Length; i++)
                {
                    CT_P p = ftr.AddNewP();
                    ftr.SetPArray(i, paragraphs[i].GetCTP());
                }
            }
            else
            {
                CT_P    p    = ftr.AddNewP();
                CT_Body body = doc.Document.body;
                if (body.SizeOfPArray() > 0)
                {
                    CT_P p0 = body.GetPArray(0);
                    if (p0.IsSetRsidR())
                    {
                        byte[] rsidr        = p0.rsidR;
                        byte[] rsidrdefault = p0.rsidRDefault;
                        p.rsidP        = rsidr;
                        p.rsidRDefault = rsidrdefault;
                    }
                }
                CT_PPr pPr             = p.AddNewPPr();
                pPr.AddNewPStyle().val = (pStyle);
            }
            return(ftr);
        }
        private void SetHeaderReference(ST_HdrFtr type, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtrRef ctHdrFtrRef = this.doc.Document.body.sectPr.AddNewHeaderReference();

            ctHdrFtrRef.type = type;
            ctHdrFtrRef.id   = wrapper.GetPackageRelationship().Id;
        }
        private CT_HdrFtr buildHdr(ST_HdrFtr type, string pStyle, XWPFHeaderFooter wrapper, XWPFParagraph[] pars)
        {
            CT_HdrFtr ctHdrFtr = this.buildHdrFtr(pStyle, pars, wrapper);

            this.SetHeaderReference(type, wrapper);
            return(ctHdrFtr);
        }
Пример #7
0
        private CT_HdrFtr buildHdr(ST_HdrFtr type, String pStyle, XWPFHeaderFooter wrapper, XWPFParagraph[] pars)
        {
            //CTHdrFtr hdr = buildHdrFtr(pStyle, pars);				// MB 24 May 2010
            CT_HdrFtr hdr = buildHdrFtr(pStyle, pars, wrapper);         // MB 24 May 2010

            SetHeaderReference(type, wrapper);
            return(hdr);
        }
Пример #8
0
        private XmlSerializerNamespaces Commit(XWPFHeaderFooter wrapper)
        {
            XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(new XmlQualifiedName[] {
                new XmlQualifiedName("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006"),
                new XmlQualifiedName("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
                new XmlQualifiedName("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"),
                new XmlQualifiedName("v", "urn:schemas-microsoft-com:vml"),
                new XmlQualifiedName("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"),
                new XmlQualifiedName("w10", "urn:schemas-microsoft-com:office:word"),
                new XmlQualifiedName("wne", "http://schemas.microsoft.com/office/word/2006/wordml"),
                new XmlQualifiedName("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
            });

            return(namespaces);
        }
        private CT_HdrFtr buildHdrFtr(string pStyle, XWPFParagraph[] paragraphs, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtr hdrFtr = wrapper._getHdrFtr();

            if (paragraphs != null)
            {
                for (int i = 0; i < paragraphs.Length; ++i)
                {
                    hdrFtr.AddNewP();
                    hdrFtr.SetPArray(i, paragraphs[i].GetCTP());
                }
            }
            else
            {
                CT_P   ctP          = hdrFtr.AddNewP();
                byte[] rsidR        = this.doc.Document.body.GetPArray(0).rsidR;
                byte[] rsidRdefault = this.doc.Document.body.GetPArray(0).rsidRDefault;
                ctP.rsidP        = rsidR;
                ctP.rsidRDefault = rsidRdefault;
                ctP.AddNewPPr().AddNewPStyle().val = pStyle;
            }
            return(hdrFtr);
        }
Пример #10
0
        /**
         * MB 24 May 2010. Created this overloaded buildHdrFtr() method because testing demonstrated
         * that the XWPFFooter or XWPFHeader object returned by calls to the CreateHeader(int, XWPFParagraph[])
         * and CreateFooter(int, XWPFParagraph[]) methods or the GetXXXXXHeader/Footer methods where
         * headers or footers had been Added to a document since it had been Created/opened, returned
         * an object that Contained no XWPFParagraph objects even if the header/footer itself did contain
         * text. The reason was that this line of code; CTHdrFtr ftr = CTHdrFtr.Factory.NewInstance();
         * Created a brand new instance of the CTHDRFtr class which was then populated with data when
         * it should have recovered the CTHdrFtr object encapsulated within the XWPFHeaderFooter object
         * that had previoulsy been instantiated in the CreateHeader(int, XWPFParagraph[]) or
         * CreateFooter(int, XWPFParagraph[]) methods.
         */

        private CT_HdrFtr buildHdrFtr(string pStyle, XWPFParagraph[] paragraphs, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtr ftr = wrapper._getHdrFtr();

            if (paragraphs != null)
            {
                for (int i = 0; i < paragraphs.Length; i++)
                {
                    CT_P p = ftr.AddNewP();
                    ftr.SetPArray(i, paragraphs[i].GetCTP());
                }
            }
            else
            {
                CT_P   p            = ftr.AddNewP();
                byte[] rsidr        = doc.Document.body.GetPArray(0).rsidR;
                byte[] rsidrdefault = doc.Document.body.GetPArray(0).rsidRDefault;
                p.rsidP        = (rsidr);
                p.rsidRDefault = (rsidrdefault);
                CT_PPr pPr             = p.AddNewPPr();
                pPr.AddNewPStyle().val = (pStyle);
            }
            return(ftr);
        }