Skip to main content
Ch__Efstathios
Inspiring
June 1, 2016
Answered

How to get the current line or the whole paragraph?

  • June 1, 2016
  • 2 replies
  • 523 views

Hi.

I am facing the following problem:

Suppose that I have the following paragraphs in FrameMaker:

This is a sentence. And   (simple line end)

also there this sentence. (paragraph end)

This is a sentence. And   (hard return)

also there this sentence. (paragraph end)

This is a sentence. And   (simple line end)

also there this sentence. (hard return)

But there is also this sentence (paragraph end)

This is a sentence. And   (simple line end)

also there this sentence. (hard return)

also there this sentence. (hard return)

But there is also this sentence (paragraph end)

What I want is the following:

Get the whole paragraph text where the insertion point of the cursor is.

However, when hard line ends exist I want to change behavior.

Here is the behavior for the above paragraphs:

For the first paragraph example if the cursor is either in first or in second line I want to get the whole paragraph.

For the second paragraph if the cursor is in the first line I want only the first line. And if it is in the second line I want only the second line.

For the third paragraph if the cursor either in first or second line I want both first and second lines to be retrieved as single text. Also if the cursor is in the third line I want only the third line.

For the fourth paragraph it works like the third paragraph. And if the cursor is in the third line I get only this one.

Could you please provide some code with FDK in C++ to start with?

It is a brain teaser.

This topic has been closed for replies.
Correct answer 4everJang

As you are in the Scripting forum, I am relating to that here. You will have to figure out the C++ code from the FDK yourself.

There is not a lot to tease my brain with this. You get the paragraph where the cursor is and retrieve the text plus line ends via the GetText() method, using a bit field that includes both FTI_String and FTI_LineEnd. Each line end has a modifier that tells you whether it is a hard or a soft return. You also get the offset in the paragraph of the current cursor position and then create the required strings from the array of text items returned by the GetText method.

If you want full running code, ask someone to program it for you and be prepared to pay for the work.

Good luck

2 replies

Ch__Efstathios
Inspiring
August 12, 2016

Problem solved. Thanks.

4everJang
4everJangCorrect answer
Legend
June 1, 2016

As you are in the Scripting forum, I am relating to that here. You will have to figure out the C++ code from the FDK yourself.

There is not a lot to tease my brain with this. You get the paragraph where the cursor is and retrieve the text plus line ends via the GetText() method, using a bit field that includes both FTI_String and FTI_LineEnd. Each line end has a modifier that tells you whether it is a hard or a soft return. You also get the offset in the paragraph of the current cursor position and then create the required strings from the array of text items returned by the GetText method.

If you want full running code, ask someone to program it for you and be prepared to pay for the work.

Good luck

Ch__Efstathios
Inspiring
June 2, 2016

Thanks people, I have done it.