[Libreoffice-commits] core.git: 2 commits - include/vcl sd/source vcl/source

Caolán McNamara caolanm at redhat.com
Thu Jul 25 09:32:48 PDT 2013


 include/vcl/layout.hxx                             |    1 
 sd/source/ui/remotecontrol/AvahiNetworkService.hxx |    2 
 sd/source/ui/remotecontrol/ZeroconfService.hxx     |    1 
 vcl/source/window/layout.cxx                       |   54 ++++++++++++++++-----
 4 files changed, 45 insertions(+), 13 deletions(-)

New commits:
commit 0b8e897647d8ea0356c5f2e204c1ee3e4512df18
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 25 17:23:25 2013 +0100

    WaE: virtual dtor warnings
    
    Change-Id: I22b79ed43db2233b5c8edd90092ca387bfd0ca9a

diff --git a/sd/source/ui/remotecontrol/AvahiNetworkService.hxx b/sd/source/ui/remotecontrol/AvahiNetworkService.hxx
index 62809af..8f506f1 100644
--- a/sd/source/ui/remotecontrol/AvahiNetworkService.hxx
+++ b/sd/source/ui/remotecontrol/AvahiNetworkService.hxx
@@ -28,7 +28,7 @@ namespace sd {
     public:
         AvahiNetworkService(const std::string& aname = "", uint aport = 1599)
             : ZeroconfService(aname, aport){}
-        ~AvahiNetworkService();
+        virtual ~AvahiNetworkService(){}
 
         void clear();
         void setup();
diff --git a/sd/source/ui/remotecontrol/ZeroconfService.hxx b/sd/source/ui/remotecontrol/ZeroconfService.hxx
index a3e92fa..a31776d 100644
--- a/sd/source/ui/remotecontrol/ZeroconfService.hxx
+++ b/sd/source/ui/remotecontrol/ZeroconfService.hxx
@@ -28,6 +28,7 @@ namespace sd{
     public:
         explicit ZeroconfService(const std::string& aname, uint aport)
             :name(aname), port(aport){}
+        virtual ~ZeroconfService(){}
 
         std::string getName() const {return name;}
         void setName(const char * n) {name = n;}
commit b64adf65afb1cfe1bd48fed0d71ac333ad962776
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 25 16:58:36 2013 +0100

    Resolves: fdo#61544 improve handling of grid's not enough layout space
    
    Change-Id: I9a73e90f639bb853b67daa98d5daac155dab5900

diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 2178aff..1463569 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -388,6 +388,7 @@ public:
 private:
     void calcMaxs(const array_type &A, std::vector<Value> &rWidths, std::vector<Value> &rHeights) const;
 
+    Size calculateRequisitionForSpacings(sal_Int32 nRowSpacing, sal_Int32 nColSpacing) const;
     virtual Size calculateRequisition() const;
     virtual void setAllocation(const Size &rAllocation);
 public:
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index ba62a22..d458a8a 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -984,6 +984,11 @@ VclGrid::Value accumulateValues(const VclGrid::Value &i, const VclGrid::Value &j
 
 Size VclGrid::calculateRequisition() const
 {
+    return calculateRequisitionForSpacings(get_row_spacing(), get_column_spacing());
+}
+
+Size VclGrid::calculateRequisitionForSpacings(sal_Int32 nRowSpacing, sal_Int32 nColSpacing) const
+{
     array_type A = assembleGrid();
 
     if (isNullGrid(A))
@@ -1004,7 +1009,7 @@ Size VclGrid::calculateRequisition() const
         nTotalWidth = std::accumulate(aWidths.begin(), aWidths.end(), Value(), accumulateValues).m_nValue;
     }
 
-    nTotalWidth += get_column_spacing() * (aWidths.size()-1);
+    nTotalWidth += nColSpacing * (aWidths.size()-1);
 
     long nTotalHeight = 0;
     if (get_row_homogeneous())
@@ -1017,7 +1022,7 @@ Size VclGrid::calculateRequisition() const
         nTotalHeight = std::accumulate(aHeights.begin(), aHeights.end(), Value(), accumulateValues).m_nValue;
     }
 
-    nTotalHeight += get_row_spacing() * (aHeights.size()-1);
+    nTotalHeight += nRowSpacing * (aHeights.size()-1);
 
     return Size(nTotalWidth, nTotalHeight);
 }
@@ -1041,9 +1046,12 @@ void VclGrid::setAllocation(const Size& rAllocation)
         calcMaxs(A, aWidths, aHeights);
     }
 
+    sal_Int32 nColSpacing(get_column_spacing());
+    sal_Int32 nRowSpacing(get_row_spacing());
+
     long nAvailableWidth = rAllocation.Width();
     if (nMaxX)
