示例#1
0
        public void TestIntegration()
        {
            XWPFDocument doc = new XWPFDocument();

            XWPFParagraph p1 = doc.CreateParagraph();

            XWPFRun r1 = p1.CreateRun();

            r1.SetText("Lorem ipsum dolor sit amet.");
            doc.EnforceCommentsProtection();

            FileInfo tempFile = TempFile.CreateTempFile("documentProtectionFile", ".docx");

            if (File.Exists(tempFile.FullName))
            {
                File.Delete(tempFile.FullName);
            }
            Stream out1 = new FileStream(tempFile.FullName, FileMode.CreateNew);

            doc.Write(out1);
            out1.Close();

            FileStream   inputStream = new FileStream(tempFile.FullName, FileMode.Open);
            XWPFDocument document    = new XWPFDocument(inputStream);

            inputStream.Close();

            Assert.IsTrue(document.IsEnforcedCommentsProtection());
        }
示例#2
0
        public void TestShouldEnforceForComments()
        {
            XWPFDocument document = XWPFTestDataSamples.OpenSampleDocument("documentProtection_no_protection.docx");

            Assert.IsFalse(document.IsEnforcedCommentsProtection());

            document.EnforceCommentsProtection();

            Assert.IsTrue(document.IsEnforcedCommentsProtection());
        }