tdf#100584 - Arrange sheets in the tab bar depending on the RTL settings

Change-Id: Id10bfd18029651790be943b74745016f6ad637ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145765
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index 7daba17..b09c748 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -704,10 +704,15 @@ void TabBar::ImplFormat()
    if (!mbFormat)
        return;

    sal_uInt16 nItemIndex = 0;
    tools::Long x = mnOffX;
    for (auto & rItem : mpImpl->maItemList)

    const size_t nItemListSize = mpImpl->maItemList.size();
    for (size_t nItemIndex = 0; nItemIndex < nItemListSize; nItemIndex++)
    {
        // tdf#100584 - arrange sheets depending on the RTL settings
        auto& rItem = mbMirrored ? mpImpl->maItemList[nItemListSize - nItemIndex - 1]
                                 : mpImpl->maItemList[nItemIndex];

        // At all non-visible tabs an empty rectangle is set
        if ((nItemIndex + 1 < mnFirstPos) || (x > mnLastOffX))
            rItem.maRect.SetEmpty();
@@ -735,8 +740,6 @@ void TabBar::ImplFormat()
                rItem.maRect.SetLeft(nNewLeft);
            }
        }

        nItemIndex++;
    }

    mbFormat = false;