-        nAvailableWidth -= get_column_spacing() * (nMaxX - 1);
+        nAvailableWidth -= nColSpacing * (nMaxX - 1);
     if (get_column_homogeneous())
     {
         for (sal_Int32 x = 0; x < nMaxX; ++x)
@@ -1057,9 +1065,20 @@ void VclGrid::setAllocation(const Size& rAllocation)
                 ++nExpandables;
         long nExtraWidthForExpanders = nExpandables ? (rAllocation.Width() - aRequisition.Width()) / nExpandables : 0;
 
-        if (rAllocation.Width() < aRequisition.Width())
+        //We don't fit and there is no volunteer to be shrunk
+        if (!nExpandables && rAllocation.Width() < aRequisition.Width())
         {
-            long nExtraWidth = (rAllocation.Width() - aRequisition.Width() - nExtraWidthForExpanders * nExpandables) / nMaxX;
+            //first reduce spacing, to a min of 3
+            while (nColSpacing >= 6)
+            {
+                nColSpacing /= 2;
+                aRequisition = calculateRequisitionForSpacings(nRowSpacing, nColSpacing);
+                if (aRequisition.Width() >= rAllocation.Width())
+                    break;
+            }
+
+            //share out the remaining pain to everyone
+            long nExtraWidth = (rAllocation.Width() - aRequisition.Width()) / nMaxX;
 
             for (sal_Int32 x = 0; x < nMaxX; ++x)
                 aWidths[x].m_nValue += nExtraWidth;
@@ -1075,7 +1094,7 @@ void VclGrid::setAllocation(const Size& rAllocation)
 
     long nAvailableHeight = rAllocation.Height();
     if (nMaxY)
-        nAvailableHeight -= get_row_spacing() * (nMaxY - 1);
+        nAvailableHeight -= nRowSpacing * (nMaxY - 1);
     if (get_row_homogeneous())
     {
         for (sal_Int32 y = 0; y < nMaxY; ++y)
@@ -1089,9 +1108,20 @@ void VclGrid::setAllocation(const Size& rAllocation)
                 ++nExpandables;
         long nExtraHeightForExpanders = nExpandables ? (rAllocation.Height() - aRequisition.Height()) / nExpandables : 0;
 
-        if (rAllocation.Height() < aRequisition.Height())
+        //We don't fit and there is no volunteer to be shrunk
+        if (!nExpandables && rAllocation.Height() < aRequisition.Height())
         {
-            long nExtraHeight = (rAllocation.Height() - aRequisition.Height() - nExtraHeightForExpanders * nExpandables) / nMaxY;
+            //first reduce spacing, to a min of 3
+            while (nRowSpacing >= 6)
+            {
+                nRowSpacing /= 2;
+                aRequisition = calculateRequisitionForSpacings(nRowSpacing, nColSpacing);
+                if (aRequisition.Height() >= rAllocation.Height())
+                    break;
+            }
+
+            //share out the remaining pain to everyone
+            long nExtraHeight = (rAllocation.Height() - aRequisition.Height()) / nMaxY;
 
             for (sal_Int32 y = 0; y < nMaxY; ++y)
                 aHeights[y].m_nValue += nExtraHeight;
@@ -1119,18 +1149,18 @@ void VclGrid::setAllocation(const Size& rAllocation)
                 sal_Int32 nWidth = rEntry.nSpanWidth;
                 for (sal_Int32 nSpanX = 0; nSpanX < nWidth; ++nSpanX)
                     aChildAlloc.Width() += aWidths[x+nSpanX].m_nValue;
-                aChildAlloc.Width() += get_column_spacing()*(nWidth-1);
+                aChildAlloc.Width() += nColSpacing*(nWidth-1);
 
                 sal_Int32 nHeight = rEntry.nSpanHeight;
                 for (sal_Int32 nSpanY = 0; nSpanY < nHeight; ++nSpanY)
                     aChildAlloc.Height() += aHeights[y+nSpanY].m_nValue;
-                aChildAlloc.Height() += get_row_spacing()*(nHeight-1);
+                aChildAlloc.Height() += nRowSpacing*(nHeight-1);
 
                 setLayoutAllocation(*pChild, aAllocPos, aChildAlloc);
             }
-            aAllocPos.Y() += aHeights[y].m_nValue + get_row_spacing();
+            aAllocPos.Y() += aHeights[y].m_nValue + nRowSpacing;
         }
-        aAllocPos.X() += aWidths[x].m_nValue + get_column_spacing();
+        aAllocPos.X() += aWidths[x].m_nValue + nColSpacing;
         aAllocPos.Y() = 0;
     }
 }


More information about the Libreoffice-commits mailing list