Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Maintaining RichText Formatting
Topic Summary:
Created On: 19-Jul-2004 21:34
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 19-Jul-2004 21:34
User is offline View Users Profile Print this message


John Mazzie

Posts: 7
Joined: 7-Jul-2004

Hello,

I'm running scripts through large modules, and I would like to remove any spaces/tabs at the beginning and end of each object's text. The modules have objects with text that has mixed bolded and normal words. Is there an easy way to remove these spaces and set the text back with its original rich text formatting. I am using the following regexp to find the spaces/tabs:

Regexp spaceTab = regexp "([ ])|([TAB])" NOTE: The "TAB" represents a real tab.

Example of object text:

Requirements - The requirements.....
Thanks,
John Mazzie
Report this to a Moderator Report this to a Moderator
 20-Jul-2004 10:28
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

John,

The regexp you want to search for is:

Regexp spaceTabStart = regexp "^([ \\t]*)([^ \\t])"
Regexp spaceTabEnd = regexp "([ \\t]*)$"

This will search for zero or more spaces or tabs, in any order, followed by anything that isn't a space or a tab, or a start of line. Note the double \ -- you need to escape the escape character so that the regexp sees \t (a tab character). (Try searching for a double backslash in a string! )

For the start string, you need to return everything from the second match on, and for the end string, you need to return everything up to the character before the start of the first match. The code below gives a worked example.

Cheers,
Paul.

-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive
Report this to a Moderator Report this to a Moderator
 20-Jul-2004 13:36
User is offline View Users Profile Print this message


John Mazzie

Posts: 7
Joined: 7-Jul-2004

Thank you very much Paul. The code works great. I'm still having one problem though. If it is possible, I would like to keep the same formatting with the text(i.e. if a word is bolded, I would like it to stay bolded when I reassign the object text). Right now my code looks for anything bold in the text and if it finds something, it ends up making the entire object text bold.

o."Object Text" = richText "{\\b " ot "}"

ot = altered object text (removed spaces and tabs)

If anyone has any suggestions, I would greatly appreciate them.

Thank you,
John Mazzie
Report this to a Moderator Report this to a Moderator
 20-Jul-2004 16:42
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

You need to do some stuff with rich text paragraphs. You can scan through a rich text paragraph by chunk, determine the attributes of each chunk. For the first chunk, strip off the leading white space. For the last chunk, strip off the trailing white space. You'll need to check whether the first and last chunks are all white space and deal with that situation accordingly. Try the Rich Text section of the DXL manual -- there's a 'for RichTextParagraph in string' loop that will help you.

Enjoy!
Paul.

-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.