diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2014-09-01 23:36:14 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2014-09-06 12:12:30 +0200 |
commit | a219bbb62f974020fac0799143fbc51c385bb460 (patch) | |
tree | eef71ae06e796f20021e49381e05308c4a4738b8 /sw/source | |
parent | 6f9f11d4a3d5eb489b4c112f2c41af91136adc89 (diff) |
Simplify by early bailout
Change-Id: I9815ced0495f3066f8b6477794f33bbd77c613ca
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/text/itratr.cxx | 173 |
1 files changed, 82 insertions, 91 deletions
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index 378004d4766a..3c4451c162a6 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -421,125 +421,116 @@ static void lcl_MinMaxNode( SwFrmFmt* pNd, SwMinMaxNodeArgs* pIn ) { const SwFmtAnchor& rFmtA = pNd->GetAnchor(); - bool bCalculate = false; if ((FLY_AT_PARA == rFmtA.GetAnchorId()) || (FLY_AT_CHAR == rFmtA.GetAnchorId())) { - bCalculate = true; - } - - if (bCalculate) - { const SwPosition *pPos = rFmtA.GetCntntAnchor(); OSL_ENSURE(pPos && pIn, "Unexpected NULL arguments"); if (!pPos || !pIn || pIn->nIndx != pPos->nNode.GetIndex()) - bCalculate = false; + return; } - if (bCalculate) + long nMin, nMax; + SwHTMLTableLayout *pLayout = 0; + const bool bIsDrawFrmFmt = pNd->Which()==RES_DRAWFRMFMT; + if( !bIsDrawFrmFmt ) { - long nMin, nMax; - SwHTMLTableLayout *pLayout = 0; - const bool bIsDrawFrmFmt = pNd->Which()==RES_DRAWFRMFMT; - if( !bIsDrawFrmFmt ) + // Does the frame contain a table at the start or the end? + const SwNodes& rNodes = pNd->GetDoc()->GetNodes(); + const SwFmtCntnt& rFlyCntnt = pNd->GetCntnt(); + sal_uLong nStt = rFlyCntnt.GetCntntIdx()->GetIndex(); + SwTableNode* pTblNd = rNodes[nStt+1]->GetTableNode(); + if( !pTblNd ) { - // Does the frame contain a table at the start or the end? - const SwNodes& rNodes = pNd->GetDoc()->GetNodes(); - const SwFmtCntnt& rFlyCntnt = pNd->GetCntnt(); - sal_uLong nStt = rFlyCntnt.GetCntntIdx()->GetIndex(); - SwTableNode* pTblNd = rNodes[nStt+1]->GetTableNode(); - if( !pTblNd ) - { - SwNode *pNd2 = rNodes[nStt]; - pNd2 = rNodes[pNd2->EndOfSectionIndex()-1]; - if( pNd2->IsEndNode() ) - pTblNd = pNd2->StartOfSectionNode()->GetTableNode(); - } - - if( pTblNd ) - pLayout = pTblNd->GetTable().GetHTMLTableLayout(); + SwNode *pNd2 = rNodes[nStt]; + pNd2 = rNodes[pNd2->EndOfSectionIndex()-1]; + if( pNd2->IsEndNode() ) + pTblNd = pNd2->StartOfSectionNode()->GetTableNode(); } - const SwFmtHoriOrient& rOrient = pNd->GetHoriOrient(); - sal_Int16 eHoriOri = rOrient.GetHoriOrient(); + if( pTblNd ) + pLayout = pTblNd->GetTable().GetHTMLTableLayout(); + } + + const SwFmtHoriOrient& rOrient = pNd->GetHoriOrient(); + sal_Int16 eHoriOri = rOrient.GetHoriOrient(); - long nDiff; - if( pLayout ) + long nDiff; + if( pLayout ) + { + nMin = pLayout->GetMin(); + nMax = pLayout->GetMax(); + nDiff = nMax - nMin; + } + else + { + if( bIsDrawFrmFmt ) { - nMin = pLayout->GetMin(); - nMax = pLayout->GetMax(); - nDiff = nMax - nMin; + const SdrObject* pSObj = pNd->FindSdrObject(); + if( pSObj ) + nMin = pSObj->GetCurrentBoundRect().GetWidth(); + else + nMin = 0; + } else { - if( bIsDrawFrmFmt ) - { - const SdrObject* pSObj = pNd->FindSdrObject(); - if( pSObj ) - nMin = pSObj->GetCurrentBoundRect().GetWidth(); - else - nMin = 0; - - } - else - { - const SwFmtFrmSize &rSz = pNd->GetFrmSize(); - nMin = rSz.GetWidth(); - } - nMax = nMin; - nDiff = 0; + const SwFmtFrmSize &rSz = pNd->GetFrmSize(); + nMin = rSz.GetWidth(); } + nMax = nMin; + nDiff = 0; + } - const SvxLRSpaceItem &rLR = pNd->GetLRSpace(); - nMin += rLR.GetLeft(); - nMin += rLR.GetRight(); - nMax += rLR.GetLeft(); - nMax += rLR.GetRight(); + const SvxLRSpaceItem &rLR = pNd->GetLRSpace(); + nMin += rLR.GetLeft(); + nMin += rLR.GetRight(); + nMax += rLR.GetLeft(); + nMax += rLR.GetRight(); - if( SURROUND_THROUGHT == pNd->GetSurround().GetSurround() ) - { - pIn->Minimum( nMin ); - return; - } + if( SURROUND_THROUGHT == pNd->GetSurround().GetSurround() ) + { + pIn->Minimum( nMin ); + return; + } - // Frames, which are left- or right-aligned are only party considered - // when calculating the maximum, since the border is already being considered. - // Only if the frame extends into the text body, this part is being added - switch( eHoriOri ) + // Frames, which are left- or right-aligned are only party considered + // when calculating the maximum, since the border is already being considered. + // Only if the frame extends into the text body, this part is being added + switch( eHoriOri ) + { + case text::HoriOrientation::RIGHT: { - case text::HoriOrientation::RIGHT: + if( nDiff ) { - if( nDiff ) - { - pIn->nRightRest -= pIn->nRightDiff; - pIn->nRightDiff = nDiff; - } - if( text::RelOrientation::FRAME != rOrient.GetRelationOrient() ) - { - if( pIn->nRightRest > 0 ) - pIn->nRightRest = 0; - } - pIn->nRightRest -= nMin; - break; + pIn->nRightRest -= pIn->nRightDiff; + pIn->nRightDiff = nDiff; } - case text::HoriOrientation::LEFT: + if( text::RelOrientation::FRAME != rOrient.GetRelationOrient() ) { - if( nDiff ) - { - pIn->nLeftRest -= pIn->nLeftDiff; - pIn->nLeftDiff = nDiff; - } - if( text::RelOrientation::FRAME != rOrient.GetRelationOrient() && - pIn->nLeftRest < 0 ) - pIn->nLeftRest = 0; - pIn->nLeftRest -= nMin; - break; + if( pIn->nRightRest > 0 ) + pIn->nRightRest = 0; } - default: + pIn->nRightRest -= nMin; + break; + } + case text::HoriOrientation::LEFT: + { + if( nDiff ) { - pIn->nMaxWidth += nMax; - pIn->Minimum( nMin ); + pIn->nLeftRest -= pIn->nLeftDiff; + pIn->nLeftDiff = nDiff; } + if( text::RelOrientation::FRAME != rOrient.GetRelationOrient() && + pIn->nLeftRest < 0 ) + pIn->nLeftRest = 0; + pIn->nLeftRest -= nMin; + break; + } + default: + { + pIn->nMaxWidth += nMax; + pIn->Minimum( nMin ); } } } |