/// <summary>
        /// Protect a Document with deleting all editable ranges
        /// </summary>
        /// <param name="objDoc"></param>
        /// <param name="blnProtect"></param>
        public static void eProtectDocClean(this Document objDoc, bool blnProtect)
        {
            object           NoRest           = false;
            object           Passwod          = "aaaaaa";
            WdProtectionType Type             = blnProtect ? WdProtectionType.wdAllowOnlyReading : WdProtectionType.wdNoProtection;
            object           UseIRM           = false;
            object           EnforceStyleLock = false;

            try
            {
                objDoc.Unprotect(ref Passwod);
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            Object everyone = WdEditorType.wdEditorEveryone;

            objDoc.DeleteAllEditableRanges(ref everyone);
            objDoc.Protect(Type, ref NoRest, ref Passwod, ref UseIRM, ref EnforceStyleLock);
            if (blnProtect == false)
            {
                objDoc.Content.eProtectRange(false);
            }
        }
        /// <summary>
        /// Protect a Document
        /// </summary>
        /// <param name="objDoc"></param>
        /// <param name="blnProtect"></param>
        public static void eProtectDoc(this Document objDoc, bool blnProtect)
        {
            object           NoRest           = false;
            object           Passwod          = "aaaaaa";
            WdProtectionType Type             = blnProtect ? WdProtectionType.wdAllowOnlyReading : WdProtectionType.wdNoProtection;
            object           UseIRM           = false;
            object           EnforceStyleLock = false;

            try
            {
                objDoc.Unprotect(ref Passwod);
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            objDoc.Protect(Type, ref NoRest, ref Passwod, ref UseIRM, ref EnforceStyleLock);
        }
示例#3
0
 public void Protect(WdProtectionType Type, ref object NoReset, ref object Password, ref object UseIRM,
     ref object EnforceStyleLock)
 {
     throw new System.NotImplementedException();
 }
示例#4
0
 public void Protect2002(WdProtectionType Type, ref object NoReset, ref object Password)
 {
     throw new System.NotImplementedException();
 }
 public void Protect(WdProtectionType Type, ref object NoReset, ref object Password, ref object UseIRM,
     ref object EnforceStyleLock)
 {
     throw new System.NotImplementedException();
 }
 public void Protect2002(WdProtectionType Type, ref object NoReset, ref object Password)
 {
     throw new System.NotImplementedException();
 }
示例#7
0
        private Document Open(ApplicationClass wordApp, string fileName, bool readOnly)
        {
            object           obj1             = (object)fileName;
            object           obj2             = (object)false;
            object           obj3             = (object)(bool)(readOnly ? 1 : 0);
            object           obj4             = (object)false;
            object           obj5             = (object)"";
            object           obj6             = (object)"";
            object           obj7             = (object)false;
            object           obj8             = (object)"";
            object           obj9             = (object)"";
            object           obj10            = (object)WdOpenFormat.wdOpenFormatAuto;
            object           obj11            = (object)"";
            object           obj12            = (object)true;
            object           obj13            = (object)false;
            object           obj14            = (object)"WordDrivePass";
            WdProtectionType wdProtectionType = WdProtectionType.wdAllowOnlyFormFields;
            Documents        documents        = wordApp.Documents;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& FileName = @obj1;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& ConfirmConversions = @obj2;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& ReadOnly = @obj3;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& AddToRecentFiles = @obj4;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& PasswordDocument = @obj5;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& PasswordTemplate = @obj6;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& Revert = @obj7;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& WritePasswordDocument = @obj8;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& WritePasswordTemplate = @obj9;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& Format = @obj10;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& Encoding = @obj11;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& Visible = @obj12;
            object  obj15   = (object)Missing.Value;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& OpenAndRepair = @obj15;
            object  obj16         = (object)Missing.Value;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& DocumentDirection = @obj16;
            object  obj17             = (object)Missing.Value;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& NoEncodingDialog = @obj17;
            object  obj18            = (object)Missing.Value;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object&  XMLTransform = @obj18;
            Document document1    = documents.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format, Encoding, Visible, OpenAndRepair, DocumentDirection, NoEncodingDialog, XMLTransform);

            if (readOnly && document1 != null)
            {
                Document document2 = document1;
                int      num       = (int)wdProtectionType;
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                object& NoReset = @obj13;
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                object& Password = @obj14;
                object  obj19    = (object)Missing.Value;
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                object& UseIRM = @obj19;
                object  obj20  = (object)Missing.Value;
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                object& EnforceStyleLock = @obj20;
                document2.Protect((WdProtectionType)num, NoReset, Password, UseIRM, EnforceStyleLock);
            }
            return(document1);
        }
示例#8
0
        private void PrepareWordApp()
        {
            object           Template         = (object)this.FileName;
            object           NewTemplate      = (object)false;
            object           DocumentType     = (object)0;
            object           Visible          = (object)true;
            object           obj1             = (object)false;
            object           obj2             = (object)"WordDrivePass";
            WdProtectionType wdProtectionType = WdProtectionType.wdAllowOnlyFormFields;

            try
            {
                string caption = this.InternalWordApp.Caption;
                this.InternalWordApp.Caption = "Barid-Word-Instance" + (object)DateTime.Now.Ticks;
                if (this.WordHwnd == 0)
                {
                    this.WordHwnd = StandAloneWordControl.FindWindow("Opusapp", this.InternalWordApp.Caption);
                }
                this.InternalWordApp.Caption = caption;
                if (this.WordHwnd == 0)
                {
                    return;
                }
                StandAloneWordControl.SetParent(this.WordHwnd, this.Handle.ToInt32());
                if (this.InternalWordApp != null)
                {
                    if (this.InternalWordApp.Documents != null)
                    {
                        this.WordDocument = this.InternalWordApp.Documents.Add(ref Template, ref NewTemplate, ref DocumentType, ref Visible);
                        if (this.Protect)
                        {
                            Document document = this.WordDocument;
                            int      num      = (int)wdProtectionType;
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            object& NoReset = @obj1;
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            object& Password = @obj2;
                            object  obj3     = (object)Missing.Value;
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            object& UseIRM = @obj3;
                            object  obj4   = (object)Missing.Value;
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            object& EnforceStyleLock = @obj4;
                            document.Protect((WdProtectionType)num, NoReset, Password, UseIRM, EnforceStyleLock);
                        }
                    }
                }
                try
                {
                    this.InternalWordApp.ActiveWindow.ActivePane.DisplayRulers = true;
                    this.InternalWordApp.ActiveWindow.DisplayRightRuler        = true;
                    this.InternalWordApp.ActiveWindow.DisplayScreenTips        = true;
                    this.InternalWordApp.ActiveWindow.DisplayVerticalRuler     = true;
                    this.InternalWordApp.ActiveWindow.DisplayRightRuler        = true;
                    this.InternalWordApp.ActiveWindow.ActivePane.DisplayRulers = true;
                    this.InternalWordApp.ActiveWindow.ActivePane.View[]        = WdViewType.wdPrintView;
                }
                catch
                {
                }
            }
            catch
            {
            }
        }