summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-04-25 16:36:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-04-26 15:11:03 +0200
commitb4a1b89cc84086dfd6f471d7f23fecf0ec8f3331 (patch)
treed297beddacbb3adeee0b4dbec54c3431c2ddb4ba /sc
parentf4ea84ff370d33a02a8fb1d6405b9d964491258e (diff)
tdf#119650 slow saving spreadsheet with comments, part 2
Reduce the number of items we set items/itemsets on the caption, which reduces the number of times editeng does text layout. Takes time from 151s to 78s Change-Id: Iecfb123768fd8f87ffe162b35fe6bcd6b56b8700 Reviewed-on: https://gerrit.libreoffice.org/71359 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/postit.cxx37
1 files changed, 18 insertions, 19 deletions
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 1bff48ca9407..7889edc7188c 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -70,9 +70,7 @@ public:
/** 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 );
- /** Updates caption item set according to the passed item set while removing shadow items. */
- static void SetCaptionItems( SdrCaptionObj& rCaption, const SfxItemSet& rItemSet );
+ static void SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc, SfxItemSet* pExtraItemSet );
};
void ScCaptionUtil::SetCaptionLayer( SdrCaptionObj& rCaption, bool bShown )
@@ -98,7 +96,7 @@ void ScCaptionUtil::SetCaptionUserData( SdrCaptionObj& rCaption, const ScAddress
pObjData->meType = ScDrawObjData::CellNote;
}
-void ScCaptionUtil::SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc )
+void ScCaptionUtil::SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc, SfxItemSet* pExtraItemSet )
{
SfxItemSet aItemSet = rCaption.GetMergedItemSet();
@@ -137,18 +135,21 @@ void ScCaptionUtil::SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc )
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.MergeValues(*pExtraItemSet);
+ // reset shadow items
+ aItemSet.Put( makeSdrShadowItem( false ) );
+ aItemSet.Put( makeSdrShadowXDistItem( 100 ) );
+ aItemSet.Put( makeSdrShadowYDistItem( 100 ) );
+ }
+
rCaption.SetMergedItemSet( aItemSet );
-}
-void ScCaptionUtil::SetCaptionItems( SdrCaptionObj& rCaption, const SfxItemSet& rItemSet )
-{
- // copy all items
- rCaption.SetMergedItemSet( rItemSet );
- // reset shadow items
- rCaption.SetMergedItem( makeSdrShadowItem( false ) );
- rCaption.SetMergedItem( makeSdrShadowXDistItem( 100 ) );
- rCaption.SetMergedItem( makeSdrShadowYDistItem( 100 ) );
- rCaption.SetSpecialTextBoxShadow();
+ if (pExtraItemSet)
+ rCaption.SetSpecialTextBoxShadow();
}
/** Helper for creation and manipulation of caption drawing objects independent
@@ -1051,9 +1052,7 @@ void ScPostIt::CreateCaptionFromInitData( const ScAddress& rPos ) const
maNoteData.mxCaption->SetText( xInitData->maSimpleText );
// copy all items or set default items; reset shadow items
- ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc );
- if (xInitData->mxItemSet)
- ScCaptionUtil::SetCaptionItems( *maNoteData.mxCaption, *xInitData->mxItemSet );
+ ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, xInitData->mxItemSet.get() );
// set position and size of the caption object
if( xInitData->mbDefaultPosSize )
@@ -1117,7 +1116,7 @@ void ScPostIt::CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCapti
else
{
// set default formatting and default position
- ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc );
+ ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, nullptr );
aCreator.AutoPlaceCaption();
}
@@ -1201,7 +1200,7 @@ ScCaptionPtr ScNoteUtil::CreateTempCaption(
{
// if pNoteCaption is null, then aBuffer contains some text
pCaption->SetText( aBuffer.makeStringAndClear() );
- ScCaptionUtil::SetDefaultItems( *pCaption, rDoc );
+ ScCaptionUtil::SetDefaultItems( *pCaption, rDoc, nullptr );
// adjust caption size to text size
long nMaxWidth = ::std::min< long >( aVisRect.GetWidth() * 2 / 3, SC_NOTECAPTION_MAXWIDTH_TEMP );
pCaption->SetMergedItem( makeSdrTextAutoGrowWidthItem( true ) );