summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2020-01-02 12:24:27 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-01-04 14:04:31 +0100
commit0c8848394df6e0c8ac3149ffde1314e8e1171869 (patch)
treeda5bbbd26ff867d45e5e0dd9fb0cfd771839a5f0 /sd
parent3367c986b78397c05e051daede2a8b60d705bffb (diff)
tdf#129708 speed-up: reuse enumeration for each effect
Change-Id: I336278c5a9eec75a2a71fe4d04d2029a5a08e6a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86102 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> (cherry picked from commit c97f9af5e47ea234ad709a1f66c1e8ed20640066) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86208 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/inc/CustomAnimationEffect.hxx4
-rw-r--r--sd/source/core/CustomAnimationEffect.cxx126
2 files changed, 101 insertions, 29 deletions
diff --git a/sd/inc/CustomAnimationEffect.hxx b/sd/inc/CustomAnimationEffect.hxx
index cf2cfe7cb7a4..c705d10022f3 100644
--- a/sd/inc/CustomAnimationEffect.hxx
+++ b/sd/inc/CustomAnimationEffect.hxx
@@ -144,7 +144,7 @@ public:
SAL_DLLPRIVATE OUString getPath() const;
SAL_DLLPRIVATE void setPath( const OUString& rPath );
- SAL_DLLPRIVATE bool checkForText();
+ SAL_DLLPRIVATE bool checkForText( const std::vector<sal_Int32>* paragraphNumberingLevel = nullptr );
SAL_DLLPRIVATE bool calculateIterateDuration();
SAL_DLLPRIVATE void setAudio( const css::uno::Reference< css::animations::XAudio >& xAudio );
@@ -334,6 +334,8 @@ protected:
SAL_DLLPRIVATE void updateTextGroups();
+ SAL_DLLPRIVATE bool getParagraphNumberingLevels( const css::uno::Reference< css::drawing::XShape >& xShape, std::vector< sal_Int32 >& rParagraphNumberingLevel );
+
protected:
css::uno::Reference< css::animations::XTimeContainer > mxSequenceRoot;
EffectSequence maEffects;
diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx
index 1a08b9b4d7de..0493f885ec8d 100644
--- a/sd/source/core/CustomAnimationEffect.cxx
+++ b/sd/source/core/CustomAnimationEffect.cxx
@@ -505,7 +505,7 @@ void CustomAnimationEffect::setGroupId( sal_Int32 nGroupId )
/** checks if the text for this effect has changed and updates internal flags.
returns true if something changed.
*/
-bool CustomAnimationEffect::checkForText()
+bool CustomAnimationEffect::checkForText( const std::vector<sal_Int32>* paragraphNumberingLevel )
{
bool bChange = false;
@@ -522,36 +522,52 @@ bool CustomAnimationEffect::checkForText()
// get paragraph
if( xText.is() )
{
- Reference< XEnumerationAccess > xEA( xText, UNO_QUERY );
- if( xEA.is() )
+ sal_Int32 nPara = aParaTarget.Paragraph;
+
+ bool bHasText = false;
+ sal_Int32 nParaDepth = 0;
+
+ if ( paragraphNumberingLevel )
{
- Reference< XEnumeration > xEnumeration = xEA->createEnumeration();
- if( xEnumeration.is() )
+ bHasText = !paragraphNumberingLevel->empty();
+ if (nPara >= 0 && static_cast<size_t>(nPara) < paragraphNumberingLevel->size())
+ nParaDepth = paragraphNumberingLevel->at(nPara);
+ }
+ else
+ {
+ Reference< XEnumerationAccess > xEA( xText, UNO_QUERY );
+ if( xEA.is() )
{
- bool bHasText = xEnumeration->hasMoreElements();
- bChange |= bHasText != mbHasText;
- mbHasText = bHasText;
-
- sal_Int32 nPara = aParaTarget.Paragraph;
+ Reference< XEnumeration > xEnumeration = xEA->createEnumeration();
+ if( xEnumeration.is() )
+ {
+ bHasText = xEnumeration->hasMoreElements();
- while( xEnumeration->hasMoreElements() && nPara-- )
- xEnumeration->nextElement();
+ while( xEnumeration->hasMoreElements() && nPara-- )
+ xEnumeration->nextElement();
- if( xEnumeration->hasMoreElements() )
- {
- Reference< XPropertySet > xParaSet;
- xEnumeration->nextElement() >>= xParaSet;
- if( xParaSet.is() )
+ if( xEnumeration->hasMoreElements() )
{
- sal_Int32 nParaDepth = 0;
- const OUString strNumberingLevel( "NumberingLevel" );
- xParaSet->getPropertyValue( strNumberingLevel ) >>= nParaDepth;
- bChange |= nParaDepth != mnParaDepth;
- mnParaDepth = nParaDepth;
+ Reference< XPropertySet > xParaSet;
+ xEnumeration->nextElement() >>= xParaSet;
+ if( xParaSet.is() )
+ {
+ const OUString strNumberingLevel( "NumberingLevel" );
+ xParaSet->getPropertyValue( strNumberingLevel ) >>= nParaDepth;
+ }
}
}
}
}
+
+ if( bHasText )
+ {
+ bChange |= bHasText != mbHasText;
+ mbHasText = bHasText;
+
+ bChange |= nParaDepth != mnParaDepth;
+ mnParaDepth = nParaDepth;
+ }
}
}
else
@@ -2120,17 +2136,63 @@ bool EffectSequenceHelper::hasEffect( const css::uno::Reference< css::drawing::X
[&xShape](const CustomAnimationEffectPtr& rxEffect) { return rxEffect->getTargetShape() == xShape; });
}
+bool EffectSequenceHelper::getParagraphNumberingLevels( const Reference< XShape >& xShape, std::vector< sal_Int32 >& rParagraphNumberingLevel )
+{
+ rParagraphNumberingLevel.clear();
+
+ if( !hasEffect( xShape ) )
+ return false;
+
+ Reference< XText > xText( xShape, UNO_QUERY );
+ if( xText.is() )
+ {
+ Reference< XEnumerationAccess > xEA( xText, UNO_QUERY );
+ if( xEA.is() )
+ {
+ Reference< XEnumeration > xEnumeration = xEA->createEnumeration();
+
+ if( xEnumeration.is() )
+ {
+ for( sal_Int32 index = 0; xEnumeration->hasMoreElements(); index++ )
+ {
+ Reference< XPropertySet > xParaSet;
+ xEnumeration->nextElement() >>= xParaSet;
+
+ sal_Int32 nParaDepth = 0;
+ if( xParaSet.is() )
+ {
+ const OUString strNumberingLevel( "NumberingLevel" );
+ xParaSet->getPropertyValue( strNumberingLevel ) >>= nParaDepth;
+ }
+
+ rParagraphNumberingLevel.push_back( nParaDepth );
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
void EffectSequenceHelper::insertTextRange( const css::uno::Any& aTarget )
{
ParagraphTarget aParaTarget;
if( !(aTarget >>= aParaTarget ) )
return;
- bool bChanges = std::accumulate(maEffects.begin(), maEffects.end(), false,
- [&aParaTarget](const bool bCheck, const CustomAnimationEffectPtr& rxEffect) {
+ // get map [paragraph index] -> [NumberingLevel]
+ // for following reusage inside all animation effects
+ std::vector< sal_Int32 > paragraphNumberingLevel;
+ std::vector< sal_Int32 >* paragraphNumberingLevelParam = nullptr;
+ if ( getParagraphNumberingLevels( aParaTarget.Shape, paragraphNumberingLevel ) )
+ paragraphNumberingLevelParam = &paragraphNumberingLevel;
+
+ // update internal flags for each animation effect
+ const bool bChanges = std::accumulate(maEffects.begin(), maEffects.end(), false,
+ [&aParaTarget, &paragraphNumberingLevelParam](const bool bCheck, const CustomAnimationEffectPtr& rxEffect) {
bool bRes = bCheck;
if (rxEffect->getTargetShape() == aParaTarget.Shape)
- bRes |= rxEffect->checkForText();
+ bRes |= rxEffect->checkForText( paragraphNumberingLevelParam );
return bRes;
});
@@ -3243,11 +3305,19 @@ void MainSequence::onTextChanged( const Reference< XShape >& xShape )
void EffectSequenceHelper::onTextChanged( const Reference< XShape >& xShape )
{
- bool bChanges = std::accumulate(maEffects.begin(), maEffects.end(), false,
- [&xShape](const bool bCheck, const CustomAnimationEffectPtr& rxEffect) {
+ // get map [paragraph index] -> [NumberingLevel]
+ // for following reusage inside all animation effects
+ std::vector< sal_Int32 > paragraphNumberingLevel;
+ std::vector< sal_Int32 >* paragraphNumberingLevelParam = nullptr;
+ if ( getParagraphNumberingLevels( xShape, paragraphNumberingLevel ) )
+ paragraphNumberingLevelParam = &paragraphNumberingLevel;
+
+ // update internal flags for each animation effect
+ const bool bChanges = std::accumulate(maEffects.begin(), maEffects.end(), false,
+ [&xShape, &paragraphNumberingLevelParam](const bool bCheck, const CustomAnimationEffectPtr& rxEffect) {
bool bRes = bCheck;
if (rxEffect->getTargetShape() == xShape)
- bRes |= rxEffect->checkForText();
+ bRes |= rxEffect->checkForText( paragraphNumberingLevelParam );
return bRes;
});