Ver código fonte

Huge improvement to InsertDocument() efficienty. Using set operations to find the missing refs.

master
coffeycathal_cp 13 anos atrás
pai
commit
1a76e6e44d
4 arquivos alterados com 11 adições e 11 exclusões
  1. 1
    1
      DocX/Container.cs
  2. 4
    4
      DocX/HelperFunctions.cs
  3. 4
    4
      DocX/Paragraph.cs
  4. 2
    2
      DocX/Properties/AssemblyInfo.cs

+ 1
- 1
DocX/Container.cs Ver arquivo

@@ -305,7 +305,7 @@ namespace Novacode
Uri style_package_uri = new Uri("/word/styles.xml", UriKind.Relative);
if (!Document.package.PartExists(style_package_uri))
{
PackagePart style_package = Document.package.CreatePart(style_package_uri, "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml");
PackagePart style_package = Document.package.CreatePart(style_package_uri, "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", CompressionOption.Maximum);
using (TextWriter tw = new StreamWriter(style_package.GetStream()))
{
style_document = new XDocument

+ 4
- 4
DocX/HelperFunctions.cs Ver arquivo

@@ -16,7 +16,7 @@ namespace Novacode
{
internal static void CreateRelsPackagePart(DocX Document, Uri uri)
{
PackagePart pp = Document.package.CreatePart(uri, "application/vnd.openxmlformats-package.relationships+xml");
PackagePart pp = Document.package.CreatePart(uri, "application/vnd.openxmlformats-package.relationships+xml", CompressionOption.Maximum);
using (TextWriter tw = new StreamWriter(pp.GetStream()))
{
XDocument d = new XDocument
@@ -190,7 +190,7 @@ namespace Novacode
Uri settingsUri = new Uri("/word/settings.xml", UriKind.Relative);
if (!package.PartExists(settingsUri))
{
settingsPart = package.CreatePart(settingsUri, "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml");
settingsPart = package.CreatePart(settingsUri, "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml", CompressionOption.Maximum);
PackagePart mainDocumentPart = package.GetParts().Where
(
@@ -259,7 +259,7 @@ namespace Novacode
internal static void CreateCustomPropertiesPart(DocX document)
{
PackagePart customPropertiesPart = document.package.CreatePart(new Uri("/docProps/custom.xml", UriKind.Relative), "application/vnd.openxmlformats-officedocument.custom-properties+xml");
PackagePart customPropertiesPart = document.package.CreatePart(new Uri("/docProps/custom.xml", UriKind.Relative), "application/vnd.openxmlformats-officedocument.custom-properties+xml", CompressionOption.Maximum);
XDocument customPropDoc = new XDocument
(
@@ -312,7 +312,7 @@ namespace Novacode
{
XDocument stylesDoc;
// Create the main document part for this package
PackagePart word_styles = package.CreatePart(new Uri("/word/styles.xml", UriKind.Relative), "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml");
PackagePart word_styles = package.CreatePart(new Uri("/word/styles.xml", UriKind.Relative), "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", CompressionOption.Maximum);
stylesDoc = HelperFunctions.DecompressXMLResource("Novacode.Resources.default_styles.xml.gz");
XElement lang = stylesDoc.Root.Element(XName.Get("docDefaults", DocX.w.NamespaceName)).Element(XName.Get("rPrDefault", DocX.w.NamespaceName)).Element(XName.Get("rPr", DocX.w.NamespaceName)).Element(XName.Get("lang", DocX.w.NamespaceName));

+ 4
- 4
DocX/Paragraph.cs Ver arquivo

@@ -219,7 +219,7 @@ namespace Novacode
this.startIndex = startIndex;
this.endIndex = startIndex + GetElementTextLength(xml);
RebuildDocProperties();
RebuildDocProperties();
#region It's possible that a Paragraph may have pStyle references
// Check if this Paragraph references any pStyle elements.
@@ -230,14 +230,14 @@ namespace Novacode
{
Uri style_package_uri = new Uri("/word/styles.xml", UriKind.Relative);
PackagePart styles_document = document.package.GetPart(style_package_uri);
using (TextReader tr = new StreamReader(styles_document.GetStream()))
{
XDocument style_document = XDocument.Load(tr);
XElement styles_element = style_document.Element(XName.Get("styles", DocX.w.NamespaceName));
var styles_element_ids = stylesElements.Select(e => e.Attribute(XName.Get("val", DocX.w.NamespaceName)).Value);
//foreach(string id in styles_element_ids)
//{
// var style =
@@ -252,7 +252,7 @@ namespace Novacode
// styles.Add(style);
//}
}
}
}
#endregion
this.runs = Xml.Elements(XName.Get("r", DocX.w.NamespaceName)).ToList();

+ 2
- 2
DocX/Properties/AssemblyInfo.cs Ver arquivo

@@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.12")]
[assembly: AssemblyFileVersion("1.0.1.12")]
[assembly: AssemblyVersion("1.0.1.13")]
[assembly: AssemblyFileVersion("1.0.1.13")]

Carregando…
Cancelar
Salvar