diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-14 09:13:24 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-15 13:48:25 +0100 |
commit | e2d2a3386fe85b0fa11fd26c3f7ca4c651eb2818 (patch) | |
tree | d60215975ea968cb50a16b1f284f4cdb640db599 /sd/source | |
parent | fda2a915cb72afbfdb3a6bddf100fd9550d81f31 (diff) |
loplugin:flatten in sd/source/core
Change-Id: Ide9a83e5baaef24fcbd2b2fa8fb89abdf5f8ce77
Reviewed-on: https://gerrit.libreoffice.org/67838
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/core/CustomAnimationEffect.cxx | 256 | ||||
-rw-r--r-- | sd/source/core/EffectMigration.cxx | 492 | ||||
-rw-r--r-- | sd/source/core/annotations/Annotation.cxx | 46 | ||||
-rw-r--r-- | sd/source/core/drawdoc.cxx | 122 | ||||
-rw-r--r-- | sd/source/core/drawdoc2.cxx | 448 | ||||
-rw-r--r-- | sd/source/core/drawdoc4.cxx | 174 | ||||
-rw-r--r-- | sd/source/core/sdpage.cxx | 840 | ||||
-rw-r--r-- | sd/source/core/sdpage2.cxx | 64 | ||||
-rw-r--r-- | sd/source/core/stlpool.cxx | 199 | ||||
-rw-r--r-- | sd/source/core/stlsheet.cxx | 176 | ||||
-rw-r--r-- | sd/source/core/undo/undoobjects.cxx | 30 | ||||
-rw-r--r-- | sd/source/core/undoanim.cxx | 18 |
12 files changed, 1451 insertions, 1414 deletions
diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx index c9dda0acafad..4bda45524403 100644 --- a/sd/source/core/CustomAnimationEffect.cxx +++ b/sd/source/core/CustomAnimationEffect.cxx @@ -409,122 +409,122 @@ sal_Int32 CustomAnimationEffect::get_node_type( const Reference< XAnimationNode void CustomAnimationEffect::setPresetClass( sal_Int16 nPresetClass ) { - if( mnPresetClass != nPresetClass ) + if( mnPresetClass == nPresetClass ) + return; + + mnPresetClass = nPresetClass; + if( !mxNode.is() ) + return; + + // first try to find a "preset-class" entry in the user data + // and change it + Sequence< NamedValue > aUserData( mxNode->getUserData() ); + sal_Int32 nLength = aUserData.getLength(); + bool bFound = false; + if( nLength ) { - mnPresetClass = nPresetClass; - if( mxNode.is() ) + NamedValue* p = aUserData.getArray(); + while( nLength-- ) { - // first try to find a "preset-class" entry in the user data - // and change it - Sequence< NamedValue > aUserData( mxNode->getUserData() ); - sal_Int32 nLength = aUserData.getLength(); - bool bFound = false; - if( nLength ) + if ( p->Name == "preset-class" ) { - NamedValue* p = aUserData.getArray(); - while( nLength-- ) - { - if ( p->Name == "preset-class" ) - { - p->Value <<= mnPresetClass; - bFound = true; - break; - } - p++; - } - } - - // no "node-type" entry inside user data, so add it - if( !bFound ) - { - nLength = aUserData.getLength(); - aUserData.realloc( nLength + 1); - aUserData[nLength].Name = "preset-class"; - aUserData[nLength].Value <<= mnPresetClass; + p->Value <<= mnPresetClass; + bFound = true; + break; } - - mxNode->setUserData( aUserData ); + p++; } } + + // no "node-type" entry inside user data, so add it + if( !bFound ) + { + nLength = aUserData.getLength(); + aUserData.realloc( nLength + 1); + aUserData[nLength].Name = "preset-class"; + aUserData[nLength].Value <<= mnPresetClass; + } + + mxNode->setUserData( aUserData ); } void CustomAnimationEffect::setNodeType( sal_Int16 nNodeType ) { - if( mnNodeType != nNodeType ) + if( mnNodeType == nNodeType ) + return; + + mnNodeType = nNodeType; + if( !mxNode.is() ) + return; + + // first try to find a "node-type" entry in the user data + // and change it + Sequence< NamedValue > aUserData( mxNode->getUserData() ); + sal_Int32 nLength = aUserData.getLength(); + bool bFound = false; + if( nLength ) { - mnNodeType = nNodeType; - if( mxNode.is() ) + NamedValue* p = aUserData.getArray(); + while( nLength-- ) { - // first try to find a "node-type" entry in the user data - // and change it - Sequence< NamedValue > aUserData( mxNode->getUserData() ); - sal_Int32 nLength = aUserData.getLength(); - bool bFound = false; - if( nLength ) + if ( p->Name == "node-type" ) { - NamedValue* p = aUserData.getArray(); - while( nLength-- ) - { - if ( p->Name == "node-type" ) - { - p->Value <<= mnNodeType; - bFound = true; - break; - } - p++; - } - } - - // no "node-type" entry inside user data, so add it - if( !bFound ) - { - nLength = aUserData.getLength(); - aUserData.realloc( nLength + 1); - aUserData[nLength].Name = "node-type"; - aUserData[nLength].Value <<= mnNodeType; + p->Value <<= mnNodeType; + bFound = true; + break; } - - mxNode->setUserData( aUserData ); + p++; } } + + // no "node-type" entry inside user data, so add it + if( !bFound ) + { + nLength = aUserData.getLength(); + aUserData.realloc( nLength + 1); + aUserData[nLength].Name = "node-type"; + aUserData[nLength].Value <<= mnNodeType; + } + + mxNode->setUserData( aUserData ); } void CustomAnimationEffect::setGroupId( sal_Int32 nGroupId ) { mnGroupId = nGroupId; - if( mxNode.is() ) + if( !mxNode.is() ) + return; + + // first try to find a "group-id" entry in the user data + // and change it + Sequence< NamedValue > aUserData( mxNode->getUserData() ); + sal_Int32 nLength = aUserData.getLength(); + bool bFound = false; + if( nLength ) { - // first try to find a "group-id" entry in the user data - // and change it - Sequence< NamedValue > aUserData( mxNode->getUserData() ); - sal_Int32 nLength = aUserData.getLength(); - bool bFound = false; - if( nLength ) + NamedValue* p = aUserData.getArray(); + while( nLength-- ) { - NamedValue* p = aUserData.getArray(); - while( nLength-- ) + if ( p->Name == "group-id" ) { - if ( p->Name == "group-id" ) - { - p->Value <<= mnGroupId; - bFound = true; - break; - } - p++; + p->Value <<= mnGroupId; + bFound = true; + break; } + p++; } + } - // no "node-type" entry inside user data, so add it - if( !bFound ) - { - nLength = aUserData.getLength(); - aUserData.realloc( nLength + 1); - aUserData[nLength].Name = "group-id"; - aUserData[nLength].Value <<= mnGroupId; - } - - mxNode->setUserData( aUserData ); + // no "node-type" entry inside user data, so add it + if( !bFound ) + { + nLength = aUserData.getLength(); + aUserData.realloc( nLength + 1); + aUserData[nLength].Name = "group-id"; + aUserData[nLength].Value <<= mnGroupId; } + + mxNode->setUserData( aUserData ); } /** checks if the text for this effect has changed and updates internal flags. @@ -717,7 +717,10 @@ void CustomAnimationEffect::setTargetSubItem( sal_Int16 nSubItem ) void CustomAnimationEffect::setDuration( double fDuration ) { - if( (mfDuration != -1.0) && (mfDuration != fDuration) ) try + if( !((mfDuration != -1.0) && (mfDuration != fDuration)) ) + return; + + try { double fScale = fDuration / mfDuration; mfDuration = fDuration; @@ -974,7 +977,10 @@ Reference< XAnimationNode > CustomAnimationEffect::createAfterEffectNode() const void CustomAnimationEffect::setIterateType( sal_Int16 nIterateType ) { - if( mnIterateType != nIterateType ) try + if( mnIterateType == nIterateType ) + return; + + try { // do we need to exchange the container node? if( (mnIterateType == 0) || (nIterateType == 0) ) @@ -1063,19 +1069,19 @@ void CustomAnimationEffect::setIterateType( sal_Int16 nIterateType ) void CustomAnimationEffect::setIterateInterval( double fIterateInterval ) { - if( mfIterateInterval != fIterateInterval ) - { - Reference< XIterateContainer > xIter( mxNode, UNO_QUERY ); + if( mfIterateInterval == fIterateInterval ) + return; - DBG_ASSERT( xIter.is(), "sd::CustomAnimationEffect::setIterateInterval(), not an iteration node" ); - if( xIter.is() ) - { - mfIterateInterval = fIterateInterval; - xIter->setIterateInterval( fIterateInterval ); - } + Reference< XIterateContainer > xIter( mxNode, UNO_QUERY ); - calculateIterateDuration(); + DBG_ASSERT( xIter.is(), "sd::CustomAnimationEffect::setIterateInterval(), not an iteration node" ); + if( xIter.is() ) + { + mfIterateInterval = fIterateInterval; + xIter->setIterateInterval( fIterateInterval ); } + + calculateIterateDuration(); } OUString CustomAnimationEffect::getPath() const @@ -1106,7 +1112,10 @@ OUString CustomAnimationEffect::getPath() const void CustomAnimationEffect::setPath( const OUString& rPath ) { - if( mxNode.is() ) try + if( !mxNode.is() ) + return; + + try { Reference< XEnumerationAccess > xEnumerationAccess( mxNode, UNO_QUERY_THROW ); Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW ); @@ -1275,7 +1284,10 @@ Any CustomAnimationEffect::getColor( sal_Int32 nIndex ) void CustomAnimationEffect::setColor( sal_Int32 nIndex, const Any& rColor ) { - if( mxNode.is() ) try + if( !mxNode.is() ) + return; + + try { Reference< XEnumerationAccess > xEnumerationAccess( mxNode, UNO_QUERY ); if( xEnumerationAccess.is() ) @@ -1415,7 +1427,10 @@ void CustomAnimationEffect::createAudio( const css::uno::Any& rSource ) { DBG_ASSERT( !mxAudio.is(), "sd::CustomAnimationEffect::createAudio(), node already has an audio!" ); - if( !mxAudio.is() ) try + if( mxAudio.is() ) + return; + + try { Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); Reference< XAudio > xAudio( Audio::create( xContext ) ); @@ -1485,7 +1500,10 @@ void CustomAnimationEffect::removeAudio() void CustomAnimationEffect::setAudio( const Reference< css::animations::XAudio >& xAudio ) { - if( mxAudio != xAudio ) try + if( mxAudio == xAudio ) + return; + + try { removeAudio(); mxAudio = xAudio; @@ -1502,7 +1520,10 @@ void CustomAnimationEffect::setAudio( const Reference< css::animations::XAudio > void CustomAnimationEffect::setStopAudio() { - if( mnCommand != EffectCommands::STOPAUDIO ) try + if( mnCommand == EffectCommands::STOPAUDIO ) + return; + + try { if( mxAudio.is() ) removeAudio(); @@ -1752,7 +1773,10 @@ CustomAnimationEffectPtr EffectSequenceHelper::append( const SdrPathObj& rPathOb void EffectSequenceHelper::replace( const CustomAnimationEffectPtr& pEffect, const CustomAnimationPresetPtr& pPreset, const OUString& rPresetSubType, double fDuration /* = -1.0 */ ) { - if( pEffect.get() && pPreset.get() ) try + if( !(pEffect.get() && pPreset.get()) ) + return; + + try { Reference< XAnimationNode > xNewNode( pPreset->create( rPresetSubType ) ); if( xNewNode.is() ) @@ -2387,7 +2411,10 @@ void EffectSequenceHelper::createTextGroupParagraphEffects( const CustomAnimatio bool bTextReverse = pTextGroup->mbTextReverse; // now add an effect for each paragraph - if( nTextGrouping >= 0 ) try + if( nTextGrouping < 0 ) + return; + + try { EffectSequence::iterator aInsertIter( find( pEffect ) ); @@ -2747,7 +2774,10 @@ void EffectSequenceHelper::create( const css::uno::Reference< css::animations::X { DBG_ASSERT( xNode.is(), "sd::EffectSequenceHelper::create(), illegal argument" ); - if( xNode.is() ) try + if( !xNode.is() ) + return; + + try { Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY_THROW ); Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW ); @@ -2767,7 +2797,10 @@ void EffectSequenceHelper::createEffectsequence( const Reference< XAnimationNode { DBG_ASSERT( xNode.is(), "sd::EffectSequenceHelper::createEffectsequence(), illegal argument" ); - if( xNode.is() ) try + if( !xNode.is() ) + return; + + try { Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY_THROW ); Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW ); @@ -2788,7 +2821,10 @@ void EffectSequenceHelper::createEffects( const Reference< XAnimationNode >& xNo { DBG_ASSERT( xNode.is(), "sd::EffectSequenceHelper::createEffects(), illegal argument" ); - if( xNode.is() ) try + if( !xNode.is() ) + return; + + try { Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY_THROW ); Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW ); diff --git a/sd/source/core/EffectMigration.cxx b/sd/source/core/EffectMigration.cxx index 7a701a38436b..97199978cec1 100644 --- a/sd/source/core/EffectMigration.cxx +++ b/sd/source/core/EffectMigration.cxx @@ -444,96 +444,96 @@ void EffectMigration::SetAnimationEffect( SvxShape* pShape, AnimationEffect eEff CustomAnimationPresetPtr pPreset( rPresets.getEffectDescriptor( aPresetId ) ); sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->getSdrPageFromSdrObject())->getMainSequence(); - if( pPreset.get() && pMainSequence.get() ) - { - const Reference< XShape > xShape( pShape ); + if( !(pPreset.get() && pMainSequence.get()) ) + return; - EffectSequence::iterator aIterOnlyBackground( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_BACKGROUND ) ); - EffectSequence::iterator aIterAsWhole( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::AS_WHOLE ) ); - const EffectSequence::iterator aEnd( pMainSequence->getEnd() ); + const Reference< XShape > xShape( pShape ); - if( (aIterOnlyBackground == aEnd) && (aIterAsWhole == aEnd) ) - { - bool bEffectCreated = false; + EffectSequence::iterator aIterOnlyBackground( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_BACKGROUND ) ); + EffectSequence::iterator aIterAsWhole( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::AS_WHOLE ) ); + const EffectSequence::iterator aEnd( pMainSequence->getEnd() ); - // check if there is already an text effect for this shape - EffectSequence::iterator aIterOnlyText( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_TEXT ) ); - if( aIterOnlyText != aEnd ) + if( (aIterOnlyBackground == aEnd) && (aIterAsWhole == aEnd) ) + { + bool bEffectCreated = false; + + // check if there is already an text effect for this shape + EffectSequence::iterator aIterOnlyText( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_TEXT ) ); + if( aIterOnlyText != aEnd ) + { + // check if this is an animation text group + sal_Int32 nGroupId = (*aIterOnlyText)->getGroupId(); + if( nGroupId >= 0 ) { - // check if this is an animation text group - sal_Int32 nGroupId = (*aIterOnlyText)->getGroupId(); - if( nGroupId >= 0 ) + CustomAnimationTextGroupPtr pGroup = pMainSequence->findGroup( nGroupId ); + if( pGroup.get() ) { - CustomAnimationTextGroupPtr pGroup = pMainSequence->findGroup( nGroupId ); - if( pGroup.get() ) - { - // add an effect to animate the shape - pMainSequence->setAnimateForm( pGroup, true ); + // add an effect to animate the shape + pMainSequence->setAnimateForm( pGroup, true ); - // find this effect - EffectSequence::iterator aIter( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_BACKGROUND ) ); + // find this effect + EffectSequence::iterator aIter( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_BACKGROUND ) ); - if( aIter != aEnd ) + if( aIter != aEnd ) + { + if( ((*aIter)->getPresetId() != aPresetId) || + ((*aIter)->getPresetSubType() != aPresetSubType) ) { - if( ((*aIter)->getPresetId() != aPresetId) || - ((*aIter)->getPresetSubType() != aPresetSubType) ) - { - (*aIter)->replaceNode( pPreset->create( aPresetSubType ) ); - pMainSequence->rebuild(); - bEffectCreated = true; - } + (*aIter)->replaceNode( pPreset->create( aPresetSubType ) ); + pMainSequence->rebuild(); + bEffectCreated = true; } } } } + } - if( !bEffectCreated ) + if( !bEffectCreated ) + { + // if there is not yet an effect that target this shape, we generate one + // we insert the shape effect before it + Reference< XAnimationNode > xNode( pPreset->create( aPresetSubType ) ); + DBG_ASSERT( xNode.is(), "EffectMigration::SetAnimationEffect(), could not create preset!" ); + if( xNode.is() ) { - // if there is not yet an effect that target this shape, we generate one - // we insert the shape effect before it - Reference< XAnimationNode > xNode( pPreset->create( aPresetSubType ) ); - DBG_ASSERT( xNode.is(), "EffectMigration::SetAnimationEffect(), could not create preset!" ); - if( xNode.is() ) - { - CustomAnimationEffectPtr pEffect( new CustomAnimationEffect( xNode ) ); - pEffect->setTarget( makeAny( xShape ) ); - SdPage* pPage = dynamic_cast< SdPage* >( pObj->getSdrPageFromSdrObject() ); - const bool bManual = (pPage == nullptr) || (pPage->GetPresChange() == PRESCHANGE_MANUAL); - if( !bManual ) - pEffect->setNodeType( EffectNodeType::AFTER_PREVIOUS ); + CustomAnimationEffectPtr pEffect( new CustomAnimationEffect( xNode ) ); + pEffect->setTarget( makeAny( xShape ) ); + SdPage* pPage = dynamic_cast< SdPage* >( pObj->getSdrPageFromSdrObject() ); + const bool bManual = (pPage == nullptr) || (pPage->GetPresChange() == PRESCHANGE_MANUAL); + if( !bManual ) + pEffect->setNodeType( EffectNodeType::AFTER_PREVIOUS ); - pMainSequence->append( pEffect ); + pMainSequence->append( pEffect ); - if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == OBJ_OUTLINETEXT ) ) - { - // special case for outline text, effects are always mapped to text group effect - pMainSequence-> - createTextGroup( pEffect, 10, bManual ? -1 : 0.0, false, false ); - } + if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == OBJ_OUTLINETEXT ) ) + { + // special case for outline text, effects are always mapped to text group effect + pMainSequence-> + createTextGroup( pEffect, 10, bManual ? -1 : 0.0, false, false ); } } } + } + else + { + // if there is already an effect targeting this shape + // just replace it + CustomAnimationEffectPtr pEffect; + if( aIterAsWhole != aEnd ) + { + pEffect = *aIterAsWhole; + } else { - // if there is already an effect targeting this shape - // just replace it - CustomAnimationEffectPtr pEffect; - if( aIterAsWhole != aEnd ) - { - pEffect = *aIterAsWhole; - } - else - { - pEffect = *aIterOnlyBackground; - } + pEffect = *aIterOnlyBackground; + } - if( pEffect.get() ) + if( pEffect.get() ) + { + if( (pEffect->getPresetId() != aPresetId) || + (pEffect->getPresetSubType() != aPresetSubType) ) { - if( (pEffect->getPresetId() != aPresetId) || - (pEffect->getPresetSubType() != aPresetSubType) ) - { - pMainSequence->replace( pEffect, pPreset, aPresetSubType, -1.0 ); - } + pMainSequence->replace( pEffect, pPreset, aPresetSubType, -1.0 ); } } } @@ -609,107 +609,107 @@ void EffectMigration::SetTextAnimationEffect( SvxShape* pShape, AnimationEffect sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->getSdrPageFromSdrObject())->getMainSequence(); - if( pPreset.get() && pMainSequence.get() ) - { - const Reference< XShape > xShape( pShape ); + if( !(pPreset.get() && pMainSequence.get()) ) + return; - EffectSequence::iterator aIterOnlyText( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_TEXT ) ); - const EffectSequence::iterator aEnd( pMainSequence->getEnd() ); + const Reference< XShape > xShape( pShape ); - CustomAnimationTextGroupPtr pGroup; + EffectSequence::iterator aIterOnlyText( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_TEXT ) ); + const EffectSequence::iterator aEnd( pMainSequence->getEnd() ); - // is there already an animation text group for this shape? - if( aIterOnlyText != aEnd ) + CustomAnimationTextGroupPtr pGroup; + + // is there already an animation text group for this shape? + if( aIterOnlyText != aEnd ) + { + const sal_Int32 nGroupId = (*aIterOnlyText)->getGroupId(); + if( nGroupId >= 0 ) + pGroup = pMainSequence->findGroup( nGroupId ); + } + + // if there is not yet a group, create it + if( pGroup.get() == nullptr ) + { + CustomAnimationEffectPtr pShapeEffect; + + EffectSequence::iterator aIterOnlyBackground( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_BACKGROUND ) ); + if( aIterOnlyBackground != aEnd ) { - const sal_Int32 nGroupId = (*aIterOnlyText)->getGroupId(); - if( nGroupId >= 0 ) - pGroup = pMainSequence->findGroup( nGroupId ); + pShapeEffect = *aIterOnlyBackground; } - - // if there is not yet a group, create it - if( pGroup.get() == nullptr ) + else { - CustomAnimationEffectPtr pShapeEffect; - - EffectSequence::iterator aIterOnlyBackground( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_BACKGROUND ) ); - if( aIterOnlyBackground != aEnd ) + EffectSequence::iterator aIterAsWhole( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::AS_WHOLE ) ); + if( aIterAsWhole != aEnd ) { - pShapeEffect = *aIterOnlyBackground; + pShapeEffect = *aIterAsWhole; } else { - EffectSequence::iterator aIterAsWhole( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::AS_WHOLE ) ); - if( aIterAsWhole != aEnd ) - { - pShapeEffect = *aIterAsWhole; - } - else + CustomAnimationPresetPtr pShapePreset( rPresets.getEffectDescriptor( "ooo-entrance-appear" ) ); + + Reference< XAnimationNode > xNode( pPreset->create( "" ) ); + DBG_ASSERT( xNode.is(), "EffectMigration::SetTextAnimationEffect(), could not create preset!" ); + if( xNode.is() ) { - CustomAnimationPresetPtr pShapePreset( rPresets.getEffectDescriptor( "ooo-entrance-appear" ) ); + pShapeEffect.reset( new CustomAnimationEffect( xNode ) ); + pShapeEffect->setTarget( makeAny( xShape ) ); + pShapeEffect->setDuration( 0.1 ); + pMainSequence->append( pShapeEffect ); - Reference< XAnimationNode > xNode( pPreset->create( "" ) ); - DBG_ASSERT( xNode.is(), "EffectMigration::SetTextAnimationEffect(), could not create preset!" ); - if( xNode.is() ) - { - pShapeEffect.reset( new CustomAnimationEffect( xNode ) ); - pShapeEffect->setTarget( makeAny( xShape ) ); - pShapeEffect->setDuration( 0.1 ); - pMainSequence->append( pShapeEffect ); - - SdPage* pPage = dynamic_cast< SdPage* >( pObj->getSdrPageFromSdrObject() ); - if( pPage && pPage->GetPresChange() != PRESCHANGE_MANUAL ) - pShapeEffect->setNodeType( EffectNodeType::AFTER_PREVIOUS ); - } + SdPage* pPage = dynamic_cast< SdPage* >( pObj->getSdrPageFromSdrObject() ); + if( pPage && pPage->GetPresChange() != PRESCHANGE_MANUAL ) + pShapeEffect->setNodeType( EffectNodeType::AFTER_PREVIOUS ); } } + } - if( pShapeEffect.get() ) - { - SdPage* pPage = dynamic_cast< SdPage* >( pObj->getSdrPageFromSdrObject() ); - const bool bManual = (pPage == nullptr) || (pPage->GetPresChange() == PRESCHANGE_MANUAL); + if( pShapeEffect.get() ) + { + SdPage* pPage = dynamic_cast< SdPage* >( pObj->getSdrPageFromSdrObject() ); + const bool bManual = (pPage == nullptr) || (pPage->GetPresChange() == PRESCHANGE_MANUAL); - // now create effects for each paragraph - pGroup = - pMainSequence-> - createTextGroup( pShapeEffect, 10, bManual ? -1 : 0.0, true, false ); - } + // now create effects for each paragraph + pGroup = + pMainSequence-> + createTextGroup( pShapeEffect, 10, bManual ? -1 : 0.0, true, false ); } + } - if( pGroup.get() != nullptr ) - { - const bool bLaserEffect = (eEffect >= AnimationEffect_LASER_FROM_LEFT) && (eEffect <= AnimationEffect_LASER_FROM_LOWERRIGHT); + if( pGroup.get() != nullptr ) + { + const bool bLaserEffect = (eEffect >= AnimationEffect_LASER_FROM_LEFT) && (eEffect <= AnimationEffect_LASER_FROM_LOWERRIGHT); - // now we have a group, so check if all effects are same as we like to have them - const EffectSequence& rEffects = pGroup->getEffects(); + // now we have a group, so check if all effects are same as we like to have them + const EffectSequence& rEffects = pGroup->getEffects(); - for( auto& rxEffect : rEffects ) + for( auto& rxEffect : rEffects ) + { + // only work on paragraph targets + if( rxEffect->getTarget().getValueType() == ::cppu::UnoType<ParagraphTarget>::get() ) { - // only work on paragraph targets - if( rxEffect->getTarget().getValueType() == ::cppu::UnoType<ParagraphTarget>::get() ) + if( (rxEffect->getPresetId() != aPresetId) || + (rxEffect->getPresetSubType() != aPresetSubType) ) { - if( (rxEffect->getPresetId() != aPresetId) || - (rxEffect->getPresetSubType() != aPresetSubType) ) - { - rxEffect->replaceNode( pPreset->create( aPresetSubType ) ); - } + rxEffect->replaceNode( pPreset->create( aPresetSubType ) ); + } - if( bLaserEffect ) - { - rxEffect->setIterateType( TextAnimationType::BY_LETTER ); - rxEffect->setIterateInterval( 0.5 );// TODO: - // Determine - // interval - // according - // to - // total - // effect - // duration - } + if( bLaserEffect ) + { + rxEffect->setIterateType( TextAnimationType::BY_LETTER ); + rxEffect->setIterateInterval( 0.5 );// TODO: + // Determine + // interval + // according + // to + // total + // effect + // duration } } } - pMainSequence->rebuild(); } + pMainSequence->rebuild(); } AnimationEffect EffectMigration::GetTextAnimationEffect( SvxShape* pShape ) @@ -1119,30 +1119,30 @@ void EffectMigration::SetPresentationOrder( SvxShape* pShape, sal_Int32 nNewPos } // check trivial case - if( nCurrentPos != nNewPos ) - { - std::vector< CustomAnimationEffectPtr > aEffects; + if( nCurrentPos == nNewPos ) + return; - for( auto& rIter : aEffectVector[nCurrentPos] ) - { - aEffects.push_back( *rIter ); - rSequence.erase( rIter ); - } + std::vector< CustomAnimationEffectPtr > aEffects; - if( nNewPos > nCurrentPos ) - nNewPos++; + for( auto& rIter : aEffectVector[nCurrentPos] ) + { + aEffects.push_back( *rIter ); + rSequence.erase( rIter ); + } - if( nNewPos == static_cast<sal_Int32>(aEffectVector.size()) ) - { - std::copy(aEffects.begin(), aEffects.end(), std::back_inserter(rSequence)); - } - else + if( nNewPos > nCurrentPos ) + nNewPos++; + + if( nNewPos == static_cast<sal_Int32>(aEffectVector.size()) ) + { + std::copy(aEffects.begin(), aEffects.end(), std::back_inserter(rSequence)); + } + else + { + EffectSequence::iterator aPos( aEffectVector[nNewPos][0] ); + for( const auto& rEffect : aEffects ) { - EffectSequence::iterator aPos( aEffectVector[nNewPos][0] ); - for( const auto& rEffect : aEffects ) - { - rSequence.insert( aPos, rEffect ); - } + rSequence.insert( aPos, rEffect ); } } } @@ -1184,40 +1184,40 @@ sal_Int32 EffectMigration::GetPresentationOrder( SvxShape* pShape ) void EffectMigration::UpdateSoundEffect( SvxShape* pShape, SdAnimationInfo const * pInfo ) { - if( pInfo ) - { - SdrObject* pObj = pShape->GetSdrObject(); - sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->getSdrPageFromSdrObject())->getMainSequence(); + if( !pInfo ) + return; - const Reference< XShape > xShape( pShape ); + SdrObject* pObj = pShape->GetSdrObject(); + sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->getSdrPageFromSdrObject())->getMainSequence(); + + const Reference< XShape > xShape( pShape ); - EffectSequence::iterator aIter; - bool bNeedRebuild = false; + EffectSequence::iterator aIter; + bool bNeedRebuild = false; - OUString aSoundFile; - if( pInfo->mbSoundOn ) - aSoundFile = pInfo->maSoundFile; + OUString aSoundFile; + if( pInfo->mbSoundOn ) + aSoundFile = pInfo->maSoundFile; - for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); ++aIter ) + for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); ++aIter ) + { + CustomAnimationEffectPtr pEffect( *aIter ); + if( pEffect->getTargetShape() == xShape ) { - CustomAnimationEffectPtr pEffect( *aIter ); - if( pEffect->getTargetShape() == xShape ) + if( !aSoundFile.isEmpty() ) { - if( !aSoundFile.isEmpty() ) - { - pEffect->createAudio( makeAny( aSoundFile ) ); - } - else - { - pEffect->removeAudio(); - } - bNeedRebuild = true; + pEffect->createAudio( makeAny( aSoundFile ) ); + } + else + { + pEffect->removeAudio(); } + bNeedRebuild = true; } - - if( bNeedRebuild ) - pMainSequence->rebuild(); } + + if( bNeedRebuild ) + pMainSequence->rebuild(); } OUString EffectMigration::GetSoundFile( SvxShape* pShape ) @@ -1258,20 +1258,20 @@ bool EffectMigration::GetSoundOn( SvxShape* pShape ) void EffectMigration::SetAnimationPath( SvxShape* pShape, SdrPathObj const * pPathObj ) { - if( pShape && pPathObj ) - { - SdrObject* pObj = pShape->GetSdrObject(); + if( !(pShape && pPathObj) ) + return; + + SdrObject* pObj = pShape->GetSdrObject(); - if( pObj ) + if( pObj ) + { + const Reference< XShape > xShape( pShape ); + SdPage* pPage = dynamic_cast< SdPage* >(pPathObj->getSdrPageFromSdrObject()); + if( pPage ) { - const Reference< XShape > xShape( pShape ); - SdPage* pPage = dynamic_cast< SdPage* >(pPathObj->getSdrPageFromSdrObject()); - if( pPage ) - { - std::shared_ptr< sd::MainSequence > pMainSequence( pPage->getMainSequence() ); - if( pMainSequence.get() ) - CustomAnimationEffectPtr pCreated( pMainSequence->append( *pPathObj, makeAny( xShape ), -1.0 ) ); - } + std::shared_ptr< sd::MainSequence > pMainSequence( pPage->getMainSequence() ); + if( pMainSequence.get() ) + CustomAnimationEffectPtr pCreated( pMainSequence->append( *pPathObj, makeAny( xShape ), -1.0 ) ); } } } @@ -1340,67 +1340,67 @@ void EffectMigration::CreateAnimatedGroup(SdrObjGroup const & rGroupObj, SdPage& // aw080 will give a vector immediately SdrObjListIter aIter(rGroupObj); - if(aIter.Count()) - { - std::shared_ptr< sd::MainSequence > pMainSequence(rPage.getMainSequence()); + if(!aIter.Count()) + return; - if(pMainSequence.get()) - { - std::vector< SdrObject* > aObjects; - aObjects.reserve(aIter.Count()); + std::shared_ptr< sd::MainSequence > pMainSequence(rPage.getMainSequence()); - while(aIter.IsMore()) - { - // do move to page rough with old/current stuff, will be different in aw080 anyways - SdrObject* pCandidate = aIter.Next(); - rGroupObj.GetSubList()->NbcRemoveObject(pCandidate->GetOrdNum()); - rPage.NbcInsertObject(pCandidate); - aObjects.push_back(pCandidate); - } + if(!pMainSequence.get()) + return; - // create main node - Reference< XMultiServiceFactory > xMsf(::comphelper::getProcessServiceFactory()); - Reference< XAnimationNode > xOuterSeqTimeContainer(xMsf->createInstance("com.sun.star.animations.ParallelTimeContainer"), UNO_QUERY_THROW); + std::vector< SdrObject* > aObjects; + aObjects.reserve(aIter.Count()); - // set begin - xOuterSeqTimeContainer->setBegin(Any(0.0)); + while(aIter.IsMore()) + { + // do move to page rough with old/current stuff, will be different in aw080 anyways + SdrObject* pCandidate = aIter.Next(); + rGroupObj.GetSubList()->NbcRemoveObject(pCandidate->GetOrdNum()); + rPage.NbcInsertObject(pCandidate); + aObjects.push_back(pCandidate); + } - // prepare parent container - Reference< XTimeContainer > xParentContainer(xOuterSeqTimeContainer, UNO_QUERY_THROW); + // create main node + Reference< XMultiServiceFactory > xMsf(::comphelper::getProcessServiceFactory()); + Reference< XAnimationNode > xOuterSeqTimeContainer(xMsf->createInstance("com.sun.star.animations.ParallelTimeContainer"), UNO_QUERY_THROW); - // prepare loop over objects - SdrObject* pNext = nullptr; - const double fDurationShow(0.2); - const double fDurationHide(0.001); + // set begin + xOuterSeqTimeContainer->setBegin(Any(0.0)); - for(size_t a(0); a < aObjects.size(); a++) - { - SdrObject* pLast = pNext; - pNext = aObjects[a]; + // prepare parent container + Reference< XTimeContainer > xParentContainer(xOuterSeqTimeContainer, UNO_QUERY_THROW); - // create node - if(pLast) - { - createVisibilityOnOffNode(xParentContainer, *pLast, false, false, fDurationHide); - } + // prepare loop over objects + SdrObject* pNext = nullptr; + const double fDurationShow(0.2); + const double fDurationHide(0.001); - if(pNext) - { - createVisibilityOnOffNode(xParentContainer, *pNext, true, !a, fDurationShow); - } - } + for(size_t a(0); a < aObjects.size(); a++) + { + SdrObject* pLast = pNext; + pNext = aObjects[a]; - // create end node - if(pNext) - { - createVisibilityOnOffNode(xParentContainer, *pNext, false, false, fDurationHide); - } + // create node + if(pLast) + { + createVisibilityOnOffNode(xParentContainer, *pLast, false, false, fDurationHide); + } - // add to main sequence and rebuild - pMainSequence->createEffects(xOuterSeqTimeContainer); - pMainSequence->rebuild(); + if(pNext) + { + createVisibilityOnOffNode(xParentContainer, *pNext, true, !a, fDurationShow); } } + + // create end node + if(pNext) + { + createVisibilityOnOffNode(xParentContainer, *pNext, false, false, fDurationHide); + } + + // add to main sequence and rebuild + pMainSequence->createEffects(xOuterSeqTimeContainer); + pMainSequence->rebuild(); } void EffectMigration::DocumentLoaded(SdDrawDocument & rDoc) diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx index f5f461b4de73..554dc4318786 100644 --- a/sd/source/core/annotations/Annotation.cxx +++ b/sd/source/core/annotations/Annotation.cxx @@ -487,18 +487,18 @@ void UndoInsertOrRemoveAnnotation::Undo() { SdPage* pPage = mxAnnotation->GetPage(); SdrModel* pModel = mxAnnotation->GetModel(); - if( pPage && pModel ) + if( !(pPage && pModel) ) + return; + + Reference< XAnnotation > xAnnotation( mxAnnotation.get() ); + if( mbInsert ) + { + pPage->removeAnnotation( xAnnotation ); + } + else { - Reference< XAnnotation > xAnnotation( mxAnnotation.get() ); - if( mbInsert ) - { - pPage->removeAnnotation( xAnnotation ); - } - else - { - pPage->addAnnotation( xAnnotation, mnIndex ); - LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation ); - } + pPage->addAnnotation( xAnnotation, mnIndex ); + LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation ); } } @@ -506,19 +506,19 @@ void UndoInsertOrRemoveAnnotation::Redo() { SdPage* pPage = mxAnnotation->GetPage(); SdrModel* pModel = mxAnnotation->GetModel(); - if( pPage && pModel ) + if( !(pPage && pModel) ) + return; + + Reference< XAnnotation > xAnnotation( mxAnnotation.get() ); + + if( mbInsert ) + { + pPage->addAnnotation( xAnnotation, mnIndex ); + LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation ); + } + else { - Reference< XAnnotation > xAnnotation( mxAnnotation.get() ); - - if( mbInsert ) - { - pPage->addAnnotation( xAnnotation, mnIndex ); - LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation ); - } - else - { - pPage->removeAnnotation( xAnnotation ); - } + pPage->removeAnnotation( xAnnotation ); } } diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index 90a503f0e180..58c8a404b144 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -807,21 +807,21 @@ void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode) /** updates all links, only links in this document should by resolved */ void SdDrawDocument::UpdateAllLinks() { - if (!s_pDocLockedInsertingLinks && pLinkManager && !pLinkManager->GetLinks().empty()) - { - s_pDocLockedInsertingLinks = this; // lock inserting links. only links in this document should by resolved - - if (mpDocSh) - { - comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = mpDocSh->getEmbeddedObjectContainer(); - rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true); - } + if (s_pDocLockedInsertingLinks || !pLinkManager || pLinkManager->GetLinks().empty()) + return; - pLinkManager->UpdateAllLinks(true, false, nullptr); // query box: update all links? + s_pDocLockedInsertingLinks = this; // lock inserting links. only links in this document should by resolved - if (s_pDocLockedInsertingLinks == this) - s_pDocLockedInsertingLinks = nullptr; // unlock inserting links + if (mpDocSh) + { + comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = mpDocSh->getEmbeddedObjectContainer(); + rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true); } + + pLinkManager->UpdateAllLinks(true, false, nullptr); // query box: update all links? + + if (s_pDocLockedInsertingLinks == this) + s_pDocLockedInsertingLinks = nullptr; // unlock inserting links } /** this loops over the presentation objects of a page and repairs some new settings @@ -830,71 +830,71 @@ void SdDrawDocument::UpdateAllLinks() void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool ) { sd::ShapeList& rPresentationShapes( pPage->GetPresentationShapeList() ); - if(!rPresentationShapes.isEmpty()) - { - // Create lists of title and outline styles - OUString aName = pPage->GetLayoutName(); - aName = aName.copy( 0, aName.indexOf( SD_LT_SEPARATOR ) ); + if(rPresentationShapes.isEmpty()) + return; + + // Create lists of title and outline styles + OUString aName = pPage->GetLayoutName(); + aName = aName.copy( 0, aName.indexOf( SD_LT_SEPARATOR ) ); - std::vector<SfxStyleSheetBase*> aOutlineList; - pSPool->CreateOutlineSheetList(aName,aOutlineList); + std::vector<SfxStyleSheetBase*> aOutlineList; + pSPool->CreateOutlineSheetList(aName,aOutlineList); - SfxStyleSheet* pTitleSheet = static_cast<SfxStyleSheet*>(pSPool->GetTitleSheet(aName)); + SfxStyleSheet* pTitleSheet = static_cast<SfxStyleSheet*>(pSPool->GetTitleSheet(aName)); - SdrObject* pObj = nullptr; - rPresentationShapes.seekShape(0); + SdrObject* pObj = nullptr; + rPresentationShapes.seekShape(0); - // Now look for title and outline text objects, then make those objects - // listeners. - while( (pObj = rPresentationShapes.getNextShape()) ) + // Now look for title and outline text objects, then make those objects + // listeners. + while( (pObj = rPresentationShapes.getNextShape()) ) + { + if (pObj->GetObjInventor() == SdrInventor::Default) { - if (pObj->GetObjInventor() == SdrInventor::Default) + OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); + sal_uInt16 nId = pObj->GetObjIdentifier(); + + if (nId == OBJ_TITLETEXT) { - OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); - sal_uInt16 nId = pObj->GetObjIdentifier(); + if( pOPO && pOPO->GetOutlinerMode() == OutlinerMode::DontKnow ) + pOPO->SetOutlinerMode( OutlinerMode::TitleObject ); - if (nId == OBJ_TITLETEXT) - { - if( pOPO && pOPO->GetOutlinerMode() == OutlinerMode::DontKnow ) - pOPO->SetOutlinerMode( OutlinerMode::TitleObject ); + // sal_True: don't delete "hard" attributes when doing this. + if (pTitleSheet) + pObj->SetStyleSheet(pTitleSheet, true); + } + else if (nId == OBJ_OUTLINETEXT) + { + if( pOPO && pOPO->GetOutlinerMode() == OutlinerMode::DontKnow ) + pOPO->SetOutlinerMode( OutlinerMode::OutlineObject ); - // sal_True: don't delete "hard" attributes when doing this. - if (pTitleSheet) - pObj->SetStyleSheet(pTitleSheet, true); - } - else if (nId == OBJ_OUTLINETEXT) + std::vector<SfxStyleSheetBase*>::iterator iter; + for (iter = aOutlineList.begin(); iter != aOutlineList.end(); ++iter) { - if( pOPO && pOPO->GetOutlinerMode() == OutlinerMode::DontKnow ) - pOPO->SetOutlinerMode( OutlinerMode::OutlineObject ); + SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(*iter); - std::vector<SfxStyleSheetBase*>::iterator iter; - for (iter = aOutlineList.begin(); iter != aOutlineList.end(); ++iter) + if (pSheet) { - SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(*iter); - - if (pSheet) - { - pObj->StartListening(*pSheet); + pObj->StartListening(*pSheet); - if( iter == aOutlineList.begin()) - // text frame listens to stylesheet of layer 1 - pObj->NbcSetStyleSheet(pSheet, true); - } + if( iter == aOutlineList.begin()) + // text frame listens to stylesheet of layer 1 + pObj->NbcSetStyleSheet(pSheet, true); } } + } - if( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr && pObj->IsEmptyPresObj()) - { - PresObjKind ePresObjKind = pPage->GetPresObjKind(pObj); - OUString aString( pPage->GetPresObjText(ePresObjKind) ); + if( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr && pObj->IsEmptyPresObj()) + { + PresObjKind ePresObjKind = pPage->GetPresObjKind(pObj); + OUString aString( pPage->GetPresObjText(ePresObjKind) ); - if (!aString.isEmpty()) - { - SdOutliner* pInternalOutl = GetInternalOutliner(); - pPage->SetObjText( static_cast<SdrTextObj*>(pObj), pInternalOutl, ePresObjKind, aString ); - pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( ePresObjKind ), true ); - pInternalOutl->Clear(); - } + if (!aString.isEmpty()) + { + SdOutliner* pInternalOutl = GetInternalOutliner(); + pPage->SetObjText( static_cast<SdrTextObj*>(pObj), pInternalOutl, ePresObjKind, aString ); + pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( ePresObjKind ), true ); + pInternalOutl->Clear(); } } } diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index 7b7215789266..bf3ecb518aff 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -509,174 +509,174 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const * pRefDocument /* = // If no page exists yet in the model, (File -> New), insert a page sal_uInt16 nPageCount = GetPageCount(); - if (nPageCount <= 1) - { - // #i57181# Paper size depends on Language, like in Writer - Size aDefSize = SvxPaperInfo::GetDefaultPaperSize( MapUnit::Map100thMM ); + if (nPageCount > 1) + return; - // Insert handout page - SdPage* pHandoutPage = AllocSdPage(false); + // #i57181# Paper size depends on Language, like in Writer + Size aDefSize = SvxPaperInfo::GetDefaultPaperSize( MapUnit::Map100thMM ); - SdPage* pRefPage = nullptr; + // Insert handout page + SdPage* pHandoutPage = AllocSdPage(false); - if( pRefDocument ) - pRefPage = pRefDocument->GetSdPage( 0, PageKind::Handout ); + SdPage* pRefPage = nullptr; - if( pRefPage ) - { - pHandoutPage->SetSize(pRefPage->GetSize()); - pHandoutPage->SetBorder( pRefPage->GetLeftBorder(), pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), pRefPage->GetLowerBorder() ); - } - else - { - pHandoutPage->SetSize(aDefSize); - pHandoutPage->SetBorder(0, 0, 0, 0); - } - - pHandoutPage->SetPageKind(PageKind::Handout); - pHandoutPage->SetName( SdResId(STR_HANDOUT) ); - InsertPage(pHandoutPage, 0); - - // Insert master page and register this with the handout page - SdPage* pHandoutMPage = AllocSdPage(true); - pHandoutMPage->SetSize( pHandoutPage->GetSize() ); - pHandoutMPage->SetPageKind(PageKind::Handout); - pHandoutMPage->SetBorder( pHandoutPage->GetLeftBorder(), - pHandoutPage->GetUpperBorder(), - pHandoutPage->GetRightBorder(), - pHandoutPage->GetLowerBorder() ); - InsertMasterPage(pHandoutMPage, 0); - pHandoutPage->TRG_SetMasterPage( *pHandoutMPage ); + if( pRefDocument ) + pRefPage = pRefDocument->GetSdPage( 0, PageKind::Handout ); - // Insert page - // If nPageCount==1 is, the model for the clipboard was created, thus a - // default page must already exist - SdPage* pPage; - bool bClipboard = false; + if( pRefPage ) + { + pHandoutPage->SetSize(pRefPage->GetSize()); + pHandoutPage->SetBorder( pRefPage->GetLeftBorder(), pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), pRefPage->GetLowerBorder() ); + } + else + { + pHandoutPage->SetSize(aDefSize); + pHandoutPage->SetBorder(0, 0, 0, 0); + } - if( pRefDocument ) - pRefPage = pRefDocument->GetSdPage( 0, PageKind::Standard ); + pHandoutPage->SetPageKind(PageKind::Handout); + pHandoutPage->SetName( SdResId(STR_HANDOUT) ); + InsertPage(pHandoutPage, 0); + + // Insert master page and register this with the handout page + SdPage* pHandoutMPage = AllocSdPage(true); + pHandoutMPage->SetSize( pHandoutPage->GetSize() ); + pHandoutMPage->SetPageKind(PageKind::Handout); + pHandoutMPage->SetBorder( pHandoutPage->GetLeftBorder(), + pHandoutPage->GetUpperBorder(), + pHandoutPage->GetRightBorder(), + pHandoutPage->GetLowerBorder() ); + InsertMasterPage(pHandoutMPage, 0); + pHandoutPage->TRG_SetMasterPage( *pHandoutMPage ); + + // Insert page + // If nPageCount==1 is, the model for the clipboard was created, thus a + // default page must already exist + SdPage* pPage; + bool bClipboard = false; + + if( pRefDocument ) + pRefPage = pRefDocument->GetSdPage( 0, PageKind::Standard ); + + if (nPageCount == 0) + { + pPage = AllocSdPage(false); - if (nPageCount == 0) + if( pRefPage ) { - pPage = AllocSdPage(false); + pPage->SetSize( pRefPage->GetSize() ); + pPage->SetBorder( pRefPage->GetLeftBorder(), pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), pRefPage->GetLowerBorder() ); + } + else if (meDocType == DocumentType::Draw) + { + // Draw: always use default size with margins + pPage->SetSize(aDefSize); - if( pRefPage ) - { - pPage->SetSize( pRefPage->GetSize() ); - pPage->SetBorder( pRefPage->GetLeftBorder(), pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), pRefPage->GetLowerBorder() ); - } - else if (meDocType == DocumentType::Draw) + SfxPrinter* pPrinter = mpDocSh->GetPrinter(false); + if (pPrinter && pPrinter->IsValid()) { - // Draw: always use default size with margins - pPage->SetSize(aDefSize); - - SfxPrinter* pPrinter = mpDocSh->GetPrinter(false); - if (pPrinter && pPrinter->IsValid()) - { - Size aOutSize(pPrinter->GetOutputSize()); - Point aPageOffset(pPrinter->GetPageOffset()); - aPageOffset -= pPrinter->PixelToLogic( Point() ); - long nOffset = !aPageOffset.X() && !aPageOffset.Y() ? 0 : PRINT_OFFSET; + Size aOutSize(pPrinter->GetOutputSize()); + Point aPageOffset(pPrinter->GetPageOffset()); + aPageOffset -= pPrinter->PixelToLogic( Point() ); + long nOffset = !aPageOffset.X() && !aPageOffset.Y() ? 0 : PRINT_OFFSET; - sal_uLong nTop = aPageOffset.Y(); - sal_uLong nLeft = aPageOffset.X(); - sal_uLong nBottom = std::max(static_cast<long>(aDefSize.Height() - aOutSize.Height() - nTop + nOffset), 0L); - sal_uLong nRight = std::max(static_cast<long>(aDefSize.Width() - aOutSize.Width() - nLeft + nOffset), 0L); + sal_uLong nTop = aPageOffset.Y(); + sal_uLong nLeft = aPageOffset.X(); + sal_uLong nBottom = std::max(static_cast<long>(aDefSize.Height() - aOutSize.Height() - nTop + nOffset), 0L); + sal_uLong nRight = std::max(static_cast<long>(aDefSize.Width() - aOutSize.Width() - nLeft + nOffset), 0L); - pPage->SetBorder(nLeft, nTop, nRight, nBottom); - } - else - { - // The printer is not available. Use a border of 10mm - // on each side instead. - // This has to be kept synchronized with the border - // width set in the - // SvxPageDescPage::PaperSizeSelect_Impl callback. - pPage->SetBorder(1000, 1000, 1000, 1000); - } + pPage->SetBorder(nLeft, nTop, nRight, nBottom); } else { - // Impress: always use screen format, landscape. - Size aSz( SvxPaperInfo::GetPaperSize(PAPER_SCREEN_16_9, MapUnit::Map100thMM) ); - pPage->SetSize( Size( aSz.Height(), aSz.Width() ) ); - pPage->SetBorder(0, 0, 0, 0); + // The printer is not available. Use a border of 10mm + // on each side instead. + // This has to be kept synchronized with the border + // width set in the + // SvxPageDescPage::PaperSizeSelect_Impl callback. + pPage->SetBorder(1000, 1000, 1000, 1000); } - - InsertPage(pPage, 1); } else { - bClipboard = true; - pPage = static_cast<SdPage*>( GetPage(1) ); + // Impress: always use screen format, landscape. + Size aSz( SvxPaperInfo::GetPaperSize(PAPER_SCREEN_16_9, MapUnit::Map100thMM) ); + pPage->SetSize( Size( aSz.Height(), aSz.Width() ) ); + pPage->SetBorder(0, 0, 0, 0); } - // Insert master page, then register this with the page - SdPage* pMPage = AllocSdPage(true); - pMPage->SetSize( pPage->GetSize() ); - pMPage->SetBorder( pPage->GetLeftBorder(), - pPage->GetUpperBorder(), - pPage->GetRightBorder(), - pPage->GetLowerBorder() ); - InsertMasterPage(pMPage, 1); - pPage->TRG_SetMasterPage( *pMPage ); - if( bClipboard ) - pMPage->SetLayoutName( pPage->GetLayoutName() ); - - // Insert notes page - SdPage* pNotesPage = AllocSdPage(false); - - if( pRefDocument ) - pRefPage = pRefDocument->GetSdPage( 0, PageKind::Notes ); + InsertPage(pPage, 1); + } + else + { + bClipboard = true; + pPage = static_cast<SdPage*>( GetPage(1) ); + } - if( pRefPage ) + // Insert master page, then register this with the page + SdPage* pMPage = AllocSdPage(true); + pMPage->SetSize( pPage->GetSize() ); + pMPage->SetBorder( pPage->GetLeftBorder(), + pPage->GetUpperBorder(), + pPage->GetRightBorder(), + pPage->GetLowerBorder() ); + InsertMasterPage(pMPage, 1); + pPage->TRG_SetMasterPage( *pMPage ); + if( bClipboard ) + pMPage->SetLayoutName( pPage->GetLayoutName() ); + + // Insert notes page + SdPage* pNotesPage = AllocSdPage(false); + + if( pRefDocument ) + pRefPage = pRefDocument->GetSdPage( 0, PageKind::Notes ); + + if( pRefPage ) + { + pNotesPage->SetSize( pRefPage->GetSize() ); + pNotesPage->SetBorder( pRefPage->GetLeftBorder(), pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), pRefPage->GetLowerBorder() ); + } + else + { + // Always use portrait format + if (aDefSize.Height() >= aDefSize.Width()) { - pNotesPage->SetSize( pRefPage->GetSize() ); - pNotesPage->SetBorder( pRefPage->GetLeftBorder(), pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), pRefPage->GetLowerBorder() ); + pNotesPage->SetSize(aDefSize); } else { - // Always use portrait format - if (aDefSize.Height() >= aDefSize.Width()) - { - pNotesPage->SetSize(aDefSize); - } - else - { - pNotesPage->SetSize( Size(aDefSize.Height(), aDefSize.Width()) ); - } - - pNotesPage->SetBorder(0, 0, 0, 0); + pNotesPage->SetSize( Size(aDefSize.Height(), aDefSize.Width()) ); } - pNotesPage->SetPageKind(PageKind::Notes); - InsertPage(pNotesPage, 2); - if( bClipboard ) - pNotesPage->SetLayoutName( pPage->GetLayoutName() ); - - // Insert master page, then register this with the notes page - SdPage* pNotesMPage = AllocSdPage(true); - pNotesMPage->SetSize( pNotesPage->GetSize() ); - pNotesMPage->SetPageKind(PageKind::Notes); - pNotesMPage->SetBorder( pNotesPage->GetLeftBorder(), - pNotesPage->GetUpperBorder(), - pNotesPage->GetRightBorder(), - pNotesPage->GetLowerBorder() ); - InsertMasterPage(pNotesMPage, 2); - pNotesPage->TRG_SetMasterPage( *pNotesMPage ); - if( bClipboard ) - pNotesMPage->SetLayoutName( pPage->GetLayoutName() ); - - if( !pRefPage && (meDocType != DocumentType::Draw) ) - pPage->SetAutoLayout( AUTOLAYOUT_TITLE, true, true ); - - mpWorkStartupTimer.reset( new Timer("DrawWorkStartupTimer") ); - mpWorkStartupTimer->SetInvokeHandler( LINK(this, SdDrawDocument, WorkStartupHdl) ); - mpWorkStartupTimer->SetTimeout(2000); - mpWorkStartupTimer->Start(); - SetChanged(false); + pNotesPage->SetBorder(0, 0, 0, 0); } + pNotesPage->SetPageKind(PageKind::Notes); + InsertPage(pNotesPage, 2); + if( bClipboard ) + pNotesPage->SetLayoutName( pPage->GetLayoutName() ); + + // Insert master page, then register this with the notes page + SdPage* pNotesMPage = AllocSdPage(true); + pNotesMPage->SetSize( pNotesPage->GetSize() ); + pNotesMPage->SetPageKind(PageKind::Notes); + pNotesMPage->SetBorder( pNotesPage->GetLeftBorder(), + pNotesPage->GetUpperBorder(), + pNotesPage->GetRightBorder(), + pNotesPage->GetLowerBorder() ); + InsertMasterPage(pNotesMPage, 2); + pNotesPage->TRG_SetMasterPage( *pNotesMPage ); + if( bClipboard ) + pNotesMPage->SetLayoutName( pPage->GetLayoutName() ); + + if( !pRefPage && (meDocType != DocumentType::Draw) ) + pPage->SetAutoLayout( AUTOLAYOUT_TITLE, true, true ); + + mpWorkStartupTimer.reset( new Timer("DrawWorkStartupTimer") ); + mpWorkStartupTimer->SetInvokeHandler( LINK(this, SdDrawDocument, WorkStartupHdl) ); + mpWorkStartupTimer->SetTimeout(2000); + mpWorkStartupTimer->Start(); + + SetChanged(false); } // Creates missing notes and handout pages (after PowerPoint import). @@ -1117,118 +1117,118 @@ void SdDrawDocument::CheckMasterPages() break; // then we have a fatal error } - if( nPage < nMaxPages ) - { - SdPage* pNotesPage = nullptr; + if( nPage >= nMaxPages ) + return; - // there is a fatal error in the master page order, - // we need to repair the document - bool bChanged = false; + SdPage* pNotesPage = nullptr; - nPage = 1; - while( nPage < nMaxPages ) + // there is a fatal error in the master page order, + // we need to repair the document + bool bChanged = false; + + nPage = 1; + while( nPage < nMaxPages ) + { + pPage = static_cast<SdPage*> (GetMasterPage( nPage )); + if( pPage->GetPageKind() != PageKind::Standard ) { - pPage = static_cast<SdPage*> (GetMasterPage( nPage )); - if( pPage->GetPageKind() != PageKind::Standard ) + bChanged = true; + sal_uInt16 nFound = nPage + 1; + while( nFound < nMaxPages ) { - bChanged = true; - sal_uInt16 nFound = nPage + 1; - while( nFound < nMaxPages ) + pPage = static_cast<SdPage*>(GetMasterPage( nFound )); + if( PageKind::Standard == pPage->GetPageKind() ) { - pPage = static_cast<SdPage*>(GetMasterPage( nFound )); - if( PageKind::Standard == pPage->GetPageKind() ) - { - MoveMasterPage( nFound, nPage ); - pPage->SetInserted(); - break; - - } + MoveMasterPage( nFound, nPage ); + pPage->SetInserted(); + break; - nFound++; } - // if we don't have any more standard pages, were done - if( nMaxPages == nFound ) - break; + nFound++; } - nPage++; + // if we don't have any more standard pages, were done + if( nMaxPages == nFound ) + break; + } - if( nPage < nMaxPages ) - pNotesPage = static_cast<SdPage*>(GetMasterPage( nPage )); - else - pNotesPage = nullptr; + nPage++; - if( (nullptr == pNotesPage) || (pNotesPage->GetPageKind() != PageKind::Notes) || ( pPage->GetLayoutName() != pNotesPage->GetLayoutName() ) ) + if( nPage < nMaxPages ) + pNotesPage = static_cast<SdPage*>(GetMasterPage( nPage )); + else + pNotesPage = nullptr; + + if( (nullptr == pNotesPage) || (pNotesPage->GetPageKind() != PageKind::Notes) || ( pPage->GetLayoutName() != pNotesPage->GetLayoutName() ) ) + { + bChanged = true; + + sal_uInt16 nFound = nPage + 1; + while( nFound < nMaxPages ) { - bChanged = true; + pNotesPage = static_cast<SdPage*>(GetMasterPage( nFound )); + if( (PageKind::Notes == pNotesPage->GetPageKind()) && ( pPage->GetLayoutName() == pNotesPage->GetLayoutName() ) ) + { + MoveMasterPage( nFound, nPage ); + pNotesPage->SetInserted(); + break; + } + + nFound++; + } - sal_uInt16 nFound = nPage + 1; + // looks like we lost a notes page + if( nMaxPages == nFound ) + { + // so create one + + // first find a reference notes page for size + SdPage* pRefNotesPage = nullptr; + nFound = 0; while( nFound < nMaxPages ) { - pNotesPage = static_cast<SdPage*>(GetMasterPage( nFound )); - if( (PageKind::Notes == pNotesPage->GetPageKind()) && ( pPage->GetLayoutName() == pNotesPage->GetLayoutName() ) ) - { - MoveMasterPage( nFound, nPage ); - pNotesPage->SetInserted(); + pRefNotesPage = static_cast<SdPage*>(GetMasterPage( nFound )); + if( PageKind::Notes == pRefNotesPage->GetPageKind() ) break; - } - nFound++; } + if( nFound == nMaxPages ) + pRefNotesPage = nullptr; - // looks like we lost a notes page - if( nMaxPages == nFound ) + SdPage* pNewNotesPage = AllocSdPage(true); + pNewNotesPage->SetPageKind(PageKind::Notes); + if( pRefNotesPage ) { - // so create one - - // first find a reference notes page for size - SdPage* pRefNotesPage = nullptr; - nFound = 0; - while( nFound < nMaxPages ) - { - pRefNotesPage = static_cast<SdPage*>(GetMasterPage( nFound )); - if( PageKind::Notes == pRefNotesPage->GetPageKind() ) - break; - nFound++; - } - if( nFound == nMaxPages ) - pRefNotesPage = nullptr; - - SdPage* pNewNotesPage = AllocSdPage(true); - pNewNotesPage->SetPageKind(PageKind::Notes); - if( pRefNotesPage ) - { - pNewNotesPage->SetSize( pRefNotesPage->GetSize() ); - pNewNotesPage->SetBorder( pRefNotesPage->GetLeftBorder(), - pRefNotesPage->GetUpperBorder(), - pRefNotesPage->GetRightBorder(), - pRefNotesPage->GetLowerBorder() ); - } - InsertMasterPage(pNewNotesPage, nPage ); - pNewNotesPage->SetLayoutName( pPage->GetLayoutName() ); - pNewNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true, true ); - nMaxPages++; + pNewNotesPage->SetSize( pRefNotesPage->GetSize() ); + pNewNotesPage->SetBorder( pRefNotesPage->GetLeftBorder(), + pRefNotesPage->GetUpperBorder(), + pRefNotesPage->GetRightBorder(), + pRefNotesPage->GetLowerBorder() ); } + InsertMasterPage(pNewNotesPage, nPage ); + pNewNotesPage->SetLayoutName( pPage->GetLayoutName() ); + pNewNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true, true ); + nMaxPages++; } - - nPage++; } - // now remove all remaining and unused non PageKind::Standard slides - while( nPage < nMaxPages ) - { - bChanged = true; + nPage++; + } - RemoveMasterPage( nPage ); - nMaxPages--; - } + // now remove all remaining and unused non PageKind::Standard slides + while( nPage < nMaxPages ) + { + bChanged = true; - if( bChanged ) - { - OSL_FAIL( "master pages where in a wrong order" ); - RecalcPageNums( true); - } + RemoveMasterPage( nPage ); + nMaxPages--; + } + + if( bChanged ) + { + OSL_FAIL( "master pages where in a wrong order" ); + RecalcPageNums( true); } } diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 2d2a6b56523b..f5fba2e58b1d 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -591,7 +591,10 @@ static Any implMakeSolidCellStyle( SdStyleSheetPool* pSSPool, const OUString& rN static void implCreateTableTemplate( const Reference< XNameContainer >& xTableFamily, const OUString& rName, const Any& rBody, const Any& rHeading, const Any& rBanding ) { - if( xTableFamily.is() ) try + if( !xTableFamily.is() ) + return; + + try { if( !xTableFamily->hasByName( rName ) ) { @@ -810,44 +813,44 @@ void SdDrawDocument::StopOnlineSpelling() // Start OnlineSpelling in the background void SdDrawDocument::StartOnlineSpelling(bool bForceSpelling) { - if (mbOnlineSpell && (bForceSpelling || mbInitialOnlineSpellingEnabled) && - mpDocSh && !mpDocSh->IsReadOnly() ) - { - StopOnlineSpelling(); + if (!(mbOnlineSpell && (bForceSpelling || mbInitialOnlineSpellingEnabled) && + mpDocSh && !mpDocSh->IsReadOnly()) ) + return; - SdOutliner* pOutl = GetInternalOutliner(); + StopOnlineSpelling(); - Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() ); - if ( xSpellChecker.is() ) - pOutl->SetSpeller( xSpellChecker ); + SdOutliner* pOutl = GetInternalOutliner(); - Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() ); - if( xHyphenator.is() ) - pOutl->SetHyphenator( xHyphenator ); + Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() ); + if ( xSpellChecker.is() ) + pOutl->SetSpeller( xSpellChecker ); - pOutl->SetDefaultLanguage( meLanguage ); + Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() ); + if( xHyphenator.is() ) + pOutl->SetHyphenator( xHyphenator ); - mpOnlineSpellingList.reset(new ShapeList); - sal_uInt16 nPage; + pOutl->SetDefaultLanguage( meLanguage ); - for ( nPage = 0; nPage < GetPageCount(); nPage++ ) - { - // Search in all pages - FillOnlineSpellingList(static_cast<SdPage*>(GetPage(nPage))); - } + mpOnlineSpellingList.reset(new ShapeList); + sal_uInt16 nPage; - for (nPage = 0; nPage < GetMasterPageCount(); nPage++) - { - // Search all master pages - FillOnlineSpellingList(static_cast<SdPage*>( GetMasterPage(nPage) )); - } + for ( nPage = 0; nPage < GetPageCount(); nPage++ ) + { + // Search in all pages + FillOnlineSpellingList(static_cast<SdPage*>(GetPage(nPage))); + } - mpOnlineSpellingList->seekShape(0); - mpOnlineSpellingIdle.reset(new Idle("OnlineSpelling")); - mpOnlineSpellingIdle->SetInvokeHandler( LINK(this, SdDrawDocument, OnlineSpellingHdl) ); - mpOnlineSpellingIdle->SetPriority(TaskPriority::LOWEST); - mpOnlineSpellingIdle->Start(); + for (nPage = 0; nPage < GetMasterPageCount(); nPage++) + { + // Search all master pages + FillOnlineSpellingList(static_cast<SdPage*>( GetMasterPage(nPage) )); } + + mpOnlineSpellingList->seekShape(0); + mpOnlineSpellingIdle.reset(new Idle("OnlineSpelling")); + mpOnlineSpellingIdle->SetInvokeHandler( LINK(this, SdDrawDocument, OnlineSpellingHdl) ); + mpOnlineSpellingIdle->SetPriority(TaskPriority::LOWEST); + mpOnlineSpellingIdle->Start(); } // Fill OnlineSpelling list @@ -944,54 +947,54 @@ IMPL_LINK_NOARG(SdDrawDocument, OnlineSpellingHdl, Timer *, void) // Spell object (for OnlineSpelling) void SdDrawDocument::SpellObject(SdrTextObj* pObj) { - if (pObj && pObj->GetOutlinerParaObject() /* && pObj != pView->GetTextEditObject() */) + if (!(pObj && pObj->GetOutlinerParaObject()) /* && pObj != pView->GetTextEditObject() */) + return; + + mbHasOnlineSpellErrors = false; + SdOutliner* pOutl = GetInternalOutliner(); + pOutl->SetUpdateMode(true); + Link<EditStatus&,void> aEvtHdl = pOutl->GetStatusEventHdl(); + pOutl->SetStatusEventHdl(LINK(this, SdDrawDocument, OnlineSpellEventHdl)); + + OutlinerMode nOldOutlMode = pOutl->GetMode(); + OutlinerMode nOutlMode = OutlinerMode::TextObject; + if (pObj->GetObjInventor() == SdrInventor::Default && + pObj->GetObjIdentifier() == OBJ_OUTLINETEXT) { - mbHasOnlineSpellErrors = false; - SdOutliner* pOutl = GetInternalOutliner(); - pOutl->SetUpdateMode(true); - Link<EditStatus&,void> aEvtHdl = pOutl->GetStatusEventHdl(); - pOutl->SetStatusEventHdl(LINK(this, SdDrawDocument, OnlineSpellEventHdl)); - - OutlinerMode nOldOutlMode = pOutl->GetMode(); - OutlinerMode nOutlMode = OutlinerMode::TextObject; - if (pObj->GetObjInventor() == SdrInventor::Default && - pObj->GetObjIdentifier() == OBJ_OUTLINETEXT) - { - nOutlMode = OutlinerMode::OutlineObject; - } - pOutl->Init( nOutlMode ); + nOutlMode = OutlinerMode::OutlineObject; + } + pOutl->Init( nOutlMode ); - // Put text into the outliner - pOutl->SetText(*pObj->GetOutlinerParaObject()); + // Put text into the outliner + pOutl->SetText(*pObj->GetOutlinerParaObject()); - if (!mpOnlineSearchItem || pOutl->HasText(*mpOnlineSearchItem)) - { - // Spelling - pOutl->CompleteOnlineSpelling(); + if (!mpOnlineSearchItem || pOutl->HasText(*mpOnlineSearchItem)) + { + // Spelling + pOutl->CompleteOnlineSpelling(); - if (mbHasOnlineSpellErrors) + if (mbHasOnlineSpellErrors) + { + std::unique_ptr<OutlinerParaObject> pOPO = pOutl->CreateParaObject(); + if (pOPO) { - std::unique_ptr<OutlinerParaObject> pOPO = pOutl->CreateParaObject(); - if (pOPO) + if (!( *pOPO == *pObj->GetOutlinerParaObject() ) || + !pObj->GetOutlinerParaObject()->isWrongListEqual( *pOPO )) { - if (!( *pOPO == *pObj->GetOutlinerParaObject() ) || - !pObj->GetOutlinerParaObject()->isWrongListEqual( *pOPO )) - { - sd::ModifyGuard aGuard( this ); + sd::ModifyGuard aGuard( this ); - // taking text from the outliner - // use non-broadcasting version to avoid O(n^2) - pObj->NbcSetOutlinerParaObject( std::move(pOPO) ); - } + // taking text from the outliner + // use non-broadcasting version to avoid O(n^2) + pObj->NbcSetOutlinerParaObject( std::move(pOPO) ); } } } - - pOutl->SetStatusEventHdl(aEvtHdl); - pOutl->SetUpdateMode(false); - pOutl->Init( nOldOutlMode ); - mbHasOnlineSpellErrors = false; } + + pOutl->SetStatusEventHdl(aEvtHdl); + pOutl->SetUpdateMode(false); + pOutl->Init( nOldOutlMode ); + mbHasOnlineSpellErrors = false; } // Object was inserted into model @@ -1282,30 +1285,29 @@ css::text::WritingMode SdDrawDocument::GetDefaultWritingMode() const void SdDrawDocument::SetDefaultWritingMode(css::text::WritingMode eMode ) { - if( pItemPool ) - { - SvxFrameDirection nVal; - switch( eMode ) - { - case css::text::WritingMode_LR_TB: nVal = SvxFrameDirection::Horizontal_LR_TB; break; - case css::text::WritingMode_RL_TB: nVal = SvxFrameDirection::Horizontal_RL_TB; break; - case css::text::WritingMode_TB_RL: nVal = SvxFrameDirection::Vertical_RL_TB; break; - default: - OSL_FAIL( "Frame direction not supported yet" ); - return; - } + if( !pItemPool ) + return; - SvxFrameDirectionItem aModeItem( nVal, EE_PARA_WRITINGDIR ); - pItemPool->SetPoolDefaultItem( aModeItem ); + SvxFrameDirection nVal; + switch( eMode ) + { + case css::text::WritingMode_LR_TB: nVal = SvxFrameDirection::Horizontal_LR_TB; break; + case css::text::WritingMode_RL_TB: nVal = SvxFrameDirection::Horizontal_RL_TB; break; + case css::text::WritingMode_TB_RL: nVal = SvxFrameDirection::Vertical_RL_TB; break; + default: + OSL_FAIL( "Frame direction not supported yet" ); + return; + } - SvxAdjustItem aAdjust( SvxAdjust::Left, EE_PARA_JUST ); + SvxFrameDirectionItem aModeItem( nVal, EE_PARA_WRITINGDIR ); + pItemPool->SetPoolDefaultItem( aModeItem ); - if( eMode == css::text::WritingMode_RL_TB ) - aAdjust.SetAdjust( SvxAdjust::Right ); + SvxAdjustItem aAdjust( SvxAdjust::Left, EE_PARA_JUST ); - pItemPool->SetPoolDefaultItem( aAdjust ); + if( eMode == css::text::WritingMode_RL_TB ) + aAdjust.SetAdjust( SvxAdjust::Right ); - } + pItemPool->SetPoolDefaultItem( aAdjust ); } void SdDrawDocument::getDefaultFonts( vcl::Font& rLatinFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont ) diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 3396c395cc74..ad3ba3cb48ec 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -242,23 +242,23 @@ SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearc /** create background properties */ void SdPage::EnsureMasterPageDefaultBackground() { - if(mbMaster) - { - // no hard attributes on MasterPage attributes - getSdrPageProperties().ClearItem(); - SfxStyleSheet* pSheetForPresObj = GetStyleSheetForMasterPageBackground(); + if(!mbMaster) + return; - if(pSheetForPresObj) - { - // set StyleSheet for background fill attributes - getSdrPageProperties().SetStyleSheet(pSheetForPresObj); - } - else - { - // no style found, assert and set at least drawing::FillStyle_NONE - OSL_FAIL("No Style for MasterPageBackground fill found (!)"); - getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE)); - } + // no hard attributes on MasterPage attributes + getSdrPageProperties().ClearItem(); + SfxStyleSheet* pSheetForPresObj = GetStyleSheetForMasterPageBackground(); + + if(pSheetForPresObj) + { + // set StyleSheet for background fill attributes + getSdrPageProperties().SetStyleSheet(pSheetForPresObj); + } + else + { + // no style found, assert and set at least drawing::FillStyle_NONE + OSL_FAIL("No Style for MasterPageBackground fill found (!)"); + getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE)); } } @@ -709,63 +709,63 @@ SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools::Rectangle& ) { - if (!maLockAutoLayoutArrangement.isLocked()) + if (maLockAutoLayoutArrangement.isLocked()) + return; + + switch (eType) { - switch (eType) + case SdrUserCallType::MoveOnly: + case SdrUserCallType::Resize: { - case SdrUserCallType::MoveOnly: - case SdrUserCallType::Resize: - { - if ( getSdrModelFromSdrPage().isLocked()) - break; + if ( getSdrModelFromSdrPage().isLocked()) + break; - if (!mbMaster) + if (!mbMaster) + { + if (rObj.GetUserCall()) { - if (rObj.GetUserCall()) - { - SdrObject& _rObj = const_cast<SdrObject&>(rObj); - SfxUndoManager* pUndoManager - = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()) - .GetUndoManager(); - const bool bUndo - = pUndoManager && pUndoManager->IsInListAction() && IsInserted(); - - if (bUndo) - pUndoManager->AddUndoAction( - std::make_unique<UndoObjectUserCall>(_rObj)); - - // Object was resized by user and does not listen to its slide anymore - _rObj.SetUserCall(nullptr); - } + SdrObject& _rObj = const_cast<SdrObject&>(rObj); + SfxUndoManager* pUndoManager + = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()) + .GetUndoManager(); + const bool bUndo + = pUndoManager && pUndoManager->IsInListAction() && IsInserted(); + + if (bUndo) + pUndoManager->AddUndoAction( + std::make_unique<UndoObjectUserCall>(_rObj)); + + // Object was resized by user and does not listen to its slide anymore + _rObj.SetUserCall(nullptr); } - else + } + else + { + // Object of the master page changed, therefore adjust + // object on all pages + sal_uInt16 nPageCount = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()) + .GetSdPageCount(mePageKind); + + for (sal_uInt16 i = 0; i < nPageCount; i++) { - // Object of the master page changed, therefore adjust - // object on all pages - sal_uInt16 nPageCount = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()) - .GetSdPageCount(mePageKind); + SdPage* pLoopPage = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()) + .GetSdPage(i, mePageKind); - for (sal_uInt16 i = 0; i < nPageCount; i++) + if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage())) { - SdPage* pLoopPage = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()) - .GetSdPage(i, mePageKind); - - if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage())) - { - // Page listens to this master page, therefore - // adjust AutoLayout - pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout()); - } + // Page listens to this master page, therefore + // adjust AutoLayout + pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout()); } } } - break; - - case SdrUserCallType::Delete: - case SdrUserCallType::Removed: - default: - break; } + break; + + case SdrUserCallType::Delete: + case SdrUserCallType::Removed: + default: + break; } } @@ -800,81 +800,81 @@ void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate ) pMasterPage->EnsureMasterPageDefaultBackground(); } - if (static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDocumentType() == DocumentType::Impress) + if (static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDocumentType() != DocumentType::Impress) + return; + + if( mePageKind == PageKind::Handout && bInit ) { - if( mePageKind == PageKind::Handout && bInit ) + // handout template + + // delete all available handout presentation objects + SdrObject *pObj=nullptr; + while( (pObj = pMasterPage->GetPresObj(PRESOBJ_HANDOUT)) != nullptr ) { - // handout template + pMasterPage->RemoveObject(pObj->GetOrdNum()); - // delete all available handout presentation objects - SdrObject *pObj=nullptr; - while( (pObj = pMasterPage->GetPresObj(PRESOBJ_HANDOUT)) != nullptr ) + if( bUndo ) { - pMasterPage->RemoveObject(pObj->GetOrdNum()); - - if( bUndo ) - { - pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); - } - else - { - SdrObject::Free( pObj ); - } + pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); } - - std::vector< ::tools::Rectangle > aAreas; - CalculateHandoutAreas( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()), pMasterPage->GetAutoLayout(), false, aAreas ); - - const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3; - std::vector< ::tools::Rectangle >::iterator iter( aAreas.begin() ); - - while( iter != aAreas.end() ) + else { - SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PRESOBJ_HANDOUT, false, (*iter++)) ); - // #i105146# We want no content to be displayed for PageKind::Handout, - // so just never set a page as content - pPageObj->SetReferencedPage(nullptr); - - if( bSkip && iter != aAreas.end() ) - ++iter; + SdrObject::Free( pObj ); } } - if( mePageKind != PageKind::Handout ) + std::vector< ::tools::Rectangle > aAreas; + CalculateHandoutAreas( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()), pMasterPage->GetAutoLayout(), false, aAreas ); + + const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3; + std::vector< ::tools::Rectangle >::iterator iter( aAreas.begin() ); + + while( iter != aAreas.end() ) { - SdrObject* pMasterTitle = pMasterPage->GetPresObj( PRESOBJ_TITLE ); - if( pMasterTitle == nullptr ) - pMasterPage->CreateDefaultPresObj(PRESOBJ_TITLE); + SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PRESOBJ_HANDOUT, false, (*iter++)) ); + // #i105146# We want no content to be displayed for PageKind::Handout, + // so just never set a page as content + pPageObj->SetReferencedPage(nullptr); - SdrObject* pMasterOutline = pMasterPage->GetPresObj( mePageKind==PageKind::Notes ? PRESOBJ_NOTES : PRESOBJ_OUTLINE ); - if( pMasterOutline == nullptr ) - pMasterPage->CreateDefaultPresObj( mePageKind == PageKind::Standard ? PRESOBJ_OUTLINE : PRESOBJ_NOTES ); + if( bSkip && iter != aAreas.end() ) + ++iter; } + } - // create header&footer objects + if( mePageKind != PageKind::Handout ) + { + SdrObject* pMasterTitle = pMasterPage->GetPresObj( PRESOBJ_TITLE ); + if( pMasterTitle == nullptr ) + pMasterPage->CreateDefaultPresObj(PRESOBJ_TITLE); - if( bCreate ) - { - if( mePageKind != PageKind::Standard ) - { - SdrObject* pHeader = pMasterPage->GetPresObj( PRESOBJ_HEADER ); - if( pHeader == nullptr ) - pMasterPage->CreateDefaultPresObj( PRESOBJ_HEADER ); - } + SdrObject* pMasterOutline = pMasterPage->GetPresObj( mePageKind==PageKind::Notes ? PRESOBJ_NOTES : PRESOBJ_OUTLINE ); + if( pMasterOutline == nullptr ) + pMasterPage->CreateDefaultPresObj( mePageKind == PageKind::Standard ? PRESOBJ_OUTLINE : PRESOBJ_NOTES ); + } - SdrObject* pDate = pMasterPage->GetPresObj( PRESOBJ_DATETIME ); - if( pDate == nullptr ) - pMasterPage->CreateDefaultPresObj( PRESOBJ_DATETIME ); + // create header&footer objects - SdrObject* pFooter = pMasterPage->GetPresObj( PRESOBJ_FOOTER ); - if( pFooter == nullptr ) - pMasterPage->CreateDefaultPresObj( PRESOBJ_FOOTER ); + if( !bCreate ) + return; - SdrObject* pNumber = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER ); - if( pNumber == nullptr ) - pMasterPage->CreateDefaultPresObj( PRESOBJ_SLIDENUMBER ); - } + if( mePageKind != PageKind::Standard ) + { + SdrObject* pHeader = pMasterPage->GetPresObj( PRESOBJ_HEADER ); + if( pHeader == nullptr ) + pMasterPage->CreateDefaultPresObj( PRESOBJ_HEADER ); } + + SdrObject* pDate = pMasterPage->GetPresObj( PRESOBJ_DATETIME ); + if( pDate == nullptr ) + pMasterPage->CreateDefaultPresObj( PRESOBJ_DATETIME ); + + SdrObject* pFooter = pMasterPage->GetPresObj( PRESOBJ_FOOTER ); + if( pFooter == nullptr ) + pMasterPage->CreateDefaultPresObj( PRESOBJ_FOOTER ); + + SdrObject* pNumber = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER ); + if( pNumber == nullptr ) + pMasterPage->CreateDefaultPresObj( PRESOBJ_SLIDENUMBER ); } namespace { @@ -1369,61 +1369,61 @@ static void CalcAutoLayoutRectangles( SdPage const & rPage,::tools::Rectangle* r OUString sLayoutAttName = layoutAttrList->getNamedItem("type")->getNodeValue(); return sLayoutAttName == sLayoutType; }); - if (aIter != layoutInfo.end()) + if (aIter == layoutInfo.end()) + return; + + int count=0; + Reference<XNode> layoutNode = *aIter; + Reference<XNodeList> layoutChildren = layoutNode->getChildNodes(); + const int presobjsize = layoutChildren->getLength(); + for( int j=0; j< presobjsize ; j++) { - int count=0; - Reference<XNode> layoutNode = *aIter; - Reference<XNodeList> layoutChildren = layoutNode->getChildNodes(); - const int presobjsize = layoutChildren->getLength(); - for( int j=0; j< presobjsize ; j++) - { - OUString nodename; - Reference<XNode> presobj = layoutChildren->item(j); - nodename=presobj->getNodeName(); + OUString nodename; + Reference<XNode> presobj = layoutChildren->item(j); + nodename=presobj->getNodeName(); - //check whether children is blank 'text-node' or 'presobj' node - if(nodename == "presobj") - { - // TODO: rework sd to permit arbitrary number of presentation objects - assert(count < MAX_PRESOBJS); + //check whether children is blank 'text-node' or 'presobj' node + if(nodename == "presobj") + { + // TODO: rework sd to permit arbitrary number of presentation objects + assert(count < MAX_PRESOBJS); - Reference<XNamedNodeMap> presObjAttributes = presobj->getAttributes(); + Reference<XNamedNodeMap> presObjAttributes = presobj->getAttributes(); - Reference<XNode> presObjSizeHeight = presObjAttributes->getNamedItem("relative-height"); - OUString sValue = presObjSizeHeight->getNodeValue(); - propvalue[0] = sValue.toDouble(); + Reference<XNode> presObjSizeHeight = presObjAttributes->getNamedItem("relative-height"); + OUString sValue = presObjSizeHeight->getNodeValue(); + propvalue[0] = sValue.toDouble(); - Reference<XNode> presObjSizeWidth = presObjAttributes->getNamedItem("relative-width"); - sValue = presObjSizeWidth->getNodeValue(); - propvalue[1] = sValue.toDouble(); + Reference<XNode> presObjSizeWidth = presObjAttributes->getNamedItem("relative-width"); + sValue = presObjSizeWidth->getNodeValue(); + propvalue[1] = sValue.toDouble(); - Reference<XNode> presObjPosX = presObjAttributes->getNamedItem("relative-posX"); - sValue = presObjPosX->getNodeValue(); - propvalue[2] = sValue.toDouble(); + Reference<XNode> presObjPosX = presObjAttributes->getNamedItem("relative-posX"); + sValue = presObjPosX->getNodeValue(); + propvalue[2] = sValue.toDouble(); - Reference<XNode> presObjPosY = presObjAttributes->getNamedItem("relative-posY"); - sValue = presObjPosY->getNodeValue(); - propvalue[3] = sValue.toDouble(); + Reference<XNode> presObjPosY = presObjAttributes->getNamedItem("relative-posY"); + sValue = presObjPosY->getNodeValue(); + propvalue[3] = sValue.toDouble(); - if(count == 0) - { - Size aSize ( aTitleRect.GetSize() ); - aSize.setHeight( basegfx::fround(aSize.Height() * propvalue[0]) ); - aSize.setWidth( basegfx::fround(aSize.Width() * propvalue[1]) ); - Point aPos( basegfx::fround(aTitlePos.X() +(aSize.Width() * propvalue[2])), - basegfx::fround(aTitlePos.Y() + (aSize.Height() * propvalue[3])) ); - rRectangle[count] = ::tools::Rectangle(aPos, aSize); - count = count+1; - } - else - { - Size aSize( basegfx::fround(aLayoutSize.Width() * propvalue[1]), - basegfx::fround(aLayoutSize.Height() * propvalue[0]) ); - Point aPos( basegfx::fround(aLayoutPos.X() +(aSize.Width() * propvalue[2])), - basegfx::fround(aLayoutPos.Y() + (aSize.Height() * propvalue[3])) ); - rRectangle[count] = ::tools::Rectangle (aPos, aSize); - count = count+1; - } + if(count == 0) + { + Size aSize ( aTitleRect.GetSize() ); + aSize.setHeight( basegfx::fround(aSize.Height() * propvalue[0]) ); + aSize.setWidth( basegfx::fround(aSize.Width() * propvalue[1]) ); + Point aPos( basegfx::fround(aTitlePos.X() +(aSize.Width() * propvalue[2])), + basegfx::fround(aTitlePos.Y() + (aSize.Height() * propvalue[3])) ); + rRectangle[count] = ::tools::Rectangle(aPos, aSize); + count = count+1; + } + else + { + Size aSize( basegfx::fround(aLayoutSize.Width() * propvalue[1]), + basegfx::fround(aLayoutSize.Height() * propvalue[0]) ); + Point aPos( basegfx::fround(aLayoutPos.X() +(aSize.Width() * propvalue[2])), + basegfx::fround(aLayoutPos.Y() + (aSize.Height() * propvalue[3])) ); + rRectangle[count] = ::tools::Rectangle (aPos, aSize); + count = count+1; } } } @@ -1460,132 +1460,132 @@ static void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDe bMissing = true; } - if( bMissing && bInit ) + if( !(bMissing && bInit) ) + return; + + // for each entry in the layoutdescriptor, look for an alternative shape + for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++) { - // for each entry in the layoutdescriptor, look for an alternative shape - for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++) - { - if( rShapes[i] ) - continue; + if( rShapes[i] ) + continue; - PresObjKind eKind = rDescriptor.meKind[i]; + PresObjKind eKind = rDescriptor.meKind[i]; - SdrObject* pObj = nullptr; - bool bFound = false; + SdrObject* pObj = nullptr; + bool bFound = false; - const size_t nShapeCount = rPage.GetObjCount(); - for(size_t nShapeIndex = 0; nShapeIndex < nShapeCount && !bFound; ++nShapeIndex ) - { - pObj = rPage.GetObj(nShapeIndex); + const size_t nShapeCount = rPage.GetObjCount(); + for(size_t nShapeIndex = 0; nShapeIndex < nShapeCount && !bFound; ++nShapeIndex ) + { + pObj = rPage.GetObj(nShapeIndex); - if( pObj->IsEmptyPresObj() ) - continue; + if( pObj->IsEmptyPresObj() ) + continue; - if( pObj->GetObjInventor() != SdrInventor::Default ) - continue; + if( pObj->GetObjInventor() != SdrInventor::Default ) + continue; - // do not reuse shapes that are already part of the layout - if( std::find( rShapes.begin(), rShapes.end(), pObj ) != rShapes.end() ) - continue; + // do not reuse shapes that are already part of the layout + if( std::find( rShapes.begin(), rShapes.end(), pObj ) != rShapes.end() ) + continue; - bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SfxStyleFamily::Page); - SdrObjKind eSdrObjKind = static_cast< SdrObjKind >( pObj->GetObjIdentifier() ); + bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SfxStyleFamily::Page); + SdrObjKind eSdrObjKind = static_cast< SdrObjKind >( pObj->GetObjIdentifier() ); - switch( eKind ) + switch( eKind ) + { + case PRESOBJ_TITLE: + bFound = eSdrObjKind == OBJ_TITLETEXT; + break; + case PRESOBJ_TABLE: + bFound = eSdrObjKind == OBJ_TABLE; + break; + case PRESOBJ_MEDIA: + bFound = eSdrObjKind == OBJ_MEDIA; + break; + case PRESOBJ_OUTLINE: + bFound = (eSdrObjKind == OBJ_OUTLINETEXT) || + ((eSdrObjKind == OBJ_TEXT) && bPresStyle) || + (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2); + break; + case PRESOBJ_GRAPHIC: + bFound = eSdrObjKind == OBJ_GRAF; + break; + case PRESOBJ_OBJECT: + if( eSdrObjKind == OBJ_OLE2 ) { - case PRESOBJ_TITLE: - bFound = eSdrObjKind == OBJ_TITLETEXT; - break; - case PRESOBJ_TABLE: - bFound = eSdrObjKind == OBJ_TABLE; - break; - case PRESOBJ_MEDIA: - bFound = eSdrObjKind == OBJ_MEDIA; - break; - case PRESOBJ_OUTLINE: - bFound = (eSdrObjKind == OBJ_OUTLINETEXT) || - ((eSdrObjKind == OBJ_TEXT) && bPresStyle) || - (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2); - break; - case PRESOBJ_GRAPHIC: - bFound = eSdrObjKind == OBJ_GRAF; - break; - case PRESOBJ_OBJECT: - if( eSdrObjKind == OBJ_OLE2 ) + SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj ); + if( pOle2 ) { - SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj ); - if( pOle2 ) + if( pOle2->IsEmpty() ) + bFound = true; + else { - if( pOle2->IsEmpty() ) - bFound = true; - else + ::comphelper::IEmbeddedHelper* pPersist(rPage.getSdrModelFromSdrPage().GetPersist()); + + if( pPersist ) { - ::comphelper::IEmbeddedHelper* pPersist(rPage.getSdrModelFromSdrPage().GetPersist()); + uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer(). + GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() ); - if( pPersist ) + // TODO CL->KA: Why is this not working anymore? + if( xObject.is() ) { - uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer(). - GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() ); - - // TODO CL->KA: Why is this not working anymore? - if( xObject.is() ) - { - SvGlobalName aClassId( xObject->getClassID() ); + SvGlobalName aClassId( xObject->getClassID() ); - const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID ); - const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID ); - const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID ); + const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID ); + const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID ); + const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID ); - if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId ) - { - bFound = true; - } + if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId ) + { + bFound = true; } } - } + } } - } - break; - case PRESOBJ_CHART: - case PRESOBJ_CALC: - if( eSdrObjKind == OBJ_OLE2 ) + } + } + break; + case PRESOBJ_CHART: + case PRESOBJ_CALC: + if( eSdrObjKind == OBJ_OLE2 ) + { + SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj ); + if( pOle2 ) { - SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj ); - if( pOle2 ) + if( + ((eKind == PRESOBJ_CHART) && + ( pOle2->GetProgName() == "StarChart" || pOle2->IsChart() ) ) + || + ((eKind == PRESOBJ_CALC) && + ( pOle2->GetProgName() == "StarCalc" || pOle2->IsCalc() ) ) ) { - if( - ((eKind == PRESOBJ_CHART) && - ( pOle2->GetProgName() == "StarChart" || pOle2->IsChart() ) ) - || - ((eKind == PRESOBJ_CALC) && - ( pOle2->GetProgName() == "StarCalc" || pOle2->IsCalc() ) ) ) - { - bFound = true; - } + bFound = true; } - break; - } - else if( eSdrObjKind == OBJ_TABLE ) - { - bFound = true; } break; - case PRESOBJ_PAGE: - case PRESOBJ_HANDOUT: - bFound = eSdrObjKind == OBJ_PAGE; - break; - case PRESOBJ_NOTES: - case PRESOBJ_TEXT: - bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT); - break; - default: - break; } + else if( eSdrObjKind == OBJ_TABLE ) + { + bFound = true; + } + break; + case PRESOBJ_PAGE: + case PRESOBJ_HANDOUT: + bFound = eSdrObjKind == OBJ_PAGE; + break; + case PRESOBJ_NOTES: + case PRESOBJ_TEXT: + bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT); + break; + default: + break; } - - if( bFound ) - rShapes[i] = pObj; } + + if( bFound ) + rShapes[i] = pObj; } } @@ -1631,28 +1631,28 @@ void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate ) } // now delete all empty presentation objects that are no longer used by the new layout - if( bInit ) - { - SdrObject* pObj = nullptr; - maPresentationShapeList.seekShape(0); + if( !bInit ) + return; - while( (pObj = maPresentationShapeList.getNextShape()) ) + SdrObject* pObj = nullptr; + maPresentationShapeList.seekShape(0); + + while( (pObj = maPresentationShapeList.getNextShape()) ) + { + if( aUsedPresentationObjects.count(pObj) == 0 ) { - if( aUsedPresentationObjects.count(pObj) == 0 ) - { - if( pObj->IsEmptyPresObj() ) - { - if( bUndo ) - pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); + if( pObj->IsEmptyPresObj() ) + { + if( bUndo ) + pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); - RemoveObject( pObj->GetOrdNum() ); + RemoveObject( pObj->GetOrdNum() ); - if( !bUndo ) - SdrObject::Free( pObj ); - } -/* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */ + if( !bUndo ) + SdrObject::Free( pObj ); } +/* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */ } } } @@ -2361,134 +2361,134 @@ void SdPage::InsertPresObj(SdrObject* pObj, PresObjKind eKind ) void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, const OUString& rString ) { - if ( pObj ) - { - DBG_ASSERT( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr, "SetObjText: No SdrTextObj!" ); - ::Outliner* pOutl = pOutliner; + if ( !pObj ) + return; - if (!pOutliner) - { - SfxItemPool* pPool(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDrawOutliner().GetEmptyItemSet().GetPool()); - pOutl = new ::Outliner( pPool, OutlinerMode::OutlineObject ); - pOutl->SetRefDevice( SD_MOD()->GetVirtualRefDevice() ); - pOutl->SetEditTextObjectPool(pPool); - pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(getSdrModelFromSdrPage().GetStyleSheetPool())); - pOutl->EnableUndo(false); - pOutl->SetUpdateMode( false ); - } + DBG_ASSERT( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr, "SetObjText: No SdrTextObj!" ); + ::Outliner* pOutl = pOutliner; - OutlinerMode nOutlMode = pOutl->GetMode(); - Size aPaperSize = pOutl->GetPaperSize(); - bool bUpdateMode = pOutl->GetUpdateMode(); - pOutl->SetUpdateMode(false); - pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() ); + if (!pOutliner) + { + SfxItemPool* pPool(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDrawOutliner().GetEmptyItemSet().GetPool()); + pOutl = new ::Outliner( pPool, OutlinerMode::OutlineObject ); + pOutl->SetRefDevice( SD_MOD()->GetVirtualRefDevice() ); + pOutl->SetEditTextObjectPool(pPool); + pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(getSdrModelFromSdrPage().GetStyleSheetPool())); + pOutl->EnableUndo(false); + pOutl->SetUpdateMode( false ); + } + + OutlinerMode nOutlMode = pOutl->GetMode(); + Size aPaperSize = pOutl->GetPaperSize(); + bool bUpdateMode = pOutl->GetUpdateMode(); + pOutl->SetUpdateMode(false); + pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() ); - // Always set the object's StyleSheet at the Outliner to - // use the current objects StyleSheet. Thus it's the same as in - // SetText(...). - // Moved this implementation from where SetObjText(...) was called - // to inside this method to work even when outliner is fetched here. - pOutl->SetStyleSheet(0, pObj->GetStyleSheet()); + // Always set the object's StyleSheet at the Outliner to + // use the current objects StyleSheet. Thus it's the same as in + // SetText(...). + // Moved this implementation from where SetObjText(...) was called + // to inside this method to work even when outliner is fetched here. + pOutl->SetStyleSheet(0, pObj->GetStyleSheet()); - OUString aString; + OUString aString; - switch( eObjKind ) + switch( eObjKind ) + { + case PRESOBJ_OUTLINE: { - case PRESOBJ_OUTLINE: - { - pOutl->Init( OutlinerMode::OutlineObject ); + pOutl->Init( OutlinerMode::OutlineObject ); - aString += "\t"; - aString += rString; + aString += "\t"; + aString += rString; - if (mbMaster) - { - pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) ); - aString += "\n\t\t"; - aString += SdResId(STR_PRESOBJ_MPOUTLLAYER2); + if (mbMaster) + { + pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) ); + aString += "\n\t\t"; + aString += SdResId(STR_PRESOBJ_MPOUTLLAYER2); - aString += "\n\t\t\t"; - aString += SdResId(STR_PRESOBJ_MPOUTLLAYER3); + aString += "\n\t\t\t"; + aString += SdResId(STR_PRESOBJ_MPOUTLLAYER3); - aString += "\n\t\t\t\t"; - aString += SdResId(STR_PRESOBJ_MPOUTLLAYER4); + aString += "\n\t\t\t\t"; + aString += SdResId(STR_PRESOBJ_MPOUTLLAYER4); - aString += "\n\t\t\t\t\t"; - aString += SdResId(STR_PRESOBJ_MPOUTLLAYER5); + aString += "\n\t\t\t\t\t"; + aString += SdResId(STR_PRESOBJ_MPOUTLLAYER5); - aString += "\n\t\t\t\t\t\t"; - aString += SdResId(STR_PRESOBJ_MPOUTLLAYER6); + aString += "\n\t\t\t\t\t\t"; + aString += SdResId(STR_PRESOBJ_MPOUTLLAYER6); - aString += "\n\t\t\t\t\t\t\t"; - aString += SdResId(STR_PRESOBJ_MPOUTLLAYER7); + aString += "\n\t\t\t\t\t\t\t"; + aString += SdResId(STR_PRESOBJ_MPOUTLLAYER7); - } } - break; + } + break; - case PRESOBJ_TITLE: - { - pOutl->Init( OutlinerMode::TitleObject ); - aString += rString; - } - break; + case PRESOBJ_TITLE: + { + pOutl->Init( OutlinerMode::TitleObject ); + aString += rString; + } + break; - default: - { - pOutl->Init( OutlinerMode::TextObject ); - aString += rString; + default: + { + pOutl->Init( OutlinerMode::TextObject ); + aString += rString; - // check if we need to add a text field - std::unique_ptr<SvxFieldData> pData; + // check if we need to add a text field + std::unique_ptr<SvxFieldData> pData; - switch( eObjKind ) - { - case PRESOBJ_HEADER: - pData.reset(new SvxHeaderField()); - break; - case PRESOBJ_FOOTER: - pData .reset(new SvxFooterField()); - break; - case PRESOBJ_SLIDENUMBER: - pData.reset(new SvxPageField()); - break; - case PRESOBJ_DATETIME: - pData.reset(new SvxDateTimeField()); - break; - default: - break; - } + switch( eObjKind ) + { + case PRESOBJ_HEADER: + pData.reset(new SvxHeaderField()); + break; + case PRESOBJ_FOOTER: + pData .reset(new SvxFooterField()); + break; + case PRESOBJ_SLIDENUMBER: + pData.reset(new SvxPageField()); + break; + case PRESOBJ_DATETIME: + pData.reset(new SvxDateTimeField()); + break; + default: + break; + } - if( pData ) - { - ESelection e; - SvxFieldItem aField( *pData, EE_FEATURE_FIELD ); - pOutl->QuickInsertField(aField,e); - } + if( pData ) + { + ESelection e; + SvxFieldItem aField( *pData, EE_FEATURE_FIELD ); + pOutl->QuickInsertField(aField,e); } - break; } + break; + } - pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() ); + pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() ); - if( !aString.isEmpty() ) - pOutl->SetText( aString, pOutl->GetParagraph( 0 ) ); + if( !aString.isEmpty() ) + pOutl->SetText( aString, pOutl->GetParagraph( 0 ) ); - pObj->SetOutlinerParaObject( pOutl->CreateParaObject() ); + pObj->SetOutlinerParaObject( pOutl->CreateParaObject() ); - if (!pOutliner) - { - delete pOutl; - pOutl = nullptr; - } - else - { - // restore the outliner - pOutl->Init( nOutlMode ); - pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() ); - pOutl->SetUpdateMode( bUpdateMode ); - pOutl->SetPaperSize( aPaperSize ); - } + if (!pOutliner) + { + delete pOutl; + pOutl = nullptr; + } + else + { + // restore the outliner + pOutl->Init( nOutlMode ); + pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() ); + pOutl->SetUpdateMode( bUpdateMode ); + pOutl->SetPaperSize( aPaperSize ); } } @@ -2728,55 +2728,55 @@ void SdPage::setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettin SetChanged(); - if(TRG_HasMasterPage()) - { - TRG_GetMasterPageDescriptorViewContact().ActionChanged(); + if(!TRG_HasMasterPage()) + return; - // #i119056# For HeaderFooterSettings SdrObjects are used, but the properties - // used are not part of their model data, but kept in SD. This data is applied - // using a 'backdoor' on primitive creation. Thus, the normal mechanism to detect - // object changes does not work here. It is necessary to trigger updates here - // directly. BroadcastObjectChange used for PagePreview invalidations, - // flushViewObjectContacts used to invalidate and flush all visualizations in - // edit views. - SdPage* pMasterPage = dynamic_cast< SdPage* >(&TRG_GetMasterPage()); + TRG_GetMasterPageDescriptorViewContact().ActionChanged(); - if(pMasterPage) - { - SdrObject* pCandidate = nullptr; + // #i119056# For HeaderFooterSettings SdrObjects are used, but the properties + // used are not part of their model data, but kept in SD. This data is applied + // using a 'backdoor' on primitive creation. Thus, the normal mechanism to detect + // object changes does not work here. It is necessary to trigger updates here + // directly. BroadcastObjectChange used for PagePreview invalidations, + // flushViewObjectContacts used to invalidate and flush all visualizations in + // edit views. + SdPage* pMasterPage = dynamic_cast< SdPage* >(&TRG_GetMasterPage()); - pCandidate = pMasterPage->GetPresObj( PRESOBJ_HEADER ); + if(!pMasterPage) + return; - if(pCandidate) - { - pCandidate->BroadcastObjectChange(); - pCandidate->GetViewContact().flushViewObjectContacts(); - } + SdrObject* pCandidate = nullptr; - pCandidate = pMasterPage->GetPresObj( PRESOBJ_DATETIME ); + pCandidate = pMasterPage->GetPresObj( PRESOBJ_HEADER ); - if(pCandidate) - { - pCandidate->BroadcastObjectChange(); - pCandidate->GetViewContact().flushViewObjectContacts(); - } + if(pCandidate) + { + pCandidate->BroadcastObjectChange(); + pCandidate->GetViewContact().flushViewObjectContacts(); + } - pCandidate = pMasterPage->GetPresObj( PRESOBJ_FOOTER ); + pCandidate = pMasterPage->GetPresObj( PRESOBJ_DATETIME ); - if(pCandidate) - { - pCandidate->BroadcastObjectChange(); - pCandidate->GetViewContact().flushViewObjectContacts(); - } + if(pCandidate) + { + pCandidate->BroadcastObjectChange(); + pCandidate->GetViewContact().flushViewObjectContacts(); + } - pCandidate = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER ); + pCandidate = pMasterPage->GetPresObj( PRESOBJ_FOOTER ); - if(pCandidate) - { - pCandidate->BroadcastObjectChange(); - pCandidate->GetViewContact().flushViewObjectContacts(); - } - } + if(pCandidate) + { + pCandidate->BroadcastObjectChange(); + pCandidate->GetViewContact().flushViewObjectContacts(); + } + + pCandidate = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER ); + + if(pCandidate) + { + pCandidate->BroadcastObjectChange(); + pCandidate->GetViewContact().flushViewObjectContacts(); } } diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx index 417fdf27146a..a1e988d9c9d7 100644 --- a/sd/source/core/sdpage2.cxx +++ b/sd/source/core/sdpage2.cxx @@ -251,23 +251,23 @@ void SdPage::EndListenOutlineText() { SdrObject* pOutlineTextObj = GetPresObj(PRESOBJ_OUTLINE); - if (pOutlineTextObj) - { - SdStyleSheetPool* pSPool = static_cast<SdStyleSheetPool*>(getSdrModelFromSdrPage().GetStyleSheetPool()); - DBG_ASSERT(pSPool, "StyleSheetPool missing"); - OUString aTrueLayoutName(maLayoutName); - sal_Int32 nIndex = aTrueLayoutName.indexOf( SD_LT_SEPARATOR ); - if( nIndex != -1 ) - aTrueLayoutName = aTrueLayoutName.copy(0, nIndex); + if (!pOutlineTextObj) + return; - std::vector<SfxStyleSheetBase*> aOutlineStyles; - pSPool->CreateOutlineSheetList(aTrueLayoutName,aOutlineStyles); + SdStyleSheetPool* pSPool = static_cast<SdStyleSheetPool*>(getSdrModelFromSdrPage().GetStyleSheetPool()); + DBG_ASSERT(pSPool, "StyleSheetPool missing"); + OUString aTrueLayoutName(maLayoutName); + sal_Int32 nIndex = aTrueLayoutName.indexOf( SD_LT_SEPARATOR ); + if( nIndex != -1 ) + aTrueLayoutName = aTrueLayoutName.copy(0, nIndex); - for (auto& rpStyle : aOutlineStyles) - { - SfxStyleSheet *pSheet = static_cast<SfxStyleSheet*>(rpStyle); - pOutlineTextObj->EndListening(*pSheet); - } + std::vector<SfxStyleSheetBase*> aOutlineStyles; + pSPool->CreateOutlineSheetList(aTrueLayoutName,aOutlineStyles); + + for (auto& rpStyle : aOutlineStyles) + { + SfxStyleSheet *pSheet = static_cast<SfxStyleSheet*>(rpStyle); + pOutlineTextObj->EndListening(*pSheet); } } @@ -292,25 +292,25 @@ void SdPage::ConnectLink() { sfx2::LinkManager* pLinkManager(getSdrModelFromSdrPage().GetLinkManager()); - if (pLinkManager && !mpPageLink && !maFileName.isEmpty() && !maBookmarkName.isEmpty() && + if (!(pLinkManager && !mpPageLink && !maFileName.isEmpty() && !maBookmarkName.isEmpty() && mePageKind==PageKind::Standard && !IsMasterPage() && - static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).IsNewOrLoadCompleted()) - { - /********************************************************************** - * Connect - * Only standard pages are allowed to be linked - **********************************************************************/ - ::sd::DrawDocShell* pDocSh = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDocSh(); + static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).IsNewOrLoadCompleted())) + return; - if (!pDocSh || pDocSh->GetMedium()->GetOrigURL() != maFileName) - { - // No links to document owned pages! - mpPageLink = new SdPageLink(this, maFileName, maBookmarkName); - OUString aFilterName(SdResId(STR_IMPRESS)); - pLinkManager->InsertFileLink(*mpPageLink, OBJECT_CLIENT_FILE, - maFileName, &aFilterName, &maBookmarkName); - mpPageLink->Connect(); - } + /********************************************************************** + * Connect + * Only standard pages are allowed to be linked + **********************************************************************/ + ::sd::DrawDocShell* pDocSh = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDocSh(); + + if (!pDocSh || pDocSh->GetMedium()->GetOrigURL() != maFileName) + { + // No links to document owned pages! + mpPageLink = new SdPageLink(this, maFileName, maBookmarkName); + OUString aFilterName(SdResId(STR_IMPRESS)); + pLinkManager->InsertFileLink(*mpPageLink, OBJECT_CLIENT_FILE, + maFileName, &aFilterName, &maBookmarkName); + mpPageLink->Connect(); } } diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx index eb8cdd709918..29e761897875 100644 --- a/sd/source/core/stlpool.cxx +++ b/sd/source/core/stlpool.cxx @@ -103,25 +103,24 @@ SdStyleSheetPool::SdStyleSheetPool(SfxItemPool const& _rPool, SdDrawDocument* pD , mpActualStyleSheet(nullptr) , mpDoc(pDocument) { - if( mpDoc ) - { - rtl::Reference< SfxStyleSheetPool > xPool( this ); + if( !mpDoc ) + return; - // create graphics family - mxGraphicFamily = new SdStyleFamily( xPool, SfxStyleFamily::Para ); - mxCellFamily = new SdStyleFamily( xPool, SfxStyleFamily::Frame ); + rtl::Reference< SfxStyleSheetPool > xPool( this ); - mxTableFamily = sdr::table::CreateTableDesignFamily(); - Reference< XNamed > xNamed( mxTableFamily, UNO_QUERY ); - if( xNamed.is() ) - msTableFamilyName = xNamed->getName(); + // create graphics family + mxGraphicFamily = new SdStyleFamily( xPool, SfxStyleFamily::Para ); + mxCellFamily = new SdStyleFamily( xPool, SfxStyleFamily::Frame ); - // create presentation families, one for each master page - const sal_uInt16 nCount = mpDoc->GetMasterSdPageCount(PageKind::Standard); - for( sal_uInt16 nPage = 0; nPage < nCount; ++nPage ) - AddStyleFamily( mpDoc->GetMasterSdPage(nPage,PageKind::Standard) ); + mxTableFamily = sdr::table::CreateTableDesignFamily(); + Reference< XNamed > xNamed( mxTableFamily, UNO_QUERY ); + if( xNamed.is() ) + msTableFamilyName = xNamed->getName(); - } + // create presentation families, one for each master page + const sal_uInt16 nCount = mpDoc->GetMasterSdPageCount(PageKind::Standard); + for( sal_uInt16 nPage = 0; nPage < nCount; ++nPage ) + AddStyleFamily( mpDoc->GetMasterSdPage(nPage,PageKind::Standard) ); } SdStyleSheetPool::~SdStyleSheetPool() @@ -529,54 +528,54 @@ void SdStyleSheetPool::CopyTableStyles(SdStyleSheetPool const & rSourcePool) Reference< XNameContainer > xTarget( mxTableFamily, UNO_QUERY ); Reference< XSingleServiceFactory > xFactory( mxTableFamily, UNO_QUERY ); - if( xSource.is() && xFactory.is() && mxTableFamily.is() ) + if( !(xSource.is() && xFactory.is() && mxTableFamily.is()) ) + return; + + for( sal_Int32 nIndex = 0; nIndex < xSource->getCount(); nIndex++ ) try { - for( sal_Int32 nIndex = 0; nIndex < xSource->getCount(); nIndex++ ) try + Reference< XStyle > xSourceTableStyle( xSource->getByIndex( nIndex ), UNO_QUERY ); + if( xSourceTableStyle.is() ) { - Reference< XStyle > xSourceTableStyle( xSource->getByIndex( nIndex ), UNO_QUERY ); - if( xSourceTableStyle.is() ) + Reference< XStyle > xNewTableStyle( xFactory->createInstance(), UNO_QUERY ); + if( xNewTableStyle.is() ) { - Reference< XStyle > xNewTableStyle( xFactory->createInstance(), UNO_QUERY ); - if( xNewTableStyle.is() ) - { - Reference< XNameAccess> xSourceNames( xSourceTableStyle, UNO_QUERY_THROW ); + Reference< XNameAccess> xSourceNames( xSourceTableStyle, UNO_QUERY_THROW ); - Sequence< OUString > aStyleNames( xSourceNames->getElementNames() ); - OUString* pStyleNames( aStyleNames.getArray() ); + Sequence< OUString > aStyleNames( xSourceNames->getElementNames() ); + OUString* pStyleNames( aStyleNames.getArray() ); - Reference< XNameReplace > xTargetNames( xNewTableStyle, UNO_QUERY ); + Reference< XNameReplace > xTargetNames( xNewTableStyle, UNO_QUERY ); - sal_Int32 nNames = aStyleNames.getLength(); - while( nNames-- ) + sal_Int32 nNames = aStyleNames.getLength(); + while( nNames-- ) + { + const OUString aName( *pStyleNames++ ); + Reference< XStyle > xSourceStyle( xSourceNames->getByName( aName ), UNO_QUERY ); + Reference< XStyle > xTargetStyle; + if( xSourceStyle.is() ) try { - const OUString aName( *pStyleNames++ ); - Reference< XStyle > xSourceStyle( xSourceNames->getByName( aName ), UNO_QUERY ); - Reference< XStyle > xTargetStyle; - if( xSourceStyle.is() ) try - { - mxCellFamily->getByName( xSourceStyle->getName() ) >>= xTargetStyle; - } - catch( Exception& ) - { - OSL_FAIL( "sd::SdStyleSheetPool::CopyTableStyles(), exception caught!" ); - } - - if( xTargetStyle.is() ) - xTargetNames->replaceByName( aName, Any( xTargetStyle ) ); + mxCellFamily->getByName( xSourceStyle->getName() ) >>= xTargetStyle; + } + catch( Exception& ) + { + OSL_FAIL( "sd::SdStyleSheetPool::CopyTableStyles(), exception caught!" ); } - } - OUString sName( xSourceTableStyle->getName() ); - if( xTarget->hasByName( sName ) ) - xTarget->replaceByName( sName, Any( xNewTableStyle ) ); - else - xTarget->insertByName( sName, Any( xNewTableStyle ) ); + if( xTargetStyle.is() ) + xTargetNames->replaceByName( aName, Any( xTargetStyle ) ); + } } + + OUString sName( xSourceTableStyle->getName() ); + if( xTarget->hasByName( sName ) ) + xTarget->replaceByName( sName, Any( xNewTableStyle ) ); + else + xTarget->insertByName( sName, Any( xNewTableStyle ) ); } - catch( Exception& ) - { - OSL_FAIL("sd::SdStyleSheetPool::CopyTableStyles(), exception caught!"); - } + } + catch( Exception& ) + { + OSL_FAIL("sd::SdStyleSheetPool::CopyTableStyles(), exception caught!"); } } @@ -753,26 +752,26 @@ void SdStyleSheetPool::CopyLayoutSheets(const OUString& rLayoutName, SdStyleShee std::vector<SfxStyleSheetBase*> aOutlineSheets; CreateOutlineSheetList(rLayoutName,aOutlineSheets); - if( !aOutlineSheets.empty() ) - { - std::vector<SfxStyleSheetBase*>::iterator it = aOutlineSheets.begin(); - SfxStyleSheetBase* pParent = *it; - ++it; + if( aOutlineSheets.empty() ) + return; - while (it != aOutlineSheets.end()) - { - pSheet = *it; + std::vector<SfxStyleSheetBase*>::iterator it = aOutlineSheets.begin(); + SfxStyleSheetBase* pParent = *it; + ++it; - if (!pSheet) - break; + while (it != aOutlineSheets.end()) + { + pSheet = *it; - if (pSheet->GetParent().isEmpty()) - pSheet->SetParent(pParent->GetName()); + if (!pSheet) + break; - pParent = pSheet; + if (pSheet->GetParent().isEmpty()) + pSheet->SetParent(pParent->GetName()); - ++it; - } + pParent = pSheet; + + ++it; } } @@ -1198,18 +1197,18 @@ void SdStyleSheetPool::AddStyleFamily( const SdPage* pPage ) void SdStyleSheetPool::RemoveStyleFamily( const SdPage* pPage ) { SdStyleFamilyMap::iterator iter( maStyleFamilyMap.find( pPage ) ); - if( iter != maStyleFamilyMap.end() ) - { - SdStyleFamilyRef xStyle( (*iter).second ); - maStyleFamilyMap.erase( iter ); + if( iter == maStyleFamilyMap.end() ) + return; - if( xStyle.is() ) try - { - xStyle->dispose(); - } - catch( Exception& ) - { - } + SdStyleFamilyRef xStyle( (*iter).second ); + maStyleFamilyMap.erase( iter ); + + if( xStyle.is() ) try + { + xStyle->dispose(); + } + catch( Exception& ) + { } } @@ -1347,33 +1346,33 @@ Any SAL_CALL SdStyleSheetPool::getByIndex( sal_Int32 Index ) void SAL_CALL SdStyleSheetPool::dispose() { - if( mpDoc ) - { - mxGraphicFamily->dispose(); - mxGraphicFamily.clear(); - mxCellFamily->dispose(); - mxCellFamily.clear(); - - Reference< XComponent > xComp( mxTableFamily, UNO_QUERY ); - if( xComp.is() ) - xComp->dispose(); - mxTableFamily = nullptr; + if( !mpDoc ) + return; - SdStyleFamilyMap aTempMap; - aTempMap.swap( maStyleFamilyMap ); + mxGraphicFamily->dispose(); + mxGraphicFamily.clear(); + mxCellFamily->dispose(); + mxCellFamily.clear(); - for( auto& rEntry : aTempMap ) try - { - rEntry.second->dispose(); - } - catch( Exception& ) - { - } + Reference< XComponent > xComp( mxTableFamily, UNO_QUERY ); + if( xComp.is() ) + xComp->dispose(); + mxTableFamily = nullptr; - mpDoc = nullptr; + SdStyleFamilyMap aTempMap; + aTempMap.swap( maStyleFamilyMap ); - Clear(); + for( auto& rEntry : aTempMap ) try + { + rEntry.second->dispose(); + } + catch( Exception& ) + { } + + mpDoc = nullptr; + + Clear(); } void SAL_CALL SdStyleSheetPool::addEventListener( const Reference< XEventListener >& /*xListener*/ ) diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx index 4ff39ddd3947..83aff4e2fb13 100644 --- a/sd/source/core/stlsheet.cxx +++ b/sd/source/core/stlsheet.cxx @@ -512,44 +512,44 @@ void SdStyleSheet::AdjustToFontHeight(SfxItemSet& rSet, bool bOnlyMissingItems) aStyleName = pRealStyle->GetName(); } - if (eFamily == SfxStyleFamily::Page && - aStyleName.indexOf(STR_LAYOUT_OUTLINE) != -1 && - rSet.GetItemState(EE_CHAR_FONTHEIGHT) == SfxItemState::SET) - { - const SfxItemSet* pCurSet = &GetItemSet(); - sal_uInt32 nNewHeight = rSet.Get(EE_CHAR_FONTHEIGHT).GetHeight(); - sal_uInt32 nOldHeight = pCurSet->Get(EE_CHAR_FONTHEIGHT).GetHeight(); + if (!(eFamily == SfxStyleFamily::Page && + aStyleName.indexOf(STR_LAYOUT_OUTLINE) != -1 && + rSet.GetItemState(EE_CHAR_FONTHEIGHT) == SfxItemState::SET)) + return; - if (rSet.GetItemState(EE_PARA_BULLET) != SfxItemState::SET || !bOnlyMissingItems) - { - const SvxBulletItem& rBItem = pCurSet->Get(EE_PARA_BULLET); - double fBulletFraction = double(rBItem.GetWidth()) / nOldHeight; - SvxBulletItem aNewBItem(rBItem); - aNewBItem.SetWidth(static_cast<sal_uInt32>(fBulletFraction * nNewHeight)); - rSet.Put(aNewBItem); - } + const SfxItemSet* pCurSet = &GetItemSet(); + sal_uInt32 nNewHeight = rSet.Get(EE_CHAR_FONTHEIGHT).GetHeight(); + sal_uInt32 nOldHeight = pCurSet->Get(EE_CHAR_FONTHEIGHT).GetHeight(); - if (rSet.GetItemState(EE_PARA_LRSPACE) != SfxItemState::SET || !bOnlyMissingItems) - { - const SvxLRSpaceItem& rLRItem = pCurSet->Get(EE_PARA_LRSPACE); - double fIndentFraction = double(rLRItem.GetTextLeft()) / nOldHeight; - SvxLRSpaceItem aNewLRItem(rLRItem); - aNewLRItem.SetTextLeft(fIndentFraction * nNewHeight); - double fFirstIndentFraction = double(rLRItem.GetTextFirstLineOfst()) / nOldHeight; - aNewLRItem.SetTextFirstLineOfst(static_cast<short>(fFirstIndentFraction * nNewHeight)); - rSet.Put(aNewLRItem); - } + if (rSet.GetItemState(EE_PARA_BULLET) != SfxItemState::SET || !bOnlyMissingItems) + { + const SvxBulletItem& rBItem = pCurSet->Get(EE_PARA_BULLET); + double fBulletFraction = double(rBItem.GetWidth()) / nOldHeight; + SvxBulletItem aNewBItem(rBItem); + aNewBItem.SetWidth(static_cast<sal_uInt32>(fBulletFraction * nNewHeight)); + rSet.Put(aNewBItem); + } - if (rSet.GetItemState(EE_PARA_ULSPACE) != SfxItemState::SET || !bOnlyMissingItems) - { - const SvxULSpaceItem& rULItem = pCurSet->Get(EE_PARA_ULSPACE); - SvxULSpaceItem aNewULItem(rULItem); - double fLowerFraction = double(rULItem.GetLower()) / nOldHeight; - aNewULItem.SetLower(static_cast<sal_uInt16>(fLowerFraction * nNewHeight)); - double fUpperFraction = double(rULItem.GetUpper()) / nOldHeight; - aNewULItem.SetUpper(static_cast<sal_uInt16>(fUpperFraction * nNewHeight)); - rSet.Put(aNewULItem); - } + if (rSet.GetItemState(EE_PARA_LRSPACE) != SfxItemState::SET || !bOnlyMissingItems) + { + const SvxLRSpaceItem& rLRItem = pCurSet->Get(EE_PARA_LRSPACE); + double fIndentFraction = double(rLRItem.GetTextLeft()) / nOldHeight; + SvxLRSpaceItem aNewLRItem(rLRItem); + aNewLRItem.SetTextLeft(fIndentFraction * nNewHeight); + double fFirstIndentFraction = double(rLRItem.GetTextFirstLineOfst()) / nOldHeight; + aNewLRItem.SetTextFirstLineOfst(static_cast<short>(fFirstIndentFraction * nNewHeight)); + rSet.Put(aNewLRItem); + } + + if (rSet.GetItemState(EE_PARA_ULSPACE) != SfxItemState::SET || !bOnlyMissingItems) + { + const SvxULSpaceItem& rULItem = pCurSet->Get(EE_PARA_ULSPACE); + SvxULSpaceItem aNewULItem(rULItem); + double fLowerFraction = double(rULItem.GetLower()) / nOldHeight; + aNewULItem.SetLower(static_cast<sal_uInt16>(fLowerFraction * nNewHeight)); + double fUpperFraction = double(rULItem.GetUpper()) / nOldHeight; + aNewULItem.SetUpper(static_cast<sal_uInt16>(fUpperFraction * nNewHeight)); + rSet.Put(aNewULItem); } } @@ -691,21 +691,21 @@ SdStyleSheet* SdStyleSheet::CreateEmptyUserStyle( SfxStyleSheetBasePool& rPool, void SAL_CALL SdStyleSheet::release( ) throw () { - if (osl_atomic_decrement( &m_refCount ) == 0) + if (osl_atomic_decrement( &m_refCount ) != 0) + return; + + // restore reference count: + osl_atomic_increment( &m_refCount ); + if (! mrBHelper.bDisposed) try { - // restore reference count: - osl_atomic_increment( &m_refCount ); - if (! mrBHelper.bDisposed) try - { - dispose(); - } - catch (RuntimeException const& exc) - { // don't break throw () - SAL_WARN( "sd", exc ); - } - OSL_ASSERT( mrBHelper.bDisposed ); - SdStyleSheetBase::release(); + dispose(); + } + catch (RuntimeException const& exc) + { // don't break throw () + SAL_WARN( "sd", exc ); } + OSL_ASSERT( mrBHelper.bDisposed ); + SdStyleSheetBase::release(); } // XComponent @@ -713,43 +713,43 @@ void SAL_CALL SdStyleSheet::release( ) throw () void SAL_CALL SdStyleSheet::dispose( ) { ClearableMutexGuard aGuard( mrBHelper.rMutex ); - if (!mrBHelper.bDisposed && !mrBHelper.bInDispose) + if (!(!mrBHelper.bDisposed && !mrBHelper.bInDispose)) + return; + + mrBHelper.bInDispose = true; + aGuard.clear(); + try { - mrBHelper.bInDispose = true; - aGuard.clear(); + // side effect: keeping a reference to this + EventObject aEvt( static_cast< OWeakObject * >( this ) ); try { - // side effect: keeping a reference to this - EventObject aEvt( static_cast< OWeakObject * >( this ) ); - try - { - mrBHelper.aLC.disposeAndClear( aEvt ); - disposing(); - } - catch (...) - { - MutexGuard aGuard2( mrBHelper.rMutex ); - // bDisposed and bInDispose must be set in this order: - mrBHelper.bDisposed = true; - mrBHelper.bInDispose = false; - throw; - } + mrBHelper.aLC.disposeAndClear( aEvt ); + disposing(); + } + catch (...) + { MutexGuard aGuard2( mrBHelper.rMutex ); // bDisposed and bInDispose must be set in this order: mrBHelper.bDisposed = true; mrBHelper.bInDispose = false; - } - catch (RuntimeException &) - { throw; } - catch (const Exception & exc) - { - css::uno::Any anyEx = cppu::getCaughtException(); - throw css::lang::WrappedTargetRuntimeException( - "unexpected UNO exception caught: " + exc.Message , - nullptr, anyEx ); - } + MutexGuard aGuard2( mrBHelper.rMutex ); + // bDisposed and bInDispose must be set in this order: + mrBHelper.bDisposed = true; + mrBHelper.bInDispose = false; + } + catch (RuntimeException &) + { + throw; + } + catch (const Exception & exc) + { + css::uno::Any anyEx = cppu::getCaughtException(); + throw css::lang::WrappedTargetRuntimeException( + "unexpected UNO exception caught: " + exc.Message , + nullptr, anyEx ); } } @@ -1321,21 +1321,21 @@ void SdStyleSheet::BroadcastSdStyleSheetChange(SfxStyleSheetBase const * pStyleS SdStyleSheet* pRealSheet = static_cast<SdStyleSheet const *>(pStyleSheet)->GetRealStyleSheet(); pRealSheet->Broadcast(SfxHint(SfxHintId::DataChanged)); - if( (ePO >= PO_OUTLINE_1) && (ePO <= PO_OUTLINE_8) ) - { - OUString sStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE) + " "); + if( !((ePO >= PO_OUTLINE_1) && (ePO <= PO_OUTLINE_8)) ) + return; - for( sal_uInt16 n = static_cast<sal_uInt16>(ePO - PO_OUTLINE_1 + 2); n < 10; n++ ) - { - OUString aName( sStyleName + OUString::number(n) ); + OUString sStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE) + " "); - SfxStyleSheetBase* pSheet = pSSPool->Find( aName, SfxStyleFamily::Pseudo); + for( sal_uInt16 n = static_cast<sal_uInt16>(ePO - PO_OUTLINE_1 + 2); n < 10; n++ ) + { + OUString aName( sStyleName + OUString::number(n) ); - if(pSheet) - { - SdStyleSheet* pRealStyleSheet = static_cast<SdStyleSheet*>(pSheet)->GetRealStyleSheet(); - pRealStyleSheet->Broadcast(SfxHint(SfxHintId::DataChanged)); - } + SfxStyleSheetBase* pSheet = pSSPool->Find( aName, SfxStyleFamily::Pseudo); + + if(pSheet) + { + SdStyleSheet* pRealStyleSheet = static_cast<SdStyleSheet*>(pSheet)->GetRealStyleSheet(); + pRealStyleSheet->Broadcast(SfxHint(SfxHintId::DataChanged)); } } } diff --git a/sd/source/core/undo/undoobjects.cxx b/sd/source/core/undo/undoobjects.cxx index b497f1a06d71..4437e4005cb6 100644 --- a/sd/source/core/undo/undoobjects.cxx +++ b/sd/source/core/undo/undoobjects.cxx @@ -46,23 +46,23 @@ ViewShellId SdUndoAction::GetViewShellId() const UndoRemovePresObjectImpl::UndoRemovePresObjectImpl( SdrObject& rObject ) { SdPage* pPage = dynamic_cast< SdPage* >( rObject.getSdrPageFromSdrObject() ); - if( pPage ) - { - if( pPage->IsPresObj(&rObject) ) - mpUndoPresObj.reset( new UndoObjectPresentationKind( rObject ) ); - if( rObject.GetUserCall() ) - mpUndoUsercall.reset( new UndoObjectUserCall(rObject) ); + if( !pPage ) + return; + + if( pPage->IsPresObj(&rObject) ) + mpUndoPresObj.reset( new UndoObjectPresentationKind( rObject ) ); + if( rObject.GetUserCall() ) + mpUndoUsercall.reset( new UndoObjectUserCall(rObject) ); - if( pPage->hasAnimationNode() ) + if( pPage->hasAnimationNode() ) + { + css::uno::Reference< css::drawing::XShape > xShape( rObject.getUnoShape(), css::uno::UNO_QUERY ); + if( pPage->getMainSequence()->hasEffect( xShape ) ) { - css::uno::Reference< css::drawing::XShape > xShape( rObject.getUnoShape(), css::uno::UNO_QUERY ); - if( pPage->getMainSequence()->hasEffect( xShape ) ) - { - mpUndoAnimation.reset( - new UndoAnimation( // TTTT may use ref? Or just *SdrPage? - static_cast< SdDrawDocument* >(&pPage->getSdrModelFromSdrPage()), - pPage)); - } + mpUndoAnimation.reset( + new UndoAnimation( // TTTT may use ref? Or just *SdrPage? + static_cast< SdDrawDocument* >(&pPage->getSdrModelFromSdrPage()), + pPage)); } } } diff --git a/sd/source/core/undoanim.cxx b/sd/source/core/undoanim.cxx index 9aed51aa89ad..e74ffe48711b 100644 --- a/sd/source/core/undoanim.cxx +++ b/sd/source/core/undoanim.cxx @@ -120,17 +120,17 @@ struct UndoAnimationPathImpl : mpPage( pThePage ) , mnEffectOffset( -1 ) { - if( mpPage && xNode.is() ) + if( !(mpPage && xNode.is()) ) + return; + + std::shared_ptr< sd::MainSequence > pMainSequence( mpPage->getMainSequence() ); + if( pMainSequence.get() ) { - std::shared_ptr< sd::MainSequence > pMainSequence( mpPage->getMainSequence() ); - if( pMainSequence.get() ) + CustomAnimationEffectPtr pEffect( pMainSequence->findEffect( xNode ) ); + if( pEffect.get() ) { - CustomAnimationEffectPtr pEffect( pMainSequence->findEffect( xNode ) ); - if( pEffect.get() ) - { - mnEffectOffset = pMainSequence->getOffsetFromEffect( pEffect ); - msUndoPath = pEffect->getPath(); - } + mnEffectOffset = pMainSequence->getOffsetFromEffect( pEffect ); + msUndoPath = pEffect->getPath(); } } } |