include/o3tl/enumarray.hxx    |    1 +
 include/vcl/vclenum.hxx       |    7 ++++---
 vcl/source/window/builder.cxx |    8 ++++----
 vcl/source/window/layout.cxx  |   14 ++++++++------
 vcl/source/window/window.cxx  |    2 +-
 5 files changed, 18 insertions(+), 14 deletions(-)

New commits:
commit fe0bba96ac0682eeba1757ede42b5fdef22764b8
Author: Noel Grandin <n...@peralex.com>
Date:   Tue May 24 09:21:33 2016 +0200

    Convert VclPackType to scoped enum
    
    Change-Id: I5bcc4f8686c1ce5bf7def948ce50837fa542786f
    Reviewed-on: https://gerrit.libreoffice.org/25394
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noelgran...@gmail.com>

diff --git a/include/o3tl/enumarray.hxx b/include/o3tl/enumarray.hxx
index 0e88142..766d967 100644
--- a/include/o3tl/enumarray.hxx
+++ b/include/o3tl/enumarray.hxx
@@ -22,6 +22,7 @@
 
 #include <iterator>
 #include <type_traits>
+#include <cassert>
 
 namespace o3tl {
 
diff --git a/include/vcl/vclenum.hxx b/include/vcl/vclenum.hxx
index 28a6888..45f9ed2 100644
--- a/include/vcl/vclenum.hxx
+++ b/include/vcl/vclenum.hxx
@@ -107,10 +107,11 @@ enum VclAlign
     VCL_ALIGN_CENTER
 };
 
-enum VclPackType
+enum class VclPackType
 {
-    VCL_PACK_START = 0,
-    VCL_PACK_END = 1
+    Start = 0,
+    End = 1,
+    LAST = End
 };
 
 // Return Values from Dialog::Execute
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 2a466ad..17c3b8f 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1997,14 +1997,14 @@ bool 
VclBuilder::sortIntoBestTabTraversalOrder::operator()(const vcl::Window *pA
             return false;
     }
     //honour relative box positions with pack group, (numerical order is 
reversed
-    //for VCL_PACK_END, they are packed from the end back, but here we need
+    //for VclPackType::End, they are packed from the end back, but here we need
     //them in visual layout order so that tabbing works as expected)
     sal_Int32 nPackA = m_pBuilder->get_window_packing_data(pA).m_nPosition;
     sal_Int32 nPackB = m_pBuilder->get_window_packing_data(pB).m_nPosition;
     if (nPackA < nPackB)
-        return ePackA == VCL_PACK_START;
+        return ePackA == VclPackType::Start;
     if (nPackA > nPackB)
-        return ePackA != VCL_PACK_START;
+        return ePackA != VclPackType::Start;
     //sort labels of Frames before body
     if (pA->GetParent() == pB->GetParent())
     {
@@ -2956,7 +2956,7 @@ void VclBuilder::applyPackingProperty(vcl::Window 
*pCurrent,
             }
             else if (sKey == "pack-type")
             {
-                VclPackType ePackType = (!sValue.isEmpty() && (sValue[0] == 
'e' || sValue[0] == 'E')) ? VCL_PACK_END : VCL_PACK_START;
+                VclPackType ePackType = (!sValue.isEmpty() && (sValue[0] == 
'e' || sValue[0] == 'E')) ? VclPackType::End : VclPackType::Start;
                 pCurrent->set_pack_type(ePackType);
             }
             else if (sKey == "left-attach")
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index a376138..5e82e4a 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -8,6 +8,8 @@
  */
 
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <o3tl/enumarray.hxx>
+#include <o3tl/enumrange.hxx>
 #include <vcl/dialog.hxx>
 #include <vcl/layout.hxx>
 #include <vcl/msgbox.hxx>
@@ -231,25 +233,25 @@ void VclBox::setAllocation(const Size &rAllocation)
     }
 
     //Split into those we pack from the start onwards, and those we pack from 
the end backwards
-    std::vector<vcl::Window*> aWindows[2];
+    o3tl::enumarray<VclPackType,std::vector<vcl::Window*>> aWindows;
     for (vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); pChild; 
pChild = pChild->GetWindow(GetWindowType::Next))
     {
         if (!pChild->IsVisible())
             continue;
 
-        sal_Int32 ePacking = pChild->get_pack_type();
+        VclPackType ePacking = pChild->get_pack_type();
         aWindows[ePacking].push_back(pChild);
     }
 
     //See VclBuilder::sortIntoBestTabTraversalOrder for why they are in visual
     //order under the parent which requires us to reverse them here to
     //pack from the end back
-    std::reverse(aWindows[VCL_PACK_END].begin(),aWindows[VCL_PACK_END].end());
+    
std::reverse(aWindows[VclPackType::End].begin(),aWindows[VclPackType::End].end());
 
-    for (sal_Int32 ePackType = VCL_PACK_START; ePackType <= VCL_PACK_END; 
++ePackType)
+    for (VclPackType ePackType : o3tl::enumrange<VclPackType>())
     {
         Point aPos(0, 0);
-        if (ePackType == VCL_PACK_END)
+        if (ePackType == VclPackType::End)
         {
             long nPrimaryCoordinate = getPrimaryCoordinate(aPos);
             setPrimaryCoordinate(aPos, nPrimaryCoordinate + 
nAllocPrimaryDimension);
@@ -297,7 +299,7 @@ void VclBox::setAllocation(const Size &rAllocation)
             }
 
             long nDiff = getPrimaryDimension(aBoxSize) + m_nSpacing;
-            if (ePackType == VCL_PACK_START)
+            if (ePackType == VclPackType::Start)
                 setPrimaryCoordinate(aPos, nPrimaryCoordinate + nDiff);
             else
             {
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 547bc2c..623275b 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -641,7 +641,7 @@ WindowImpl::WindowImpl( WindowType nType )
     meAlwaysInputMode                   = AlwaysInputNone;           // 
neither AlwaysEnableInput nor AlwaysDisableInput called
     meHalign                            = VCL_ALIGN_FILL;
     meValign                            = VCL_ALIGN_FILL;
-    mePackType                          = VCL_PACK_START;
+    mePackType                          = VclPackType::Start;
     mnPadding                           = 0;
     mnGridHeight                        = 1;
     mnGridLeftAttach                    = -1;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to