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.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2024-08-15 14:22:16 +02:00
parent 2f6f717073
commit bd0c2772f8
4 changed files with 33 additions and 6 deletions

View file

@ -267,6 +267,7 @@ enum class SfxItemType : sal_uInt16 {
SfxRangeItemType,
SfxRectangleItemType,
SfxRegionItemType,
SfxScriptOrganizerItemType,
SfxSetItemType,
SfxStringItemType,
SfxStringListItemType,

View file

@ -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; };
};

View file

@ -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: */

View file

@ -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