diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-04-27 08:53:13 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-05-02 08:18:16 +0200 |
commit | d0a5eebad23c0af09c3063a308c2a4b5dec9f18f (patch) | |
tree | 236b6320f05d7dfdaa080927263512e3a162cdda /xmloff/source | |
parent | 2da286b41edfced3c331f69445dcda6ce55b3c84 (diff) |
sw content controls, checkbox: add ODT filter
Map the 4 new UNO properties to XML attributes:
- Checkbox <-> loext:checkbox="..."
- Checked <-> loext:checked="..."
- CheckedState <-> loext:checked-state="..."
- UncheckedState <-> loext:unchecked-state="..."
(cherry picked from commit c2fab664a887b16cb78570851ceffcacd26815f7)
Change-Id: Ia4623004ee39c77f5f242c2d720bc188e4dd9433
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133643
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 32 | ||||
-rw-r--r-- | xmloff/source/text/xmlcontentcontrolcontext.cxx | 43 | ||||
-rw-r--r-- | xmloff/source/text/xmlcontentcontrolcontext.hxx | 5 | ||||
-rw-r--r-- | xmloff/source/token/tokens.txt | 2 |
5 files changed, 84 insertions, 0 deletions
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index ebde9b9f34b7..68dbabd25246 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3472,6 +3472,8 @@ namespace xmloff::token { TOKEN("content-control", XML_CONTENT_CONTROL ), TOKEN("showing-place-holder", XML_SHOWING_PLACE_HOLDER ), + TOKEN("checked-state", XML_CHECKED_STATE), + TOKEN("unchecked-state", XML_UNCHECKED_STATE), #if OSL_DEBUG_LEVEL > 0 diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 109015c9fe98..85890612b96b 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -3874,6 +3874,38 @@ void XMLTextParagraphExport::ExportContentControl( GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_SHOWING_PLACE_HOLDER, aBuffer.makeStringAndClear()); } + + bool bCheckbox = false; + xPropertySet->getPropertyValue("Checkbox") >>= bCheckbox; + if (bCheckbox) + { + OUStringBuffer aBuffer; + sax::Converter::convertBool(aBuffer, bCheckbox); + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_CHECKBOX, aBuffer.makeStringAndClear()); + } + + bool bChecked = false; + xPropertySet->getPropertyValue("Checked") >>= bChecked; + if (bChecked) + { + OUStringBuffer aBuffer; + sax::Converter::convertBool(aBuffer, bChecked); + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_CHECKED, aBuffer.makeStringAndClear()); + } + + OUString aCheckedState; + xPropertySet->getPropertyValue("CheckedState") >>= aCheckedState; + if (!aCheckedState.isEmpty()) + { + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_CHECKED_STATE, aCheckedState); + } + + OUString aUncheckedState; + xPropertySet->getPropertyValue("UncheckedState") >>= aUncheckedState; + if (!aUncheckedState.isEmpty()) + { + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_UNCHECKED_STATE, aUncheckedState); + } } SvXMLElementExport aElem(GetExport(), bExport, XML_NAMESPACE_LO_EXT, XML_CONTENT_CONTROL, false, diff --git a/xmloff/source/text/xmlcontentcontrolcontext.cxx b/xmloff/source/text/xmlcontentcontrolcontext.cxx index fb7869b6e8a8..61fa609e0185 100644 --- a/xmloff/source/text/xmlcontentcontrolcontext.cxx +++ b/xmloff/source/text/xmlcontentcontrolcontext.cxx @@ -58,6 +58,32 @@ void XMLContentControlContext::startFastElement( } break; } + case XML_ELEMENT(LO_EXT, XML_CHECKBOX): + { + if (sax::Converter::convertBool(bTmp, rIter.toView())) + { + m_bCheckbox = bTmp; + } + break; + } + case XML_ELEMENT(LO_EXT, XML_CHECKED): + { + if (sax::Converter::convertBool(bTmp, rIter.toView())) + { + m_bChecked = bTmp; + } + break; + } + case XML_ELEMENT(LO_EXT, XML_CHECKED_STATE): + { + m_aCheckedState = rIter.toString(); + break; + } + case XML_ELEMENT(LO_EXT, XML_UNCHECKED_STATE): + { + m_aUncheckedState = rIter.toString(); + break; + } default: XMLOFF_WARN_UNKNOWN("xmloff", rIter); } @@ -99,6 +125,23 @@ void XMLContentControlContext::endFastElement(sal_Int32) { xPropertySet->setPropertyValue("ShowingPlaceHolder", uno::makeAny(m_bShowingPlaceHolder)); } + + if (m_bCheckbox) + { + xPropertySet->setPropertyValue("Checkbox", uno::makeAny(m_bCheckbox)); + } + if (m_bChecked) + { + xPropertySet->setPropertyValue("Checked", uno::makeAny(m_bChecked)); + } + if (!m_aCheckedState.isEmpty()) + { + xPropertySet->setPropertyValue("CheckedState", uno::makeAny(m_aCheckedState)); + } + if (!m_aUncheckedState.isEmpty()) + { + xPropertySet->setPropertyValue("UncheckedState", uno::makeAny(m_aUncheckedState)); + } } css::uno::Reference<css::xml::sax::XFastContextHandler> diff --git a/xmloff/source/text/xmlcontentcontrolcontext.hxx b/xmloff/source/text/xmlcontentcontrolcontext.hxx index 2658fa76972b..3d3e44d76445 100644 --- a/xmloff/source/text/xmlcontentcontrolcontext.hxx +++ b/xmloff/source/text/xmlcontentcontrolcontext.hxx @@ -35,6 +35,11 @@ class XMLContentControlContext : public SvXMLImportContext bool m_bShowingPlaceHolder = false; + bool m_bCheckbox = false; + bool m_bChecked = false; + OUString m_aCheckedState; + OUString m_aUncheckedState; + public: XMLContentControlContext(SvXMLImport& rImport, sal_Int32 nElement, XMLHints_Impl& rHints, bool& rIgnoreLeadingSpace); diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index b202beb7a319..a95c2228bdae 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -3216,4 +3216,6 @@ symmetric linked-style-name content-control showing-place-holder +checked-state +unchecked-state TOKEN_END_DUMMY |