include/svl/poolitem.hxx        |    1 +
 sfx2/inc/sorgitm.hxx            |   12 ++++++++++--
 sfx2/source/control/sorgitm.cxx |   24 +++++++++++++++++++++---
 svl/source/items/poolitem.cxx   |    2 +-
 4 files changed, 33 insertions(+), 6 deletions(-)

New commits:
commit bd0c2772f843dd9ae6c82d00665e303c20a48a73
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Aug 15 14:22:16 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Aug 15 21:04:48 2024 +0200

    SfxScriptOrganizerItem should not subclass SfxStringItem
    
    it never actually uses the superclass value. It has been this way since
    initial import.
    
    Change-Id: I99708c3ad8f1f2727ef87af56c62165d55f348d4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171904
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index 83963b19f7d0..4c69c0c9053d 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -267,6 +267,7 @@ enum class SfxItemType : sal_uInt16 {
     SfxRangeItemType,
     SfxRectangleItemType,
     SfxRegionItemType,
+    SfxScriptOrganizerItemType,
     SfxSetItemType,
     SfxStringItemType,
     SfxStringListItemType,
diff --git a/sfx2/inc/sorgitm.hxx b/sfx2/inc/sorgitm.hxx
index d67d890620eb..3dc6ea8193d6 100644
--- a/sfx2/inc/sorgitm.hxx
+++ b/sfx2/inc/sorgitm.hxx
@@ -19,11 +19,12 @@
 #ifndef INCLUDED_SFX2_INC_SORGITM_HXX
 #define INCLUDED_SFX2_INC_SORGITM_HXX
 
-#include <svl/stritem.hxx>
+#include <svl/svldllapi.h>
+#include <svl/poolitem.hxx>
 
 // class SfxScriptOrganizerItem ---------------------------------------------
 
-class SfxScriptOrganizerItem final : public SfxStringItem
+class SfxScriptOrganizerItem final : public SfxPoolItem
 {
 private:
     OUString aLanguage;
@@ -34,8 +35,15 @@ public:
 
     virtual SfxScriptOrganizerItem* Clone( SfxItemPool* pPool = nullptr ) 
const override;
     virtual bool          operator==( const SfxPoolItem& ) const override;
+    virtual bool supportsHashCode() const override { return true; }
+    virtual size_t hashCode() const override { return aLanguage.hashCode(); }
     virtual bool          QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId 
= 0 ) const override;
     virtual bool          PutValue( const css::uno::Any& rVal, sal_uInt8 
nMemberId ) override;
+    virtual bool GetPresentation(SfxItemPresentation,
+                                 MapUnit, MapUnit,
+                                 OUString & rText,
+                                 const IntlWrapper&) const override;
+    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
     const OUString&       getLanguage() const { return aLanguage; };
 };
 
diff --git a/sfx2/source/control/sorgitm.cxx b/sfx2/source/control/sorgitm.cxx
index a9005619a3a6..39280e71dfb8 100644
--- a/sfx2/source/control/sorgitm.cxx
+++ b/sfx2/source/control/sorgitm.cxx
@@ -21,11 +21,12 @@
 #include <sfx2/sfxsids.hrc>
 #include <sorgitm.hxx>
 #include <osl/diagnose.h>
+#include <libxml/xmlwriter.h>
 
 SfxPoolItem* SfxScriptOrganizerItem::CreateDefault() { return new 
SfxScriptOrganizerItem; }
 
 
-SfxScriptOrganizerItem::SfxScriptOrganizerItem()
+SfxScriptOrganizerItem::SfxScriptOrganizerItem() : SfxPoolItem(0, 
SfxItemType::SfxScriptOrganizerItemType)
 {
 }
 
@@ -36,8 +37,8 @@ SfxScriptOrganizerItem* SfxScriptOrganizerItem::Clone( 
SfxItemPool * ) const
 
 bool SfxScriptOrganizerItem::operator==( const SfxPoolItem& rItem) const
 {
-     return SfxStringItem::operator==(rItem) &&
-         aLanguage == static_cast<const SfxScriptOrganizerItem 
&>(rItem).aLanguage;
+    assert(SfxPoolItem::operator==(rItem));
+    return aLanguage == static_cast<const SfxScriptOrganizerItem 
&>(rItem).aLanguage;
 }
 
 
@@ -82,4 +83,21 @@ bool SfxScriptOrganizerItem::PutValue( const css::uno::Any& 
rVal, sal_uInt8 nMem
     return bRet;
 }
 
+// virtual
+bool SfxScriptOrganizerItem::GetPresentation(SfxItemPresentation, MapUnit,
+                                        MapUnit, OUString & rText,
+                                        const IntlWrapper&) const
+{
+    rText = aLanguage;
+    return true;
+}
+
+void SfxScriptOrganizerItem::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    (void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("SfxScriptOrganizerItem"));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), 
BAD_CAST(aLanguage.toUtf8().getStr()));
+    (void)xmlTextWriterEndElement(pWriter);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index d453c38897c7..76f78863f03f 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -250,9 +250,9 @@
 //        class XLineDashItem : public NameOrIndex
 //        class XLineEndItem : public NameOrIndex
 //        class XLineStartItem : public NameOrIndex
-//    class SfxScriptOrganizerItem : public SfxStringItem
 //    class SdrLayerNameItem: public SfxStringItem
 //    class SwNumRuleItem : public SfxStringItem
+//class SfxScriptOrganizerItem : public SfxPoolItem
 //class SfxBoolItem    : public SfxPoolItem
 //    class SvxAutoKernItem : public SfxBoolItem
 //    class SvxBlinkItem : public SfxBoolItem

Reply via email to