Przeglądaj źródła

DocX.cs

---------
Added property bool isProtected
Added function removeProtection()

Protection is different than Encryption.
master
coffeycathal_cp 15 lat temu
rodzic
commit
7122dc4a88
1 zmienionych plików z 23 dodań i 1 usunięć
  1. 23
    1
      DocX/DocX.cs

+ 23
- 1
DocX/DocX.cs Wyświetl plik

static internal XNamespace customVTypesSchema = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"; static internal XNamespace customVTypesSchema = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes";
#endregion #endregion
public bool isProtected
{
get
{
return settings.Descendants(XName.Get("documentProtection", DocX.w.NamespaceName)).Count() > 0;
}
}
public void RemoveProtection()
{
// Remove every node of type documentProtection.
settings.Descendants(XName.Get("documentProtection", DocX.w.NamespaceName)).Remove();
}
public PageLayout PageLayout public PageLayout PageLayout
{ {
get get
// The mainDocument is loaded into a XDocument object for easy querying and editing // The mainDocument is loaded into a XDocument object for easy querying and editing
internal XDocument mainDoc; internal XDocument mainDoc;
internal XDocument settings;
internal XDocument header1; internal XDocument header1;
internal XDocument header2; internal XDocument header2;
internal XDocument header3; internal XDocument header3;
PopulateDocument(document, package); PopulateDocument(document, package);
return document;
using (TextReader tr = new StreamReader(document.settingsPart.GetStream()))
document.settings = XDocument.Load(tr);
return document;
} }
private static void PopulateDocument(DocX document, Package package) private static void PopulateDocument(DocX document, Package package)
).Save(tw, SaveOptions.DisableFormatting); ).Save(tw, SaveOptions.DisableFormatting);
} }
} }
// Save the settings document.
using (TextWriter tw = new StreamWriter(settingsPart.GetStream(FileMode.Create, FileAccess.Write)))
settings.Save(tw, SaveOptions.DisableFormatting);
} }
// Close the document so that it can be saved. // Close the document so that it can be saved.

Ładowanie…
Anuluj
Zapisz