Kaydet (Commit) 7ed69df3 authored tarafından Armin Le Grand's avatar Armin Le Grand

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: 's avatarArmin Le Grand <Armin.Le.Grand@me.com>
üst 0fded059
......@@ -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 ) );
......
......@@ -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);
......
......@@ -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
{
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment