[Libreoffice-commits] core.git: basic/source svx/source

Noel Grandin noel.grandin at collabora.co.uk
Fri Dec 2 11:17:37 UTC 2016


 basic/source/comp/exprtree.cxx |   10 +--
 svx/source/svdraw/svdedxv.cxx  |  117 +++++++++++++++++++++--------------------
 2 files changed, 65 insertions(+), 62 deletions(-)

New commits:
commit 4d2c210c74567d9af6bededf3fae6bfd62406f14
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Dec 2 11:11:44 2016 +0200

    use early return to simplify flow
    
    Change-Id: I98201eac2e038c152422bbc6380cfa321ba266df
    Reviewed-on: https://gerrit.libreoffice.org/31534
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index 008976f..fa8e9d1 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -1055,11 +1055,11 @@ SbiExprListPtr SbiExprList::ParseParameters( SbiParser* pParser, bool bStandalon
         {
             if( ( pExprList->bBracket && eTok == RPAREN ) || SbiTokenizer::IsEoln( eTok ) )
             {
-                if ( SbiTokenizer::IsEoln( eTok ) && pExprList->bBracket)
-                {
-                    pParser->Error( ERRCODE_BASIC_EXPECTED, RPAREN );
-                    pExprList->bError = true;
-                }
+//                if ( SbiTokenizer::IsEoln( eTok ) && pExprList->bBracket)
+//                {
+//                    pParser->Error( ERRCODE_BASIC_EXPECTED, RPAREN );
+//                    pExprList->bError = true;
+//                }
                 break;
             }
             pParser->Error( pExprList->bBracket ? ERRCODE_BASIC_BAD_BRACKETS : ERRCODE_BASIC_EXPECTED, COMMA );
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index c152b8c..de95bc5 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2293,77 +2293,80 @@ void SdrObjEditView::ApplyFormatPaintBrushToText( SfxItemSet& rFormatSet, SdrTex
 
 void SdrObjEditView::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats )
 {
-    if( !mxSelectionController.is() || !mxSelectionController->ApplyFormatPaintBrush( rFormatSet, bNoCharacterFormats, bNoParagraphFormats ) )
+    if( mxSelectionController.is() &&
+        mxSelectionController->ApplyFormatPaintBrush( rFormatSet, bNoCharacterFormats, bNoParagraphFormats ) )
     {
-        OutlinerView* pOLV = GetTextEditOutlinerView();
-        if( !pOLV )
-        {
-            const SdrMarkList& rMarkList = GetMarkedObjectList();
-            SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
-            const SfxItemSet& rShapeSet = pObj->GetMergedItemSet();
+        return;
+    }
 
-            // if not in text edit mode (aka the user selected text or clicked on a word)
-            // apply formatting attributes to selected shape
-            // All formatting items (see ranges above) that are unequal in selected shape and
-            // the format paintbrush are hard set on the selected shape.
+    OutlinerView* pOLV = GetTextEditOutlinerView();
+    if( !pOLV )
+    {
+        const SdrMarkList& rMarkList = GetMarkedObjectList();
+        SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+        const SfxItemSet& rShapeSet = pObj->GetMergedItemSet();
 
-            const sal_uInt16* pRanges = rFormatSet.GetRanges();
-            bool bTextOnly = true;
+        // if not in text edit mode (aka the user selected text or clicked on a word)
+        // apply formatting attributes to selected shape
+        // All formatting items (see ranges above) that are unequal in selected shape and
+        // the format paintbrush are hard set on the selected shape.
 
-            while( *pRanges )
-            {
-                if( (*pRanges != EE_PARA_START) && (*pRanges != EE_CHAR_START) )
-                {
-                    bTextOnly = false;
-                    break;
-                }
-                pRanges += 2;
-            }
+        const sal_uInt16* pRanges = rFormatSet.GetRanges();
+        bool bTextOnly = true;
 
-            if( !bTextOnly )
+        while( *pRanges )
+        {
+            if( (*pRanges != EE_PARA_START) && (*pRanges != EE_CHAR_START) )
             {
-                SfxItemSet aPaintSet( CreatePaintSet(
-                                        GetFormatRangeImpl(false), *rShapeSet.GetPool(),
-                                        rFormatSet, rShapeSet,
-                                        bNoCharacterFormats, bNoParagraphFormats ) );
-                SetAttrToMarked(aPaintSet, false/*bReplaceAll*/);
+                bTextOnly = false;
+                break;
             }
+            pRanges += 2;
+        }
 
-            // now apply character and paragraph formatting to text, if the shape has any
-            SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj);
-            if( pTextObj )
-            {
-                sal_Int32 nText = pTextObj->getTextCount();
-
-                while( --nText >= 0 )
-                {
-                    SdrText* pText = pTextObj->getText( nText );
-                    ApplyFormatPaintBrushToText( rFormatSet, *pTextObj, pText, bNoCharacterFormats, bNoParagraphFormats );
-                }
-            }
+        if( !bTextOnly )
+        {
+            SfxItemSet aPaintSet( CreatePaintSet(
+                                    GetFormatRangeImpl(false), *rShapeSet.GetPool(),
+                                    rFormatSet, rShapeSet,
+                                    bNoCharacterFormats, bNoParagraphFormats ) );
+            SetAttrToMarked(aPaintSet, false/*bReplaceAll*/);
         }
-        else
+
+        // now apply character and paragraph formatting to text, if the shape has any
+        SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj);
+        if( pTextObj )
         {
-            ::Outliner* pOutliner = pOLV->GetOutliner();
-            if( pOutliner )
+            sal_Int32 nText = pTextObj->getTextCount();
+
+            while( --nText >= 0 )
             {
-                const EditEngine& rEditEngine = pOutliner->GetEditEngine();
-
-                ESelection aSel( pOLV->GetSelection() );
-                if( !aSel.HasRange() )
-                    pOLV->SetSelection( rEditEngine.GetWord( aSel, css::i18n::WordType::DICTIONARY_WORD ) );
-
-                const bool bRemoveParaAttribs = !bNoParagraphFormats;
-                pOLV->RemoveAttribsKeepLanguages( bRemoveParaAttribs );
-                SfxItemSet aSet( pOLV->GetAttribs() );
-                SfxItemSet aPaintSet( CreatePaintSet(
-                                        GetFormatRangeImpl(true), *aSet.GetPool(),
-                                        rFormatSet, aSet,
-                                        bNoCharacterFormats, bNoParagraphFormats ) );
-                pOLV->SetAttribs( aPaintSet );
+                SdrText* pText = pTextObj->getText( nText );
+                ApplyFormatPaintBrushToText( rFormatSet, *pTextObj, pText, bNoCharacterFormats, bNoParagraphFormats );
             }
         }
     }
+    else
+    {
+        ::Outliner* pOutliner = pOLV->GetOutliner();
+        if( pOutliner )
+        {
+            const EditEngine& rEditEngine = pOutliner->GetEditEngine();
+
+            ESelection aSel( pOLV->GetSelection() );
+            if( !aSel.HasRange() )
+                pOLV->SetSelection( rEditEngine.GetWord( aSel, css::i18n::WordType::DICTIONARY_WORD ) );
+
+            const bool bRemoveParaAttribs = !bNoParagraphFormats;
+            pOLV->RemoveAttribsKeepLanguages( bRemoveParaAttribs );
+            SfxItemSet aSet( pOLV->GetAttribs() );
+            SfxItemSet aPaintSet( CreatePaintSet(
+                                    GetFormatRangeImpl(true), *aSet.GetPool(),
+                                    rFormatSet, aSet,
+                                    bNoCharacterFormats, bNoParagraphFormats ) );
+            pOLV->SetAttribs( aPaintSet );
+        }
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list