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

How to get the current line or the whole paragraph?

Participant ,
Jun 01, 2016 Jun 01, 2016

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

369

Translate

Translate

Report

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

correct answers 1 Correct answer

Advocate , Jun 01, 2016 Jun 01, 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 a

...

Votes

Translate

Translate
Advocate ,
Jun 01, 2016 Jun 01, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Participant ,
Jun 02, 2016 Jun 02, 2016

Copy link to clipboard

Copied

Thanks people, I have done it.

Votes

Translate

Translate

Report

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
Participant ,
Aug 12, 2016 Aug 12, 2016

Copy link to clipboard

Copied

LATEST

Problem solved. Thanks.

Votes

Translate

Translate

Report

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