drawinglayer/source/tools/primitive2dxmldump.cxx |  114 +++++++++++------------
 include/tools/XmlWriter.hxx                      |   26 ++---
 oox/source/crypto/AgileEngine.cxx                |    4 
 opencl/inc/opencl_device_selection.h             |    8 -
 sc/source/core/data/dpsave.cxx                   |   16 +--
 svx/source/styles/ColorSets.cxx                  |    4 
 sw/source/filter/indexing/IndexingExport.cxx     |   14 +-
 tools/qa/cppunit/test_xmlwriter.cxx              |   21 ++++
 tools/source/xml/XmlWriter.cxx                   |   11 +-
 vcl/source/gdi/mtfxmldump.cxx                    |    6 -
 vcl/source/pdf/XmpMetadata.cxx                   |   80 +++++++---------
 11 files changed, 157 insertions(+), 147 deletions(-)

New commits:
commit 4fa74cefc36975533c4cba3c049d69c7d73cef2a
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Fri Nov 14 13:06:52 2025 +0900
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Wed Nov 19 07:33:37 2025 +0100

    tools: use string_view instead of OString in XmlWriter
    
    Change-Id: I55dd06fc432d9686b370274a4621d61c035a99dc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193997
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx 
b/drawinglayer/source/tools/primitive2dxmldump.cxx
index b1615b9a005d..75ebfcc34326 100644
--- a/drawinglayer/source/tools/primitive2dxmldump.cxx
+++ b/drawinglayer/source/tools/primitive2dxmldump.cxx
@@ -167,38 +167,38 @@ void writeLineAttribute(::tools::XmlWriter& rWriter,
     switch (rLineAttribute.getLineJoin())
     {
         case basegfx::B2DLineJoin::NONE:
-            rWriter.attribute("linejoin", "NONE"_ostr);
+            rWriter.attribute("linejoin", "NONE");
             break;
         case basegfx::B2DLineJoin::Bevel:
-            rWriter.attribute("linejoin", "Bevel"_ostr);
+            rWriter.attribute("linejoin", "Bevel");
             break;
         case basegfx::B2DLineJoin::Miter:
         {
-            rWriter.attribute("linejoin", "Miter"_ostr);
+            rWriter.attribute("linejoin", "Miter");
             rWriter.attribute("miterangle",
                               
basegfx::rad2deg(rLineAttribute.getMiterMinimumAngle()));
             break;
         }
         case basegfx::B2DLineJoin::Round:
-            rWriter.attribute("linejoin", "Round"_ostr);
+            rWriter.attribute("linejoin", "Round");
             break;
         default:
-            rWriter.attribute("linejoin", "Unknown"_ostr);
+            rWriter.attribute("linejoin", "Unknown");
             break;
     }
     switch (rLineAttribute.getLineCap())
     {
         case css::drawing::LineCap::LineCap_BUTT:
-            rWriter.attribute("linecap", "BUTT"_ostr);
+            rWriter.attribute("linecap", "BUTT");
             break;
         case css::drawing::LineCap::LineCap_ROUND:
-            rWriter.attribute("linecap", "ROUND"_ostr);
+            rWriter.attribute("linecap", "ROUND");
             break;
         case css::drawing::LineCap::LineCap_SQUARE:
-            rWriter.attribute("linecap", "SQUARE"_ostr);
+            rWriter.attribute("linecap", "SQUARE");
             break;
         default:
-            rWriter.attribute("linecap", "Unknown"_ostr);
+            rWriter.attribute("linecap", "Unknown");
             break;
     }
 
@@ -219,34 +219,34 @@ void writeSdrLineAttribute(::tools::XmlWriter& rWriter,
     switch (rLineAttribute.getJoin())
     {
         case basegfx::B2DLineJoin::NONE:
-            rWriter.attribute("linejoin", "NONE"_ostr);
+            rWriter.attribute("linejoin", "NONE");
             break;
         case basegfx::B2DLineJoin::Bevel:
-            rWriter.attribute("linejoin", "Bevel"_ostr);
+            rWriter.attribute("linejoin", "Bevel");
             break;
         case basegfx::B2DLineJoin::Miter:
-            rWriter.attribute("linejoin", "Miter"_ostr);
+            rWriter.attribute("linejoin", "Miter");
             break;
         case basegfx::B2DLineJoin::Round:
-            rWriter.attribute("linejoin", "Round"_ostr);
+            rWriter.attribute("linejoin", "Round");
             break;
         default:
-            rWriter.attribute("linejoin", "Unknown"_ostr);
+            rWriter.attribute("linejoin", "Unknown");
             break;
     }
     switch (rLineAttribute.getCap())
     {
         case css::drawing::LineCap::LineCap_BUTT:
-            rWriter.attribute("linecap", "BUTT"_ostr);
+            rWriter.attribute("linecap", "BUTT");
             break;
         case css::drawing::LineCap::LineCap_ROUND:
-            rWriter.attribute("linecap", "ROUND"_ostr);
+            rWriter.attribute("linecap", "ROUND");
             break;
         case css::drawing::LineCap::LineCap_SQUARE:
-            rWriter.attribute("linecap", "SQUARE"_ostr);
+            rWriter.attribute("linecap", "SQUARE");
             break;
         default:
-            rWriter.attribute("linecap", "Unknown"_ostr);
+            rWriter.attribute("linecap", "Unknown");
             break;
     }
 
@@ -282,22 +282,22 @@ void writeSdrFillAttribute(::tools::XmlWriter& rWriter,
         {
             default: // GradientStyle_MAKE_FIXED_SIZE
             case css::awt::GradientStyle_LINEAR:
-                rWriter.attribute("style", "Linear"_ostr);
+                rWriter.attribute("style", "Linear");
                 break;
             case css::awt::GradientStyle_AXIAL:
-                rWriter.attribute("style", "Axial"_ostr);
+                rWriter.attribute("style", "Axial");
                 break;
             case css::awt::GradientStyle_RADIAL:
-                rWriter.attribute("style", "Radial"_ostr);
+                rWriter.attribute("style", "Radial");
                 break;
             case css::awt::GradientStyle_ELLIPTICAL:
-                rWriter.attribute("style", "Elliptical"_ostr);
+                rWriter.attribute("style", "Elliptical");
                 break;
             case css::awt::GradientStyle_SQUARE:
-                rWriter.attribute("style", "Square"_ostr);
+                rWriter.attribute("style", "Square");
                 break;
             case css::awt::GradientStyle_RECT:
-                rWriter.attribute("style", "Rect"_ostr);
+                rWriter.attribute("style", "Rect");
                 break;
         }
         rWriter.attribute("border", rGradient.getBorder());
@@ -332,13 +332,13 @@ void writeSdrFillAttribute(::tools::XmlWriter& rWriter,
         switch (rHatch.getStyle())
         {
             case drawinglayer::attribute::HatchStyle::Single:
-                rWriter.attribute("style", "Single"_ostr);
+                rWriter.attribute("style", "Single");
                 break;
             case drawinglayer::attribute::HatchStyle::Double:
-                rWriter.attribute("style", "Double"_ostr);
+                rWriter.attribute("style", "Double");
                 break;
             case drawinglayer::attribute::HatchStyle::Triple:
-                rWriter.attribute("style", "Triple"_ostr);
+                rWriter.attribute("style", "Triple");
                 break;
         }
         rWriter.attribute("distance", rHatch.getDistance());
@@ -365,19 +365,19 @@ void writeShadeMode(::tools::XmlWriter& rWriter, const 
css::drawing::ShadeMode&
     switch (rMode)
     {
         case css::drawing::ShadeMode_FLAT:
-            rWriter.attribute("shadeMode", "Flat"_ostr);
+            rWriter.attribute("shadeMode", "Flat");
             break;
         case css::drawing::ShadeMode_SMOOTH:
-            rWriter.attribute("shadeMode", "Smooth"_ostr);
+            rWriter.attribute("shadeMode", "Smooth");
             break;
         case css::drawing::ShadeMode_PHONG:
-            rWriter.attribute("shadeMode", "Phong"_ostr);
+            rWriter.attribute("shadeMode", "Phong");
             break;
         case css::drawing::ShadeMode_DRAFT:
-            rWriter.attribute("shadeMode", "Draft"_ostr);
+            rWriter.attribute("shadeMode", "Draft");
             break;
         default:
-            rWriter.attribute("shadeMode", "Undefined"_ostr);
+            rWriter.attribute("shadeMode", "Undefined");
             break;
     }
 }
@@ -387,13 +387,13 @@ void writeProjectionMode(::tools::XmlWriter& rWriter, 
const css::drawing::Projec
     switch (rMode)
     {
         case css::drawing::ProjectionMode_PARALLEL:
-            rWriter.attribute("projectionMode", "Parallel"_ostr);
+            rWriter.attribute("projectionMode", "Parallel");
             break;
         case css::drawing::ProjectionMode_PERSPECTIVE:
-            rWriter.attribute("projectionMode", "Perspective"_ostr);
+            rWriter.attribute("projectionMode", "Perspective");
             break;
         default:
-            rWriter.attribute("projectionMode", "Undefined"_ostr);
+            rWriter.attribute("projectionMode", "Undefined");
             break;
     }
 }
@@ -403,16 +403,16 @@ void writeNormalsKind(::tools::XmlWriter& rWriter, const 
css::drawing::NormalsKi
     switch (rKind)
     {
         case css::drawing::NormalsKind_SPECIFIC:
-            rWriter.attribute("normalsKind", "Specific"_ostr);
+            rWriter.attribute("normalsKind", "Specific");
             break;
         case css::drawing::NormalsKind_FLAT:
-            rWriter.attribute("normalsKind", "Flat"_ostr);
+            rWriter.attribute("normalsKind", "Flat");
             break;
         case css::drawing::NormalsKind_SPHERE:
-            rWriter.attribute("normalsKind", "Sphere"_ostr);
+            rWriter.attribute("normalsKind", "Sphere");
             break;
         default:
-            rWriter.attribute("normalsKind", "Undefined"_ostr);
+            rWriter.attribute("normalsKind", "Undefined");
             break;
     }
 }
@@ -423,16 +423,16 @@ void writeTextureProjectionMode(::tools::XmlWriter& 
rWriter, const char* pElemen
     switch (rMode)
     {
         case css::drawing::TextureProjectionMode_OBJECTSPECIFIC:
-            rWriter.attribute(pElement, "Specific"_ostr);
+            rWriter.attribute(pElement, "Specific");
             break;
         case css::drawing::TextureProjectionMode_PARALLEL:
-            rWriter.attribute(pElement, "Parallel"_ostr);
+            rWriter.attribute(pElement, "Parallel");
             break;
         case css::drawing::TextureProjectionMode_SPHERE:
-            rWriter.attribute(pElement, "Sphere"_ostr);
+            rWriter.attribute(pElement, "Sphere");
             break;
         default:
-            rWriter.attribute(pElement, "Undefined"_ostr);
+            rWriter.attribute(pElement, "Undefined");
             break;
     }
 }
@@ -442,16 +442,16 @@ void writeTextureKind(::tools::XmlWriter& rWriter, const 
css::drawing::TextureKi
     switch (rKind)
     {
         case css::drawing::TextureKind2_LUMINANCE:
-            rWriter.attribute("textureKind", "Luminance"_ostr);
+            rWriter.attribute("textureKind", "Luminance");
             break;
         case css::drawing::TextureKind2_INTENSITY:
-            rWriter.attribute("textureKind", "Intensity"_ostr);
+            rWriter.attribute("textureKind", "Intensity");
             break;
         case css::drawing::TextureKind2_COLOR:
-            rWriter.attribute("textureKind", "Color"_ostr);
+            rWriter.attribute("textureKind", "Color");
             break;
         default:
-            rWriter.attribute("textureKind", "Undefined"_ostr);
+            rWriter.attribute("textureKind", "Undefined");
             break;
     }
 }
@@ -461,16 +461,16 @@ void writeTextureMode(::tools::XmlWriter& rWriter, const 
css::drawing::TextureMo
     switch (rMode)
     {
         case css::drawing::TextureMode_REPLACE:
-            rWriter.attribute("textureMode", "Replace"_ostr);
+            rWriter.attribute("textureMode", "Replace");
             break;
         case css::drawing::TextureMode_MODULATE:
-            rWriter.attribute("textureMode", "Modulate"_ostr);
+            rWriter.attribute("textureMode", "Modulate");
             break;
         case css::drawing::TextureMode_BLEND:
-            rWriter.attribute("textureMode", "Blend"_ostr);
+            rWriter.attribute("textureMode", "Blend");
             break;
         default:
-            rWriter.attribute("textureMode", "Undefined"_ostr);
+            rWriter.attribute("textureMode", "Undefined");
             break;
     }
 }
@@ -492,16 +492,16 @@ void writeSpreadMethod(::tools::XmlWriter& rWriter,
     switch (rSpreadMethod)
     {
         case drawinglayer::primitive2d::SpreadMethod::Pad:
-            rWriter.attribute("spreadmethod", "pad"_ostr);
+            rWriter.attribute("spreadmethod", "pad");
             break;
         case drawinglayer::primitive2d::SpreadMethod::Reflect:
-            rWriter.attribute("spreadmethod", "reflect"_ostr);
+            rWriter.attribute("spreadmethod", "reflect");
             break;
         case drawinglayer::primitive2d::SpreadMethod::Repeat:
-            rWriter.attribute("spreadmethod", "repeat"_ostr);
+            rWriter.attribute("spreadmethod", "repeat");
             break;
         default:
-            rWriter.attribute("spreadmethod", "unknown"_ostr);
+            rWriter.attribute("spreadmethod", "unknown");
     }
 }
 
@@ -708,7 +708,7 @@ void Primitive2dXmlDump::decomposeAndWrite(
 
                 rWriter.attribute("height", aSizePixel.getHeight());
                 rWriter.attribute("width", aSizePixel.getWidth());
-                rWriter.attribute("checksum", 
OString(std::to_string(aBitmap.GetChecksum())));
+                rWriter.attribute("checksum", 
std::to_string(aBitmap.GetChecksum()));
 
                 for (tools::Long y = 0; y < aSizePixel.getHeight(); y++)
                 {
@@ -954,7 +954,7 @@ void Primitive2dXmlDump::decomposeAndWrite(
                     for (size_t iDx = 0; iDx < aDx.size(); ++iDx)
                     {
                         OString sName = "dx" + OString::number(iDx);
-                        rWriter.attribute(sName, OString::number(aDx[iDx]));
+                        rWriter.attribute(sName.getStr(), 
OString::number(aDx[iDx]));
                     }
                 }
                 rWriter.endElement();
diff --git a/include/tools/XmlWriter.hxx b/include/tools/XmlWriter.hxx
index 9c8f82a86f42..8947c16ed1ff 100644
--- a/include/tools/XmlWriter.hxx
+++ b/include/tools/XmlWriter.hxx
@@ -7,8 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#ifndef INCLUDED_TOOLS_XMLWRITER_HXX
-#define INCLUDED_TOOLS_XMLWRITER_HXX
+#pragma once
 
 #include <sal/config.h>
 
@@ -18,6 +17,7 @@
 #include <memory>
 #include <string_view>
 #include <vector>
+#include <o3tl/concepts.hxx>
 
 class SvStream;
 
@@ -52,26 +52,22 @@ public:
     void startElement(const OString& sPrefix, const OString& sName, const 
OString& sNamespaceUri);
     void endElement();
 
-    void attribute(const char* sTagName, const OString& aValue);
-    void attribute(const OString& sTagName, const OString& aValue)
-    {
-        attribute(sTagName.getStr(), aValue);
-    }
+    void attribute(const char* sTagName, std::string_view aValue);
     void attribute(const char* sTagName, std::u16string_view aValue);
     void attribute(const char* sTagName, sal_Int64 aNumber);
-    template <typename T>
-    requires std::is_arithmetic_v<T> void attribute(const char* sTagName, T 
aNumber)
+    template <o3tl::integral T> void attribute(const char* sTagName, T aNumber)
     {
-        if constexpr (std::is_floating_point_v<T>)
-            return attribute(sTagName, basegfx::fround64(aNumber));
-        else
-            return attribute(sTagName, static_cast<sal_Int64>(aNumber));
+        return attribute(sTagName, static_cast<sal_Int64>(aNumber));
+    }
+    template <o3tl::floating_point T> void attribute(const char* sTagName, T 
aNumber)
+    {
+        return attribute(sTagName, basegfx::fround64(aNumber));
     }
     void attributeDouble(const char* sTagName, double aNumber);
     void attributeBase64(const char* sTagName, std::vector<sal_uInt8> const& 
rValueInBytes);
     void attributeBase64(const char* sTagName, std::vector<char> const& 
rValueInBytes);
 
-    void content(const OString& sValue);
+    void content(std::string_view sValue);
     void content(std::u16string_view sValue);
 
     void element(const char* sName);
@@ -79,6 +75,4 @@ public:
 
 } // end tools namespace
 
-#endif // INCLUDED_TOOLS_XMLWRITER_HXX
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/crypto/AgileEngine.cxx 
b/oox/source/crypto/AgileEngine.cxx
index 5c02305512d5..fb9720872e3e 100644
--- a/oox/source/crypto/AgileEngine.cxx
+++ b/oox/source/crypto/AgileEngine.cxx
@@ -769,7 +769,7 @@ void AgileEngine::writeEncryptionInfo(BinaryXOutputStream & 
rStream)
     if (aXmlWriter.startDocument(0/*nIndent*/))
     {
         aXmlWriter.startElement(""_ostr, "encryption"_ostr, 
"http://schemas.microsoft.com/office/2006/encryption"_ostr);
-        aXmlWriter.attribute("xmlns:p", 
"http://schemas.microsoft.com/office/2006/keyEncryptor/password"_ostr);
+        aXmlWriter.attribute("xmlns:p", 
"http://schemas.microsoft.com/office/2006/keyEncryptor/password";);
 
         aXmlWriter.startElement("keyData");
         aXmlWriter.attribute("saltSize", mInfo.saltSize);
@@ -789,7 +789,7 @@ void AgileEngine::writeEncryptionInfo(BinaryXOutputStream & 
rStream)
 
         aXmlWriter.startElement("keyEncryptors");
         aXmlWriter.startElement("keyEncryptor");
-        aXmlWriter.attribute("uri", 
"http://schemas.microsoft.com/office/2006/keyEncryptor/password"_ostr);
+        aXmlWriter.attribute("uri", 
"http://schemas.microsoft.com/office/2006/keyEncryptor/password";);
 
         aXmlWriter.startElement("p"_ostr, "encryptedKey"_ostr, ""_ostr);
         aXmlWriter.attribute("spinCount", mInfo.spinCount);
diff --git a/opencl/inc/opencl_device_selection.h 
b/opencl/inc/opencl_device_selection.h
index 4baffbf2737c..69120f74841c 100644
--- a/opencl/inc/opencl_device_selection.h
+++ b/opencl/inc/opencl_device_selection.h
@@ -263,12 +263,12 @@ inline ds_status writeProfile(const OUString& 
rStreamName, std::unique_ptr<ds_pr
         {
             case DeviceType::NativeCPU:
                 aXmlWriter.startElement("type");
-                aXmlWriter.content("native"_ostr);
+                aXmlWriter.content("native");
                 aXmlWriter.endElement();
                 break;
             case DeviceType::OpenCLDevice:
                 aXmlWriter.startElement("type");
-                aXmlWriter.content("opencl"_ostr);
+                aXmlWriter.content("opencl");
                 aXmlWriter.endElement();
 
                 aXmlWriter.startElement("name");
@@ -285,13 +285,13 @@ inline ds_status writeProfile(const OUString& 
rStreamName, std::unique_ptr<ds_pr
 
         aXmlWriter.startElement("time");
         if (rtl::math::approxEqual(rDevice.fTime, DBL_MAX))
-            aXmlWriter.content("max"_ostr);
+            aXmlWriter.content("max");
         else
             aXmlWriter.content(OString::number(rDevice.fTime));
         aXmlWriter.endElement();
 
         aXmlWriter.startElement("errors");
-        aXmlWriter.content(rDevice.bErrors ? "true"_ostr : "false"_ostr);
+        aXmlWriter.content(rDevice.bErrors ? "true" : "false");
         aXmlWriter.endElement();
 
         aXmlWriter.endElement();
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 90ede1217eb8..1d697d648899 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -164,12 +164,12 @@ void ScDPSaveMember::dumpAsXml(tools::XmlWriter& rWriter) 
const
     if (mpLayoutName)
         rWriter.attribute("layout_name", *mpLayoutName);
     else
-        rWriter.attribute("layout_name", "(none)"_ostr);
+        rWriter.attribute("layout_name", "(none)");
 
     if (nVisibleMode == SC_DPSAVEMODE_DONTKNOW)
-        rWriter.attribute("visibility", "(unknown)"_ostr);
+        rWriter.attribute("visibility", "(unknown)");
     else
-        rWriter.attribute("visibility", (nVisibleMode ? "visible"_ostr : 
"hidden"_ostr));
+        rWriter.attribute("visibility", (nVisibleMode ? "visible" : "hidden"));
     rWriter.endElement();
 }
 
@@ -670,9 +670,9 @@ void ScDPSaveDimension::dumpAsXml(tools::XmlWriter& 
rWriter) const
     rWriter.startElement("dimension");
     rWriter.attribute("name", aName);
     if (nOrientation <= DataPilotFieldOrientation_DATA)
-        rWriter.attribute("orientation", 
OString(sOrientNames[sal_Int32(nOrientation)]));
+        rWriter.attribute("orientation", 
sOrientNames[sal_Int32(nOrientation)]);
     else
-        rWriter.attribute("orientation", "invalid"_ostr);
+        rWriter.attribute("orientation", "invalid");
 
     if (mpLayoutName)
         rWriter.attribute("layout_name", *mpLayoutName);
@@ -680,10 +680,10 @@ void ScDPSaveDimension::dumpAsXml(tools::XmlWriter& 
rWriter) const
     if (mpSubtotalName)
         rWriter.attribute("subtotal_name", *mpSubtotalName);
     else
-        rWriter.attribute("subtotal_name", "(none)"_ostr);
+        rWriter.attribute("subtotal_name", "(none)");
 
-    rWriter.attribute("data_layout", (bIsDataLayout ? "yes"_ostr : "no"_ostr));
-    rWriter.attribute("duplicate", (bDupFlag ? "yes"_ostr : "no"_ostr));
+    rWriter.attribute("data_layout", (bIsDataLayout ? "yes" : "no"));
+    rWriter.attribute("duplicate", (bDupFlag ? "yes" : "no"));
 
     for (ScDPSaveMember* pMember : maMemberList)
     {
diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx
index 0e59effe779a..9d6ae570bc33 100644
--- a/svx/source/styles/ColorSets.cxx
+++ b/svx/source/styles/ColorSets.cxx
@@ -249,8 +249,8 @@ void ColorSets::writeToUserFolder(model::ColorSet const& 
rNewColorSet)
         {
             Color aColor = rNewColorSet.getColor(eThemeColorType);
             aWriter.startElement("color");
-            aWriter.attribute("name", OString(iterator->second));
-            aWriter.attribute("color", "#"_ostr + 
aColor.AsRGBHexString().toUtf8());
+            aWriter.attribute("name", iterator->second);
+            aWriter.attribute("color", Concat2View("#" + 
aColor.AsRGBHexString().toUtf8()));
             aWriter.endElement();
         }
     }
diff --git a/sw/source/filter/indexing/IndexingExport.cxx 
b/sw/source/filter/indexing/IndexingExport.cxx
index 1daaaf481eca..fa2134a03b05 100644
--- a/sw/source/filter/indexing/IndexingExport.cxx
+++ b/sw/source/filter/indexing/IndexingExport.cxx
@@ -71,7 +71,7 @@ public:
         m_rXmlWriter.startElement("object");
         m_rXmlWriter.attribute("alt", pOleNode->GetTitle());
         m_rXmlWriter.attribute("name", pFrameFormat->GetName().toString());
-        m_rXmlWriter.attribute("object_type", "ole"_ostr);
+        m_rXmlWriter.attribute("object_type", "ole");
         m_rXmlWriter.endElement();
     }
 
@@ -81,7 +81,7 @@ public:
         m_rXmlWriter.startElement("object");
         m_rXmlWriter.attribute("alt", pGraphicNode->GetTitle());
         m_rXmlWriter.attribute("name", pFrameFormat->GetName().toString());
-        m_rXmlWriter.attribute("object_type", "graphic"_ostr);
+        m_rXmlWriter.attribute("object_type", "graphic");
         m_rXmlWriter.endElement();
     }
 
@@ -98,7 +98,7 @@ public:
             return;
         m_rXmlWriter.startElement("paragraph");
         m_rXmlWriter.attribute("index", sal_Int32(pTextNode->GetIndex()));
-        m_rXmlWriter.attribute("node_type", "writer"_ostr);
+        m_rXmlWriter.attribute("node_type", "writer");
         if (nParentIndex >= SwNodeOffset(0))
             m_rXmlWriter.attribute("parent_index", sal_Int32(nParentIndex));
         m_rXmlWriter.content(aString);
@@ -113,7 +113,7 @@ public:
         m_rXmlWriter.startElement("object");
         m_rXmlWriter.attribute("name", pObject->GetName());
         m_rXmlWriter.attribute("alt", pObject->GetTitle());
-        m_rXmlWriter.attribute("object_type", "shape"_ostr);
+        m_rXmlWriter.attribute("object_type", "shape");
         m_rXmlWriter.attribute("description", pObject->GetDescription());
 
         m_rXmlWriter.endElement();
@@ -133,7 +133,7 @@ public:
 
             m_rXmlWriter.startElement("paragraph");
             m_rXmlWriter.attribute("index", nParagraph);
-            m_rXmlWriter.attribute("node_type", "common"_ostr);
+            m_rXmlWriter.attribute("node_type", "common");
             m_rXmlWriter.attribute("object_name", pObject->GetName());
             m_rXmlWriter.content(sText);
             m_rXmlWriter.endElement();
@@ -148,7 +148,7 @@ public:
         m_rXmlWriter.startElement("object");
         m_rXmlWriter.attribute("index", sal_Int32(pTableNode->GetIndex()));
         m_rXmlWriter.attribute("name", sName.toString());
-        m_rXmlWriter.attribute("object_type", "table"_ostr);
+        m_rXmlWriter.attribute("object_type", "table");
         m_rXmlWriter.endElement();
 
         maNodeStack.push_back(pTableNode);
@@ -159,7 +159,7 @@ public:
         m_rXmlWriter.startElement("object");
         m_rXmlWriter.attribute("index", sal_Int32(pSectionNode->GetIndex()));
         m_rXmlWriter.attribute("name", 
pSectionNode->GetSection().GetSectionName().toString());
-        m_rXmlWriter.attribute("object_type", "section"_ostr);
+        m_rXmlWriter.attribute("object_type", "section");
         m_rXmlWriter.endElement();
 
         maNodeStack.push_back(pSectionNode);
diff --git a/tools/qa/cppunit/test_xmlwriter.cxx 
b/tools/qa/cppunit/test_xmlwriter.cxx
index eeb475030f89..6ab22950bf4d 100644
--- a/tools/qa/cppunit/test_xmlwriter.cxx
+++ b/tools/qa/cppunit/test_xmlwriter.cxx
@@ -26,10 +26,12 @@ public:
 
     void testSimpleRoot();
     void testSpecialChars();
+    void testAttributes();
 
     CPPUNIT_TEST_SUITE(XmlWriterTest);
     CPPUNIT_TEST(testSimpleRoot);
     CPPUNIT_TEST(testSpecialChars);
+    CPPUNIT_TEST(testAttributes);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -55,7 +57,7 @@ void XmlWriterTest::testSpecialChars()
     tools::XmlWriter aWriter(&aMemoryStream);
     aWriter.startDocument(0, false);
     aWriter.startElement("test");
-    aWriter.content("<>"_ostr);
+    aWriter.content("<>");
     aWriter.endElement();
     aWriter.endDocument();
 
@@ -64,6 +66,23 @@ void XmlWriterTest::testSpecialChars()
     CPPUNIT_ASSERT_EQUAL("<test>&lt;&gt;</test>"_ostr, aString);
 }
 
+void XmlWriterTest::testAttributes()
+{
+    SvMemoryStream aMemoryStream;
+
+    tools::XmlWriter aWriter(&aMemoryStream);
+    aWriter.startDocument(0, false);
+    aWriter.startElement("test");
+    aWriter.attribute("c", std::string_view("c"));
+    aWriter.attribute("d", std::u16string_view(u"d"));
+    aWriter.endElement();
+    aWriter.endDocument();
+
+    aMemoryStream.Seek(0);
+    OString aString(static_cast<const char*>(aMemoryStream.GetData()), 
aMemoryStream.GetSize());
+    CPPUNIT_ASSERT_EQUAL("<test c=\"c\" d=\"d\"/>"_ostr, aString);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(XmlWriterTest);
 }
 
diff --git a/tools/source/xml/XmlWriter.cxx b/tools/source/xml/XmlWriter.cxx
index afc6dd9b73be..5200c3dcd044 100644
--- a/tools/source/xml/XmlWriter.cxx
+++ b/tools/source/xml/XmlWriter.cxx
@@ -120,11 +120,11 @@ void XmlWriter::attributeBase64(const char* pName, 
std::vector<char> const& rVal
     attributeBase64_impl(mpImpl->mpWriter, pName, rValueInBytes.data(), 
rValueInBytes.size());
 }
 
-void XmlWriter::attribute(const char* name, const OString& value)
+void XmlWriter::attribute(const char* name, std::string_view value)
 {
     xmlChar* xmlName = BAD_CAST(name);
-    xmlChar* xmlValue = BAD_CAST(value.getStr());
-    (void)xmlTextWriterWriteAttribute(mpImpl->mpWriter, xmlName, xmlValue);
+    (void)xmlTextWriterWriteFormatAttribute(mpImpl->mpWriter, xmlName, "%.*s", 
int(value.size()),
+                                            value.data());
 }
 
 void XmlWriter::attribute(const char* name, std::u16string_view value)
@@ -142,10 +142,9 @@ void XmlWriter::attributeDouble(const char* name, const 
double aNumber)
     attribute(name, OString::number(aNumber));
 }
 
-void XmlWriter::content(const OString& sValue)
+void XmlWriter::content(std::string_view value)
 {
-    xmlChar* xmlValue = BAD_CAST(sValue.getStr());
-    (void)xmlTextWriterWriteString(mpImpl->mpWriter, xmlValue);
+    (void)xmlTextWriterWriteFormatString(mpImpl->mpWriter, "%.*s", 
int(value.size()), value.data());
 }
 
 void XmlWriter::content(std::u16string_view sValue)
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 039db43254d6..6f8cdc1e7d5c 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -550,11 +550,11 @@ void writeRectangle(tools::XmlWriter& rWriter, 
tools::Rectangle const& rRectangl
     rWriter.attribute("left", rRectangle.Left());
     rWriter.attribute("top", rRectangle.Top());
     if (rRectangle.IsWidthEmpty())
-        rWriter.attribute("right", "empty"_ostr);
+        rWriter.attribute("right", "empty");
     else
         rWriter.attribute("right", rRectangle.Right());
     if (rRectangle.IsHeightEmpty())
-        rWriter.attribute("bottom", "empty"_ostr);
+        rWriter.attribute("bottom", "empty");
     else
         rWriter.attribute("bottom", rRectangle.Bottom());
 }
@@ -1582,7 +1582,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& 
rMetaFile, tools::XmlWriter& r
             default:
             {
                 rWriter.startElement(sCurrentElementTag);
-                rWriter.attribute("note", "not implemented in xml dump"_ostr);
+                rWriter.attribute("note", "not implemented in xml dump");
                 rWriter.endElement();
             }
             break;
diff --git a/vcl/source/pdf/XmpMetadata.cxx b/vcl/source/pdf/XmpMetadata.cxx
index 0bc84404321e..eec7e5667fbf 100644
--- a/vcl/source/pdf/XmpMetadata.cxx
+++ b/vcl/source/pdf/XmpMetadata.cxx
@@ -50,8 +50,8 @@ void XmpMetadata::write()
             OString sPdfVersion = OString::number(mnPDF_A);
 
             aXmlWriter.startElement("rdf:Description");
-            aXmlWriter.attribute("rdf:about", ""_ostr);
-            aXmlWriter.attribute("xmlns:pdfaid", 
"http://www.aiim.org/pdfa/ns/id/"_ostr);
+            aXmlWriter.attribute("rdf:about", "");
+            aXmlWriter.attribute("xmlns:pdfaid", 
"http://www.aiim.org/pdfa/ns/id/";);
 
             aXmlWriter.startElement("pdfaid:part");
             aXmlWriter.content(sPdfVersion);
@@ -60,7 +60,7 @@ void XmpMetadata::write()
             if (mnPDF_A == 4)
             {
                 aXmlWriter.startElement("pdfaid:rev");
-                aXmlWriter.content("2020"_ostr);
+                aXmlWriter.content("2020");
                 aXmlWriter.endElement();
             }
 
@@ -80,11 +80,11 @@ void XmpMetadata::write()
             || !msSource.isEmpty() || !msType.isEmpty())
         {
             aXmlWriter.startElement("rdf:Description");
-            aXmlWriter.attribute("rdf:about", ""_ostr);
-            aXmlWriter.attribute("xmlns:dc", 
"http://purl.org/dc/elements/1.1/"_ostr);
+            aXmlWriter.attribute("rdf:about", "");
+            aXmlWriter.attribute("xmlns:dc", 
"http://purl.org/dc/elements/1.1/";);
 
             aXmlWriter.startElement("dc:format");
-            aXmlWriter.content("application/pdf"_ostr);
+            aXmlWriter.content("application/pdf");
             aXmlWriter.endElement();
 
             aXmlWriter.startElement("dc:date");
@@ -101,7 +101,7 @@ void XmpMetadata::write()
                 aXmlWriter.startElement("dc:title");
                 aXmlWriter.startElement("rdf:Alt");
                 aXmlWriter.startElement("rdf:li");
-                aXmlWriter.attribute("xml:lang", "x-default"_ostr);
+                aXmlWriter.attribute("xml:lang", "x-default");
                 aXmlWriter.content(msTitle);
                 aXmlWriter.endElement();
                 aXmlWriter.endElement();
@@ -122,7 +122,7 @@ void XmpMetadata::write()
                 aXmlWriter.startElement("dc:description");
                 aXmlWriter.startElement("rdf:Alt");
                 aXmlWriter.startElement("rdf:li");
-                aXmlWriter.attribute("xml:lang", "x-default"_ostr);
+                aXmlWriter.attribute("xml:lang", "x-default");
                 aXmlWriter.content(msSubject);
                 aXmlWriter.endElement();
                 aXmlWriter.endElement();
@@ -184,7 +184,7 @@ void XmpMetadata::write()
                 aXmlWriter.startElement("dc:rights");
                 aXmlWriter.startElement("rdf:Alt");
                 aXmlWriter.startElement("rdf:li");
-                aXmlWriter.attribute("xml:lang", "x-default"_ostr);
+                aXmlWriter.attribute("xml:lang", "x-default");
                 aXmlWriter.content(msRights);
                 aXmlWriter.endElement();
                 aXmlWriter.endElement();
@@ -211,74 +211,72 @@ void XmpMetadata::write()
             if (mnPDF_A != 0)
             { // tdf#157517 PDF/A extension schema is required
                 aXmlWriter.startElement("rdf:Description");
-                aXmlWriter.attribute("rdf:about", ""_ostr);
+                aXmlWriter.attribute("rdf:about", "");
                 aXmlWriter.attribute("xmlns:pdfaExtension",
-                                     
"http://www.aiim.org/pdfa/ns/extension/"_ostr);
-                aXmlWriter.attribute("xmlns:pdfaSchema",
-                                     
"http://www.aiim.org/pdfa/ns/schema#"_ostr);
-                aXmlWriter.attribute("xmlns:pdfaProperty",
-                                     
"http://www.aiim.org/pdfa/ns/property#"_ostr);
+                                     "http://www.aiim.org/pdfa/ns/extension/";);
+                aXmlWriter.attribute("xmlns:pdfaSchema", 
"http://www.aiim.org/pdfa/ns/schema#";);
+                aXmlWriter.attribute("xmlns:pdfaProperty", 
"http://www.aiim.org/pdfa/ns/property#";);
                 aXmlWriter.startElement("pdfaExtension:schemas");
                 aXmlWriter.startElement("rdf:Bag");
                 aXmlWriter.startElement("rdf:li");
-                aXmlWriter.attribute("rdf:parseType", "Resource"_ostr);
+                aXmlWriter.attribute("rdf:parseType", "Resource");
                 aXmlWriter.startElement("pdfaSchema:namespaceURI");
-                aXmlWriter.content("http://www.aiim.org/pdfua/ns/id/"_ostr);
+                aXmlWriter.content("http://www.aiim.org/pdfua/ns/id/";);
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaSchema:prefix");
-                aXmlWriter.content("pdfuaid"_ostr);
+                aXmlWriter.content("pdfuaid");
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaSchema:schema");
-                aXmlWriter.content("PDF/UA identification schema"_ostr);
+                aXmlWriter.content("PDF/UA identification schema");
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaSchema:property");
                 aXmlWriter.startElement("rdf:Seq");
 
                 aXmlWriter.startElement("rdf:li");
-                aXmlWriter.attribute("rdf:parseType", "Resource"_ostr);
+                aXmlWriter.attribute("rdf:parseType", "Resource");
                 aXmlWriter.startElement("pdfaProperty:category");
-                aXmlWriter.content("internal"_ostr);
+                aXmlWriter.content("internal");
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaProperty:description");
-                aXmlWriter.content("PDF/UA version identifier"_ostr);
+                aXmlWriter.content("PDF/UA version identifier");
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaProperty:name");
-                aXmlWriter.content("part"_ostr);
+                aXmlWriter.content("part");
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaProperty:valueType");
-                aXmlWriter.content("Integer"_ostr);
+                aXmlWriter.content("Integer");
                 aXmlWriter.endElement();
                 aXmlWriter.endElement(); // rdf:li
 
                 aXmlWriter.startElement("rdf:li");
-                aXmlWriter.attribute("rdf:parseType", "Resource"_ostr);
+                aXmlWriter.attribute("rdf:parseType", "Resource");
                 aXmlWriter.startElement("pdfaProperty:category");
-                aXmlWriter.content("internal"_ostr);
+                aXmlWriter.content("internal");
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaProperty:description");
-                aXmlWriter.content("PDF/UA amendment identifier"_ostr);
+                aXmlWriter.content("PDF/UA amendment identifier");
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaProperty:name");
-                aXmlWriter.content("amd"_ostr);
+                aXmlWriter.content("amd");
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaProperty:valueType");
-                aXmlWriter.content("Text"_ostr);
+                aXmlWriter.content("Text");
                 aXmlWriter.endElement();
                 aXmlWriter.endElement(); // rdf:li
 
                 aXmlWriter.startElement("rdf:li");
-                aXmlWriter.attribute("rdf:parseType", "Resource"_ostr);
+                aXmlWriter.attribute("rdf:parseType", "Resource");
                 aXmlWriter.startElement("pdfaProperty:category");
-                aXmlWriter.content("internal"_ostr);
+                aXmlWriter.content("internal");
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaProperty:description");
-                aXmlWriter.content("PDF/UA corrigenda identifier"_ostr);
+                aXmlWriter.content("PDF/UA corrigenda identifier");
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaProperty:name");
-                aXmlWriter.content("corr"_ostr);
+                aXmlWriter.content("corr");
                 aXmlWriter.endElement();
                 aXmlWriter.startElement("pdfaProperty:valueType");
-                aXmlWriter.content("Text"_ostr);
+                aXmlWriter.content("Text");
                 aXmlWriter.endElement();
                 aXmlWriter.endElement(); // rdf:li
 
@@ -291,8 +289,8 @@ void XmpMetadata::write()
             }
             OString sPdfUaVersion = OString::number(mnPDF_UA);
             aXmlWriter.startElement("rdf:Description");
-            aXmlWriter.attribute("rdf:about", ""_ostr);
-            aXmlWriter.attribute("xmlns:pdfuaid", 
"http://www.aiim.org/pdfua/ns/id/"_ostr);
+            aXmlWriter.attribute("rdf:about", "");
+            aXmlWriter.attribute("xmlns:pdfuaid", 
"http://www.aiim.org/pdfua/ns/id/";);
 
             aXmlWriter.startElement("pdfuaid:part");
             aXmlWriter.content(sPdfUaVersion);
@@ -301,7 +299,7 @@ void XmpMetadata::write()
             if (mnPDF_UA == 2)
             {
                 aXmlWriter.startElement("pdfuaid:rev");
-                aXmlWriter.content("2024"_ostr);
+                aXmlWriter.content("2024");
                 aXmlWriter.endElement();
             }
             aXmlWriter.endElement();
@@ -311,8 +309,8 @@ void XmpMetadata::write()
         if (!msProducer.isEmpty() || !msKeywords.isEmpty() || 
!msPDFVersion.isEmpty())
         {
             aXmlWriter.startElement("rdf:Description");
-            aXmlWriter.attribute("rdf:about", ""_ostr);
-            aXmlWriter.attribute("xmlns:pdf", 
"http://ns.adobe.com/pdf/1.3/"_ostr);
+            aXmlWriter.attribute("rdf:about", "");
+            aXmlWriter.attribute("xmlns:pdf", "http://ns.adobe.com/pdf/1.3/";);
             if (!msProducer.isEmpty())
             {
                 aXmlWriter.startElement("pdf:Producer");
@@ -336,8 +334,8 @@ void XmpMetadata::write()
 
         // XMP Basic schema
         aXmlWriter.startElement("rdf:Description");
-        aXmlWriter.attribute("rdf:about", ""_ostr);
-        aXmlWriter.attribute("xmlns:xmp", "http://ns.adobe.com/xap/1.0/"_ostr);
+        aXmlWriter.attribute("rdf:about", "");
+        aXmlWriter.attribute("xmlns:xmp", "http://ns.adobe.com/xap/1.0/";);
         if (!m_sCreatorTool.isEmpty())
         {
             aXmlWriter.startElement("xmp:CreatorTool");

Reply via email to