diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-08-15 14:22:16 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-08-15 21:04:48 +0200 |
commit | bd0c2772f843dd9ae6c82d00665e303c20a48a73 (patch) | |
tree | f285cece010ba5d3485dddb9f9b5d27c7e628c76 /sfx2 | |
parent | 2f6f717073084b17e9be80e32a87200bacd1b74c (diff) |
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>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sorgitm.hxx | 12 | ||||
-rw-r--r-- | sfx2/source/control/sorgitm.cxx | 24 |
2 files changed, 31 insertions, 5 deletions
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: */ |