summaryrefslogtreecommitdiff
path: root/xmloff/source/text/txtparae.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-04-08 11:32:22 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-04-08 12:51:09 +0200
commitcf5bbe3fce4a250ab25998053965bdc604c6114e (patch)
treebfa97cba1a90e188fd9209799a56b1e46093c69f /xmloff/source/text/txtparae.cxx
parent4688e74bcf0c58ab1bbf60e9c19331d25ebfe95b (diff)
sw content controls: add ODT export
Wrap the text portions inside the content control in a <loext:content-control> XML element. Also map the (so far) single UNO property of it to <loext:content-control loext:showing-place-holder="...">. This is just initial export for inline text content controls, more properties are to be added in follow-up commits. Change-Id: I5d928255b925ed7e08fb635ba39f546e9a4879de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132717 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'xmloff/source/text/txtparae.cxx')
-rw-r--r--xmloff/source/text/txtparae.cxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index b813885f0812..5b8c07b70919 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -2212,6 +2212,10 @@ void XMLTextParagraphExport::exportTextRangeEnumeration(
{
exportMeta(xPropSet, bAutoStyles, bIsProgress, rPrevCharIsSpace);
}
+ else if (sType == "ContentControl")
+ {
+ ExportContentControl(xPropSet, bAutoStyles, bIsProgress, rPrevCharIsSpace);
+ }
else if (sType == gsTextFieldStart)
{
Reference< css::text::XFormField > xFormField(xPropSet->getPropertyValue(gsBookmark), UNO_QUERY);
@@ -3868,6 +3872,43 @@ void XMLTextParagraphExport::exportMeta(
exportTextRangeEnumeration(xTextEnum, i_bAutoStyles, i_isProgress, rPrevCharIsSpace);
}
+void XMLTextParagraphExport::ExportContentControl(
+ const uno::Reference<beans::XPropertySet>& xPortion, bool bAutoStyles, bool isProgress,
+ bool& rPrevCharIsSpace)
+{
+ // Do not export the element in the autostyle case.
+ bool bExport = !bAutoStyles;
+ if (!(GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED))
+ {
+ bExport = false;
+ }
+
+ uno::Reference<text::XTextContent> xTextContent(xPortion->getPropertyValue("ContentControl"),
+ uno::UNO_QUERY_THROW);
+ uno::Reference<container::XEnumerationAccess> xEA(xTextContent, uno::UNO_QUERY_THROW);
+ uno::Reference<container::XEnumeration> xTextEnum = xEA->createEnumeration();
+
+ if (bExport)
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(xTextContent, uno::UNO_QUERY_THROW);
+ bool bShowingPlaceHolder = false;
+ xPropertySet->getPropertyValue("ShowingPlaceHolder") >>= bShowingPlaceHolder;
+ if (bShowingPlaceHolder)
+ {
+ OUStringBuffer aBuffer;
+ sax::Converter::convertBool(aBuffer, bShowingPlaceHolder);
+ GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_SHOWING_PLACE_HOLDER,
+ aBuffer.makeStringAndClear());
+ }
+ }
+
+ SvXMLElementExport aElem(GetExport(), bExport, XML_NAMESPACE_LO_EXT, XML_CONTENT_CONTROL, false,
+ false);
+
+ // Recurse to export content.
+ exportTextRangeEnumeration(xTextEnum, bAutoStyles, isProgress, rPrevCharIsSpace);
+}
+
void XMLTextParagraphExport::PreventExportOfControlsInMuteSections(
const Reference<XIndexAccess> & rShapes,
const rtl::Reference<xmloff::OFormLayerXMLExport>& xFormExport )