diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-06-15 10:19:41 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-28 08:48:30 +0100 |
commit | b89114144d0d3bf4b3903df42a3e97e5cbc458a0 (patch) | |
tree | e884a0e43ca5afbfde5108ca53fed6d8e3b6b6a7 | |
parent | 2d2c0d9e5860249742330d8fdfd606509b8b256f (diff) |
drop empty rows/cols in VclGrid
-rw-r--r-- | vcl/source/window/layout.cxx | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 79c63fe7d330..ae1f81a2fb8b 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -376,7 +376,50 @@ VclGrid::array_type VclGrid::assembleGrid() const A[nLeftAttach][nTopAttach] = pChild; } - return A; + + //see if we have any empty rows/cols + sal_Int32 nMaxX = A.shape()[0]; + sal_Int32 nMaxY = A.shape()[1]; + + std::vector<bool> aNonEmptyCols(nMaxX); + std::vector<bool> aNonEmptyRows(nMaxY); + + for (sal_Int32 x = 0; x < nMaxX; ++x) + { + for (sal_Int32 y = 0; y < nMaxY; ++y) + { + const Window *pChild = A[x][y]; + if (pChild) + { + aNonEmptyCols[x] = true; + aNonEmptyRows[y] = true; + } + } + } + + sal_Int32 nNonEmptyCols = std::count(aNonEmptyCols.begin(), aNonEmptyCols.end(), true); + sal_Int32 nNonEmptyRows = std::count(aNonEmptyRows.begin(), aNonEmptyRows.end(), true); + + //no empty rows or cols + if (nNonEmptyCols == nMaxX && nNonEmptyRows == nMaxY) + return A; + + //make new grid without empty rows and columns + array_type B(boost::extents[nNonEmptyCols][nNonEmptyRows]); + for (sal_Int32 x = 0, x2 = 0; x < nMaxX; ++x) + { + if (aNonEmptyCols[x] == false) + continue; + for (sal_Int32 y = 0, y2 = 0; y < nMaxY; ++y) + { + if (aNonEmptyRows[y] == false) + continue; + B[x2][y2++] = A[x][y]; + } + ++x2; + } + + return B; } bool VclGrid::isNullGrid(const array_type &A) const |