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

Remove userStyle entry without ApplyElementUserStyleOperation?

Community Beginner ,
Mar 09, 2012 Mar 09, 2012

Copy link to clipboard

Copied

ApplyElementUserStyleOperation is deprecated with TLF 2.0. But I can't find a way to remove a userStyle without it. If I try to use ApplyFormatToElement with a TextLayoutFormat, it won't clear userStyles set to "undefined", just as it won't clear other styles.

Any suggestions? My code is working now using ApplyElementUserStyleOperation, but it always feels wrong to use deprecated methods.

TOPICS
Text layout framework

Views

2.8K

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
Adobe Employee ,
Mar 11, 2012 Mar 11, 2012

Copy link to clipboard

Copied

Use “delete” to undefine a property

if (val === undefined) delete _styles[val];

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
Community Beginner ,
Mar 12, 2012 Mar 12, 2012

Copy link to clipboard

Copied

Good point, I've tried that and it works. But in this case I need to keep the undo-stack intact, and manipulating properties directly reset it. Is there any way of clearing user styles through the EditManager?

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
Adobe Employee ,
Mar 12, 2012 Mar 12, 2012

Copy link to clipboard

Copied

ClearFormatOnElementOperation or ClearFormatOperation

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
Community Beginner ,
Mar 13, 2012 Mar 13, 2012

Copy link to clipboard

Copied

LATEST

No, that doesn't work. Or at least, ClearFormatOnElementOperation doesn't work for clearing userStyles.

The below method in ClearFormatOnElementOperation does the job. The problem is that TextLayoutFormat.description object which it iterates on does not contain userStyles as far as I can see.

public override function doOperation():Boolean

                    {

                              var targetElement:FlowElement = getTargetElement();

 

                              adjustForDoOperation(targetElement);

 

                              _undoStyles = new TextLayoutFormat(targetElement.format);

 

                              if (_format)

                              {

                                        var newFormat:TextLayoutFormat = new TextLayoutFormat(targetElement.format);

  // this is fairly rare so this operation is not optimizied

                                        for (var prop:String in TextLayoutFormat.description)

                                        {

                                                  if (_format[prop] !== undefined)

                                                            newFormat[prop] = undefined;

                                        }

                                        targetElement.format = newFormat;

                              }

 

  return true;

                    }

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