2016-11-10 33 views
0

我正在使用下面的代碼來將填充應用於InlineGraphicElement,但它似乎只應用該值並且未將其刪除。如何從TLF中的FlowElement中刪除樣式?

imageFloat = inlineGraphicElement.float; 
newFormat = new TextLayoutFormat(); 

if (imageFloat==Float.LEFT || imageFloat==Float.START) { 
    newFormat.paddingRight = 5; 
    inlineGraphicElement.paddingRight = 5; 
} 
else if (imageFloat==Float.RIGHT || imageFloat==Float.END) { 
    newFormat.paddingLeft = 5; 
    inlineGraphicElement.paddingLeft = 5; 
} 
else { 
    newFormat.paddingLeft = undefined; 
    newFormat.paddingRight = undefined; 
} 

absoluteStart = inlineGraphicElement.getAbsoluteStart(); 
textContainerManager = richEditableText.mx_internal::textContainerManager as RichEditableTextContainerManager; 
textContainerManager.applyFormatOperation(newFormat, null, null, absoluteStart, absoluteStart+1); 

它看起來像忽略未定義的值。現在我不確定如何將填充重置爲無。

UPDATE:
我發現在編輯管理類clearFormat方法:

editManager = richEditableText.textFlow.interactionManager as IEditManager; 
currentFormat = new TextLayoutFormat(); 
currentFormat.paddingLeft = 1; 
currentFormat.paddingRight = 1; 

editManager.clearFormat(currentFormat, null, null); 

我不知道這是正確的,但。但是,如果它似乎工作,我會添加它作爲答案。

回答

0

我發現在編輯管理類clearFormat方法:

editManager = richEditableText.textFlow.interactionManager as IEditManager; 
currentFormat = new TextLayoutFormat(); 
currentFormat.paddingLeft = 1; 
currentFormat.paddingRight = 1; 

editManager.clearFormat(currentFormat, null, null); 

你必須給的值要未定義的屬性。新的TextLayoutFormat對象中的所有值都是未定義的。因此,要刪除FlowElement上的任何樣式,請將該樣式設置爲undefined以外的值,然後調用clearFormat(myTextLayoutFormat)傳遞要刪除屬性的對象。

+0

看來,如果選擇延伸到段落上,它不會刪除格式。 –