editeng/source/items/frmitems.cxx |   84 ++++++++++++++++++--------------------
 svl/source/items/cenumitm.cxx     |    8 ++-
 svl/source/items/intitem.cxx      |   31 +++++++-------
 svl/source/items/itemset.cxx      |   10 ++--
 svl/source/items/poolitem.cxx     |   20 ++++-----
 svl/source/items/stritem.cxx      |   10 ++--
 svl/source/items/style.cxx        |   24 ++++------
 svl/source/items/voiditem.cxx     |    9 ++--
 svl/source/undo/undo.cxx          |   45 ++++++++++----------
 svx/source/xoutdev/xattr.cxx      |   67 ++++++++++++++----------------
 svx/source/xoutdev/xattr2.cxx     |   55 ++++++++++++++----------
 svx/source/xoutdev/xattrbmp.cxx   |   10 ++--
 12 files changed, 192 insertions(+), 181 deletions(-)

New commits:
commit 4edaca7c38fbe66d3d27994748f8ddd03410bfce
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Sun Dec 7 00:06:17 2025 +0900
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Mon Dec 8 09:01:03 2025 +0100

    switch some dumpAsXml functions to use tools::XmlWriter
    
    Change-Id: I6bcda888f578ec52c05a575df56c4c267ad82ccc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195169
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/editeng/source/items/frmitems.cxx 
b/editeng/source/items/frmitems.cxx
index b3742fc9b06c..b397d4e4dff7 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -50,6 +50,7 @@
 #include <tools/debug.hxx>
 #include <tools/mapunit.hxx>
 #include <tools/UnitConversion.hxx>
+#include <tools/XmlWriter.hxx>
 #include <vcl/graphicfilter.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
@@ -1022,11 +1023,12 @@ bool SvxLeftMarginItem::HasMetrics() const
 
 void SvxLeftMarginItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxLeftMarginItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nLeftMargin"), 
