Quantcast
Channel: Adobe Community: Message List - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 3715

Re: Best way to copy range of paragraphs

$
0
0

Hi Mark,

 

Glad you are making progress. About the Pgfs in tables: yes, they are in a world of their own. Each table is a more or less closed object anchored to a paragraph in the document. You can step through all Pgfs in a document (including the ones in your text flows as well as the ones in table cells) using one single linked list, but that list does not care about the order in which the paragraphs appear in your document, and also includes paragraphs on your master and reference pages. This is not what you want to have.

 

You mentioned you wanted to copy not just the paragraph with changebars but the section that contains at least one paragraph with changebars. One strategy is finding a paragraph with changebars and then tracking back to the previous heading and forward to the next heading, so that you can determine which section to copy to your changes document. With the requirement of checking paragraphs in tables added into the equation, this becomes a complex matter. Even if you know that a paragraph in a table cell has a changebar set, you should track back to the table anchor, then to the paragraph in which the anchor is located, and then back to the section that you need to copy. And if the section also contains a paragraph with changebars outside a table, you do not want to copy it again.

 

This might require a completely different approach to the problem. Build an array with paragraph identifiers of all headings in your document, and create an array of booleans all set to false that has the same number of entries. Then find all paragraphs with changebars and, for each found paragraph, walk back to the nearest heading, find the heading identifier in the headings array and set the corresponding entry in the boolean array to true. Then do the same thing with paragraphs with changebars in tables. In this case, you track the paragraph in the table back to its table anchor, then to the paragraph containing the table anchor and from there walk back to the nearest heading.

 

In the end you will have an array of heading paragraph identifiers and a matching array of booleans telling you which sections to copy to the changes document. Doing the copying is dead easy, as you already have the start and end paragraph identifier for each section. Just create a TextLoc pointing at the first heading Pgf with offset 0 and a TextLoc pointing at the next heading Pgf with offset 0 and copy this range.

 

I hope this makes sense to you. If things get too complicated, throw me an email (you will find my mail address in my profile) with a sample file and I will have a look at it. If I think it will take me more than a couple of hours to write, I will make you a decent offer.

 

Kind regards

 

Jang


Viewing all articles
Browse latest Browse all 3715

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>