[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - sfx2/source

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 9 02:36:13 UTC 2019


 sfx2/source/sidebar/Deck.cxx         |    3 +
 sfx2/source/sidebar/DeckLayouter.cxx |   93 +++++++++++++++--------------------
 2 files changed, 43 insertions(+), 53 deletions(-)

New commits:
commit 33dd53818ee68aea81b4cfd5725c06f5f590474f
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Dec 8 11:26:06 2019 -0500
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Mon Dec 9 03:35:45 2019 +0100

    sfx2: convert iterator loops to range-for
    
    Change-Id: Iebeb96b2eea76f13abdba6fffb0a4b488f202faa
    Reviewed-on: https://gerrit.libreoffice.org/84719
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sfx2/source/sidebar/DeckLayouter.cxx b/sfx2/source/sidebar/DeckLayouter.cxx
index 650b112605aa..c1b35df89525 100644
--- a/sfx2/source/sidebar/DeckLayouter.cxx
+++ b/sfx2/source/sidebar/DeckLayouter.cxx
@@ -163,13 +163,10 @@ tools::Rectangle LayoutPanels (
     sal_Int32 nTotalPreferredHeight (0);
     sal_Int32 nTotalMinimumHeight (0);
 
-    for(::std::vector<LayoutItem>::const_iterator iItem(rLayoutItems.begin()),
-         iEnd(rLayoutItems.end());
-        iItem!=iEnd;
-        ++iItem)
+    for (const LayoutItem& item : rLayoutItems)
     {
-        nTotalMinimumHeight += iItem->maLayoutSize.Minimum;
-        nTotalPreferredHeight += iItem->maLayoutSize.Preferred;
+        nTotalMinimumHeight += item.maLayoutSize.Minimum;
+        nTotalPreferredHeight += item.maLayoutSize.Preferred;
     }
 
 
@@ -354,41 +351,39 @@ void GetRequestedSizes (
 
     const sal_Int32 nDeckSeparatorHeight (Theme::GetInteger(Theme::Int_DeckSeparatorHeight));
 
-    ::std::vector<LayoutItem>::const_iterator iEnd(rLayoutItems.end());
-
-    for(::std::vector<LayoutItem>::iterator iItem(rLayoutItems.begin());
-        iItem!=iEnd;
-        ++iItem)
+    for (LayoutItem& item : rLayoutItems)
     {
         ui::LayoutSize aLayoutSize (ui::LayoutSize(0,0,0));
-        if (iItem->mpPanel != nullptr)
+        if (item.mpPanel != nullptr)
         {
             if (rLayoutItems.size() == 1
-                && iItem->mpPanel->IsTitleBarOptional())
+                && item.mpPanel->IsTitleBarOptional())
             {
                 // There is only one panel and its title bar is
                 // optional => hide it.
                 rAvailableHeight -= nDeckSeparatorHeight;
-                iItem->mbShowTitleBar = false;
+                item.mbShowTitleBar = false;
             }
             else
             {
                 // Show the title bar and a separator above and below
                 // the title bar.
-                const sal_Int32 nPanelTitleBarHeight (Theme::GetInteger(Theme::Int_PanelTitleBarHeight) * iItem->mpPanel->GetDPIScaleFactor());
+                const sal_Int32 nPanelTitleBarHeight(
+                    Theme::GetInteger(Theme::Int_PanelTitleBarHeight)
+                    * item.mpPanel->GetDPIScaleFactor());
 
                 rAvailableHeight -= nPanelTitleBarHeight;
                 rAvailableHeight -= nDeckSeparatorHeight;
             }
 
-            if (iItem->mpPanel->IsExpanded())
+            if (item.mpPanel->IsExpanded())
             {
-                Reference<ui::XSidebarPanel> xPanel (iItem->mpPanel->GetPanelComponent());
+                Reference<ui::XSidebarPanel> xPanel(item.mpPanel->GetPanelComponent());
                 if (xPanel.is())
                 {
                     aLayoutSize = xPanel->getHeightForWidth(rContentBox.GetWidth());
 
-                    sal_Int32 nWidth = xPanel->getMinimalWidth();
+                    const sal_Int32 nWidth = xPanel->getMinimalWidth();
                     if (nWidth > rMinimalWidth)
                         rMinimalWidth = nWidth;
                 }
@@ -396,7 +391,8 @@ void GetRequestedSizes (
                     aLayoutSize = ui::LayoutSize(MinimalPanelHeight, -1, 0);
             }
         }
-        iItem->maLayoutSize = aLayoutSize;
+
+        item.maLayoutSize = aLayoutSize;
     }
 }
 
@@ -416,25 +412,19 @@ void DistributeHeights (
     sal_Int32 nTotalWeight (0);
     sal_Int32 nNoMaximumCount (0);
 
-    ::std::vector<LayoutItem>::const_iterator iEnd(rLayoutItems.end());
-
-    for(::std::vector<LayoutItem>::iterator iItem(rLayoutItems.begin());
-        iItem!=iEnd;
-        ++iItem)
+    for (LayoutItem& item : rLayoutItems)
     {
-        if (iItem->maLayoutSize.Maximum == 0)
+        if (item.maLayoutSize.Maximum == 0)
             continue;
-        if (iItem->maLayoutSize.Maximum < 0)
+        if (item.maLayoutSize.Maximum < 0)
             ++nNoMaximumCount;
 
-        const sal_Int32 nBaseHeight (
-            bMinimumHeightIsBase
-                ? iItem->maLayoutSize.Minimum
-                : iItem->maLayoutSize.Preferred);
+        const sal_Int32 nBaseHeight(bMinimumHeightIsBase ? item.maLayoutSize.Minimum
+                                                         : item.maLayoutSize.Preferred);
         if (nBaseHeight < nContainerHeight)
         {
-            iItem->mnWeight = nContainerHeight - nBaseHeight;
-            nTotalWeight += iItem->mnWeight;
+            item.mnWeight = nContainerHeight - nBaseHeight;
+            nTotalWeight += item.mnWeight;
         }
     }
 
@@ -442,21 +432,18 @@ void DistributeHeights (
         return;
 
     // First pass of height distribution.
-    for(::std::vector<LayoutItem>::iterator iItem(rLayoutItems.begin());
-        iItem!=iEnd;
-        ++iItem)
+    for (LayoutItem& item : rLayoutItems)
     {
-        const sal_Int32 nBaseHeight (
-            bMinimumHeightIsBase
-                ? iItem->maLayoutSize.Minimum
-                : iItem->maLayoutSize.Preferred);
-        sal_Int32 nDistributedHeight (iItem->mnWeight * nHeightToDistribute / nTotalWeight);
-        if (nBaseHeight+nDistributedHeight > iItem->maLayoutSize.Maximum
-            && iItem->maLayoutSize.Maximum >= 0)
+        const sal_Int32 nBaseHeight(bMinimumHeightIsBase ? item.maLayoutSize.Minimum
+                                                         : item.maLayoutSize.Preferred);
+        sal_Int32 nDistributedHeight(item.mnWeight * nHeightToDistribute / nTotalWeight);
+        if (nBaseHeight + nDistributedHeight > item.maLayoutSize.Maximum
+            && item.maLayoutSize.Maximum >= 0)
         {
-            nDistributedHeight = ::std::max<sal_Int32>(0,iItem->maLayoutSize.Maximum - nBaseHeight);
+            nDistributedHeight = ::std::max<sal_Int32>(0, item.maLayoutSize.Maximum - nBaseHeight);
         }
-        iItem->mnDistributedHeight = nDistributedHeight;
+
+        item.mnDistributedHeight = nDistributedHeight;
         nRemainingHeightToDistribute -= nDistributedHeight;
     }
 
@@ -473,19 +460,19 @@ void DistributeHeights (
         // There are no panels with unrestricted height.
         return;
     }
-    const sal_Int32 nAdditionalHeightPerPanel (nRemainingHeightToDistribute / nNoMaximumCount);
+
+    const sal_Int32 nAdditionalHeightPerPanel(nRemainingHeightToDistribute / nNoMaximumCount);
     // Handle rounding error.
-    sal_Int32 nAdditionalHeightForFirstPanel (nRemainingHeightToDistribute
-        - nNoMaximumCount*nAdditionalHeightPerPanel);
+    const sal_Int32 nAdditionalHeightForFirstPanel(nRemainingHeightToDistribute
+                                                   - nNoMaximumCount * nAdditionalHeightPerPanel);
 
-    for(::std::vector<LayoutItem>::iterator iItem(rLayoutItems.begin());
-        iItem!=iEnd;
-        ++iItem)
+    for (LayoutItem& item : rLayoutItems)
     {
-        if (iItem->maLayoutSize.Maximum < 0)
+        if (item.maLayoutSize.Maximum < 0)
         {
-            iItem->mnDistributedHeight += nAdditionalHeightPerPanel + nAdditionalHeightForFirstPanel;
-            nRemainingHeightToDistribute -= nAdditionalHeightPerPanel + nAdditionalHeightForFirstPanel;
+            item.mnDistributedHeight += nAdditionalHeightPerPanel + nAdditionalHeightForFirstPanel;
+            nRemainingHeightToDistribute
+                -= nAdditionalHeightPerPanel + nAdditionalHeightForFirstPanel;
         }
     }
 
commit a40deaf2d5d35cf28b4a0709c8d82a055b16d1e4
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Dec 8 12:36:58 2019 -0500
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Mon Dec 9 03:35:32 2019 +0100

    sidebar: sensible line and page sizes and invalidate
    
    Change-Id: Icf60480a47d7c93bad44f6457bb05af332e63c6d
    Reviewed-on: https://gerrit.libreoffice.org/84718
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index 66de858cc35c..fba9f1330833 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -65,6 +65,8 @@ Deck::Deck(const DeckDescriptor& rDeckDescriptor, vcl::Window* pParentWindow,
     mpScrollContainer->Show();
 
     mpVerticalScrollBar->SetScrollHdl(LINK(this, Deck, HandleVerticalScrollBarChange));
+    mpVerticalScrollBar->SetLineSize(10);
+    mpVerticalScrollBar->SetPageSize(100);
 
 #ifdef DEBUG
     SetText(OUString("Deck"));
@@ -344,6 +346,7 @@ IMPL_LINK_NOARG(Deck, HandleVerticalScrollBarChange, ScrollBar*, void)
     const sal_Int32 nYOffset (-mpVerticalScrollBar->GetThumbPos());
     mpScrollContainer->SetPosPixel(Point(mpScrollContainer->GetPosPixel().X(),
                                          nYOffset));
+    mpScrollContainer->Invalidate();
 }
 
 //----- Deck::ScrollContainerWindow -------------------------------------------


More information about the Libreoffice-commits mailing list