Explorar el Código

Enumerations.cs

-----------------
EditRestrictions 

DocX.cs
--------
EditRestrictions GetProtectionType()
AddProtection(EditRestrictions er)
master
coffeycathal_cp hace 15 años
padre
commit
97cc1fc974
Se han modificado 2 ficheros con 34 adiciones y 1 borrados
  1. 25
    1
      DocX/DocX.cs
  2. 9
    0
      DocX/_Enumerations.cs

+ 25
- 1
DocX/DocX.cs Ver fichero

@@ -27,7 +27,7 @@ namespace Novacode
static internal XNamespace customVTypesSchema = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes";
#endregion
public bool isProtected
public bool isProtected
{
get
{
@@ -35,6 +35,30 @@ namespace Novacode
}
}
public EditRestrictions GetProtectionType()
{
if (isProtected)
{
XElement documentProtection = settings.Descendants(XName.Get("documentProtection", DocX.w.NamespaceName)).FirstOrDefault();
string edit_type = documentProtection.Attribute(XName.Get("edit", DocX.w.NamespaceName)).Value;
return (EditRestrictions)Enum.Parse(typeof(EditRestrictions), edit_type);
}
return EditRestrictions.none;
}
public void AddProtection(EditRestrictions er)
{
if (er == EditRestrictions.none)
return;
XElement documentProtection = new XElement(XName.Get("documentProtection", DocX.w.NamespaceName));
documentProtection.Add(new XAttribute(XName.Get("edit", DocX.w.NamespaceName), er.ToString()));
documentProtection.Add(new XAttribute(XName.Get("enforcement", DocX.w.NamespaceName), "1"));
settings.Root.AddFirst(documentProtection);
}
public void RemoveProtection()
{
// Remove every node of type documentProtection.

+ 9
- 0
DocX/_Enumerations.cs Ver fichero

@@ -18,6 +18,15 @@ namespace Novacode
nine
}
public enum EditRestrictions
{
none,
readOnly,
forms,
comments,
trackedChanges
}
/// <summary>
/// Table Cell Border styles
/// Added by lckuiper @ 20101117

Cargando…
Cancelar
Guardar