BAD_CAST(OString::number(m_nLeftMargin).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nPropLeftMargin"), 
BAD_CAST(OString::number(m_nPropLeftMargin).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SvxLeftMarginItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("m_nLeftMargin", m_nLeftMargin);
+    aWriter.attribute("m_nPropLeftMargin", m_nPropLeftMargin);
+    aWriter.endElement();
 }
 
 boost::property_tree::ptree SvxLeftMarginItem::dumpAsJSON() const
@@ -2806,13 +2808,14 @@ bool SvxShadowItem::HasMetrics() const
 
 void SvxShadowItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxShadowItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("aShadowColor"), 
BAD_CAST(aShadowColor.AsRGBHexString().toUtf8().getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nWidth"), 
BAD_CAST(OString::number(nWidth).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("eLocation"), 
BAD_CAST(OString::number(static_cast<int>(eLocation)).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), 
BAD_CAST(EditResId(RID_SVXITEMS_SHADOW[static_cast<int>(eLocation)]).toUtf8().getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SvxShadowItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("aShadowColor", aShadowColor.AsRGBHexString());
+    aWriter.attribute("nWidth", nWidth);
+    aWriter.attribute("eLocation", sal_Int32(eLocation));
+    aWriter.attribute("presentation", 
EditResId(RID_SVXITEMS_SHADOW[static_cast<int>(eLocation)]));
+    aWriter.endElement();
 }
 
 // class SvxBoxItem ------------------------------------------------------
@@ -2845,17 +2848,14 @@ SvxBoxItem::~SvxBoxItem()
 
 void SvxBoxItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxBoxItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("top-dist"),
-                                      
BAD_CAST(OString::number(mnTopDistance).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("bottom-dist"),
-                                      
BAD_CAST(OString::number(mnBottomDistance).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("left-dist"),
-                                      
BAD_CAST(OString::number(mnLeftDistance).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("right-dist"),
-                                      
BAD_CAST(OString::number(mnRightDistance).getStr()));
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SvxBoxItem");
+    aWriter.attribute("top-dist", mnTopDistance);
+    aWriter.attribute("bottom-dist", mnBottomDistance);
+    aWriter.attribute("left-dist", mnLeftDistance);
+    aWriter.attribute("right-dist", mnRightDistance);
     SfxPoolItem::dumpAsXml(pWriter);
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement();
 }
 
 boost::property_tree::ptree SvxBoxItem::dumpAsJSON() const
@@ -4373,11 +4373,10 @@ bool SvxFormatKeepItem::GetPresentation
 
 void SvxFormatKeepItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxFormatKeepItem"));
-
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SvxFormatKeepItem");
     SfxBoolItem::dumpAsXml(pWriter);
-
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement();
 }
 
 SvxLineItem::SvxLineItem( const sal_uInt16 nId ) :
@@ -5138,16 +5137,17 @@ void SvxBrushItem::ApplyGraphicTransparency_Impl()
 
 void SvxBrushItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxBrushItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("color"), 
BAD_CAST(aColor.AsRGBHexString().toUtf8().getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("filtercolor"), 
BAD_CAST(aFilterColor.AsRGBHexString().toUtf8().getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("shadingValue"), 
BAD_CAST(OString::number(nShadingValue).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("link"), 
BAD_CAST(maStrLink.toUtf8().getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("filter"), 
BAD_CAST(maStrFilter.toUtf8().getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("graphicPos"), 
BAD_CAST(OString::number(eGraphicPos).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("loadAgain"), 
BAD_CAST(OString::boolean(bLoadAgain).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SvxBrushItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("color", aColor.AsRGBHexString());
+    aWriter.attribute("filtercolor", aFilterColor.AsRGBHexString());
+    aWriter.attribute("shadingValue", nShadingValue);
+    aWriter.attribute("link", maStrLink);
+    aWriter.attribute("filter", maStrFilter);
+    aWriter.attribute("graphicPos", eGraphicPos);
+    aWriter.attribute("loadAgain", bLoadAgain);
+    aWriter.endElement();
 }
 
 ItemInstanceManager* SvxFrameDirectionItem::getItemInstanceManager() const
@@ -5290,13 +5290,11 @@ bool SvxFrameDirectionItem::QueryValue( css::uno::Any& 
rVal,
 
 void SvxFrameDirectionItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("SvxFrameDirectionItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nWhich"),
-                                BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(
-        pWriter, BAD_CAST("m_nValue"),
-        
BAD_CAST(OString::number(static_cast<sal_Int16>(GetValue())).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SvxFrameDirectionItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("m_nValue", sal_Int16(GetValue()));
+    aWriter.endElement();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/cenumitm.cxx b/svl/source/items/cenumitm.cxx
index 8da04d98df67..849ce0307635 100644
--- a/svl/source/items/cenumitm.cxx
+++ b/svl/source/items/cenumitm.cxx
@@ -23,6 +23,7 @@
 #include <unordered_map>
 #include <comphelper/extract.hxx>
 #include <libxml/xmlwriter.h>
+#include <tools/XmlWriter.hxx>
 #include <sal/log.hxx>
 
 
@@ -196,10 +197,11 @@ bool SfxBoolItem::GetPresentation(SfxItemPresentation,
 
 void SfxBoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxBoolItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(GetValueTextByVal(m_bValue).toUtf8().getStr()));
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxBoolItem");
+    aWriter.attribute("value", GetValueTextByVal(m_bValue));
     SfxPoolItem::dumpAsXml(pWriter);
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement();
 }
 
 // virtual
diff --git a/svl/source/items/intitem.cxx b/svl/source/items/intitem.cxx
index 0ced3eb20146..02acd395d137 100644
--- a/svl/source/items/intitem.cxx
+++ b/svl/source/items/intitem.cxx
@@ -17,18 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
 #include <svl/intitem.hxx>
 #include <com/sun/star/uno/Any.hxx>
 #include <osl/diagnose.h>
 #include <tools/bigint.hxx>
 #include <svl/metitem.hxx>
 #include <libxml/xmlwriter.h>
+#include <tools/XmlWriter.hxx>
 #include <boost/property_tree/ptree.hpp>
 
 
-
-
 SfxPoolItem* SfxByteItem::CreateDefault()
 {
     return new SfxByteItem();
@@ -100,10 +98,11 @@ SfxPoolItem* SfxUInt16Item::CreateDefault()
 
 void SfxUInt16Item::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxUInt16Item"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(OString::number(GetValue()).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxUInt16Item");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", GetValue());
+    aWriter.endElement();
 }
 
 boost::property_tree::ptree SfxUInt16Item::dumpAsJSON() const
@@ -123,10 +122,11 @@ SfxPoolItem* SfxInt32Item::CreateDefault()
 
 void SfxInt32Item::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxInt32Item"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(OString::number(GetValue()).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxInt32Item");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", GetValue());
+    aWriter.endElement();
 }
 
 boost::property_tree::ptree SfxInt32Item::dumpAsJSON() const
@@ -146,10 +146,11 @@ SfxPoolItem* SfxUInt32Item::CreateDefault()
 
 void SfxUInt32Item::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxUInt32Item"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(OString::number(GetValue()).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxUInt32Item");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", GetValue());
+    aWriter.endElement();
 }
 
 boost::property_tree::ptree SfxUInt32Item::dumpAsJSON() const
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 3c0d1cbd4783..5a7efdac8708 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -26,6 +26,7 @@
 #include <unordered_map>
 
 #include <libxml/xmlwriter.h>
+#include <tools/XmlWriter.hxx>
 
 #include <sal/log.hxx>
 #include <svl/itemset.hxx>
@@ -1344,21 +1345,22 @@ SfxItemSet SfxItemSet::CloneAsValue(bool bItems, 
SfxItemPool *pToPool ) const
 
 void SfxItemSet::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxItemSet"));
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxItemSet");
     SfxItemIter aIter(*this);
     for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
     {
         if (IsInvalidItem(pItem))
         {
-            (void)xmlTextWriterStartElement(pWriter, BAD_CAST("invalid"));
-            (void)xmlTextWriterEndElement(pWriter);
+            aWriter.startElement("invalid");
+            aWriter.endElement();
         }
         else
         {
             pItem->dumpAsXml(pWriter);
         }
     }
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement();
 }
 
 
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index 3bb040372f29..393554df1ac8 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -23,6 +23,7 @@
 #include <osl/diagnose.h>
 #include <sal/log.hxx>
 #include <libxml/xmlwriter.h>
+#include <tools/XmlWriter.hxx>
 #include <typeinfo>
 #include <boost/property_tree/ptree.hpp>
 
@@ -187,19 +188,20 @@ bool SfxPoolItem::GetPresentation(
 
 void SfxPoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxPoolItem"));
-    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"),
-                                      
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("typeName"),
-                                      BAD_CAST(typeid(*this).name()));
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxPoolItem");
+    aWriter.attribute("ptr", reinterpret_cast<sal_IntPtr>(this));
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("typeName", typeid(*this).name());
+
     OUString rText;
     IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
     if (GetPresentation(SfxItemPresentation::Complete, MapUnit::Map100thMM, 
MapUnit::Map100thMM,
                         rText, aIntlWrapper))
-        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"),
-                                          BAD_CAST(rText.toUtf8().getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    {
+        aWriter.attribute("presentation", rText);
+    }
+    aWriter.endElement();
 }
 
 boost::property_tree::ptree SfxPoolItem::dumpAsJSON() const
diff --git a/svl/source/items/stritem.cxx b/svl/source/items/stritem.cxx
index 0c6b8be1763d..fef4d404a486 100644
--- a/svl/source/items/stritem.cxx
+++ b/svl/source/items/stritem.cxx
@@ -19,6 +19,7 @@
 
 #include <svl/stritem.hxx>
 #include <libxml/xmlwriter.h>
+#include <tools/XmlWriter.hxx>
 #include <com/sun/star/uno/Any.hxx>
 #include <osl/diagnose.h>
 #include <unotools/intlwrapper.hxx>
@@ -70,10 +71,11 @@ SfxStringItem* SfxStringItem::Clone(SfxItemPool *) const
 
 void SfxStringItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxStringItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(GetValue().toUtf8().getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxStringItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", GetValue());
+    aWriter.endElement();
 }
 
 SfxPoolItem* SfxStringItem::CreateDefault()
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index 97a183bb05a8..fefcd02c78dd 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -20,6 +20,7 @@
 #include <memory>
 
 #include <libxml/xmlwriter.h>
+#include <tools/XmlWriter.hxx>
 
 #include <svl/style.hxx>
 
@@ -273,14 +274,13 @@ std::optional<SfxItemSet> 
SfxStyleSheetBase::GetItemSetForPreview()
 
 void SfxStyleSheetBase::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxStyleSheetBase"));
-    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), 
BAD_CAST(aName.toUtf8().getStr()));
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxStyleSheetBase");
+    aWriter.attribute("ptr", reinterpret_cast<sal_IntPtr>(this));
+    aWriter.attribute("name", aName);
     if (pSet)
-    {
         pSet->dumpAsXml(pWriter);
-    }
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement();
 }
 
 /**
@@ -694,17 +694,15 @@ void SfxStyleSheetBasePool::Add( const SfxStyleSheetBase& 
rSheet )
 
 void SfxStyleSheetBasePool::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("SfxStyleSheetBasePool"));
-    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
-
-    std::shared_ptr<SfxStyleSheetIterator> aSSSI
-        = std::make_shared<SfxStyleSheetIterator>(this, SfxStyleFamily::All);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxStyleSheetBasePool");
+    aWriter.attribute("ptr", reinterpret_cast<sal_IntPtr>(this));
+    auto aSSSI = std::make_shared<SfxStyleSheetIterator>(this, 
SfxStyleFamily::All);
     for (SfxStyleSheetBase* pStyle = aSSSI->First(); pStyle; pStyle = 
aSSSI->Next())
     {
         pStyle->dumpAsXml(pWriter);
     }
-
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement();
 }
 
 SfxStyleSheetBasePool& SfxStyleSheetBasePool::operator=( const 
SfxStyleSheetBasePool& r )
diff --git a/svl/source/items/voiditem.cxx b/svl/source/items/voiditem.cxx
index 6bda725d0fcd..df1503dc7473 100644
--- a/svl/source/items/voiditem.cxx
+++ b/svl/source/items/voiditem.cxx
@@ -19,6 +19,7 @@
 
 #include <svl/voiditem.hxx>
 #include <libxml/xmlwriter.h>
+#include <tools/XmlWriter.hxx>
 #include <sal/log.hxx>
 
 SfxPoolItem* SfxVoidItem::CreateDefault() { return new SfxVoidItem(0); }
@@ -59,10 +60,10 @@ bool SfxVoidItem::GetPresentation(SfxItemPresentation 
/*ePresentation*/, MapUnit
 
 void SfxVoidItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxVoidItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"),
-                                      
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxVoidItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.endElement();
 }
 
 SfxVoidItem* SfxVoidItem::Clone(SfxItemPool*) const { return new 
SfxVoidItem(*this); }
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index 8986ff76d7ac..4972a119491f 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -25,6 +25,7 @@
 #include <comphelper/diagnose_ex.hxx>
 #include <tools/long.hxx>
 #include <libxml/xmlwriter.h>
+#include <tools/XmlWriter.hxx>
 #include <boost/property_tree/json_parser.hpp>
 #include <unotools/datetime.hxx>
 
@@ -146,13 +147,14 @@ bool SfxUndoAction::CanRepeat(SfxRepeatTarget&) const
 
 void SfxUndoAction::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxUndoAction"));
-    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"), 
BAD_CAST(typeid(*this).name()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("comment"), 
BAD_CAST(GetComment().toUtf8().getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("viewShellId"), 
BAD_CAST(OString::number(static_cast<sal_Int32>(GetViewShellId())).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("dateTime"), 
BAD_CAST(utl::toISO8601(m_aDateTime.GetUNODateTime()).toUtf8().getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxUndoAction");
+    aWriter.attribute("ptr", reinterpret_cast<sal_IntPtr>(this));
+    aWriter.attribute("symbol", typeid(*this).name());
+    aWriter.attribute("comment", GetComment());
+    aWriter.attribute("viewShellId", sal_Int32(GetViewShellId()));
+    aWriter.attribute("dateTime", 
utl::toISO8601(m_aDateTime.GetUNODateTime()));
+    aWriter.endElement();
 }
 
 std::unique_ptr<SfxUndoAction> SfxUndoArray::Remove(int idx)
@@ -1205,27 +1207,27 @@ void SfxUndoManager::dumpAsXml(xmlTextWriterPtr 
pWriter) const
         bOwns = true;
     }
 
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxUndoManager"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nUndoActionCount"), 
BAD_CAST(OString::number(GetUndoActionCount()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nRedoActionCount"), 
BAD_CAST(OString::number(GetRedoActionCount()).getStr()));
-
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("undoActions"));
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxUndoManager");
+    aWriter.attribute("nUndoActionCount", GetUndoActionCount());
+    aWriter.attribute("nRedoActionCount", GetRedoActionCount());
+    aWriter.startElement("undoActions");
     for (size_t i = 0; i < GetUndoActionCount(); ++i)
     {
         const SfxUndoArray* pUndoArray = m_xData->pActUndoArray;
         pUndoArray->maUndoActions[pUndoArray->nCurUndoAction - 1 - 
i].pAction->dumpAsXml(pWriter);
     }
-    (void)xmlTextWriterEndElement(pWriter);
-
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("redoActions"));
+    aWriter.endElement();
+    aWriter.startElement("redoActions");
     for (size_t i = 0; i < GetRedoActionCount(); ++i)
     {
         const SfxUndoArray* pUndoArray = m_xData->pActUndoArray;
         pUndoArray->maUndoActions[pUndoArray->nCurUndoAction + 
i].pAction->dumpAsXml(pWriter);
     }
-    (void)xmlTextWriterEndElement(pWriter);
 
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement();
+    aWriter.endElement();
+
     if (bOwns)
     {
         (void)xmlTextWriterEndDocument(pWriter);
@@ -1417,14 +1419,13 @@ bool SfxListUndoAction::Merge( SfxUndoAction 
*pNextAction )
 
 void SfxListUndoAction::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxListUndoAction"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("size"), 
BAD_CAST(OString::number(maUndoActions.size()).getStr()));
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("SfxListUndoAction");
+    aWriter.attribute("size", maUndoActions.size());
     SfxUndoAction::dumpAsXml(pWriter);
-
     for (size_t i = 0; i < maUndoActions.size(); ++i)
         maUndoActions[i].pAction->dumpAsXml(pWriter);
-
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement();
 }
 
 SfxUndoArray::~SfxUndoArray()
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index 84468622d9f3..f5fa68bc3e88 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -89,6 +89,7 @@
 #include <unotools/intlwrapper.hxx>
 #include <unotools/syslocale.hxx>
 #include <string>
+#include <tools/XmlWriter.hxx>
 
 #include <boost/property_tree/ptree.hpp>
 #include <libxml/xmlwriter.h>
@@ -266,12 +267,13 @@ OUString NameOrIndex::CheckNamedItem(const sal_uInt16 
nWhich, const SfxItemPool*
 
 void NameOrIndex::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("NameOrIndex"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("isIndex"), 
BAD_CAST(OString::boolean(IsIndex()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), 
BAD_CAST(GetName().toUtf8().getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("index"), 
BAD_CAST(OString::number(m_nPalIndex).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("NameOrIndex");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("isIndex", IsIndex());
+    aWriter.attribute("name", GetName());
+    aWriter.attribute("index", GetPalIndex());
+    aWriter.endElement();
 }
 
 SfxPoolItem* XColorItem::CreateDefault() { return new XColorItem(); }
@@ -399,38 +401,32 @@ bool XColorItem::PutValue( const css::uno::Any& rVal, 
sal_uInt8 nMemberId)
 
 void XColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XColorItem"));
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("XColorItem");
     if (Which() == SDRATTR_SHADOWCOLOR)
     {
-        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST("SDRATTR_SHADOWCOLOR"));
+        aWriter.attribute("whichId", "SDRATTR_SHADOWCOLOR");
     }
     else if (Which() == XATTR_FILLCOLOR)
     {
-        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST("XATTR_FILLCOLOR"));
+        aWriter.attribute("whichId", "XATTR_FILLCOLOR");
     }
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("aColor"),
-                                
BAD_CAST(m_aColor.AsRGBHexString().toUtf8().getStr()));
+    aWriter.attribute("color", m_aColor.AsRGBHexString());
 
     NameOrIndex::dumpAsXml(pWriter);
 
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("complex-color"));
-
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("scheme-index"),
-                                      
BAD_CAST(OString::number(sal_Int16(maComplexColor.getThemeColorType())).getStr()));
-
+    aWriter.startElement("ComplexColor");
+    aWriter.attribute("scheme_index", 
sal_Int16(maComplexColor.getThemeColorType()));
     for (auto const& rTransform : maComplexColor.getTransformations())
     {
-        (void)xmlTextWriterStartElement(pWriter, BAD_CAST("transformation"));
-        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"),
-                                      
BAD_CAST(OString::number(sal_Int16(rTransform.meType)).getStr()));
-        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
-                                      
BAD_CAST(OString::number(rTransform.mnValue).getStr()));
-        (void)xmlTextWriterEndElement(pWriter);
+        aWriter.startElement("transformation");
+        aWriter.attribute("type", sal_Int16(rTransform.meType));
+        aWriter.attribute("value", rTransform.mnValue);
+        aWriter.endElement();
     }
 
-    (void)xmlTextWriterEndElement(pWriter);
-
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement(); // complex-color
+    aWriter.endElement(); // XColorItem
 }
 
 // --- line attributes ---
@@ -1781,16 +1777,17 @@ bool XFillStyleItem::PutValue( const css::uno::Any& 
rVal, sal_uInt8 /*nMemberId*
 
 void XFillStyleItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillStyleItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(OString::number(static_cast<sal_Int16>(GetValue())).getStr()));
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("XFillStyleItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", sal_Int16(GetValue()));
 
     OUString aPresentation;
     IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
     GetPresentation(SfxItemPresentation::Nameless, MapUnit::Map100thMM, 
MapUnit::Map100thMM, aPresentation, aIntlWrapper);
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), 
BAD_CAST(aPresentation.toUtf8().getStr()));
+    aWriter.attribute("presentation", aPresentation);
 
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement();
 }
 
 boost::property_tree::ptree XFillStyleItem::dumpAsJSON() const
@@ -1979,12 +1976,12 @@ bool XFillColorItem::PutValue( const css::uno::Any& 
rVal, sal_uInt8 nMemberId )
 
 void XFillColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillColorItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("XFillColorItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", GetValue());
     XColorItem::dumpAsXml(pWriter);
-
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement();
 }
 
 boost::property_tree::ptree XFillColorItem::dumpAsJSON() const
diff --git a/svx/source/xoutdev/xattr2.cxx b/svx/source/xoutdev/xattr2.cxx
index 1131408e4bf5..744441c32fb4 100644
--- a/svx/source/xoutdev/xattr2.cxx
+++ b/svx/source/xoutdev/xattr2.cxx
@@ -51,6 +51,7 @@
 #include <comphelper/lok.hxx>
 
 #include <libxml/xmlwriter.h>
+#include <tools/XmlWriter.hxx>
 #include <boost/property_tree/ptree.hpp>
 
 XLineTransparenceItem::XLineTransparenceItem(sal_uInt16 nLineTransparence) :
@@ -356,10 +357,11 @@ bool XFillTransparenceItem::GetPresentation
 
 void XFillTransparenceItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("XFillTransparenceItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(OString::number(GetValue()).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("XFillTransparenceItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", GetValue());
+    aWriter.endElement();
 }
 
 boost::property_tree::ptree XFillTransparenceItem::dumpAsJSON() const
@@ -482,10 +484,11 @@ bool XFillBmpTileItem::GetPresentation
 
 void XFillBmpTileItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillBmpTileItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(OString::boolean(GetValue()).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("XFillBmpTileItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", GetValue());
+    aWriter.endElement();
 }
 
 
@@ -514,10 +517,11 @@ bool XFillBmpPosItem::GetPresentation
 
 void XFillBmpPosItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillBmpPosItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(OString::number(static_cast<int>(GetValue())).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("XFillBmpPosItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", sal_Int32(GetValue()));
+    aWriter.endElement();
 }
 
 
@@ -671,10 +675,11 @@ bool XFillBmpStretchItem::GetPresentation
 
 void XFillBmpStretchItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillBmpStretchItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(OString::boolean(GetValue()).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("XFillBmpStretchItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", GetValue());
+    aWriter.endElement();
 }
 
 XFillBmpPosOffsetXItem::XFillBmpPosOffsetXItem(sal_Int32 nOffPosX)
@@ -740,10 +745,11 @@ bool XFillBackgroundItem::GetPresentation( 
SfxItemPresentation /*ePres*/, MapUni
 
 void XFillBackgroundItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillBackgroundItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(OString::boolean(GetValue()).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("XFillBackgroundItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", GetValue());
+    aWriter.endElement();
 }
 
 XFillUseSlideBackgroundItem::XFillUseSlideBackgroundItem( bool bFill ) :
@@ -765,10 +771,11 @@ bool XFillUseSlideBackgroundItem::GetPresentation( 
SfxItemPresentation /*ePres*/
 
 void XFillUseSlideBackgroundItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("XFillUseSlideBackgroundItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(OString::boolean(GetValue()).getStr()));
-    (void)xmlTextWriterEndElement(pWriter);
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("XFillUseSlideBackgroundItem");
+    aWriter.attribute("whichId", Which());
+    aWriter.attribute("value", GetValue());
+    aWriter.endElement();
 }
 
 
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index 50c754beb936..c34bdb353e23 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -39,6 +39,7 @@
 #include <vcl/GraphicLoader.hxx>
 
 #include <libxml/xmlwriter.h>
+#include <tools/XmlWriter.hxx>
 
 using namespace ::com::sun::star;
 
@@ -328,12 +329,11 @@ std::unique_ptr<XFillBitmapItem> 
XFillBitmapItem::checkForUniqueItem( SdrModel&
 
 void XFillBitmapItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("XFillBitmapItem"));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
-
+    tools::XmlWriter aWriter(pWriter);
+    aWriter.startElement("XFillBitmapItem");
+    aWriter.attribute("whichId", Which());
     NameOrIndex::dumpAsXml(pWriter);
-
-    (void)xmlTextWriterEndElement(pWriter);
+    aWriter.endElement();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to