Allow to unset a paragraph style with OpSetParagraph

This commit is contained in:
Friedrich W. H. Kossebau
2013-07-02 22:25:53 +02:00
parent abf45004e8
commit 64c009ae4e
2 changed files with 45 additions and 1 deletions
+5 -1
View File
@@ -61,7 +61,11 @@ ops.OpSetParagraphStyle = function OpSetParagraphStyle() {
if (domPosition) {
paragraphNode = odtDocument.getParagraphElement(domPosition.textNode);
if (paragraphNode) {
paragraphNode.setAttributeNS(textns, 'text:style-name', styleNameAfter);
if (styleNameAfter !== "") {
paragraphNode.setAttributeNS(textns, 'text:style-name', styleNameAfter);
} else {
paragraphNode.removeAttributeNS(textns, 'style-name');
}
odtDocument.getOdfCanvas().refreshSize();
odtDocument.emit(ops.OdtDocument.signalParagraphChanged, {
+40
View File
@@ -566,4 +566,44 @@
<office:text><text:p/></office:text>
</after>
</test>
<test name="SetParagraphStyle_unset_set">
<before>
<office:styles><style:style style:name="S" style:family="paragraph" style:class="text"/></office:styles>
<office:text><text:p/></office:text>
</before>
<ops>
<op optype="SetParagraphStyle" position="0" styleNameAfter="S"/>
</ops>
<after>
<office:styles><style:style style:name="S" style:family="paragraph" style:class="text"/></office:styles>
<office:text><text:p text:style-name="S"/></office:text>
</after>
</test>
<test name="SetParagraphStyle_set_set">
<before>
<office:styles><style:style style:name="S" style:family="paragraph" style:class="text"/><style:style style:name="SB" style:family="paragraph" style:class="text"/></office:styles>
<office:text><text:p text:style-name="SB"/></office:text>
</before>
<ops>
<op optype="SetParagraphStyle" position="0" styleNameAfter="S"/>
</ops>
<after>
<office:styles><style:style style:name="S" style:family="paragraph" style:class="text"/><style:style style:name="SB" style:family="paragraph" style:class="text"/></office:styles>
<office:text><text:p text:style-name="S"/></office:text>
</after>
</test>
<test name="SetParagraphStyle_set_unset">
<before>
<office:styles><style:style style:name="S" style:family="paragraph" style:class="text"/></office:styles>
<office:text><text:p text:style-name="S"/></office:text>
</before>
<ops>
<op optype="SetParagraphStyle" position="0" styleNameAfter=""/>
</ops>
<after>
<office:styles><style:style style:name="S" style:family="paragraph" style:class="text"/></office:styles>
<office:text><text:p/></office:text>
</after>
</test>
</tests>