当前位置: 首页>>代码示例>>C#>>正文


C# DocumentBuilder.StartEditableRange方法代码示例

本文整理汇总了C#中DocumentBuilder.StartEditableRange方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.StartEditableRange方法的具体用法?C# DocumentBuilder.StartEditableRange怎么用?C# DocumentBuilder.StartEditableRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentBuilder的用法示例。


在下文中一共展示了DocumentBuilder.StartEditableRange方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EditableRangeEx

        public void EditableRangeEx()
        {
            //ExStart
            //ExFor:DocumentBuilder.StartEditableRange
            //ExFor:DocumentBuilder.EndEditableRange()
            //ExFor:DocumentBuilder.EndEditableRange(EditableRangeStart)
            //ExSummary:Shows how to start and end an editable range.
            Document doc = new Document(MyDir + "Document.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Start an editable range.
            EditableRangeStart edRange1Start = builder.StartEditableRange();

            // An EditableRange object is created for the EditableRangeStart that we just made.
            EditableRange editableRange1 = edRange1Start.EditableRange;

            // Put something inside the editable range.
            builder.Writeln("Paragraph inside first editable range");

            // An editable range is well-formed if it has a start and an end. 
            // Multiple editable ranges can be nested and overlapping. 
            EditableRangeEnd edRange1End = builder.EndEditableRange();

            // Both the start and end automatically belong to editableRange1.
            Console.WriteLine(editableRange1.EditableRangeStart.Equals(edRange1Start)); // True
            Console.WriteLine(editableRange1.EditableRangeEnd.Equals(edRange1End)); // True

            // Explicitly state which EditableRangeStart a new EditableRangeEnd should be paired with.
            EditableRangeStart edRange2Start = builder.StartEditableRange();
            builder.Writeln("Paragraph inside second editable range");
            EditableRange editableRange2 = edRange2Start.EditableRange;
            EditableRangeEnd edRange2End = builder.EndEditableRange(edRange2Start);

            // Both the start and end automatically belong to editableRange2.
            Console.WriteLine(editableRange2.EditableRangeStart.Equals(edRange2Start)); // True
            Console.WriteLine(editableRange2.EditableRangeEnd.Equals(edRange2End)); // True
            //ExEnd
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:38,代码来源:ExEditableRange.cs

示例2: RemoveEx

        public void RemoveEx()
        {
            //ExStart
            //ExFor:EditableRange.Remove
            //ExSummary:Shows how to remove an editable range from a document.
            Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "Document.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Create an EditableRange so we can remove it. Does not have to be well-formed.
            EditableRangeStart edRange1Start = builder.StartEditableRange();
            Aspose.Words.EditableRange editableRange1 = edRange1Start.EditableRange;
            builder.Writeln("Paragraph inside editable range");
            EditableRangeEnd edRange1End = builder.EndEditableRange();

            // Remove the range that was just made.
            editableRange1.Remove();
            //ExEnd
        }
开发者ID:romankorchagin,项目名称:Aspose_Words_NET,代码行数:18,代码来源:ExEditableRange.cs

示例3: StartEditableRangeEx

        public void StartEditableRangeEx()
        {
            //ExStart
            //ExFor:StartEditableRange
            //ExId:StartEditableRangeEx
            //ExSummary:Shows how to use StartEditableRange.
            Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "Document.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.StartEditableRange();
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:12,代码来源:ExDocumentBuilder.cs

示例4: EditableRanges_InvalidOperationException

        public void EditableRanges_InvalidOperationException()
        {
            Document doc = new Document();

            DocumentBuilder builder = new DocumentBuilder(doc);

            //Is not valid structure for the current document
            builder.EndEditableRange();

            builder.StartEditableRange();
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:11,代码来源:QaEditableRange.cs

示例5: EditableRanges_AddEditableRanges

        public void EditableRanges_AddEditableRanges()
        {
            Document doc = DocumentHelper.CreateDocumentFillWithDummyText();

            DocumentBuilder builder = new DocumentBuilder(doc);

            //Get paragraphs of the current document
            Paragraph paraFirst = DocumentHelper.GetParagraph(doc, 0);
            Paragraph paraSecond = DocumentHelper.GetParagraph(doc, 1);

            builder.MoveTo(paraFirst);

            //Add EditableRangeStart to the first paragraph
            EditableRangeStart startRangeParaFirst = builder.StartEditableRange();

            builder.Writeln("EditableRange_1_1");
            builder.Writeln("EditableRange_1_2");

            //Mark the current position as an editable range end for "startRangeParaFirst"
            //"EndEditableRange()" closes the first created EditableRangeStart
            builder.EndEditableRange();

            //Add text to non-editable region of a document
            builder.Writeln("NotEditableRange_1_1");
            builder.Writeln("NotEditableRange_1_2");

            builder.MoveTo(paraSecond);

            //Add EditableRangeStart to the second paragraph
            EditableRangeStart startRangeParaSecond = builder.StartEditableRange();

            builder.Writeln("EditableRange_2_1");

            //Mark the current position as an editable range end for "startRangeParaSecond"
            //"EndEditableRange(EditableRangeStart)" closes EditableRangeStart which you specify in paramert
            builder.EndEditableRange(startRangeParaSecond);

            //Add text to non-editable region of a document
            builder.Writeln("NotEditableRange_2_1");

            //Sets the editor for editable range regions
            startRangeParaFirst.EditableRange.EditorGroup = EditorType.Everyone;
            startRangeParaSecond.EditableRange.EditorGroup = EditorType.Everyone;

            //Sets that the document read only and is password-protected
            doc.Protect(ProtectionType.ReadOnly, "123");

            MemoryStream dstStream = new MemoryStream();
            doc.Save(dstStream, SaveFormat.Docx);

            NodeCollection startNodes = doc.GetChildNodes(NodeType.EditableRangeStart, true);

            //Assert that the document have nodes of EditableRangeStart
            Assert.AreEqual(2, startNodes.Count);

            //Assert that is the current region and structure is not broken
            Node startRangeRun1 = startNodes[0].NextSibling;
            Assert.AreEqual(startRangeRun1.GetText(), "EditableRange_1_1");

            //Assert that is the current region and structure is not broken
            Node startRangeRun2 = startNodes[1].NextSibling;
            Assert.AreEqual(startRangeRun2.GetText(), "EditableRange_2_1");

            //Assert that the document have nodes of EditableRangeEnd
            NodeCollection endNodes = doc.GetChildNodes(NodeType.EditableRangeEnd, true);
            Assert.AreEqual(2, endNodes.Count);

            //Assert that is the current region and structure is not broken
            Node endRangeRun1 = endNodes[0].NextSibling;
            Assert.AreEqual(endRangeRun1.GetText(), "NotEditableRange_1_1");

            //Assert that is the current region and structure is not broken
            Node endRangeRun2 = endNodes[1].NextSibling;
            Assert.AreEqual(endRangeRun2.GetText(), "NotEditableRange_2_1");
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:75,代码来源:QaEditableRange.cs

示例6: EditableRanges_WithoutEnd

        public void EditableRanges_WithoutEnd()
        {
            Document doc = DocumentHelper.CreateDocumentFillWithDummyText();

            DocumentBuilder builder = new DocumentBuilder(doc);

            //Add EditableRangeStart
            EditableRangeStart startRange1 = builder.StartEditableRange();

            builder.Writeln("EditableRange_1_1");
            builder.Writeln("EditableRange_1_2");

            //Sets the editor for editable range region
            startRange1.EditableRange.EditorGroup = EditorType.Everyone;

            //Sets that the document read only and is password-protected
            doc.Protect(ProtectionType.ReadOnly, "123");

            MemoryStream dstStream = new MemoryStream();
            doc.Save(dstStream, SaveFormat.Docx);

            //Assert that it's not valid structure and editable ranges aren't added to the current document
            NodeCollection startNodes = doc.GetChildNodes(NodeType.EditableRangeStart, true);
            Assert.AreEqual(0, startNodes.Count);

            NodeCollection endNodes = doc.GetChildNodes(NodeType.EditableRangeEnd, true);
            Assert.AreEqual(0, endNodes.Count);
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:28,代码来源:QaEditableRange.cs

示例7: IncorrectStructureDoNotAdded

        public void IncorrectStructureDoNotAdded()
        {
            Document doc = DocumentHelper.CreateDocumentFillWithDummyText();

            DocumentBuilder builder = new DocumentBuilder(doc);

            //ExStart
            //ExFor: EditableRange.EditorGroup
            //ExSummary:Shows how to add editing group for editableranges
            //Add EditableRangeStart
            EditableRangeStart startRange1 = builder.StartEditableRange();

            builder.Writeln("EditableRange_1_1");
            builder.Writeln("EditableRange_1_2");

            //Sets the editor for editable range region
            startRange1.EditableRange.EditorGroup = EditorType.Everyone;
            //ExEnd

            MemoryStream dstStream = new MemoryStream();
            doc.Save(dstStream, SaveFormat.Docx);

            //Assert that it's not valid structure and editable ranges aren't added to the current document
            NodeCollection startNodes = doc.GetChildNodes(NodeType.EditableRangeStart, true);
            Assert.AreEqual(0, startNodes.Count);

            NodeCollection endNodes = doc.GetChildNodes(NodeType.EditableRangeEnd, true);
            Assert.AreEqual(0, endNodes.Count);
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:29,代码来源:ExEditableRange.cs

示例8: IncorrectStructureException

        public void IncorrectStructureException()
        {
            Document doc = new Document();

            DocumentBuilder builder = new DocumentBuilder(doc);

            //Is not valid structure for the current document
            Assert.That(() => builder.EndEditableRange(), Throws.TypeOf<InvalidOperationException>());

            builder.StartEditableRange();
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:11,代码来源:ExEditableRange.cs


注:本文中的DocumentBuilder.StartEditableRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。