Aspose::Words::DocumentBuilder::InsertDocumentInline method
DocumentBuilder::InsertDocumentInline method
Inserts a document inline at the cursor position.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::DocumentBuilder::InsertDocumentInline(const System::SharedPtr<Aspose::Words::Document> &srcDoc, Aspose::Words::ImportFormatMode importFormatMode, const System::SharedPtr<Aspose::Words::ImportFormatOptions> &importFormatOptions)
Parameter | Type | Description |
---|---|---|
srcDoc | const System::SharedPtr<Aspose::Words::Document>& | Source document for inserting. |
importFormatMode | Aspose::Words::ImportFormatMode | Specifies how to merge style formatting that clashes. |
importFormatOptions | const System::SharedPtr<Aspose::Words::ImportFormatOptions>& | Allows to specify options that affect formatting of a result document. |
ReturnValue
First node of the inserted content.
Remarks
This method mimics the MS Word behavior, as if CTRL+‘A’ (select all content) was pressed, then CTRL+‘C’ (copy selected into the buffer) inside one document and then CTRL+‘V’ (insert content from the buffer) inside another document.
As a difference from InsertDocument() this method moves the content of the paragraph of the destination document, before which the source document is inserted, into the last paragraph of the inserted source document. Actually, this means that paragraph break of the last inserted paragraph is removed.
Note, if the last node of the source document is not a paragraph, then nothing will be done.
Examples
Shows how to insert a document inline at the cursor position.
auto srcDoc = System::MakeObject<Aspose::Words::DocumentBuilder>();
srcDoc->Write(u"[src content]");
// Create destination document.
auto dstDoc = System::MakeObject<Aspose::Words::DocumentBuilder>();
dstDoc->Write(u"Before ");
dstDoc->InsertNode(System::MakeObject<Aspose::Words::BookmarkStart>(dstDoc->get_Document(), u"src_place"));
dstDoc->InsertNode(System::MakeObject<Aspose::Words::BookmarkEnd>(dstDoc->get_Document(), u"src_place"));
dstDoc->Write(u" after");
ASSERT_EQ(u"Before after", dstDoc->get_Document()->GetText().TrimEnd(System::MakeObject<System::Array<char16_t>>(0)));
// Insert source document into destination inline.
dstDoc->MoveToBookmark(u"src_place");
dstDoc->InsertDocumentInline(srcDoc->get_Document(), Aspose::Words::ImportFormatMode::UseDestinationStyles, System::MakeObject<Aspose::Words::ImportFormatOptions>());
ASSERT_EQ(u"Before [src content] after", dstDoc->get_Document()->GetText().TrimEnd(System::MakeObject<System::Array<char16_t>>(0)));
See Also
- Class Node
- Class Document
- Enum ImportFormatMode
- Class ImportFormatOptions
- Class DocumentBuilder
- Namespace Aspose::Words
- Library Aspose.Words for C++