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 e9b28885e5b5ac2c5a0b4e634730d1f8670a8ebd
Author: Jim Jagielski <[email protected]>
AuthorDate: Fri Oct 23 09:34:04 2026 -0400

    xmloff: don't write preserved attributes in ODF namespaces in ODF 1.2 mode
    
    Preserved attributes in foreign namespaces are still written, no change 
there.
---
 main/sw/source/filter/xml/xmlexpit.cxx | 4 ++++
 main/xmloff/inc/xmloff/xmlcnimp.hxx    | 2 ++
 main/xmloff/source/core/xmlcnitm.cxx   | 9 +++++++++
 main/xmloff/source/style/xmlexppr.cxx  | 4 ++++
 4 files changed, 19 insertions(+)

diff --git a/main/sw/source/filter/xml/xmlexpit.cxx 
b/main/sw/source/filter/xml/xmlexpit.cxx
index 5c4986b674..ac80c42937 100644
--- a/main/sw/source/filter/xml/xmlexpit.cxx
+++ b/main/sw/source/filter/xml/xmlexpit.cxx
@@ -34,6 +34,7 @@
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/xmlnmspe.hxx>
 #include <editeng/xmlcnitm.hxx>
+#include <xmloff/xmlcnimp.hxx>
 #include <xmloff/xmlexp.hxx>
 #include <editeng/memberids.hrc>
 
@@ -173,6 +174,9 @@ void SvXMLExportItemMapper::exportXML( const SvXMLExport& 
rExport,
                        OUStringBuffer sName;
                        for( sal_uInt16 i=0; i < nCount; i++ )
                        {
+                               if( rExport.getDefaultVersion() == 
SvtSaveOptions::ODFVER_012 &&
+                                       SvXMLIsODFNamespace( 
pUnknown->GetAttrNamespace( i ) ) )
+                                       continue;
                                OUString sPrefix( pUnknown->GetAttrPrefix( i ) 
);
                                if( sPrefix.getLength() )
                                {
diff --git a/main/xmloff/inc/xmloff/xmlcnimp.hxx 
b/main/xmloff/inc/xmloff/xmlcnimp.hxx
index 5d2d4e0cf2..093bfab9c7 100644
--- a/main/xmloff/inc/xmloff/xmlcnimp.hxx
+++ b/main/xmloff/inc/xmloff/xmlcnimp.hxx
@@ -121,4 +121,6 @@ inline const ::rtl::OUString& 
SvXMLAttrContainerData::GetPrefix( sal_uInt16 i )
        return aNamespaceMap.GetPrefixByIndex( i );
 }
 
+XMLOFF_DLLPUBLIC sal_Bool SvXMLIsODFNamespace( const ::rtl::OUString& 
rNamespace );
+
 #endif
diff --git a/main/xmloff/source/core/xmlcnitm.cxx 
b/main/xmloff/source/core/xmlcnitm.cxx
index d692428682..937ca74563 100644
--- a/main/xmloff/source/core/xmlcnitm.cxx
+++ b/main/xmloff/source/core/xmlcnitm.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/lang/XUnoTunnel.hpp>
 
 #include <xmloff/xmlcnimp.hxx>
+#include <xmloff/xmltoken.hxx>
 #include "xmloff/unoatrcn.hxx"
 
 using namespace rtl;
@@ -211,3 +212,11 @@ const ::rtl::OUString& 
SvXMLAttrContainerData::GetAttrValue(sal_uInt16 i) const
        OSL_ENSURE( i < pValues->Count(), "SvXMLAttrContainerData::GetValue: 
illegal index" );
        return *(*pValues)[i];
 }
+
+sal_Bool SvXMLIsODFNamespace( const ::rtl::OUString& rNamespace )
+{
+       return rNamespace.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( 
"urn:oasis:names:tc:opendocument:xmlns:" ) ) ||
+                  rNamespace == ::xmloff::token::GetXMLToken( 
::xmloff::token::XML_N_FO ) ||
+                  rNamespace == ::xmloff::token::GetXMLToken( 
::xmloff::token::XML_N_XLINK ) ||
+                  rNamespace == ::xmloff::token::GetXMLToken( 
::xmloff::token::XML_N_DC );
+}
diff --git a/main/xmloff/source/style/xmlexppr.cxx 
b/main/xmloff/source/style/xmlexppr.cxx
index 3a6c3071d0..fdb6981b70 100644
--- a/main/xmloff/source/style/xmlexppr.cxx
+++ b/main/xmloff/source/style/xmlexppr.cxx
@@ -41,6 +41,7 @@
 #include <xmloff/nmspmap.hxx>
 #include "xmloff/xmlnmspe.hxx"
 #include <xmloff/xmlexp.hxx>
+#include <xmloff/xmlcnimp.hxx>
 #include <xmloff/xmlprmap.hxx>
 #include <xmloff/PropertySetInfoHash.hxx>
 #include <comphelper/stl_types.hxx>
@@ -994,9 +995,12 @@ void SvXMLExportPropertyMapper::_exportXML(
 
                        OUStringBuffer sNameBuffer;
                        xml::AttributeData aData;
+                       const sal_Bool bSkipODFNamespaces( 
SvtSaveOptions().GetODFDefaultVersion() == SvtSaveOptions::ODFVER_012 );
                        for( sal_Int32 i=0; i < nCount; i++, pAttribName++ )
                        {
                                xAttrContainer->getByName( *pAttribName ) >>= 
aData;
+                               if( bSkipODFNamespaces && SvXMLIsODFNamespace( 
aData.Namespace ) )
+                                       continue;
                                OUString sAttribName( *pAttribName );
 
                                // extract namespace prefix from attribute name 
if it exists

Reply via email to