office-gobmx/extensions
Armin Le Grand (allotropia) ca3c6d468f ITEM: ItemPool Rework (I)
Driving forward the Item reworks I now take the
ItemPool in focus: It now does not hold any items
anymore and should be renamed to something like
ItemInfoProvider/ItemHelper, since it's main purpose
is to provide the Defaults for the Item functionality.

There is that SfxItemInfo, only a struct and bundling
SlotID and ItemFlags. There are also the DefaultItems,
just handled as ptrs in an array. It is/was always
error-prone to keep these in sync. Remember that it's
also necessary for the order to not only being sorted
but being increments of one with no gaps allowed in
the WhichIDs to which the Items are bound.

I now bundled that to a new class ItemInfo that joins
WhichID, SlotID, ItemFlags and the default Item. This
is a pure virtual base class, it comes in three
derivations:

(1) ItemInfoStatic:
This is supposed to be global static and hosts the
Item in a std::unique_ptr to ensure cleanup. It is
designed to be constructed once during runtime and
being shared globally. It allows the ItemPtr to be
nullptr to mark as non-static (if initial static is
not possible for some reason) but still offers the
needed data. Most cases (95%+) are of that case.
The contained Item is owned by that instance. The
flag isStaticDefault() is set at the Item.

(2) ItemInfoDynamic:
This is supposed to be used for cases where the Item
cannot be static: Mainly for SfxSetItem (that needs
a Pool itself in the contained SfxItemSet, so lifetime
is bound to that Pool), but other cases showed up in
the transition. These instances live while the Pool
lives and get destructed when the Pool goes down.
Also uses std::unique_ptr for the Item instance for
as much automated cleanup as possible, the contained
Item is owned by that instance, the instance by the
Pool. The flag isDynamicDefault() is set at the Item.

(3) ItemInfoUser:
This is used for UserDefaults that can be set for
every ItemInfo entry to 'overshadow' the default
from the 'outside'. It uses a regular Item and
the central access methods implCreateItemEntry/
implCleanupItemEntry to manage the Item instance,
thus works like a SfxPoolItemHolder. The Item
instance can be globally shared and re-used even
when the Pool goes down. Instances belong to the
Pool and are cleaned up when the Pool goes down.
This Item does not need any further flag to be
set.

The ItemInfos are organized using a class
called ItemInfoPackage:

This bundles groups of ItemInfoStatic to
functional instances. There are derivations/
implementations of this e.g. for Writer ItemPool
bundling all the needed defaults for Writer,
similar for draw/impress, Calc and other usages.

These ItemInfoPackage can be 'registered' at an
ItemPool using it's method registerItemInfoPackage.
This does all the needed stuff to setup that
group of ItemInfos at the Pool (It even sets
internal vars First/LastWhich, that info can just
be derived from the buildup ItemInfo Ptrs).

The ItemInfoPackage has methods 'size()' and
'getItemInfo(index) to allow looping over it
and deliver the infos the Pool needs. The
(forced, pure virtual) overloads of getItemInfo
in the specific implementations check for the
ItemPtr being nullptr and create a exclusive
incarnation of ItemInfoDynamic for the Pool if
needed, returning that. The Pool owns the
ItemInfoDynamic incarnations and uses the
ItemInfoStatic directly. On shutdown it cleans
up the ItemInfoDynamic as needed.

The ItemInfoUser is used by the Pool when a
UserDefault is set/used: for SetUserDefaultItem,
GetUserDefaultItem, ResetUserDefaultItem. It
is not held in a 2nd list, but directly in the
list of ItemInfo'ptrs: To keep track of this
an unordered_map is used that helds the original
ItemInfo associated with the WhichID. That way
no two lookups (as before) are needed to get the
current Pool's default for any WhichID.

The derivations of ItemInfoPackage are
encapsulated and just allow access to an
ItemInfoPackage& with a single method as
return value. All use a static local instance
of a std::array<ItemInfoStatic, FIXED_SIZE>
which constructs all ItemInfoStatic and the
static Item instances - if already possible.
Sometimes it is necessary to overload the
constructor to set some static instances
for Items later than the lib init. These are
also just marked with nullptr as Item instance.
Some need to overload getItemInfo to complete
instances of ItemInfoStatic, if needed, or
create and deliver instances of ItemInfoDynamic.

The registerItemInfoPackage also offers a
optional lambda callback: there were two cases
where local data from the Pool was needed to
incarnate the item - just add that to the
call to registerItemInfoPackage if needed,
see examples in the adapted code.

For the re-use of Items this means that now
in SfxItemSet/SfxPoolItemHolder *true* static
Items can and will be used without RefCount
directly and globally. This is also the case
for dynamic Items, with the exception of
differing Pools for SfxSetItems which cannot
be done.

Future:
That design is already prepared to allow
solving that Pool-chaining problem: currently
there are master/sub-pools and all accesses
have to traverse that structure before even
doing anything.
For the future the idea is more to 'compose'
a Pool by registering ItemInfoPackages, e.g.
for Writer pool you may start with SfxItemPool,
register the writer-specific ItemInfoPackage,
then the one for DrawingLayer (if needed) and
the one for EditEngine.
It should also be possible to get to smaller
granularities of that packages. Ideas for
new ones will emerge. We might also think
about composing Pools which can e.g. run Writer
and Chart, so allowing to use Chart *without*
OLE stuff in Writer - just ideas...

More changes:
- Adapted all stuff, cleaned up old stuff/
  definitions
- Removed FreezeIdRanges, that can be done
  once per Pool on-demand (and cannot be
  forgotten to be called)
- Merged XOutdevItemPool with SdrItemPool
  and offered a ItemInfoPackage which joins
  both needed sets of Items
- All the cleanup hassle with Pools and
  defaults cleaned up
- Adapted all access methods of the pool
  to use that new stuff. Pool chaining
  currently stays, but I use a central
  method 'getTargetPool' instead of
  recursive calling to get the correct
  Pool for the action

Change-Id: I2b8d3d4c3cc80b1d0d0b3c0f4bd90d7656b4bab7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163157
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
2024-02-12 10:35:33 +01:00
..
inc tdf#159151 Fix double space in Tree Control 2024-01-15 02:17:15 +01:00
qa Drop std::as_const from css::uno::Sequence iterations 2024-01-27 12:43:48 +01:00
source ITEM: ItemPool Rework (I) 2024-02-12 10:35:33 +01:00
test tdf#148251 Use std::swap instead of using temporary values 2024-01-01 14:27:36 +01:00
uiconfig The name is macOS since 2016 2023-09-19 07:13:24 +02:00
AllLangMoTarget_pcr.mk
Configuration_updchk.mk
CppunitTest_extensions_bibliography.mk
CppunitTest_extensions_test_update.mk Move tools/diagnose_ex.h to comphelper/diagnose_ex.hxx 2022-08-18 17:10:19 +02:00
CustomTarget_automationtest.mk
CustomTarget_so_activex_idl.mk
CustomTarget_so_activex_x64.mk
Executable_twain32shim.mk
IwyuFilter_extensions.yaml
JunitTest_extensions_unoapi.mk
Library_abp.mk
Library_bib.mk
Library_dbp.mk
Library_ldapbe2.mk openldap: upgrade to release 2.6.4 2023-06-21 12:52:52 +02:00
Library_log.mk
Library_oleautobridge.mk tdf#158375: add expert option DisableOLEAutomation 2024-01-09 00:50:10 +01:00
Library_OOoSpotlightImporter.mk
Library_pcr.mk
Library_scn.mk
Library_so_activex.mk
Library_so_activex_x64.mk
Library_updatecheckui.mk
Library_updatefeed.mk
Library_updchk.mk officecfg,*: add Office::Security::Net::AllowInsecureProtocols 2023-11-09 16:51:31 +01:00
Library_WinUserInfoBe.mk
Makefile
Module_extensions.mk WASM add Calc as optional build result, make it build & run 2022-10-14 09:21:30 +02:00
Package_mdibundle.mk
Package_OOoSpotlightImporter.mk
README.md add some notes on how to debug online update from a dev version 2022-11-24 14:57:21 +01:00
UIConfig_sabpilot.mk
UIConfig_sbibliography.mk
UIConfig_scanner.mk
UIConfig_spropctrlr.mk
WinResTarget_activex.mk

Miscellaneous Modules

This module contains a grab-bag of unrelated miscellaneous libraries, none of which is an extension.

Application Online Update Checking

When we start LO, first InitUpdateCheckJobThread is created, via UpdateCheckJob::execute() (from extensions/source/update/check/updatecheckjob.cxx), as a reaction to a onFirstVisibleTask event. It waits 25 seconds (so that it does not interfere with the startup itself), and then calls UpdateCheck::initialize() (from extensions/source/update/check/updatecheck.cxx).

This creates one more thread, UpdateCheckThread, that regularly checks whether we have reached the time when we should ask for the update. If yes, asks for that, and shows the download button in the menu (if the new update is available).

The update server will decide if there is an update available based on the user-agent string created by UpdateInformationProvider::getUserAgent, the data used there is extracted from instdir/program/versionrc and the update server takes the buildid into account, so to experiment with the updates from a dev version getUserAgent needs to return a recognized id.

OLE Automation Bridge

A bridge between "OLE automation" and UNO, so you can use UNO services from JScript, VBScript, etc.

https://www.openoffice.org/udk/common/man/spec/ole_bridge.html

See udkapi/com/sun/star/bridge/oleautomation/ApplicationRegistration.idl

This is initialized in Desktop::Main() in Desktop::OpenClients_Impl() by creating the service com.sun.star.bridge.OleApplicationRegistration, which is implemented by OleServer_Impl.

See extensions/source/ole/

ActiveX Control

This allows embedding LO into a Win32 application as an ActiveX control.

See extensions/source/activex/

Spotlight Provider

On macOS, this allows indexing ODF documents with Spotlight.

See extensions/source/macosx/spotlight/

Scanner Support

You can scan from LibreOffice, using platform specific backends like TWAIN/SANE.

See extensions/source/scanner/