Kaydet (Commit) b4a1b89c authored tarafından Noel Grandin's avatar Noel Grandin

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: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst f4ea84ff
...@@ -70,9 +70,7 @@ public: ...@@ -70,9 +70,7 @@ public:
/** Stores the cell position of the note in the user data area of the caption. */ /** Stores the cell position of the note in the user data area of the caption. */
static void SetCaptionUserData( SdrCaptionObj& rCaption, const ScAddress& rPos ); static void SetCaptionUserData( SdrCaptionObj& rCaption, const ScAddress& rPos );
/** Sets all default formatting attributes to the caption object. */ /** Sets all default formatting attributes to the caption object. */
static void SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc ); static void SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc, SfxItemSet* pExtraItemSet );
/** Updates caption item set according to the passed item set while removing shadow items. */
static void SetCaptionItems( SdrCaptionObj& rCaption, const SfxItemSet& rItemSet );
}; };
void ScCaptionUtil::SetCaptionLayer( SdrCaptionObj& rCaption, bool bShown ) void ScCaptionUtil::SetCaptionLayer( SdrCaptionObj& rCaption, bool bShown )
...@@ -98,7 +96,7 @@ void ScCaptionUtil::SetCaptionUserData( SdrCaptionObj& rCaption, const ScAddress ...@@ -98,7 +96,7 @@ void ScCaptionUtil::SetCaptionUserData( SdrCaptionObj& rCaption, const ScAddress
pObjData->meType = ScDrawObjData::CellNote; pObjData->meType = ScDrawObjData::CellNote;
} }
void ScCaptionUtil::SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc ) void ScCaptionUtil::SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc, SfxItemSet* pExtraItemSet )
{ {
SfxItemSet aItemSet = rCaption.GetMergedItemSet(); SfxItemSet aItemSet = rCaption.GetMergedItemSet();
...@@ -137,18 +135,21 @@ void ScCaptionUtil::SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc ) ...@@ -137,18 +135,21 @@ void ScCaptionUtil::SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc )
const ScPatternAttr& rDefPattern = rDoc.GetPool()->GetDefaultItem( ATTR_PATTERN ); const ScPatternAttr& rDefPattern = rDoc.GetPool()->GetDefaultItem( ATTR_PATTERN );
rDefPattern.FillEditItemSet( &aItemSet ); 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 ); rCaption.SetMergedItemSet( aItemSet );
}
void ScCaptionUtil::SetCaptionItems( SdrCaptionObj& rCaption, const SfxItemSet& rItemSet ) if (pExtraItemSet)
{ rCaption.SetSpecialTextBoxShadow();
// copy all items
rCaption.SetMergedItemSet( rItemSet );
// reset shadow items
rCaption.SetMergedItem( makeSdrShadowItem( false ) );
rCaption.SetMergedItem( makeSdrShadowXDistItem( 100 ) );
rCaption.SetMergedItem( makeSdrShadowYDistItem( 100 ) );
rCaption.SetSpecialTextBoxShadow();
} }
/** Helper for creation and manipulation of caption drawing objects independent /** Helper for creation and manipulation of caption drawing objects independent
...@@ -1051,9 +1052,7 @@ void ScPostIt::CreateCaptionFromInitData( const ScAddress& rPos ) const ...@@ -1051,9 +1052,7 @@ void ScPostIt::CreateCaptionFromInitData( const ScAddress& rPos ) const
maNoteData.mxCaption->SetText( xInitData->maSimpleText ); maNoteData.mxCaption->SetText( xInitData->maSimpleText );
// copy all items or set default items; reset shadow items // copy all items or set default items; reset shadow items
ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc ); ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, xInitData->mxItemSet.get() );
if (xInitData->mxItemSet)
ScCaptionUtil::SetCaptionItems( *maNoteData.mxCaption, *xInitData->mxItemSet );
// set position and size of the caption object // set position and size of the caption object
if( xInitData->mbDefaultPosSize ) if( xInitData->mbDefaultPosSize )
...@@ -1117,7 +1116,7 @@ void ScPostIt::CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCapti ...@@ -1117,7 +1116,7 @@ void ScPostIt::CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCapti
else else
{ {
// set default formatting and default position // set default formatting and default position
ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc ); ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, nullptr );
aCreator.AutoPlaceCaption(); aCreator.AutoPlaceCaption();
} }
...@@ -1201,7 +1200,7 @@ ScCaptionPtr ScNoteUtil::CreateTempCaption( ...@@ -1201,7 +1200,7 @@ ScCaptionPtr ScNoteUtil::CreateTempCaption(
{ {
// if pNoteCaption is null, then aBuffer contains some text // if pNoteCaption is null, then aBuffer contains some text
pCaption->SetText( aBuffer.makeStringAndClear() ); pCaption->SetText( aBuffer.makeStringAndClear() );
ScCaptionUtil::SetDefaultItems( *pCaption, rDoc ); ScCaptionUtil::SetDefaultItems( *pCaption, rDoc, nullptr );
// adjust caption size to text size // adjust caption size to text size
long nMaxWidth = ::std::min< long >( aVisRect.GetWidth() * 2 / 3, SC_NOTECAPTION_MAXWIDTH_TEMP ); long nMaxWidth = ::std::min< long >( aVisRect.GetWidth() * 2 / 3, SC_NOTECAPTION_MAXWIDTH_TEMP );
pCaption->SetMergedItem( makeSdrTextAutoGrowWidthItem( true ) ); pCaption->SetMergedItem( makeSdrTextAutoGrowWidthItem( true ) );
......
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