diff options
author | Armin Le Grand <Armin.Le.Grand@me.com> | 2019-05-16 10:36:01 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2019-05-16 17:41:55 +0200 |
commit | 7ed69df31bb5f3f4e89ca2ef914e103676836362 (patch) | |
tree | 5b3702d4848153245cd51e9e1fc35250e532eec2 | |
parent | 0fded059c7d5a5e59cdfcd571726f5ccd9cf1edb (diff) |
tdf#125054 fixed WhichIDs for cloned Items
Cause of error is that former operator= for SfxPoolItem
copies all but the WhichID from the source, so being quite
(and dangerously) dfferent from Clone() method.
There were quite some places (and will be) that use that
from my POV 'hidden' functionality by creating an Item
with the target-WhichID and then using operator= to assign
data from an Item with different WhichID
Change-Id: Ia7e78d6d1b8b34c9c34e936db10cc850928531d5
Reviewed-on: https://gerrit.libreoffice.org/72399
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
-rw-r--r-- | sc/source/core/data/patattr.cxx | 18 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/drtxtob.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/view/editsh.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 9 |
4 files changed, 31 insertions, 10 deletions
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 52bdfcda5b27..bf3d1dc115e2 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -717,20 +717,26 @@ void ScPatternAttr::FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& r } else { - rEditSet.Put( *aColorItem ); + // tdf#125054 adapt WhichID + rEditSet.Put( *aColorItem, EE_CHAR_COLOR ); } - rEditSet.Put( *aFontItem ); - rEditSet.Put( *aCjkFontItem ); - rEditSet.Put( *aCtlFontItem ); + // tdf#125054 adapt WhichID + rEditSet.Put( *aFontItem, EE_CHAR_FONTINFO ); + rEditSet.Put( *aCjkFontItem, EE_CHAR_FONTINFO_CJK ); + rEditSet.Put( *aCtlFontItem, EE_CHAR_FONTINFO_CTL ); + rEditSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) ); rEditSet.Put( SvxFontHeightItem( nCjkHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) ); rEditSet.Put( SvxFontHeightItem( nCtlHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) ); rEditSet.Put( SvxWeightItem ( eWeight, EE_CHAR_WEIGHT ) ); rEditSet.Put( SvxWeightItem ( eCjkWeight, EE_CHAR_WEIGHT_CJK ) ); rEditSet.Put( SvxWeightItem ( eCtlWeight, EE_CHAR_WEIGHT_CTL ) ); - rEditSet.Put( *aUnderlineItem ); - rEditSet.Put( *aOverlineItem ); + + // tdf#125054 adapt WhichID + rEditSet.Put( *aUnderlineItem, EE_CHAR_UNDERLINE ); + rEditSet.Put( *aOverlineItem, EE_CHAR_OVERLINE ); + rEditSet.Put( SvxWordLineModeItem( bWordLine, EE_CHAR_WLM ) ); rEditSet.Put( SvxCrossedOutItem( eStrike, EE_CHAR_STRIKEOUT ) ); rEditSet.Put( SvxPostureItem ( eItalic, EE_CHAR_ITALIC ) ); diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index 1100de6da90d..3c03fa2b2eba 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -239,7 +239,15 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq ) if ( !aString.isEmpty() ) { SfxItemSet aSet( pOutliner->GetEmptyItemSet() ); - aSet.Put( *aNewItem ); + // tdf#125054 + // checked against original, indeed aNewItem looks as if it can have + // either WhichID EE_CHAR_FONTINFO or ATTR_FONT when it was reset + // above, original uses '= SvxFontItem(..., ATTR_FONT). + // BUT beware: the operator=() did not copy the WhichID when resetting, + // so it indeed has WhichID of EE_CHAR_FONTINFO despite copying an Item + // that was constructed using ATTR_FONT as WhichID (!) + aSet.Put( *aNewItem, EE_CHAR_FONTINFO ); + // If nothing is selected, then SetAttribs of the View selects a word pOutView->GetOutliner()->QuickSetAttribs( aSet, pOutView->GetSelection() ); pOutView->InsertText(aString); diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index 05ad3a5c4283..77c47994f19d 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -407,6 +407,7 @@ void ScEditShell::Execute( SfxRequest& rReq ) { const OUString& aFontName(pFontItem->GetValue()); vcl::Font aFont(aFontName, Size(1,1)); // Size just because CTOR + // tdf#125054 see comment in drtxob.cxx, same ID aNewItem = std::make_shared<SvxFontItem>( aFont.GetFamilyType(), aFont.GetFamilyName(), aFont.GetStyleName(), aFont.GetPitch(), @@ -416,6 +417,9 @@ void ScEditShell::Execute( SfxRequest& rReq ) { aNewItem.reset(static_cast<SvxFontItem*>(rItem.Clone())); } + + // tdf#125054 force Item to correct intended ID + aNewItem->SetWhich(EE_CHAR_FONTINFO); } else { diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index ab88adfc265c..a3cc7609e310 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -2413,15 +2413,18 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor) const SfxPoolItem* pItem; if ( mpPreviewFontSet->GetItemState( ATTR_FONT, true, &pItem ) == SfxItemState::SET ) { - pSet->Put(*pItem); + // tdf#125054 adapt WhichID + pSet->Put(*pItem, EE_CHAR_FONTINFO); } if ( mpPreviewFontSet->GetItemState( ATTR_CJK_FONT, true, &pItem ) == SfxItemState::SET ) { - pSet->Put(*pItem); + // tdf#125054 adapt WhichID + pSet->Put(*pItem, EE_CHAR_FONTINFO_CJK); } if ( mpPreviewFontSet->GetItemState( ATTR_CTL_FONT, true, &pItem ) == SfxItemState::SET ) { - pSet->Put(*pItem); + // tdf#125054 adapt WhichID + pSet->Put(*pItem, EE_CHAR_FONTINFO_CTL); } } bool bParaHyphenate = pSet->Get(EE_PARA_HYPHENATE).GetValue(); |