summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2016-12-02 11:11:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-12-02 11:17:12 +0000
commit4d2c210c74567d9af6bededf3fae6bfd62406f14 (patch)
treec51cfed1eac6dd425940d0cdc62135d51a0b9a08 /svx
parent8a238809ba861c810304354f01a5504d43111399 (diff)
use early return to simplify flow
Change-Id: I98201eac2e038c152422bbc6380cfa321ba266df Reviewed-on: https://gerrit.libreoffice.org/31534 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdedxv.cxx117
1 files changed, 60 insertions, 57 deletions
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index c152b8c48a41..de95bc54a296 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: */