You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
parent
4bdbaf4a88
commit
966bba02bb
@@ -27,6 +27,6 @@ using System;
|
||||
|
||||
namespace System.ComponentModel {
|
||||
|
||||
public delegate void CurrentChangingEventHandler (object sender, CurrentChangingEventArgs args);
|
||||
public delegate void CurrentChangingEventHandler (object sender, CurrentChangingEventArgs e);
|
||||
|
||||
}
|
||||
|
@@ -165,12 +165,15 @@ namespace System.IO.Packaging {
|
||||
TargetMode mode = TargetMode.Internal;
|
||||
if (node.Attributes["TargetMode"] != null)
|
||||
mode = (TargetMode) Enum.Parse (typeof(TargetMode), node.Attributes ["TargetMode"].Value);
|
||||
|
||||
CreateRelationship (new Uri (node.Attributes["Target"].Value.ToString(), UriKind.RelativeOrAbsolute),
|
||||
mode,
|
||||
node.Attributes["Type"].Value.ToString (),
|
||||
node.Attributes["Id"].Value.ToString (),
|
||||
true);
|
||||
|
||||
// Workaround for Mono relative paths
|
||||
// http://www.mono-project.com/docs/faq/known-issues/urikind-relativeorabsolute/
|
||||
var kind = (UriKind) 300;
|
||||
CreateRelationship (new Uri (node.Attributes["Target"].Value.ToString(), kind),
|
||||
mode,
|
||||
node.Attributes["Type"].Value.ToString (),
|
||||
node.Attributes["Id"].Value.ToString (),
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -215,5 +215,42 @@ namespace MonoTests.System.IO.Packaging
|
||||
|
||||
return pack;
|
||||
}
|
||||
|
||||
Package CreateSpreadsheet(Stream stream)
|
||||
{
|
||||
Package pack = Package.Open(stream, FileMode.Create);
|
||||
|
||||
// Create package parts.
|
||||
PackagePart workbookPart = pack.CreatePart(new Uri("/xl/workbook.xml", UriKind.Relative), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml");
|
||||
PackagePart sharedStringsPart = pack.CreatePart(new Uri("/xl/sharedStrings.xml", UriKind.Relative), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml");
|
||||
|
||||
workbookPart.CreateRelationship(new Uri("/xl/sharedStrings.xml", UriKind.Relative), TargetMode.Internal, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings", "rel1");
|
||||
|
||||
// Load some basic data into the different parts.
|
||||
foreach (PackagePart part in package.GetParts())
|
||||
using (Stream s = part.GetStream())
|
||||
s.Write(new byte[10], 0, 10);
|
||||
|
||||
return pack;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExcelWorkbook()
|
||||
{
|
||||
MemoryStream stream = new MemoryStream();
|
||||
Package package = CreateSpreadsheet(stream);
|
||||
Assert.IsTrue(package.PartExists(new Uri("/xl/workbook.xml", UriKind.Relative)), "#1");
|
||||
Assert.IsTrue(package.PartExists(new Uri("/xl/sharedStrings.xml", UriKind.Relative)), "#2");
|
||||
|
||||
package.Close();
|
||||
package = Package.Open(new MemoryStream(stream.ToArray()), FileMode.Open);
|
||||
|
||||
PackagePart workbookPart = package.GetPart(new Uri("/xl/workbook.xml", UriKind.Relative));
|
||||
Assert.IsTrue(workbookPart.RelationshipExists("rel1"), "#3");
|
||||
|
||||
var r = workbookPart.GetRelationship("rel1");
|
||||
Assert.IsFalse(r.TargetUri.IsAbsoluteUri, "#4");
|
||||
package.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user