From 90fbb14e517c95036a133697d7300fc662d1b8b5 Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Fri, 14 Apr 2023 15:13:32 +0300 Subject: sc drawstyles: Don't consider the default cell style formatting We no longer use the text formatting of the default cell style for new comments, nor we follow that style changes, so there is no reason to do that on import. And this formatting will be overwritten anyway in most cases with the imported formatting. (There is currently a bug in xlsx import that makes the author name appear with the default font in visible comments, and that case will look differently after this commit. However, the truth is that *both* old and new looks are wrong. The correct font can be seen in the temp popup when hovering the comment marker, or after copying & pasting the cell with the comment to somewhere else. But even if this wasn't a bug, it was *our* decision to use the cell style font, not something imported or done by Excel, so I believe we're free to change something like this.) Change-Id: I92b95d7dfcfb747144eb710c76ec5f755f70400f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150490 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky --- sc/source/core/data/postit.cxx | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'sc') diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index f74937377d8e..b4acfb35f205 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -80,8 +80,8 @@ public: static void SetBasicCaptionSettings( SdrCaptionObj& rCaption, bool bShown ); /** Stores the cell position of the note in the user data area of the caption. */ static void SetCaptionUserData( SdrCaptionObj& rCaption, const ScAddress& rPos ); - /** Sets all default formatting attributes to the caption object. */ - static void SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc, const SfxItemSet* pExtraItemSet ); + /** Sets all hard formatting attributes to the caption object. */ + static void SetExtraItems( SdrCaptionObj& rCaption, const SfxItemSet& rExtraItemSet ); }; void ScCaptionUtil::SetCaptionLayer( SdrCaptionObj& rCaption, bool bShown ) @@ -107,28 +107,17 @@ void ScCaptionUtil::SetCaptionUserData( SdrCaptionObj& rCaption, const ScAddress pObjData->meType = ScDrawObjData::CellNote; } -void ScCaptionUtil::SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc, const SfxItemSet* pExtraItemSet ) +void ScCaptionUtil::SetExtraItems( SdrCaptionObj& rCaption, const SfxItemSet& rExtraItemSet ) { SfxItemSet aItemSet = rCaption.GetMergedItemSet(); - const ScPatternAttr& rDefPattern = rDoc.GetPool()->GetDefaultItem( ATTR_PATTERN ); - rDefPattern.FillEditItemSet( &aItemSet ); - - if (pExtraItemSet) - { - /* Updates caption item set according to the passed item set while removing shadow items. */ - - aItemSet.Put(*pExtraItemSet); - // reset shadow items - aItemSet.Put( makeSdrShadowItem( false ) ); - aItemSet.Put( makeSdrShadowXDistItem( 100 ) ); - aItemSet.Put( makeSdrShadowYDistItem( 100 ) ); - } + aItemSet.Put(rExtraItemSet); + // reset shadow items + aItemSet.Put( makeSdrShadowItem( false ) ); + aItemSet.Put( makeSdrShadowXDistItem( 100 ) ); + aItemSet.Put( makeSdrShadowYDistItem( 100 ) ); rCaption.SetMergedItemSet( aItemSet ); - - if (pExtraItemSet) - rCaption.SetSpecialTextBoxShadow(); } /** Helper for creation and manipulation of caption drawing objects independent @@ -680,8 +669,9 @@ void ScPostIt::CreateCaptionFromInitData( const ScAddress& rPos ) const if (auto pStyleSheet = mrDoc.GetStyleSheetPool()->Find(ScResId(STR_STYLENAME_NOTE), SfxStyleFamily::Frame)) maNoteData.mxCaption->SetStyleSheet(static_cast(pStyleSheet), true); - // copy all items or set default items; reset shadow items - ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, xInitData->moItemSet ? &*xInitData->moItemSet : nullptr ); + // copy all items and reset shadow items + if (xInitData->moItemSet) + ScCaptionUtil::SetExtraItems(*maNoteData.mxCaption, *xInitData->moItemSet); } // set position and size of the caption object -- cgit v1.2.3