Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Problem with F_ApiAddText() after F_ApiPaste()

New Here ,
Aug 05, 2008 Aug 05, 2008
Hello,

I've some troubles adding text to structured document after I paste some text from clipboard into it. Here it is how it goes in the code:

...

F_ApiSetTextRange(FV_SessionId, m_docId, FP_TextSelection, &tr);
F_ApiPaste(m_docId, 0);
F_ApiPopClipboard();

...

F_TextLoc addLoc;
addLoc.objId = m_paragraphId;
addLoc.offset = tr.beg.offset + pastedObjectLen;

F_ApiAddText(m_docId, &addLoc, newText);

The object from clipboard (in fact it's cross-reference) is pasted correctly to the right position but no text is added from then on.

pastedObjectLen is length of the cross-reference text (including the element begin/end tags)

I tried more variations of the line:
addLoc.offset = tr.beg.offset + 1;
addLoc.offset = tr.beg.offset + 2;
...

But nothing works.

Can somebody see where the problem lies?

I'm using FrameMaker8.

Thank you!
TOPICS
Structured
809
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 05, 2008 Aug 05, 2008
Now I discovered something. I checked the return value of F_ApiAddText() and FA_errno after the call and I found out that F_ApiAddText() returns F_TextLoc with { objId = 0, offset = 0 }, so invalid text location. FA_errno has the value FE_BadObjId.

So I investigated further and before the F_ApiAddText() call I traverse all paragraphs in the document and the paragraph to which I pasted the cross-reference is suddenly not there! Or to say it precisely, there is no paragraph with m_paragraphId anymore in the list of document's paragraphs.

How is that possible?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 06, 2008 Aug 06, 2008
Stanislav,

What is the exact task you are trying to perform? Someone may be able to give you an alternative solution.

Rick Quatro
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 07, 2008 Aug 07, 2008
Hi Rick,

thank you for response. What I was trying to do is copy&pasting cross-reference from one place to another and then adding some text behind it.

Eventually, I found the solution. As I had already written, the paragraph ID is changed after the cross-reference is pasted into it. What I tried first was to save paragraph's UID and then obtain its new ID by calling F_ApiGetUniqueObject() but it didn't work (this function returned 0).

Simple solution is to call F_ApiGetTextRange(FV_Session, docId, FP_TextSelection) after pasting the cross-reference and extract paragraph ID from the returned F_TextRangeT structure.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 07, 2008 Aug 07, 2008
Hi Stanislav,

I'm happy that you got it working, but just for future reference, I don't believe that a paragraph ID should change just because you pasted an xref into it. At least, assuming you are talking about its F_ObjHandleT ID. If you thought that you saw an object handle change, you might take a closer look at it next time... could just have been a bug somewhere in your code.

Russ
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
LATEST
Hi Russ,

I also thought there is no reason for paragraph's ID to change after pasting xref into it. But it's really the case. When I tried to call eg. F_ApiAddText() after pasting the xref with the original ID, it failed. I think the proof is the solution I found: new paragraph ID obtained from F_TextRangeT tr = F_ApiGetTextRange(..., FP_TextSelection) is different from the original one.

One more note: I think that paragraph ID changed only if the xref pasted was unresolved, ie. if it pointed to some unavailable location.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines