sw/inc/fchrfmt.hxx                  |    2 ++
 sw/source/core/txtnode/chrfmt.cxx   |    1 +
 sw/source/core/txtnode/fmtatr2.cxx  |   11 +++++++++++
 sw/source/core/txtnode/txatbase.cxx |    7 -------
 4 files changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 795a02b719a86dd128b10a867036a26450536c95
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Jan 4 20:04:35 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Jan 5 07:12:03 2023 +0000

    sw doc model xml dump: extract part of SwTextAttr::dumpAsXml() ...
    
    ... into SwFormatCharFormat().
    
    This allows searching for a style name like Emphasis and search for all
    uses, even if you're not confident wrt the name due to style name
    collisions.
    
    This also means that the impl details of SwFormatCharFormat now leak
    less into SwTextAttr.
    
    Change-Id: Ifb208d04c938b7070ec94ebe727309bab96266dc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145046
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/inc/fchrfmt.hxx b/sw/inc/fchrfmt.hxx
index ef8719103f7c..87508596013b 100644
--- a/sw/inc/fchrfmt.hxx
+++ b/sw/inc/fchrfmt.hxx
@@ -68,6 +68,8 @@ public:
         pFormat->Add(this);
     }
     SwCharFormat* GetCharFormat() const { return 
const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(GetRegisteredIn())); 
}
+
+    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 };
 #endif
 
diff --git a/sw/source/core/txtnode/chrfmt.cxx 
b/sw/source/core/txtnode/chrfmt.cxx
index ea2bb5a45511..e22b6bab0421 100644
--- a/sw/source/core/txtnode/chrfmt.cxx
+++ b/sw/source/core/txtnode/chrfmt.cxx
@@ -26,6 +26,7 @@
 void SwCharFormat::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwCharFormat"));
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"),
                                       BAD_CAST(GetName().toUtf8().getStr()));
 
diff --git a/sw/source/core/txtnode/fmtatr2.cxx 
b/sw/source/core/txtnode/fmtatr2.cxx
index d3843f4db1e8..c776116a4ecc 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -113,6 +113,17 @@ bool SwFormatCharFormat::PutValue( const uno::Any& , 
sal_uInt8   )
     return false;
 }
 
+void SwFormatCharFormat::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFormatCharFormat"));
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, 
BAD_CAST("text-attribute"), "%p", m_pTextAttribute);
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("char-format"), 
"%p", GetCharFormat());
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("char-format-name"),
+                                      
BAD_CAST(GetCharFormat()->GetName().toUtf8().getStr()));
+    (void)xmlTextWriterEndElement(pWriter);
+}
+
 SwFormatAutoFormat::SwFormatAutoFormat( sal_uInt16 nInitWhich )
     : SfxPoolItem( nInitWhich )
 {
diff --git a/sw/source/core/txtnode/txatbase.cxx 
b/sw/source/core/txtnode/txatbase.cxx
index 011abccb4a71..1b65cf793448 100644
--- a/sw/source/core/txtnode/txatbase.cxx
+++ b/sw/source/core/txtnode/txatbase.cxx
@@ -113,13 +113,6 @@ void SwTextAttr::dumpAsXml(xmlTextWriterPtr pWriter) const
     case RES_TXTATR_FLYCNT:
         pWhich = "fly content";
         break;
-    case RES_TXTATR_CHARFMT:
-        {
-            pWhich = "character format";
-            if (SwCharFormat* pCharFormat = GetCharFormat().GetCharFormat())
-                oValue = OString("name: " + 
OUStringToOString(pCharFormat->GetName(), RTL_TEXTENCODING_UTF8));
-            break;
-        }
     case RES_TXTATR_INETFMT:
         {
             pWhich = "inet format";

Reply via email to