summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-03-19 11:19:54 +0100
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2014-03-20 10:28:22 +0100
commit64ad575674e6170ebb8ebeeacd41b14af07a0377 (patch)
tree18b8b7b7944082a46d6f941143f331b97b47d505 /writerfilter
parentde1f5cb2ad67d94dfac46b3577a7c0b8ed06ba6d (diff)
ooxml: preserve checkbox sdt control
Checkbox controls in docx are implemented with a sdt block containing the property w:14:checkbox, which has several child elements. To implement the preservation of the field, we had to add several tags to the ooxml model file. Notice they belong to namespace w14, that's why we had to add a redundant definitions of CT_STRING, ST_STRING and their actions. Then, we just used the existing mechanisms on the importer and the exporter. Finally, added a unit test. TODO: the checkbox is preserved on export but it cannot be modified. We should import it like we do for combo and date boxes. Change-Id: I40f29b48ec24719c48482b9c8cff10176d1b188d
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx4
-rw-r--r--writerfilter/source/ooxml/model.xml44
2 files changed, 47 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 0407fd1907d7..e1215f09e846 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2234,6 +2234,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
}
break;
case NS_ooxml::LN_CT_SdtPr_equation:
+ case NS_ooxml::LN_CT_SdtPr_checkbox:
case NS_ooxml::LN_CT_SdtPr_docPartObj:
case NS_ooxml::LN_CT_SdtPr_docPartList:
case NS_ooxml::LN_CT_SdtPr_picture:
@@ -2250,6 +2251,9 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
pProperties->resolve(*this);
}
break;
+ case NS_ooxml::LN_CT_SdtCheckbox_checked:
+ case NS_ooxml::LN_CT_SdtCheckbox_checkedState:
+ case NS_ooxml::LN_CT_SdtCheckbox_uncheckedState:
case NS_ooxml::LN_CT_SdtDocPart_docPartGallery:
case NS_ooxml::LN_CT_SdtDocPart_docPartCategory:
case NS_ooxml::LN_CT_SdtDocPart_docPartUnique:
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index d80f2e2d1a3e..ca9685df01a7 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -6280,9 +6280,47 @@
<ref name="CT_OnOff"/>
</element>
</define>
+
+ <define name="ST_String">
+ <data type="string">
+ <xs:documentation>String</xs:documentation>
+ </data>
+ </define>
+ <define name="CT_String">
+ <attribute name="val">
+ <ref name="ST_String"/>
+ <xs:documentation>value</xs:documentation>
+ </attribute>
+ </define>
+ <define name="CT_SdtCheckbox">
+ <optional>
+ <element name="checked">
+ <ref name="CT_String"/>
+ </element>
+ </optional>
+ <optional>
+ <element name="checkedState">
+ <ref name="CT_String"/>
+ </element>
+ </optional>
+ <optional>
+ <element name="uncheckedState">
+ <ref name="CT_String"/>
+ </element>
+ </optional>
+ </define>
</grammar>
<!-- Simple Types Resource Definitions -->
+ <resource name="CT_String" resource="Value" tag="attribute">
+ <attribute name="val" tokenid="ooxml:CT_String_val" action="setValue"/>
+ <action name="start" action="setDefaultStringValue"/>
+ </resource>
+ <resource name="CT_SdtCheckbox" resource="Properties" tag="field">
+ <element name="checked" tokenid="ooxml:CT_SdtCheckbox_checked">checked</element>
+ <element name="checkedState" tokenid="ooxml:CT_SdtCheckbox_checkedState">checkedState</element>
+ <element name="uncheckedState" tokenid="ooxml:CT_SdtCheckbox_uncheckedState">uncheckedState</element>
+ </resource>
<resource name="ST_SchemeColorVal" resource="List" generated="yes">
<value name="bg1" tokenid="ooxml:ST_SchemeColorVal_bg1">bg1</value>
<value name="tx1" tokenid="ooxml:ST_SchemeColorVal_tx1">tx1</value>
@@ -18860,6 +18898,9 @@
<element name="comboBox">
<ref name="CT_SdtComboBox"/>
</element>
+ <element name="w14:checkbox">
+ <ref name="CT_SdtCheckbox"/>
+ </element>
<element name="date">
<ref name="CT_SdtDate"/>
</element>
@@ -24508,7 +24549,7 @@
<attribute name="val" tokenid="ooxml:CT_CalendarType_val" action="setValue"/>
<action name="start" action="setDefaultStringValue"/>
</resource>
- <resource name="CT_SdtPr" resource="Properties" tag="field">
+ <resource xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" name="CT_SdtPr" resource="Properties" tag="field">
<element name="rPr" tokenid="ooxml:CT_SdtPr_rPr"/>
<element name="alias" tokenid="ooxml:CT_SdtPr_alias"/>
<element name="lock" tokenid="ooxml:CT_SdtPr_lock"/>
@@ -24520,6 +24561,7 @@
<element name="tag" tokenid="ooxml:CT_SdtPr_tag"/>
<element name="equation" tokenid="ooxml:CT_SdtPr_equation"/>
<element name="comboBox" tokenid="ooxml:CT_SdtPr_comboBox"/>
+ <element name="w14:checkbox" tokenid="ooxml:CT_SdtPr_checkbox"/>
<element name="date" tokenid="ooxml:CT_SdtPr_date"/>
<element name="docPartObj" tokenid="ooxml:CT_SdtPr_docPartObj"/>
<element name="docPartList" tokenid="ooxml:CT_SdtPr_docPartList"/>