summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-10-07 11:13:20 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-10-07 11:32:45 +0200
commit243fbdf426bcca9ff13053ee179bfe3cc44eb2c6 (patch)
tree9f64ea855b78ff695d2061f0a880214ea18cb984 /svtools
parenta868478b2e7a7b74a2fa19b1dfedfa0eb6fe68d8 (diff)
Abstract out repeated code into a lambda
...to silence a clang-analyzer-deadcode.DeadStores on the last update of nX Change-Id: Ifeb2e5294b22270ba134a303fbe5aa1d50025c75
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/tabbar.cxx49
1 files changed, 17 insertions, 32 deletions
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index a7f9fc570f44..b10f5d7afe63 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -1318,52 +1318,37 @@ void TabBar::Resize()
}
// order the scroll buttons
- long nHeight = aNewSize.Height();
+ long const nHeight = aNewSize.Height();
// adapt font height?
ImplInitSettings( true, false );
long nButtonMargin = BUTTON_MARGIN * GetDPIScaleFactor();
long nX = mbMirrored ? (aNewSize.Width() - nHeight - nButtonMargin) : nButtonMargin;
- long nXDiff = mbMirrored ? -nHeight : nHeight;
+ long const nXDiff = mbMirrored ? -nHeight : nHeight;
nButtonWidth += nButtonMargin;
- Size aBtnSize( nHeight, nHeight );
- if (mpImpl->mpFirstButton)
- {
- mpImpl->mpFirstButton->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
- nX += nXDiff;
- nButtonWidth += nHeight;
- }
- if (mpImpl->mpPrevButton)
- {
- mpImpl->mpPrevButton->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
- nX += nXDiff;
- nButtonWidth += nHeight;
- }
- if (mpImpl->mpNextButton)
- {
- mpImpl->mpNextButton->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
- nX += nXDiff;
- nButtonWidth += nHeight;
- }
- if (mpImpl->mpLastButton)
+ Size const aBtnSize( nHeight, nHeight );
+ auto setButton = [aBtnSize, nXDiff, nHeight, &nX, &nButtonWidth](
+ ScopedVclPtr<ImplTabButton> const & button)
{
- mpImpl->mpLastButton->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
- nX += nXDiff;
- nButtonWidth += nHeight;
- }
+ if (button) {
+ button->SetPosSizePixel(Point(nX, 0), aBtnSize);
+ nX += nXDiff;
+ nButtonWidth += nHeight;
+ }
+ };
+
+ setButton(mpImpl->mpFirstButton);
+ setButton(mpImpl->mpPrevButton);
+ setButton(mpImpl->mpNextButton);
+ setButton(mpImpl->mpLastButton);
nButtonWidth += nButtonMargin;
nX += mbMirrored ? -nButtonMargin : nButtonMargin;
- if (mpImpl->mpAddButton)
- {
- mpImpl->mpAddButton->SetPosSizePixel( Point( nX, 0 ), aBtnSize );
- nX += nXDiff;
- nButtonWidth += nHeight;
- }
+ setButton(mpImpl->mpAddButton);
nButtonWidth += nButtonMargin;