Example #1
0
        public void SetTableGrid(IEnumerable <int> columnWidthsTw)
        {
            var xNameTablePr = XName.Get("tblPr", Namespaces.w.NamespaceName);
            var tblPr        = Xml.Element(xNameTablePr);

            var xName = Namespaces.w + "tblGrid";

            Xml.Element(xName)?.Remove();

            var tblGrid = new XElement(xName);

            foreach (var c in columnWidthsTw)
            {
                tblGrid.Add(new XElement(Namespaces.w + "gridCol", new XAttribute(Namespaces.w + "w", c)));
            }

            // Seems like LibreOffice expects tblGrid right after tblPr
            if (tblPr != null)
            {
                tblPr.AddAfterSelf(tblGrid);
            }
            else
            {
                Xml.AddFirst(tblGrid);
            }
        }
Example #2
0
        private XElement GetOrCreateDefaultRunPropertiesXmlElement()
        {
            var xName      = XName.Get("rPrDefault", Namespaces.w.NamespaceName);
            var rPrDefault = Xml.Element(xName);

            if (rPrDefault != null)
            {
                return(rPrDefault);
            }
            rPrDefault = new XElement(xName);
            Xml.AddFirst(rPrDefault);
            return(rPrDefault);
        }
Example #3
0
        private XElement GetOrCreateDefaultParagraphPropertiesXmlElement()
        {
            var xName      = XName.Get("pPrDefault", Namespaces.w.NamespaceName);
            var pPrDefault = Xml.Element(xName);

            if (pPrDefault != null)
            {
                return(pPrDefault);
            }
            pPrDefault = new XElement(xName);
            Xml.AddFirst(pPrDefault);
            return(pPrDefault);
        }
Example #4
0
        XElement IParagraphPropertiesContainer.GetOrCreateParagraphPropertiesXmlElement()
        {
            var xName = XName.Get("pPr", Namespaces.w.NamespaceName);
            var pPr   = Xml.Element(xName);

            if (pPr != null)
            {
                return(pPr);
            }
            pPr = new XElement(xName);
            Xml.AddFirst(pPr);
            return(pPr);
        }
Example #5
0
        XElement ICellPropertiesContainer.GetOrCreateCellPropertiesXmlElement()
        {
            var xName = XName.Get("tcPr", Namespaces.w.NamespaceName);
            var tcPr  = Xml.Element(xName);

            if (tcPr != null)
            {
                return(tcPr);
            }
            tcPr = new XElement(xName);
            Xml.AddFirst(tcPr);
            return(tcPr);
        }
Example #6
0
        XElement IRunPropertiesContainer.GetOrCreateRunPropertiesXmlElement()
        {
            var xName = XName.Get("rPr", Namespaces.w.NamespaceName);
            var rPr   = Xml.Element(xName);

            if (rPr != null)
            {
                return(rPr);
            }
            rPr = new XElement(xName);
            Xml.AddFirst(rPr);
            return(rPr);
        }