[Libreoffice-commits] core.git: 2 commits - sd/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Feb 15 12:48:45 UTC 2019


 sd/source/core/CustomAnimationEffect.cxx       |  256 ++--
 sd/source/core/EffectMigration.cxx             |  492 ++++----
 sd/source/core/annotations/Annotation.cxx      |   46 
 sd/source/core/drawdoc.cxx                     |  122 +-
 sd/source/core/drawdoc2.cxx                    |  448 +++----
 sd/source/core/drawdoc4.cxx                    |  174 +--
 sd/source/core/sdpage.cxx                      |  840 +++++++-------
 sd/source/core/sdpage2.cxx                     |   64 -
 sd/source/core/stlpool.cxx                     |  199 +--
 sd/source/core/stlsheet.cxx                    |  176 +--
 sd/source/core/undo/undoobjects.cxx            |   30 
 sd/source/core/undoanim.cxx                    |   18 
 sd/source/filter/eppt/eppt.cxx                 |  246 ++--
 sd/source/filter/eppt/epptso.cxx               |  607 +++++-----
 sd/source/filter/eppt/escherex.cxx             |   54 
 sd/source/filter/eppt/pptexanimations.cxx      |  728 ++++++------
 sd/source/filter/eppt/pptexsoundcollection.cxx |   26 
 sd/source/filter/eppt/pptx-animations.cxx      |  201 +--
 sd/source/filter/eppt/pptx-stylesheet.cxx      |   50 
 sd/source/filter/eppt/pptx-text.cxx            |  240 ++--
 sd/source/filter/html/buttonset.cxx            |   20 
 sd/source/filter/html/htmlex.cxx               |   22 
 sd/source/filter/html/pubdlg.cxx               |   64 -
 sd/source/filter/ppt/pptin.cxx                 |  180 +--
 sd/source/filter/ppt/pptinanimations.cxx       | 1442 ++++++++++++-------------
 sd/source/filter/ppt/propread.cxx              |   56 
 sd/source/filter/xml/sdtransform.cxx           |  104 -
 27 files changed, 3469 insertions(+), 3436 deletions(-)

New commits:
commit e2d2a3386fe85b0fa11fd26c3f7ca4c651eb2818
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Feb 14 09:13:24 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Feb 15 13:48:25 2019 +0100

    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 at collabora.co.uk>

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;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list