diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2023-10-04 15:42:27 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2023-11-07 18:07:13 +0100 |
commit | ab7c81f55621d7b0d1468c63305163016dd78837 (patch) | |
tree | 4fb039902ced911bb96660edd343ee5705e5688b /sw | |
parent | 89780c208837973e21ddbf098d77f4369018ee9e (diff) |
ITEM: Get away from classic 'poolable' Item flag
To understand this, some look back in history will be needed to see
why it is as it is today. In some (reworked) comments 'poolable' is
described as flag to hold Items in the ItemPool, also always having
only one incarnation of each possible Item.
This is not the original intention, but a side-effect. The reason is
what the binary format in the office did: To save a document, the
Objects & the Pool were saved, *not* individual Items *together*
with the objects. The Pool was completely (binary) saved (and loaded)
in one run.
Temporary IDs were used to represent at the objects in file which
Items were referenced. This *required* to have only one incarnation
per item to have a minimal binary file size, thus this high effort
was put into this. At doc load, the pool was loaded, all Items were
set to RefCount 5000, the references from the objects were restored
and then for each Item the RefCount was lowered by 5000 again
and - if being zero - deleted. Items for UI were marked 'non-poolable'
to *not* safe them with the document, so poolable was a flag to decide
if that Info/Item was to be saved with the document - or more direct:
if it is Model Data.
Items are small, so if we prefer runtime it is okay to no longer being
strict with this, anyways does not happen often and has only marginal
memory effects - compared to runtime effects/savings.
Other problems which this caused: One example is that objects in the
UNDO stack were still in the pool, so e.g. deleted pictures were saved
with the document despite no longer being used (!). That is the reason
we have an UndoItemPool and a method MigrateItemPool to move stuff to
that Pool when objects go to the UNDO stack - all of this is also no
longer needed.
Cleaning this up means to ideally have all items in the SfxItemSet,
no longer at the Pool. The Pool should be reduced to a 'Default-Item-
Holder' and a 'Slot-to-whichId-mapper'.
This needs thorough cleanups/removals, but will be worth it because
that massive simplification(s) will increase safety an runtime and make
migrating to the goal of completely type-based ItemSet stuff easier for
the future. Hopefully only view code in the office working with items
will have to be changed for this.
In this 1st step I already found that some 'compromizes' will be
needed:
- There are still Items that have to be at the pool to make the
Surrogate-stuff working. This gives back all Items in a Pool of a type
and is used in ca. 80 cases. Each one looks at these Items *without*
context (e.g. a SfxItemSet at an Object would be a context), so if e.g.
a dialog is open that temporarily uses Items of that type you would
also get these - without knowing about it...
To make that work there is still a mechanism to have Items at the Pool,
but now just *registering* (and un-reg) them without any sort/search/
remove needs. Also only for Items that need that, so I evaluated the
GetItemSurrogates calls and added some asserts when GetItemSurrogates
tries to access an unregistered item type which needs to be added.
- Another caveat is that there are about 250 places that directly put
Items to the Pool (not all remove these, that is done at pool deletion,
so some kind of silent 'garbage-collection' is in place). To have an
overview I renamed the accessing methods to separate them from the same
functionality at the SfxItemSet, which had the same names. An
implementation does still add these directly to the pool, there is no
way to cleanup those usages for now. In principle all these should be
changed to hold the data at an SfxItemSet.
I am still hunting problems. But you can build the office, all apps
work (including chart) and you can do speed comparisons already.
There are test throwing errors, so I hunt these now. It is hard to
give an estimation about how much more changes/corrections will be
needed.
Completed adaptions to new registered Items at Pool, that reduces the
failing tests. Still many that I need to hunt.
Added stuff to work around that 'compromize' in ScDocumentPool: It
overloads ::PutImpl of the pool to implement special handling for
a single Item in SC, the ScPatternAttr. In former code that method
was used from SfxItemSet and ::PutImpl at the pool directly, so it
was only used in one place. I am not sure if it was used from
the SfxItemSet functionality, but better offer it for now. To not
waste too much runtime the callbacks depend on the boolean
'NewItemCallback' at the SfxPoolItem, it gets set for that single
Item in SC and only then the callbacks trigger. I hope to get rid
of those again, e.g. newItem_UseDirect is only needed since we have
no 'real' StaticPoolDefaults currently - another thing that needs to
be cleaned up in a next step.
Since usages of impl(Create|Cleanup)ItemEntry and
Direct(Put|Remove)ItemInPoolImpl got more and more similar I decided to
unify that: move impl(Create|Cleanup)ItemEntry to tooling, make it
globally available in svl and use it also directly for
Direct(Put|Remove)ItemInPoolImpl. This slightly increases the failing
tests again, but only since in Direct(Put|Remove)ItemInPoolImpl that
fallback (e.g. tryToGetEqualItem) was used before, thus this is the
same class of errors (SfxPoolItem ptr-compare) as the others which I
will need to find anyways. Also fixed some missing stuff.
Have now idenified and redirected all SfxPoolItem ptr-compares
to be able to debug these - one cause for the remaining errors is
probably that before with bPoolable those often were sufficient, but
are no longer. Used the [loplugin:itemcompare] and a local clang
build to do so, see https://gerrit.libreoffice.org/c/core/+/157172
Stabilized Direct(Put|Remove)ItemInPoolImpl forwards, added parameter
to implCreateItemEntry to signal that it gets called from DirectPool
stuff - currently needed. Hopefully when getting rid of that DirectPool
stuff we can remove that again
Added two more debug functionalities:
- Added a SerialNumber to allow targeted debugging for deterministic
cases
- Added registering & listing of still-allocated SfxPoolItems at
office shutdown
Found PtrComp error in thints.cxx - POC, thanks to
areSfxPoolItemPtrsEqual. Will hopefully help more with other tests
Found some wrong asserts/warnings where I was too careful and not
finding something/succeeding is OK, fixes some UnitTests for SC
For SC I now just tried to replace all areSfxPoolItemPtrsEqual with
the full-ptr-content compare SfxPoolItem::areSame. I also needed to
experiment/adapt the newItem_Callback solution but got it working.
Did that replacement now for SW too, found some places where the
direct ptr compare is OK.
Continued for the rest of occurrences, now all 160 places evaluated.
Also done some cleanups.
Massive cleanups of stuff no longer needed with this paradigm change.
Also decided to keep tryToGetEqualItem/ITEM_CLASSIC_MODE for now.
It is used for *one* Item (ScPatternAttr/ATTR_PATTERN) in SC that
already needs many exceptions. Also useful for testing if errors
come up on this change to test if it is related to this.
Added forwarding of target Pool for ::Clone in SvxSetItem and
SvxSetItem, simplified SfxStateCache::SetState_Impl and returned
to simple ptr compares in SfxPoolItem::areSame to not do the test
in areSfxPoolItemPtrsEqual.
Debugged through UITest_calc_tests9 and found that in tdf133629
where BoxStyle is applied to fully selected empty calc the Item-
reuse fallback has to be used not only for ATTR_PATTERN, see
comment @implCreateItemEntry. Maybe more...
Problem with test_tdf156611_insert_hyperlink_like_excel. Found that
in ScEditShell::GetFirstURLFieldFromCell the correct SvxURLField
is found and returned as ptr, but it's usage crashes. That is due to
the SfxItemSet aEditSet used there gets destroyed at function return
what again deletes the SvxFieldItem that is holding the SvxURLField
that gets returned.
This shows a more general problem: There is no 'SfxPoolItemHolder'
that safely holds a single SfxPoolItem - like a SfxItemSet for a
single Item (if Items would be shared_ptrs, that would be a safe
return value).
That will be needed in the future, but for now use another solution:
Since I see no reason why EE_FEATURE_FIELD should not be shareable
I wil change this for ow in the SfxItemInfo for EditCharAttribField.
That way the Item returned will be shared (RefCnt > 1) and thus not
be deleted.
I changed the return value for GetURLField() and
GetFirstURLFieldFromCell() in ScEditShell: At least for
GetFirstURLFieldFromCell the return type/value was not safe: The
SvxFieldItem accessed there and held in the local temporary
SfxItemSet may be deleted with it, so return value can be
corrupted/deleted. To avoid that, return a Clone of SvxFieldData
as a unique_ptr.
With all that UnitTest debugging and hunting and to get the paradigm
change working to no longer rely on shared/pooled items I lost a
little bit focus on speed, so I made an optimization round for the
two central methods implCreateItemEntry/implCleanupItemEntry to
get back to the speed improvements that I detected when starting this
change. It was mainly lost due to that 'strange' chained pool stuff
we have, so I added to detect the target pool (the one at which the
WhichID is registered) directly and only once. Next thing to cleanup
will/should be the pool and it's concept, all this is not needed
and really costs runtime.
Since implCreateItemEntry/implCleanupItemEntry are executed millions
of times, each cycle counts here.
Had an error in the last changes: pool::*_Impl methods use index
instead of WhichID - most of them. Another bad trap, I really need
to cleanup pool stuff next.
Change-Id: I6295f332325b33268ec396ed46f8d0a1026e2d69
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157559
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'sw')
34 files changed, 324 insertions, 299 deletions
diff --git a/sw/source/core/attr/cellatr.cxx b/sw/source/core/attr/cellatr.cxx index 09b070e42c3a..9023cca2f793 100644 --- a/sw/source/core/attr/cellatr.cxx +++ b/sw/source/core/attr/cellatr.cxx @@ -58,9 +58,6 @@ SwTableBoxFormula::SwTableBoxFormula( const OUString& rFormula ) SwTableFormula( rFormula ), m_pDefinedIn( nullptr ) { - // ITEM: mark this Item to be non-shareable/non-RefCountable. For more - // info see comment @SwAttrSet::SetModifyAtAttr - m_bShareable = false; } bool SwTableBoxFormula::operator==( const SfxPoolItem& rAttr ) const diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx index 7102ce7d7f5d..641d7380312f 100644 --- a/sw/source/core/attr/hints.cxx +++ b/sw/source/core/attr/hints.cxx @@ -140,10 +140,13 @@ SwMsgPoolItem::SwMsgPoolItem( sal_uInt16 nWhch ) { } -bool SwMsgPoolItem::operator==( const SfxPoolItem& ) const +bool SwMsgPoolItem::operator==( const SfxPoolItem& rItem ) const { - assert( false && "SwMsgPoolItem knows no ==" ); - return false; + assert( SfxPoolItem::operator==(rItem)); (void)rItem; + // SwMsgPoolItem now knows operator== due to evtl. deeper + // ItemCompares using SfxPoolItem::areSame. No members, + // so always equal + return true; } SwMsgPoolItem* SwMsgPoolItem::Clone( SfxItemPool* ) const diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx index b08026a1bd34..fc4612757dcc 100644 --- a/sw/source/core/attr/swatrset.cxx +++ b/sw/source/core/attr/swatrset.cxx @@ -141,12 +141,12 @@ void SwAttrSet::changeCallback(const SfxPoolItem* pOld, const SfxPoolItem* pNew) const SfxItemSet* pParent(GetParent()); m_pOldSet->PutImpl(nullptr != pParent ? pParent->Get(nWhich) - : GetPool()->GetDefaultItem(nWhich), nWhich, false, false); + : GetPool()->GetDefaultItem(nWhich), nWhich, false); } else if (!IsInvalidItem(pOld)) { // set/remember old value - m_pOldSet->PutImpl(*pOld, nWhich, true, false); + m_pOldSet->PutImpl(*pOld, nWhich, false); } } @@ -159,12 +159,12 @@ void SwAttrSet::changeCallback(const SfxPoolItem* pOld, const SfxPoolItem* pNew) const SfxItemSet* pParent(GetParent()); m_pNewSet->PutImpl(nullptr != pParent ? pParent->Get(nWhich) - : GetPool()->GetDefaultItem(nWhich), nWhich, false, false); + : GetPool()->GetDefaultItem(nWhich), nWhich, false); } else if (!IsInvalidItem(pNew)) { // set/remember new value - m_pNewSet->PutImpl(*pNew, nWhich, true, false); + m_pNewSet->PutImpl(*pNew, nWhich, false); } } } @@ -337,33 +337,6 @@ bool SwAttrSet::SetModifyAtAttr( const sw::BroadcastingModify* pModify ) { bool bSet = false; - // ITEM: At this place the paradigm of Item/Set/Pool gets broken: - // The three Items in Writer - // - SwFormatPageDesc - // - SwFormatDrop - // - SwTableBoxFormula - // contain a unique ptr to SwFormat (or: sw::BroadcastingModify - // if you wish), so the Item *cannot* be shared or re-used. - // But that is the intended nature of Items: - // - they are read-only (note the bad const_cast's below) - // - they are ref-counted to be re-usable in as many Sets as - // possible - // Thus if we need to change that ptr @ Item we *need* to make - // sure that Item is *unique*. This is now done by using the - // 'm_bShareable' at the Item (see where that gets set). - // This was done in the past using the 'poolable' flag, but that - // flag was/is for a completely different purpose - uniqueness is - // a side-effect. It already led to massively cloning that Item. - // That something is not 'clean' here can also be seen by using - // const_cast to *change* values at Items *in* the Set - these - // are returned by const reference for a purpose. - // If info/data at an Item has to be changed, the official/clean - // way is to create a new one (e.g. Clone), set the values (if - // not given to the constructor) and then set that Item at the Set. - // NOTE: I do not know if and how it would be possible, but holding - // a SwFormat*/sw::BroadcastingModify* at those Items should - // be fixed/removed ASAP - const SwFormatPageDesc* pPageDescItem = GetItemIfSet( RES_PAGEDESC, false ); if( pPageDescItem && pPageDescItem->GetDefinedIn() != pModify ) diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index 3e286b31e80a..f0080719c28d 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -264,180 +264,181 @@ SwDfltAttrTab aAttrTab( POOLATTR_END - POOLATTR_BEGIN, nullptr ); SfxItemInfo aSlotTab[] = { - { SID_ATTR_CHAR_CASEMAP, true }, // RES_CHRATR_CASEMAP - { SID_ATTR_CHAR_CHARSETCOLOR, true }, // RES_CHRATR_CHARSETCOLOR - { SID_ATTR_CHAR_COLOR, true }, // RES_CHRATR_COLOR - { SID_ATTR_CHAR_CONTOUR, true }, // RES_CHRATR_CONTOUR - { SID_ATTR_CHAR_STRIKEOUT, true }, // RES_CHRATR_CROSSEDOUT - { SID_ATTR_CHAR_ESCAPEMENT, true }, // RES_CHRATR_ESCAPEMENT - { SID_ATTR_CHAR_FONT, true }, // RES_CHRATR_FONT - { SID_ATTR_CHAR_FONTHEIGHT, true }, // RES_CHRATR_FONTSIZE - { SID_ATTR_CHAR_KERNING, true }, // RES_CHRATR_KERNING - { SID_ATTR_CHAR_LANGUAGE, true }, // RES_CHRATR_LANGUAGE - { SID_ATTR_CHAR_POSTURE, true }, // RES_CHRATR_POSTURE - { 0, true }, // RES_CHRATR_UNUSED1 - { SID_ATTR_CHAR_SHADOWED, true }, // RES_CHRATR_SHADOWED - { SID_ATTR_CHAR_UNDERLINE, true }, // RES_CHRATR_UNDERLINE - { SID_ATTR_CHAR_WEIGHT, true }, // RES_CHRATR_WEIGHT - { SID_ATTR_CHAR_WORDLINEMODE, true }, // RES_CHRATR_WORDLINEMODE - { SID_ATTR_CHAR_AUTOKERN, true }, // RES_CHRATR_AUTOKERN - { SID_ATTR_FLASH, true }, // RES_CHRATR_BLINK - { 0, true }, // RES_CHRATR_UNUSED2 - { 0, true }, // RES_CHRATR_NOHYPHEN - { SID_ATTR_BRUSH_CHAR, true }, // RES_CHRATR_BACKGROUND - { SID_ATTR_CHAR_CJK_FONT, true }, // RES_CHRATR_CJK_FONT - { SID_ATTR_CHAR_CJK_FONTHEIGHT, true },// RES_CHRATR_CJK_FONTSIZE - { SID_ATTR_CHAR_CJK_LANGUAGE, true }, // RES_CHRATR_CJK_LANGUAGE - { SID_ATTR_CHAR_CJK_POSTURE, true }, // RES_CHRATR_CJK_POSTURE - { SID_ATTR_CHAR_CJK_WEIGHT, true }, // RES_CHRATR_CJK_WEIGHT - { SID_ATTR_CHAR_CTL_FONT, true }, // RES_CHRATR_CTL_FONT - { SID_ATTR_CHAR_CTL_FONTHEIGHT, true },// RES_CHRATR_CTL_FONTSIZE - { SID_ATTR_CHAR_CTL_LANGUAGE, true }, // RES_CHRATR_CTL_LANGUAGE - { SID_ATTR_CHAR_CTL_POSTURE, true }, // RES_CHRATR_CTL_POSTURE - { SID_ATTR_CHAR_CTL_WEIGHT, true }, // RES_CHRATR_CTL_WEIGHT - { SID_ATTR_CHAR_ROTATED, true }, // RES_CHRATR_ROTATE - { SID_ATTR_CHAR_EMPHASISMARK, true }, // RES_CHRATR_EMPHASIS_MARK - { SID_ATTR_CHAR_TWO_LINES, true }, // RES_CHRATR_TWO_LINES - { SID_ATTR_CHAR_SCALEWIDTH, true }, // RES_CHRATR_SCALEW - { SID_ATTR_CHAR_RELIEF, true }, // RES_CHRATR_RELIEF - { SID_ATTR_CHAR_HIDDEN, true }, // RES_CHRATR_HIDDEN - { SID_ATTR_CHAR_OVERLINE, true }, // RES_CHRATR_OVERLINE - { 0, true }, // RES_CHRATR_RSID - { SID_ATTR_CHAR_BOX, true }, // RES_CHRATR_BOX - { SID_ATTR_CHAR_SHADOW, true }, // RES_CHRATR_SHADOW - { 0, true }, // RES_CHRATR_HIGHLIGHT - { SID_ATTR_CHAR_GRABBAG, true }, // RES_CHRATR_GRABBAG - { 0, true }, // RES_CHRATR_BIDIRTL - { 0, true }, // RES_CHRATR_IDCTHINT - - { 0, false }, // RES_TXTATR_REFMARK - { 0, false }, // RES_TXTATR_TOXMARK - { 0, false }, // RES_TXTATR_META - { 0, false }, // RES_TXTATR_METAFIELD - { 0, true }, // RES_TXTATR_AUTOFMT - { FN_TXTATR_INET, false }, // RES_TXTATR_INETFMT - { 0, false }, // RES_TXTATR_CHARFMT - { SID_ATTR_CHAR_CJK_RUBY, false }, // RES_TXTATR_CJK_RUBY - { 0, true }, // RES_TXTATR_UNKNOWN_CONTAINER - { 0, false }, // RES_TXTATR_INPUTFIELD - { 0, false }, // RES_TXTATR_CONTENTCONTROL - - { 0, false }, // RES_TXTATR_FIELD - { 0, false }, // RES_TXTATR_FLYCNT - { 0, false }, // RES_TXTATR_FTN - { 0, false }, // RES_TXTATR_ANNOTATION - { 0, false }, // RES_TXTATR_LINEBREAK - { 0, true }, // RES_TXTATR_DUMMY1 - - { SID_ATTR_PARA_LINESPACE, true }, // RES_PARATR_LINESPACING - { SID_ATTR_PARA_ADJUST, true }, // RES_PARATR_ADJUST - { SID_ATTR_PARA_SPLIT, true }, // RES_PARATR_SPLIT - { SID_ATTR_PARA_ORPHANS, true }, // RES_PARATR_ORPHANS - { SID_ATTR_PARA_WIDOWS, true }, // RES_PARATR_WIDOWS - { SID_ATTR_TABSTOP, true }, // RES_PARATR_TABSTOP - { SID_ATTR_PARA_HYPHENZONE, true }, // RES_PARATR_HYPHENZONE - { FN_FORMAT_DROPCAPS, false }, // RES_PARATR_DROP - { SID_ATTR_PARA_REGISTER, true }, // RES_PARATR_REGISTER - { SID_ATTR_PARA_NUMRULE, true }, // RES_PARATR_NUMRULE - { SID_ATTR_PARA_SCRIPTSPACE, true }, // RES_PARATR_SCRIPTSPACE - { SID_ATTR_PARA_HANGPUNCTUATION, true },// RES_PARATR_HANGINGPUNCTUATION - - { SID_ATTR_PARA_FORBIDDEN_RULES, true },// RES_PARATR_FORBIDDEN_RULES - { SID_PARA_VERTALIGN, true }, // RES_PARATR_VERTALIGN - { SID_ATTR_PARA_SNAPTOGRID, true }, // RES_PARATR_SNAPTOGRID - { SID_ATTR_BORDER_CONNECT, true }, // RES_PARATR_CONNECT_BORDER - - { SID_ATTR_PARA_OUTLINE_LEVEL, true }, // RES_PARATR_OUTLINELEVEL //#outline level - { 0, true }, // RES_PARATR_RSID - { SID_ATTR_PARA_GRABBAG, true }, // RES_PARATR_GRABBAG - { 0, true }, // RES_PARATR_LIST_ID - { 0, true }, // RES_PARATR_LIST_LEVEL - { 0, true }, // RES_PARATR_LIST_ISRESTART - { 0, true }, // RES_PARATR_LIST_RESTARTVALUE - { 0, true }, // RES_PARATR_LIST_ISCOUNTED - { 0, true }, // RES_PARATR_LIST_AUTOFMT - - { 0, true }, // RES_FILL_ORDER - { 0, true }, // RES_FRM_SIZE - { SID_ATTR_PAGE_PAPERBIN, true }, // RES_PAPER_BIN - { SID_ATTR_PARA_FIRSTLINESPACE, true }, // RES_MARGIN_FIRSTLINE - { SID_ATTR_PARA_LEFTSPACE, true }, // RES_MARGIN_TEXTLEFT - { SID_ATTR_PARA_RIGHTSPACE, true }, // RES_MARGIN_RIGHT - { 0, true }, // RES_MARGIN_LEFT - { 0, true }, // RES_MARGIN_GUTTER - { 0, true }, // RES_MARGIN_GUTTER_RIGHT - { SID_ATTR_LRSPACE, true }, // RES_LR_SPACE - { SID_ATTR_ULSPACE, true }, // RES_UL_SPACE - { 0, false }, // RES_PAGEDESC - { SID_ATTR_PARA_PAGEBREAK, true }, // RES_BREAK - { 0, false }, // RES_CNTNT - { 0, true }, // RES_HEADER - { 0, true }, // RES_FOOTER - { 0, true }, // RES_PRINT - { FN_OPAQUE, true }, // RES_OPAQUE - { FN_SET_PROTECT, true }, // RES_PROTECT - { FN_SURROUND, true }, // RES_SURROUND - { FN_VERT_ORIENT, true }, // RES_VERT_ORIENT - { FN_HORI_ORIENT, true }, // RES_HORI_ORIENT - { 0, false }, // RES_ANCHOR - { SID_ATTR_BRUSH, true }, // RES_BACKGROUND - { SID_ATTR_BORDER_OUTER, true }, // RES_BOX - { SID_ATTR_BORDER_SHADOW, true }, // RES_SHADOW - { SID_ATTR_MACROITEM, true }, // RES_FRMMACRO - { FN_ATTR_COLUMNS, true }, // RES_COL - { SID_ATTR_PARA_KEEP, true }, // RES_KEEP - { 0, true }, // RES_URL - { 0, true }, // RES_EDIT_IN_READONLY - - { 0, true }, // RES_LAYOUT_SPLIT - { 0, false }, // RES_CHAIN - { 0, true }, // RES_TEXTGRID - { FN_FORMAT_LINENUMBER, true }, // RES_LINENUMBER - { 0, true }, // RES_FTN_AT_TXTEND - { 0, true }, // RES_END_AT_TXTEND - { 0, true }, // RES_COLUMNBALANCE - - { SID_ATTR_FRAMEDIRECTION, true }, // RES_FRAMEDIR - - { SID_ATTR_HDFT_DYNAMIC_SPACING, true },// RES_HEADER_FOOTER_EAT_SPACING - { FN_TABLE_ROW_SPLIT, true }, // RES_ROW_SPLIT - { 0, true } , // RES_FLY_SPLIT + // _nSID, _bNeedsPoolRegistration, _bShareable + { SID_ATTR_CHAR_CASEMAP, false, true }, // RES_CHRATR_CASEMAP + { SID_ATTR_CHAR_CHARSETCOLOR, false, true }, // RES_CHRATR_CHARSETCOLOR + { SID_ATTR_CHAR_COLOR, true, true }, // RES_CHRATR_COLOR + { SID_ATTR_CHAR_CONTOUR, false, true }, // RES_CHRATR_CONTOUR + { SID_ATTR_CHAR_STRIKEOUT, false, true }, // RES_CHRATR_CROSSEDOUT + { SID_ATTR_CHAR_ESCAPEMENT, false, true }, // RES_CHRATR_ESCAPEMENT + { SID_ATTR_CHAR_FONT, true, true }, // RES_CHRATR_FONT + { SID_ATTR_CHAR_FONTHEIGHT, false, true }, // RES_CHRATR_FONTSIZE + { SID_ATTR_CHAR_KERNING, false, true }, // RES_CHRATR_KERNING + { SID_ATTR_CHAR_LANGUAGE, false, true }, // RES_CHRATR_LANGUAGE + { SID_ATTR_CHAR_POSTURE, false, true }, // RES_CHRATR_POSTURE + { 0, false, true }, // RES_CHRATR_UNUSED1 + { SID_ATTR_CHAR_SHADOWED, false, true }, // RES_CHRATR_SHADOWED + { SID_ATTR_CHAR_UNDERLINE, true, true }, // RES_CHRATR_UNDERLINE + { SID_ATTR_CHAR_WEIGHT, false, true }, // RES_CHRATR_WEIGHT + { SID_ATTR_CHAR_WORDLINEMODE, false, true }, // RES_CHRATR_WORDLINEMODE + { SID_ATTR_CHAR_AUTOKERN, false, true }, // RES_CHRATR_AUTOKERN + { SID_ATTR_FLASH, false, true }, // RES_CHRATR_BLINK + { 0, false, true }, // RES_CHRATR_UNUSED2 + { 0, false, true }, // RES_CHRATR_NOHYPHEN + { SID_ATTR_BRUSH_CHAR, true, true }, // RES_CHRATR_BACKGROUND + { SID_ATTR_CHAR_CJK_FONT, true, true }, // RES_CHRATR_CJK_FONT + { SID_ATTR_CHAR_CJK_FONTHEIGHT, false, true }, // RES_CHRATR_CJK_FONTSIZE + { SID_ATTR_CHAR_CJK_LANGUAGE, false, true }, // RES_CHRATR_CJK_LANGUAGE + { SID_ATTR_CHAR_CJK_POSTURE, false, true }, // RES_CHRATR_CJK_POSTURE + { SID_ATTR_CHAR_CJK_WEIGHT, false, true }, // RES_CHRATR_CJK_WEIGHT + { SID_ATTR_CHAR_CTL_FONT, true, true }, // RES_CHRATR_CTL_FONT + { SID_ATTR_CHAR_CTL_FONTHEIGHT, false, true }, // RES_CHRATR_CTL_FONTSIZE + { SID_ATTR_CHAR_CTL_LANGUAGE, false, true }, // RES_CHRATR_CTL_LANGUAGE + { SID_ATTR_CHAR_CTL_POSTURE, false, true }, // RES_CHRATR_CTL_POSTURE + { SID_ATTR_CHAR_CTL_WEIGHT, false, true }, // RES_CHRATR_CTL_WEIGHT + { SID_ATTR_CHAR_ROTATED, false, true }, // RES_CHRATR_ROTATE + { SID_ATTR_CHAR_EMPHASISMARK, false, true }, // RES_CHRATR_EMPHASIS_MARK + { SID_ATTR_CHAR_TWO_LINES, false, true }, // RES_CHRATR_TWO_LINES + { SID_ATTR_CHAR_SCALEWIDTH, false, true }, // RES_CHRATR_SCALEW + { SID_ATTR_CHAR_RELIEF, false, true }, // RES_CHRATR_RELIEF + { SID_ATTR_CHAR_HIDDEN, false, true }, // RES_CHRATR_HIDDEN + { SID_ATTR_CHAR_OVERLINE, true, true }, // RES_CHRATR_OVERLINE + { 0, false, true }, // RES_CHRATR_RSID + { SID_ATTR_CHAR_BOX, true, true }, // RES_CHRATR_BOX + { SID_ATTR_CHAR_SHADOW, false, true }, // RES_CHRATR_SHADOW + { 0, true, true }, // RES_CHRATR_HIGHLIGHT + { SID_ATTR_CHAR_GRABBAG, false, true }, // RES_CHRATR_GRABBAG + { 0, false, true }, // RES_CHRATR_BIDIRTL + { 0, false, true }, // RES_CHRATR_IDCTHINT + + { 0, true, false }, // RES_TXTATR_REFMARK + { 0, true, false }, // RES_TXTATR_TOXMARK + { 0, false, false }, // RES_TXTATR_META + { 0, false, false }, // RES_TXTATR_METAFIELD + { 0, false, true }, // RES_TXTATR_AUTOFMT + { FN_TXTATR_INET, true, false }, // RES_TXTATR_INETFMT + { 0, false, false }, // RES_TXTATR_CHARFMT + { SID_ATTR_CHAR_CJK_RUBY, true, false }, // RES_TXTATR_CJK_RUBY + { 0, true, true }, // RES_TXTATR_UNKNOWN_CONTAINER + { 0, true, false }, // RES_TXTATR_INPUTFIELD + { 0, false, false }, // RES_TXTATR_CONTENTCONTROL + + { 0, true, false }, // RES_TXTATR_FIELD + { 0, false, false }, // RES_TXTATR_FLYCNT + { 0, false, false }, // RES_TXTATR_FTN + { 0, false, false }, // RES_TXTATR_ANNOTATION + { 0, false, false }, // RES_TXTATR_LINEBREAK + { 0, false, true }, // RES_TXTATR_DUMMY1 + + { SID_ATTR_PARA_LINESPACE, false, true }, // RES_PARATR_LINESPACING + { SID_ATTR_PARA_ADJUST, false, true }, // RES_PARATR_ADJUST + { SID_ATTR_PARA_SPLIT, false, true }, // RES_PARATR_SPLIT + { SID_ATTR_PARA_ORPHANS, false, true }, // RES_PARATR_ORPHANS + { SID_ATTR_PARA_WIDOWS, false, true }, // RES_PARATR_WIDOWS + { SID_ATTR_TABSTOP, true, true }, // RES_PARATR_TABSTOP + { SID_ATTR_PARA_HYPHENZONE, false, true }, // RES_PARATR_HYPHENZONE + { FN_FORMAT_DROPCAPS, false, false }, // RES_PARATR_DROP + { SID_ATTR_PARA_REGISTER, false, true }, // RES_PARATR_REGISTER + { SID_ATTR_PARA_NUMRULE, false, true }, // RES_PARATR_NUMRULE + { SID_ATTR_PARA_SCRIPTSPACE, false, true }, // RES_PARATR_SCRIPTSPACE + { SID_ATTR_PARA_HANGPUNCTUATION, false, true }, // RES_PARATR_HANGINGPUNCTUATION + + { SID_ATTR_PARA_FORBIDDEN_RULES, false, true }, // RES_PARATR_FORBIDDEN_RULES + { SID_PARA_VERTALIGN, false, true }, // RES_PARATR_VERTALIGN + { SID_ATTR_PARA_SNAPTOGRID, false, true }, // RES_PARATR_SNAPTOGRID + { SID_ATTR_BORDER_CONNECT, false, true }, // RES_PARATR_CONNECT_BORDER + + { SID_ATTR_PARA_OUTLINE_LEVEL, false, true }, // RES_PARATR_OUTLINELEVEL //#outline level + { 0, false, true }, // RES_PARATR_RSID + { SID_ATTR_PARA_GRABBAG, false, true }, // RES_PARATR_GRABBAG + { 0, false, true }, // RES_PARATR_LIST_ID + { 0, false, true }, // RES_PARATR_LIST_LEVEL + { 0, false, true }, // RES_PARATR_LIST_ISRESTART + { 0, false, true }, // RES_PARATR_LIST_RESTARTVALUE + { 0, false, true }, // RES_PARATR_LIST_ISCOUNTED + { 0, false, true }, // RES_PARATR_LIST_AUTOFMT + + { 0, false, true }, // RES_FILL_ORDER + { 0, false, true }, // RES_FRM_SIZE + { SID_ATTR_PAGE_PAPERBIN, false, true }, // RES_PAPER_BIN + { SID_ATTR_PARA_FIRSTLINESPACE, false, true }, // RES_MARGIN_FIRSTLINE + { SID_ATTR_PARA_LEFTSPACE, false, true }, // RES_MARGIN_TEXTLEFT + { SID_ATTR_PARA_RIGHTSPACE, false, true }, // RES_MARGIN_RIGHT + { 0, false, true }, // RES_MARGIN_LEFT + { 0, false, true }, // RES_MARGIN_GUTTER + { 0, false, true }, // RES_MARGIN_GUTTER_RIGHT + { SID_ATTR_LRSPACE, false, true }, // RES_LR_SPACE + { SID_ATTR_ULSPACE, false, true }, // RES_UL_SPACE + { 0, true, false }, // RES_PAGEDESC + { SID_ATTR_PARA_PAGEBREAK, false, true }, // RES_BREAK + { 0, false, false }, // RES_CNTNT + { 0, false, true }, // RES_HEADER + { 0, false, true }, // RES_FOOTER + { 0, false, true }, // RES_PRINT + { FN_OPAQUE, false, true }, // RES_OPAQUE + { FN_SET_PROTECT, false, true }, // RES_PROTECT + { FN_SURROUND, false, true }, // RES_SURROUND + { FN_VERT_ORIENT, false, true }, // RES_VERT_ORIENT + { FN_HORI_ORIENT, false, true }, // RES_HORI_ORIENT + { 0, false, false }, // RES_ANCHOR + { SID_ATTR_BRUSH, true, true }, // RES_BACKGROUND + { SID_ATTR_BORDER_OUTER, true, true }, // RES_BOX + { SID_ATTR_BORDER_SHADOW, true, true }, // RES_SHADOW + { SID_ATTR_MACROITEM, false, true }, // RES_FRMMACRO + { FN_ATTR_COLUMNS, false, true }, // RES_COL + { SID_ATTR_PARA_KEEP, false, true }, // RES_KEEP + { 0, true, true }, // RES_URL + { 0, false, true }, // RES_EDIT_IN_READONLY + + { 0, false, true }, // RES_LAYOUT_SPLIT + { 0, false, false }, // RES_CHAIN + { 0, false, true }, // RES_TEXTGRID + { FN_FORMAT_LINENUMBER, false, true }, // RES_LINENUMBER + { 0, false, true }, // RES_FTN_AT_TXTEND + { 0, false, true }, // RES_END_AT_TXTEND + { 0, false, true }, // RES_COLUMNBALANCE + + { SID_ATTR_FRAMEDIRECTION, false, true }, // RES_FRAMEDIR + + { SID_ATTR_HDFT_DYNAMIC_SPACING, false, true }, // RES_HEADER_FOOTER_EAT_SPACING + { FN_TABLE_ROW_SPLIT, false, true }, // RES_ROW_SPLIT + { 0, false, true }, // RES_FLY_SPLIT // #i18732# - use slot-id define in svx - { SID_SW_FOLLOW_TEXT_FLOW, true }, // RES_FOLLOW_TEXT_FLOW + { SID_SW_FOLLOW_TEXT_FLOW, false, true }, // RES_FOLLOW_TEXT_FLOW // #i29550# - { SID_SW_COLLAPSING_BORDERS, true }, // RES_COLLAPSING_BORDERS + { SID_SW_COLLAPSING_BORDERS, false, true }, // RES_COLLAPSING_BORDERS // #i28701# - { SID_SW_WRAP_INFLUENCE_ON_OBJPOS, true },// RES_WRAP_INFLUENCE_ON_OBJPOS - { 0, false }, // RES_AUTO_STYLE - { 0, true }, // RES_FRMATR_STYLE_NAME - { 0, true }, // RES_FRMATR_CONDITIONAL_STYLE_NAME - { 0, true }, // RES_FRMATR_GRABBAG - { 0, true }, // RES_TEXT_VERT_ADJUST - { 0, true }, // RES_BACKGROUND_FULL_SIZE - { 0, true }, // RES_RTL_GUTTER - { 0, true }, // RES_DECORATIVE - - { 0, true }, // RES_GRFATR_MIRRORGRF - { SID_ATTR_GRAF_CROP, true }, // RES_GRFATR_CROPGRF - { 0, true }, // RES_GRFATR_ROTATION, - { 0, true }, // RES_GRFATR_LUMINANCE, - { 0, true }, // RES_GRFATR_CONTRAST, - { 0, true }, // RES_GRFATR_CHANNELR, - { 0, true }, // RES_GRFATR_CHANNELG, - { 0, true }, // RES_GRFATR_CHANNELB, - { 0, true }, // RES_GRFATR_GAMMA, - { 0, true }, // RES_GRFATR_INVERT, - { 0, true }, // RES_GRFATR_TRANSPARENCY, - { 0, true }, // RES_GRFATR_DUMMY3, - { 0, true }, // RES_GRFATR_DUMMY4, - { 0, true }, // RES_GRFATR_DUMMY5, - { 0, true }, // RES_GRFATR_DUMMY6, - - { 0, true }, // RES_BOXATR_FORMAT - { 0, false }, // RES_BOXATR_FORMULA, - { 0, true }, // RES_BOXATR_VALUE - - { 0, true } // RES_UNKNOWNATR_CONTAINER + { SID_SW_WRAP_INFLUENCE_ON_OBJPOS, false, true }, // RES_WRAP_INFLUENCE_ON_OBJPOS + { 0, false, false }, // RES_AUTO_STYLE + { 0, false, true }, // RES_FRMATR_STYLE_NAME + { 0, false, true }, // RES_FRMATR_CONDITIONAL_STYLE_NAME + { 0, false, true }, // RES_FRMATR_GRABBAG + { 0, false, true }, // RES_TEXT_VERT_ADJUST + { 0, false, true }, // RES_BACKGROUND_FULL_SIZE + { 0, false, true }, // RES_RTL_GUTTER + { 0, false, true }, // RES_DECORATIVE + + { 0, false, true }, // RES_GRFATR_MIRRORGRF + { SID_ATTR_GRAF_CROP, false, true }, // RES_GRFATR_CROPGRF + { 0, false, true }, // RES_GRFATR_ROTATION, + { 0, false, true }, // RES_GRFATR_LUMINANCE, + { 0, false, true }, // RES_GRFATR_CONTRAST, + { 0, false, true }, // RES_GRFATR_CHANNELR, + { 0, false, true }, // RES_GRFATR_CHANNELG, + { 0, false, true }, // RES_GRFATR_CHANNELB, + { 0, false, true }, // RES_GRFATR_GAMMA, + { 0, false, true }, // RES_GRFATR_INVERT, + { 0, false, true }, // RES_GRFATR_TRANSPARENCY, + { 0, false, true }, // RES_GRFATR_DUMMY3, + { 0, false, true }, // RES_GRFATR_DUMMY4, + { 0, false, true }, // RES_GRFATR_DUMMY5, + { 0, false, true }, // RES_GRFATR_DUMMY6, + + { 0, false, true }, // RES_BOXATR_FORMAT + { 0, true, false }, // RES_BOXATR_FORMULA, + { 0, false, true }, // RES_BOXATR_VALUE + + { 0, true, true } // RES_UNKNOWNATR_CONTAINER }; std::vector<SvGlobalName> *pGlobalOLEExcludeList = nullptr; diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 05ea83bfad70..acee83905967 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -416,12 +416,13 @@ bool SwCursorShell::GotoNxtPrvTableFormula( bool bNext, bool bOnlyErrors ) &rPos, &tmp) ); } - sal_uInt32 nMaxItems = GetDoc()->GetAttrPool().GetItemCount2( RES_BOXATR_FORMULA ); + const registeredSfxPoolItems& rSurrogates(GetDoc()->GetAttrPool().GetItemSurrogates(RES_BOXATR_FORMULA)); + const sal_uInt32 nMaxItems(rSurrogates.size()); if( nMaxItems > 0 ) { sal_uInt8 nMaxDo = 2; do { - for (const SfxPoolItem* pItem : GetDoc()->GetAttrPool().GetItemSurrogates(RES_BOXATR_FORMULA)) + for (const SfxPoolItem* pItem : rSurrogates) { const SwTableBox* pTBox; auto pFormulaItem = dynamic_cast<const SwTableBoxFormula*>(pItem); @@ -521,7 +522,8 @@ bool SwCursorShell::GotoNxtPrvTOXMark( bool bNext ) const SwTextNode* pTextNd; const SwTextTOXMark* pTextTOX; - sal_uInt32 nMaxItems = GetDoc()->GetAttrPool().GetItemCount2( RES_TXTATR_TOXMARK ); + const registeredSfxPoolItems& rSurrogates(GetDoc()->GetAttrPool().GetItemSurrogates(RES_TXTATR_TOXMARK)); + const sal_uInt32 nMaxItems(rSurrogates.size()); if( nMaxItems == 0 ) { SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound ); @@ -529,7 +531,7 @@ bool SwCursorShell::GotoNxtPrvTOXMark( bool bNext ) } do { - for (const SfxPoolItem* pItem : GetDoc()->GetAttrPool().GetItemSurrogates(RES_TXTATR_TOXMARK)) + for (const SfxPoolItem* pItem : rSurrogates) { auto pToxMarkItem = dynamic_cast<const SwTOXMark*>(pItem); if( !pToxMarkItem ) diff --git a/sw/source/core/doc/docbasic.cxx b/sw/source/core/doc/docbasic.cxx index c28a15f12bf5..697559b0b469 100644 --- a/sw/source/core/doc/docbasic.cxx +++ b/sw/source/core/doc/docbasic.cxx @@ -143,7 +143,7 @@ sal_uInt16 SwDoc::CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCall for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_INETFMT)) { auto pFormatItem = dynamic_cast<const SwFormatINetFormat*>(pItem); - if( pFormatItem && rCallEvent.PTR.pINetAttr == pFormatItem ) + if( pFormatItem && SfxPoolItem::areSame(rCallEvent.PTR.pINetAttr, pFormatItem) ) { bCheckPtr = false; // misuse as a flag break; diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 82051e0be6a8..f03687d810e4 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -247,7 +247,8 @@ const SwTOXMark& SwDoc::GotoTOXMark( const SwTOXMark& rCurTOXMark, for(SwTOXMark* pTOXMark : aMarks) { - if ( pTOXMark == &rCurTOXMark ) + // Item PtrCompare needed here + if (areSfxPoolItemPtrsEqual( pTOXMark, &rCurTOXMark )) continue; pMark = pTOXMark->GetTextTOXMark(); diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx index 5561b882ee3f..4d87241a03ba 100644 --- a/sw/source/core/doc/fmtcol.cxx +++ b/sw/source/core/doc/fmtcol.cxx @@ -237,7 +237,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH const SvxFirstLineIndentItem *pOldFirstLineIndent(GetItemIfSet(RES_MARGIN_FIRSTLINE, false)); if (pNewFirstLineIndent && pOldFirstLineIndent) { - if (pOldFirstLineIndent != pNewFirstLineIndent) // Avoid recursion (SetAttr!) + if (!SfxPoolItem::areSame(pOldFirstLineIndent, pNewFirstLineIndent)) // Avoid recursion (SetAttr!) { bool bChg = false; SvxFirstLineIndentItem aNew(*pOldFirstLineIndent); @@ -263,7 +263,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH const SvxTextLeftMarginItem *pOldTextLeftMargin(GetItemIfSet(RES_MARGIN_TEXTLEFT, false)); if (pNewTextLeftMargin && pOldTextLeftMargin) { - if (pOldTextLeftMargin != pNewTextLeftMargin) // Avoid recursion (SetAttr!) + if (!SfxPoolItem::areSame(pOldTextLeftMargin, pNewTextLeftMargin)) // Avoid recursion (SetAttr!) { bool bChg = false; SvxTextLeftMarginItem aNew(*pOldTextLeftMargin); @@ -289,7 +289,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH const SvxRightMarginItem *pOldRightMargin(GetItemIfSet(RES_MARGIN_RIGHT, false)); if (pNewRightMargin && pOldRightMargin) { - if (pOldRightMargin != pNewRightMargin) // Avoid recursion (SetAttr!) + if (!SfxPoolItem::areSame(pOldRightMargin, pNewRightMargin)) // Avoid recursion (SetAttr!) { bool bChg = false; SvxRightMarginItem aNew(*pOldRightMargin); @@ -313,7 +313,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH } if( pNewULSpace && (pOldULSpace = GetItemIfSet(RES_UL_SPACE, false)) && - pOldULSpace != pNewULSpace ) // Avoid recursion (SetAttr!) + !SfxPoolItem::areSame(pOldULSpace, pNewULSpace) ) // Avoid recursion (SetAttr!) { SvxULSpaceItem aNew( *pOldULSpace ); bool bChg = false; @@ -348,7 +348,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH if( pFSize && (SfxItemState::SET == GetItemState( pFSize->Which(), false, reinterpret_cast<const SfxPoolItem**>(&pOldFSize) )) && // Avoid recursion (SetAttr!) - pFSize != pOldFSize ) + !SfxPoolItem::areSame(pFSize, pOldFSize) ) { if( 100 == pOldFSize->GetProp() && MapUnit::MapRelative == pOldFSize->GetPropUnit() ) diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 6cfab7801f43..b2419bd132ec 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1174,13 +1174,13 @@ void SwContentNode::SwClientNotify( const SwModify&, const SfxHint& rHint) // Thus we are asserting here, but falling back to an proper // hint instead. so that we at least will not spread such poison further. #ifdef DBG_UTIL - if(pLegacyHint->m_pNew != pLegacyHint->m_pOld) + if (!SfxPoolItem::areSame(pLegacyHint->m_pNew, pLegacyHint->m_pOld)) { auto pBT = sal::backtrace_get(20); SAL_WARN("sw.core", "UpdateAttr not matching! " << sal::backtrace_to_string(pBT.get())); } #endif - assert(pLegacyHint->m_pNew == pLegacyHint->m_pOld); + assert(SfxPoolItem::areSame(pLegacyHint->m_pNew, pLegacyHint->m_pOld)); assert(dynamic_cast<const SwUpdateAttr*>(pLegacyHint->m_pNew)); const SwUpdateAttr aFallbackHint(0,0,0); const SwUpdateAttr& rUpdateAttr = pLegacyHint->m_pNew ? *static_cast<const SwUpdateAttr*>(pLegacyHint->m_pNew) : aFallbackHint; diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index b3dd57ca6c7f..ee4a451d16dc 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -634,9 +634,6 @@ SwFormatPageDesc::SwFormatPageDesc( const SwFormatPageDesc &rCpy ) m_oNumOffset( rCpy.m_oNumOffset ), m_pDefinedIn( nullptr ) { - // ITEM: mark this Item to be non-shareable/non-RefCountable. For more - // info see comment @SwAttrSet::SetModifyAtAttr - m_bShareable = false; } SwFormatPageDesc::SwFormatPageDesc( const SwPageDesc *pDesc ) @@ -644,14 +641,11 @@ SwFormatPageDesc::SwFormatPageDesc( const SwPageDesc *pDesc ) SwClient( const_cast<SwPageDesc*>(pDesc) ), m_pDefinedIn( nullptr ) { - // ITEM: mark this Item to be non-shareable/non-RefCountable. For more - // info see comment @SwAttrSet::SetModifyAtAttr - m_bShareable = false; } SwFormatPageDesc &SwFormatPageDesc::operator=(const SwFormatPageDesc &rCpy) { - if(this == &rCpy) + if (SfxPoolItem::areSame(this, &rCpy)) return *this; if (rCpy.GetPageDesc()) @@ -865,7 +859,7 @@ SwFormatCol::~SwFormatCol() {} SwFormatCol& SwFormatCol::operator=( const SwFormatCol& rCpy ) { - if (this != &rCpy) + if (!SfxPoolItem::areSame(this, &rCpy)) { m_eLineStyle = rCpy.m_eLineStyle; m_nLineWidth = rCpy.m_nLineWidth; @@ -1650,7 +1644,7 @@ sal_Int32 SwFormatAnchor::GetAnchorContentOffset() const SwFormatAnchor& SwFormatAnchor::operator=(const SwFormatAnchor& rAnchor) { - if (this != &rAnchor) + if (!SfxPoolItem::areSame(this, &rAnchor)) { m_eAnchorId = rAnchor.m_eAnchorId; m_nPageNumber = rAnchor.m_nPageNumber; diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index 7afcb6b89800..fdbcb5a57092 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -147,7 +147,7 @@ void SwSectionFrame::Init() { const SwFormatCol *pOld = Lower() ? &rCol : new SwFormatCol; ChgColumns( *pOld, rCol, IsAnyNoteAtEnd() ); - if( pOld != &rCol ) + if (!SfxPoolItem::areSame( pOld, &rCol )) delete pOld; } } diff --git a/sw/source/core/para/paratr.cxx b/sw/source/core/para/paratr.cxx index 7d57bcd3c7a4..f724ac21c0fe 100644 --- a/sw/source/core/para/paratr.cxx +++ b/sw/source/core/para/paratr.cxx @@ -44,9 +44,6 @@ SwFormatDrop::SwFormatDrop() m_nChars( 0 ), m_bWholeWord( false ) { - // ITEM: mark this Item to be non-shareable/non-RefCountable. For more - // info see comment @SwAttrSet::SetModifyAtAttr - m_bShareable = false; } SwFormatDrop::SwFormatDrop( const SwFormatDrop &rCpy ) @@ -58,9 +55,6 @@ SwFormatDrop::SwFormatDrop( const SwFormatDrop &rCpy ) m_nChars( rCpy.GetChars() ), m_bWholeWord( rCpy.GetWholeWord() ) { - // ITEM: mark this Item to be non-shareable/non-RefCountable. For more - // info see comment @SwAttrSet::SetModifyAtAttr - m_bShareable = false; } SwFormatDrop::~SwFormatDrop() diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx index 4e1386f4e21a..3cc2e3670711 100644 --- a/sw/source/core/table/swnewtable.cxx +++ b/sw/source/core/table/swnewtable.cxx @@ -2383,7 +2383,7 @@ bool SwTable::CanConvertSubtables() const { return false; // no formulas in fields yet } - if (pDoc->GetAttrPool().GetItemCount2(RES_BOXATR_FORMULA) != 0) + if (pDoc->GetAttrPool().GetItemSurrogates(RES_BOXATR_FORMULA).size() != 0) { return false; // no table box formulas yet } diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index d50c493079a2..a5540a491b0e 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -1630,16 +1630,16 @@ bool SwTable::IsDeleted() const void SwTable::GatherFormulas(std::vector<SwTableBoxFormula*>& rvFormulas) { - for(SfxPoolItem* pItem: GetFrameFormat()->GetDoc()->GetAttrPool().GetItemSurrogates(RES_BOXATR_FORMULA)) + for(const SfxPoolItem* pItem: GetFrameFormat()->GetDoc()->GetAttrPool().GetItemSurrogates(RES_BOXATR_FORMULA)) { - auto pBoxFormula = dynamic_cast<SwTableBoxFormula*>(pItem); + auto pBoxFormula = dynamic_cast<const SwTableBoxFormula*>(pItem); assert(pBoxFormula); // use StaticWhichCast instead? if(!pBoxFormula->GetDefinedIn()) continue; const SwNode* pNd = pBoxFormula->GetNodeOfFormula(); if(!pNd || &pNd->GetNodes() != &pNd->GetDoc().GetNodes()) // is this ever valid or should we assert here? continue; - rvFormulas.push_back(pBoxFormula); + rvFormulas.push_back(const_cast<SwTableBoxFormula*>(pBoxFormula)); } } diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index 358d6d5068f3..24203ecb531c 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -659,9 +659,9 @@ static bool CanSkipOverRedline( } for (size_t i = 0; i < SAL_N_ELEMENTS(activeCharAttrsStart); ++i) { - // all of these are poolable -// assert(!activeCharAttrsStart[i] || activeCharAttrsStart[i]->GetItemPool()->IsItemPoolable(*activeCharAttrsStart[i])); - if (activeCharAttrsStart[i] != activeCharAttrsEnd[i]) + // all of these should be shareable (but we have no SfxItemPool to check it here) + // assert(!activeCharAttrsStart[i] || activeCharAttrsStart[i]->GetItemPool()->Shareable(*activeCharAttrsStart[i])); + if (!SfxPoolItem::areSame(activeCharAttrsStart[i], activeCharAttrsEnd[i])) { if (!isTheAnswerYes) return false; } diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index 67cd13af4d6d..4e7268698efc 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -1080,7 +1080,7 @@ std::optional<SwMultiCreator> SwTextSizeInfo::GetMultiCreator(TextFrameIndex &rP return aRet; } if (pActiveTwoLinesHint || - (pNodeTwoLinesItem && pNodeTwoLinesItem == pActiveTwoLinesItem && + (pNodeTwoLinesItem && SfxPoolItem::areSame(pNodeTwoLinesItem, pActiveTwoLinesItem) && rPos < TextFrameIndex(GetText().getLength()))) { // The winner is a 2-line-attribute, // the end of the multiportion depends on the following attributes... @@ -1228,7 +1228,7 @@ std::optional<SwMultiCreator> SwTextSizeInfo::GetMultiCreator(TextFrameIndex &rP return aRet; } if (pActiveRotateHint || - (pNodeRotateItem && pNodeRotateItem == pActiveRotateItem && + (pNodeRotateItem && SfxPoolItem::areSame(pNodeRotateItem, pActiveRotateItem) && rPos < TextFrameIndex(GetText().getLength()))) { // The winner is a rotate-attribute, // the end of the multiportion depends on the following attributes... diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index a86dfcaf175f..470ce8b528fd 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -2459,7 +2459,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) nPos = MapModelToView(&rNode, nNPos); if (IsIdxInside(nPos, TextFrameIndex(1))) { - if( pNew == pOld ) + if (SfxPoolItem::areSame( pNew, pOld )) { // only repaint // opt: invalidate window? @@ -2518,7 +2518,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) { const SfxPoolItem* pOldItem = pOld ? &(static_cast<const SwAttrSetChg*>(pOld)->GetChgSet()->Get(RES_TXTATR_FIELD)) : nullptr; - if( pItem == pOldItem ) + if (SfxPoolItem::areSame( pItem, pOldItem )) { InvalidatePage(); SetCompletePaint(); diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx index 34db9fde8aaa..1782f23fb526 100644 --- a/sw/source/core/txtnode/attrcontentcontrol.cxx +++ b/sw/source/core/txtnode/attrcontentcontrol.cxx @@ -67,7 +67,9 @@ SwFormatContentControl::SwFormatContentControl( SwFormatContentControl::~SwFormatContentControl() { - if (m_pContentControl && (m_pContentControl->GetFormatContentControl() == this)) + if (m_pContentControl + // SwFormatContentControl is not shareable, so ptr compare is OK + && areSfxPoolItemPtrsEqual(m_pContentControl->GetFormatContentControl(), this)) { NotifyChangeTextNode(nullptr); m_pContentControl->SetFormatContentControl(nullptr); @@ -116,7 +118,8 @@ void SwFormatContentControl::SetTextAttr(SwTextContentControl* pTextAttr) { m_pContentControl->SetFormatContentControl(this); } - else if (m_pContentControl->GetFormatContentControl() == this) + // SwFormatContentControl is not shareable, so ptr compare is OK + else if (areSfxPoolItemPtrsEqual(m_pContentControl->GetFormatContentControl(), this)) { // The text attribute is gone, so de-register from text node. NotifyChangeTextNode(nullptr); @@ -132,7 +135,9 @@ void SwFormatContentControl::NotifyChangeTextNode(SwTextNode* pTextNode) { SAL_WARN("sw.core", "SwFormatContentControl::NotifyChangeTextNode: no content control?"); } - if (m_pContentControl && (m_pContentControl->GetFormatContentControl() == this)) + if (m_pContentControl + // SwFormatContentControl is not shareable, so ptr compare is OK + && areSfxPoolItemPtrsEqual(m_pContentControl->GetFormatContentControl(), this)) { // Not calling Modify, that would call SwXContentControl::SwClientNotify. m_pContentControl->NotifyChangeTextNode(pTextNode); diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 7792d0183d54..3a57680fa51b 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -428,7 +428,8 @@ SwFormatRuby::~SwFormatRuby() SwFormatRuby& SwFormatRuby::operator=( const SwFormatRuby& rAttr ) { - if(this == &rAttr) + // SwFormatRuby is not shareable, so ptr compare is OK + if (areSfxPoolItemPtrsEqual(this, &rAttr)) return *this; m_sRubyText = rAttr.m_sRubyText; @@ -568,7 +569,8 @@ SwFormatMeta::SwFormatMeta( std::shared_ptr< ::sw::Meta > i_pMeta, SwFormatMeta::~SwFormatMeta() { - if (m_pMeta && (m_pMeta->GetFormatMeta() == this)) + // SwFormatMeta is not shareable, so ptr compare is OK + if (m_pMeta && areSfxPoolItemPtrsEqual(m_pMeta->GetFormatMeta(), this)) { NotifyChangeTextNode(nullptr); m_pMeta->SetFormatMeta(nullptr); @@ -603,7 +605,8 @@ void SwFormatMeta::SetTextAttr(SwTextMeta * const i_pTextAttr) { m_pMeta->SetFormatMeta(this); } - else if (m_pMeta->GetFormatMeta() == this) + // SwFormatMeta is not shareable, so ptr compare is OK + else if (areSfxPoolItemPtrsEqual(m_pMeta->GetFormatMeta(), this)) { // text attribute gone => de-register from text node! NotifyChangeTextNode(nullptr); m_pMeta->SetFormatMeta(nullptr); @@ -616,7 +619,8 @@ void SwFormatMeta::NotifyChangeTextNode(SwTextNode *const pTextNode) // N.B.: do not reset m_pTextAttr here: see call in nodes.cxx, // where the hint is not deleted! OSL_ENSURE(m_pMeta, "SwFormatMeta::NotifyChangeTextNode: no Meta?"); - if (m_pMeta && (m_pMeta->GetFormatMeta() == this)) + // SwFormatMeta is not shareable, so ptr compare is OK + if (m_pMeta && areSfxPoolItemPtrsEqual(m_pMeta->GetFormatMeta(), this)) { // do not call Modify, that would call SwXMeta::SwClientNotify m_pMeta->NotifyChangeTextNode(pTextNode); } diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 71c1ed75d059..0556facafe19 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -899,7 +899,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint, { const SfxPoolItem* pTmpItem = nullptr; if ( SfxItemState::SET == rWholeParaAttrSet.GetItemState( pItem->Which(), false, &pTmpItem ) && - pTmpItem == pItem ) + SfxPoolItem::areSame(pTmpItem, pItem) ) { // Do not clear item if the attribute is set in a character format: if ( !pCurrentCharFormat || nullptr == CharFormat::GetItem( *pCurrentCharFormat, pItem->Which() ) ) @@ -936,8 +936,9 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint, do { const SfxPoolItem* pTmpItem = nullptr; + // here direct SfxPoolItem ptr comp was wrong, found using SfxPoolItem::areSame if ( SfxItemState::SET == rWholeParaAttrSet.GetItemState( pItem->Which(), false, &pTmpItem ) && - pTmpItem == pItem ) + SfxPoolItem::areSame(pTmpItem, pItem) ) { // Do not clear item if the attribute is set in a character format: if ( !pCurrentCharFormat || nullptr == CharFormat::GetItem( *pCurrentCharFormat, pItem->Which() ) ) @@ -1023,7 +1024,7 @@ SwTextAttr* MakeRedlineTextAttr( SwDoc & rDoc, SfxPoolItem const & rAttr ) // Put new attribute into pool // FIXME: this const_cast is evil! SfxPoolItem& rNew = - const_cast<SfxPoolItem&>( rDoc.GetAttrPool().Put( rAttr ) ); + const_cast<SfxPoolItem&>( rDoc.GetAttrPool().DirectPutItemInPool( rAttr ) ); return new SwTextAttrEnd( rNew, 0, 0 ); } @@ -1061,7 +1062,7 @@ SwTextAttr* MakeTextAttr( // Put new attribute into pool // FIXME: this const_cast is evil! SfxPoolItem& rNew = - const_cast<SfxPoolItem&>( rDoc.GetAttrPool().Put( rAttr ) ); + const_cast<SfxPoolItem&>( rDoc.GetAttrPool().DirectPutItemInPool( rAttr ) ); SwTextAttr* pNew = nullptr; switch( rNew.Which() ) @@ -2981,18 +2982,22 @@ static MergeResult lcl_Compare_Attributes( pItem1 = iter1.NextItem(); if (pItem2 && pItem2->Which() == RES_CHRATR_RSID) pItem2 = iter2.NextItem(); - if (!pItem1 && !pItem2) + + if (nullptr == pItem1 && nullptr == pItem2) { eMerge = DIFFER_ONLY_RSID; break; } - if (!pItem1 || !pItem2) + + if (nullptr == pItem1 || nullptr == pItem2) { + // one ptr is nullptr, not both, that would + // have triggered above return DIFFER; } - if (pItem1 != pItem2) // all are poolable + + if (!SfxPoolItem::areSame(*pItem1, *pItem2)) { - assert(IsInvalidItem(pItem1) || IsInvalidItem(pItem2) || pItem1->Which() != pItem2->Which() || *pItem1 != *pItem2); return DIFFER; } pItem1 = iter1.NextItem(); diff --git a/sw/source/core/txtnode/txatbase.cxx b/sw/source/core/txtnode/txatbase.cxx index df347860db11..1d57f0e0dda5 100644 --- a/sw/source/core/txtnode/txatbase.cxx +++ b/sw/source/core/txtnode/txatbase.cxx @@ -60,7 +60,7 @@ void SwTextAttr::Destroy( SwTextAttr * pToDestroy, SfxItemPool& rPool ) if (!pToDestroy) return; SfxPoolItem * const pAttr = pToDestroy->m_pAttr; delete pToDestroy; - rPool.Remove( *pAttr ); + rPool.DirectRemoveItemFromPool( *pAttr ); } bool SwTextAttr::operator==( const SwTextAttr& rAttr ) const diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index d17c08e4795b..9a18fde99ffe 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -502,7 +502,7 @@ void SwHistorySetFootnote::SetInDoc( SwDoc* pDoc, bool ) // set the footnote in the TextNode SwFormatFootnote aTemp( m_bEndNote ); SwFormatFootnote& rNew = const_cast<SwFormatFootnote&>( - pDoc->GetAttrPool().Put(aTemp) ); + pDoc->GetAttrPool().DirectPutItemInPool(aTemp) ); if ( !m_FootnoteNumber.isEmpty() ) { rNew.SetNumStr( m_FootnoteNumber ); @@ -1382,7 +1382,7 @@ void SwRegHistory::SwClientNotify(const SwModify&, const SfxHint& rHint) if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint); - if ( !(m_pHistory && pLegacyHint->m_pNew && pLegacyHint->m_pOld != pLegacyHint->m_pNew) ) + if ( !(m_pHistory && pLegacyHint->m_pNew && !areSfxPoolItemPtrsEqual(pLegacyHint->m_pOld, pLegacyHint->m_pNew) ) ) return; if ( pLegacyHint->m_pNew->Which() < POOLATTR_END ) diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index 66ccb4073bc3..7e694e21b7d2 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -683,7 +683,7 @@ void SwUndoResetAttr::RedoImpl(::sw::UndoRedoContext & rContext) break; case RES_TXTATR_REFMARK: { - SfxItemPool::Item2Range aRange = rDoc.GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK); + const registeredSfxPoolItems& aRange(rDoc.GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK)); SwHistoryHint* pHistoryHint = GetHistory()[0]; if (pHistoryHint && HSTRY_SETREFMARKHNT == pHistoryHint->Which()) { diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index 781c5555a6f6..f0430b965bc2 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -648,7 +648,7 @@ void SwUndoSetFlyFormat::RedoImpl(::sw::UndoRedoContext & rContext) void SwUndoSetFlyFormat::PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem ) { - if( pItem && pItem != GetDfltAttr( nWhich ) ) + if( pItem && !SfxPoolItem::areSame(pItem, GetDfltAttr( nWhich ) ) ) { // Special treatment for this anchor if( RES_ANCHOR == nWhich ) diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index b86fbc675730..43b0690ecb08 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -284,7 +284,7 @@ SwXReferenceMark::getAnchor() { SwFormatRefMark const*const pNewMark = m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); - if (pNewMark && (pNewMark == m_pImpl->m_pMarkFormat)) + if (pNewMark && SfxPoolItem::areSame(pNewMark, m_pImpl->m_pMarkFormat)) { SwTextRefMark const*const pTextMark = m_pImpl->m_pMarkFormat->GetTextRefMark(); @@ -315,7 +315,7 @@ void SAL_CALL SwXReferenceMark::dispose() { SwFormatRefMark const*const pNewMark = m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); - if (pNewMark && (pNewMark == m_pImpl->m_pMarkFormat)) + if (pNewMark && SfxPoolItem::areSame(pNewMark, m_pImpl->m_pMarkFormat)) { SwTextRefMark const*const pTextMark = m_pImpl->m_pMarkFormat->GetTextRefMark(); @@ -385,7 +385,7 @@ void SAL_CALL SwXReferenceMark::setName(const OUString& rName) SwFormatRefMark const*const pCurMark = m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); if ((rName != m_pImpl->m_sMarkName) - && pCurMark && (pCurMark == m_pImpl->m_pMarkFormat)) + && pCurMark && SfxPoolItem::areSame(pCurMark, m_pImpl->m_pMarkFormat)) { const UnoActionContext aCont(m_pImpl->m_pDoc); SwTextRefMark const*const pTextMark = diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index d33cd0a81652..731a7c42d770 100644 --- a/sw/source/filter/basflt/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx @@ -915,7 +915,7 @@ void SwFltAnchorListener::Notify(const SfxHint& rHint) bool SwFltRedline::operator==(const SfxPoolItem& rItem) const { return SfxPoolItem::operator==(rItem) && - this == &rItem; + SfxPoolItem::areSame(this, &rItem); } SwFltRedline* SwFltRedline::Clone( SfxItemPool* ) const diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index 5ed18a2cad7c..448a64a2f2a5 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -63,7 +63,7 @@ void Writer_Impl::RemoveFontList( SwDoc& rDoc ) { for( const auto& rpFontItem : aFontRemoveLst ) { - rDoc.GetAttrPool().Remove( *rpFontItem ); + rDoc.GetAttrPool().DirectRemoveItemFromPool( *rpFontItem ); } } @@ -379,13 +379,13 @@ void Writer::AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont ) { SvxFontItem aFont( rFont ); aFont.SetWhich( RES_CHRATR_FONT ); - pItem = &rPool.Put( aFont ); + pItem = &rPool.DirectPutItemInPool( aFont ); } else - pItem = &rPool.Put( rFont ); + pItem = &rPool.DirectPutItemInPool( rFont ); if( 1 < pItem->GetRefCount() ) - rPool.Remove( *pItem ); + rPool.DirectRemoveItemFromPool( *pItem ); else { m_pImpl->aFontRemoveLst.push_back( pItem ); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 06f96f23d24f..fdadb13d34a7 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3330,7 +3330,7 @@ void MSWordExportBase::AddLinkTarget(std::u16string_view rURL) { pMark = &m_rDoc.GotoTOXMark(*pMark, TOX_SAME_NXT, true); } - if (pMark != &tmp->first) + if (!SfxPoolItem::areSame(pMark, &tmp->first)) { m_TOXMarkBookmarksByURL.emplace(aURL, name); m_TOXMarkBookmarksByTOXMark.emplace(pMark, nameDecoded); diff --git a/sw/source/filter/xml/xmlfonte.cxx b/sw/source/filter/xml/xmlfonte.cxx index b8c0f7730d57..c6a9c89cb6ca 100644 --- a/sw/source/filter/xml/xmlfonte.cxx +++ b/sw/source/filter/xml/xmlfonte.cxx @@ -39,6 +39,24 @@ public: } +namespace +{ +sal_Int32 CompareTo(sal_Int32 nA, sal_Int32 nB) +{ + if (nA < nB) + { + return -1; + } + + if (nA > nB) + { + return 1; + } + + return 0; +} +} + SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(SwXMLExport& _rExport, bool bFontEmbedding) : XMLFontAutoStylePool(_rExport, bFontEmbedding) { @@ -60,7 +78,34 @@ SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(SwXMLExport& _rExport, } std::sort(aFonts.begin(), aFonts.end(), - [](const SvxFontItem* pA, const SvxFontItem* pB) -> bool { return *pA < *pB; }); + [](const SvxFontItem* pA, const SvxFontItem* pB) -> bool + { + sal_Int32 nRet = pA->GetFamilyName().compareTo(pB->GetFamilyName()); + if (nRet != 0) + { + return nRet < 0; + } + + nRet = pA->GetStyleName().compareTo(pB->GetStyleName()); + if (nRet != 0) + { + return nRet < 0; + } + + nRet = CompareTo(pA->GetFamily(), pB->GetFamily()); + if (nRet != 0) + { + return nRet < 0; + } + + nRet = CompareTo(pA->GetPitch(), pB->GetPitch()); + if (nRet != 0) + { + return nRet < 0; + } + + return pA->GetCharSet() < pB->GetCharSet(); + }); for (const auto& pFont : aFonts) { Add(pFont->GetFamilyName(), pFont->GetStyleName(), pFont->GetFamily(), pFont->GetPitch(), diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index 52904b73d68e..39443f7e7b04 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -287,19 +287,19 @@ void SwIndexMarkPane::InitControls() bool bShow = false; pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_PRV ); - if( pMoveMark != pMark ) + if (!SfxPoolItem::areSame( pMoveMark, pMark )) { m_pSh->GotoTOXMark( *pMoveMark, TOX_NXT ); bShow = true; } - m_xPrevBT->set_sensitive(pMoveMark != pMark); + m_xPrevBT->set_sensitive(!SfxPoolItem::areSame(pMoveMark, pMark)); pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_NXT ); - if( pMoveMark != pMark ) + if (!SfxPoolItem::areSame( pMoveMark, pMark )) { m_pSh->GotoTOXMark( *pMoveMark, TOX_PRV ); bShow = true; } - m_xNextBT->set_sensitive(pMoveMark != pMark); + m_xNextBT->set_sensitive(!SfxPoolItem::areSame(pMoveMark, pMark)); if( bShow ) { m_xPrevBT->show(); @@ -308,19 +308,19 @@ void SwIndexMarkPane::InitControls() } pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_SAME_PRV ); - if( pMoveMark != pMark ) + if (!SfxPoolItem::areSame( pMoveMark, pMark )) { m_pSh->GotoTOXMark( *pMoveMark, TOX_SAME_NXT ); bShow = true; } - m_xPrevSameBT->set_sensitive(pMoveMark != pMark); + m_xPrevSameBT->set_sensitive(!SfxPoolItem::areSame(pMoveMark, pMark)); pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_SAME_NXT ); - if( pMoveMark != pMark ) + if (!SfxPoolItem::areSame( pMoveMark, pMark )) { m_pSh->GotoTOXMark( *pMoveMark, TOX_SAME_PRV ); bShow = true; } - m_xNextSameBT->set_sensitive(pMoveMark != pMark); + m_xNextSameBT->set_sensitive(!SfxPoolItem::areSame(pMoveMark, pMark)); if( bShow ) { m_xNextSameBT->show(); @@ -894,25 +894,25 @@ void SwIndexMarkPane::UpdateDialog() if( m_xPrevBT->get_visible() ) { const SwTOXMark* pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_PRV ); - if( pMoveMark != pMark ) + if (!SfxPoolItem::areSame( pMoveMark, pMark )) m_pSh->GotoTOXMark( *pMoveMark, TOX_NXT ); - m_xPrevBT->set_sensitive( pMoveMark != pMark ); + m_xPrevBT->set_sensitive( !SfxPoolItem::areSame(pMoveMark, pMark) ); pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_NXT ); - if( pMoveMark != pMark ) + if (!SfxPoolItem::areSame( pMoveMark, pMark )) m_pSh->GotoTOXMark( *pMoveMark, TOX_PRV ); - m_xNextBT->set_sensitive( pMoveMark != pMark ); + m_xNextBT->set_sensitive( !SfxPoolItem::areSame(pMoveMark, pMark) ); } if (m_xPrevSameBT->get_visible()) { const SwTOXMark* pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_SAME_PRV ); - if( pMoveMark != pMark ) + if (!SfxPoolItem::areSame( pMoveMark, pMark )) m_pSh->GotoTOXMark( *pMoveMark, TOX_SAME_NXT ); - m_xPrevSameBT->set_sensitive( pMoveMark != pMark ); + m_xPrevSameBT->set_sensitive( !SfxPoolItem::areSame(pMoveMark, pMark) ); pMoveMark = &m_pSh->GotoTOXMark( *pMark, TOX_SAME_NXT ); - if( pMoveMark != pMark ) + if (!SfxPoolItem::areSame( pMoveMark, pMark )) m_pSh->GotoTOXMark( *pMoveMark, TOX_SAME_PRV ); - m_xNextSameBT->set_sensitive( pMoveMark != pMark ); + m_xNextSameBT->set_sensitive( !SfxPoolItem::areSame(pMoveMark, pMark) ); } const bool bEnable = !m_pSh->HasReadonlySel(); @@ -1013,7 +1013,7 @@ void SwIndexMarkPane::ReInitDlg(SwWrtShell& rWrtShell, SwTOXMark const * pCurTOX if(pCurTOXMark) { for(sal_uInt16 i = 0; i < m_pTOXMgr->GetTOXMarkCount(); i++) - if(m_pTOXMgr->GetTOXMark(i) == pCurTOXMark) + if (SfxPoolItem::areSame(m_pTOXMgr->GetTOXMark(i), pCurTOXMark)) { m_pTOXMgr->SetCurTOXMark(i); break; diff --git a/sw/source/uibase/index/toxmgr.cxx b/sw/source/uibase/index/toxmgr.cxx index 5fc78fc18053..8b8ff6dbd8ec 100644 --- a/sw/source/uibase/index/toxmgr.cxx +++ b/sw/source/uibase/index/toxmgr.cxx @@ -47,7 +47,7 @@ void SwTOXMgr::DeleteTOXMark() if( m_pCurTOXMark ) { pNext = const_cast<SwTOXMark*>(&m_pSh->GotoTOXMark( *m_pCurTOXMark, TOX_NXT )); - if( pNext == m_pCurTOXMark ) + if (SfxPoolItem::areSame( pNext, m_pCurTOXMark )) pNext = nullptr; m_pSh->DeleteTOXMark( m_pCurTOXMark ); diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx index 65c41becb0c3..0976b6cb42c0 100644 --- a/sw/source/uibase/shells/frmsh.cxx +++ b/sw/source/uibase/shells/frmsh.cxx @@ -1093,7 +1093,7 @@ void SwFrameShell::ExecFrameStyle(SfxRequest const & rReq) rSh.GetFlyFrameAttr( aFrameSet ); const SvxBoxItem& rBoxItem = aFrameSet.Get(RES_BOX); - if (pPoolBoxItem == &rBoxItem) + if (SfxPoolItem::areSame(pPoolBoxItem, &rBoxItem)) bDefault = true; std::unique_ptr<SvxBoxItem> aBoxItem(rBoxItem.Clone()); diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index a6aae01383a8..6cb3aeedeece 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -2538,7 +2538,8 @@ static auto JumpToTOXMark(SwWrtShell & rSh, std::u16string_view aName) -> bool } SwTOXMark const* pMark(&tmp->first); // hack: check first if one exists - if (&tmp->first != &rSh.GetDoc()->GotoTOXMark(tmp->first, TOX_SAME_NXT, rSh.IsReadOnlyAvailable())) + // need simple ptr control, else UnitTest CppunitTest_sw_uiwriter3 fails + if (!areSfxPoolItemPtrsEqual(&tmp->first, &rSh.GetDoc()->GotoTOXMark(tmp->first, TOX_SAME_NXT, rSh.IsReadOnlyAvailable()))) { for (sal_Int32 i = 0; i < tmp->second; ++i) { diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 3a4322ad1532..4c126fb6193d 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -5262,7 +5262,7 @@ void SwContentTree::EditEntry(const weld::TreeIter& rEntry, EditEntryMode nMode) if(nMode == EditEntryMode::DELETE) { const OUString& rName = pCnt->GetName(); - for (SfxPoolItem* pItem : + for (const SfxPoolItem* pItem : m_pActiveShell->GetDoc()->GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK)) { assert(dynamic_cast<const SwFormatRefMark*>(pItem)); |