6 Replies Latest reply on May 22, 2008 3:03 PM by sstanleyau

    Clearing Overrides [AS}

    Level 1
      I don't seem to be able to clear character overrides when applying a paragraph style with a script to a CS3 document. I've tried it a number of ways, following the dictionary closely but no luck. It just doesn't seem to clear character overrides. Does anyone know if this is a bug? What follows is the section of my script with the clear/apply in it.

      What happens is this:

      The script places a new anchored text box at the end of a line of text. That line has a paragraph style applied to it and a nested style that uses a character style for the first word and then the unaltered applied paragraph style for the rest of the line. The anchor mark is immediately before the hard return at the end of that line. What happens is that the text in the anchored text box is carrying over the character style from the paragraph it's anchored in. Note that the character style is otherwise only affecting the first word in this paragraph, so it doesn't seem like it should carry over. Once the anchored text box is created, it gets an applied object style and its text contents get an applied paragraph style. However, neither of those two actions can clear the character style. Here's the code snippet:

      --place New Style Box
      if text of item 12 of Rev_Style_List ≠ "" then
      set myInsertionPoint to insertion point -2
      tell myInsertionPoint
      set myGraphicFrame to make rectangle with properties {content type:text type, contents:"", geometric bounds:{114.48, 546.768, 128.88, 573.768}}
      tell myGraphicFrame
      set contents of insertion point -1 to ("NEW STYLE")
      set theParagraph to the object reference of last paragraph
      set theParagraphStyle to NewColorStyleBox
      tell theParagraph
      clear overrides overrides to clear all
      apply paragraph style using theParagraphStyle
      end tell
      apply object style using NewStyleBox
      end tell
      end tell
      end if
        • 1. Re: Clearing Overrides [AS}
          Brad Walrod Level 1
          Looking at this from a user (not a scripter) perspective, I'm just
          wondering if you should apply the paragraph style before you clear
          the overrides. Or apply the object style first, assuming you're
          willing to make the application of the paragraph style part of the
          object style definition.

          Brad


          On May 21, 2008, at 3:16 PM, chris harges wrote:

          > tell theParagraph
          > clear overrides overrides to clear all
          > apply paragraph style using theParagraphStyle
          > end tell
          > apply object style using NewStyleBox
          • 2. Re: Clearing Overrides [AS}
            Level 1
            Thanks Brad. I've actually tried these variations:

            style the text using the paragraph style embedded in the object style
            apply the object style and then apply the paragraph style to the text
            apply a character style of None to the text contents of the text frame before applying the paragraph style
            playing with a variety of options to the nested style in the paragraph style applied to the line that contains the anchor

            No go with any of these.

            Now I'm trying to script a Find/Replace. That works with the Find/Replace window in the GUI but I'm having a little more trouble when I'm scripting it. Again, it doesn't seem to want to take the styles I'm applying with something like this:

            set properties of find text preferences to {find what:"NEW STYLE", applied paragraph style:paragraph style "FTW--New Color/Style Box"}

            set properties of change text preferences to {applied character style:character style "[None]", applied paragraph style:paragraph style "FTW--New Color/Style Box"}
            • 3. Re: Clearing Overrides [AS}
              sstanleyau Level 4
              Clearing overrides won't clear a character style; by definition that's not<br />an override. You need to make sure no character style is applied by applying<br />character style "[None]".<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
              • 4. Re: Clearing Overrides [AS}
                Level 1
                Excellent! Thanks Shane. I had flailed down that path a bit but I think I was trying to apply the character style to the contents of the anchored text frame rather than just adding a "apply character style using..." to the same block where I am applying the paragraph style to the last paragraph.

                What do overrides clear, anyway? I had thought that that's what this dictionary item was about:

                clear overrides v : Clears the specified types of override.
                clear overrides specifier : Supported by the following objects: text, character, word, line, text column, paragraph, text style range, insertion point, story.
                [overrides to clear all/character only/paragraph only] : The types of override to clear.

                Of course, it's possible that I'm not really sure what an "override" is.
                • 5. Re: Clearing Overrides [AS}
                  Level 1
                  Excellent! Thanks Shane. I had flailed down that path a bit but I think I was trying to apply the character style to the contents of the anchored text frame rather than just adding a "apply character style using..." to the same block where I am applying the paragraph style to the last paragraph.

                  What do overrides clear, anyway? I had thought that that's what this dictionary item was about:

                  >clear overrides v : Clears the specified types of override.
                  clear overrides specifier : Supported by the following objects: text, character, word, line, text column, paragraph, text style range, insertion point, story.
                  [overrides to clear all/character only/paragraph only] : The types of override to clear.

                  Of course, it's possible that I'm not really sure what an "override" is.
                  • 6. Re: Clearing Overrides [AS}
                    sstanleyau Level 4
                    An override is manual formatting -- anything not done via a paragraph or<br />character style.<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>