blob: 143bf32a19125cb2c3260e1822027c37867299a2 [file] [log] [blame]
////////////////////////////////////////////////////////////////////////////////
//
// 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.elements
{
import flash.text.engine.ElementFormat;
import flash.text.engine.TextElement;
import flash.text.engine.TextLine;
import flashx.textLayout.compose.BaseCompose;
import flashx.textLayout.compose.IFlowComposer;
import flashx.textLayout.compose.ISWFContext;
import flashx.textLayout.formats.ITextLayoutFormat;
import flashx.textLayout.tlf_internal;
use namespace tlf_internal;
public class TableLeafElement extends FlowLeafElement
{
private var _table:TableElement;
public function TableLeafElement(table:TableElement)
{
super();
_table = table;
}
/** @private */
override tlf_internal function createContentElement():void
{
// not sure if this makes sense...
if (_blockElement)
return;
computedFormat; // BEFORE creating the element
var flowComposer:IFlowComposer = getTextFlow().flowComposer;
var swfContext:ISWFContext = flowComposer && flowComposer.swfContext ? flowComposer.swfContext : BaseCompose.globalSWFContext;
var format:ElementFormat = FlowLeafElement.computeElementFormatHelper (_table.computedFormat, _table.getParagraph(), swfContext)
_blockElement = new TextElement(_text,format);
CONFIG::debug { Debugging.traceFTECall(_blockElement,null,"new TextElement()"); }
CONFIG::debug { Debugging.traceFTEAssign(_blockElement, "text", _text); }
super.createContentElement();
}
/** @private */
override protected function get abstract():Boolean
{ return false; }
/** @private */
tlf_internal override function get defaultTypeName():String
{ return "table"; }
/** @private */
public override function get text():String
{
return String.fromCharCode(0x16);
}
/** @private */
public override function getText(relativeStart:int=0, relativeEnd:int=-1, paragraphSeparator:String="\n"):String
{
return _table.getText(relativeStart, relativeEnd, paragraphSeparator);
}
/** @private */
tlf_internal override function normalizeRange(normalizeStart:uint,normalizeEnd:uint):void
{
// not sure what to do here (see SpanElement)...
super.normalizeRange(normalizeStart,normalizeEnd);
}
/** @private */
tlf_internal override function mergeToPreviousIfPossible():Boolean
{
// not sure what to do here (see SpanElement)...
return false;
}
public override function getNextLeaf(limitElement:FlowGroupElement=null):FlowLeafElement
{
return _table.getNextLeafHelper(limitElement,this);
}
public override function getPreviousLeaf(limitElement:FlowGroupElement=null):FlowLeafElement
{
return _table.getPreviousLeafHelper(limitElement,this);
}
/** @private */
public override function getCharAtPosition(relativePosition:int):String
{
return getText(relativePosition,relativePosition);
}
public override function get computedFormat():ITextLayoutFormat
{
return _table.computedFormat;
}
public override function get textLength():int
{
return _table.textLength;
}
tlf_internal override function updateAdornments(tLine:TextLine, blockProgression:String):int
{
return 0;
}
override public function get parent():FlowGroupElement
{
return _table;
}
override public function getTextFlow():TextFlow
{
return _table.getTextFlow();
}
override public function getParagraph():ParagraphElement
{
return _table.getParagraph();
}
override public function getElementRelativeStart(ancestorElement:FlowElement):int
{
return _table.getElementRelativeStart(ancestorElement);
}
}
}