Topic
3 replies Latest Post - ‏2012-11-28T00:04:42Z by Mathias Mamsch
Irons
Irons
4 Posts
ACCEPTED ANSWER

Pinned topic Trouble sniffing out tabs in RTF

‏2012-11-20T23:06:26Z |
I’m running into issues identifying when tabs occur. How does DOORS treat tabs in rich text paragraphs? My ultimate goal is to replace all tabs with a space.

Here’s a sample:

TEST-Requirements
a) blah blah

Using a quick print of the current object's text including the RTF yields:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}
\viewkind4\b TEST-Requirements\b0\par
a) blah blah\par}

I'm not seeing how DOORS is looking at the tabs themselves. The typical \tab does not print with the rest of the Rich Text. Does DOORS include these RTF prefixes, and if so, how can I manipulate them?

Thanks so much!
Updated on 2012-11-28T00:04:42Z at 2012-11-28T00:04:42Z by Mathias Mamsch
  • Mathias Mamsch
    Mathias Mamsch
    1911 Posts
    ACCEPTED ANSWER

    Re: Trouble sniffing out tabs in RTF

    ‏2012-11-26T22:47:09Z  in response to Irons

    Why would you think that DOORS does not print tabs? When I execute the following code:
     

    (current Object)."Object Text" = richText "Line 1\\par\\tab Line 2\\par\\tab\\tab Line 3\\par"
    

     

    Then I get the following result:

     

    Line 1
        Line 2
            Line 3
    



    To replace those you need to scan for \tab in the richText, but when replacing you need to take care about some special cases:

     

     

    • even number (escaped) backslashes (e.g. \\tab, \\\\tab, etc. but NOT \\\tab, \\\\\tab) is the literal text \tab
    • If there is a space as a termiantor after the tab you need to check, if there is an RTF keyword before. If so the terminating space must be kept, e.g. "Test\\line\\tab test" will become "Test\\line test" (with 2 spaces)
    • If there is no rtf keyword before the \\tab then the terminator has to go to, e.g. "Test\\tab Text" will become "Test Text" (with 1 space).


    That should do it, if you need help, just ask. Regards, Mathias

    Regards, Mathias

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

    Updated on 2014-01-06T14:46:42Z at 2014-01-06T14:46:42Z by iron-man
    • llandale
      llandale
      2939 Posts
      ACCEPTED ANSWER

      Re: Trouble sniffing out tabs in RTF

      ‏2012-11-27T18:00:15Z  in response to Mathias Mamsch
      "\tabular " is an unrecognized ignored keyword; not a Tab followed by "ular".

      I think the character AFTER the "\tab" must be a space, a slash \, or a bracket {}. I wonder if there are others. If it is a space you'd replace "\tab " with a space; otherwise replace "\tab" with a space.

      -Louie

      You can also replace the raw-text tabs '\t' in the rich text. There is some thread on that using replaceRichText().
      • Mathias Mamsch
        Mathias Mamsch
        1911 Posts
        ACCEPTED ANSWER

        Re: Trouble sniffing out tabs in RTF

        ‏2012-11-28T00:04:42Z  in response to llandale

        Louie you are only partially correct! One space can be a terminator for multiple RTF control words, e.g. Test\line\tab test. If you replaced the space too then you would get Test\line test which will just remove the tab, not replace it by a space. So in this case you must not replace the space, even though a space is used as a terminator.

        The RTF terminators can be seen from the RTF spec by the way:
         

        The "delimiter" marks the end of an RTF control word or symbol. A
        delimiter can be one of the following:
         
         - A space. If a space delimits a control word, the space does not
           appear in the document. Any characters following the delimiter,
           including spaces, do appear in the document. For this reason, you
           should use spaces only where necessary; do not use spaces merely to
           break up RTF code.
         
         - A backslash (\), opening brace ({), or closing brace (}). These
           characters are used to mark the beginning of a new control word or
           symbol, the beginning of a group, and end of a group, respectively.
           More information about control symbols and groups is provided later
           in this document.
         
         - Any character other than a letter or a digit. In this case, the
           character terminates the control word but is not actually part of
           the control word. The character is considered part of the document
           text.
        

         


        So a backslash or #()!, etc. these should all be valid delimiters for a control word. Did not try it by the way.

        Regards, Mathias

         

         

         


        Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

         

         

        Updated on 2014-01-06T14:47:04Z at 2014-01-06T14:47:04Z by iron-man