Kaydet (Commit) 4d2c210c authored tarafından Noel Grandin's avatar Noel Grandin

use early return to simplify flow

Change-Id: I98201eac2e038c152422bbc6380cfa321ba266df
Reviewed-on: https://gerrit.libreoffice.org/31534Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 8a238809
......@@ -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 );
......
......@@ -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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment