This is an automated email from the ASF dual-hosted git repository. jimjag pushed a commit to branch odf-devel in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 9f5eef8add050e2929fc4abf85b00a4c75d6abf3 Author: Jim Jagielski <[email protected]> AuthorDate: Thu Oct 29 08:46:33 2026 -0400 xmloff: write fieldmarks as bookmarks and drop-down fields as text in ODF 1.2 strict mode --- main/xmloff/source/text/txtflde.cxx | 6 ++++++ main/xmloff/source/text/txtparae.cxx | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/main/xmloff/source/text/txtflde.cxx b/main/xmloff/source/text/txtflde.cxx index dd24e00166..f86ea1ec76 100644 --- a/main/xmloff/source/text/txtflde.cxx +++ b/main/xmloff/source/text/txtflde.cxx @@ -1882,6 +1882,12 @@ void XMLTextFieldExport::ExportFieldHelper( case FIELD_ID_DROP_DOWN: { + // text:drop-down is not in ODF 1.2; keep the shown item as plain text + if ( bStrict ) + { + GetExport().Characters( sPresentation ); + break; + } ProcessString(XML_NAME, GetStringProperty(sPropertyName, rPropSet)); ProcessString(XML_HELP, GetStringProperty(sPropertyHelp, rPropSet), true); diff --git a/main/xmloff/source/text/txtparae.cxx b/main/xmloff/source/text/txtparae.cxx index 4b05cd0fa7..6192b2b4ea 100644 --- a/main/xmloff/source/text/txtparae.cxx +++ b/main/xmloff/source/text/txtparae.cxx @@ -1464,6 +1464,27 @@ static const enum XMLTokenEnum lcl_XmlReferenceElements[] = { static const enum XMLTokenEnum lcl_XmlBookmarkElements[] = { XML_BOOKMARK, XML_BOOKMARK_START, XML_BOOKMARK_END }; +// ODF 1.2 has no field:fieldmark; keep the position as a bookmark with the fieldmark's name +static void lcl_ExportFieldmarkAsBookmark( + SvXMLExport& rExport, const Reference<XPropertySet>& rPropSet, + const OUString& rProperty, enum XMLTokenEnum eElement, OUString& rLastPoint ) +{ + Reference<XNamed> xName(rPropSet->getPropertyValue(rProperty), UNO_QUERY); + if (xName.is() && xName->getName().getLength() > 0) + { + // a checkbox is a point bookmark; the end portion that follows it has no start to close + if (eElement == XML_BOOKMARK) + rLastPoint = xName->getName(); + else if (eElement == XML_BOOKMARK_END && xName->getName() == rLastPoint) + { + rLastPoint = OUString(); + return; + } + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xName->getName()); + SvXMLElementExport aElem(rExport, XML_NAMESPACE_TEXT, eElement, sal_False, sal_False); + } +} + // This function replaces the text portion iteration during auto style // collection. bool XMLTextParagraphExport::collectTextAutoStylesOptimized( sal_Bool bIsProgress ) @@ -2228,6 +2249,7 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( static OUString sAnnotationEnd(RTL_CONSTASCII_USTRINGPARAM("AnnotationEnd")); sal_Bool bPrevCharIsSpace = bPrvChrIsSpc; + OUString sFormElementName; while( rTextEnum->hasMoreElements() ) { @@ -2315,6 +2337,16 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( { exportMeta( xPropSet, bAutoStyles, bIsProgress ); } + else if (GetExport().getDefaultVersion() == SvtSaveOptions::ODFVER_012 && + (sType.equals(sTextFieldStart) || sType.equals(sTextFieldEnd) || + sType.equals(sTextFieldStartEnd))) + { + if (!bAutoStyles) + lcl_ExportFieldmarkAsBookmark( GetExport(), xPropSet, sBookmark, + sType.equals(sTextFieldStart) ? XML_BOOKMARK_START : + sType.equals(sTextFieldEnd) ? XML_BOOKMARK_END : XML_BOOKMARK, + sFormElementName ); + } else if (sType.equals(sTextFieldStart)) { Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY);
