瀏覽代碼

correct width/height setting in Picture class

next newid extended on CreatePicture in Paragraph class
SetWidthsPercentage pwidth calculation extended  with * (96 / 72)  to get pixels from points
master
ermoll 9 年之前
父節點
當前提交
9948f40cea
共有 4 個文件被更改,包括 20 次插入9 次删除
  1. 2
    2
      DocX/Image.cs
  2. 11
    0
      DocX/Paragraph.cs
  3. 6
    6
      DocX/Picture.cs
  4. 1
    1
      DocX/Table.cs

+ 2
- 2
DocX/Image.cs 查看文件

string temp = pr.SourceUri.OriginalString; string temp = pr.SourceUri.OriginalString;
string start = temp.Remove(temp.LastIndexOf('/')); string start = temp.Remove(temp.LastIndexOf('/'));
string end = pr.TargetUri.OriginalString; string end = pr.TargetUri.OriginalString;
string full = start + "/" + end;
string full = end.Contains(start) ? end : start + "/" + end;
return(new PackagePartStream(document.package.GetPart(new Uri(full, UriKind.Relative)).GetStream(mode, access)));
return (new PackagePartStream(document.package.GetPart(new Uri(full, UriKind.Relative)).GetStream(mode, access)));
} }
/// <summary> /// <summary>

+ 11
- 0
DocX/Paragraph.cs 查看文件

existingIds.Add(idAtt.Value); existingIds.Add(idAtt.Value);
} }
while (existingIds.Contains(newDocPrId.ToString()))
newDocPrId++;
//also loop thru all docPr ids
foreach (var bookmarkId in document.Xml.Descendants(XName.Get("docPr", DocX.wp.NamespaceName)))
{
var idAtt = bookmarkId.Attributes().FirstOrDefault(x => x.Name.LocalName == "id");
if (idAtt != null)
existingIds.Add(idAtt.Value);
}
while (existingIds.Contains(newDocPrId.ToString())) while (existingIds.Contains(newDocPrId.ToString()))
newDocPrId++; newDocPrId++;

+ 6
- 6
DocX/Picture.cs 查看文件

get { return cx / EmusInPixel; } get { return cx / EmusInPixel; }
set set
{
cx = value;
{
cx = value * EmusInPixel;
foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cx"))) foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cx")))
a.Value = (cx * EmusInPixel).ToString();
a.Value = (cx).ToString();
} }
} }
get { return cy / EmusInPixel; } get { return cy / EmusInPixel; }
set set
{
cy = value;
{
cy = value * EmusInPixel;
foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cy"))) foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cy")))
a.Value = (cy * EmusInPixel).ToString();
a.Value = (cy).ToString();
} }
} }

+ 1
- 1
DocX/Table.cs 查看文件

{ {
if (totalWidth == null) totalWidth = this.Document.PageWidth - this.Document.MarginLeft - this.Document.MarginRight; // calculate total table width if (totalWidth == null) totalWidth = this.Document.PageWidth - this.Document.MarginLeft - this.Document.MarginRight; // calculate total table width
List<float> widths = new List<float>(widthsPercentage.Length); // empty list, will hold actual width List<float> widths = new List<float>(widthsPercentage.Length); // empty list, will hold actual width
widthsPercentage.ToList().ForEach(pWidth => { widths.Add(pWidth * totalWidth.Value / 100); }); // convert percentage to actual width for all values in array
widthsPercentage.ToList().ForEach(pWidth => { widths.Add((pWidth * totalWidth.Value / 100) * (96 / 72)); }); // convert percentage to actual width for all values in array
SetWidths(widths.ToArray()); // set actual column width SetWidths(widths.ToArray()); // set actual column width
} }

Loading…
取消
儲存