avmedia/source/framework/mediatoolbox.cxx | 2 basctl/source/basicide/IDEComboBox.cxx | 4 basctl/source/basicide/basides1.cxx | 2 basctl/source/basicide/sbxitem.cxx | 35 + basctl/source/inc/IDEComboBox.hxx | 4 basctl/source/inc/sbxitem.hxx | 19 - cui/source/dialogs/cuihyperdlg.cxx | 2 cui/source/inc/cuihyperdlg.hxx | 2 idl/source/objects/slot.cxx | 2 idl/source/objects/types.cxx | 9 include/avmedia/mediatoolbox.hxx | 2 include/item/base/ItemAdministrator.hxx | 30 - include/item/base/ItemBase.hxx | 30 + include/item/base/ItemBaseStaticHelper.hxx | 75 --- include/item/base/ItemControlBlock.hxx | 71 +++ include/item/base/ItemSet.hxx | 22 - include/item/base/ModelSpecificItemValues.hxx | 8 include/item/base/SlotSet.hxx | 13 include/item/simple/CntInt16.hxx | 20 - include/item/simple/CntOUString.hxx | 20 - include/sfx2/ctrlitem.hxx | 4 include/sfx2/msg.hxx | 18 include/sfx2/sfxstatuslistener.hxx | 2 include/sfx2/sidebar/ControllerItem.hxx | 2 include/sfx2/stbitem.hxx | 2 include/sfx2/tbxctrl.hxx | 2 include/sfx2/unoctitm.hxx | 2 include/svx/ParaSpacingControl.hxx | 4 include/svx/bmpmask.hxx | 2 include/svx/clipboardctl.hxx | 2 include/svx/fillctrl.hxx | 2 include/svx/float3d.hxx | 4 include/svx/fontwork.hxx | 2 include/svx/formatpaintbrushctrl.hxx | 2 include/svx/grafctrl.hxx | 4 include/svx/imapdlg.hxx | 2 include/svx/insctrl.hxx | 2 include/svx/layctrl.hxx | 4 include/svx/lboxctrl.hxx | 2 include/svx/linectrl.hxx | 4 include/svx/modctrl.hxx | 2 include/svx/pszctrl.hxx | 2 include/svx/selctrl.hxx | 2 include/svx/tbcontrl.hxx | 4 include/svx/tbxctl.hxx | 2 include/svx/verttexttbxctrl.hxx | 2 include/svx/xmlsecctrl.hxx | 2 include/svx/zoomctrl.hxx | 2 include/svx/zoomsliderctrl.hxx | 2 item/Library_item.mk | 1 item/source/base/ItemAdministrator.cxx | 54 +- item/source/base/ItemBase.cxx | 48 +- item/source/base/ItemControlBlock.cxx | 53 ++ item/source/base/ItemSet.cxx | 8 item/source/base/ModelSpecificItemValues.cxx | 14 item/source/base/SlotSet.cxx | 4 item/source/simple/CntInt16.cxx | 31 + item/source/simple/CntOUString.cxx | 29 + item/test/ItemTest.cxx | 377 ++++++++++++++++---- reportdesign/source/ui/misc/statusbarcontroller.cxx | 4 sc/inc/NumberFormatControl.hxx | 2 sc/source/ui/cctrl/tbzoomsliderctrl.cxx | 2 sc/source/ui/inc/navcitem.hxx | 2 sc/source/ui/inc/tbzoomsliderctrl.hxx | 2 sc/source/ui/navipi/navcitem.cxx | 2 sc/source/ui/sidebar/NumberFormatControl.cxx | 2 sd/source/ui/app/tmplctrl.cxx | 2 sd/source/ui/dlg/animobjs.cxx | 2 sd/source/ui/dlg/diactrl.cxx | 2 sd/source/ui/dlg/gluectrl.cxx | 2 sd/source/ui/dlg/navigatr.cxx | 4 sd/source/ui/inc/animobjs.hxx | 2 sd/source/ui/inc/diactrl.hxx | 2 sd/source/ui/inc/gluectrl.hxx | 2 sd/source/ui/inc/navigatr.hxx | 4 sd/source/ui/inc/tmplctrl.hxx | 2 sd/source/ui/view/sdruler.cxx | 4 sfx2/inc/inettbc.hxx | 2 sfx2/source/appl/appuno.cxx | 4 sfx2/source/control/bindings.cxx | 2 sfx2/source/control/ctrlitem.cxx | 4 sfx2/source/control/sfxstatuslistener.cxx | 4 sfx2/source/control/statcach.cxx | 10 sfx2/source/control/unoctitm.cxx | 4 sfx2/source/dialog/tplcitem.cxx | 2 sfx2/source/inc/tplcitem.hxx | 2 sfx2/source/inet/inettbc.cxx | 2 sfx2/source/sidebar/ControllerItem.cxx | 2 sfx2/source/statbar/stbitem.cxx | 4 sfx2/source/toolbox/tbxitem.cxx | 4 sfx2/source/view/viewfrm2.cxx | 2 starmath/inc/view.hxx | 4 starmath/source/view.cxx | 4 svx/source/dialog/_bmpmask.cxx | 2 svx/source/dialog/_contdlg.cxx | 2 svx/source/dialog/contimp.hxx | 2 svx/source/dialog/fontwork.cxx | 2 svx/source/dialog/imapdlg.cxx | 2 svx/source/dialog/rlrcitem.cxx | 2 svx/source/dialog/rlrcitem.hxx | 2 svx/source/dialog/srchctrl.cxx | 2 svx/source/dialog/srchctrl.hxx | 2 svx/source/engine3d/float3d.cxx | 4 svx/source/form/datanavi.cxx | 2 svx/source/form/filtnav.cxx | 2 svx/source/form/fmPropBrw.cxx | 2 svx/source/form/fmexpl.cxx | 2 svx/source/form/tabwin.cxx | 2 svx/source/form/tbxform.cxx | 4 svx/source/inc/datanavi.hxx | 2 svx/source/inc/filtnav.hxx | 2 svx/source/inc/fmPropBrw.hxx | 2 svx/source/inc/fmexpl.hxx | 2 svx/source/inc/tabwin.hxx | 2 svx/source/inc/tbxform.hxx | 4 svx/source/mnuctrls/clipboardctl.cxx | 2 svx/source/sidebar/paragraph/ParaSpacingControl.cxx | 4 svx/source/stbctrls/insctrl.cxx | 2 svx/source/stbctrls/modctrl.cxx | 2 svx/source/stbctrls/pszctrl.cxx | 2 svx/source/stbctrls/selctrl.cxx | 2 svx/source/stbctrls/xmlsecctrl.cxx | 2 svx/source/stbctrls/zoomctrl.cxx | 2 svx/source/stbctrls/zoomsliderctrl.cxx | 2 svx/source/tbxctrls/fillctrl.cxx | 2 svx/source/tbxctrls/formatpaintbrushctrl.cxx | 2 svx/source/tbxctrls/grafctrl.cxx | 4 svx/source/tbxctrls/layctrl.cxx | 4 svx/source/tbxctrls/lboxctrl.cxx | 2 svx/source/tbxctrls/linectrl.cxx | 4 svx/source/tbxctrls/tbcontrl.cxx | 8 svx/source/tbxctrls/tbxdrctl.cxx | 2 svx/source/tbxctrls/verttexttbxctrl.cxx | 2 sw/source/uibase/inc/bookctrl.hxx | 2 sw/source/uibase/inc/navipi.hxx | 2 sw/source/uibase/inc/tmplctrl.hxx | 2 sw/source/uibase/inc/viewlayoutctrl.hxx | 2 sw/source/uibase/inc/wordcountctrl.hxx | 2 sw/source/uibase/inc/workctrl.hxx | 4 sw/source/uibase/inc/zoomctrl.hxx | 2 sw/source/uibase/ribbar/workctrl.cxx | 4 sw/source/uibase/utlui/bookctrl.cxx | 2 sw/source/uibase/utlui/navipi.cxx | 2 sw/source/uibase/utlui/tmplctrl.cxx | 2 sw/source/uibase/utlui/viewlayoutctrl.cxx | 2 sw/source/uibase/utlui/wordcountctrl.cxx | 2 sw/source/uibase/utlui/zoomctrl.cxx | 2 147 files changed, 811 insertions(+), 500 deletions(-)
New commits: commit 6693a1c95420e952403cab6b6a1fe80b25bfe34f Author: Armin Le Grand <armin.le.gr...@me.com> AuthorDate: Tue Apr 9 17:19:10 2019 +0200 Commit: Armin Le Grand <armin.le.gr...@me.com> CommitDate: Tue Apr 9 17:19:10 2019 +0200 WIP: Huge restructuring to allow simple derivation Experimenting let me stumble over problems with the static methods involved when wanting to derive from an existing Item:: implementation. Both cases (1) derive and add local data (2) derive to get a new class/identifier had problems. Experimented and decided to take an approach closer to have a service-structure per derivation that e.g. allows re-usage of the Item- Administrator in case (2). Case (2) is important in potentially solving the ItemSet/SlotSet mix I currently have by allowing simple definition of Items derived from simple basic types (as e.g. CntOUString) to have a solution for Items that now have to go to Slots. Change-Id: Ibe1d8d967614e07de65bd81d59e36681e50687b6 diff --git a/avmedia/source/framework/mediatoolbox.cxx b/avmedia/source/framework/mediatoolbox.cxx index 0d5a421e65da..e43811f3e784 100644 --- a/avmedia/source/framework/mediatoolbox.cxx +++ b/avmedia/source/framework/mediatoolbox.cxx @@ -83,7 +83,7 @@ MediaToolBoxControl::~MediaToolBoxControl() } -void MediaToolBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& /*rSlotItem*/ ) +void MediaToolBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& /*rSlotItem*/ ) { MediaToolBoxControl_Impl* pCtrl = static_cast< MediaToolBoxControl_Impl* >( GetToolBox().GetItemWindow( GetId() ) ); diff --git a/basctl/source/basicide/IDEComboBox.cxx b/basctl/source/basicide/IDEComboBox.cxx index 1c420d3dd70d..a02584b61bd5 100644 --- a/basctl/source/basicide/IDEComboBox.cxx +++ b/basctl/source/basicide/IDEComboBox.cxx @@ -58,7 +58,7 @@ LibBoxControl::LibBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx) { } -void LibBoxControl::StateChanged(sal_uInt16, SfxItemState eState, const SfxPoolItem* pState, const ::Item::ItemBase::SharedPtr& /*rSlotItem*/) +void LibBoxControl::StateChanged(sal_uInt16, SfxItemState eState, const SfxPoolItem* pState, const ::std::shared_ptr<const ::Item::ItemBase>& /*rSlotItem*/) { LibBox* pBox = static_cast<LibBox*>(GetToolBox().GetItemWindow(GetId())); @@ -335,7 +335,7 @@ LanguageBoxControl::LanguageBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolB { } -void LanguageBoxControl::StateChanged(sal_uInt16, SfxItemState eState, const SfxPoolItem* pItem, const ::Item::ItemBase::SharedPtr& /*rSlotItem*/) +void LanguageBoxControl::StateChanged(sal_uInt16, SfxItemState eState, const SfxPoolItem* pItem, const ::std::shared_ptr<const ::Item::ItemBase>& /*rSlotItem*/) { if (LanguageBox* pBox = static_cast<LanguageBox*>(GetToolBox().GetItemWindow(GetId()))) { diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 32eb37cd05b2..ceb2d7991b08 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -573,7 +573,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) { DBG_ASSERT( rReq.GetArgs(), "arguments expected" ); // I2TM - const auto aSbxItem = rReq.GetArgs()->slotSet().GetSlot<const Item::Sbx>(SID_BASICIDE_ARG_SBX); + const auto aSbxItem = rReq.GetArgs()->slotSet().GetSlot<const basctl::Item::Sbx>(SID_BASICIDE_ARG_SBX); const ScriptDocument& aDocument( aSbxItem->GetDocument() ); const OUString& aLibName( aSbxItem->GetLibName() ); const OUString& aName( aSbxItem->GetName() ); diff --git a/basctl/source/basicide/sbxitem.cxx b/basctl/source/basicide/sbxitem.cxx index 2b20734357f6..bb5e518f72ce 100644 --- a/basctl/source/basicide/sbxitem.cxx +++ b/basctl/source/basicide/sbxitem.cxx @@ -19,21 +19,30 @@ #include <sbxitem.hxx> #include <sal/log.hxx> +#include <item/base/ItemAdministrator.hxx> namespace basctl { // I2TM namespace Item { - // need internal access to ItemAdministrator - ::Item::ItemAdministrator* Sbx::GetIAdministrator() const + ::Item::ItemControlBlock& Sbx::GetStaticItemControlBlock() { - return &GetStaticAdmin(); + static ::Item::ItemControlBlock aItemControlBlock( + std::shared_ptr<::Item::ItemAdministrator>(new ::Item::IAdministrator_vector()), + std::shared_ptr<const ::Item::ItemBase>(new Sbx()), + [](){ return new Sbx(); }); + + return aItemControlBlock; + } + + ::Item::ItemControlBlock& Sbx::GetItemControlBlock() const + { + return Sbx::GetStaticItemControlBlock(); } Sbx::Sbx(const ScriptDocument* pDocument, const OUString& aLibName, const OUString& aName, const OUString& aMethodName, ItemType eType) - : SbxStaticHelper(), - ::Item::ItemBase(), + : ::Item::ItemBase(), m_aDocument(nullptr != pDocument ? *pDocument : ScriptDocument::getApplicationScriptDocument()), m_aLibName(aLibName), m_aName(aName), @@ -47,9 +56,16 @@ namespace Item implInstanceCleanup(); } - std::shared_ptr<const Sbx> Sbx::Create(const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, const OUString& aMethodName, ItemType eType) + std::shared_ptr<const Sbx> Sbx::Create( + const ScriptDocument& rDocument, + const OUString& aLibName, + const OUString& aName, + const OUString& aMethodName, + ItemType eType) { - return std::static_pointer_cast<const Sbx>(GetStaticAdmin().Create(new Sbx(&rDocument, aLibName, aName, aMethodName, eType))); + return std::static_pointer_cast<const Sbx>( + Sbx::GetStaticItemControlBlock().GetItemAdministrator()->Create( + new Sbx(&rDocument, aLibName, aName, aMethodName, eType))); } bool Sbx::operator==(const ItemBase& rCandidate) const diff --git a/basctl/source/inc/IDEComboBox.hxx b/basctl/source/inc/IDEComboBox.hxx index 392df989ebd3..283fe4dff1c4 100644 --- a/basctl/source/inc/IDEComboBox.hxx +++ b/basctl/source/inc/IDEComboBox.hxx @@ -60,7 +60,7 @@ public: * @param pState -- */ virtual void StateChanged(sal_uInt16 nSlotID, SfxItemState eState, - const SfxPoolItem* pState, const ::Item::ItemBase::SharedPtr& rSlotItem) override; + const SfxPoolItem* pState, const ::std::shared_ptr<const ::Item::ItemBase>& rSlotItem) override; /*! * Create combobox of Macro and Dialog Library * @@ -189,7 +189,7 @@ public: * @param pState -- */ virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const ::Item::ItemBase::SharedPtr& rSlotItem) override; + const SfxPoolItem* pState, const ::std::shared_ptr<const ::Item::ItemBase>& rSlotItem) override; /*! * Create ComboBox of Language * diff --git a/basctl/source/inc/sbxitem.hxx b/basctl/source/inc/sbxitem.hxx index 89ee646a35ae..fe6cc705b83d 100644 --- a/basctl/source/inc/sbxitem.hxx +++ b/basctl/source/inc/sbxitem.hxx @@ -23,7 +23,8 @@ #include <svl/poolitem.hxx> // I2TM -#include <item/base/ItemBaseStaticHelper.hxx> +#include <item/base/ItemBase.hxx> +//#include <item/base/ItemBaseStaticHelper.hxx> // ~I2TM namespace basctl @@ -42,19 +43,11 @@ enum ItemType // I2TM namespace Item { - class Sbx; - typedef ::Item::ItemBaseStaticHelper<Sbx, ::Item::IAdministrator_vector> SbxStaticHelper; - - class Sbx final : public SbxStaticHelper, public ::Item::ItemBase + class Sbx final : public ::Item::ItemBase { public: - // SharedPtr typedef to be used handling instances of given type - typedef std::shared_ptr<const Sbx> SharedPtr; - - private: - // need to offer internal access to ItemAdministrator - // in each derivation - just calls GetStaticAdmin internally - virtual ::Item::ItemAdministrator* GetIAdministrator() const override; + static ::Item::ItemControlBlock& GetStaticItemControlBlock(); + virtual ::Item::ItemControlBlock& GetItemControlBlock() const override; private: const ScriptDocument m_aDocument; @@ -64,8 +57,6 @@ namespace Item ItemType m_eType; protected: - friend SbxStaticHelper; - Sbx( const ScriptDocument* pDocument = nullptr, const OUString& aLibName = OUString(), diff --git a/cui/source/dialogs/cuihyperdlg.cxx b/cui/source/dialogs/cuihyperdlg.cxx index 331abdc2aed9..84b25bf20fb7 100644 --- a/cui/source/dialogs/cuihyperdlg.cxx +++ b/cui/source/dialogs/cuihyperdlg.cxx @@ -57,7 +57,7 @@ void SvxHlinkCtrl::dispose() } void SvxHlinkCtrl::StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& /*rSlotItem*/ ) + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& /*rSlotItem*/ ) { if ( eState == SfxItemState::DEFAULT && !pParent->IsDisposed() ) { diff --git a/cui/source/inc/cuihyperdlg.hxx b/cui/source/inc/cuihyperdlg.hxx index fb3ec9aad6e3..48a8894fcb40 100644 --- a/cui/source/inc/cuihyperdlg.hxx +++ b/cui/source/inc/cuihyperdlg.hxx @@ -61,7 +61,7 @@ public: virtual void dispose() override; virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; }; diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx index e15d4ef19a53..d1885dda923b 100644 --- a/idl/source/objects/slot.cxx +++ b/idl/source/objects/slot.cxx @@ -614,10 +614,10 @@ sal_uInt16 SvMetaSlot::WriteSlotParamArray( SvIdlDataBase & rBase, SvStream & rO SvMetaAttribute * pPar = rList[n]; SvMetaType * pPType = pPar->GetType(); WriteTab( rOutStm, 1 ); + // I2TM use simple self-demangling for VarName to support nakmespaces const OString aDemangledVarName(pPType->GetName().replaceAll("::", "_")); rOutStm.WriteCharPtr("{ (const SfxType*) &a") // item type -// .WriteOString(pPType->GetName()).WriteCharPtr("_Impl, ") .WriteOString(aDemangledVarName).WriteCharPtr("_Impl, ") // parameter name .WriteCharPtr("\"").WriteOString(pPar->GetName()).WriteCharPtr("\", ") diff --git a/idl/source/objects/types.cxx b/idl/source/objects/types.cxx index 2c214ff2f881..e3338ba01537 100644 --- a/idl/source/objects/types.cxx +++ b/idl/source/objects/types.cxx @@ -221,7 +221,7 @@ void SvMetaType::WriteSfxItem( const OString& rItemName, SvIdlDataBase const & rBase, SvStream& rOutStm ) { WriteStars( rOutStm ); -// OString aVarName = " a" + rItemName + "_Impl"; + // I2TM use simple self-demangling for VarName to support nakmespaces const OString aDemangledVarName(" a" + rItemName.replaceAll("::", "_") + "_Impl"); OStringBuffer aAttrArray; @@ -246,7 +246,6 @@ void SvMetaType::WriteSfxItem( if (bExport) rOutStm.WriteCharPtr( "SFX2_DLLPUBLIC " ); rOutStm.WriteOString( aTypeName ) -// .WriteOString( aVarName ).WriteChar( ';' ) << endl; .WriteOString( aDemangledVarName ).WriteChar( ';' ) << endl; if (bReturn) return; @@ -256,11 +255,11 @@ void SvMetaType::WriteSfxItem( rOutStm.WriteCharPtr( "#if !defined(_WIN32) && ((defined(DISABLE_DYNLOADING) && (defined(ANDROID) || defined(IOS) || defined(LINUX))) || STATIC_LINKING)" ) << endl; rOutStm.WriteCharPtr( "__attribute__((__weak__))" ) << endl; rOutStm.WriteCharPtr( "#endif" ) << endl; -// rOutStm.WriteOString( aTypeName ).WriteOString( aVarName ) rOutStm.WriteOString( aTypeName ).WriteOString( aDemangledVarName ) .WriteCharPtr( " = " ) << endl; rOutStm.WriteChar( '{' ) << endl; + // I2TM bIsSlotItem is temorary - when change would be completely done, may be remoevd const bool bIsSlotItem(rItemName.indexOf("Item::") >= 0); if(bIsSlotItem) { @@ -276,10 +275,6 @@ void SvMetaType::WriteSfxItem( rOutStm.WriteCharPtr("&typeid(").WriteOString( rItemName ).WriteCharPtr( "), " ); rOutStm.WriteOString( aAttrCount ); - // rOutStm.WriteCharPtr( "\tcreateSfxPoolItem<" ).WriteOString( rItemName ) - // .WriteCharPtr(">, &typeid(").WriteOString( rItemName ).WriteCharPtr( "), " ); - // rOutStm.WriteOString( aAttrCount ); - if( nAttrCount ) { rOutStm.WriteCharPtr( ", { " ); diff --git a/include/avmedia/mediatoolbox.hxx b/include/avmedia/mediatoolbox.hxx index 751d5d50c1be..56b9321c9a06 100644 --- a/include/avmedia/mediatoolbox.hxx +++ b/include/avmedia/mediatoolbox.hxx @@ -40,7 +40,7 @@ public: MediaToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbX ); virtual ~MediaToolBoxControl() override; - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window* pParent ) override; private: diff --git a/include/item/base/ItemAdministrator.hxx b/include/item/base/ItemAdministrator.hxx index 81e90a45b308..e3e14aea126a 100644 --- a/include/item/base/ItemAdministrator.hxx +++ b/include/item/base/ItemAdministrator.hxx @@ -24,12 +24,15 @@ #include <set> #include <unordered_set> #include <cassert> -#include <item/base/ItemBase.hxx> +//#include <item/base/ItemBase.hxx> /////////////////////////////////////////////////////////////////////////////// namespace Item { + // predefine ItemAdministrator and ItemBase - no need to include + class ItemBase; + // Base class for ItemAdministrator. It's Task is to administer instances // of ItemBase - Items. Target is to always have only one instance // of a typed Item in one attributation, e.g. for sal_uInt16 many @@ -64,13 +67,9 @@ namespace Item // for ModelSpecificItemValues need to be overriden. class ITEM_DLLPUBLIC ItemAdministrator { - protected: - // instance of global default value - ItemBase::SharedPtr m_aDefault; - public: // constructor/destructor - ItemAdministrator(const ItemBase* pDefault); + ItemAdministrator(); virtual ~ItemAdministrator(); // noncopyable @@ -82,12 +81,7 @@ namespace Item // will check existance/default and either re-use existing // instance (and delete given one) or start using given instance virtual void HintExpired(const ItemBase* pIBase); - virtual ItemBase::SharedPtr Create(const ItemBase* pIBase) = 0; - - // interface for global default value support - // on Administrator level - const ItemBase::SharedPtr& GetDefault() const; - bool IsDefault(const ItemBase* pIBase) const; + virtual std::shared_ptr<const ItemBase> Create(const ItemBase* pIBase) = 0; }; } // end of namespace Item @@ -117,9 +111,9 @@ namespace Item std::set<const ItemBase*, less_for_set> m_aEntries; public: - IAdministrator_set(const ItemBase* pDefault); + IAdministrator_set(); - virtual ItemBase::SharedPtr Create(const ItemBase* pIBase) override; + virtual std::shared_ptr<const ItemBase> Create(const ItemBase* pIBase) override; virtual void HintExpired(const ItemBase* pIBase) override; }; } // end of namespace Item @@ -160,9 +154,9 @@ namespace Item std::unordered_set<const ItemBase*, hash_for_unordered_set, compare_for_unordered_set> m_aEntries; public: - IAdministrator_unordered_set(const ItemBase* pDefault); + IAdministrator_unordered_set(); - virtual ItemBase::SharedPtr Create(const ItemBase* pIBase) override; + virtual std::shared_ptr<const ItemBase> Create(const ItemBase* pIBase) override; virtual void HintExpired(const ItemBase* pIBase) override; }; } // end of namespace Item @@ -196,9 +190,9 @@ namespace Item void erase(std::vector<const ItemBase*>::iterator& rIter); public: - IAdministrator_vector(const ItemBase* pDefault); + IAdministrator_vector(); - virtual ItemBase::SharedPtr Create(const ItemBase* pIBase) override; + virtual std::shared_ptr<const ItemBase> Create(const ItemBase* pIBase) override; virtual void HintExpired(const ItemBase* pIBase) override; }; } // end of namespace Item diff --git a/include/item/base/ItemBase.hxx b/include/item/base/ItemBase.hxx index d06f766a4212..6af2858e8d0a 100644 --- a/include/item/base/ItemBase.hxx +++ b/include/item/base/ItemBase.hxx @@ -32,6 +32,7 @@ namespace Item { // predefine ItemAdministrator - no need to include class ItemAdministrator; + class ItemControlBlock; // Base class for ItemBase and thus for all new implementation of // Items. Items are in general read-only instances. The constructor @@ -91,9 +92,6 @@ namespace Item class ITEM_DLLPUBLIC ItemBase : public std::enable_shared_from_this<ItemBase> { public: - // SharedPtr typedef to be used handling instances of this type - typedef std::shared_ptr<const ItemBase> SharedPtr; - // typedefs for PutValues/PutValue/CreateFromAny functionality // used from the SfxSlot mechanism (see CreateSlotItem) typedef std::pair<const css::uno::Any, sal_uInt8> AnyIDPair; @@ -114,6 +112,10 @@ namespace Item // but limited to a single local method in the implementation there friend void SetAdministratedFromItemAdministrator(ItemBase& rIBase); + public: + static ItemControlBlock& GetStaticItemControlBlock(); + virtual ItemControlBlock& GetItemControlBlock() const; + protected: // constructor - protected BY DEFAULT - do NOT CHANGE (!) // Use ::Create(...) methods in derived classes instead @@ -125,13 +127,9 @@ namespace Item // basic RTTI TypeCheck to secure e.g. operator== and similar bool CheckSameType(const ItemBase& rCmp) const; - // basic access to Adminiatrator, default returns nullptr and is *not* - // designed to be used/called, only exists to have simple Item - // representations for special purposes, e.g. InvalidateItem/DisableItem - virtual ItemAdministrator* GetIAdministrator() const; - // PutValue/Any interface for automated instance creation from SfxType // mechanism (UNO API and sfx2 stuff) + friend class ItemControlBlock; void PutValues(const AnyIDArgs& rArgs); virtual void PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId); @@ -152,7 +150,7 @@ namespace Item // Interface for global default value support. These non-static and // non-virtual non-typed local versions can/may work more direct. The - // typed static versions are not capable of working with 'const ItemBase::SharedPtr&' + // typed static versions are not capable of working with 'const std::shared_ptr<const ItemBase>&' // due to using std::static_pointer_cast, thus these may be faster and // use less ressources when the type is not needed. // These will use the callback to static administrator and it's administrated @@ -160,13 +158,20 @@ namespace Item // Remember that there *will* also be static, typed versions of this call // in derived Item(s), see ItemBaseStaticHelper for reference bool IsDefault() const; - const SharedPtr& GetDefault() const; + const std::shared_ptr<const ItemBase>& GetDefault() const; // check Administrated flag bool IsAdministrated() const { return m_bAdministrated; } + + static bool IsDefault(const std::shared_ptr<const ItemBase>& rCandidate); + + template<class T> static std::shared_ptr<const T> GetDefault() + { + return std::static_pointer_cast<const T>(T::GetStaticItemControlBlock().GetDefaultItem()); + } }; } // end of namespace Item diff --git a/include/item/base/ItemBaseStaticHelper.hxx b/include/item/base/ItemBaseStaticHelper.hxx deleted file mode 100644 index 29c228059836..000000000000 --- a/include/item/base/ItemBaseStaticHelper.hxx +++ /dev/null @@ -1,75 +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_ITEM_BASE_ITEMBASESTATICHELPER_HXX -#define INCLUDED_ITEM_BASE_ITEMBASESTATICHELPER_HXX - -#include <item/base/ItemBase.hxx> -#include <item/base/ItemAdministrator.hxx> - -/////////////////////////////////////////////////////////////////////////////// - -namespace Item -{ - // Template class which supports Item implementations using ItemBase. - // It allows automatic creation of default static methods. - // It provides implementation of all static typed stuff needed to - // implement and make available the single global static ItemAdministrator - // which will be used for the implementation of that new Item-type. - // Usually one of three predefined/preimplemented IAdministrators - // will be used, for details see ItemAdministrator.hxx and - // - IAdministrator_set - // - IAdministrator_unordered_set - // - IAdministrator_vector - // and the explanations/preconditions for their usage. - template< class TargetType, typename AdminType > class ItemBaseStaticHelper //: public ItemBase - { - protected: - static ItemAdministrator& GetStaticAdmin() - { - static AdminType aAdmin(new TargetType()); - return aAdmin; - } - - public: - static std::shared_ptr<const TargetType> GetStaticDefault() - { - return std::static_pointer_cast<const TargetType>(GetStaticAdmin().GetDefault()); - } - - static bool IsStaticDefault(const std::shared_ptr<const TargetType>& rCandidate) - { - return rCandidate && GetStaticAdmin().IsDefault(rCandidate.get()); - } - - // SharedPtr-constructor - static std::shared_ptr<const TargetType> CreateFromAny(const ItemBase::AnyIDArgs& rArgs) - { - TargetType* pNewInstance(new TargetType()); - pNewInstance->PutValues(rArgs); - return std::shared_ptr<const TargetType>(pNewInstance); - } - }; -} // end of namespace Item - -/////////////////////////////////////////////////////////////////////////////// - -#endif // INCLUDED_ITEM_BASE_ITEMBASESTATICHELPER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/item/base/ItemControlBlock.hxx b/include/item/base/ItemControlBlock.hxx new file mode 100755 index 000000000000..cfa2e62583fc --- /dev/null +++ b/include/item/base/ItemControlBlock.hxx @@ -0,0 +1,71 @@ +/* -*- 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_ITEM_BASE_ITEMCONTROLBLOCK_HXX +#define INCLUDED_ITEM_BASE_ITEMCONTROLBLOCK_HXX + +#include <functional> + +/////////////////////////////////////////////////////////////////////////////// + +namespace Item +{ + // predefine ItemAdministrator and ItemBase - no need to include + class ItemAdministrator; + class ItemBase; + + class ITEM_DLLPUBLIC ItemControlBlock + { + private: + std::shared_ptr<ItemAdministrator> m_aItemAdministrator; + const std::shared_ptr<const ItemBase> m_aDefaultItem; + std::function<ItemBase*()> m_aConstructItem; + + public: + ItemControlBlock( + const std::shared_ptr<ItemAdministrator>& rItemAdministrator, + const std::shared_ptr<const ItemBase>& rDefaultItem, + std::function<ItemBase*()>constructItem); + ItemControlBlock(); + + const std::shared_ptr<ItemAdministrator>& GetItemAdministrator() + { + return m_aItemAdministrator; + } + + const std::shared_ptr<const ItemBase>& GetDefaultItem() const + { + return m_aDefaultItem; + } + + ItemBase* ConstructItem() const + { + return m_aConstructItem(); + } + + std::shared_ptr<const ItemBase> CreateFromAny(const ItemBase::AnyIDArgs& rArgs); + bool IsDefaultDDD(const ItemBase& rItem) const; + }; +} // end of namespace Item + +/////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_ITEM_BASE_ITEMCONTROLBLOCK_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/item/base/ItemSet.hxx b/include/item/base/ItemSet.hxx index 7be0092f5ddf..3f1cab7ed137 100644 --- a/include/item/base/ItemSet.hxx +++ b/include/item/base/ItemSet.hxx @@ -235,20 +235,20 @@ namespace Item ModelSpecificItemValues::SharedPtr m_aModelSpecificIValues; // the items as content - std::unordered_map<size_t, ItemBase::SharedPtr> m_aItems; + std::unordered_map<size_t, std::shared_ptr<const ItemBase>> m_aItems; // single global static instance for helper class ImplInvalidateItem - static const ItemBase::SharedPtr& getInvalidateItem() + static const std::shared_ptr<const ItemBase>& getInvalidateItem() { - static ItemBase::SharedPtr aImplInvalidateItem(new ImplInvalidateItem()); + static std::shared_ptr<const ItemBase> aImplInvalidateItem(new ImplInvalidateItem()); return aImplInvalidateItem; } // single global static instance for helper class ImplDisableItem - static const ItemBase::SharedPtr& getDisableItem() + static const std::shared_ptr<const ItemBase>& getDisableItem() { - static ItemBase::SharedPtr aImplDisableItem(new ImplDisableItem()); + static std::shared_ptr<const ItemBase> aImplDisableItem(new ImplDisableItem()); return aImplDisableItem; } @@ -288,11 +288,11 @@ namespace Item m_aItems[hash_code] = getDisableItem(); } - template< typename TItem > std::shared_ptr<TItem> GetDefault() const + template< typename TItem > std::shared_ptr<const TItem> GetDefault() const { // get static available default as instance - ItemBase::SharedPtr aRetval(TItem::GetStaticDefault()); - assert(aRetval && "empty ItemBase::SharedPtr not allowed for default (!)"); + std::shared_ptr<const ItemBase> aRetval(TItem::GetStaticItemControlBlock().GetDefaultItem()); + assert(aRetval && "empty std::shared_ptr<const ItemBase> not allowed for default (!)"); if(m_aModelSpecificIValues) { @@ -301,10 +301,10 @@ namespace Item aRetval = m_aModelSpecificIValues->GetDefault(aRetval); } - return std::static_pointer_cast<TItem>(aRetval); + return std::static_pointer_cast<const TItem>(aRetval); } - void SetItem(const ItemBase::SharedPtr& rItem); + void SetItem(const std::shared_ptr<const ItemBase>& rItem); template< typename TItem > StateAndItem<TItem> GetStateAndItem(bool bSearchParent = true) const { @@ -313,7 +313,7 @@ namespace Item if(aRetval != m_aItems.end()) // && aRetval->second) { - assert(aRetval->second && "empty ItemBase::SharedPtr set in ItemSet (!)"); + assert(aRetval->second && "empty std::shared_ptr<const ItemBase> set in ItemSet (!)"); if(aRetval->second.get() == getInvalidateItem().get()) { diff --git a/include/item/base/ModelSpecificItemValues.hxx b/include/item/base/ModelSpecificItemValues.hxx index 830145f9ab92..e8e9289686d1 100644 --- a/include/item/base/ModelSpecificItemValues.hxx +++ b/include/item/base/ModelSpecificItemValues.hxx @@ -45,7 +45,7 @@ namespace Item private: // the alternative default items - std::unordered_map<size_t, ItemBase::SharedPtr> m_aAlternativeItems; + std::unordered_map<size_t, std::shared_ptr<const ItemBase>> m_aAlternativeItems; protected: // constructor - protected BY DEFAULT - do NOT CHANGE (!) @@ -63,9 +63,9 @@ namespace Item static SharedPtr Create(); // AlternativeDefault interface - void SetAlternativeDefaultItem(const ItemBase::SharedPtr& rItem); - bool IsDefault(const ItemBase::SharedPtr& rItem) const; - const ItemBase::SharedPtr& GetDefault(const ItemBase::SharedPtr& rItem) const; + void SetAlternativeDefaultItem(const std::shared_ptr<const ItemBase>& rItem); + bool IsDefault(const std::shared_ptr<const ItemBase>& rItem) const; + const std::shared_ptr<const ItemBase>& GetDefault(const std::shared_ptr<const ItemBase>& rItem) const; }; } // end of namespace Item diff --git a/include/item/base/SlotSet.hxx b/include/item/base/SlotSet.hxx index 73c9fe053298..491354463fa7 100755 --- a/include/item/base/SlotSet.hxx +++ b/include/item/base/SlotSet.hxx @@ -22,6 +22,7 @@ #include <cassert> #include <item/base/ModelSpecificItemValues.hxx> +#include <item/base/ItemControlBlock.hxx> /////////////////////////////////////////////////////////////////////////////// @@ -36,7 +37,7 @@ namespace Item private: // the slots as content - std::unordered_map<SlotID, ItemBase::SharedPtr> m_aSlots; + std::unordered_map<SlotID, std::shared_ptr<const ItemBase>> m_aSlots; protected: // constructor - protected BY DEFAULT - do NOT CHANGE (!) @@ -58,22 +59,22 @@ namespace Item // SharedPtr-construtcor static SharedPtr Create(); - void SetSlot(SlotID aSlotID, const ItemBase::SharedPtr& rItem); + void SetSlot(SlotID aSlotID, const std::shared_ptr<const ItemBase>& rItem); void SetSlots(const SlotSet& rSlotSet); - template< typename TargetType > std::shared_ptr<const TargetType> GetSlot(SlotID aSlotID) const + template< typename TargetType > const std::shared_ptr<const TargetType> GetSlot(SlotID aSlotID) const { const auto aRetval(m_aSlots.find(aSlotID)); if(aRetval != m_aSlots.end()) // && aRetval->second) { - assert(aRetval->second && "empty ItemBase::SharedPtr set in SlotSet (!)"); - assert(typeid(*aRetval->second) == typeid(TargetType) && "wrong ItemBase::SharedPtr type in SlotSet (!)"); + assert(aRetval->second && "empty std::shared_ptr<const ItemBase> set in SlotSet (!)"); + assert(typeid(*aRetval->second) == typeid(TargetType) && "wrong std::shared_ptr<const ItemBase> type in SlotSet (!)"); return std::static_pointer_cast<TargetType>(aRetval->second); } - return TargetType::GetStaticDefault(); + return std::static_pointer_cast<const TargetType>(TargetType::GetStaticItemControlBlock().GetDefaultItem()); } bool ClearSlot(SlotID aSlotID); diff --git a/include/item/simple/CntInt16.hxx b/include/item/simple/CntInt16.hxx index a0d52940d9a4..677221f359d0 100644 --- a/include/item/simple/CntInt16.hxx +++ b/include/item/simple/CntInt16.hxx @@ -10,7 +10,7 @@ #ifndef INCLUDED_ITEM_SIMPLE_CNTINT16_HXX #define INCLUDED_ITEM_SIMPLE_CNTINT16_HXX -#include <item/base/ItemBaseStaticHelper.hxx> +#include <item/base/ItemBase.hxx> /////////////////////////////////////////////////////////////////////////////// @@ -20,35 +20,25 @@ namespace Item // It uses IAdministrator_set to provide an Administrator using // a sorted list for fast accesses. This requires ::operator< to be // implemented. - class CntInt16; - typedef ItemBaseStaticHelper<CntInt16, IAdministrator_set> CntInt16StaticHelper; - class ITEM_DLLPUBLIC CntInt16 : public CntInt16StaticHelper, public ItemBase + class ITEM_DLLPUBLIC CntInt16 : public ItemBase { public: - // SharedPtr typedef to be used handling instances of given type - typedef std::shared_ptr<const CntInt16> SharedPtr; - - private: - // need to offer internal access to ItemAdministrator - // in each derivation - just calls GetStaticAdmin internally - virtual ItemAdministrator* GetIAdministrator() const override; + static ItemControlBlock& GetStaticItemControlBlock(); + virtual ItemControlBlock& GetItemControlBlock() const override; private: // local variavbles sal_Int16 m_nValue; protected: - // allow local ItemAdministrator access to protected constructor - friend CntInt16StaticHelper; - // SharedPtr-constructor - protected BY DEFAULT - do NOT CHANGE (!) CntInt16(sal_Int16 nValue = 0); public: virtual ~CntInt16(); - static CntInt16::SharedPtr Create(sal_Int16 nValue); + static std::shared_ptr<const CntInt16> Create(sal_Int16 nValue); virtual bool operator==(const ItemBase& rCandidate) const override; virtual bool operator<(const ItemBase& rCandidate) const override; sal_Int16 GetValue() const; diff --git a/include/item/simple/CntOUString.hxx b/include/item/simple/CntOUString.hxx index 4f52ec33942e..1d5b085f7351 100644 --- a/include/item/simple/CntOUString.hxx +++ b/include/item/simple/CntOUString.hxx @@ -10,7 +10,8 @@ #ifndef INCLUDED_ITEM_SIMPLE_CNTOUSTRING_HXX #define INCLUDED_ITEM_SIMPLE_CNTOUSTRING_HXX -#include <item/base/ItemBaseStaticHelper.hxx> +//#include <item/base/ItemBaseStaticHelper.hxx> +#include <item/base/ItemBase.hxx> #include <rtl/ustring.hxx> /////////////////////////////////////////////////////////////////////////////// @@ -21,28 +22,17 @@ namespace Item // It uses IAdministrator_unordered_set to provide an Administrator using // a hashed list for fast accesses. This requires ::operator== and // ::GetUniqueKey() to be implemented. - class CntOUString; - typedef ItemBaseStaticHelper<CntOUString, IAdministrator_unordered_set> CntOUStringStaticHelper; - - class ITEM_DLLPUBLIC CntOUString : public CntOUStringStaticHelper, public ItemBase + class ITEM_DLLPUBLIC CntOUString : public ItemBase { public: - // SharedPtr typedef to be used handling instances of given type - typedef std::shared_ptr<const CntOUString> SharedPtr; - - private: - // need to offer internal access to ItemAdministrator - // in each derivation - just calls GetStaticAdmin internally - virtual ItemAdministrator* GetIAdministrator() const override; + static ItemControlBlock& GetStaticItemControlBlock(); + virtual ItemControlBlock& GetItemControlBlock() const override; private: // local variavbles rtl::OUString m_aValue; protected: - // allow local ItemAdministrator access to protected constructor - friend CntOUStringStaticHelper; - // SharedPtr-constructor - protected BY DEFAULT - do NOT CHANGE (!) CntOUString(const rtl::OUString& rValue = rtl::OUString()); diff --git a/include/sfx2/ctrlitem.hxx b/include/sfx2/ctrlitem.hxx index 2cea8cd1e85c..0a6d6fdb27d9 100644 --- a/include/sfx2/ctrlitem.hxx +++ b/include/sfx2/ctrlitem.hxx @@ -63,7 +63,7 @@ public: sal_uInt16 GetId() const { return nId; } virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ); + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ); MapUnit GetCoreMetric() const; @@ -79,7 +79,7 @@ class SFX2_DLLPUBLIC SfxStatusForwarder: public SfxControllerItem protected: virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; public: SfxStatusForwarder( sal_uInt16 nSlotId, diff --git a/include/sfx2/msg.hxx b/include/sfx2/msg.hxx index 849634b3b32a..53a97814b15b 100644 --- a/include/sfx2/msg.hxx +++ b/include/sfx2/msg.hxx @@ -101,14 +101,18 @@ template<class T> SfxPoolItem* createSfxPoolItem() { return T::CreateDefault(); } +// I2TM version for ::Item stuff - if all would be changed, version above may be deleted template<class T> std::shared_ptr<const T> createSlotItem(const Item::ItemBase::AnyIDArgs& rArgs) { - return T::CreateFromAny(rArgs); + // I2TM was 'return T::CreateFromAny(rArgs);' but no real need to have a + // static Item::CreateFromAny templated version + return std::static_pointer_cast<const T>(T::GetStaticItemControlBlock().CreateFromAny(rArgs)); } struct SfxType { std::function<SfxPoolItem* ()> const createSfxPoolItemFunc; - std::function<Item::ItemBase::SharedPtr(const Item::ItemBase::AnyIDArgs& rArgs)> const createSlotItemFunc; + // I2TM extended to five members due to need of new creator method + std::function<std::shared_ptr<const Item::ItemBase>(const Item::ItemBase::AnyIDArgs& rArgs)> const createSlotItemFunc; const std::type_info* pType; sal_uInt16 const nAttribs; SfxTypeAttrib aAttrib[1]; // variable length @@ -123,11 +127,13 @@ struct SfxType return std::unique_ptr<SfxPoolItem>(createSfxPoolItemFunc()); } - Item::ItemBase::SharedPtr CreateSlotItem(const Item::ItemBase::AnyIDArgs& rArgs) const + // I2TM + std::shared_ptr<const Item::ItemBase> CreateSlotItem(const Item::ItemBase::AnyIDArgs& rArgs) const { return createSlotItemFunc(rArgs); } + // I2TM temporary bool isSlotItem() const { return nullptr != createSlotItemFunc; @@ -137,7 +143,7 @@ struct SfxType struct SfxType0 { std::function<SfxPoolItem* ()> const createSfxPoolItemFunc; - std::function<Item::ItemBase::SharedPtr(const Item::ItemBase::AnyIDArgs& rArgs)> const createSlotItemFunc; + std::function<std::shared_ptr<const Item::ItemBase>(const Item::ItemBase::AnyIDArgs& rArgs)> const createSlotItemFunc; const std::type_info* pType; sal_uInt16 const nAttribs; @@ -149,7 +155,7 @@ struct SfxType0 #define SFX_DECL_TYPE(n) struct SfxType##n \ { \ std::function<SfxPoolItem* ()> createSfxPoolItemFunc; \ - std::function<Item::ItemBase::SharedPtr(const Item::ItemBase::AnyIDArgs& rArgs)> const createSlotItemFunc; \ + std::function<std::shared_ptr<const Item::ItemBase>(const Item::ItemBase::AnyIDArgs& rArgs)> const createSlotItemFunc; \ const std::type_info* pType; \ sal_uInt16 nAttribs; \ SfxTypeAttrib aAttrib[n]; \ @@ -208,7 +214,7 @@ struct SfxFormalArgument return pType->CreateSfxPoolItem(); } - Item::ItemBase::SharedPtr CreateSlotItem(const Item::ItemBase::AnyIDArgs& rArgs) const + std::shared_ptr<const Item::ItemBase> CreateSlotItem(const Item::ItemBase::AnyIDArgs& rArgs) const { return pType->CreateSlotItem(rArgs); } diff --git a/include/sfx2/sfxstatuslistener.hxx b/include/sfx2/sfxstatuslistener.hxx index 3b3ec33c8153..44dba1f18db8 100644 --- a/include/sfx2/sfxstatuslistener.hxx +++ b/include/sfx2/sfxstatuslistener.hxx @@ -47,7 +47,7 @@ class SFX2_DLLPUBLIC SfxStatusListener : public cppu::WeakImplHelper< void UnBind(); void ReBind(); - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ); + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ); // XComponent virtual void SAL_CALL dispose() override; diff --git a/include/sfx2/sidebar/ControllerItem.hxx b/include/sfx2/sidebar/ControllerItem.hxx index c2372899447f..0f071a5145c6 100644 --- a/include/sfx2/sidebar/ControllerItem.hxx +++ b/include/sfx2/sidebar/ControllerItem.hxx @@ -76,7 +76,7 @@ public: protected: - virtual void StateChanged (sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem) override; + virtual void StateChanged (sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem) override; private: ItemUpdateReceiverInterface& mrItemUpdateReceiver; diff --git a/include/sfx2/stbitem.hxx b/include/sfx2/stbitem.hxx index ee429970375e..076f7b44a845 100644 --- a/include/sfx2/stbitem.hxx +++ b/include/sfx2/stbitem.hxx @@ -94,7 +94,7 @@ protected: // Old sfx2 interface virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ); + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ); virtual void Click(); virtual void Command( const CommandEvent& rCEvt ); virtual bool MouseButtonDown( const MouseEvent & ); diff --git a/include/sfx2/tbxctrl.hxx b/include/sfx2/tbxctrl.hxx index 7ccac5d3272f..78f4add866dd 100644 --- a/include/sfx2/tbxctrl.hxx +++ b/include/sfx2/tbxctrl.hxx @@ -137,7 +137,7 @@ protected: DECL_LINK( ClosePopupWindow, SfxPopupWindow *, void ); // old SfxToolBoxControl methods - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ); + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ); virtual void Select( sal_uInt16 nSelectModifier ); virtual void DoubleClick(); diff --git a/include/sfx2/unoctitm.hxx b/include/sfx2/unoctitm.hxx index df2dcd29e33e..4766387118d1 100644 --- a/include/sfx2/unoctitm.hxx +++ b/include/sfx2/unoctitm.hxx @@ -130,7 +130,7 @@ public: static OUString getSlaveCommand( const css::util::URL& rURL ); void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, SfxSlotServer const * pServ ); - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; void setMasterSlaveCommand( bool bSet ); /// @throws css::uno::RuntimeException void dispatch( const css::util::URL& aURL, diff --git a/include/svx/ParaSpacingControl.hxx b/include/svx/ParaSpacingControl.hxx index 3ff213936290..67feabc8269e 100644 --- a/include/svx/ParaSpacingControl.hxx +++ b/include/svx/ParaSpacingControl.hxx @@ -37,7 +37,7 @@ public: virtual ~ParaULSpacingControl() override; virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem) override; virtual VclPtr<vcl::Window> CreateItemWindow(vcl::Window* pParent) override = 0; }; @@ -71,7 +71,7 @@ public: virtual void SAL_CALL dispose() override; virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem) override; virtual VclPtr<vcl::Window> CreateItemWindow(vcl::Window* pParent) override = 0; // XContextChangeEventListener diff --git a/include/svx/bmpmask.hxx b/include/svx/bmpmask.hxx index 53cd4ba6fe6b..3e6c35a4150e 100644 --- a/include/svx/bmpmask.hxx +++ b/include/svx/bmpmask.hxx @@ -59,7 +59,7 @@ private: protected: virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; public: SvxBmpMaskSelectItem( SvxBmpMask& rMask, diff --git a/include/svx/clipboardctl.hxx b/include/svx/clipboardctl.hxx index 4e4bd075a1a3..6a84eb14910f 100644 --- a/include/svx/clipboardctl.hxx +++ b/include/svx/clipboardctl.hxx @@ -49,7 +49,7 @@ public: virtual VclPtr<SfxPopupWindow> CreatePopupWindow() override; virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; }; #endif diff --git a/include/svx/fillctrl.hxx b/include/svx/fillctrl.hxx index 55d5d87e6f0e..42de248b99f8 100644 --- a/include/svx/fillctrl.hxx +++ b/include/svx/fillctrl.hxx @@ -70,7 +70,7 @@ public: SvxFillToolBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx); virtual ~SvxFillToolBoxControl() override; - virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem) override; + virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem) override; void Update(); virtual VclPtr<vcl::Window> CreateItemWindow(vcl::Window* pParent) override; }; diff --git a/include/svx/float3d.hxx b/include/svx/float3d.hxx index 5b0698e58984..91d0b1815493 100644 --- a/include/svx/float3d.hxx +++ b/include/svx/float3d.hxx @@ -236,7 +236,7 @@ class Svx3DCtrlItem : public SfxControllerItem { protected: virtual void StateChanged( sal_uInt16 nSId, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; public: Svx3DCtrlItem( sal_uInt16, SfxBindings* ); @@ -254,7 +254,7 @@ class SvxConvertTo3DItem : public SfxControllerItem bool bState; protected: - virtual void StateChanged(sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem) override; + virtual void StateChanged(sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem) override; public: SvxConvertTo3DItem(sal_uInt16 nId, SfxBindings* pBindings); diff --git a/include/svx/fontwork.hxx b/include/svx/fontwork.hxx index aee0aced0cf7..ff53e0485b9b 100644 --- a/include/svx/fontwork.hxx +++ b/include/svx/fontwork.hxx @@ -58,7 +58,7 @@ class SvxFontWorkControllerItem : public SfxControllerItem protected: virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem) override; public: SvxFontWorkControllerItem(sal_uInt16 nId, SvxFontWorkDialog&, SfxBindings&); diff --git a/include/svx/formatpaintbrushctrl.hxx b/include/svx/formatpaintbrushctrl.hxx index 03fb6b62f2a2..496a668df5c7 100644 --- a/include/svx/formatpaintbrushctrl.hxx +++ b/include/svx/formatpaintbrushctrl.hxx @@ -41,7 +41,7 @@ public: virtual void Select(sal_uInt16 nSelectModifier) override; virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; private: DECL_LINK( WaitDoubleClickHdl, Timer*, void ); void impl_executePaintBrush(); diff --git a/include/svx/grafctrl.hxx b/include/svx/grafctrl.hxx index 854484b90908..2309f4a5ac95 100644 --- a/include/svx/grafctrl.hxx +++ b/include/svx/grafctrl.hxx @@ -32,7 +32,7 @@ public: SvxGrafToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); virtual ~SvxGrafToolBoxControl() override; - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) override; }; @@ -100,7 +100,7 @@ public: SvxGrafModeToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); virtual ~SvxGrafModeToolBoxControl() override; - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) override; }; diff --git a/include/svx/imapdlg.hxx b/include/svx/imapdlg.hxx index eed8b334f498..1ad202fc0c18 100644 --- a/include/svx/imapdlg.hxx +++ b/include/svx/imapdlg.hxx @@ -67,7 +67,7 @@ class SvxIMapDlgItem : public SfxControllerItem protected: virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; public: diff --git a/include/svx/insctrl.hxx b/include/svx/insctrl.hxx index 68a9eec5ad84..46306e774a68 100644 --- a/include/svx/insctrl.hxx +++ b/include/svx/insctrl.hxx @@ -27,7 +27,7 @@ class SVX_DLLPUBLIC SvxInsertStatusBarControl : public SfxStatusBarControl { public: virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual void Paint( const UserDrawEvent& rEvt ) override; SFX_DECL_STATUSBAR_CONTROL(); diff --git a/include/svx/layctrl.hxx b/include/svx/layctrl.hxx index e6ddc26de437..60306e5d7075 100644 --- a/include/svx/layctrl.hxx +++ b/include/svx/layctrl.hxx @@ -31,7 +31,7 @@ public: virtual VclPtr<SfxPopupWindow> CreatePopupWindow() override; virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; SFX_DECL_TOOLBOX_CONTROL(); @@ -52,7 +52,7 @@ public: virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; }; #endif diff --git a/include/svx/lboxctrl.hxx b/include/svx/lboxctrl.hxx index 60166d60e38b..3a92af52e085 100644 --- a/include/svx/lboxctrl.hxx +++ b/include/svx/lboxctrl.hxx @@ -49,7 +49,7 @@ public: virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual VclPtr<SfxPopupWindow> CreatePopupWindow() override; }; diff --git a/include/svx/linectrl.hxx b/include/svx/linectrl.hxx index cdb9c2eb99ac..5d74b4c3093f 100644 --- a/include/svx/linectrl.hxx +++ b/include/svx/linectrl.hxx @@ -51,7 +51,7 @@ public: virtual ~SvxLineStyleToolBoxControl() override; virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; void Update( const SfxPoolItem* pState ); virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) override; }; @@ -69,7 +69,7 @@ public: virtual ~SvxLineWidthToolBoxControl() override; virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) override; }; diff --git a/include/svx/modctrl.hxx b/include/svx/modctrl.hxx index 29b672d07636..c46f5db9fe77 100644 --- a/include/svx/modctrl.hxx +++ b/include/svx/modctrl.hxx @@ -31,7 +31,7 @@ class SVX_DLLPUBLIC SvxModifyControl : public SfxStatusBarControl { public: virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual void Paint( const UserDrawEvent& rUsrEvt ) override; virtual void Click() override; diff --git a/include/svx/pszctrl.hxx b/include/svx/pszctrl.hxx index 7a5b35b39e86..a5c9f36a0f7a 100644 --- a/include/svx/pszctrl.hxx +++ b/include/svx/pszctrl.hxx @@ -37,7 +37,7 @@ public: SvxPosSizeStatusBarControl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb ); virtual ~SvxPosSizeStatusBarControl() override; - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual void Paint( const UserDrawEvent& rEvt ) override; virtual void Command( const CommandEvent& rCEvt ) override; }; diff --git a/include/svx/selctrl.hxx b/include/svx/selctrl.hxx index ae346c2cbfa0..34e4e2c3dc0c 100644 --- a/include/svx/selctrl.hxx +++ b/include/svx/selctrl.hxx @@ -32,7 +32,7 @@ public: SvxSelectionModeControl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb ); virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual bool MouseButtonDown( const MouseEvent& rEvt ) override; virtual void Paint( const UserDrawEvent& rEvt ) override; diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx index 5a5e3181e1d1..dc7fd663a53f 100644 --- a/include/svx/tbcontrl.hxx +++ b/include/svx/tbcontrl.hxx @@ -170,7 +170,7 @@ public: virtual VclPtr<vcl::Window> CreateItemWindow(vcl::Window* pParent) override; virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem) override; DECL_LINK( VisibilityNotification, SvxStyleBox_Impl&, void ); protected: @@ -259,7 +259,7 @@ public: virtual ~SvxSimpleUndoRedoController() override; virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem) override; }; class SVX_DLLPUBLIC SvxCurrencyToolBoxControl : public svt::PopupWindowController diff --git a/include/svx/tbxctl.hxx b/include/svx/tbxctl.hxx index 180a3ed26510..feac07550f85 100644 --- a/include/svx/tbxctl.hxx +++ b/include/svx/tbxctl.hxx @@ -46,7 +46,7 @@ public: virtual void Select(sal_uInt16 nSelectModifier) override; virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; }; #endif diff --git a/include/svx/verttexttbxctrl.hxx b/include/svx/verttexttbxctrl.hxx index cd64d57993a4..e73b8ad5334f 100644 --- a/include/svx/verttexttbxctrl.hxx +++ b/include/svx/verttexttbxctrl.hxx @@ -35,7 +35,7 @@ public: virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override; virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; }; class SVX_DLLPUBLIC SvxCTLTextTbxCtrl : public SvxVertCTLTextTbxCtrl diff --git a/include/svx/xmlsecctrl.hxx b/include/svx/xmlsecctrl.hxx index ec479fcc8dea..f872526e91f2 100644 --- a/include/svx/xmlsecctrl.hxx +++ b/include/svx/xmlsecctrl.hxx @@ -39,7 +39,7 @@ public: XmlSecStatusBarControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& _rStb ); virtual ~XmlSecStatusBarControl() override; - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual void Paint( const UserDrawEvent& rEvt ) override; virtual void Command( const CommandEvent& rCEvt ) override; }; diff --git a/include/svx/zoomctrl.hxx b/include/svx/zoomctrl.hxx index 88301bbc2f29..e3acef4de096 100644 --- a/include/svx/zoomctrl.hxx +++ b/include/svx/zoomctrl.hxx @@ -32,7 +32,7 @@ private: public: virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual void Paint( const UserDrawEvent& rEvt ) override; virtual void Command( const CommandEvent& rCEvt ) override; diff --git a/include/svx/zoomsliderctrl.hxx b/include/svx/zoomsliderctrl.hxx index 7c289a522ba1..a2a039c85b17 100644 --- a/include/svx/zoomsliderctrl.hxx +++ b/include/svx/zoomsliderctrl.hxx @@ -44,7 +44,7 @@ public: SvxZoomSliderControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& _rStb ); virtual ~SvxZoomSliderControl() override; - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const Item::ItemBase::SharedPtr& rSlotItem ) override; + virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, const std::shared_ptr<const Item::ItemBase>& rSlotItem ) override; virtual void Paint( const UserDrawEvent& rEvt ) override; virtual bool MouseButtonDown( const MouseEvent & ) override; virtual bool MouseButtonUp( const MouseEvent & ) override; diff --git a/item/Library_item.mk b/item/Library_item.mk index dd7de41135ca..f59247140a1f 100644 --- a/item/Library_item.mk +++ b/item/Library_item.mk @@ -36,6 +36,7 @@ $(eval $(call gb_Library_add_exception_objects,item,\ item/source/base/ModelSpecificItemValues \ item/source/base/ItemSet \ item/source/base/SlotSet \ + item/source/base/ItemControlBlock \ item/source/simple/CntInt16 \ item/source/simple/CntOUString \ )) diff --git a/item/source/base/ItemAdministrator.cxx b/item/source/base/ItemAdministrator.cxx index c3aa8a0b8aa2..5010b4b02830 100644 --- a/item/source/base/ItemAdministrator.cxx +++ b/item/source/base/ItemAdministrator.cxx @@ -18,10 +18,8 @@ namespace Item rIBase.m_bAdministrated = true; } - ItemAdministrator::ItemAdministrator(const ItemBase* pDefault) - : m_aDefault(ItemBase::SharedPtr(pDefault)) + ItemAdministrator::ItemAdministrator() { - assert(pDefault != nullptr && "nullptr not allowed, default *is* required (!)"); } ItemAdministrator::~ItemAdministrator() @@ -35,39 +33,29 @@ namespace Item // m_aDefault being destroyed from ~ItemAdministrator() above as last thing in // ItemAdministrator cleanup, the derived classes are no longer available at that time. } - - const ItemBase::SharedPtr& ItemAdministrator::GetDefault() const - { - return m_aDefault; - } - - bool ItemAdministrator::IsDefault(const ItemBase* pIBase) const - { - assert(pIBase != nullptr && "nullptr not allowed (!)"); - return pIBase == m_aDefault.get() || pIBase->operator==(*m_aDefault.get()); - } } // end of namespace Item /////////////////////////////////////////////////////////////////////////////// namespace Item { - IAdministrator_set::IAdministrator_set(const ItemBase* pDefault) - : ItemAdministrator(pDefault), + IAdministrator_set::IAdministrator_set() + : ItemAdministrator(), m_aEntries() { } - ItemBase::SharedPtr IAdministrator_set::Create(const ItemBase* pIBase) + std::shared_ptr<const ItemBase> IAdministrator_set::Create(const ItemBase* pIBase) { assert(pIBase != nullptr && "nullptr not allowed (!)"); - if(IsDefault(pIBase)) + if(pIBase->IsDefault()) { // if the Item to-be-created equals default, delete it and // use the existing single global default + const std::shared_ptr<const ItemBase>& rDefault(pIBase->GetDefault()); delete pIBase; - return GetDefault(); + return rDefault; } // check for existance @@ -85,7 +73,7 @@ namespace Item // start using offered instance and administrate it from now SetAdministratedFromItemAdministrator(*const_cast<ItemBase*>(pIBase)); m_aEntries.insert(pIBase); - return ItemBase::SharedPtr(pIBase); + return std::shared_ptr<const ItemBase>(pIBase); } } @@ -107,22 +95,23 @@ namespace Item namespace Item { - IAdministrator_unordered_set::IAdministrator_unordered_set(const ItemBase* pDefault) - : ItemAdministrator(pDefault), + IAdministrator_unordered_set::IAdministrator_unordered_set() + : ItemAdministrator(), m_aEntries() { } - ItemBase::SharedPtr IAdministrator_unordered_set::Create(const ItemBase* pIBase) + std::shared_ptr<const ItemBase> IAdministrator_unordered_set::Create(const ItemBase* pIBase) { assert(pIBase != nullptr && "nullptr not allowed (!)"); - if(IsDefault(pIBase)) + if(pIBase->IsDefault()) { // if the Item to-be-created equals default, delete it and // use the existing single global default + const std::shared_ptr<const ItemBase>& rDefault(pIBase->GetDefault()); delete pIBase; - return GetDefault(); + return rDefault; } // check for existance @@ -140,7 +129,7 @@ namespace Item // start using offered instance and administrate it from now SetAdministratedFromItemAdministrator(*const_cast<ItemBase*>(pIBase)); m_aEntries.insert(pIBase); - return ItemBase::SharedPtr(pIBase); + return std::shared_ptr<const ItemBase>(pIBase); } } @@ -234,23 +223,24 @@ namespace Item } } - IAdministrator_vector::IAdministrator_vector(const ItemBase* pDefault) - : ItemAdministrator(pDefault), + IAdministrator_vector::IAdministrator_vector() + : ItemAdministrator(), m_aEntries(), m_aFreeSlots() { } - ItemBase::SharedPtr IAdministrator_vector::Create(const ItemBase* pIBase) + std::shared_ptr<const ItemBase> IAdministrator_vector::Create(const ItemBase* pIBase) { assert(pIBase != nullptr && "nullptr not allowed (!)"); - if(IsDefault(pIBase)) + if(pIBase->IsDefault()) { // if the Item to-be-created equals default, delete it and // use the existing single global default + const std::shared_ptr<const ItemBase>& rDefault(pIBase->GetDefault()); delete pIBase; - return GetDefault(); + return rDefault; } // check for existance @@ -268,7 +258,7 @@ namespace Item // start using offered instance and administrate it from now SetAdministratedFromItemAdministrator(*const_cast<ItemBase*>(pIBase)); insert(pIBase); - return ItemBase::SharedPtr(pIBase); + return std::shared_ptr<const ItemBase>(pIBase); } } diff --git a/item/source/base/ItemBase.cxx b/item/source/base/ItemBase.cxx index f4b5705aae2e..1e7ac4d55fc9 100644 --- a/item/source/base/ItemBase.cxx +++ b/item/source/base/ItemBase.cxx @@ -9,6 +9,7 @@ #include <item/base/ItemBase.hxx> #include <item/base/ItemAdministrator.hxx> +#include <item/base/ItemControlBlock.hxx> #include <cassert> /////////////////////////////////////////////////////////////////////////////// @@ -202,6 +203,22 @@ class SW_DLLPUBLIC SwPaMItem : public SfxPoolItem namespace Item { + ItemControlBlock& ItemBase::GetStaticItemControlBlock() + { + assert(false && "ItemBase::GetItemControlBlock call not allowed (!)"); + static ItemControlBlock aItemControlBlock( + std::shared_ptr<ItemAdministrator>(), + std::shared_ptr<const ItemBase>(), + [](){ return nullptr; }); + + return aItemControlBlock; + } + + ItemControlBlock& ItemBase::GetItemControlBlock() const + { + return ItemBase::GetStaticItemControlBlock(); + } + ItemBase::ItemBase() : std::enable_shared_from_this<ItemBase>(), m_bAdministrated(false) @@ -213,13 +230,6 @@ namespace Item return typeid(rCmp) == typeid(*this); } - ItemAdministrator* ItemBase::GetIAdministrator() const - { - // not intended to be used, error - assert(false && "ItemBase::GetIAdministrator call not allowed (!)"); - return nullptr; - } - void ItemBase::PutValues(const AnyIDArgs& rArgs) { for(const auto& arg : rArgs) @@ -238,7 +248,7 @@ namespace Item { if(IsAdministrated()) { - GetIAdministrator()->HintExpired(this); + GetItemControlBlock().GetItemAdministrator()->HintExpired(this); } } @@ -271,14 +281,20 @@ namespace Item bool ItemBase::IsDefault() const { - // callback to static administrator - return GetIAdministrator()->IsDefault(this); + // callback to ItemControlBlock + return GetItemControlBlock().IsDefaultDDD(*this); + } + + const std::shared_ptr<const ItemBase>& ItemBase::GetDefault() const + { + // callback to ItemControlBlock + assert(GetItemControlBlock().GetDefaultItem() && "empty DefaultItem detected - not allowed (!)"); + return GetItemControlBlock().GetDefaultItem(); } - const ItemBase::SharedPtr& ItemBase::GetDefault() const + bool ItemBase::IsDefault(const std::shared_ptr<const ItemBase>& rCandidate) { - // callback to static administrator - return GetIAdministrator()->GetDefault(); + return rCandidate && rCandidate->GetItemControlBlock().IsDefaultDDD(*rCandidate); } } // end of namespace Item diff --git a/item/source/base/ItemControlBlock.cxx b/item/source/base/ItemControlBlock.cxx new file mode 100755 index 000000000000..c95517e7ef12 --- /dev/null +++ b/item/source/base/ItemControlBlock.cxx @@ -0,0 +1,53 @@ +/* -*- 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/. + */ + +#include <cassert> +#include <item/base/ItemControlBlock.hxx> + +/////////////////////////////////////////////////////////////////////////////// + +namespace Item +{ + ItemControlBlock::ItemControlBlock( + const std::shared_ptr<ItemAdministrator>& rItemAdministrator, + const std::shared_ptr<const ItemBase>& rDefaultItem, + std::function<ItemBase*()>constructItem) + : m_aItemAdministrator(rItemAdministrator), + m_aDefaultItem(rDefaultItem), + m_aConstructItem(constructItem) + { + assert(rItemAdministrator && "nullptr not allowed, an ItemAdministrator *is* required (!)"); + assert(rDefaultItem && "nullptr not allowed, a default value *is* required (!)"); + } + + ItemControlBlock::ItemControlBlock() + : m_aItemAdministrator(), + m_aDefaultItem(), + m_aConstructItem() + { + } + + std::shared_ptr<const ItemBase> ItemControlBlock::CreateFromAny(const ItemBase::AnyIDArgs& rArgs) + { + ItemBase* pNewInstance(ConstructItem()); + pNewInstance->PutValues(rArgs); + return std::shared_ptr<const ItemBase>(pNewInstance); + } + + bool ItemControlBlock::IsDefaultDDD(const ItemBase& rItem) const + { + assert(nullptr != m_aDefaultItem.get() && "empty DefaultItem detected - not allowed (!)"); + assert(typeid(rItem) == typeid(*m_aDefaultItem) && "different types compared - not allowed (!)"); + return &rItem == m_aDefaultItem.get() || rItem.operator==(*m_aDefaultItem.get()); + } +} // end of namespace Item + +/////////////////////////////////////////////////////////////////////////////// + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/item/source/base/ItemSet.cxx b/item/source/base/ItemSet.cxx index e2a2e6b8b547..7a8a58b2dabd 100644 --- a/item/source/base/ItemSet.cxx +++ b/item/source/base/ItemSet.cxx @@ -46,9 +46,9 @@ namespace Item return m_aModelSpecificIValues; } - void ItemSet::SetItem(const ItemBase::SharedPtr& rItem) + void ItemSet::SetItem(const std::shared_ptr<const ItemBase>& rItem) { - assert(rItem && "empty ItemBase::SharedPtr not allowed - and should be unable to be created (!)"); + assert(rItem && "empty std::shared_ptr<const ItemBase> not allowed - and should be unable to be created (!)"); bool bDefault(false); // detect if rItem is default item, include evtl. model-specific @@ -62,7 +62,7 @@ namespace Item else { // use Item's own static global default - bDefault = rItem->IsDefault(); + bDefault = ItemBase::IsDefault(rItem); } const size_t hash_code(typeid(*rItem).hash_code()); @@ -83,7 +83,7 @@ namespace Item { for(const auto& candidate : rSource.m_aItems) { - assert(candidate.second && "empty ItemBase::SharedPtr not allowed - and should be unable to be created (!)"); + assert(candidate.second && "empty std::shared_ptr<const ItemBase> not allowed - and should be unable to be created (!)"); if(bDontCareToDefault && candidate.second.get() == getInvalidateItem().get()) { diff --git a/item/source/base/ModelSpecificItemValues.cxx b/item/source/base/ModelSpecificItemValues.cxx index 265649b0e9e3..99831349d95c 100644 --- a/item/source/base/ModelSpecificItemValues.cxx +++ b/item/source/base/ModelSpecificItemValues.cxx @@ -29,17 +29,17 @@ namespace Item return ModelSpecificItemValues::SharedPtr(new ModelSpecificItemValues()); } - void ModelSpecificItemValues::SetAlternativeDefaultItem(const ItemBase::SharedPtr& rItem) + void ModelSpecificItemValues::SetAlternativeDefaultItem(const std::shared_ptr<const ItemBase>& rItem) { - assert(rItem && "empty ItemBase::SharedPtr not allowed - and should be unable to be created (!)"); + assert(rItem && "empty std::shared_ptr<const ItemBase> not allowed - and should be unable to be created (!)"); const size_t hash_code(typeid(*rItem).hash_code()); m_aAlternativeItems[hash_code] = rItem; } - bool ModelSpecificItemValues::IsDefault(const ItemBase::SharedPtr& rItem) const + bool ModelSpecificItemValues::IsDefault(const std::shared_ptr<const ItemBase>& rItem) const { - assert(rItem && "empty ItemBase::SharedPtr not allowed - and should be unable to be created (!)"); + assert(rItem && "empty std::shared_ptr<const ItemBase> not allowed - and should be unable to be created (!)"); if(!m_aAlternativeItems.empty()) { @@ -54,12 +54,12 @@ namespace Item } // use Item's own static global default - return rItem->IsDefault(); + return ItemBase::IsDefault(rItem); } - const ItemBase::SharedPtr& ModelSpecificItemValues::GetDefault(const ItemBase::SharedPtr& rItem) const + const std::shared_ptr<const ItemBase>& ModelSpecificItemValues::GetDefault(const std::shared_ptr<const ItemBase>& rItem) const { - assert(rItem && "empty ItemBase::SharedPtr not allowed - and should be unable to be created (!)"); + assert(rItem && "empty std::shared_ptr<const ItemBase> not allowed - and should be unable to be created (!)"); if(!m_aAlternativeItems.empty()) { diff --git a/item/source/base/SlotSet.cxx b/item/source/base/SlotSet.cxx index e2ddda5a0013..1783caba9baf 100755 --- a/item/source/base/SlotSet.cxx +++ b/item/source/base/SlotSet.cxx @@ -29,9 +29,9 @@ namespace Item return SlotSet::SharedPtr(new SlotSet()); } - void SlotSet::SetSlot(SlotID aSlotID, const ItemBase::SharedPtr& rItem) + void SlotSet::SetSlot(SlotID aSlotID, const std::shared_ptr<const ItemBase>& rItem) { - assert(rItem && "empty ItemBase::SharedPtr not allowed - and should be unable to be created (!)"); + assert(rItem && "empty std::shared_ptr<const ItemBase> not allowed - and should be unable to be created (!)"); m_aSlots[aSlotID] = rItem; } diff --git a/item/source/simple/CntInt16.cxx b/item/source/simple/CntInt16.cxx index 2bbbc1dc240e..14885387a979 100644 --- a/item/source/simple/CntInt16.cxx +++ b/item/source/simple/CntInt16.cxx @@ -9,20 +9,30 @@ #include <cassert> #include <item/simple/CntInt16.hxx> +#include <item/base/ItemAdministrator.hxx> +#include <item/base/ItemControlBlock.hxx> /////////////////////////////////////////////////////////////////////////////// namespace Item { - // need internal access to ItemAdministrator - ItemAdministrator* CntInt16::GetIAdministrator() const + ItemControlBlock& CntInt16::GetStaticItemControlBlock() { - return &GetStaticAdmin(); + static ItemControlBlock aItemControlBlock( + std::shared_ptr<ItemAdministrator>(new IAdministrator_set()), + std::shared_ptr<const ItemBase>(new CntInt16()), + [](){ return new CntInt16(); }); + + return aItemControlBlock; + } + + ItemControlBlock& CntInt16::GetItemControlBlock() const + { + return CntInt16::GetStaticItemControlBlock(); } CntInt16::CntInt16(sal_Int16 nValue) - : CntInt16StaticHelper(), - ItemBase(), + : ItemBase(), m_nValue(nValue) { } @@ -35,13 +45,15 @@ namespace Item implInstanceCleanup(); } - CntInt16::SharedPtr CntInt16::Create(sal_Int16 nValue) + std::shared_ptr<const CntInt16> CntInt16::Create(sal_Int16 nValue) { // use ::Create(...) method with local incarnation, it will handle // - detection of being default (will delete local incarnation) // - detection of reuse (will delete local incarnation) // - detectiomn of new use - will create shared_ptr for local incarnation and buffer - return std::static_pointer_cast<const CntInt16>(GetStaticAdmin().Create(new CntInt16(nValue))); + return std::static_pointer_cast<const CntInt16>( + CntInt16::GetStaticItemControlBlock().GetItemAdministrator()->Create( + new CntInt16(nValue))); } bool CntInt16::operator==(const ItemBase& rCandidate) const diff --git a/item/source/simple/CntOUString.cxx b/item/source/simple/CntOUString.cxx index b18a9340a690..bd77b934cb05 100644 --- a/item/source/simple/CntOUString.cxx +++ b/item/source/simple/CntOUString.cxx @@ -9,20 +9,30 @@ #include <cassert> #include <item/simple/CntOUString.hxx> +#include <item/base/ItemAdministrator.hxx> +#include <item/base/ItemControlBlock.hxx> /////////////////////////////////////////////////////////////////////////////// namespace Item { - // need internal access to ItemAdministrator - ItemAdministrator* CntOUString::GetIAdministrator() const + ItemControlBlock& CntOUString::GetStaticItemControlBlock() { - return &GetStaticAdmin(); + static ItemControlBlock aItemControlBlock( + std::shared_ptr<ItemAdministrator>(new IAdministrator_unordered_set()), + std::shared_ptr<const ItemBase>(new CntOUString()), + [](){ return new CntOUString(); }); + + return aItemControlBlock; + } + + ItemControlBlock& CntOUString::GetItemControlBlock() const + { + return CntOUString::GetStaticItemControlBlock(); } CntOUString::CntOUString(const rtl::OUString& rValue) - : CntOUStringStaticHelper(), - ItemBase(), + : ItemBase(), m_aValue(rValue) { } @@ -41,7 +51,9 @@ namespace Item // - detection of being default (will delete local incarnation) // - detection of reuse (will delete local incarnation) // - detectiomn of new use - will create shared_ptr for local incarnation and buffer - return std::static_pointer_cast<const CntOUString>(GetStaticAdmin().Create(new CntOUString(rValue))); + return std::static_pointer_cast<const CntOUString>( + CntOUString::GetStaticItemControlBlock().GetItemAdministrator()->Create( + new CntOUString(rValue))); } bool CntOUString::operator==(const ItemBase& rCandidate) const diff --git a/item/test/ItemTest.cxx b/item/test/ItemTest.cxx index 6b0029bdd9c3..46816e7507c5 100644 --- a/item/test/ItemTest.cxx +++ b/item/test/ItemTest.cxx @@ -18,29 +18,30 @@ #include <item/base/ItemSet.hxx> #include <item/simple/CntInt16.hxx> #include <item/simple/CntOUString.hxx> +#include <item/base/ItemControlBlock.hxx> namespace Item { // example for multi value Item - class MultiValueAB; - typedef ItemBaseStaticHelper<MultiValueAB, IAdministrator_vector> MultiValueStaticHelperAB; - // if this should be based on faster IAdministrator_set, changes needed would be: // - typedef ItemBaseStaticHelper<MultiValueAB, IAdministrator_set> MultiValueStaticHelperAB; // - define virtual bool operator<(const ItemBase& rCandidate) const override - - class MultiValueAB : public MultiValueStaticHelperAB, public ItemBase + class MultiValueAB : public ItemBase { public: - // SharedPtr typedef to be used handling instances of given type - typedef std::shared_ptr<const MultiValueAB> SharedPtr; + static ItemControlBlock& MultiValueAB::GetStaticItemControlBlock() + { + static ItemControlBlock aItemControlBlock( + std::shared_ptr<ItemAdministrator>(new IAdministrator_vector()), + std::shared_ptr<const ItemBase>(new MultiValueAB()), + [](){ return new MultiValueAB(); }); - private: - // need to offer internal access to ItemAdministrator - // in each derivation - just calls GetStaticAdmin internally - virtual ItemAdministrator* GetIAdministrator() const override + return aItemControlBlock; + } + + virtual ItemControlBlock& MultiValueAB::GetItemControlBlock() const override { - return &MultiValueStaticHelperAB::GetStaticAdmin(); + return MultiValueAB::GetStaticItemControlBlock(); } private: @@ -48,11 +49,8 @@ namespace Item sal_Int32 m_nValueB; protected: - friend MultiValueStaticHelperAB; - MultiValueAB(sal_Int16 nValueA = 0, sal_Int16 nValueB = 0) - : MultiValueStaticHelperAB(), - ItemBase(), + : ItemBase(), m_nValueA(nValueA), m_nValueB(nValueB) { @@ -74,7 +72,7 @@ namespace Item // - detection of reuse (will delete local incarnation) // - detectiomn of new use - will create shared_ptr for local incarnation and buffer return std::static_pointer_cast<const MultiValueAB>( - MultiValueStaticHelperAB::GetStaticAdmin().Create( + MultiValueAB::GetStaticItemControlBlock().GetItemAdministrator()->Create( new MultiValueAB(nValueA, nValueB))); } @@ -111,32 +109,30 @@ namespace Item { // example for multi value Item deived from already defined one, // adding parameters (only one here) - class MultiValueABC; - typedef ItemBaseStaticHelper<MultiValueABC, IAdministrator_vector> MultiValueStaticHelperABC; - - class MultiValueABC : public MultiValueAB, public MultiValueStaticHelperABC + class MultiValueABC : public MultiValueAB { public: - // SharedPtr typedef to be used handling instances of given type - typedef std::shared_ptr<const MultiValueABC> SharedPtr; + static ItemControlBlock& MultiValueABC::GetStaticItemControlBlock() + { + static ItemControlBlock aItemControlBlock( + std::shared_ptr<ItemAdministrator>(new IAdministrator_vector()), + std::shared_ptr<const ItemBase>(new MultiValueABC()), + [](){ return new MultiValueABC(); }); - private: - // need to offer internal access to ItemAdministrator - // in each derivation - just calls GetStaticAdmin internally - virtual ItemAdministrator* GetIAdministrator() const override + return aItemControlBlock; + } + + virtual ItemControlBlock& MultiValueABC::GetItemControlBlock() const override { - return &MultiValueStaticHelperABC::GetStaticAdmin(); + return MultiValueABC::GetStaticItemControlBlock(); } private: sal_Int64 m_nValueC; protected: - friend MultiValueStaticHelperABC; - MultiValueABC(sal_Int16 nValueA = 0, sal_Int16 nValueB = 0, sal_Int16 nValueC = 0) : MultiValueAB(nValueA, nValueB), - MultiValueStaticHelperABC(), m_nValueC(nValueC) { } @@ -157,7 +153,7 @@ namespace Item // - detection of reuse (will delete local incarnation) // - detectiomn of new use - will create shared_ptr for local incarnation and buffer return std::static_pointer_cast<const MultiValueABC>( - MultiValueStaticHelperABC::GetStaticAdmin().Create( + MultiValueABC::GetStaticItemControlBlock().GetItemAdministrator()->Create( new MultiValueABC(nValueA, nValueB, nValueC))); } @@ -191,8 +187,20 @@ namespace Item class MultiValueAB_Alternative : public MultiValueAB { public: - // SharedPtr typedef to be used handling instances of given type - typedef std::shared_ptr<const MultiValueAB_Alternative> SharedPtr; + static ItemControlBlock& MultiValueAB_Alternative::GetStaticItemControlBlock() + { + static ItemControlBlock aItemControlBlock( + MultiValueABC::GetStaticItemControlBlock().GetItemAdministrator(), + std::shared_ptr<const ItemBase>(new MultiValueAB_Alternative()), + [](){ return new MultiValueAB_Alternative(); }); + + return aItemControlBlock; + } + + virtual ItemControlBlock& MultiValueAB_Alternative::GetItemControlBlock() const override + { + return MultiValueAB_Alternative::GetStaticItemControlBlock(); + } protected: MultiValueAB_Alternative(sal_Int16 nValueA = 0, sal_Int16 nValueB = 0) @@ -208,7 +216,7 @@ namespace Item // - detection of reuse (will delete local incarnation) // - detectiomn of new use - will create shared_ptr for local incarnation and buffer return std::static_pointer_cast<const MultiValueAB_Alternative>( - MultiValueStaticHelperAB::GetStaticAdmin().Create( + MultiValueAB_Alternative::GetStaticItemControlBlock().GetItemAdministrator()->Create( new MultiValueAB_Alternative(nValueA, nValueB))); } @@ -247,31 +255,26 @@ namespace Item // current SfxPoolItem/SfxItemSet/SfxItemPool stuff ... int nIncrement(0); - MultiValueAB::SharedPtr mhas3(MultiValueAB::Create(5,2)); - MultiValueAB::SharedPtr mhas4(MultiValueAB::Create(2,3)); - - if(MultiValueStaticHelperAB::IsStaticDefault(MultiValueAB::Create(3,0))) - { - nIncrement++; - } + std::shared_ptr<const MultiValueAB> mhas3(MultiValueAB::Create(5,2)); + std::shared_ptr<const MultiValueAB> mhas4(MultiValueAB::Create(2,3)); - if(MultiValueStaticHelperAB::IsStaticDefault(MultiValueAB::Create(8,7))) + if(ItemBase::IsDefault(MultiValueAB::Create(3,0))) { nIncrement++; } - if(MultiValueStaticHelperAB::IsStaticDefault(MultiValueStaticHelperAB::GetStaticDefault())) + if(ItemBase::IsDefault(MultiValueAB::Create(8,7))) { nIncrement++; } - if(MultiValueStaticHelperABC::IsStaticDefault(MultiValueStaticHelperABC::GetStaticDefault())) + if(ItemBase::IsDefault(ItemBase::GetDefault<MultiValueAB>())) { nIncrement++; } - MultiValueAB::SharedPtr testAA(MultiValueAB::Create(11,22)); - std::vector<MultiValueAB::SharedPtr> test; + std::shared_ptr<const MultiValueAB> testAA(MultiValueAB::Create(11,22)); + std::vector<std::shared_ptr<const MultiValueAB>> test; const sal_uInt32 nLoopNumber(50); for(sal_uInt32 aloop(0); aloop < nLoopNumber; aloop++) @@ -279,8 +282,8 @@ namespace Item test.push_back(MultiValueAB::Create(aloop+1, (aloop+1)*2)); } - MultiValueAB::SharedPtr testA(MultiValueAB::Create(2,4)); - MultiValueAB::SharedPtr testB(MultiValueAB::Create(2,3)); + std::shared_ptr<const MultiValueAB> testA(MultiValueAB::Create(2,4)); + std::shared_ptr<const MultiValueAB> testB(MultiValueAB::Create(2,3)); for(sal_uInt32 dloop(0); dloop < nLoopNumber; dloop+=2) { @@ -308,25 +311,25 @@ namespace Item // make direct use of local MultiValueABC item int nIncrement(0); - MultiValueABC::SharedPtr mhas3x(MultiValueABC::Create(5,2,5)); - MultiValueABC::SharedPtr mhas4x(MultiValueABC::Create(2,3,7)); + std::shared_ptr<const MultiValueABC> mhas3x(MultiValueABC::Create(5,2,5)); + std::shared_ptr<const MultiValueABC> mhas4x(MultiValueABC::Create(2,3,7)); - if(MultiValueStaticHelperABC::IsStaticDefault(MultiValueABC::Create(3,0,5))) + if(ItemBase::IsDefault(MultiValueABC::Create(3,0,5))) { nIncrement++; } - if(MultiValueStaticHelperABC::IsStaticDefault(MultiValueABC::Create(8,7,12))) + if(ItemBase::IsDefault(MultiValueABC::Create(8,7,12))) { nIncrement++; } - if(MultiValueStaticHelperABC::IsStaticDefault(MultiValueStaticHelperABC::GetStaticDefault())) + if(ItemBase::IsDefault(ItemBase::GetDefault<MultiValueABC>())) { nIncrement++; } - std::vector<MultiValueABC::SharedPtr> testx; + std::vector<std::shared_ptr<const MultiValueABC>> testx; const sal_uInt32 nLoopNumber(50); for(sal_uInt32 aloop(0); aloop < nLoopNumber; aloop++) @@ -334,8 +337,8 @@ namespace Item testx.push_back(MultiValueABC::Create(aloop+1, (aloop+1)*2, (aloop+1)*4)); } - MultiValueABC::SharedPtr testAx(MultiValueABC::Create(2,4,3)); - MultiValueABC::SharedPtr testBx(MultiValueABC::Create(2,4,6)); + std::shared_ptr<const MultiValueABC> testAx(MultiValueABC::Create(2,4,3)); + std::shared_ptr<const MultiValueABC> testBx(MultiValueABC::Create(2,4,6)); for(sal_uInt32 dloop(0); dloop < nLoopNumber; dloop+=2) { @@ -362,32 +365,32 @@ namespace Item { int nIncrement(0); const sal_uInt32 nLoopNumber(50); - MultiValueAB_Alternative::SharedPtr mhas3_A(MultiValueAB_Alternative::Create(5,2)); + std::shared_ptr<const MultiValueAB_Alternative> mhas3_A(MultiValueAB_Alternative::Create(5,2)); - if(MultiValueStaticHelperAB::IsStaticDefault(MultiValueAB_Alternative::Create(3,0))) + if(ItemBase::IsDefault(MultiValueAB_Alternative::Create(3,0))) { nIncrement++; } - if(MultiValueStaticHelperAB::IsStaticDefault(MultiValueAB_Alternative::Create(8,7))) + if(ItemBase::IsDefault(MultiValueAB_Alternative::Create(8,7))) { nIncrement++; } - if(MultiValueStaticHelperAB::IsStaticDefault(MultiValueStaticHelperAB::GetStaticDefault())) + if(ItemBase::IsDefault(ItemBase::GetDefault<MultiValueAB_Alternative>())) { nIncrement++; } - std::vector<MultiValueAB_Alternative::SharedPtr> testAB_A; + std::vector<std::shared_ptr<const MultiValueAB_Alternative>> testAB_A; for(sal_uInt32 aloop(0); aloop < nLoopNumber; aloop++) { testAB_A.push_back(MultiValueAB_Alternative::Create(aloop+1, (aloop+1)*2)); } - MultiValueAB_Alternative::SharedPtr testA_A(MultiValueAB_Alternative::Create(2,4)); - MultiValueAB_Alternative::SharedPtr testB_A(MultiValueAB_Alternative::Create(2,3)); + std::shared_ptr<const MultiValueAB_Alternative> testA_A(MultiValueAB_Alternative::Create(2,4)); + std::shared_ptr<const MultiValueAB_Alternative> testB_A(MultiValueAB_Alternative::Create(2,3)); for(sal_uInt32 dloop(0); dloop < nLoopNumber; dloop+=2) { @@ -447,10 +450,10 @@ namespace Item void checkSimpleItems() { static bool bInit(false); - static CntInt16::SharedPtr a_sp, b_sp, c_sp; - static CntInt16::SharedPtr theDefault; - static CntOUString::SharedPtr sa_sp, sb_sp, sc_sp; - static CntOUString::SharedPtr stheDefault; + static std::shared_ptr<const CntInt16> a_sp, b_sp, c_sp; + static std::shared_ptr<const CntInt16> theDefault; + static std::shared_ptr<const CntOUString> sa_sp, sb_sp, sc_sp; + static std::shared_ptr<const CntOUString> stheDefault; const sal_uInt32 nLoopNumber(50); int nIncrement(0); @@ -460,35 +463,35 @@ namespace Item a_sp = CntInt16::Create(3); b_sp = CntInt16::Create(5); c_sp = CntInt16::Create(7); - theDefault = CntInt16::GetStaticDefault(); + theDefault = ItemBase::GetDefault<CntInt16>(); sa_sp = CntOUString::Create("Hello"); sb_sp = CntOUString::Create("World"); sc_sp = CntOUString::Create("..of Doom!"); - stheDefault = CntOUString::GetStaticDefault(); + stheDefault = ItemBase::GetDefault<CntOUString>(); } /////////////////////////////////////////////////////////////////////////////// - CntInt16::SharedPtr has3(CntInt16::Create(3)); - CntInt16::SharedPtr has4(CntInt16::Create(4)); + std::shared_ptr<const CntInt16> has3(CntInt16::Create(3)); + std::shared_ptr<const CntInt16> has4(CntInt16::Create(4)); - if(CntInt16::IsStaticDefault(CntInt16::Create(11))) + if(ItemBase::IsDefault(CntInt16::Create(11))) { nIncrement++; } - if(CntInt16::IsStaticDefault(CntInt16::Create(0))) + if(ItemBase::IsDefault(CntInt16::Create(0))) { nIncrement++; } - if(CntInt16::IsStaticDefault(theDefault)) + if(ItemBase::IsDefault(theDefault)) { nIncrement++; } - std::vector<CntInt16::SharedPtr> test16; + std::vector<std::shared_ptr<const CntInt16>> test16; for(sal_uInt32 a(0); a < nLoopNumber; a++) { @@ -499,25 +502,25 @@ namespace Item /////////////////////////////////////////////////////////////////////////////// - CntOUString::SharedPtr shas3(CntOUString::Create("Hello")); - CntOUString::SharedPtr shas4(CntOUString::Create("WhateverComesAlong")); + std::shared_ptr<const CntOUString> shas3(CntOUString::Create("Hello")); + std::shared_ptr<const CntOUString> shas4(CntOUString::Create("WhateverComesAlong")); - if(CntOUString::IsStaticDefault(CntOUString::Create("NotDefault"))) + if(ItemBase::IsDefault(CntOUString::Create("NotDefault"))) { nIncrement++; } - if(CntOUString::IsStaticDefault(CntOUString::Create(OUString()))) + if(ItemBase::IsDefault(CntOUString::Create(OUString()))) { nIncrement++; } - if(CntOUString::IsStaticDefault(stheDefault)) + if(ItemBase::IsDefault(stheDefault)) { nIncrement++; } - std::vector<CntOUString::SharedPtr> testStr; + std::vector<std::shared_ptr<const CntOUString>> testStr; for(sal_uInt32 a(0); a < nLoopNumber; a++) { @@ -554,7 +557,7 @@ namespace Item aSet->SetItem(CntInt16::Create(4)); const auto aActA(aSet->GetStateAndItem<const CntInt16>()); - aSet->SetItem(CntInt16::GetStaticDefault()); + aSet->SetItem(ItemBase::GetDefault<CntInt16>()); const auto aActB(aSet->GetStateAndItem<const CntInt16>()); aSet->SetItem(CntInt16::Create(12)); @@ -587,9 +590,9 @@ namespace Item } // check getting default at Set, this will include ModelSpecificItemValues - // compared with the static CntInt16::GetStaticDefault() call ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits