/external/python3/

-7-0+backports'>distro/lhm/libreoffice-7-0+backports LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
path: root/sc/source/ui/inc/undocell.hxx
AgeCommit message (Collapse)Author
2023-12-28Decouple ScPatternAttr from SfxItemPoolArmin Le Grand (allotropia)
ScPatternAttr is traditionally derived from SfxPoolItem (or better: SfxSetItem) and held in the ScDocumentPool as Item. This is only because of 'using' the 'poolable' functionality of the Item/ItemSet/ItemPool mechanism. Lots of hacks were added to sc and Item/ItemSet/ ItemPool to make that 'work' which shows already that this relationship is not optimal. It uses DirectPutItemInPool/DirectRemoveItemFromPool to do so, also with massive overhead to do that (and with not much success). The RefCnt in the SfxPoolItem that is used for this never worked reliably, so the SfxItemPool was (ab)used as garbage collector (all Items added and never removed get deleted at last for good when the Pool goes down). For this reasons and to be able to further get ItemSets modernized I changed this. I did two big changes here: (1) No longer derive ScPatternAttr from SfxItemSet/ SfxSetItem, no longer hold as SfxPoolItem (2) Add tooling to reliably control the lifetime of ScPatternAttr instances and ther uniqueness/ reusage for memory reasons It is now a regular non-derived class. The SfxItemSet formally derived from SfxSetItem is now a member. The RefCnt is now also a member (so independent from size/data type of SfxPoolItem). All in all it's pretty much the same size as before. To support handling it I created a CellAttributeHelper that is at/owned by ScDocument and takes over tooling to handle the ScPatternAttr. It supports to guarantee the uniqueness of incarnated ScPatternAttr instances for a ScDocument by providing helpers like registerAndCheck and doUnregister. It hosts the default CellAttribute/ ScPatternAttr. That default handling was anyways not using the standard default-handling of Items/Pools. I adapted whole SC to use that mainly by replacing calls to DirectPutItemInPool with registerAndCheck and DirectRemoveItemFromPool with doUnregister, BUT: This was not sufficient, the RefCnt kept to be broken. For that reason I decided to also do (2) in this change: I added a CellAttributeHolder that owns/regulates the lifetime of a single ScPatternAttr. Originally it also contained the CellAttributeHolder, but after some thoughts I decided that this is not needed - if there is no ScPatternAttr set, no CellAttributeHolder is needed for safe cleanup at destruction of the helper. So I moved/added the CellAttributeHolder to ScPatternAttr where it belongs more naturally anyways. The big plus is that CellAttributeHolder is just one ptr, so not bigger than having a simple ScPatternAttr*. That way, e.g. ScAttrEntry in ScAttrArray did not 'grow' at all. In principle all places where a ScPatternAttr* is used can now be replaced by using a CellAttributeHolder, except for construction. It is capable to be initialized with either ScPatternAttr instances from the heap (it creates a copy that then gets RefCounted) or allocated (it supports ownership change at construction time). Note that ScAttrEntry started to get more a C++ class in that change, it has a constructor. I did not change the SCROW member, but that should also be done. Also made registerAndCheck/doUnregister private in CellAttributeHelper and exclusively used by CellAttributeHolder. That way the RefCnt works, and a lot of code gets much simpler (check ScItemPoolCache, it's now straightforward) and safer and ~ScPatternAttr() uses now a hard assert(!isRegistered()); which shows that RefCnt works now (the 1st time?). There can be done more (see ToDo section below) but I myself will concentrate on getting ItemSets forward. This decoupling makes both involved mechanisms more safe, less complex and more stable. It also opens up possibilities to further optimize ScPatternAttr in SC without further hacking Item/ItemSet/ItemPool stuff. NOTE: ScPatternAttr *should* be renamed to 'CellAttribute' which describes what it is. The experiencd devs may know what it does, but it is a hindrance for understanding for attacting new devs. I already used now names like CellAttributeHelper/CellAttributeHolder etc., but abstained from renaming ScPatternAttr, see ToDo list below. SfxItemSet discussion: ScPatternAttr still contains a SfxItemSet, or better, a SfxSetItem. For that reason it still depends on access to an SfxItemPool (so there is acces in CellAttributeHelper). This is in principle not needed - no Item (in the range [ATTR_PATTERN_START .. ATTR_PATTERN_END]) needs that. In principle ScPatternAttr could now do it's own handling of those needed Items, however this might be done (linear array, hash-by-WhichID, ...). The Items get translated to and from this to the rest of the office anyways. Note that *merging* of SfxItemSets is *still* needed what means to have WhichID slots in SfxItemState::DONTCARE, see note in ScPatternAttr::ScPatternAttr about that. And there is also the Surrogates stuff which would have to be checked. The other extreme is to use SfxItemSet *more*, e.g. directly derive from SfxItemSet what would make stuff easier, maybe even get back to using the 'regular' Items like all office, I doubt that that would be much slower, so why...? Also possible is to remove that range of Items exclusively used by ScPatternAttr from ScDocumentPool *completely* and create an own Pool for them, owned by CellAttributeHelper. That Pool might even be static global, so all SC Docs could share all those Items - maybe even the ScPatternAttr themselves (except the default per document). That would remove the dependency of ScPatternAttr from a Pool completely. ToDo-List: - rename ScPatternAttr to CellAttribute or similar - use SfxItemSetFixed with range [ATTR_PATTERN_START .. ATTR_PATTERN_END] instead of regular SfxItemSet (if the copy-construtor works now...?) - maybe create own/separate Pool for exclusive Items - make ScAttrEntry more a C++ class by moving SCROW to the private section, add get/set methods and adapt SC Had to add some more usages of CellAttributeHolder to the SC Sort mechanism, there were situations where the sorted ScPatternAttr were replaced in the Table, but the 'sorted' ones were just ScPatternAttr*, thus deleting the valid ones in the Table already. Using CellAttributeHolder makes this safe, too. Added a small, one-entry cache to CellAttributeHelper to buffer the last found buffered ScPattrnAttr. It has a HitRate of ca. 5-6% and brings the UnitTest testSheetCellRangeProperties from 0m48,710s to 0m37,556s. Not too massive, but erery bit counts :-) Also shows that after that change optimizations in the now split functionality is possible and easy. Change-Id: I268a7b2a943ce5ddfe3c75b5e648c0f6b0cedb85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161244 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
2022-08-07clang-tidy modernize-pass-by-value in scNoel Grandin
Change-Id: Ia7ff651d1cbc119b36a9f8052594d03650988f59 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137848 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-02generalize the undo independence checkNoel Grandin
Change-Id: I441edbdf11ada1a0a724577a4f76ae8ae14177e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137683 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-30sc: allow undo of typing in 2 views independent from each otherNoel Grandin
This commit follows the same pattern as commit c72e500ccaf0ce2261c5233b80fba9342778f810 sw: allow undo of typing in 2 views independent from each other with some changes since calc and writer have different undo/redo infrastructure on top of SfxUndoManager. Change-Id: Ib6e7e21caccb94752c01c529b5013553dba8b4f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137579 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-03-23tdf#124176 Use pragma once in s*Vincent LE GARREC
sc, scaddins, sccomp, scripting Change-Id: Ia99fec9e238033821cb784810edd4762c09bd5db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112049 Tested-by: Jenkins Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
2020-03-12Revert "loplugin:constfields in sc"Noel Grandin
This reverts commit fb1d3b580763a333bbbfe115d09e1b5cd8849675. Now that we know that making fields has negative side effects like disabling assignment operator generation. Change-Id: Ib48334ffbeb2c768896dd8ced6818aa0b9910b0b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90333 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-05-20tdf#99938 : Allow batch of formula-cells to be written...Dennis Francis
using a single undo document from ScMovingAverageDialog rather than write tons of formula-cells to the document one by one thus creating that many number of undo docs unnecessarily. Change-Id: I2528e0ab47f83e0c5ea40c73d00db5af14f656e0 Reviewed-on: https://gerrit.libreoffice.org/71823 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
2019-03-21tdf#42949 Fix IWYU warnings in sc/source/ui/pagedlg...undoGabor Kelemen
Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: Icb5f0235339364e6dc09936e26f256765a60830a Reviewed-on: https://gerrit.libreoffice.org/69378 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-02-28reintroduce ScCaptionPtrLuboš Luňák
This basically reverts b6b1ded0a0539e7be1b5338de378a3276a6ff445, since it introduces tdf#118707, and I cannot reproduce any of the original problems when reverting. The patch itself is technically correct, but the problem is in the Windows implementation of clipboard handling, which uses delayed processing of setting clipboard contents. This leads to previous clipboard contents being deleted too late, and with shared_ptr instances of SdrCaptionObj may get deleted after the related SdrModel has already been deleted. A proper fix would be to remove the stupid delayed processing from the clipboard code, but that's non-trivial. If that gets fixed, the change removing ScCaptionPtr may most probably be applied again. Change-Id: I29634847486aa955b20483c9eb38bba4fed87187 Reviewed-on: https://gerrit.libreoffice.org/67725 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2018-11-06tdf#42949 Fix IWYU warnings in sc/source/ui/inc/[m-z]*Gabor Kelemen
Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: I6ca0168abc71b4d9b6d332dc0fd8a3c779fdaa87 Reviewed-on: https://gerrit.libreoffice.org/62524 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2018-10-15loplugin:constfields in scNoel Grandin
Change-Id: If326175d571d15752efd1b63df45b2bc785f7541 Reviewed-on: https://gerrit.libreoffice.org/61653 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-09-03pass SdrUndoAction around by std::unique_ptrNoel Grandin
convert the LINK we use here to std::function, since LINK does not currently handle std::unique_ptr Change-Id: I9df80352e612445e5f5ca513d7d4196d65589778 Reviewed-on: https://gerrit.libreoffice.org/59804 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-31use std::unique_ptr in various sc undo codeNoel Grandin
Change-Id: I7906f4e78336d3b738ea3409838ce3404e7f5c30 Reviewed-on: https://gerrit.libreoffice.org/59796 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-06-29loplugin:useuniqueptr in various ScUndo*Noel Grandin
Change-Id: I604d7b900836e87fc768e1b00dc62a570ff477b5 Reviewed-on: https://gerrit.libreoffice.org/56619 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-06-26Missing includeStephan Bergmann
Change-Id: I2d8b3acdbf4c3bfa54edf9d8f98e3f8d54ed15a8
2018-06-26sc: replace ScCaptionPtr with std::shared_ptr, tdf#117997, tdf#117228Henry Castro
Change-Id: I9b6a2c2504c9ce060906ac3bf156721709fef2f3 Reviewed-on: https://gerrit.libreoffice.org/55490 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
2018-04-11pass EditTextObject around using std::unique_ptrNoel Grandin
Change-Id: I71f4529c2e02fd0ac2561191e4cb35e18e206037 Reviewed-on: https://gerrit.libreoffice.org/52682 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-12-22can just use default dtorsCaolán McNamara
Change-Id: I4f8974876df033f68f7207dfd66526e7af10a6b3 Reviewed-on: https://gerrit.libreoffice.org/46960 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2017-10-23loplugin:includeform: scStephan Bergmann
Change-Id: I2ed763e0584a188032c80fde60890de3c6985cbd
2017-09-07tdf#107952: Move cursor to changed cell after undo/redo in ScUndoSetCellDennis Francis
Change-Id: Id9f2ba2ed2d77f03c9bd56c41b958aa23921da0d Reviewed-on: https://gerrit.libreoffice.org/42014 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Dennis Francis <dennis.francis@collabora.co.uk>
2016-10-31loplugin:countusersofdefaultparams in sc(part1)Noel Grandin
Change-Id: Ia2b0174654fad536ee23f6174a0b38b1843a4aa5 Reviewed-on: https://gerrit.libreoffice.org/30427 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-09-13loplugin:override: No more need for the "MSVC dtor override" workaroundStephan Bergmann
The issue of 362d4f0cd4e50111edfae9d30c90602c37ed65a2 "Explicitly mark overriding destructors as 'virtual'" appears to no longer be a problem with MSVC 2013. (The little change in the rewriting code of compilerplugins/clang/override.cxx was necessary to prevent an endless loop when adding "override" to OOO_DLLPUBLIC_CHARTTOOLS virtual ~CloseableLifeTimeManager(); in chart2/source/inc/LifeTime.hxx, getting stuck in the leading OOO_DLLPUBLIC_CHARTTOOLS macro. Can't remember what that isAtEndOfImmediateMacroExpansion thing was originally necessary for, anyway.) Change-Id: I534c634504d7216b9bb632c2775c04eaf27e927e
2016-07-13loplugin:singlevalfields in sc(part1)Noel Grandin
Change-Id: I25760def2c12e4ca87843c2f3ce1a60b5a9b2e44 Reviewed-on: https://gerrit.libreoffice.org/26680 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
2016-03-23loplugin:constantparam in scNoel Grandin
Change-Id: I437367b8c6960db730a69c020ba82792a9170d01
2015-11-115th step to remove tools/rtti.hxxOliver Specht
tools/rtti.hxx removed completed the interface of some Sdr.* Items and removed pseudo items Change-Id: I0cdcd01494be35b97a27d5985aa908affa96048a Reviewed-on: https://gerrit.libreoffice.org/19837 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Oliver Specht <oliver.specht@cib.de>
2015-11-10loplugin:nullptr (automatic rewrite)Stephan Bergmann
Change-Id: I765d2a600f9c57da50c85354688e3ae796750d94
2015-10-12Replace "SAL_OVERRIDE" with "override" in LIBO_INTERNAL_ONLY codeStephan Bergmann
Change-Id: I2ea407acd763ef2d7dae2d3b8f32525523ac8274
2015-09-18boost->stdCaolán McNamara
Change-Id: I7f3bb094f116103c1146a7d60e3af94c0b37d9ea Reviewed-on: https://gerrit.libreoffice.org/18677 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2015-09-17revert for mac and win unit case crashes after boost->stdCaolán McNamara
Change-Id: I82c7084f203a834c2d42f9527705288e6036019b
2015-09-17boost->stdCaolán McNamara
Change-Id: I1e6a7fd66f90e6acd803c6cd464f1d73252f7bcb