From fb282d552f5a8ecd89c6fd845a6db116d8362114 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 15 Aug 2024 10:24:28 +0200 Subject: [PATCH] merge CntUnencodedStringItem into SfxStringItem which simplifies the hierarhcy. We never allocate such a thing, we always allocate subclasses, and it has no real meaning by itself. Change-Id: Ie6b716c9ea6ca0efe0ae4f39ac345608c45534f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171890 Tested-by: Jenkins Reviewed-by: Noel Grandin --- ...d-can-be-private-symbols.functions.results | 1 - ...b-can-be-private-symbols.functions.results | 1 - .../unusedenumconstants.writeonly.results | 2 - cui/inc/pch/precompiled_cui.hxx | 1 - include/svl/custritm.hxx | 63 ---------------- include/svl/poolitem.hxx | 1 - include/svl/stritem.hxx | 34 ++++++--- reportdesign/inc/pch/precompiled_rptui.hxx | 1 - solenv/clang-format/excludelist | 2 - solenv/vs/LibreOffice.natvis | 2 +- svl/Library_svl.mk | 1 - svl/source/items/custritm.cxx | 71 ------------------- svl/source/items/poolitem.cxx | 49 +++++++------ svl/source/items/stritem.cxx | 42 +++++++++++ sw/inc/pch/precompiled_msword.hxx | 1 - sw/inc/pch/precompiled_vbaswobj.hxx | 1 - 16 files changed, 92 insertions(+), 181 deletions(-) delete mode 100644 include/svl/custritm.hxx delete mode 100644 svl/source/items/custritm.cxx diff --git a/bin/find-can-be-private-symbols.functions.results b/bin/find-can-be-private-symbols.functions.results index 332b99ad4cd3..7572709eeb6c 100644 --- a/bin/find-can-be-private-symbols.functions.results +++ b/bin/find-can-be-private-symbols.functions.results @@ -116,7 +116,6 @@ CntByteItem::Clone(SfxItemPool*) const CntInt32Item::Clone(SfxItemPool*) const CntUInt16Item::Clone(SfxItemPool*) const CntUInt32Item::Clone(SfxItemPool*) const -CntUnencodedStringItem::Clone(SfxItemPool*) const CodeCompleteDataCache::Clear() CodeCompleteDataCache::InsertGlobalVar(rtl::OUString const&, rtl::OUString const&) CodeCompleteDataCache::InsertLocalVar(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&) diff --git a/bin/find-mergedlib-can-be-private-symbols.functions.results b/bin/find-mergedlib-can-be-private-symbols.functions.results index 24eeb5a85d5e..0fa7ff44a5a7 100644 --- a/bin/find-mergedlib-can-be-private-symbols.functions.results +++ b/bin/find-mergedlib-can-be-private-symbols.functions.results @@ -229,7 +229,6 @@ CntByteItem::GetPresentation(SfxItemPresentation, MapUnit, MapUnit, rtl::OUStrin CntInt32Item::Clone(SfxItemPool*) const CntUInt16Item::Clone(SfxItemPool*) const CntUInt32Item::Clone(SfxItemPool*) const -CntUnencodedStringItem::Clone(SfxItemPool*) const CodeCompleteOptions::CodeCompleteOptions() CodeCompleteOptions::IsAutoCloseParenthesisOn() CodeCompleteOptions::IsAutoCloseQuotesOn() diff --git a/compilerplugins/clang/unusedenumconstants.writeonly.results b/compilerplugins/clang/unusedenumconstants.writeonly.results index 5b7f62f259a9..f950b0ba18aa 100644 --- a/compilerplugins/clang/unusedenumconstants.writeonly.results +++ b/compilerplugins/clang/unusedenumconstants.writeonly.results @@ -2508,8 +2508,6 @@ include/svl/poolitem.hxx:113 enum SfxItemType CntUInt16ItemType include/svl/poolitem.hxx:114 enum SfxItemType CntUInt32ItemType -include/svl/poolitem.hxx:115 - enum SfxItemType CntUnencodedStringItemType include/svl/poolitem.hxx:116 enum SfxItemType DatabaseMapItemType include/svl/poolitem.hxx:117 diff --git a/cui/inc/pch/precompiled_cui.hxx b/cui/inc/pch/precompiled_cui.hxx index 3655744b08fa..2ff025d34f49 100644 --- a/cui/inc/pch/precompiled_cui.hxx +++ b/cui/inc/pch/precompiled_cui.hxx @@ -345,7 +345,6 @@ #include #include #include -#include #include #include #include diff --git a/include/svl/custritm.hxx b/include/svl/custritm.hxx deleted file mode 100644 index 118fd0963f15..000000000000 --- a/include/svl/custritm.hxx +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SVL_CUSTRITM_HXX -#define INCLUDED_SVL_CUSTRITM_HXX - -#include -#include -#include -#include - -class SVL_DLLPUBLIC CntUnencodedStringItem: public SfxPoolItem -{ - OUString m_aValue; - -public: - - CntUnencodedStringItem(sal_uInt16 which, SfxItemType eItemType = SfxItemType::CntUnencodedStringItemType) - : SfxPoolItem(which, eItemType) - {} - - CntUnencodedStringItem(sal_uInt16 which, OUString aTheValue, SfxItemType eItemType = SfxItemType::CntUnencodedStringItemType): - SfxPoolItem(which, eItemType), m_aValue(std::move(aTheValue)) - {} - - virtual bool operator ==(const SfxPoolItem & rItem) const override; - - virtual bool GetPresentation(SfxItemPresentation, - MapUnit, MapUnit, - OUString & rText, - const IntlWrapper&) const override; - - 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 CntUnencodedStringItem* Clone(SfxItemPool * = nullptr) const override; - - const OUString & GetValue() const { return m_aValue; } - - void SetValue(const OUString & rTheValue) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_aValue = rTheValue; } -}; - -#endif // INCLUDED_SVL_CUSTRITM_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index 8e86d43dae6f..83963b19f7d0 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -111,7 +111,6 @@ enum class SfxItemType : sal_uInt16 { CntInt32ItemType, CntUInt16ItemType, CntUInt32ItemType, - CntUnencodedStringItemType, DatabaseMapItemType, DbuTypeCollectionItemType, DriverPoolingSettingsItemType, diff --git a/include/svl/stritem.hxx b/include/svl/stritem.hxx index 1b788c05bdf5..270a6cdde41a 100644 --- a/include/svl/stritem.hxx +++ b/include/svl/stritem.hxx @@ -16,31 +16,47 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - -#ifndef INCLUDED_SVL_STRITEM_HXX -#define INCLUDED_SVL_STRITEM_HXX +#pragma once #include -#include +#include +#include +#include -class SVL_DLLPUBLIC SfxStringItem: public CntUnencodedStringItem +class SVL_DLLPUBLIC SfxStringItem: public SfxPoolItem { public: static SfxPoolItem* CreateDefault(); SfxStringItem(sal_uInt16 which = 0, SfxItemType eItemType = SfxItemType::SfxStringItemType) - : CntUnencodedStringItem(which, eItemType) {} + : SfxPoolItem(which, eItemType) {} SfxStringItem(sal_uInt16 which, const OUString & rValue, SfxItemType eItemType = SfxItemType::SfxStringItemType): - CntUnencodedStringItem(which, rValue, eItemType) {} + SfxPoolItem(which, eItemType), m_aValue(rValue) {} + + virtual bool operator ==(const SfxPoolItem & rItem) const override; + + virtual bool GetPresentation(SfxItemPresentation, + MapUnit, MapUnit, + OUString & rText, + const IntlWrapper&) const override; + + 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 SfxStringItem* Clone(SfxItemPool * = nullptr) const override; void dumpAsXml(xmlTextWriterPtr pWriter) const override; + const OUString & GetValue() const { return m_aValue; } + + void SetValue(const OUString & rTheValue) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_aValue = rTheValue; } + +private: + OUString m_aValue; }; -#endif // INCLUDED_SVL_STRITEM_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/reportdesign/inc/pch/precompiled_rptui.hxx b/reportdesign/inc/pch/precompiled_rptui.hxx index 908dfa9cf4f9..5a0d42225883 100644 --- a/reportdesign/inc/pch/precompiled_rptui.hxx +++ b/reportdesign/inc/pch/precompiled_rptui.hxx @@ -371,7 +371,6 @@ #include #include #include -#include #include #include #include diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 983c48ece4a0..c806227c28f3 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -5613,7 +5613,6 @@ include/svl/cenumitm.hxx include/svl/cintitem.hxx include/svl/cryptosign.hxx include/svl/ctloptions.hxx -include/svl/custritm.hxx include/svl/documentlockfile.hxx include/svl/eitem.hxx include/svl/filenotation.hxx @@ -10978,7 +10977,6 @@ svl/source/items/IndexedStyleSheets.cxx svl/source/items/aeitem.cxx svl/source/items/cenumitm.cxx svl/source/items/cintitem.cxx -svl/source/items/custritm.cxx svl/source/items/flagitem.cxx svl/source/items/globalnameitem.cxx svl/source/items/ilstitem.cxx diff --git a/solenv/vs/LibreOffice.natvis b/solenv/vs/LibreOffice.natvis index 8cfedffb93de..6d7eae1a5d04 100644 --- a/solenv/vs/LibreOffice.natvis +++ b/solenv/vs/LibreOffice.natvis @@ -336,7 +336,7 @@ {{which={m_nWhich,x}}} {m_nValue} - + {{which={m_nWhich,x}}} {m_aValue} diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk index d848c2bde516..afb64aca110d 100644 --- a/svl/Library_svl.mk +++ b/svl/Library_svl.mk @@ -116,7 +116,6 @@ $(eval $(call gb_Library_add_exception_objects,svl,\ svl/source/filepicker/pickerhistory \ svl/source/items/cenumitm \ svl/source/items/cintitem \ - svl/source/items/custritm \ svl/source/items/flagitem \ svl/source/items/globalnameitem \ svl/source/items/globalpool \ diff --git a/svl/source/items/custritm.cxx b/svl/source/items/custritm.cxx deleted file mode 100644 index e814662ec77c..000000000000 --- a/svl/source/items/custritm.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include - -#include -#include -#include - -// virtual -bool CntUnencodedStringItem::operator ==(const SfxPoolItem & rItem) const -{ - assert(SfxPoolItem::operator==(rItem)); - return m_aValue - == static_cast< const CntUnencodedStringItem * >(&rItem)-> - m_aValue; -} - -// virtual -bool CntUnencodedStringItem::GetPresentation(SfxItemPresentation, MapUnit, - MapUnit, OUString & rText, - const IntlWrapper&) const -{ - rText = m_aValue; - return true; -} - -// virtual -bool CntUnencodedStringItem::QueryValue(css::uno::Any& rVal, sal_uInt8) const -{ - rVal <<= m_aValue; - return true; -} - -// virtual -bool CntUnencodedStringItem::PutValue(const css::uno::Any& rVal, - sal_uInt8) -{ - OUString aTheValue; - if (rVal >>= aTheValue) - { - m_aValue = aTheValue; - return true; - } - OSL_FAIL("CntUnencodedStringItem::PutValue(): Wrong type"); - return false; -} - -// virtual -CntUnencodedStringItem* CntUnencodedStringItem::Clone(SfxItemPool *) const -{ - return new CntUnencodedStringItem(*this); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx index dd628225a7d8..d453c38897c7 100644 --- a/svl/source/items/poolitem.cxx +++ b/svl/source/items/poolitem.cxx @@ -229,31 +229,30 @@ // class SvxRsidItem : public SfxUInt32Item // class SdrGrafGamma100Item : public SfxUInt32Item // class SwTableBoxNumFormat : public SfxUInt32Item -//class CntUnencodedStringItem: public SfxPoolItem -// class SfxStringItem: public CntUnencodedStringItem -// class SvxPageModelItem : public SfxStringItem -// class SfxDocumentInfoItem : public SfxStringItem -// class SvxPostItAuthorItem: public SfxStringItem -// class SvxPostItDateItem: public SfxStringItem -// class SvxPostItTextItem: public SfxStringItem -// class SvxPostItIdItem: public SfxStringItem -// class SdrMeasureFormatStringItem: public SfxStringItem -// class NameOrIndex : public SfxStringItem -// class XFillBitmapItem : public NameOrIndex -// class XColorItem : public NameOrIndex -// class XFillColorItem : public XColorItem -// class XFormTextShadowColorItem : public XColorItem -// class XLineColorItem : public XColorItem -// class XSecondaryFillColorItem : public XColorItem -// class XFillGradientItem : public NameOrIndex -// class XFillFloatTransparenceItem : public XFillGradientItem -// class XFillHatchItem : public NameOrIndex -// 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 SfxStringItem: public SfxPoolItem +// class SvxPageModelItem : public SfxStringItem +// class SfxDocumentInfoItem : public SfxStringItem +// class SvxPostItAuthorItem: public SfxStringItem +// class SvxPostItDateItem: public SfxStringItem +// class SvxPostItTextItem: public SfxStringItem +// class SvxPostItIdItem: public SfxStringItem +// class SdrMeasureFormatStringItem: public SfxStringItem +// class NameOrIndex : public SfxStringItem +// class XFillBitmapItem : public NameOrIndex +// class XColorItem : public NameOrIndex +// class XFillColorItem : public XColorItem +// class XFormTextShadowColorItem : public XColorItem +// class XLineColorItem : public XColorItem +// class XSecondaryFillColorItem : public XColorItem +// class XFillGradientItem : public NameOrIndex +// class XFillFloatTransparenceItem : public XFillGradientItem +// class XFillHatchItem : public NameOrIndex +// 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 SfxBoolItem : public SfxPoolItem // class SvxAutoKernItem : public SfxBoolItem // class SvxBlinkItem : public SfxBoolItem diff --git a/svl/source/items/stritem.cxx b/svl/source/items/stritem.cxx index c0ec01a9aba4..a384e23a2ee8 100644 --- a/svl/source/items/stritem.cxx +++ b/svl/source/items/stritem.cxx @@ -19,6 +19,48 @@ #include #include +#include +#include +#include + +// virtual +bool SfxStringItem::GetPresentation(SfxItemPresentation, MapUnit, + MapUnit, OUString & rText, + const IntlWrapper&) const +{ + rText = m_aValue; + return true; +} + +// virtual +bool SfxStringItem::QueryValue(css::uno::Any& rVal, sal_uInt8) const +{ + rVal <<= m_aValue; + return true; +} + +// virtual +bool SfxStringItem::PutValue(const css::uno::Any& rVal, + sal_uInt8) +{ + OUString aTheValue; + if (rVal >>= aTheValue) + { + m_aValue = aTheValue; + return true; + } + OSL_FAIL("CntUnencodedStringItem::PutValue(): Wrong type"); + return false; +} + +// virtual +bool SfxStringItem::operator ==(const SfxPoolItem & rItem) const +{ + assert(SfxPoolItem::operator==(rItem)); + return m_aValue + == static_cast< const SfxStringItem * >(&rItem)-> + m_aValue; +} // virtual SfxStringItem* SfxStringItem::Clone(SfxItemPool *) const diff --git a/sw/inc/pch/precompiled_msword.hxx b/sw/inc/pch/precompiled_msword.hxx index a6385c4be84b..d0e555fb70bc 100644 --- a/sw/inc/pch/precompiled_msword.hxx +++ b/sw/inc/pch/precompiled_msword.hxx @@ -434,7 +434,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/inc/pch/precompiled_vbaswobj.hxx b/sw/inc/pch/precompiled_vbaswobj.hxx index c6e0bb176da7..88ac8570d5fe 100644 --- a/sw/inc/pch/precompiled_vbaswobj.hxx +++ b/sw/inc/pch/precompiled_vbaswobj.hxx @@ -309,7 +309,6 @@ #include #include #include -#include #include #include #include