//////////////////////////////////////////////////////////////////////////////// // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// package flashx.textLayout.operations { import flashx.textLayout.debug.assert; import flashx.textLayout.edit.ElementRange; import flashx.textLayout.edit.ParaEdit; import flashx.textLayout.edit.SelectionState; import flashx.textLayout.elements.TextFlow; import flashx.textLayout.formats.Category; import flashx.textLayout.formats.ITextLayoutFormat; import flashx.textLayout.formats.TextLayoutFormat; import flashx.textLayout.formats.TextLayoutFormatValueHolder; import flashx.textLayout.property.Property; import flashx.textLayout.tlf_internal; use namespace tlf_internal; /** * The ClearFormatOperation class encapsulates a way to undefine formats. * *
An UndefineFormatOperation undefines properties set in the leaf format to the text in the * specified range (no change is made if the specified range is a single point). * It undefines properties set in the paragraph format to any paragraphs at least partially within the range * (or a single paragraph if the range is a single point). * And it undefines properties set in the container format to any containers at least partially within the range * (or a single container if the range is a single point).
* * @see flashx.textLayout.edit.EditManager * @see flashx.textLayout.events.FlowOperationEvent * * @includeExample examples\ApplyFormatOperation_example.as -noswf * * @playerversion Flash 10 * @playerversion AIR 1.5 * @langversion 3.0 */ public class ClearFormatOperation extends FlowTextOperation { private var applyLeafFormat:ITextLayoutFormat; private var applyParagraphFormat:ITextLayoutFormat; private var applyContainerFormat:ITextLayoutFormat; // helper array of styles to revert // each entry has a begIdx, endIdx, ContainerFormat private var undoLeafArray:Array; private var undoParagraphArray:Array; private var undoContainerArray:Array; /** * Creates an ClearFormatOperation object. * * @param operationState Defines the text range to which the format is applied. * @param leafFormat The format whose set values indicate properties to undefine to LeafFlowElement objects in the selected range. * @param paragraphFormat The format whose set values indicate properties to undefine to ParagraphElement objects in the selected range. * @param containerFormat The format whose set values indicate properties to undefine to ContainerController objects in the selected range. * * @playerversion Flash 10 * @playerversion AIR 1.5 * @langversion 3.0 */ public function ClearFormatOperation(operationState:SelectionState, leafFormat:ITextLayoutFormat, paragraphFormat:ITextLayoutFormat, containerFormat:ITextLayoutFormat = null) { super(operationState); this.leafFormat = leafFormat; this.paragraphFormat = paragraphFormat; this.containerFormat = containerFormat; } /** * The format properties to undefine on the leaf elements in the range. * *If the range of this operation is a point, or if leafFormat
is null
,
* then no leaf element formats are changed.
The formats of any paragraphs at least partially within the range are updated.
* If the range of this operation is a point, then a single paragraph is updated.
* If paragraphFormat
is null
, then no paragraph formats are changed.
The formats of any containers at least partially within the range are updated.
* If the range of this operation is a point, then a single container is updated.
* If containerFormat
is null
, then no container formats are changed.