Kaydet (Commit) 3cc52de5 authored tarafından Caolán McNamara's avatar Caolán McNamara

return early on no-op cases, no logic change

Change-Id: I7041ac2268d1df8b37e380ccde926d5aec06510e
üst 876e63e6
...@@ -210,100 +210,100 @@ void SwColExample::DrawPage(vcl::RenderContext& rRenderContext, const Point& rOr ...@@ -210,100 +210,100 @@ void SwColExample::DrawPage(vcl::RenderContext& rRenderContext, const Point& rOr
const bool bSecond, const bool bEnabled) const bool bSecond, const bool bEnabled)
{ {
SwPageExample::DrawPage(rRenderContext, rOrg, bSecond, bEnabled); SwPageExample::DrawPage(rRenderContext, rOrg, bSecond, bEnabled);
sal_uInt16 nColumnCount; if (!pColMgr)
if (pColMgr && 0 != (nColumnCount = pColMgr->GetCount())) return;
sal_uInt16 nColumnCount = pColMgr->GetCount();
if (!nColumnCount)
return;
long nL = GetLeft();
long nR = GetRight();
if (GetUsage() == SVX_PAGE_MIRROR && !bSecond)
{ {
long nL = GetLeft(); // swap for mirrored
long nR = GetRight(); nL = GetRight();
nR = GetLeft();
}
if (GetUsage() == SVX_PAGE_MIRROR && !bSecond) rRenderContext.SetFillColor(Color(COL_LIGHTGRAY));
{ Rectangle aRect;
// rotate for mirrored aRect.Right() = rOrg.X() + GetSize().Width() - nR;
nL = GetRight(); aRect.Left() = rOrg.X() + nL;
nR = GetLeft(); aRect.Top() = rOrg.Y() + GetTop() + GetHdHeight() + GetHdDist();
} aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom() - GetFtHeight() - GetFtDist();
rRenderContext.DrawRect(aRect);
rRenderContext.SetFillColor(Color(COL_LIGHTGRAY)); //UUUU
Rectangle aRect; const Rectangle aDefineRect(aRect);
aRect.Right() = rOrg.X() + GetSize().Width() - nR;
aRect.Left() = rOrg.X() + nL;
aRect.Top() = rOrg.Y() + GetTop() + GetHdHeight() + GetHdDist();
aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom() - GetFtHeight() - GetFtDist();
rRenderContext.DrawRect(aRect);
//UUUU //UUUU
const Rectangle aDefineRect(aRect); const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes = getPageFillAttributes();
//UUUU if (!rFillAttributes.get() || !rFillAttributes->isUsed())
const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes = getPageFillAttributes(); {
//UUUU If there is no fill, use fallback color
const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
const Color& rFieldColor = rStyleSettings.GetFieldColor();
if (!rFillAttributes.get() || !rFillAttributes->isUsed()) setPageFillAttributes(
{ drawinglayer::attribute::SdrAllFillAttributesHelperPtr(
//UUUU If there is no fill, use fallback color new drawinglayer::attribute::SdrAllFillAttributesHelper(rFieldColor)));
const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); }
const Color& rFieldColor = rStyleSettings.GetFieldColor();
setPageFillAttributes( // #97495# make sure that the automatic column width's are always equal
drawinglayer::attribute::SdrAllFillAttributesHelperPtr( bool bAutoWidth = pColMgr->IsAutoWidth();
new drawinglayer::attribute::SdrAllFillAttributesHelper(rFieldColor))); sal_Int32 nAutoColWidth = 0;
} if (bAutoWidth)
{
sal_Int32 nColumnWidthSum = 0;
for (sal_uInt16 i = 0; i < nColumnCount; ++i)
nColumnWidthSum += pColMgr->GetColWidth( i );
nAutoColWidth = nColumnWidthSum / nColumnCount;
}
// #97495# make sure that the automatic column width's are always equal for (sal_uInt16 i = 0; i < nColumnCount; ++i)
bool bAutoWidth = pColMgr->IsAutoWidth(); {
sal_Int32 nAutoColWidth = 0; if (!bAutoWidth)
if (bAutoWidth) nAutoColWidth = pColMgr->GetColWidth(i);
{ aRect.Right() = aRect.Left() + nAutoColWidth;
sal_Int32 nColumnWidthSum = 0;
sal_uInt16 i;
for (i = 0; i < nColumnCount; ++i)
nColumnWidthSum += pColMgr->GetColWidth( i );
nAutoColWidth = nColumnWidthSum / nColumnCount;
}
sal_uInt16 i; //UUUU use primitive draw command
for (i = 0; i < nColumnCount; i++) drawFillAttributes(rRenderContext, getPageFillAttributes(), aRect, aDefineRect);
{
if (!bAutoWidth)
nAutoColWidth = pColMgr->GetColWidth(i);
aRect.Right() = aRect.Left() + nAutoColWidth;
//UUUU use primitive draw command if (i < nColumnCount - 1)
drawFillAttributes(rRenderContext, getPageFillAttributes(), aRect, aDefineRect); aRect.Left() = aRect.Right() + pColMgr->GetGutterWidth(i);
}
if (pColMgr->HasLine())
{
Point aUp(rOrg.X() + nL, rOrg.Y() + GetTop());
Point aDown(rOrg.X() + nL,
rOrg.Y() + GetSize().Height() - GetBottom() - GetFtHeight() - GetFtDist());
if (i < nColumnCount - 1) if (pColMgr->GetLineHeightPercent() != 100)
aRect.Left() = aRect.Right() + pColMgr->GetGutterWidth(i);
}
if (pColMgr->HasLine())
{ {
Point aUp(rOrg.X() + nL, rOrg.Y() + GetTop()); long nLength = aDown.Y() - aUp.Y();
Point aDown(rOrg.X() + nL, nLength -= nLength * pColMgr->GetLineHeightPercent() / 100;
rOrg.Y() + GetSize().Height() - GetBottom() - GetFtHeight() - GetFtDist()); switch (pColMgr->GetAdjust())
if (pColMgr->GetLineHeightPercent() != 100)
{ {
long nLength = aDown.Y() - aUp.Y(); case COLADJ_BOTTOM: aUp.Y() += nLength; break;
nLength -= nLength * pColMgr->GetLineHeightPercent() / 100; case COLADJ_TOP: aDown.Y() -= nLength; break;
switch (pColMgr->GetAdjust()) case COLADJ_CENTER:
{ aUp.Y() += nLength / 2;
case COLADJ_BOTTOM: aUp.Y() += nLength; break; aDown.Y() -= nLength / 2;
case COLADJ_TOP: aDown.Y() -= nLength; break; break;
case COLADJ_CENTER: default:; // prevent warning
aUp.Y() += nLength / 2;
aDown.Y() -= nLength / 2;
break;
default:; // prevent warning
}
} }
}
for (i = 0; i < nColumnCount - 1; i++) for (sal_uInt16 i = 0; i < nColumnCount - 1; ++i)
{ {
int nGutter = pColMgr->GetGutterWidth(i); int nGutter = pColMgr->GetGutterWidth(i);
int nDist = pColMgr->GetColWidth( i ) + nGutter; int nDist = pColMgr->GetColWidth( i ) + nGutter;
nDist -= (i == 0) ? nGutter / 2 : 0; nDist -= (i == 0) ? nGutter / 2 : 0;
aUp.X() += nDist; aUp.X() += nDist;
aDown.X() += nDist; aDown.X() += nDist;
rRenderContext.DrawLine(aUp, aDown); rRenderContext.DrawLine(aUp, aDown);
}
} }
} }
} }
......
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