summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2014-03-28 00:08:59 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2014-03-30 16:37:45 +0200
commit91825d5c2df7fffbc97f7664812983570b9ba8e7 (patch)
tree91ab3b43315dc820e1052eb35469f07e0e4552e8
parentf07dc0e439235b2c6033d79cdebffa3dcf9b33fe (diff)
Rework SwFrmPage::GetAlignment
* Early bail-out * Remove temporaries * Some constification * Don't check the same pointer twice Change-Id: I10e19f8807872e16b6d1419f6a345b6343b17c94
-rw-r--r--sw/source/ui/frmdlg/frmpage.cxx46
1 files changed, 18 insertions, 28 deletions
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 4fbc0e206ef1..3832a3259d94 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -1614,44 +1614,34 @@ short SwFrmPage::GetRelation(FrmMap * /*pMap*/, ListBox &rRelationLB)
short SwFrmPage::GetAlignment(FrmMap *pMap, sal_Int32 nMapPos,
ListBox &/*rAlignLB*/, ListBox &rRelationLB)
{
- short nAlign = 0;
-
if (!pMap || nMapPos < 0)
- return nAlign;
+ return 0;
- size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
+ const size_t nMapCount = ::lcl_GetFrmMapCount(pMap);
if (static_cast<size_t>(nMapPos) >= nMapCount)
- return nAlign;
+ return 0;
// i#22341 special handling also for map <aVCharMap>,
// because it contains ambigous items for alignment
- if ( pMap == aVAsCharHtmlMap || pMap == aVAsCharMap ||
- pMap == aVCharMap )
- {
- if (rRelationLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND)
- {
- sal_uLong nRel = ((RelationMap *)rRelationLB.GetEntryData(rRelationLB.GetSelectEntryPos()))->nLBRelation;
- SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
+ if ( pMap != aVAsCharHtmlMap && pMap != aVAsCharMap && pMap != aVCharMap )
+ return pMap[nMapPos].nAlign;
- for (size_t i = 0; i < nMapCount; i++)
- {
- if (pMap[i].eStrId == eStrId)
- {
- sal_uLong nLBRelations = pMap[i].nLBRelations;
- if (nLBRelations & nRel)
- {
- nAlign = pMap[i].nAlign;
- break;
- }
- }
- }
- }
+ if (rRelationLB.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND)
+ return 0;
+
+ const RelationMap *const pRelationMap = (const RelationMap *const )
+ rRelationLB.GetEntryData(rRelationLB.GetSelectEntryPos());
+ const sal_uLong nRel = pRelationMap->nLBRelation;
+ const SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId;
+
+ for (size_t i = 0; i < nMapCount; ++i)
+ {
+ if (pMap[i].eStrId == eStrId && (pMap[i].nLBRelations & nRel))
+ return pMap[i].nAlign;
}
- else if (pMap)
- nAlign = pMap[nMapPos].nAlign;
- return nAlign;
+ return 0;
}
sal_Int32 SwFrmPage::GetMapPos( const FrmMap *pMap, ListBox &rAlignLB )