This is a migrated thread and some comments may be shown as answers.

Inserting annotation in document

5 Answers 103 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 06 Dec 2015, 03:21 PM

Hi,

For instance I have to cut fragment from a document and paste it in another one. The fragment is AnnotationRange and it has others annotation elements inside. When I insert it GetRootDocument for parent element is not null (it's my document), but for children it is null.

How can I set my document as owner for all internal elements?

Thanks in advance.

5 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 09 Dec 2015, 11:09 AM
Hi Alexander,

If you are enumerating the elements in the document fragment which shall be pasted into another document, their root document is normal to be null, because the root document calculations are based on the document collection elements and the corresponding to the elements associated layout boxes.

However, after the insertion of the fragment in the new document, the root document of the inserted DocumentElement objects should be the document where they are inserted to. There isn't a way to change the document owner of a document element and this is by design.

I hope this information is helpful.

Regards,
Todor
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Alexander
Top achievements
Rank 1
answered on 09 Dec 2015, 01:02 PM

Todor, thank you for your anwer. 

The elements from the document fragment are not displayed after inserting the fragment in my document. How can I use these elements from editor if editor's document isn't owner of them?

0
Todor
Telerik team
answered on 12 Dec 2015, 11:31 AM
Hello Alexander,

I'm not sure I understand your exact scenario. Please try to shed some more light on what you are trying to achieve and what the desired result should be. Maybe we can suggest you a more suitable solution for the problem.

About the not displayed document elements after insertion of a document fragment - I've tried to reproduce the issue, but to no avail. You can find the project with which I've tested attached. Please, try to modify it or create another one and send it back to us. In this way, it will be much easier for us to find what might cause the issue.

Looking forward to your reply.

Regards,
Todor
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Alexander
Top achievements
Rank 1
answered on 13 Dec 2015, 04:12 PM

Todor, thank you.
I've changed your solution.Sorry, if my variant is large or complex. 
I marked with breakpoint where it was problem with root document.

P.S. I renamed .zip to .jpg because .zip is from not allowed type.

0
Todor
Telerik team
answered on 16 Dec 2015, 08:28 AM
Hello Alexander,

I've tested the project you've sent and the annotations are inserted. You can easily verify that by just enumerating the inlines of the Document of the second RadRichTextBox (the one with "rtb2"). 

However, the text representation depends on the implementation of your custom document elements. In your case, the Souce property of your FieldStart object holds the text which is copied from the first Document. You should modify the DataRangeStart.CreateDocumentFragment() method (and more precisely the GetDocumentFragment() implementation in the classes which inherit the DataRangeStart class) which is invoked from the DrawContent() method in order the correct Span or other elements to be inserted in the DocumentFragment. 

More about Annotations and custom Annotations you can read in the corresponding help articles.

Regards,
Todor
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
RichTextBox
Asked by
Alexander
Top achievements
Rank 1
Answers by
Todor
Telerik team
Alexander
Top achievements
Rank 1
Share this question
or