| static internal XNamespace c = "http://schemas.openxmlformats.org/drawingml/2006/chart"; | static internal XNamespace c = "http://schemas.openxmlformats.org/drawingml/2006/chart"; | ||||
| #endregion | #endregion | ||||
| public float PageWidth | |||||
| { | |||||
| public float PageWidth | |||||
| { | |||||
| get | get | ||||
| { | { | ||||
| XElement body = mainDoc.Root.Element(XName.Get("body", DocX.w.NamespaceName)); | XElement body = mainDoc.Root.Element(XName.Get("body", DocX.w.NamespaceName)); | ||||
| { | { | ||||
| XElement pgSz = sectPr.Element(XName.Get("pgSz", DocX.w.NamespaceName)); | XElement pgSz = sectPr.Element(XName.Get("pgSz", DocX.w.NamespaceName)); | ||||
| if(pgSz != null) | |||||
| if (pgSz != null) | |||||
| { | { | ||||
| XAttribute w = pgSz.Attribute(XName.Get("w", DocX.w.NamespaceName)); | XAttribute w = pgSz.Attribute(XName.Get("w", DocX.w.NamespaceName)); | ||||
| if(w != null) | |||||
| if (w != null) | |||||
| { | { | ||||
| float f; | float f; | ||||
| if(float.TryParse(w.Value,out f)) | |||||
| if (float.TryParse(w.Value, out f)) | |||||
| return (int)(f / 15.0f); | return (int)(f / 15.0f); | ||||
| } | } | ||||
| } | } | ||||
| if (body != null) | if (body != null) | ||||
| { | { | ||||
| XElement sectPr = body.Element(XName.Get("sectPr", DocX.w.NamespaceName)); | XElement sectPr = body.Element(XName.Get("sectPr", DocX.w.NamespaceName)); | ||||
| if (sectPr != null) | if (sectPr != null) | ||||
| { | { | ||||
| XElement pgSz = sectPr.Element(XName.Get("pgSz", DocX.w.NamespaceName)); | XElement pgSz = sectPr.Element(XName.Get("pgSz", DocX.w.NamespaceName)); | ||||
| return p; | return p; | ||||
| } | } | ||||
| public Paragraph[] InsertParagraphs(string text) | |||||
| { | |||||
| String[] textArray = text.Split('\n'); | |||||
| List<Paragraph> paragraphs = new List<Paragraph>(); | |||||
| foreach (var textForParagraph in textArray) | |||||
| { | |||||
| Paragraph p = base.InsertParagraph(text); | |||||
| p.PackagePart = mainPart; | |||||
| paragraphs.Add(p); | |||||
| } | |||||
| return paragraphs.ToArray(); | |||||
| } | |||||
| public override List<Paragraph> Paragraphs | public override List<Paragraph> Paragraphs | ||||
| { | { | ||||
| get | get | ||||
| PackageRelationship rel = mainPart.CreateRelationship(chartPackagePart.Uri, TargetMode.Internal, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", relID); | PackageRelationship rel = mainPart.CreateRelationship(chartPackagePart.Uri, TargetMode.Internal, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", relID); | ||||
| // Save a chart info the chartPackagePart | // Save a chart info the chartPackagePart | ||||
| chart.Xml.Save(chartPackagePart.GetStream(FileMode.Create, FileAccess.Write)); | |||||
| chart.Xml.Save(chartPackagePart.GetStream(FileMode.Create, FileAccess.Write)); | |||||
| // Insert a new chart into a paragraph. | // Insert a new chart into a paragraph. | ||||
| Paragraph p = InsertParagraph(); | Paragraph p = InsertParagraph(); | ||||
| ) | ) | ||||
| ) | ) | ||||
| )); | )); | ||||
| p.Xml.Add(chartElement); | |||||
| p.Xml.Add(chartElement); | |||||
| } | } | ||||
| #region IDisposable Members | #region IDisposable Members |