summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@me.com>2019-03-20 13:57:39 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2019-05-05 18:44:53 +0200
commitc194994cb7ef4de8fab82b9723ee34a1954348e6 (patch)
tree74166fb07f7a2b1e952598e2a8c5e086ad9c8655
parentacd8ee107f336d629782956350ed3981ca302024 (diff)
WIP: Started replacement Item::IBase, ::ISet stuff
To have a base for replacing SfxItem* stuff in the long term I started to implement some basic stuff, please see comments in new part tree item and includes and testfiles to see how it works. Extended docu will be done during (hopefully) progressing Change-Id: I59245f9ed0897943e72bfd53f8d1136a30f2db16
-rw-r--r--Repository.mk1
-rw-r--r--RepositoryModule_build.mk1
-rw-r--r--RepositoryModule_host.mk1
-rw-r--r--basctl/Library_basctl.mk1
-rw-r--r--basctl/source/basicide/sbxitem.cxx45
-rw-r--r--basctl/source/inc/sbxitem.hxx45
-rwxr-xr-xbin/update_pch1
-rw-r--r--include/item/base/IAdministrator.hxx212
-rw-r--r--include/item/base/IBase.hxx152
-rw-r--r--include/item/base/IBaseStaticHelper.hxx93
-rw-r--r--include/item/base/ISet.hxx301
-rw-r--r--include/item/base/ModelSpecificIValues.hxx76
-rw-r--r--include/item/itemdllapi.h24
-rw-r--r--include/item/simple/CntInt16.hxx50
-rw-r--r--include/item/simple/CntOUString.hxx51
-rw-r--r--item/CppunitTest_item.mk28
-rw-r--r--item/Library_item.mk42
-rw-r--r--item/Makefile14
-rw-r--r--item/Module_item.mk20
-rw-r--r--item/README6
-rw-r--r--item/inc/pch/precompiled_item.cxx12
-rw-r--r--item/inc/pch/precompiled_item.hxx26
-rw-r--r--item/source/base/IAdministrator.cxx292
-rw-r--r--item/source/base/IBase.cxx206
-rw-r--r--item/source/base/ISet.cxx85
-rw-r--r--item/source/base/ModelSpecificIValues.cxx82
-rw-r--r--item/source/simple/CntInt16.cxx63
-rw-r--r--item/source/simple/CntOUString.cxx62
-rw-r--r--item/test/ItemTest.cxx385
-rw-r--r--solenv/clang-format/blacklist17
-rw-r--r--solenv/qa/python/gbuildtojson.py2
31 files changed, 2395 insertions, 1 deletions
diff --git a/Repository.mk b/Repository.mk
index d9654e717025..c07a7007da77 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -435,6 +435,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
$(call gb_Helper_optional,SCRIPTING,stringresource) \
svgio \
emfio \
+ item \
svl \
svt \
svx \
diff --git a/RepositoryModule_build.mk b/RepositoryModule_build.mk
index 541940515eba..a3718290209a 100644
--- a/RepositoryModule_build.mk
+++ b/RepositoryModule_build.mk
@@ -77,6 +77,7 @@ $(eval $(call gb_Module_add_moduledirs,cross_toolset,\
sot \
svgio \
emfio \
+ item \
svl \
svtools \
svx \
diff --git a/RepositoryModule_host.mk b/RepositoryModule_host.mk
index e6f93c869ccd..7294a24910bc 100644
--- a/RepositoryModule_host.mk
+++ b/RepositoryModule_host.mk
@@ -125,6 +125,7 @@ $(eval $(call gb_Module_add_moduledirs,libreoffice,\
svtools \
svgio \
emfio \
+ item \
svx \
sw \
swext \
diff --git a/basctl/Library_basctl.mk b/basctl/Library_basctl.mk
index d93c5974f28e..08b842897349 100644
--- a/basctl/Library_basctl.mk
+++ b/basctl/Library_basctl.mk
@@ -60,6 +60,7 @@ $(eval $(call gb_Library_use_libraries,basctl,\
ucbhelper \
vcl \
xmlscript \
+ item \
))
$(eval $(call gb_Library_add_exception_objects,basctl,\
diff --git a/basctl/source/basicide/sbxitem.cxx b/basctl/source/basicide/sbxitem.cxx
index e1281f62510a..2ea28ae32313 100644
--- a/basctl/source/basicide/sbxitem.cxx
+++ b/basctl/source/basicide/sbxitem.cxx
@@ -22,6 +22,51 @@
namespace basctl
{
+
+#ifdef ENABLE_ITEMS
+namespace Item
+{
+Sbx::Sbx(const ScriptDocument* pDocument, const OUString& aLibName, const OUString& aName, const OUString& aMethodName, ItemType eType)
+: SbxStaticHelper(),
+ m_aDocument(nullptr != pDocument ? *pDocument : ScriptDocument::getApplicationScriptDocument()),
+ m_aLibName(aLibName),
+ m_aName(aName),
+ m_aMethodName(aMethodName),
+ m_eType(eType)
+{
+}
+
+Sbx::~Sbx()
+{
+ if(IsAdministrated())
+ {
+ GetStaticAdmin().HintExpired(this);
+ }
+}
+
+std::shared_ptr<const Sbx> Sbx::Create(const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, ItemType eType)
+{
+ return std::static_pointer_cast<const Sbx>(GetStaticAdmin().Create(new Sbx(&rDocument, aLibName, aName, OUString(), 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)));
+}
+
+bool Sbx::operator==(const IBase& rCandidate) const
+{
+ assert(IBase::operator==(rCandidate));
+ const Sbx& rCand(static_cast<const Sbx&>(rCandidate));
+ return (GetDocument() == rCand.GetDocument()
+ && GetLibName() == rCand.GetLibName()
+ && GetName() == rCand.GetName()
+ && GetMethodName() == rCand.GetMethodName()
+ && GetType() == rCand.GetType());
+}
+}
+#endif
+
SfxPoolItem* SbxItem::CreateDefault() { SAL_WARN( "basctl.basicide", "No SbxItem factory available"); return nullptr; }
SbxItem::SbxItem (
sal_uInt16 nWhichItem,
diff --git a/basctl/source/inc/sbxitem.hxx b/basctl/source/inc/sbxitem.hxx
index 4e97389906fd..f144a54e8034 100644
--- a/basctl/source/inc/sbxitem.hxx
+++ b/basctl/source/inc/sbxitem.hxx
@@ -22,6 +22,10 @@
#include "scriptdocument.hxx"
#include <svl/poolitem.hxx>
+#ifdef ENABLE_ITEMS
+#include <item/base/IBaseStaticHelper.hxx>
+#endif
+
namespace basctl
{
@@ -35,6 +39,47 @@ enum ItemType
TYPE_METHOD
};
+#ifdef ENABLE_ITEMS
+namespace Item
+{
+class Sbx;
+typedef ::Item::IBaseStaticHelper<Sbx, ::Item::IAdministrator_vector> SbxStaticHelper;
+
+class Sbx final : public SbxStaticHelper
+{
+private:
+ const ScriptDocument m_aDocument;
+ const OUString m_aLibName;
+ const OUString m_aName;
+ const OUString m_aMethodName;
+ ItemType m_eType;
+
+protected:
+ friend SbxStaticHelper;
+
+ Sbx(
+ const ScriptDocument* pDocument = nullptr,
+ const OUString& aLibName = OUString(),
+ const OUString& aName = OUString(),
+ const OUString& aMethodName = OUString(),
+ ItemType eType = TYPE_UNKNOWN);
+
+public:
+ virtual ~Sbx();
+
+ static std::shared_ptr<const Sbx> Create(const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, ItemType);
+ static std::shared_ptr<const Sbx> Create(const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, const OUString& aMethodName, ItemType eType);
+ virtual bool operator==(const IBase& rCandidate) const override;
+
+ ScriptDocument const& GetDocument() const { return m_aDocument; }
+ OUString const& GetLibName() const { return m_aLibName; }
+ OUString const& GetName() const { return m_aName; }
+ OUString const& GetMethodName() const { return m_aMethodName; }
+ ItemType GetType() const { return m_eType; }
+};
+}
+#endif
+
class SbxItem : public SfxPoolItem
{
const ScriptDocument m_aDocument;
diff --git a/bin/update_pch b/bin/update_pch
index 435cc3fcdbb9..2bf5b2c1a6ee 100755
--- a/bin/update_pch
+++ b/bin/update_pch
@@ -44,6 +44,7 @@ DEFAULTS = \
'accessibility.acc' : ( 4, EXCLUDE, INCLUDE, INCLUDE), # 7.8
'basctl.basctl' : ( 3, EXCLUDE, INCLUDE, EXCLUDE), # 11.9
'basegfx.basegfx' : ( 3, EXCLUDE, EXCLUDE, INCLUDE), # 3.8
+ 'item.item' : ( 3, EXCLUDE, EXCLUDE, INCLUDE), # 3.8
'basic.sb' : ( 2, EXCLUDE, EXCLUDE, INCLUDE), # 10.7
'chart2.chartcontroller' : ( 6, EXCLUDE, INCLUDE, INCLUDE), # 18.4
'chart2.chartcore' : ( 3, EXCLUDE, EXCLUDE, INCLUDE), # 22.5
diff --git a/include/item/base/IAdministrator.hxx b/include/item/base/IAdministrator.hxx
new file mode 100644
index 000000000000..4d83ef235614
--- /dev/null
+++ b/include/item/base/IAdministrator.hxx
@@ -0,0 +1,212 @@
+/* -*- 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_IADMINISTRATOR_HXX
+#define INCLUDED_ITEM_BASE_IADMINISTRATOR_HXX
+
+#include <vector>
+#include <set>
+#include <unordered_set>
+#include <cassert>
+#include <item/base/IBase.hxx>
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ // Base class for IAdministrator. It's Task is to administer instances
+ // of IBase - Items. Target is to always have only one instance
+ // of a typed Item in one attributation, e.g. for sal_uInt16 many
+ // users may use the instance representing the value '12'.
+ // To do so, IAdministrator has to administer a list of that instances
+ // as static global typed entity for each type of Item that allows
+ // search and removal of typed Items.
+ // The instances are by purpose no shared_ptr's of the instances. I have
+ // made experiments with using weak_ptr already, but all slow and error
+ // prone at office shutdown and removal. Best and fastest for this
+ // anyways non-public accessible mechanism are the direct pointer
+ // instances - these are handled by the rest of the Item namespace
+ // as shared_ptr and thus will trigger the destructor when the last
+ // usage is removed.
+ // This is a working, fast and nice spot to then remove from this
+ // typed list with a single call from the destructor. One small
+ // optimization is to not need to check if member of the list by using
+ // a boolean flag in Iase (see m_bAdministrated).
+ // Note: These lists may need some semaphore/mutex mechanism later.
+ // SfxItemSets never needed this, but were less global in the sense
+ // to have global lists of re-used existing Items in the SfxItemPool
+ // only. These SfxItemPools are pretty App-specific (except
+ // EditEngine), but the Apps never were or are task-bound, so it's
+ // worth to check first if problems arise at all - we'll see.
+ // This single static global list for one Item-type is also the place
+ // where to administer the Item's global default. This again is done
+ // as shared_ptr to fit nicely to the rest of the mechanism.
+ // Note to this default: This is the Item's global, type-specific
+ // default, this may be overriden by ISet and ModelSpecificIValues,
+ // but only in association with an ISet (see there). The Item-specific
+ // global default will always be the same, so only deviating values
+ // for ModelSpecificIValues need to be overriden.
+ class ITEM_DLLPUBLIC IAdministrator
+ {
+ protected:
+ // instance of global default value
+ IBase::SharedPtr m_aDefault;
+
+ void SetAdministrated(const IBase& rIBase) const;
+
+ public:
+ // constructor/destructor
+ IAdministrator(const IBase* pDefault);
+ virtual ~IAdministrator();
+
+ // noncopyable
+ IAdministrator(const IAdministrator&) = delete;
+ IAdministrator& operator=(const IAdministrator&) = delete;
+
+ // needed IAdministrator calls from IBase implementations.
+ // these are the add/remove calls to the list. The Create
+ // will check existance/default and either re-use existing
+ // instance (and delete given one) or start using given instance
+ virtual void HintExpired(const IBase* pIBase);
+ virtual IBase::SharedPtr Create(const IBase* pIBase) = 0;
+
+ // interface for global default value support
+ // on Administrator level
+ const IBase::SharedPtr& GetDefault() const;
+ bool IsDefault(const IBase* pIBase) const;
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ // IAdministrator-implementation using std::set for implementation
+ // which guarantees good runtime for accesses (sorted list)
+ // requirements from IBase:
+ // - bool IBase::operator<(const IBase& rCand) const
+ // Caution: This does not exist for current SfxItem implementations
+ class ITEM_DLLPUBLIC IAdministrator_set : public IAdministrator
+ {
+ private:
+ struct less_for_set
+ {
+ bool operator()(const IBase* pItem1, const IBase* pItem2) const
+ {
+ // forward to IBase::operator<
+ return pItem1->operator<(*pItem2);
+ }
+ };
+
+ // std::set with all instanciated Items of this type, sorted by
+ // operator< (see less_for_set above)
+ std::set<const IBase*, less_for_set> m_aEntries;
+
+ public:
+ IAdministrator_set(const IBase* pDefault);
+
+ virtual IBase::SharedPtr Create(const IBase* pIBase) override;
+ virtual void HintExpired(const IBase* pIBase) override;
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ // IAdministrator-implementation using std::unordered_set for
+ // implementation which guarantees good runtime for accesses (hashed)
+ // requirements from IBase:
+ // - virtual bool IBase::operator==(const IBase& rCandidate) const
+ // - size_t IBase::GetUniqueKey() const
+ // Caution: GetUniqueKey does not exist for current SfxItem implementations
+ class ITEM_DLLPUBLIC IAdministrator_unordered_set : public IAdministrator
+ {
+ private:
+ struct compare_for_unordered_set
+ {
+ bool operator()(const IBase* pItem1, const IBase* pItem2) const
+ {
+ // forward to IBase::operator==
+ return pItem1->operator==(*pItem2);
+ }
+ };
+
+ struct hash_for_unordered_set
+ {
+ size_t operator()(const IBase* pItem) const
+ {
+ // forward to IBase::GetUniqueKey
+ return pItem->GetUniqueKey();
+ }
+ };
+
+ // std::unordered_set with all instanciated Items of this type,
+ // using hash and operator== (see hash_for_unordered_set, compare_for_unordered_set above)
+ std::unordered_set<const IBase*, hash_for_unordered_set, compare_for_unordered_set> m_aEntries;
+
+ public:
+ IAdministrator_unordered_set(const IBase* pDefault);
+
+ virtual IBase::SharedPtr Create(const IBase* pIBase) override;
+ virtual void HintExpired(const IBase* pIBase) override;
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ // IAdministrator-implementation using std::vector for implementation.
+ // this is slow, but at least uses a 2nd vector to administer the free
+ // slots in the 1st list. This is BTW what SfxItemPool does right now,
+ // so this is slowest, but guarantees same speed as current implementation.
+ // requirements from IBase:
+ // - virtual bool IBase::operator==(const IBase& rCandidate) const
+ // This does exist for current SfxItem implementations, so this is the
+ // simple default for all Items that are hard to transfer/change/update,
+ // it allows to continue to use the single operator== for administration.
+ class ITEM_DLLPUBLIC IAdministrator_vector : public IAdministrator
+ {
+ private:
+ // this unsorted list is used when only operator== is available. Thus
+ // this is the slowest of the available IAdministrators, ony use when
+ // not avoidable or in a phase of change (SfxItem's have operator== already).
+ // It uses a std::vector to hjold all instances, plus a list of free slots
+ // (just indices) for reuse to avoid re-organizing the vector
+ std::vector<const IBase*> m_aEntries;
+ std::vector<size_t> m_aFreeSlots;
+
+ std::vector<const IBase*>::iterator find(const IBase* pIBase);
+ void insert(const IBase* pIBase);
+ void erase(std::vector<const IBase*>::iterator& rIter);
+
+ public:
+ IAdministrator_vector(const IBase* pDefault);
+
+ virtual IBase::SharedPtr Create(const IBase* pIBase) override;
+ virtual void HintExpired(const IBase* pIBase) override;
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+#endif // INCLUDED_ITEM_BASE_IADMINISTRATOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/item/base/IBase.hxx b/include/item/base/IBase.hxx
new file mode 100644
index 000000000000..b86ded4cea71
--- /dev/null
+++ b/include/item/base/IBase.hxx
@@ -0,0 +1,152 @@
+/* -*- 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_IBASE_HXX
+#define INCLUDED_ITEM_BASE_IBASE_HXX
+
+#include <memory>
+#include <sal/types.h>
+#include <item/itemdllapi.h>
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ // predefine IAdministrator - no need to include
+ class IAdministrator;
+
+ // Base class for IBase and thus for all new implementation of
+ // Items. Items are in general read-only instances. The constructor
+ // is protected now so that no one is able to create own instances.
+ // The reason for that is that for all Items only a single value-
+ // specific instance shall exist at any time, guaranteed by being
+ // administrated by an instance of IAdministrator associated with
+ // each implemented type of IBase Item.
+ // To construct, use the ::Create methods. These are in general
+ // static member functions. These have to use the protected
+ // constructor(s) from which also any number may be defined to
+ // support the ::Create methods, but all shall be protected.
+ // It is also possible to use a single constructor and set values
+ // as needed at the created instance in any local implementation
+ // of a ::Create method.
+ // That instance created and filled (value-set) in a ::Create method
+ // will then be handed over to the single static global IAdministrator
+ // instance of the derived Item-type. That method will decide if
+ // to use the given instance or delete it again - if already an instance
+ // of that Item exists (or is identical to the global default of
+ // this Item-type).
+ // The static ::Create methods only return shared_ptr's of instances,
+ // thus any usage of Items will be based on using shared_ptr's and
+ // thus making runtime existance of Items safe. It also uses typed
+ // derivations and templates to ensure throghout usage of typed
+ // Items.
+ // That Items are in general read-only instances also means that there
+ // will no longer be set-methods like ::SetAny(Any& aAny) or similar.
+ // Instead, implement a ::Create method for this that creates an instance
+ // using a/the protected constructor, set all members from the Any (in
+ // this exapmle) and hand over to the IAdministrator. Result will in all
+ // cases be a shared_ptr of the Item.
+ // Items are no longer identified by any global to-be-somewhere-defined
+ // (collision-free, global, incompatible, hard to maintain) ItemID, but
+ // by their Type only internally using C++'s typeid() and
+ // typeid(<ItemType>).hash_code().
+ // The efficency the administration can be done highly depends on the
+ // type of operators defined at the Item-Implementation, see
+ // comments at IAdministrator and it's three default implementations for
+ // details - also discussing speed compared to SfxItem implementations.
+ // When implementing an Item, you choose one of these three
+ // predefined implementations to use for the Item-type, based on the
+ // operators available at your Item-implementation.
+ // For an example, see 'CntMultiValue' in the test cases, or any other
+ // Item-implementation (e.g. Item::CntInt16 or Item::CntOUString).
+ // Note: Be aware that some static local functions will be needed for
+ // any Item-implementation. To support this and full typed accesses
+ // to implemented Items, check out the implementation helper template
+ // class 'IBaseStaticHelper' which should be used to implement Items.
+ // This Base-Class IBase exists as minimal achor point, it sometimes
+ // is useful, see e.g. helper classes ImplInvalidateItem and
+ // ImplDisableItem used in ::Iset to represent ItemStates in ISet's.
+ class ITEM_DLLPUBLIC IBase : public std::enable_shared_from_this<IBase>
+ {
+ public:
+ // SharedPtr typedef to be used handling instances of this type
+ typedef std::shared_ptr<const IBase> SharedPtr;
+
+ private:
+ // flag to mark this instance being administared by an
+ // IAdministrator. Not urgently needed due to also being
+ // able to check being administarted in the HintExpired
+ // calls. But that is the point - when using this flag
+ // at adding the instance and thus making it being actively
+ // administrated it is not necessary to do that check
+ // if it is administrated which means a 'find' access
+ // to a kind of list which may have varying costs...
+ friend class IAdministrator;
+ bool m_bAdministrated;
+
+ protected:
+ // constructor - protected BY DEFAULT - do NOT CHANGE (!)
+ // Use ::Create(...) methods in derived classes instead
+ IBase();
+
+ // basic RTTI TypeCheck to secure e.g. operator== and similar
+ bool CheckSameType(const IBase& 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 IAdministrator* GetIAdministrator() const;
+
+ public:
+ virtual ~IBase();
+
+ // noncopyable
+ IBase(const IBase&) = delete;
+ IBase& operator=(const IBase&) = delete;
+
+ // operators potentially used by IAdministrator implementations, so have to be defined
+ virtual bool operator==(const IBase& rCmp) const;
+ virtual bool operator<(const IBase& rCmp) const;
+ virtual size_t GetUniqueKey() const;
+
+ // 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 IBase::SharedPtr&'
+ // 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
+ // single global default instance.
+ // Remember that there *will* also be static, typed versions of this call
+ // in derived Item(s), see IBaseStaticHelper for reference
+ bool IsDefault() const;
+ const SharedPtr& GetDefault() const;
+
+ // check Administrated flag
+ bool IsAdministrated() const
+ {
+ return m_bAdministrated;
+ }
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+#endif // INCLUDED_ITEM_BASE_IBASE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/item/base/IBaseStaticHelper.hxx b/include/item/base/IBaseStaticHelper.hxx
new file mode 100644
index 000000000000..3b79fc31acc8
--- /dev/null
+++ b/include/item/base/IBaseStaticHelper.hxx
@@ -0,0 +1,93 @@
+/* -*- 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_IBASESTATICHELPER_HXX
+#define INCLUDED_ITEM_BASE_IBASESTATICHELPER_HXX
+
+#include <item/base/IBase.hxx>
+#include <item/base/IAdministrator.hxx>
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ // Template class which supports Item implementations using IBase.
+ // It allows automatic creation of default static methods. To keep
+ // things simple, it directly derives from ::IBase already.
+ // It provides implementation of all static typed stuff needed to
+ // implement and make available the single global static IAdministrator
+ // 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 IAdministrator.hxx and
+ // - IAdministrator_set
+ // - IAdministrator_unordered_set
+ // - IAdministrator_vector
+ // and the explanations/preconditions for their usage.
+ // It also defines a convenient SharedPtr type for access for each derived type
+ // of Item.
+ template< class TargetType, typename AdminType > class IBaseStaticHelper : public IBase
+ {
+ public:
+ // SharedPtr typedef to be used handling instances of given type
+ typedef std::shared_ptr<const TargetType> SharedPtr;
+
+ protected:
+ static IAdministrator& GetStaticAdmin()
+ {
+ static AdminType aAdmin(new TargetType());
+ return aAdmin;
+ }
+
+ virtual IAdministrator* GetIAdministrator() const override
+ {
+ return &GetStaticAdmin();
+ }
+
+ public:
+ // we *could* have a method like below that is able to return
+ // a non-static_pointer_cast value, thus allowing to return
+ // it as const& to the SharedPtr and to avoid constructing the
+ // TargetType::SharedPtr (less overhead). This could be used e.g.
+ // in Set::SetItem calls.
+ // Disadvantage is that the User/Programmer using it would have
+ // to be very aware what he is doing - to avoid confusion, I
+ // decided to *not* offer this currently.
+ //
+ // static const IBase::SharedPtr& getStaticDefault()
+ // {
+ // return std::static_pointer_cast<const TargetType>(GetStaticAdmin().GetDefault());
+ // }
+
+ static std::shared_ptr<const TargetType> GetDefault()
+ {
+ return std::static_pointer_cast<const TargetType>(GetStaticAdmin().GetDefault());
+ }
+
+ static bool IsDefault(const std::shared_ptr<const TargetType>& rCandidate)
+ {
+ return rCandidate && GetStaticAdmin().IsDefault(rCandidate.get());
+ }
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+#endif // INCLUDED_ITEM_BASE_IBASESTATICHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/item/base/ISet.hxx b/include/item/base/ISet.hxx
new file mode 100644
index 000000000000..c1562225b3e1
--- /dev/null
+++ b/include/item/base/ISet.hxx
@@ -0,0 +1,301 @@
+/* -*- 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_ISET_HXX
+#define INCLUDED_ITEM_BASE_ISET_HXX
+
+#include <item/base/ModelSpecificIValues.hxx>
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Temporary migration infos:
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// -> NO usage of &op, so NOT used as flag values anywhere (!)
+// enum class SfxItemState {
+// /** Specifies an unknown state. */
+// UNKNOWN = 0,
+// /** Specifies that the property is currently disabled. */
+// DISABLED = 0x0001,
+// /** Specifies that the property is currently read-only. */
+// READONLY = 0x0002,
+// /** Specifies that the property is currently in a don't care state.
+// * <br/>
+// * This is normally used if a selection provides more than one state
+// * for a property at the same time.
+// */
+// DONTCARE = 0x0010,
+// /** Specifies that the property is currently in a default state. */
+// DEFAULT = 0x0020,
+// /** The property has been explicitly set to a given value hence we know
+// * we are not taking the default value.
+// * <br/>
+// * For example, you may want to get the font color and it might either
+// * be the default one or one that has been explicitly set.
+// */
+// SET = 0x0040
+// };
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// SfxItemSet::GetItemState:
+// SfxItemState::UNKNOWN -> not in any range
+// SfxItemState::DEFAULT -> nullptr in range
+// SfxItemState::DONTCARE -> IsInvalidItem -> pItem == INVALID_POOL_ITEM -> reinterpret_cast<SfxPoolItem*>(-1)
+// SfxItemState::DISABLED -> IsVoidItem() -> instance of SfxVoidItem, virtual bool IsVoidItem()
+// SfxItemState::SET -> in range and ptr != nullptr && ptr != -1 && ptr != SfxVoidItem
+// NOT USED: SfxItemState::READONLY
+//
+// SfxItemState::READONLY
+// 28 hits in code testing it, but never set ?!?!
+//
+// 16: interpreted as 'SfxItemState::DISABLED'
+// 8: interpreted as 'SfxItemState::SET'
+// 1: eState <= SfxItemState::READONLY
+// 1: else ... -> used as DISABLED/READ_ONLY (with comment 'SfxItemState::DISABLED or SfxItemState::READONLY')
+// 1: typecheck UNO API to throw css::uno::RuntimeException
+// 1: name extract ItemBrowser
+// check with '//UU' if needed -> testbuild OK
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// C:\lo\work01\workdir\UnoApiHeadersTarget\offapi\comprehensive\com\sun\star\frame\status\ItemState.hdl
+// only used: css::frame::status::ItemState::DONT_CARE;
+// namespace com { namespace sun { namespace star { namespace frame { namespace status { namespace ItemState {
+// static const ::sal_Int16 DEFAULT_VALUE = (sal_Int16)32;
+// static const ::sal_Int16 DISABLED = (sal_Int16)1;
+// static const ::sal_Int16 DONT_CARE = (sal_Int16)16;
+// static const ::sal_Int16 READ_ONLY = (sal_Int16)2;
+// static const ::sal_Int16 SET = (sal_Int16)64;
+// static const ::sal_Int16 UNKNOWN = (sal_Int16)0;
+//
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ class ITEM_DLLPUBLIC ISet : public std::enable_shared_from_this<ISet>
+ {
+ public:
+ // SharedPtr typedef to be used handling instances of this type
+ typedef std::shared_ptr<ISet> SharedPtr;
+
+ // The states that an Item (IBase) can have in an ISet
+ enum class IState
+ {
+ /** Specifies that the property is currently disabled. */
+ DISABLED = 0x0001,
+
+ /** Specifies that the property is currently in a don't care state.
+ * <br/>
+ * This is normally used if a selection provides more than one state
+ * for a property at the same time.
+ */
+ DONTCARE = 0x0010,
+
+ /** Specifies that the property is currently in a default state. */
+ DEFAULT = 0x0020,
+
+ /** The property has been explicitly set to a given value hence we know
+ * we are not taking the default value.
+ * <br/>
+ * For example, you may want to get the font color and it might either
+ * be the default one or one that has been explicitly set.
+ */
+ SET = 0x0040
+ };
+
+ // helper class for returning result pairs for calls to ISet::StateAndItem
+ // that contain the IState and the IBase at the same time.
+ // IBase aItem will be set when IState is either SET or DEFAULT. The
+ // DEFAULT will be the evtl. replaced one from ISet (see
+ // ModelSpecificIValues)
+ template< class TargetType > class StateAndItem
+ {
+ private:
+ typedef std::shared_ptr<const TargetType> SharedPtr;
+
+ const IState m_aIState;
+ const SharedPtr m_aItem;
+
+ public:
+ StateAndItem(IState aIState, const SharedPtr& rItem)
+ : m_aIState(aIState),
+ m_aItem(rItem)
+ {
+ }
+
+ IState GetIState() const { return m_aIState; }
+ const SharedPtr& GetItem() const { return m_aItem; }
+ const TargetType* GetItemInstance() const { return m_aItem ? m_aItem.get() : nullptr; }
+
+ bool HasItem() const { return bool(m_aItem); }
+ bool IsSet() const { return IState::SET == m_aIState; }
+ bool IsDefault() const { return IState::DEFAULT == m_aIState; }
+ bool IsDontCare() const { return IState::DONTCARE == m_aIState; }
+ bool IsDisabled() const { return IState::DISABLED == m_aIState; }
+ };
+
+ private:
+ // helper class for an ImplInvalidateItem - placeholder for InvaidateState
+ // SfxItemState::DONTCARE -> IsInvalidItem -> pItem == INVALID_POOL_ITEM -> reinterpret_cast<SfxPoolItem*>(-1)
+ class ImplInvalidateItem : public IBase
+ {
+ public:
+ ImplInvalidateItem() = default;
+ };
+
+ // helper class for a ImplDisableItem - placeholder for InvaidateState
+ // SfxItemState::DISABLED -> IsVoidItem() -> instance of SfxVoidItem, virtual bool IsVoidItem()
+ class ImplDisableItem : public IBase
+ {
+ public:
+ ImplDisableItem() = default;
+ };
+
+ // the Parent of this ISet
+ SharedPtr m_aParent;
+
+ // model-specific ItemValues, e.g. overridden defaults.
+ // Maybe set or not set, empty allowed here.
+ ModelSpecificIValues::SharedPtr m_aModelSpecificIValues;
+
+ // the items as content
+ std::unordered_map<size_t, IBase::SharedPtr> m_aItems;
+
+ // single global static instance for helper class ImplInvalidateItem
+ static const IBase::SharedPtr& getInvalidateItem()
+ {
+ static IBase::SharedPtr aImplInvalidateItem(new ImplInvalidateItem());
+
+ return aImplInvalidateItem;
+ }
+
+ // single global static instance for helper class ImplDisableItem
+ static const IBase::SharedPtr& getDisableItem()
+ {
+ static IBase::SharedPtr aImplDisableItem(new ImplDisableItem());
+
+ return aImplDisableItem;
+ }
+
+ protected:
+ // constructor - protected BY DEFAULT - do NOT CHANGE (!)
+ // Use ::Create(...) method instead
+ ISet(const ModelSpecificIValues::SharedPtr& rModelSpecificIValues);
+
+ public:
+ virtual ~ISet();
+
+ // noncopyable
+ ISet(const ISet&) = delete;
+ ISet& operator=(const ISet&) = delete;
+
+ // parent
+ void SetParent(const SharedPtr& rNewParent);
+ const SharedPtr& GetParent() const;
+
+ static SharedPtr Create(const ModelSpecificIValues::SharedPtr& rModelSpecificIValues);
+
+ const ModelSpecificIValues::SharedPtr& GetModelSpecificIValues() const;
+
+ template< typename TItem > void InvalidateItem()
+ {
+ const size_t hash_code(typeid(TItem).hash_code());
+
+ m_aItems[hash_code] = getInvalidateItem();
+ }
+
+ template< typename TItem > void DisableItem()
+ {
+ const size_t hash_code(typeid(TItem).hash_code());
+
+ m_aItems[hash_code] = getDisableItem();
+ }
+
+ template< typename TItem > std::shared_ptr<TItem> GetDefault() const
+ {
+ // get static available default as instance
+ IBase::SharedPtr aRetval(TItem::GetDefault());
+ assert(aRetval && "empty IBase::SharedPtr not allowed for default (!)");
+
+ if(m_aModelSpecificIValues)
+ {
+ // may use model-specific default, get from helper
+ // helper *will* fallback to IBase default
+ aRetval = m_aModelSpecificIValues->GetDefault(aRetval);
+ }
+
+ return std::static_pointer_cast<TItem>(aRetval);
+ }
+
+ void SetItem(const IBase::SharedPtr& rItem);
+
+ template< typename TItem > StateAndItem<TItem> GetStateAndItem(bool bSearchParent = true) const
+ {
+ const size_t hash_code(typeid(TItem).hash_code());
+ const auto aRetval(m_aItems.find(hash_code));
+
+ if(aRetval != m_aItems.end()) // && aRetval->second)
+ {
+ assert(aRetval->second && "empty IBase::SharedPtr set in ISet (!)");
+
+ if(aRetval->second.get() == getInvalidateItem().get())
+ {
+ // SfxItemState::DONTCARE
+ return StateAndItem<TItem>(IState::DONTCARE, std::shared_ptr<TItem>());
+ }
+
+ if(aRetval->second.get() == getDisableItem().get())
+ {
+ // SfxItemState::DISABLED
+ return StateAndItem<TItem>(IState::DISABLED, std::shared_ptr<TItem>());
+ }
+
+ // SfxItemState::SET
+ return StateAndItem<TItem>(IState::SET, std::static_pointer_cast<TItem>(aRetval->second));
+ }
+
+ // not set
+ if(bSearchParent && m_aParent)
+ {
+ // continue searching in parent
+ return m_aParent->GetStateAndItem<TItem>(true);
+ }
+ else
+ {
+ // SfxItemState::DEFAULT
+ return StateAndItem<TItem>(IState::DEFAULT, GetDefault<TItem>());
+ }
+ }
+
+ template< typename TItem > bool ClearItem()
+ {
+ const size_t hash_code(typeid(TItem).hash_code());
+
+ return (0 != m_aItems.erase(hash_code));
+ }
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+#endif // INCLUDED_ITEM_BASE_ISET_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/item/base/ModelSpecificIValues.hxx b/include/item/base/ModelSpecificIValues.hxx
new file mode 100644
index 000000000000..9876a5842a07
--- /dev/null
+++ b/include/item/base/ModelSpecificIValues.hxx
@@ -0,0 +1,76 @@
+/* -*- 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_MODELSPECIFICIVALUES_HXX
+#define INCLUDED_ITEM_BASE_MODELSPECIFICIVALUES_HXX
+
+#include <memory>
+#include <item/itemdllapi.h>
+#include <unordered_map>
+#include <item/base/IBase.hxx>
+#include <sal/types.h>
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ // Model-specific ItemValues, e.g. overridden defaults.
+ // - override defaults per Set (already in place)
+ // - maybe: old SfxItemInfo replacement which is a mapping
+ // between SlotID and WhichID
+ // - maybe: ItemNames - currently in ::TakeItemName and others
+ // - maybe: hold MapMode info to allow correct GetPresentation
+ // executions
+ class ITEM_DLLPUBLIC ModelSpecificIValues : public std::enable_shared_from_this<ModelSpecificIValues>
+ {
+ public:
+ // SharedPtr typedef to be used handling instances of this type
+ typedef std::shared_ptr<ModelSpecificIValues> SharedPtr;
+
+ private:
+ // the alternative default items
+ std::unordered_map<size_t, IBase::SharedPtr> m_aAlternativeItems;
+
+ protected:
+ // constructor - protected BY DEFAULT - do NOT CHANGE (!)
+ // Use ::Create(...) method instead
+ ModelSpecificIValues();
+
+ public:
+ virtual ~ModelSpecificIValues();
+
+ // noncopyable
+ ModelSpecificIValues(const ModelSpecificIValues&) = delete;
+ ModelSpecificIValues& operator=(const ModelSpecificIValues&) = delete;
+
+ // create instance
+ static SharedPtr Create();
+
+ // AlternativeDefault interface
+ void SetAlternativeDefaultItem(const IBase::SharedPtr& rItem);
+ bool IsDefault(const IBase::SharedPtr& rItem) const;
+ const IBase::SharedPtr& GetDefault(const IBase::SharedPtr& rItem) const;
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+#endif // INCLUDED_ITEM_BASE_MODELSPECIFICIVALUES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/item/itemdllapi.h b/include/item/itemdllapi.h
new file mode 100644
index 000000000000..489563042cfe
--- /dev/null
+++ b/include/item/itemdllapi.h
@@ -0,0 +1,24 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_ITEM_ITEMDLLAPI_H
+#define INCLUDED_ITEM_ITEMDLLAPI_H
+
+#include <sal/types.h>
+
+#if defined(ITEM_DLLIMPLEMENTATION)
+#define ITEM_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define ITEM_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+#define ITEM_DLLPRIVATE SAL_DLLPRIVATE
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/item/simple/CntInt16.hxx b/include/item/simple/CntInt16.hxx
new file mode 100644
index 000000000000..6be33aabab51
--- /dev/null
+++ b/include/item/simple/CntInt16.hxx
@@ -0,0 +1,50 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_ITEM_SIMPLE_CNTINT16_HXX
+#define INCLUDED_ITEM_SIMPLE_CNTINT16_HXX
+
+#include <item/base/IBaseStaticHelper.hxx>
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ // example for SfxInt16Item
+ // It uses IAdministrator_set to provide an Administrator using
+ // a sorted list for fast accesses. This requires ::operator< to be
+ // implemented.
+ class CntInt16;
+ typedef IBaseStaticHelper<CntInt16, IAdministrator_set> CntInt16StaticHelper;
+
+ class ITEM_DLLPUBLIC CntInt16 : public CntInt16StaticHelper
+ {
+ private:
+ sal_Int16 m_nValue;
+
+ protected:
+ friend CntInt16StaticHelper;
+
+ CntInt16(sal_Int16 nValue = 0);
+
+ public:
+ virtual ~CntInt16();
+
+ static CntInt16::SharedPtr Create(sal_Int16 nValue);
+ virtual bool operator==(const IBase& rCandidate) const override;
+ virtual bool operator<(const IBase& rCandidate) const override;
+ sal_Int16 GetValue() const;
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+#endif // INCLUDED_ITEM_SIMPLE_CNTINT16_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/item/simple/CntOUString.hxx b/include/item/simple/CntOUString.hxx
new file mode 100644
index 000000000000..b9b509b43e7f
--- /dev/null
+++ b/include/item/simple/CntOUString.hxx
@@ -0,0 +1,51 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_ITEM_SIMPLE_CNTOUSTRING_HXX
+#define INCLUDED_ITEM_SIMPLE_CNTOUSTRING_HXX
+
+#include <item/base/IBaseStaticHelper.hxx>
+#include <rtl/ustring.hxx>
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ // example for OUStringItem
+ // 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 IBaseStaticHelper<CntOUString, IAdministrator_unordered_set> CntOUStringStaticHelper;
+
+ class ITEM_DLLPUBLIC CntOUString : public CntOUStringStaticHelper
+ {
+ private:
+ rtl::OUString m_aValue;
+
+ protected:
+ friend CntOUStringStaticHelper;
+
+ CntOUString(const rtl::OUString& rValue = rtl::OUString());
+
+ public:
+ virtual ~CntOUString();
+
+ static std::shared_ptr<const CntOUString> Create(const rtl::OUString& rValue);
+ virtual bool operator==(const IBase& rCandidate) const override;
+ virtual size_t GetUniqueKey() const override;
+ const rtl::OUString& GetValue() const;
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+#endif // INCLUDED_ITEM_SIMPLE_CNTOUSTRING_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/item/CppunitTest_item.mk b/item/CppunitTest_item.mk
new file mode 100644
index 000000000000..84b53cea5807
--- /dev/null
+++ b/item/CppunitTest_item.mk
@@ -0,0 +1,28 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,item))
+
+$(eval $(call gb_CppunitTest_use_external,item,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,item))
+
+$(eval $(call gb_CppunitTest_use_libraries,item,\
+ item \
+ comphelper \
+ cppu \
+ cppuhelper \
+ sal \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,item,\
+ item/test/ItemTest \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/item/Library_item.mk b/item/Library_item.mk
new file mode 100644
index 000000000000..7297d680ee55
--- /dev/null
+++ b/item/Library_item.mk
@@ -0,0 +1,42 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Library_Library,item))
+
+$(eval $(call gb_Library_use_external,item,boost_headers))
+
+$(eval $(call gb_Library_set_precompiled_header,item,$(SRCDIR)/item/inc/pch/precompiled_item))
+
+$(eval $(call gb_Library_use_sdk_api,item))
+
+$(eval $(call gb_Library_use_libraries,item,\
+ cppu \
+ cppuhelper \
+ sal \
+))
+
+#$(eval $(call gb_Library_set_include,item,\
+# -I$(SRCDIR)/item/source/inc \
+# $$(INCLUDE) \
+#))
+
+$(eval $(call gb_Library_add_defs,item,\
+ -DITEM_DLLIMPLEMENTATION \
+))
+
+$(eval $(call gb_Library_add_exception_objects,item,\
+ item/source/base/IBase \
+ item/source/base/IAdministrator \
+ item/source/base/ModelSpecificIValues \
+ item/source/base/ISet \
+ item/source/simple/CntInt16 \
+ item/source/simple/CntOUString \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/item/Makefile b/item/Makefile
new file mode 100644
index 000000000000..0997e628485b
--- /dev/null
+++ b/item/Makefile
@@ -0,0 +1,14 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/item/Module_item.mk b/item/Module_item.mk
new file mode 100644
index 000000000000..48c666c19439
--- /dev/null
+++ b/item/Module_item.mk
@@ -0,0 +1,20 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Module_Module,item))
+
+$(eval $(call gb_Module_add_targets,item,\
+ Library_item \
+))
+
+$(eval $(call gb_Module_add_check_targets,item,\
+ CppunitTest_item \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/item/README b/item/README
new file mode 100644
index 000000000000..b0d552dd28b9
--- /dev/null
+++ b/item/README
@@ -0,0 +1,6 @@
+All necessary low-level definitions and tools to work with
+- Item::IBase
+- Item::IAdministrator
+- Item::ModelSpecificIValues
+- Item::ISet
+This is planned/developed to be a replacement for SfxPoolItem/SfxItemSet/SfxItemPool
diff --git a/item/inc/pch/precompiled_item.cxx b/item/inc/pch/precompiled_item.cxx
new file mode 100644
index 000000000000..b917e720636d
--- /dev/null
+++ b/item/inc/pch/precompiled_item.cxx
@@ -0,0 +1,12 @@
+/* -*- 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 "precompiled_item.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/item/inc/pch/precompiled_item.hxx b/item/inc/pch/precompiled_item.hxx
new file mode 100644
index 000000000000..4b130dcbd042
--- /dev/null
+++ b/item/inc/pch/precompiled_item.hxx
@@ -0,0 +1,26 @@
+/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it
+ manually (such as when an include file has been moved/renamed/removed). All such
+ manual changes will be rewritten by the next run of update_pch.sh (which presumably
+ also fixes all possible problems, so it's usually better to use it).
+
+ Generated on 2017-09-20 22:51:33 using:
+ ./bin/update_pch basegfx basegfx --cutoff=3 --exclude:system --exclude:module --include:local
+
+ If after updating build fails, use the following command to locate conflicting headers:
+ ./bin/update_pch_bisect ./basegfx/inc/pch/precompiled_basegfx.hxx "make basegfx.build" --find-conflicts
+*/
+
+#include <algorithm>
+#include <item/base/IBase.hxx>
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/item/source/base/IAdministrator.cxx b/item/source/base/IAdministrator.cxx
new file mode 100644
index 000000000000..9d841491124f
--- /dev/null
+++ b/item/source/base/IAdministrator.cxx
@@ -0,0 +1,292 @@
+/* -*- 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 <item/base/IAdministrator.hxx>
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ void IAdministrator::SetAdministrated(const IBase& rIBase) const
+ {
+ const_cast<IBase&>(rIBase).m_bAdministrated = true;
+ }
+
+ IAdministrator::IAdministrator(const IBase* pDefault)
+ : m_aDefault(IBase::SharedPtr(pDefault))
+ {
+ assert(pDefault != nullptr && "nullptr not allowed, default *is* required (!)");
+ }
+
+ IAdministrator::~IAdministrator()
+ {
+ }
+
+ void IAdministrator::HintExpired(const IBase* /*pIBase*/)
+ {
+ // Default does nothing and will be triggered from m_aDefault being destructed
+ // using the HintExpired calls in the administrated classes. This happens due to
+ // m_aDefault being destroyed from ~IAdministrator() above as last thing in
+ // IAdministrator cleanup, the derived classes are no longer available at that time.
+ }
+
+ const IBase::SharedPtr& IAdministrator::GetDefault() const
+ {
+ return m_aDefault;
+ }
+
+ bool IAdministrator::IsDefault(const IBase* 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 IBase* pDefault)
+ : IAdministrator(pDefault),
+ m_aEntries()
+ {
+ }
+
+ IBase::SharedPtr IAdministrator_set::Create(const IBase* pIBase)
+ {
+ assert(pIBase != nullptr && "nullptr not allowed (!)");
+
+ if(IsDefault(pIBase))
+ {
+ // if the Item to-be-created equals default, delete it and
+ // use the existing single global default
+ delete pIBase;
+ return GetDefault();
+ }
+
+ // check for existance
+ auto ExistingEntry(m_aEntries.find(pIBase));
+
+ if(m_aEntries.end() != ExistingEntry)
+ {
+ // if the Item to-be-created exists already, delete it and
+ // use the existing instance
+ delete pIBase;
+ return (*ExistingEntry)->shared_from_this();
+ }
+ else
+ {
+ // start using offered instance and administrate it from now
+ SetAdministrated(*pIBase);
+ m_aEntries.insert(pIBase);
+ return IBase::SharedPtr(pIBase);
+ }
+ }
+
+ void IAdministrator_set::HintExpired(const IBase* pIBase)
+ {
+ // called from ::~Item. This happens in two cases:
+ // (1) a temporary Item instance gets deleted
+ // (2) last shared_ptr was deleted
+ // The caller should have already checked the
+ // Administrated-flag, so only administrated instances
+ // of IBase should be handled here which is case (2)
+ assert(pIBase != nullptr && "nullptr not allowed (!)");
+ assert(pIBase->IsAdministrated() && "call only for administrated instances of IBase (!)");
+ m_aEntries.erase(pIBase);
+ }
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ IAdministrator_unordered_set::IAdministrator_unordered_set(const IBase* pDefault)
+ : IAdministrator(pDefault),
+ m_aEntries()
+ {
+ }
+
+ IBase::SharedPtr IAdministrator_unordered_set::Create(const IBase* pIBase)
+ {
+ assert(pIBase != nullptr && "nullptr not allowed (!)");
+
+ if(IsDefault(pIBase))
+ {
+ // if the Item to-be-created equals default, delete it and
+ // use the existing single global default
+ delete pIBase;
+ return GetDefault();
+ }
+
+ // check for existance
+ auto ExistingEntry(m_aEntries.find(pIBase));
+
+ if(m_aEntries.end() != ExistingEntry)
+ {
+ // if the Item to-be-created exists already, delete it and
+ // use the existing instance
+ delete pIBase;
+ return (*ExistingEntry)->shared_from_this();
+ }
+ else
+ {
+ // start using offered instance and administrate it from now
+ SetAdministrated(*pIBase);
+ m_aEntries.insert(pIBase);
+ return IBase::SharedPtr(pIBase);
+ }
+ }
+
+ void IAdministrator_unordered_set::HintExpired(const IBase* pIBase)
+ {
+ // called from ::~Item. This happens in two cases:
+ // (1) a temporary Item instance gets deleted
+ // (2) last shared_ptr was deleted
+ // The caller should have already checked the
+ // Administrated-flag, so only administrated instances
+ // of IBase should be handled here which is case (2)
+ assert(pIBase != nullptr && "nullptr not allowed (!)");
+ assert(pIBase->IsAdministrated() && "call only for administrated instances of IBase (!)");
+ m_aEntries.erase(pIBase);
+ }
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ std::vector<const IBase*>::iterator IAdministrator_vector::find(const IBase* pIBase)
+ {
+ // find has to linearly traverse through instances and use operator==
+ assert(pIBase != nullptr && "nullptr not allowed (!)");
+ for(std::vector<const IBase*>::iterator candidate(m_aEntries.begin()); candidate != m_aEntries.end(); candidate++)
+ {
+ if(*candidate != nullptr)
+ {
+ if(*candidate == pIBase || (*candidate)->operator==(*pIBase))
+ {
+ return candidate;
+ }
+ }
+ }
+
+ return m_aEntries.end();
+ }
+
+ void IAdministrator_vector::insert(const IBase* pIBase)
+ {
+ // insert reuses free slots if there are some, else
+ // appends to existing vector
+ assert(pIBase != nullptr && "nullptr not allowed (!)");
+ if(m_aFreeSlots.empty())
+ {
+ m_aEntries.push_back(pIBase);
+ return;
+ }
+
+ const size_t freeIndex(m_aFreeSlots.back());
+ m_aFreeSlots.pop_back();
+ m_aEntries[freeIndex] = pIBase;
+ return;
+ }
+
+ void IAdministrator_vector::erase(std::vector<const IBase*>::iterator& rIter)
+ {
+ if(rIter != m_aEntries.end())
+ {
+ // erase does not modify the vector's size, just resets the
+ // pointer and remembers a new free slot.
+ m_aFreeSlots.push_back(std::distance(m_aEntries.begin(), rIter));
+ *rIter = nullptr;
+
+ // at some useful criteria, re-organize the vector to safe space and
+ // runtime for ::find
+ if(m_aEntries.size() > 8
+ && m_aEntries.size() > m_aFreeSlots.size()
+ && m_aFreeSlots.size() * 2 > m_aEntries.size())
+ {
+ std::vector<const IBase*> aNewEntries;
+ aNewEntries.reserve(m_aEntries.size() - m_aFreeSlots.size());
+
+ for(std::vector<const IBase*>::iterator candidate(m_aEntries.begin()); candidate != m_aEntries.end(); candidate++)
+ {
+ if(*candidate != nullptr)
+ {
+ aNewEntries.push_back(*candidate);
+ }
+ }
+
+ m_aEntries = aNewEntries;
+ m_aFreeSlots.clear();
+ }
+ else if(m_aFreeSlots.size() == m_aEntries.size())
+ {
+ m_aEntries.clear();
+ m_aFreeSlots.clear();
+ }
+ }
+ }
+
+ IAdministrator_vector::IAdministrator_vector(const IBase* pDefault)
+ : IAdministrator(pDefault),
+ m_aEntries(),
+ m_aFreeSlots()
+ {
+ }
+
+ IBase::SharedPtr IAdministrator_vector::Create(const IBase* pIBase)
+ {
+ assert(pIBase != nullptr && "nullptr not allowed (!)");
+
+ if(IsDefault(pIBase))
+ {
+ // if the Item to-be-created equals default, delete it and
+ // use the existing single global default
+ delete pIBase;
+ return GetDefault();
+ }
+
+ // check for existance
+ auto ExistingEntry(find(pIBase));
+
+ if(m_aEntries.end() != ExistingEntry)
+ {
+ // if the Item to-be-created exists already, delete it and
+ // use the existing instance
+ delete pIBase;
+ return (*ExistingEntry)->shared_from_this();
+ }
+ else
+ {
+ // start using offered instance and administrate it from now
+ SetAdministrated(*pIBase);
+ insert(pIBase);
+ return IBase::SharedPtr(pIBase);
+ }
+ }
+
+ void IAdministrator_vector::HintExpired(const IBase* pIBase)
+ {
+ // called from ::~Item. This happens in two cases:
+ // (1) a temporary Item instance gets deleted
+ // (2) last shared_ptr was deleted
+ // The caller should have already checked the
+ // Administrated-flag, so only administrated instances
+ // of IBase should be handled here which is case (2)
+ assert(pIBase != nullptr && "nullptr not allowed (!)");
+ assert(pIBase->IsAdministrated() && "call only for administrated instances of IBase (!)");
+ auto iter(find(pIBase));
+ erase(iter);
+ }
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/item/source/base/IBase.cxx b/item/source/base/IBase.cxx
new file mode 100644
index 000000000000..d34e715775b1
--- /dev/null
+++ b/item/source/base/IBase.cxx
@@ -0,0 +1,206 @@
+/* -*- 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 <item/base/IBase.hxx>
+#include <item/base/IAdministrator.hxx>
+#include <cassert>
+
+///////////////////////////////////////////////////////////////////////////////
+// export CXXFLAGS=-DENABLE_ITEMS
+/*
+class SbxItem : public SfxPoolItem
+class SvxChartColorTableItem : public SfxPoolItem
+class DriverPoolingSettingsItem final : public SfxPoolItem
+class DatabaseMapItem final : public SfxPoolItem
+class DbuTypeCollectionItem : public SfxPoolItem
+class OptionalBoolItem : public SfxPoolItem
+class OStringListItem : public SfxPoolItem
+class AVMEDIA_DLLPUBLIC MediaItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxBoxItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxBoxInfoItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxBrushItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxBulletItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxColorItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxFontHeightItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxFieldItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxFontListItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxFontItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxHyphenZoneItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxLineItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxLRSpaceItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxNumBulletItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SfxHyphenRegionItem: public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxProtectItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxSizeItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxTabStopItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxTwoLinesItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvxULSpaceItem : public SfxPoolItem
+class EDITENG_DLLPUBLIC SvXMLAttrContainerItem: public SfxPoolItem
+class SFX2_DLLPUBLIC SfxLinkItem : public SfxPoolItem
+class SFX2_DLLPUBLIC SfxEventNamesItem : public SfxPoolItem
+class SFX2_DLLPUBLIC SfxFrameItem: public SfxPoolItem
+class SFX2_DLLPUBLIC SfxUnoAnyItem : public SfxPoolItem
+class SFX2_DLLPUBLIC SfxUnoFrameItem : public SfxPoolItem
+class SFX2_DLLPUBLIC SfxMacroInfoItem: public SfxPoolItem
+class SFX2_DLLPUBLIC SfxObjectItem: public SfxPoolItem
+class SFX2_DLLPUBLIC SfxObjectShellItem: public SfxPoolItem
+class SFX2_DLLPUBLIC SfxViewFrameItem: public SfxPoolItem
+class SFX2_DLLPUBLIC SfxWatermarkItem: public SfxPoolItem
+class SVL_DLLPUBLIC SfxEnumItemInterface: public SfxPoolItem
+class SVL_DLLPUBLIC CntByteItem: public SfxPoolItem
+class SVL_DLLPUBLIC CntUInt16Item: public SfxPoolItem
+class SVL_DLLPUBLIC CntInt32Item: public SfxPoolItem
+class SVL_DLLPUBLIC CntUInt32Item: public SfxPoolItem
+class SVL_DLLPUBLIC CntUnencodedStringItem: public SfxPoolItem
+class SVL_DLLPUBLIC SfxFlagItem: public SfxPoolItem
+class SVL_DLLPUBLIC SfxGlobalNameItem: public SfxPoolItem
+class SVL_DLLPUBLIC SfxGrabBagItem : public SfxPoolItem
+class SVL_DLLPUBLIC SfxIntegerListItem : public SfxPoolItem
+class SVL_DLLPUBLIC SfxInt64Item : public SfxPoolItem
+class SVL_DLLPUBLIC SfxInt16Item: public SfxPoolItem
+class SVL_DLLPUBLIC SfxLockBytesItem : public SfxPoolItem
+class SVL_DLLPUBLIC SvxMacroItem: public SfxPoolItem
+class SVL_DLLPUBLIC SfxVoidItem final: public SfxPoolItem
+class SVL_DLLPUBLIC SfxSetItem: public SfxPoolItem
+class SVL_DLLPUBLIC SfxPointItem: public SfxPoolItem
+class SVL_DLLPUBLIC SfxRectangleItem: public SfxPoolItem
+class SVL_DLLPUBLIC SfxRangeItem : public SfxPoolItem
+class SVL_DLLPUBLIC SfxStringListItem : public SfxPoolItem
+class SVL_DLLPUBLIC SfxVisibilityItem: public SfxPoolItem
+class SVX_DLLPUBLIC AffineMatrixItem : public SfxPoolItem
+class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxMarginItem: public SfxPoolItem
+class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxDoubleItem : public SfxPoolItem
+class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxClipboardFormatItem : public SfxPoolItem
+class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxColorListItem: public SfxPoolItem
+class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxGradientListItem : public SfxPoolItem
+class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxHatchListItem : public SfxPoolItem
+class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxBitmapListItem : public SfxPoolItem
+class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxPatternListItem : public SfxPoolItem
+class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxDashListItem : public SfxPoolItem
+class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLineEndListItem : public SfxPoolItem
+class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxB3DVectorItem : public SfxPoolItem
+class SVX_DLLPUBLIC SvxGalleryItem : public SfxPoolItem
+class SVX_DLLPUBLIC SvxHyperlinkItem : public SfxPoolItem
+class SVX_DLLPUBLIC SvxNumberInfoItem : public SfxPoolItem
+class SVX_DLLPUBLIC OfaPtrItem : public SfxPoolItem
+class OfaRefItem : public SfxPoolItem
+class SVX_DLLPUBLIC SvxGridItem : public SvxOptionsGrid, public SfxPoolItem
+class SVX_DLLPUBLIC SvxPageItem: public SfxPoolItem
+class SVX_DLLPUBLIC SvxLongLRSpaceItem : public SfxPoolItem
+class SVX_DLLPUBLIC SvxLongULSpaceItem : public SfxPoolItem
+class SVX_DLLPUBLIC SvxPagePosSizeItem : public SfxPoolItem
+class SVX_DLLPUBLIC SvxColumnItem : public SfxPoolItem
+class SVX_DLLPUBLIC SvxObjectItem : public SfxPoolItem
+class SVX_DLLPUBLIC SdrCustomShapeGeometryItem : public SfxPoolItem
+class SVX_DLLPUBLIC SvxSmartTagItem : public SfxPoolItem
+class SVX_DLLPUBLIC SvxGraphicItem: public SfxPoolItem
+class SdrFractionItem: public SfxPoolItem {
+class SC_DLLPUBLIC ScPageHFItem : public SfxPoolItem
+class SC_DLLPUBLIC ScPageScaleToItem : public SfxPoolItem
+class ScCondFormatItem : public SfxPoolItem
+class SC_DLLPUBLIC ScTpDefaultsItem : public SfxPoolItem
+class SC_DLLPUBLIC ScTpCalcItem : public SfxPoolItem
+class SC_DLLPUBLIC ScTpFormulaItem : public SfxPoolItem
+class SC_DLLPUBLIC ScTpPrintItem : public SfxPoolItem
+class SC_DLLPUBLIC ScTpViewItem : public SfxPoolItem
+class ScCondFormatDlgItem : public SfxPoolItem
+class ScInputStatusItem : public SfxPoolItem
+class SC_DLLPUBLIC ScSortItem : public SfxPoolItem
+class SC_DLLPUBLIC ScQueryItem : public SfxPoolItem
+class SC_DLLPUBLIC ScSubTotalItem : public SfxPoolItem
+class SC_DLLPUBLIC ScUserListItem : public SfxPoolItem
+class ScConsolidateItem : public SfxPoolItem
+class ScPivotItem : public SfxPoolItem
+class ScSolveItem : public SfxPoolItem
+class ScTabOpItem : public SfxPoolItem
+class SD_DLLPUBLIC SdOptionsLayoutItem : public SfxPoolItem
+class SD_DLLPUBLIC SdOptionsMiscItem : public SfxPoolItem
+class SD_DLLPUBLIC SdOptionsSnapItem : public SfxPoolItem
+class SD_DLLPUBLIC SdOptionsPrintItem : public SfxPoolItem
+class SW_DLLPUBLIC SwCondCollItem : public SfxPoolItem
+class SwMsgPoolItem : public SfxPoolItem
+class SW_DLLPUBLIC SwTextGridItem : public SfxPoolItem
+class SW_DLLPUBLIC SwDocDisplayItem : public SfxPoolItem
+class SW_DLLPUBLIC SwElemItem : public SfxPoolItem
+class SW_DLLPUBLIC SwAddPrinterItem : public SfxPoolItem, public SwPrintData
+class SW_DLLPUBLIC SwShadowCursorItem : public SfxPoolItem
+class SW_DLLPUBLIC SwTestItem : public SfxPoolItem
+class SW_DLLPUBLIC SwEnvItem : public SfxPoolItem
+class SW_DLLPUBLIC SwLabItem : public SfxPoolItem
+class SW_DLLPUBLIC SwWrtShellItem: public SfxPoolItem
+class SW_DLLPUBLIC SwPageFootnoteInfoItem : public SfxPoolItem
+class SW_DLLPUBLIC SwPtrItem : public SfxPoolItem
+class SW_DLLPUBLIC SwUINumRuleItem : public SfxPoolItem
+class SW_DLLPUBLIC SwPaMItem : public SfxPoolItem
+*/
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ IBase::IBase()
+ : std::enable_shared_from_this<IBase>(),
+ m_bAdministrated(false)
+ {
+ }
+
+ bool IBase::CheckSameType(const IBase& rCmp) const
+ {
+ return typeid(rCmp) == typeid(*this);
+ }
+
+ IAdministrator* IBase::GetIAdministrator() const
+ {
+ // not intended to be used, error
+ assert(false && "IBase::GetIAdministrator call not allowed (!)");
+ return nullptr;
+ }
+
+ IBase::~IBase()
+ {
+ }
+
+ bool IBase::operator==(const IBase& rCmp) const
+ {
+ // basic implementation compares type, no data available
+ return CheckSameType(rCmp);
+ }
+
+ bool IBase::operator<(const IBase& rCmp) const
+ {
+ // basic implementation uses addresses of instances to
+ // deliver a consistent result, but should *not* be used in
+ // this form - it will not compare any data
+ assert(CheckSameType(rCmp));
+ return this < &rCmp;
+ }
+
+ size_t IBase::GetUniqueKey() const
+ {
+ // basic implementation uses adress of instance as hash, to
+ // deliver a consistent result, but should *not* be used in
+ // this form - it will not compare any data
+ return static_cast<size_t>(sal_uInt64(this));
+ }
+
+ bool IBase::IsDefault() const
+ {
+ // callback to static administrator
+ return GetIAdministrator()->IsDefault(this);
+ }
+
+ const IBase::SharedPtr& IBase::GetDefault() const
+ {
+ // callback to static administrator
+ return GetIAdministrator()->GetDefault();
+ }
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/item/source/base/ISet.cxx b/item/source/base/ISet.cxx
new file mode 100644
index 000000000000..9e5fae09d672
--- /dev/null
+++ b/item/source/base/ISet.cxx
@@ -0,0 +1,85 @@
+/* -*- 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/ISet.hxx>
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ ISet::ISet(const ModelSpecificIValues::SharedPtr& rModelSpecificIValues)
+ : std::enable_shared_from_this<ISet>(),
+ m_aParent(),
+ m_aModelSpecificIValues(rModelSpecificIValues),
+ m_aItems()
+ {
+ }
+
+ ISet::~ISet()
+ {
+ }
+
+ void ISet::SetParent(const ISet::SharedPtr& rNewParent)
+ {
+ m_aParent = rNewParent;
+ }
+
+ const ISet::SharedPtr& ISet::GetParent() const
+ {
+ return m_aParent;
+ }
+
+ ISet::SharedPtr ISet::Create(const ModelSpecificIValues::SharedPtr& rModelSpecificIValues)
+ {
+ return ISet::SharedPtr(new ISet(rModelSpecificIValues));
+ }
+
+ const ModelSpecificIValues::SharedPtr& ISet::GetModelSpecificIValues() const
+ {
+ return m_aModelSpecificIValues;
+ }
+
+ void ISet::SetItem(const IBase::SharedPtr& rItem)
+ {
+ assert(rItem && "empty IBase::SharedPtr not allowed - and should be unable to be created (!)");
+ bool bDefault(false);
+
+ // detect if rItem is default item, include evtl. model-specific
+ // defaults, not only the Item-implementation single global one
+ if(m_aModelSpecificIValues)
+ {
+ // may use model-specific default, get from helper
+ // helper *will* fallback to IBase default
+ bDefault = m_aModelSpecificIValues->IsDefault(rItem);
+ }
+ else
+ {
+ // use Item's own static global default
+ bDefault = rItem->IsDefault();
+ }
+
+ const size_t hash_code(typeid(*rItem).hash_code());
+
+ if(bDefault)
+ {
+ // SfxItemState::DEFAULT is represented by not being set
+ m_aItems.erase(hash_code);
+ }
+ else
+ {
+ // SfxItemState::SET
+ m_aItems[hash_code] = rItem;
+ }
+ }
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/item/source/base/ModelSpecificIValues.cxx b/item/source/base/ModelSpecificIValues.cxx
new file mode 100644
index 000000000000..1720a2a0ace6
--- /dev/null
+++ b/item/source/base/ModelSpecificIValues.cxx
@@ -0,0 +1,82 @@
+/* -*- 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/ModelSpecificIValues.hxx>
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ ModelSpecificIValues::ModelSpecificIValues()
+ : std::enable_shared_from_this<ModelSpecificIValues>(),
+ m_aAlternativeItems()
+ {
+ }
+
+ ModelSpecificIValues::~ModelSpecificIValues()
+ {
+ }
+
+ ModelSpecificIValues::SharedPtr ModelSpecificIValues::Create()
+ {
+ return ModelSpecificIValues::SharedPtr(new ModelSpecificIValues());
+ }
+
+ void ModelSpecificIValues::SetAlternativeDefaultItem(const IBase::SharedPtr& rItem)
+ {
+ assert(rItem && "empty IBase::SharedPtr not allowed - and should be unable to be created (!)");
+ const size_t hash_code(typeid(*rItem).hash_code());
+
+ m_aAlternativeItems[hash_code] = rItem;
+ }
+
+ bool ModelSpecificIValues::IsDefault(const IBase::SharedPtr& rItem) const
+ {
+ assert(rItem && "empty IBase::SharedPtr not allowed - and should be unable to be created (!)");
+
+ if(!m_aAlternativeItems.empty())
+ {
+ const size_t hash_code(typeid(*rItem).hash_code());
+ const auto aRetval(m_aAlternativeItems.find(hash_code));
+
+ if(aRetval != m_aAlternativeItems.end())
+ {
+ return aRetval->second.get() == rItem.get()
+ || aRetval->second->operator==(*rItem);
+ }
+ }
+
+ // use Item's own static global default
+ return rItem->IsDefault();
+ }
+
+ const IBase::SharedPtr& ModelSpecificIValues::GetDefault(const IBase::SharedPtr& rItem) const
+ {
+ assert(rItem && "empty IBase::SharedPtr not allowed - and should be unable to be created (!)");
+
+ if(!m_aAlternativeItems.empty())
+ {
+ const size_t hash_code(typeid(*rItem).hash_code());
+ const auto aRetval(m_aAlternativeItems.find(hash_code));
+
+ if(aRetval != m_aAlternativeItems.end())
+ {
+ return aRetval->second;
+ }
+ }
+
+ // loop through given instance
+ return rItem;
+ }
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/item/source/simple/CntInt16.cxx b/item/source/simple/CntInt16.cxx
new file mode 100644
index 000000000000..4ce2aa1bf198
--- /dev/null
+++ b/item/source/simple/CntInt16.cxx
@@ -0,0 +1,63 @@
+/* -*- 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/simple/CntInt16.hxx>
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ CntInt16::CntInt16(sal_Int16 nValue)
+ : CntInt16StaticHelper(),
+ m_nValue(nValue)
+ {
+ }
+
+ CntInt16::~CntInt16()
+ {
+ // needs to be called from here to have the fully derived implementation type
+ // in the helper method - do NOT move to a imaginable general
+ // implementation in IBaseStaticHelper (!)
+ if(IsAdministrated())
+ {
+ GetStaticAdmin().HintExpired(this);
+ }
+ }
+
+ CntInt16::SharedPtr 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)));
+ }
+
+ bool CntInt16::operator==(const IBase& rCandidate) const
+ {
+ assert(IBase::operator==(rCandidate));
+ return (GetValue() == static_cast<const CntInt16&>(rCandidate).GetValue());
+ }
+
+ bool CntInt16::operator<(const IBase& rCandidate) const
+ {
+ assert(IBase::operator==(rCandidate));
+ return static_cast<const CntInt16*>(this)->GetValue() < static_cast<const CntInt16&>(rCandidate).GetValue();
+ }
+
+ sal_Int16 CntInt16::GetValue() const
+ {
+ return m_nValue;
+ }
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/item/source/simple/CntOUString.cxx b/item/source/simple/CntOUString.cxx
new file mode 100644
index 000000000000..4f7bbfea6d4f
--- /dev/null
+++ b/item/source/simple/CntOUString.cxx
@@ -0,0 +1,62 @@
+/* -*- 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/simple/CntOUString.hxx>
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ CntOUString::CntOUString(const rtl::OUString& rValue)
+ : CntOUStringStaticHelper(),
+ m_aValue(rValue)
+ {
+ }
+
+ CntOUString::~CntOUString()
+ {
+ // needs to be called from here to have the fully derived implementation type
+ // in the helper method - do NOT move to a imaginable general
+ // implementation in IBaseStaticHelper (!)
+ if(IsAdministrated())
+ {
+ GetStaticAdmin().HintExpired(this);
+ }
+ }
+
+ std::shared_ptr<const CntOUString> CntOUString::Create(const rtl::OUString& rValue)
+ {
+ // 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 CntOUString>(GetStaticAdmin().Create(new CntOUString(rValue)));
+ }
+
+ bool CntOUString::operator==(const IBase& rCandidate) const
+ {
+ assert(IBase::operator==(rCandidate));
+ return (GetValue() == static_cast<const CntOUString&>(rCandidate).GetValue());
+ }
+
+ size_t CntOUString::GetUniqueKey() const
+ {
+ return static_cast<const CntOUString*>(this)->GetValue().hashCode();
+ }
+
+ const rtl::OUString& CntOUString::GetValue() const
+ {
+ return m_aValue;
+ }
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/item/test/ItemTest.cxx b/item/test/ItemTest.cxx
new file mode 100644
index 000000000000..dadb34b2d504
--- /dev/null
+++ b/item/test/ItemTest.cxx
@@ -0,0 +1,385 @@
+/* -*- 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 <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <item/base/IBase.hxx>
+#include <item/base/IAdministrator.hxx>
+#include <item/base/ModelSpecificIValues.hxx>
+#include <item/base/ISet.hxx>
+#include <item/simple/CntInt16.hxx>
+#include <item/simple/CntOUString.hxx>
+
+namespace Item
+{
+ // example for multi value Item
+ class CntMultiValue;
+ typedef IBaseStaticHelper<CntMultiValue, IAdministrator_vector> CntMultiValueStaticHelper;
+
+ // if this should be based on faster IAdministrator_set, changes needed would be:
+ // - typedef IBaseStaticHelper<CntMultiValue, IAdministrator_set> CntMultiValueStaticHelper;
+ // - define virtual bool operator<(const IBase& rCandidate) const override
+
+ class CntMultiValue : public CntMultiValueStaticHelper
+ {
+ private:
+ sal_Int16 m_nValueA;
+ sal_Int32 m_nValueB;
+ sal_Int64 m_nValueC;
+
+ protected:
+ friend CntMultiValueStaticHelper;
+
+ CntMultiValue(sal_Int16 nValueA = 0, sal_Int16 nValueB = 0, sal_Int16 nValueC = 0)
+ : CntMultiValueStaticHelper(),
+ m_nValueA(nValueA),
+ m_nValueB(nValueB),
+ m_nValueC(nValueC)
+ {
+ }
+
+ public:
+ virtual ~CntMultiValue()
+ {
+ // needs to be called from here to have the fully derived implementation type
+ // in the helper method - do NOT move to a imaginable general
+ // implementation in IBaseStaticHelper (!)
+ if(IsAdministrated())
+ {
+ GetStaticAdmin().HintExpired(this);
+ }
+ }
+
+ static std::shared_ptr<const CntMultiValue> Create(sal_Int16 nValueA, sal_Int16 nValueB, sal_Int16 nValueC)
+ {
+ // 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 CntMultiValue>(GetStaticAdmin().Create(new CntMultiValue(nValueA, nValueB, nValueC)));
+ }
+
+ virtual bool operator==(const IBase& rCandidate) const override
+ {
+ assert(IBase::operator==(rCandidate));
+ const CntMultiValue& rCand(static_cast<const CntMultiValue&>(rCandidate));
+ return (GetValueA() == rCand.GetValueA()
+ && GetValueB() == rCand.GetValueB()
+ && GetValueC() == rCand.GetValueC());
+ }
+
+ sal_Int16 GetValueA() const
+ {
+ return m_nValueA;
+ }
+
+ sal_Int16 GetValueB() const
+ {
+ return m_nValueB;
+ }
+
+ sal_Int16 GetValueC() const
+ {
+ return m_nValueC;
+ }
+
+ // virtual bool operator<(const IBase& rCandidate) const override
+ // {
+ // assert(IBase::operator==(rCandidate));
+ // return static_cast<const CntMultiValue*>(this)->GetValueA() < static_cast<const CntMultiValue&>(rCandidate).GetValueA()
+ // && static_cast<const CntMultiValue*>(this)->GetValueB() < static_cast<const CntMultiValue&>(rCandidate).GetValueB()
+ // && static_cast<const CntMultiValue*>(this)->GetValueC() < static_cast<const CntMultiValue&>(rCandidate).GetValueC();
+ // }
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+namespace Item
+{
+ class ibase : public CppUnit::TestFixture
+ {
+ private:
+ public:
+ void checkCntMultiValue()
+ {
+ // make direct use of local CntMultiValue item
+
+ // for debug, change bLoop to true, start, attach and set to
+ // false again to debug (one possibility...)
+ static bool bLoop(false);
+ while(bLoop)
+ {
+ bLoop = true;
+ }
+
+ // to see the diff between IAdministrator_vector and
+ // IAdministrator_set, see instructions in CntMultiValue above,
+ // create version for IAdministrator_set and raise this number.
+ // this demonstrates how/why this should be much faster than
+ // current SfxPoolItem/SfxItemSet/SfxItemPool stuff ...
+ int nIncrement(0);
+
+ CntMultiValue::SharedPtr mhas3(CntMultiValue::Create(5,2,8));
+ CntMultiValue::SharedPtr mhas4(CntMultiValue::Create(2,3,0));
+
+ if(CntMultiValue::IsDefault(CntMultiValue::Create(3,0,0)))
+ {
+ nIncrement++;
+ }
+
+ if(CntMultiValue::IsDefault(CntMultiValue::Create(8,7,6)))
+ {
+ nIncrement++;
+ }
+
+ if(CntMultiValue::IsDefault(CntMultiValue::GetDefault()))
+ {
+ nIncrement++;
+ }
+
+ CntMultiValue::SharedPtr testAA(CntMultiValue::Create(11,22,99));
+ std::vector<CntMultiValue::SharedPtr> test;
+ const sal_uInt32 nLoopNumber(50);
+
+ for(sal_uInt32 aloop(0); aloop < nLoopNumber; aloop++)
+ {
+ test.push_back(CntMultiValue::Create(aloop+1, (aloop+1)*2, (aloop+1)*4));
+ }
+
+ CntMultiValue::SharedPtr testA(CntMultiValue::Create(2,4,8));
+ CntMultiValue::SharedPtr testB(CntMultiValue::Create(2,4,9));
+
+ for(sal_uInt32 dloop(0); dloop < nLoopNumber; dloop+=2)
+ {
+ test[dloop] = nullptr;
+ if(dloop%5)
+ test.push_back(CntMultiValue::Create(dloop+1, (dloop+1)*2, (dloop+1)*4));
+ }
+
+ for(sal_uInt32 eloop(1); eloop < (nLoopNumber * 2) / 3; eloop+=2)
+ {
+ test[eloop] = nullptr;
+ if(eloop%7)
+ test.push_back(CntMultiValue::Create(eloop+1, (eloop+1)*2, (eloop+1)*4));
+ }
+
+ test.clear();
+ }
+
+ void checkCntMultiValueAtISet()
+ {
+ int nIncrement(0);
+
+ // make use of local CntMultiValue item in conjuction with ISet
+ ModelSpecificIValues::SharedPtr aModelSpecificIValues(ModelSpecificIValues::Create());
+ ISet::SharedPtr aSet(ISet::Create(aModelSpecificIValues));
+ aSet->SetItem(CntMultiValue::Create(5,4,3));
+
+ if(const auto Item(aSet->GetStateAndItem<const CntMultiValue>()); Item.IsSet())
+ {
+ nIncrement += (ISet::IState::SET == Item.GetIState()) ? 1 : 0;
+ nIncrement += (Item.GetItem()) ? 1 : 0;
+ nIncrement += (nullptr != Item.GetItemInstance()) ? 1 : 0;
+ nIncrement += Item.HasItem();
+ nIncrement += Item.IsDisabled();
+ }
+ else if(Item.IsDefault())
+ {
+ nIncrement += Item.IsDisabled();
+ }
+ else if(Item.IsDontCare())
+ {
+ nIncrement += Item.IsDisabled();
+ }
+ else
+ {
+ nIncrement += Item.IsDisabled();
+ }
+
+ // CPPUNIT_ASSERT_EQUAL_MESSAGE("simple range rounding from double to integer",
+ // B2IRange(1, 2, 4, 5), fround(ibase(1.2, 2.3, 3.5, 4.8)));
+ }
+
+ 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;
+ const sal_uInt32 nLoopNumber(50);
+ int nIncrement(0);
+
+ if(!bInit)
+ {
+ bInit = true;
+ a_sp = CntInt16::Create(3);
+ b_sp = CntInt16::Create(5);
+ c_sp = CntInt16::Create(7);
+ theDefault = CntInt16::GetDefault();
+
+ sa_sp = CntOUString::Create("Hello");
+ sb_sp = CntOUString::Create("World");
+ sc_sp = CntOUString::Create("..of Doom!");
+ stheDefault = CntOUString::GetDefault();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////
+
+ CntInt16::SharedPtr has3(CntInt16::Create(3));
+ CntInt16::SharedPtr has4(CntInt16::Create(4));
+
+ if(CntInt16::IsDefault(CntInt16::Create(11)))
+ {
+ nIncrement++;
+ }
+
+ if(CntInt16::IsDefault(CntInt16::Create(0)))
+ {
+ nIncrement++;
+ }
+
+ if(CntInt16::IsDefault(theDefault))
+ {
+ nIncrement++;
+ }
+
+ std::vector<CntInt16::SharedPtr> test16;
+
+ for(sal_uInt32 a(0); a < nLoopNumber; a++)
+ {
+ test16.push_back(CntInt16::Create(a));
+ }
+
+ test16.clear();
+
+ ///////////////////////////////////////////////////////////////////////////////
+
+ CntOUString::SharedPtr shas3(CntOUString::Create("Hello"));
+ CntOUString::SharedPtr shas4(CntOUString::Create("WhateverComesAlong"));
+
+ if(CntOUString::IsDefault(CntOUString::Create("NotDefault")))
+ {
+ nIncrement++;
+ }
+
+ if(CntOUString::IsDefault(CntOUString::Create(OUString())))
+ {
+ nIncrement++;
+ }
+
+ if(CntOUString::IsDefault(stheDefault))
+ {
+ nIncrement++;
+ }
+
+ std::vector<CntOUString::SharedPtr> testStr;
+
+ for(sal_uInt32 a(0); a < nLoopNumber; a++)
+ {
+ testStr.push_back(CntOUString::Create(OUString::number(static_cast<int>(a))));
+ }
+
+ testStr.clear();
+
+ if(bInit)
+ {
+ bInit = false;
+ a_sp.reset();
+ b_sp.reset();
+ c_sp.reset();
+ theDefault.reset();
+ sa_sp.reset();
+ sb_sp.reset();
+ sc_sp.reset();
+ stheDefault.reset();
+ }
+ }
+
+ void checkSimpleItemsAtISet()
+ {
+ int nIncrement(0);
+
+ ModelSpecificIValues::SharedPtr aModelSpecificIValues(ModelSpecificIValues::Create());
+ aModelSpecificIValues->SetAlternativeDefaultItem(CntInt16::Create(3));
+ aModelSpecificIValues->SetAlternativeDefaultItem(CntInt16::Create(4));
+
+ ISet::SharedPtr aSet(ISet::Create(aModelSpecificIValues));
+ const auto aActEmpty(aSet->GetStateAndItem<const CntInt16>());
+
+ aSet->SetItem(CntInt16::Create(4));
+ const auto aActA(aSet->GetStateAndItem<const CntInt16>());
+
+ aSet->SetItem(CntInt16::GetDefault());
+ const auto aActB(aSet->GetStateAndItem<const CntInt16>());
+
+ aSet->SetItem(CntInt16::Create(12));
+ const auto aActC(aSet->GetStateAndItem<const CntInt16>());
+
+ aSet->SetItem(CntOUString::Create("Teststring - not really useful :-)"));
+ const auto aActStr(aSet->GetStateAndItem<const CntOUString>());
+
+ const auto ItemDADA(aSet->GetStateAndItem<const CntInt16>());
+
+ if(const auto Item(aSet->GetStateAndItem<const CntOUString>()); Item.IsSet())
+ {
+ nIncrement += (ISet::IState::SET == Item.GetIState()) ? 1 : 0;
+ nIncrement += (Item.GetItem()) ? 1 : 0;
+ nIncrement += (nullptr != Item.GetItemInstance()) ? 1 : 0;
+ nIncrement += Item.HasItem();
+ nIncrement += Item.IsDisabled();
+ }
+ else if(Item.IsDefault())
+ {
+ nIncrement += Item.IsDisabled();
+ }
+ else if(Item.IsDontCare())
+ {
+ nIncrement += Item.IsDisabled();
+ }
+ else
+ {
+ nIncrement += Item.IsDisabled();
+ }
+
+ // check getting default at Set, this will include ModelSpecificIValues
+ // compared with the static CntInt16::GetDefault() call
+ const CntInt16::SharedPtr aDefSet(aSet->GetDefault<const CntInt16>());
+ const CntInt16::SharedPtr aDefGlobal(CntInt16::GetDefault());
+
+ const bool bClA(aSet->ClearItem<const CntInt16>());
+ nIncrement += bClA;
+ // let one exist to check destruction when Set gets destructed
+ // const bool bClB(aSet->ClearItem<const CntOUString>());
+ nIncrement ++;
+ }
+
+ // Change the following lines only, if you add, remove or rename
+ // member functions of the current class,
+ // because these macros are need by auto register mechanism.
+
+ CPPUNIT_TEST_SUITE(ibase);
+ CPPUNIT_TEST(checkCntMultiValue);
+ CPPUNIT_TEST(checkCntMultiValueAtISet);
+ CPPUNIT_TEST(checkSimpleItems);
+ CPPUNIT_TEST(checkSimpleItemsAtISet);
+ CPPUNIT_TEST_SUITE_END();
+ };
+} // end of namespace Item
+
+///////////////////////////////////////////////////////////////////////////////
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Item::ibase);
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index e270e474ea51..6263ec308663 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -6399,6 +6399,14 @@ include/i18nutil/searchopt.hxx
include/i18nutil/transliteration.hxx
include/i18nutil/unicode.hxx
include/i18nutil/widthfolding.hxx
+include/item/itemdllapi.h
+include/item/base/IAdministrator.hxx
+include/item/base/IBase.hxx
+include/item/base/IBaseStaticHelper.hxx
+include/item/base/ISet.hxx
+include/item/base/ModelSpecificIValues.hxx
+include/item/simple/CntInt16.hxx
+include/item/simple/CntOUString.hxx
include/jvmaccess/classpath.hxx
include/jvmaccess/jvmaccessdllapi.h
include/jvmaccess/unovirtualmachine.hxx
@@ -8128,6 +8136,15 @@ io/test/testconnection.cxx
ios/LibreOfficeLight/LibreOfficeLight/lokit-Bridging-Header.h
ios/source/LibreOfficeKit.c
ios/source/LibreOfficeKit.h
+item/inc/pch/precompiled_item.cxx
+item/inc/pch/precompiled_item.hxx
+item/source/base/IAdministrator.cxx
+item/source/base/IBase.cxx
+item/source/base/ISet.cxx
+item/source/base/ModelSpecificIValues.cxx
+item/source/simple/CntInt16.cxx
+item/source/simple/CntOUString.cxx
+item/test/ItemTest.cxx
javaunohelper/source/bootstrap.cxx
javaunohelper/source/javaunohelper.cxx
javaunohelper/source/juhx-export-functions.hxx
diff --git a/solenv/qa/python/gbuildtojson.py b/solenv/qa/python/gbuildtojson.py
index 6d93b6ff2369..f77c2fc1329f 100644
--- a/solenv/qa/python/gbuildtojson.py
+++ b/solenv/qa/python/gbuildtojson.py
@@ -123,7 +123,7 @@ class CheckGbuildToJsonModules(unittest.TestCase):
shutil.rmtree(self.tempwork)
def test_gbuildtojson(self):
- modules = ['accessibility', 'android', 'animations', 'apple_remote', 'avmedia', 'basctl', 'basegfx', 'basic', 'bean', 'canvas', 'chart2', 'codemaker', 'comphelper', 'cppcanvas', 'cui', 'dbaccess', 'desktop', 'drawinglayer', 'dtrans', 'editeng', 'embeddedobj', 'embedserv', 'eventattacher', 'extras', 'filter', 'forms', 'formula', 'fpicker', 'framework', 'hwpfilter', 'i18nlangtag', 'i18nutil', 'idl', 'idlc', 'instsetoo_native', 'io', 'ios', 'jvmaccess', 'jvmfwk', 'l10ntools', 'librelogo', 'libreofficekit', 'linguistic', 'lotuswordpro', 'nlpsolver', 'o3tl', 'offapi', 'officecfg', 'onlineupdate', 'oovbaapi', 'oox', 'opencl', 'package', 'postprocess', 'pyuno', 'registry', 'remotebridges', 'reportbuilder', 'reportdesign', 'ridljar', 'salhelper', 'sax', 'sc', 'sccomp', 'scp2', 'scripting', 'sd', 'sdext', 'setup_native', 'sfx2', 'slideshow', 'smoketest', 'soltools', 'sot', 'starmath', 'store', 'svgio', 'emfio', 'svl', 'svtools', 'svx', 'sw', 'swext', 'sysui', 'test', 'testtools', 'toolkit', 'ucb', 'ucbhelper', 'udkapi', 'uitest', 'UnoControls', 'unodevtools', 'unoidl', 'unoil', 'unotest', 'unotools', 'unoxml', 'ure', 'uui', 'vbahelper', 'vcl', 'winaccessibility', 'wizards', 'writerperfect', 'xmerge', 'xmlhelp', 'xmloff', 'xmlreader', 'xmlscript', 'xmlsecurity']
+ modules = ['accessibility', 'android', 'animations', 'apple_remote', 'avmedia', 'basctl', 'basegfx', 'basic', 'bean', 'canvas', 'chart2', 'codemaker', 'comphelper', 'cppcanvas', 'cui', 'dbaccess', 'desktop', 'drawinglayer', 'dtrans', 'editeng', 'embeddedobj', 'embedserv', 'eventattacher', 'extras', 'filter', 'forms', 'formula', 'fpicker', 'framework', 'hwpfilter', 'i18nlangtag', 'i18nutil', 'idl', 'idlc', 'instsetoo_native', 'io', 'ios', 'jvmaccess', 'jvmfwk', 'l10ntools', 'librelogo', 'libreofficekit', 'linguistic', 'lotuswordpro', 'nlpsolver', 'o3tl', 'offapi', 'officecfg', 'onlineupdate', 'oovbaapi', 'oox', 'opencl', 'package', 'postprocess', 'pyuno', 'registry', 'remotebridges', 'reportbuilder', 'reportdesign', 'ridljar', 'salhelper', 'sax', 'sc', 'sccomp', 'scp2', 'scripting', 'sd', 'sdext', 'setup_native', 'sfx2', 'slideshow', 'smoketest', 'soltools', 'sot', 'starmath', 'store', 'svgio', 'emfio', 'item', 'svl', 'svtools', 'svx', 'sw', 'swext', 'sysui', 'test', 'testtools', 'toolkit', 'ucb', 'ucbhelper', 'udkapi', 'uitest', 'UnoControls', 'unodevtools', 'unoidl', 'unoil', 'unotest', 'unotools', 'unoxml', 'ure', 'uui', 'vbahelper', 'vcl', 'winaccessibility', 'wizards', 'writerperfect', 'xmerge', 'xmlhelp', 'xmloff', 'xmlreader', 'xmlscript', 'xmlsecurity']
if os.environ['OS'] == 'WNT':
# for now, use a limited subset for testing on windows as it is so annoyingly slow on this
modules = ['chart2', 'cui', 'dbaccess', 'framework', 'oox', 'sfx2', 'svl', 'svtools', 'svx', 'toolkit', 'vcl', 'xmloff']