[Libreoffice-commits] core.git: 2 commits - include/sfx2 sc/source sfx2/Library_sfx.mk sfx2/source svx/source sw/source vcl/source

Caolán McNamara caolanm at redhat.com
Fri Jul 5 05:38:53 PDT 2013


 include/sfx2/sidebar/GridLayouter.hxx                |  203 +++++
 include/sfx2/sidebar/Layouter.hxx                    |   79 ++
 include/sfx2/sidebar/SidebarToolBox.hxx              |    4 
 sc/source/ui/sidebar/AlignmentPropertyPanel.cxx      |   26 
 sc/source/ui/sidebar/AlignmentPropertyPanel.hxx      |    2 
 sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx |   17 
 sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx |    2 
 sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx   |   15 
 sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx   |    2 
 sfx2/Library_sfx.mk                                  |    2 
 sfx2/source/sidebar/GridLayouter.cxx                 |  724 +++++++++++++++++++
 sfx2/source/sidebar/Layouter.cxx                     |  114 ++
 svx/source/sidebar/area/AreaPropertyPanel.cxx        |   49 +
 svx/source/sidebar/area/AreaPropertyPanel.hxx        |    5 
 svx/source/sidebar/graphic/GraphicPropertyPanel.cxx  |   70 +
 svx/source/sidebar/graphic/GraphicPropertyPanel.hxx  |    4 
 svx/source/sidebar/line/LinePropertyPanel.cxx        |   61 +
 svx/source/sidebar/line/LinePropertyPanel.hrc        |    4 
 svx/source/sidebar/line/LinePropertyPanel.hxx        |    5 
 svx/source/sidebar/line/LinePropertyPanel.src        |    4 
 svx/source/sidebar/paragraph/ParaPropertyPanel.cxx   |   28 
 svx/source/sidebar/paragraph/ParaPropertyPanel.hxx   |    5 
 svx/source/sidebar/possize/PosSizePropertyPanel.cxx  |   55 +
 svx/source/sidebar/possize/PosSizePropertyPanel.hxx  |    4 
 svx/source/sidebar/text/TextPropertyPanel.cxx        |   34 
 svx/source/sidebar/text/TextPropertyPanel.hxx        |    5 
 sw/source/ui/sidebar/PagePropertyPanel.cxx           |   22 
 sw/source/ui/sidebar/PagePropertyPanel.hxx           |    5 
 vcl/source/window/builder.cxx                        |   19 
 29 files changed, 1539 insertions(+), 30 deletions(-)

New commits:
commit 8d0883b9dec891d71adbbb7fd98730703c561aa5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jul 5 13:37:47 2013 +0100

    map 'relief' none/half/normal to flat/bevel/3dlook
    
    Change-Id: Ib125363a649d3bef6b9563ad7d07871b2c247383

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 95f0737..7018789 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -617,6 +617,21 @@ namespace
         return bIsStock;
     }
 
+    WinBits extractRelief(VclBuilder::stringmap &rMap)
+    {
+        WinBits nBits = WB_3DLOOK;
+        VclBuilder::stringmap::iterator aFind = rMap.find(OString("relief"));
+        if (aFind != rMap.end())
+        {
+            if (aFind->second == "half")
+                nBits = WB_FLATBUTTON | WB_BEVELBUTTON;
+            else if (aFind->second == "none")
+                nBits = WB_FLATBUTTON;
+            rMap.erase(aFind);
+        }
+        return nBits;
+    }
+
     OString extractLabel(VclBuilder::stringmap &rMap)
     {
         OString sType;
@@ -676,7 +691,9 @@ namespace
 
     Window * extractStockAndBuildPushButton(Window *pParent, VclBuilder::stringmap &rMap)
     {
-        WinBits nBits = WB_CENTER|WB_VCENTER|WB_3DLOOK;
+        WinBits nBits = WB_CENTER|WB_VCENTER;
+
+        nBits |= extractRelief(rMap);
 
         bool bIsStock = extractStock(rMap);
 
commit c61c5a240314f1899a2160a97e00e2108104e4bd
Author: Andre Fischer <af at apache.org>
Date:   Fri Jul 5 08:53:11 2013 +0000

    Related: #i122635# Add layouting to some sidebar panels.
    
    (cherry picked from commit 4f9ac2af7157786ee6fba46551bd6782730d8b55)
    
    Conflicts:
    	sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
    	sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
    	sfx2/Package_inc.mk
    	sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx
    	svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
    	svx/source/sidebar/text/TextPropertyPanel.hrc
    	svx/source/sidebar/text/TextPropertyPanel.src
    	sw/source/ui/sidebar/PagePropertyPanel.cxx
    
    Change-Id: I94bfc87c9eeddd0c39bd979dd26b11c95b1e3c72

diff --git a/include/sfx2/sidebar/GridLayouter.hxx b/include/sfx2/sidebar/GridLayouter.hxx
new file mode 100644
index 0000000..1bd3c85
--- /dev/null
+++ b/include/sfx2/sidebar/GridLayouter.hxx
@@ -0,0 +1,203 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef SFX_SIDEBAR_GRID_LAYOUTER_HXX
+#define SFX_SIDEBAR_GRID_LAYOUTER_HXX
+
+#include "sfx2/dllapi.h"
+#include <boost/scoped_ptr.hpp>
+
+class Rectangle;
+class Window;
+
+namespace sfx2 { namespace sidebar {
+
+class CellDescriptor;
+class ColumnDescriptor;
+
+/** A simple layouter that organizes controls in a grid.
+    At the moment only horizontal positions and sizes are processed.
+    It can handle all or only a subset of the controls in one panel.
+*/
+class SFX2_DLLPUBLIC GridLayouter
+{
+public:
+    GridLayouter (Window& rParent);
+    ~GridLayouter (void);
+
+    /** Return the cell descriptor for the specified cell.
+        This creates empty column data structures as needed.
+
+        By default a cell has only one cell descriptor.  Different
+        variants allow different cell descriptors for different
+        controls.  This is useful if different controls are displayed
+        for different contexts, and, say, one has a fixed width and
+        another is to fill the column.
+
+        During layouting only cell descriptors are processed that have
+        visible controls.
+    */
+    CellDescriptor& GetCell (
+        const sal_Int32 nRow,
+        const sal_Int32 nColumn,
+        const sal_Int32 nVariant = 0);
+
+    ColumnDescriptor& GetColumn (
+        const sal_Int32 nColumn);
+
+    /** Calculate positions and sizes for all visible controls under
+        the control of the grid layouter according to the current size
+        of the parent window.
+    */
+    void Layout (void);
+
+    /** Paint some debug information.
+    */
+    void Paint (const Rectangle& rBox);
+
+private:
+    class Implementation;
+    ::boost::scoped_ptr<Implementation> mpImplementation;
+};
+
+
+
+/** A collection of attributes for a single cell in a grid layout.
+    Represents one control.
+*/
+class SFX2_DLLPUBLIC CellDescriptor
+{
+public:
+    CellDescriptor (void);
+    ~CellDescriptor (void);
+
+    /** Set the number of columns covered by the cell.  The default
+        value is 1.
+    */
+    CellDescriptor& SetGridWidth (const sal_Int32 nColumnCount);
+
+    /** Set the control represented by the cell and whose position and
+        size will be modified in subsequent calls to
+        GridLayouter::Layout().
+        The cell is only taken into account in Layout() when the
+        control is visible.
+    */
+    CellDescriptor& SetControl (Window& rWindow);
+
+    /** Set the minimum and maximum width of the cell to the given
+        value.
+    */
+    CellDescriptor& SetFixedWidth (const sal_Int32 nWidth);
+
+    /** Set the minimum and maximum width of the cell to the current
+        width of the control.
+    */
+    CellDescriptor& SetFixedWidth (void);
+    CellDescriptor& SetMinimumWidth (const sal_Int32 nWidth);
+
+    /** Set the horizontal offset of the control with respect to the
+        containing column.  The offset is only used when the position
+        of the control is calculated not when the sizes of columns are
+        calculated.
+    */
+    CellDescriptor& SetOffset (const sal_Int32 nOffset);
+
+    sal_Int32 GetGridWidth (void) const;
+    Window* GetControl (void) const;
+    sal_Int32 GetMinimumWidth (void) const;
+    sal_Int32 GetMaximumWidth (void) const;
+    sal_Int32 GetOffset (void) const;
+
+private:
+    Window* mpControl;
+    sal_Int32 mnGridWidth;
+    sal_Int32 mnMinimumWidth;
+    sal_Int32 mnMaximumWidth;
+    sal_Int32 mnOffset;
+};
+
+
+
+/** A collection of attributes for a single column in a grid layout.
+*/
+class SFX2_DLLPUBLIC ColumnDescriptor
+{
+public:
+    ColumnDescriptor (void);
+    ~ColumnDescriptor (void);
+
+    ColumnDescriptor& SetWeight (
+        const sal_Int32 nWeight);
+    ColumnDescriptor& SetMinimumWidth (
+        const sal_Int32 nWidth);
+    /** Set both minimum and maximum width to the given value.
+    */
+    ColumnDescriptor& SetFixedWidth (
+        const sal_Int32 nWidth);
+
+    /** Set external padding on the left side of the column.
+    */
+    ColumnDescriptor& SetLeftPadding (
+        const sal_Int32 nPadding);
+
+    /** Set external padding on the right side of the column.
+    */
+    ColumnDescriptor& SetRightPadding (
+        const sal_Int32 nPadding);
+
+    sal_Int32 GetWeight (void) const;
+
+    /** Return the minimum width of the column without external
+        padding.  This is the value last set with SetMinimumWidth() or SetFixedWidth().
+    */
+    sal_Int32 GetMinimumWidth (void) const;
+
+    /** Return the maximum width of the column without external
+        padding.  This is the value last set with SetFixedWidth().
+    */
+    sal_Int32 GetMaximumWidth (void) const;
+
+    /** Return the maximum width of the column including external
+        padding.
+    */
+    sal_Int32 GetTotalMaximumWidth (void) const;
+
+    sal_Int32 GetLeftPadding (void) const;
+    sal_Int32 GetRightPadding (void) const;
+
+    /** The width of the column is a temporary and internal value that
+        is calculated in GridLayouter::Layout().
+        Calling this method outside of Layout() does not have any effect.
+    */
+    void SetWidth (const sal_Int32 nWidth);
+    sal_Int32 GetWidth (void) const;
+
+private:
+    sal_Int32 mnWeight;
+    sal_Int32 mnMinimumWidth;
+    sal_Int32 mnMaximumWidth;
+    sal_Int32 mnLeftPadding;
+    sal_Int32 mnRightPadding;
+
+    // Temporary values set calculated in the Layout() method.
+    sal_Int32 mnWidth;
+};
+
+
+} } // end of namespace sfx2::sidebar
+
+#endif
diff --git a/include/sfx2/sidebar/Layouter.hxx b/include/sfx2/sidebar/Layouter.hxx
new file mode 100644
index 0000000..ba2943d7
--- /dev/null
+++ b/include/sfx2/sidebar/Layouter.hxx
@@ -0,0 +1,79 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef SFX_SIDEBAR_LAYOUTER_HXX
+#define SFX_SIDEBAR_LAYOUTER_HXX
+
+#include "sfx2/dllapi.h"
+
+class Window;
+
+namespace sfx2 { namespace sidebar {
+
+/** Collection of simple helper functions for layouting sidebar panels.
+*/
+class SFX2_DLLPUBLIC Layouter
+{
+public:
+    /** Make the given control wider by the given value.  Negative
+        values would make the control smaller.
+        The height and the position of the control remain unchanged.
+    */
+    static void EnlargeControlHorizontally (
+        Window& rControl,
+        const sal_Int32 nDeltaX);
+
+    static void SetWidth (
+        Window& rControl,
+        const sal_Int32 nWidth);
+
+    static void SetRight (
+        Window& rControl,
+        const sal_Int32 nRight);
+
+    /** Move the given control by the given value to the right.
+        A negative value would move the control to the left.
+        The y-position and the size of the control remain unchanged.
+    */
+    static void MoveControlHorizontally (
+        Window& rControl,
+        const sal_Int32 nDeltaX);
+
+    static void SetHorizontalPosition (
+        Window& rControl,
+        const sal_Int32 nX);
+
+    /** Set the WB_ELLIPSIS flag at the given control so that when it
+        can not be shown completely it is shortened more gracefully
+        then just cutting it off.  The ellipsis flag can not be set
+        via the resource file.
+    */
+    static void PrepareForLayouting (
+        Window& rControl);
+
+    static sal_Int32 MapX (
+        const Window& rControl,
+        const sal_Int32 nValue);
+
+    static sal_Int32 MapWidth (
+        const Window& rControl,
+        const sal_Int32 nValue);
+};
+
+} } // end of namespace sfx2::sidebar
+
+#endif
diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx b/include/sfx2/sidebar/SidebarToolBox.hxx
index ec63cc3..b37c65c 100644
--- a/include/sfx2/sidebar/SidebarToolBox.hxx
+++ b/include/sfx2/sidebar/SidebarToolBox.hxx
@@ -103,6 +103,10 @@ private:
     DECL_LINK(ActivateToolBox, ToolBox*);
     DECL_LINK(DeactivateToolBox, ToolBox*);
 
+    using ToolBox::Activate;
+    using ToolBox::Deactivate;
+    using DockingWindow::SetPosSizePixel;
+
     void CreateController (
         const sal_uInt16 nItemId,
         const cssu::Reference<css::frame::XFrame>& rxFrame,
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
index d20a906..99ecfb4 100644
--- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
@@ -19,6 +19,7 @@
 #include <sfx2/sidebar/ResourceDefinitions.hrc>
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/sidebar/Layouter.hxx>
 #include <AlignmentPropertyPanel.hxx>
 #include <editeng/justifyitem.hxx>
 #include <svx/dialmgr.hxx>
@@ -33,6 +34,7 @@
 
 using namespace css;
 using namespace cssu;
+using ::sfx2::sidebar::Layouter;
 using ::sfx2::sidebar::ControlFactory;
 
 const char UNO_ALIGNBLOCK[]            = ".uno:AlignBlock";
@@ -86,6 +88,13 @@ AlignmentPropertyPanel::AlignmentPropertyPanel(
 
     mpFTLeftIndent->SetBackground(Wallpaper());
     mpFtRotate->SetBackground(Wallpaper());
+
+    Layouter::PrepareForLayouting(*mpFTLeftIndent);
+    Layouter::PrepareForLayouting(*mpFtRotate);
+    Layouter::PrepareForLayouting(*mpCBXWrapText);
+    Layouter::PrepareForLayouting(*mpCBXMergeCell);
+    Layouter::PrepareForLayouting(*mpCbStacked);
+
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -611,10 +620,17 @@ void AlignmentPropertyPanel::UpdateVerAlign()
     }
 }
 
-//////////////////////////////////////////////////////////////////////////////
-// namespace close
 
-}} // end of namespace ::sc::sidebar
 
-//////////////////////////////////////////////////////////////////////////////
-// eof
+
+void AlignmentPropertyPanel::Resize (void)
+{
+    const sal_Int32 nRight (GetSizePixel().Width() - Layouter::MapWidth(*this, TB_BORDER));
+    Layouter::SetRight(*mpFtRotate, nRight);
+    Layouter::SetRight(*mpCBXWrapText, nRight);
+    Layouter::SetRight(*mpCBXMergeCell, nRight);
+    Layouter::SetRight(*mpCbStacked, nRight);
+}
+
+
+}} // end of namespace ::sc::sidebar
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx
index 476633e..4a90a87 100644
--- a/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx
+++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx
@@ -58,6 +58,8 @@ public:
 
     SfxBindings* GetBindings();
 
+    virtual void Resize (void);
+
 private:
     //ui controls
     ToolBox*                                    mpTBHorizontal;
diff --git a/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
index 332b72d..fcf5264 100644
--- a/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
+++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
@@ -19,6 +19,7 @@
 #include <sfx2/sidebar/ResourceDefinitions.hrc>
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/sidebar/Layouter.hxx>
 #include <CellAppearancePropertyPanel.hxx>
 #include <CellAppearancePropertyPanel.hrc>
 #include "sc.hrc"
@@ -44,6 +45,8 @@
 
 using namespace css;
 using namespace cssu;
+using ::sfx2::sidebar::Layouter;
+
 
 const char UNO_BACKGROUNDCOLOR[] = ".uno:BackgroundColor";
 const char UNO_SETBORDERSTYLE[] = ".uno:SetBorderStyle";
@@ -829,8 +832,18 @@ void CellAppearancePropertyPanel::UpdateControlState()
     }
 }
 
-//////////////////////////////////////////////////////////////////////////////
-// namespace close
+
+
+
+void CellAppearancePropertyPanel::Resize (void)
+{
+    const sal_Int32 nRight (GetSizePixel().Width() - Layouter::MapWidth(*this, TB_BORDER));
+    Layouter::SetRight(*mpFTFillColor, nRight);
+    Layouter::SetRight(*mpFTCellBorder, nRight);
+    Layouter::SetRight(*mpCBXShowGrid, nRight);
+}
+
+
 
 }} // end of namespace ::sc::sidebar
 
diff --git a/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx b/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx
index 5791ba7..a8dabba 100644
--- a/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx
+++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx
@@ -66,6 +66,8 @@ public:
 
     SfxBindings* GetBindings();
 
+    virtual void Resize (void);
+
 private:
     //ui controls
 
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
index 7e9983a..de9c728 100644
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
@@ -18,6 +18,7 @@
 
 #include <sfx2/sidebar/ResourceDefinitions.hrc>
 #include <sfx2/sidebar/Theme.hxx>
+#include <sfx2/sidebar/Layouter.hxx>
 #include <sfx2/sidebar/ControlFactory.hxx>
 #include <NumberFormatPropertyPanel.hxx>
 #include "sc.hrc"
@@ -34,6 +35,7 @@
 
 using namespace css;
 using namespace cssu;
+using ::sfx2::sidebar::Layouter;
 using ::sfx2::sidebar::Theme;
 
 const char UNO_NUMERICFIELD[]         = ".uno:NumericField";
@@ -351,8 +353,17 @@ SfxBindings* NumberFormatPropertyPanel::GetBindings()
     return mpBindings;
 }
 
-//////////////////////////////////////////////////////////////////////////////
-// namespace close
+
+
+
+void NumberFormatPropertyPanel::Resize (void)
+{
+    const sal_Int32 nRight (GetSizePixel().Width() - Layouter::MapWidth(*this, TB_BORDER));
+    Layouter::SetRight(*mpFtCategory, nRight);
+    Layouter::SetRight(*mpFtLeadZeroes, nRight);
+    Layouter::SetRight(*mpBtnNegRed, nRight);
+    Layouter::SetRight(*mpBtnThousand, nRight);
+}
 
 }} // end of namespace ::sc::sidebar
 
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx
index 6bc898f..01bc074 100644
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx
@@ -55,6 +55,8 @@ public:
 
     SfxBindings* GetBindings();
 
+    virtual void Resize (void);
+
 private:
     //ui controls
     ListBox*                                mpLbCategory;
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 161a6f7..c18230a 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -252,9 +252,11 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
     sfx2/source/sidebar/DrawHelper \
     sfx2/source/sidebar/EnumContext \
     sfx2/source/sidebar/FocusManager \
+    sfx2/source/sidebar/GridLayouter \
     sfx2/source/sidebar/MenuButton \
     sfx2/source/sidebar/IContextChangeReceiver \
     sfx2/source/sidebar/ILayoutableWindow \
+    sfx2/source/sidebar/Layouter \
     sfx2/source/sidebar/Paint \
     sfx2/source/sidebar/Panel \
     sfx2/source/sidebar/PanelDescriptor \
diff --git a/sfx2/source/sidebar/GridLayouter.cxx b/sfx2/source/sidebar/GridLayouter.cxx
new file mode 100644
index 0000000..493a654
--- /dev/null
+++ b/sfx2/source/sidebar/GridLayouter.cxx
@@ -0,0 +1,724 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include "precompiled_sfx2.hxx"
+#include "sfx2/sidebar/GridLayouter.hxx"
+
+#include <vcl/window.hxx>
+
+namespace sfx2 { namespace sidebar {
+
+typedef std::vector<CellDescriptor> CellData;
+typedef std::vector<CellData> ColumnData;
+
+class GridLayouter::Implementation
+{
+public:
+    Implementation (Window& rParent);
+    ~Implementation (void);
+
+    CellDescriptor& GetCell (
+        const sal_Int32 nRow,
+        const sal_Int32 nColumn,
+        const sal_Int32 nVariant);
+
+    void Layout (void);
+    void LayoutColumn(
+        ColumnData& rColumn,
+        const sal_Int32 nX,
+        const sal_Int32 nColumnIndex);
+
+    void DistributeWidth (const sal_Int32 nTotalWidth);
+    sal_Int32 GetMinimumColumnWidth (
+        ColumnData& rColumn,
+        const ColumnDescriptor& rDescriptor) const;
+
+    void Paint (void);
+
+    Window& mrParent;
+    ::std::vector<ColumnData> maColumns;
+    ::std::vector<ColumnDescriptor> maColumnDescriptors;
+};
+
+#define ForAllColumnDescriptors(I)                              \
+    for (::std::vector<ColumnDescriptor>::iterator              \
+             I(maColumnDescriptors.begin()),                    \
+             iEnd(maColumnDescriptors.end());                   \
+         I!=iEnd;                                               \
+         ++I)
+
+#define ForAllColumns(I,N)                                      \
+    sal_Int32 N (0);                                            \
+    for (::std::vector<ColumnData>::iterator                    \
+             I(maColumns.begin()),                              \
+             iEnd(maColumns.end());                             \
+         I!=iEnd;                                               \
+         ++I,++N)
+
+#define ForAllRows(ColumnData,I)                                \
+    for (std::vector<CellData>::iterator                        \
+             I((ColumnData).begin()),                           \
+             iRowEnd((ColumnData).end());                       \
+         I!=iRowEnd;                                            \
+         ++I)
+
+#define ForAllCells(CellData,I)                                 \
+    for (::std::vector<CellDescriptor>::iterator                \
+             I((CellData).begin()),                             \
+             iCellEnd((CellData).end());                        \
+         I!=iCellEnd;                                           \
+         ++I)
+
+
+//===== GridLayouter ==========================================================
+
+GridLayouter::GridLayouter (Window& rParent)
+    : mpImplementation(new Implementation(rParent))
+{
+}
+
+
+
+
+GridLayouter::~GridLayouter (void)
+{
+}
+
+
+
+
+CellDescriptor& GridLayouter::GetCell (
+    const sal_Int32 nRow,
+    const sal_Int32 nColumn,
+    const sal_Int32 nVariant)
+{
+    return mpImplementation->GetCell(nRow, nColumn, nVariant);
+}
+
+
+
+
+ColumnDescriptor& GridLayouter::GetColumn (
+    const sal_Int32 nColumn)
+{
+    // Make sure that the specified column exists.
+    mpImplementation->GetCell(0, nColumn, 0);
+    return mpImplementation->maColumnDescriptors[nColumn];
+}
+
+
+
+
+void GridLayouter::Layout (void)
+{
+    mpImplementation->Layout();
+}
+
+
+
+
+void GridLayouter::Paint (const Rectangle& rBox)
+{
+    (void)rBox;
+
+    mpImplementation->Paint();
+}
+
+
+
+
+//===== CellDescriptor ========================================================
+
+CellDescriptor::CellDescriptor (void)
+    : mpControl(NULL),
+      mnGridWidth(1),
+      mnMinimumWidth(-1),
+      mnMaximumWidth(-1),
+      mnOffset(0)
+{
+}
+
+
+
+
+CellDescriptor::~CellDescriptor (void)
+{
+}
+
+
+
+
+CellDescriptor& CellDescriptor::SetGridWidth (const sal_Int32 nColumnCount)
+{
+    mnGridWidth = nColumnCount;
+    return *this;
+}
+
+
+
+
+CellDescriptor& CellDescriptor::SetControl (Window& rControl)
+{
+    mpControl = &rControl;
+    return *this;
+}
+
+
+
+
+CellDescriptor& CellDescriptor::SetFixedWidth (const sal_Int32 nWidth)
+{
+    mnMinimumWidth = nWidth;
+    mnMaximumWidth = nWidth;
+    return *this;
+}
+
+
+
+CellDescriptor& CellDescriptor::SetOffset (const sal_Int32 nOffset)
+{
+    mnOffset = nOffset;
+    return *this;
+}
+
+
+
+
+CellDescriptor& CellDescriptor::SetFixedWidth (void)
+{
+    sal_Int32 nMaxControlWidth (0);
+    if (mpControl != NULL)
+    {
+        const sal_Int32 nControlWidth (mpControl->GetSizePixel().Width());
+        if (nControlWidth > nMaxControlWidth)
+            nMaxControlWidth = nControlWidth;
+    }
+    mnMinimumWidth = nMaxControlWidth;
+    mnMaximumWidth = nMaxControlWidth;
+
+    return *this;
+}
+
+
+
+
+CellDescriptor& CellDescriptor::SetMinimumWidth (const sal_Int32 nWidth)
+{
+    mnMinimumWidth = nWidth;
+    return *this;
+}
+
+
+
+sal_Int32 CellDescriptor::GetGridWidth (void) const
+{
+    return mnGridWidth;
+}
+
+
+
+
+Window* CellDescriptor::GetControl (void) const
+{
+    return mpControl;
+}
+
+
+
+
+sal_Int32 CellDescriptor::GetMinimumWidth (void) const
+{
+    return mnMinimumWidth + mnOffset;
+}
+
+
+
+
+sal_Int32 CellDescriptor::GetMaximumWidth (void) const
+{
+    return mnMaximumWidth;
+}
+
+
+
+sal_Int32 CellDescriptor::GetOffset (void) const
+{
+    return mnOffset;
+}
+
+
+
+
+//===== GridLayouter::Implementation ==========================================
+
+GridLayouter::Implementation::Implementation (Window& rParent)
+    : mrParent(rParent),
+      maColumns(),
+      maColumnDescriptors()
+{
+}
+
+
+
+
+GridLayouter::Implementation::~Implementation (void)
+{
+}
+
+
+
+
+CellDescriptor& GridLayouter::Implementation::GetCell (
+    const sal_Int32 nRow,
+    const sal_Int32 nColumn,
+    const sal_Int32 nVariant)
+{
+    if (nColumn<0 || nRow<0 || nVariant<0)
+    {
+        OSL_ASSERT(nColumn>=0);
+        OSL_ASSERT(nRow>=0);
+        OSL_ASSERT(nVariant>=0);
+        return GetCell(0,0,0);
+    }
+
+    // Provide missing columns.
+    if (maColumns.size() <= static_cast<size_t>(nColumn))
+    {
+        maColumns.resize(nColumn+1);
+        maColumnDescriptors.resize(nColumn+1);
+    }
+
+    // Provide missing rows.
+    ColumnData& rColumn (maColumns[nColumn]);
+    if (rColumn.size() <= static_cast<size_t>(nRow))
+        rColumn.resize(nRow+1);
+
+    // Provide missing variants.
+    CellData& rCellData (rColumn[nRow]);
+    if (rCellData.size() <= static_cast<size_t>(nVariant))
+        rCellData.resize(nVariant+1);
+
+    return rCellData[nVariant];
+}
+
+
+
+
+void GridLayouter::Implementation::Layout (void)
+{
+    if (maColumns.empty())
+    {
+        // There are no columns and therefore no controls => nothing
+        // to do.
+        return;
+    }
+
+    const Size aParentSize (mrParent.GetSizePixel());
+
+    // Determine the total column weight.
+    sal_Int32 nTotalColumnWeight (0);
+    ForAllColumnDescriptors(iDescriptor)
+        nTotalColumnWeight += iDescriptor->GetWeight();
+    if (nTotalColumnWeight <= 0)
+    {
+        OSL_ASSERT(nTotalColumnWeight>0);
+        return;
+    }
+
+    // Distribute the width of the parent window to the columns.
+    DistributeWidth(aParentSize.Width());
+
+    // Set the new positions and widths.
+    sal_Int32 nX (0);
+    ForAllColumns(iColumn,nColumnIndex)
+    {
+        LayoutColumn(
+            *iColumn,
+            nX,
+            nColumnIndex);
+
+        nX += maColumnDescriptors[nColumnIndex].GetWidth();
+    }
+}
+
+
+
+
+void GridLayouter::Implementation::LayoutColumn(
+    ColumnData& rColumn,
+    const sal_Int32 nX,
+    const sal_Int32 nColumnIndex)
+{
+    ColumnDescriptor& rDescriptor (maColumnDescriptors[nColumnIndex]);
+    const sal_Int32 nLeft (nX + rDescriptor.GetLeftPadding());
+    const sal_Int32 nWidth (rDescriptor.GetWidth() - rDescriptor.GetLeftPadding() - rDescriptor.GetRightPadding());
+
+    sal_Int32 nRow (-1);
+    ForAllRows(rColumn, iCell)
+    {
+        ++nRow;
+
+        ForAllCells(*iCell, iCellDescriptor)
+        {
+            Window* pControl = iCellDescriptor->GetControl();
+            if (pControl==NULL || ! pControl->IsVisible())
+                continue;
+
+            sal_Int32 nCellWidth (nWidth);
+            const sal_Int32 nGridWidth (iCellDescriptor->GetGridWidth());
+            if (nGridWidth < 0)
+                continue;
+            else if (nGridWidth > 1)
+            {
+                // Cell spans more than one column.  Sum all their
+                // widths.
+                for (sal_Int32 nOffset=1;
+                     nOffset<nGridWidth && static_cast<size_t>(nColumnIndex+nOffset)<maColumnDescriptors.size();
+                     ++nOffset)
+                {
+                    nCellWidth += maColumnDescriptors[nColumnIndex+nOffset].GetWidth();
+                }
+                nCellWidth -= maColumnDescriptors[nColumnIndex+nGridWidth-1].GetRightPadding();
+            }
+
+            // Check width against valid range of cell.
+            if (iCellDescriptor->GetMinimumWidth() > 0)
+                if (nCellWidth < iCellDescriptor->GetMinimumWidth())
+                    nCellWidth = iCellDescriptor->GetMinimumWidth();
+            if (iCellDescriptor->GetMaximumWidth() > 0)
+                if (nCellWidth > iCellDescriptor->GetMaximumWidth())
+                    nCellWidth = iCellDescriptor->GetMaximumWidth();
+
+            pControl->SetPosSizePixel(
+                nLeft + iCellDescriptor->GetOffset(),
+                0,
+                nCellWidth,
+                0,
+                WINDOW_POSSIZE_X | WINDOW_POSSIZE_WIDTH);
+        }
+    }
+}
+
+
+
+
+void GridLayouter::Implementation::DistributeWidth (const sal_Int32 nTotalWidth)
+{
+    // Prepare width distribution:
+    // a) Setup minimum widths for all columns.
+    // b) Sum up the width of columns that have zero weight.
+    // c) Sum up the non-zero weights.
+    sal_Int32 nZeroWeightWidth (0);
+    sal_Int32 nTotalColumnWeight (0);
+    for (sal_uInt32 nColumn=0; nColumn<maColumns.size(); ++nColumn)
+    {
+        ColumnDescriptor& rDescriptor (maColumnDescriptors[nColumn]);
+        ColumnData& rColumn (maColumns[nColumn]);
+
+        const sal_Int32 nWidth (GetMinimumColumnWidth(rColumn, rDescriptor));
+
+        rDescriptor.SetWidth(nWidth);
+
+        if (rDescriptor.GetWeight() <= 0)
+            nZeroWeightWidth += nWidth;
+        else
+            nTotalColumnWeight += rDescriptor.GetWeight();
+    }
+
+    sal_Int32 nRemainingWidth (nTotalWidth - nZeroWeightWidth);
+    if (nRemainingWidth < 0)
+        nRemainingWidth = 0;
+
+
+    // Distribute the remaining width between columns that have
+    // non-zero width.
+    const sal_Int32 nDistributableWidth (nRemainingWidth);
+    for (sal_uInt32 nColumn=0; nColumn<maColumns.size(); ++nColumn)
+    {
+        ColumnDescriptor& rDescriptor (maColumnDescriptors[nColumn]);
+
+        if (rDescriptor.GetWeight() > 0)
+        {
+            sal_Int32 nWidth (nDistributableWidth * rDescriptor.GetWeight() / nTotalColumnWeight);
+            // Make sure the width lies inside the valid range of
+            // column widths.
+            if (nWidth < rDescriptor.GetWidth())
+                nWidth = rDescriptor.GetWidth();
+            if (rDescriptor.GetMaximumWidth()>0)
+                if (nWidth > rDescriptor.GetTotalMaximumWidth())
+                    nWidth = rDescriptor.GetTotalMaximumWidth();
+
+            rDescriptor.SetWidth(nWidth);
+            nRemainingWidth -= nWidth;
+        }
+    }
+
+    // If there are some pixels left (due to rounding errors), then
+    // give them to the first column that has non-zero weight.
+    if (nRemainingWidth > 0)
+        for (sal_uInt32 nColumn=0; nColumn<maColumns.size(); ++nColumn)
+        {
+            ColumnDescriptor& rDescriptor (maColumnDescriptors[nColumn]);
+            if (rDescriptor.GetWeight() > 0)
+            {
+                rDescriptor.SetWidth(rDescriptor.GetWidth() + nRemainingWidth);
+                break;
+            }
+        }
+}
+
+
+
+
+sal_Int32 GridLayouter::Implementation::GetMinimumColumnWidth (
+    ColumnData& rColumn,
+    const ColumnDescriptor& rDescriptor) const
+{
+    // Start with the minimum width of the whole column.
+    sal_Int32 nMinimumWidth (rDescriptor.GetMinimumWidth());
+
+    // Take also into account the minimum widths of all cells in the column.
+    ForAllRows(rColumn, iCell)
+        ForAllCells(*iCell, iCellDescriptor)
+        {
+            if (iCellDescriptor->GetGridWidth() != 1)
+                continue;
+            const sal_Int32 nMinimumCellWidth (iCellDescriptor->GetMinimumWidth());
+            if (nMinimumCellWidth > nMinimumWidth)
+                nMinimumWidth = nMinimumCellWidth;
+        }
+
+    // Make sure that the minimum width does not become larger than
+    // the maximum width of the column.
+    if (nMinimumWidth > rDescriptor.GetMaximumWidth() && rDescriptor.GetMaximumWidth()>0)
+        nMinimumWidth = rDescriptor.GetMaximumWidth();
+
+    // Add the horizontal padding.
+    return  nMinimumWidth
+        + rDescriptor.GetLeftPadding()
+        + rDescriptor.GetRightPadding();
+}
+
+
+
+
+void GridLayouter::Implementation::Paint (void)
+{
+    const Size aParentSize (mrParent.GetSizePixel());
+
+    static const Color aSeparatorColor (0x66cdaa);
+    static const Color aLeftPaddingColor (0x98fb98);
+    static const Color aRightPaddingColor (0xff69b4);
+    static const Color aControlOverlayColor (0xffff00);
+
+    sal_Int32 nX (0);
+    mrParent.SetLineColor();
+    mrParent.SetFillColor(aLeftPaddingColor);
+    ForAllColumnDescriptors(iColumn)
+    {
+        if (iColumn->GetLeftPadding() > 0)
+        {
+            mrParent.DrawRect(Rectangle(
+                    nX,0,
+                    nX+iColumn->GetLeftPadding(),aParentSize.Height()));
+        }
+
+        nX += iColumn->GetWidth();
+    }
+
+    nX = 0;
+    mrParent.SetFillColor(aRightPaddingColor);
+    ForAllColumnDescriptors(iColumn)
+    {
+        if (iColumn->GetRightPadding() > 0)
+        {
+            const sal_Int32 nRight (nX + iColumn->GetWidth());
+            const sal_Int32 nLeft (nRight - iColumn->GetRightPadding());
+            mrParent.DrawRect(Rectangle(
+                    nLeft,0,
+                    nRight,aParentSize.Height()));
+        }
+
+        nX += iColumn->GetWidth();
+    }
+
+    nX = 0;
+    mrParent.SetFillColor();
+    mrParent.SetLineColor(aSeparatorColor);
+    ForAllColumnDescriptors(iColumn)
+    {
+        mrParent.DrawLine(Point(nX,0), Point(nX,aParentSize.Height()));
+        nX += iColumn->GetWidth();
+    }
+
+    mrParent.SetFillColor();
+    mrParent.SetLineColor(aControlOverlayColor);
+    ForAllColumns(iColumn,nColumnIndex)
+        ForAllRows(*iColumn, iCell)
+            ForAllCells(*iCell, iCellDescriptor)
+            {
+                Window* pControl (iCellDescriptor->GetControl());
+                if (pControl!=NULL && pControl->IsVisible())
+                {
+                    Rectangle aBox (
+                        pControl->GetPosPixel(),
+                        pControl->GetSizePixel());
+                    --aBox.Left();
+                    --aBox.Top();
+                    ++aBox.Right();
+                    ++aBox.Bottom();
+                    mrParent.DrawRect(aBox);
+                }
+            }
+}
+
+
+
+
+//===== ColumnDescriptor ======================================================
+
+ColumnDescriptor::ColumnDescriptor (void)
+    : mnWeight(1),
+      mnMinimumWidth(0),
+      mnMaximumWidth(-1),
+      mnLeftPadding(0),
+      mnRightPadding(0),
+      mnWidth(0)
+{
+}
+
+
+
+
+ColumnDescriptor::~ColumnDescriptor (void)
+{
+}
+
+
+
+
+ColumnDescriptor& ColumnDescriptor::SetWeight (const sal_Int32 nWeight)
+{
+    mnWeight = nWeight;
+
+    return *this;
+}
+
+
+
+
+ColumnDescriptor& ColumnDescriptor::SetMinimumWidth (const sal_Int32 nWidth)
+{
+    mnMinimumWidth = nWidth;
+
+    return *this;
+}
+
+
+
+ColumnDescriptor& ColumnDescriptor::SetFixedWidth (const sal_Int32 nWidth)
+{
+    mnMinimumWidth = nWidth;
+    mnMaximumWidth = nWidth;
+
+    return *this;
+}
+
+
+
+ColumnDescriptor& ColumnDescriptor::SetLeftPadding (const sal_Int32 nPadding)
+{
+    mnLeftPadding = nPadding;
+
+    return *this;
+}
+
+
+
+
+ColumnDescriptor& ColumnDescriptor::SetRightPadding (const sal_Int32 nPadding)
+{
+    mnRightPadding = nPadding;
+
+    return *this;
+}
+
+
+
+
+sal_Int32 ColumnDescriptor::GetWeight (void) const
+{
+    return mnWeight;
+}
+
+
+
+
+sal_Int32 ColumnDescriptor::GetMinimumWidth (void) const
+{
+    return mnMinimumWidth;
+}
+
+
+
+
+sal_Int32 ColumnDescriptor::GetMaximumWidth (void) const
+{
+    return mnMaximumWidth;
+}
+
+
+
+
+sal_Int32 ColumnDescriptor::GetTotalMaximumWidth (void) const
+{
+    return mnMaximumWidth + mnLeftPadding + mnRightPadding;
+}
+
+
+
+
+sal_Int32 ColumnDescriptor::GetLeftPadding (void) const
+{
+    return mnLeftPadding;
+}
+
+
+
+
+sal_Int32 ColumnDescriptor::GetRightPadding (void) const
+{
+    return mnRightPadding;
+}
+
+
+
+
+void ColumnDescriptor::SetWidth (const sal_Int32 nWidth)
+{
+    mnWidth = nWidth;
+}
+
+
+
+
+sal_Int32 ColumnDescriptor::GetWidth (void) const
+{
+    return mnWidth;
+}
+
+} } // end of namespace sfx2::sidebar
diff --git a/sfx2/source/sidebar/Layouter.cxx b/sfx2/source/sidebar/Layouter.cxx
new file mode 100644
index 0000000..8f9bc36
--- /dev/null
+++ b/sfx2/source/sidebar/Layouter.cxx
@@ -0,0 +1,114 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include "precompiled_sfx2.hxx"
+#include "sfx2/sidebar/Layouter.hxx"
+
+#include <vcl/window.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/outdev.hxx>
+
+namespace sfx2 { namespace sidebar {
+
+void Layouter::EnlargeControlHorizontally (
+    Window& rControl,
+    const sal_Int32 nDeltaX)
+{
+    Size aSize (rControl.GetSizePixel());
+    aSize.Width() += nDeltaX;
+    rControl.SetSizePixel(aSize);
+
+}
+
+
+
+
+void Layouter::SetWidth (
+    Window& rControl,
+    const sal_Int32 nWidth)
+{
+    rControl.SetPosSizePixel(
+        0,0,
+        nWidth,0,
+        WINDOW_POSSIZE_WIDTH);
+}
+
+
+
+
+void Layouter::SetRight (
+    Window& rControl,
+    const sal_Int32 nRight)
+{
+    rControl.SetPosSizePixel(
+        0,0,
+        nRight-rControl.GetPosPixel().X(),0,
+        WINDOW_POSSIZE_WIDTH);
+}
+
+
+
+
+void Layouter::MoveControlHorizontally (
+    Window& rControl,
+    const sal_Int32 nDeltaX)
+{
+    Point aPosition (rControl.GetPosPixel());
+    aPosition.Move(nDeltaX, 0);
+    rControl.SetPosPixel(aPosition);
+}
+
+
+
+
+void Layouter::SetHorizontalPosition (
+    Window& rControl,
+    const sal_Int32 nX)
+{
+    rControl.SetPosPixel(Point(nX, rControl.GetPosPixel().Y()));
+}
+
+
+
+
+void Layouter::PrepareForLayouting (
+    Window& rControl)
+{
+    //    rControl.SetStyle(rControl.GetStyle() | WB_PATHELLIPSIS | WB_INFO);
+}
+
+
+
+
+sal_Int32 Layouter::MapX (
+    const Window& rControl,
+    const sal_Int32 nValue)
+{
+    return rControl.LogicToPixel(Point(nValue,0), MAP_APPFONT).X();
+}
+
+
+
+
+sal_Int32 Layouter::MapWidth (
+    const Window& rControl,
+    const sal_Int32 nValue)
+{
+    return rControl.LogicToPixel(Point(nValue,0), MAP_APPFONT).X();
+}
+
+} } // end of namespace sfx2::sidebar
diff --git a/svx/source/sidebar/area/AreaPropertyPanel.cxx b/svx/source/sidebar/area/AreaPropertyPanel.cxx
index c089631..fbdce48 100644
--- a/svx/source/sidebar/area/AreaPropertyPanel.cxx
+++ b/svx/source/sidebar/area/AreaPropertyPanel.cxx
@@ -21,6 +21,7 @@
 #include <sfx2/sidebar/ResourceDefinitions.hrc>
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/sidebar/Layouter.hxx>
 #include <AreaPropertyPanel.hxx>
 #include <AreaPropertyPanel.hrc>
 #include <svx/dialogs.hrc>
@@ -43,6 +44,7 @@
 
 using namespace css;
 using namespace cssu;
+using ::sfx2::sidebar::Layouter;
 using ::sfx2::sidebar::Theme;
 
 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
@@ -119,10 +121,41 @@ AreaPropertyPanel::AreaPropertyPanel(
       mpTransparanceItem(),
       mxFrame(rxFrame),
       mpBindings(pBindings),
-      mbColorAvail(true)
+      mbColorAvail(true),
+      maLayouter(*this)
 {
     Initialize();
     FreeResource();
+
+    // Setup the grid layouter.
+    const sal_Int32 nMappedMboxWidth (Layouter::MapWidth(*this, MBOX_WIDTH));
+
+    maLayouter.GetCell(0,0).SetControl(*mpColorTextFT).SetGridWidth(3);
+    maLayouter.GetCell(1,0).SetControl(*mpLbFillType);
+    maLayouter.GetCell(1,2,0).SetControl(*mpToolBoxColorBackground).SetFixedWidth();
+    maLayouter.GetCell(1,2,1).SetControl(*mpLbFillAttr);
+
+    maLayouter.GetCell(2,0).SetControl(*mpTrspTextFT).SetGridWidth(3);
+    maLayouter.GetCell(3,0).SetControl(*mpLBTransType);
+    maLayouter.GetCell(3,2,0).SetControl(*mpMTRTransparent);
+    maLayouter.GetCell(3,2,1).SetControl(*mpBTNGradient);
+
+    maLayouter.GetColumn(0)
+        .SetWeight(1)
+        .SetLeftPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL))
+        .SetMinimumWidth(nMappedMboxWidth);
+    maLayouter.GetColumn(1)
+        .SetWeight(0)
+        .SetMinimumWidth(Layouter::MapWidth(*this, CONTROL_SPACING_HORIZONTAL));
+    maLayouter.GetColumn(2)
+        .SetWeight(1)
+        .SetMinimumWidth(nMappedMboxWidth)
+        .SetRightPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL));
+
+    // Make controls that display text handle short widths more
+    // graceful.
+    Layouter::PrepareForLayouting(*mpColorTextFT);
+    Layouter::PrepareForLayouting(*mpTrspTextFT);
 }
 
 
@@ -412,6 +445,8 @@ IMPL_LINK( AreaPropertyPanel, SelectFillTypeHdl, ListBox *, pToolBox )
                 mpLbFillType->Selected();
             }
         }
+
+        maLayouter.Layout();
     }
 
     return 0;
@@ -1097,6 +1132,8 @@ void AreaPropertyPanel::NotifyItemUpdate(
             break;
         }
     }
+
+    maLayouter.Layout();
 }
 
 
@@ -1427,6 +1464,16 @@ sal_Int32 AreaPropertyPanel::GetSelectedTransparencyTypeIndex (void) const
     return mpLBTransType->GetSelectEntryPos();
 }
 
+
+
+
+void AreaPropertyPanel::Resize (void)
+{
+    maLayouter.Layout();
+}
+
+
+
 } } // end of namespace svx::sidebar
 
 // eof
diff --git a/svx/source/sidebar/area/AreaPropertyPanel.hxx b/svx/source/sidebar/area/AreaPropertyPanel.hxx
index caf005a..55284a6 100644
--- a/svx/source/sidebar/area/AreaPropertyPanel.hxx
+++ b/svx/source/sidebar/area/AreaPropertyPanel.hxx
@@ -23,6 +23,7 @@
 #include <vcl/ctrl.hxx>
 #include <sfx2/sidebar/SidebarPanelBase.hxx>
 #include <sfx2/sidebar/ControllerItem.hxx>
+#include <sfx2/sidebar/GridLayouter.hxx>
 #include <svx/xgrad.hxx>
 #include <svx/itemwin.hxx>
 #include <svx/xfillit0.hxx>
@@ -81,6 +82,8 @@ public:
     void SetGradient (const XGradient& rGradient);
     sal_Int32 GetSelectedTransparencyTypeIndex (void) const;
 
+    virtual void Resize (void);
+
 private:
     sal_uInt16                                          meLastXFS;
     Color                                               maLastColor;
@@ -152,6 +155,8 @@ private:
     /// bitfield
     bool                                                mbColorAvail : 1;
 
+    ::sfx2::sidebar::GridLayouter maLayouter;
+
     DECL_LINK(SelectFillTypeHdl, ListBox* );
     DECL_LINK(SelectFillAttrHdl, ListBox* );
     DECL_LINK(ChangeTrgrTypeHdl_Impl, void*);
diff --git a/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx b/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx
index 04bdbf5..25207dc 100644
--- a/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx
+++ b/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx
@@ -18,6 +18,7 @@
 #include <sfx2/sidebar/ResourceDefinitions.hrc>
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/sidebar/Layouter.hxx>
 #include <GraphicPropertyPanel.hxx>
 #include <GraphicPropertyPanel.hrc>
 #include <svx/dialogs.hrc>
@@ -31,12 +32,13 @@
 
 using namespace css;
 using namespace cssu;
+using ::sfx2::sidebar::Layouter;
 using ::sfx2::sidebar::Theme;
 
 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
 
 //////////////////////////////////////////////////////////////////////////////
-// namespace open
+
 
 namespace svx { namespace sidebar {
 
@@ -74,10 +76,58 @@ GraphicPropertyPanel::GraphicPropertyPanel(
     maImgBlue(this, SVX_RES(IMG_BLUE)),
     maImgGamma(this, SVX_RES(IMG_GAMMA)),
     mxFrame(rxFrame),
-    mpBindings(pBindings)
+    mpBindings(pBindings),
+    maLayouter(*this)
 {
     Initialize();
     FreeResource();
+
+    // Setup the grid layouter.
+    maLayouter.GetCell(0,0).SetControl(*mpFtBrightness).SetGridWidth(2);
+    maLayouter.GetCell(1,0).SetControl(*mpMtrBrightness).SetGridWidth(2);
+
+    maLayouter.GetCell(0,3).SetControl(*mpFtContrast).SetGridWidth(2);
+    maLayouter.GetCell(1,3).SetControl(*mpMtrContrast).SetGridWidth(2);
+
+    maLayouter.GetCell(2,0).SetControl(*mpFtColorMode).SetGridWidth(2);
+    maLayouter.GetCell(3,0).SetControl(*mpLBColorMode).SetGridWidth(2);
+
+    maLayouter.GetCell(2,3).SetControl(*mpFtTrans).SetGridWidth(2);
+    maLayouter.GetCell(3,3).SetControl(*mpMtrTrans).SetGridWidth(2);
+
+    maLayouter.GetCell(4,0).SetControl(maImgRed).SetFixedWidth();
+    maLayouter.GetCell(4,1).SetControl(*mpMtrRed);
+
+    maLayouter.GetCell(5,0).SetControl(maImgBlue).SetFixedWidth();
+    maLayouter.GetCell(5,1).SetControl(*mpMtrBlue);
+
+    maLayouter.GetCell(4,3).SetControl(maImgGreen).SetFixedWidth();
+    maLayouter.GetCell(4,4).SetControl(*mpMtrGreen);
+    maLayouter.GetCell(5,3).SetControl(maImgGamma).SetFixedWidth();
+    maLayouter.GetCell(5,4).SetControl(*mpMtrGamma);
+
+    maLayouter.GetColumn(0)
+        .SetWeight(0)
+        .SetLeftPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL));
+    maLayouter.GetColumn(1)
+        .SetWeight(1)
+        .SetMinimumWidth(Layouter::MapWidth(*this, MBOX_WIDTH - 10));
+    maLayouter.GetColumn(2)
+        .SetWeight(0)
+        .SetMinimumWidth(Layouter::MapWidth(*this, CONTROL_SPACING_HORIZONTAL));
+    maLayouter.GetColumn(3)
+        .SetWeight(0);
+    maLayouter.GetColumn(4)
+        .SetWeight(1)
+        .SetMinimumWidth(Layouter::MapWidth(*this, MBOX_WIDTH - 10))
+        .SetRightPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL));
+
+    // Make controls that display text handle short widths more
+    // graceful.
+    Layouter::PrepareForLayouting(*mpFtBrightness);
+    Layouter::PrepareForLayouting(*mpFtContrast);
+    Layouter::PrepareForLayouting(*mpFtColorMode);
+    Layouter::PrepareForLayouting(*mpFtTrans);
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -482,17 +532,19 @@ void GraphicPropertyPanel::NotifyItemUpdate(
 
 
 
-//////////////////////////////////////////////////////////////////////////////
-
 SfxBindings* GraphicPropertyPanel::GetBindings()
 {
     return mpBindings;
 }
 
-//////////////////////////////////////////////////////////////////////////////
-// namespace close
 
-}} // end of namespace ::svx::sidebar
 
-//////////////////////////////////////////////////////////////////////////////
-// eof
+
+void GraphicPropertyPanel::Resize (void)
+{
+    maLayouter.Layout();
+}
+
+
+
+}} // end of namespace ::svx::sidebar
diff --git a/svx/source/sidebar/graphic/GraphicPropertyPanel.hxx b/svx/source/sidebar/graphic/GraphicPropertyPanel.hxx
index d5e0c09..bca9b9c 100644
--- a/svx/source/sidebar/graphic/GraphicPropertyPanel.hxx
+++ b/svx/source/sidebar/graphic/GraphicPropertyPanel.hxx
@@ -21,6 +21,7 @@
 #include <vcl/ctrl.hxx>
 #include <sfx2/sidebar/SidebarPanelBase.hxx>
 #include <sfx2/sidebar/ControllerItem.hxx>
+#include <sfx2/sidebar/GridLayouter.hxx>
 #include <vcl/fixed.hxx>
 #include <boost/scoped_ptr.hpp>
 
@@ -53,6 +54,8 @@ public:
 
     SfxBindings* GetBindings();
 
+    virtual void Resize (void);
+
 private:
     //ui controls
     ::boost::scoped_ptr< FixedText >                    mpFtBrightness;
@@ -94,6 +97,7 @@ private:
 
     cssu::Reference<css::frame::XFrame>                 mxFrame;
     SfxBindings*                                        mpBindings;
+    ::sfx2::sidebar::GridLayouter maLayouter;
 
     DECL_LINK( ModifyBrightnessHdl, void * );
     DECL_LINK( ModifyContrastHdl, void * );
diff --git a/svx/source/sidebar/line/LinePropertyPanel.cxx b/svx/source/sidebar/line/LinePropertyPanel.cxx
index 1330f46..4b2b852 100644
--- a/svx/source/sidebar/line/LinePropertyPanel.cxx
+++ b/svx/source/sidebar/line/LinePropertyPanel.cxx
@@ -18,6 +18,7 @@
 #include <sfx2/sidebar/ResourceDefinitions.hrc>
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/sidebar/Layouter.hxx>
 #include <LinePropertyPanel.hxx>
 #include <LinePropertyPanel.hrc>
 #include <svx/dialogs.hrc>
@@ -55,8 +56,10 @@
 
 using namespace css;
 using namespace cssu;
+using ::sfx2::sidebar::Layouter;
 using ::sfx2::sidebar::Theme;
 
+
 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
 
 namespace {
@@ -201,10 +204,58 @@ LinePropertyPanel::LinePropertyPanel(
     mxFrame(rxFrame),
     mpBindings(pBindings),
     mbColorAvailable(true),
-    mbWidthValuable(true)
+    mbWidthValuable(true),
+    maLayouter(*this)
 {
     Initialize();
     FreeResource();
+
+    // Setup the grid layouter.
+    const sal_Int32 nMappedToolBoxWidth (Layouter::MapWidth(*this, TOOLBOX_WIDTH));
+
+    maLayouter.GetCell(0,0).SetControl(*mpFTWidth);
+    maLayouter.GetCell(1,0).SetControl(*mpTBWidthBackground).SetFixedWidth();
+
+    maLayouter.GetCell(0,2).SetControl(*mpFTColor);
+    maLayouter.GetCell(1,2).SetControl(*mpTBColorBackground).SetFixedWidth();
+
+    maLayouter.GetCell(2,0).SetControl(*mpFTStyle);
+    maLayouter.GetCell(3,0).SetControl(*mpLBStyle);
+
+    maLayouter.GetCell(2,2).SetControl(*mpFTTrancparency);
+    maLayouter.GetCell(3,2).SetControl(*mpMFTransparent);
+
+    maLayouter.GetCell(4,0).SetControl(*mpFTArrow).SetGridWidth(3);
+    maLayouter.GetCell(5,0).SetControl(*mpLBStart);
+    maLayouter.GetCell(5,2).SetControl(*mpLBEnd);
+
+    maLayouter.GetCell(6,0).SetControl(*mpFTEdgeStyle);
+    maLayouter.GetCell(7,0).SetControl(*mpLBEdgeStyle);
+
+    maLayouter.GetCell(6,2).SetControl(*mpFTCapStyle);
+    maLayouter.GetCell(7,2).SetControl(*mpLBCapStyle);
+
+    maLayouter.GetColumn(0)
+        .SetWeight(1)
+        .SetLeftPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL))
+        .SetMinimumWidth(nMappedToolBoxWidth);
+    maLayouter.GetColumn(1)
+        .SetWeight(0)
+        .SetMinimumWidth(Layouter::MapWidth(*this, CONTROL_SPACING_HORIZONTAL));
+    maLayouter.GetColumn(2)
+        .SetWeight(1)
+        .SetRightPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL))
+        .SetMinimumWidth(nMappedToolBoxWidth);
+
+    // Make controls that display text handle short widths more
+    // graceful.
+    Layouter::PrepareForLayouting(*mpFTWidth);
+    Layouter::PrepareForLayouting(*mpFTColor);
+    Layouter::PrepareForLayouting(*mpFTStyle);
+    Layouter::PrepareForLayouting(*mpFTTrancparency);
+    Layouter::PrepareForLayouting(*mpFTArrow);
+    Layouter::PrepareForLayouting(*mpFTEdgeStyle);
+    Layouter::PrepareForLayouting(*mpFTCapStyle);
 }
 
 
@@ -941,6 +992,14 @@ void LinePropertyPanel::EndLineWidthPopupMode (void)
 
 
 
+void LinePropertyPanel::Resize (void)
+{
+    maLayouter.Layout();
+}
+
+
+
+
 void LinePropertyPanel::SetWidthIcon(int n)
 {
     if(n==0)
diff --git a/svx/source/sidebar/line/LinePropertyPanel.hrc b/svx/source/sidebar/line/LinePropertyPanel.hrc
index 13c446e..1d08121 100644
--- a/svx/source/sidebar/line/LinePropertyPanel.hrc
+++ b/svx/source/sidebar/line/LinePropertyPanel.hrc
@@ -21,6 +21,10 @@
 #define CUSTOM_W    74
 #define CUSTOM_H    POPUPPANEL_MARGIN_LARGE * 2 +  TEXT_HEIGHT + 12 +  TEXT_CONTROL_SPACING_VERTICAL
 
+#define TOOLBOX_WIDTH       50
+#define TOOLBOX_HEIGHT      14
+#define LISTBOX_HEIGHT      99
+
 #define FT_COLOR            1
 #define TB_COLOR            2
 #define FT_WIDTH            3
diff --git a/svx/source/sidebar/line/LinePropertyPanel.hxx b/svx/source/sidebar/line/LinePropertyPanel.hxx
index b2f97bd..31f43c7 100644
--- a/svx/source/sidebar/line/LinePropertyPanel.hxx
+++ b/svx/source/sidebar/line/LinePropertyPanel.hxx
@@ -22,6 +22,7 @@
 #include <vcl/ctrl.hxx>
 #include <sfx2/sidebar/SidebarPanelBase.hxx>
 #include <sfx2/sidebar/ControllerItem.hxx>
+#include <sfx2/sidebar/GridLayouter.hxx>
 #include <vcl/fixed.hxx>
 #include <vcl/field.hxx>
 #include <boost/scoped_ptr.hpp>
@@ -87,6 +88,8 @@ public:
 
     void EndLineWidthPopupMode (void);
 
+    virtual void Resize (void);
+
 private:
     //ui controls
     ::boost::scoped_ptr< FixedText >                        mpFTWidth;
@@ -150,6 +153,8 @@ private:
     bool                mbColorAvailable : 1;
     bool                mbWidthValuable : 1;
 
+    ::sfx2::sidebar::GridLayouter maLayouter;
+
     void SetupIcons(void);
     void Initialize();
     void FillLineEndList();
diff --git a/svx/source/sidebar/line/LinePropertyPanel.src b/svx/source/sidebar/line/LinePropertyPanel.src
index e904958..075c0c6 100644
--- a/svx/source/sidebar/line/LinePropertyPanel.src
+++ b/svx/source/sidebar/line/LinePropertyPanel.src
@@ -20,10 +20,6 @@
 #include <svx/dialogs.hrc>
 #include "helpid.hrc"
 
-#define TOOLBOX_WIDTH       50
-#define TOOLBOX_HEIGHT      14
-#define LISTBOX_HEIGHT      99
-
 Control RID_SIDEBAR_LINE_PANEL
 {
     OutputSize = TRUE;
diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
index 83e2a60..4bf8227 100644
--- a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
+++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
@@ -29,6 +29,7 @@
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/ResourceDefinitions.hrc>
 #include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/sidebar/Layouter.hxx>
 #include <sfx2/sidebar/Tools.hxx>
 #include <svx/sidebar/PopupContainer.hxx>
 #include <sfx2/dispatch.hxx>
@@ -45,8 +46,10 @@
 #include <sfx2/objsh.hxx>
 #include <svtools/unitconv.hxx>
 #include <boost/bind.hpp>
+
 using namespace css;
 using namespace cssu;
+using namespace ::sfx2::sidebar;
 using ::sfx2::sidebar::Theme;
 using ::sfx2::sidebar::ControlFactory;
 
@@ -244,6 +247,28 @@ void ParaPropertyPanel::ReSize(bool /* bSize */)
         mxSidebar->requestLayout();
 }
 
+
+
+
+void ParaPropertyPanel::Resize (void)
+{
+    switch (maContext.GetCombinedContext_DI())
+    {
+        case CombinedEnumContext(Application_Calc, Context_DrawText):
+        case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
+        case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
+            ReSize(false);
+            break;
+
+        default:
+            ReSize(true);
+            break;
+    }
+}
+
+
+
+
 void ParaPropertyPanel::EndSpacingPopupMode (void)
 {
     maLineSpacePopup.Hide();
@@ -1513,7 +1538,8 @@ ParaPropertyPanel::ParaPropertyPanel(Window* pParent,
       maBulletsPopup(this, ::boost::bind(&ParaPropertyPanel::CreateBulletsPopupControl, this, _1)),
       maNumberingPopup(this, ::boost::bind(&ParaPropertyPanel::CreateNumberingPopupControl, this, _1)),
       maBGColorPopup(this, ::boost::bind(&ParaPropertyPanel::CreateBGColorPopupControl, this, _1)),
-      mxSidebar(rxSidebar)
+      mxSidebar(rxSidebar),
+      maLayouter(*this)
 {
     //Alignment
     get(mpAlignToolBox, "horizontalalignment");
diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx b/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx
index 0544850..559d93a 100644
--- a/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx
+++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx
@@ -21,6 +21,7 @@
 #include <vcl/ctrl.hxx>
 #include <sfx2/sidebar/ControllerItem.hxx>
 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <sfx2/sidebar/GridLayouter.hxx>
 #include <editeng/lspcitem.hxx>
 #include <svtools/ctrlbox.hxx>
 #include <svx/sidebar/PanelLayout.hxx>
@@ -185,7 +186,7 @@ private:
     ParaNumberingPopup maNumberingPopup;
     ColorPopup maBGColorPopup;
     cssu::Reference<css::ui::XSidebar> mxSidebar;
-
+    ::sfx2::sidebar::GridLayouter maLayouter;
 
     ParaPropertyPanel (
         Window* pParent,
@@ -223,6 +224,8 @@ private:
     void initial();
     void ReSize(bool bSize);
 
+    // Inherited from vcl Window.
+    virtual void Resize (void);
 
     PopupControl* CreateLineSpacingControl (PopupContainer* pParent);
     PopupControl* CreateBulletsPopupControl (PopupContainer* pParent);
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
index 20879f1..c4a0dc1 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
@@ -18,6 +18,7 @@
 #include <sfx2/sidebar/ResourceDefinitions.hrc>
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/sidebar/Layouter.hxx>
 #include "PosSizePropertyPanel.hxx"
 #include "PosSizePropertyPanel.hrc"
 #include <svx/sidebar/SidebarDialControl.hxx>
@@ -40,6 +41,7 @@
 
 using namespace css;
 using namespace cssu;
+using ::sfx2::sidebar::Layouter;
 using ::sfx2::sidebar::Theme;
 
 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
@@ -116,7 +118,8 @@ PosSizePropertyPanel::PosSizePropertyPanel(
     mbAutoHeight(false),
     mbAdjustEnabled(false),
     mbIsFlip(false),
-    mxSidebar(rxSidebar)
+    mxSidebar(rxSidebar),
+    maLayouter(*this)
 {
     Initialize();
     FreeResource();
@@ -125,6 +128,47 @@ PosSizePropertyPanel::PosSizePropertyPanel(
     mpBindings->Update( SID_ATTR_TRANSFORM_HEIGHT );
     mpBindings->Update( SID_ATTR_TRANSFORM_PROTECT_SIZE );
     mpBindings->Update( SID_ATTR_METRIC );
+
+    // Setup the grid layouter.
+    const sal_Int32 nMappedMboxWidth (Layouter::MapWidth(*this, MBOX_WIDTH));
+
+    maLayouter.GetCell(0,0).SetControl(*mpFtPosX);
+    maLayouter.GetCell(1,0).SetControl(*mpMtrPosX);
+
+    maLayouter.GetCell(0,2).SetControl(*mpFtPosY);
+    maLayouter.GetCell(1,2).SetControl(*mpMtrPosY);
+
+    maLayouter.GetCell(2,0).SetControl(*mpFtWidth);
+    maLayouter.GetCell(3,0).SetControl(*mpMtrWidth);
+
+    maLayouter.GetCell(2,2).SetControl(*mpFtHeight);
+    maLayouter.GetCell(3,2).SetControl(*mpMtrHeight);
+
+    maLayouter.GetCell(4,0).SetControl(*mpCbxScale).SetGridWidth(3);
+    maLayouter.GetCell(5,0).SetControl(*mpFtAngle).SetGridWidth(3);
+
+
+    maLayouter.GetColumn(0)
+        .SetWeight(1)
+        .SetLeftPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL))
+        .SetMinimumWidth(nMappedMboxWidth);
+    maLayouter.GetColumn(1)
+        .SetWeight(0)
+        .SetMinimumWidth(Layouter::MapWidth(*this, CONTROL_SPACING_HORIZONTAL));
+    maLayouter.GetColumn(2)
+        .SetWeight(1)
+        .SetRightPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL))
+        .SetMinimumWidth(nMappedMboxWidth);
+
+    // Make controls that display text handle short widths more
+    // graceful.
+    Layouter::PrepareForLayouting(*mpFtPosX);
+    Layouter::PrepareForLayouting(*mpFtPosY);
+    Layouter::PrepareForLayouting(*mpFtWidth);
+    Layouter::PrepareForLayouting(*mpFtHeight);
+    Layouter::PrepareForLayouting(*mpCbxScale);
+    Layouter::PrepareForLayouting(*mpFtAngle);
+
 }
 
 
@@ -178,6 +222,15 @@ namespace
 
 
 
+
+void PosSizePropertyPanel::Resize (void)
+{
+    maLayouter.Layout();
+}
+
+
+
+
 void PosSizePropertyPanel::Initialize()
 {
     mpFtPosX->SetBackground(Wallpaper());
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx
index 29d9289..cb03075 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx
@@ -22,6 +22,7 @@
 #include <sfx2/sidebar/SidebarPanelBase.hxx>
 #include <sfx2/sidebar/ControllerItem.hxx>
 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <sfx2/sidebar/GridLayouter.hxx>
 #include <boost/scoped_ptr.hpp>
 #include <svx/rectenum.hxx>
 #include <svl/poolitem.hxx>
@@ -67,6 +68,8 @@ public:
     SfxBindings* GetBindings();
     void ShowMenu (void);
 
+    virtual void Resize (void);
+
 private:
     //Position
     ::boost::scoped_ptr< FixedText >        mpFtPosX;
@@ -147,6 +150,7 @@ private:
     bool                                    mbIsFlip : 1;
 
     cssu::Reference<css::ui::XSidebar> mxSidebar;
+    ::sfx2::sidebar::GridLayouter maLayouter;
 
     DECL_LINK( ChangePosXHdl, void * );
     DECL_LINK( ChangePosYHdl, void * );
diff --git a/svx/source/sidebar/text/TextPropertyPanel.cxx b/svx/source/sidebar/text/TextPropertyPanel.cxx
index 68382b1..3b36f90 100644
--- a/svx/source/sidebar/text/TextPropertyPanel.cxx
+++ b/svx/source/sidebar/text/TextPropertyPanel.cxx
@@ -40,6 +40,7 @@
 #include <sfx2/sidebar/ResourceDefinitions.hrc>
 #include <sfx2/sidebar/ControlFactory.hxx>
 #include <sfx2/sidebar/ControllerFactory.hxx>
+#include <sfx2/sidebar/Layouter.hxx>
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/SidebarToolBox.hxx>
 #include "sfx2/imagemgr.hxx"
@@ -60,8 +61,10 @@
 
 using namespace css;
 using namespace cssu;
+using namespace ::sfx2::sidebar;
 using ::sfx2::sidebar::Theme;
 using ::sfx2::sidebar::ControlFactory;
+using ::sfx2::sidebar::Layouter;
 
 const char UNO_BACKCOLOR[] = ".uno:BackColor";
 const char UNO_BOLD[] = ".uno:Bold";
@@ -79,6 +82,9 @@ const char UNO_UNDERLINE[] = ".uno:Underline";
 
 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
 
+
+
+
 namespace svx { namespace sidebar {
 
 #undef HAS_IA2
@@ -153,7 +159,8 @@ TextPropertyPanel::TextPropertyPanel ( Window* pParent, const cssu::Reference<cs
         maCharSpacePopup(this, ::boost::bind(&TextPropertyPanel::CreateCharacterSpacingControl, this, _1)),
         maUnderlinePopup(this, ::boost::bind(&TextPropertyPanel::CreateUnderlinePopupControl, this, _1)),
         maContext(),
-        mpBindings(pBindings)
+        mpBindings(pBindings),
+        maLayouter(*this)
 {
     get(mpFontNameBox, "font");
     get(mpFontSizeBox, "fontsize");
@@ -166,6 +173,23 @@ TextPropertyPanel::TextPropertyPanel ( Window* pParent, const cssu::Reference<cs
     Initialize();
 
     UpdateFontColorToolbox(rContext);
+
+    // Setup the grid layouter.
+    maLayouter.GetCell(0,0).SetControl(*mpFontNameBox).SetMinimumWidth(Layouter::MapWidth(*this,FONTNAME_WIDTH));
+    maLayouter.GetCell(0,2).SetControl(maFontSizeBox).SetFixedWidth();
+
+    maLayouter.GetCell(1,0).SetControl(*mpToolBoxFontBackground).SetFixedWidth();
+    maLayouter.GetCell(1,2).SetControl(*mpToolBoxIncDecBackground).SetFixedWidth();
+
+    maLayouter.GetColumn(0)
+        .SetWeight(1)
+        .SetLeftPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL));
+    maLayouter.GetColumn(1)
+        .SetWeight(0)
+        .SetMinimumWidth(Layouter::MapWidth(*this, CONTROL_SPACING_HORIZONTAL));
+    maLayouter.GetColumn(2)
+        .SetWeight(0)
+        .SetRightPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL));
 }
 
 
@@ -1091,6 +1115,14 @@ void TextPropertyPanel::NotifyItemUpdate (
 
 
 
+void TextPropertyPanel::Resize (void)
+{
+    maLayouter.Layout();
+}
+
+
+
+
 void TextPropertyPanel::UpdateItem (const sal_uInt16 nSlotId)
 {
     switch (nSlotId)
diff --git a/svx/source/sidebar/text/TextPropertyPanel.hxx b/svx/source/sidebar/text/TextPropertyPanel.hxx
index 342b9a9..92d0b4e 100644
--- a/svx/source/sidebar/text/TextPropertyPanel.hxx
+++ b/svx/source/sidebar/text/TextPropertyPanel.hxx
@@ -23,6 +23,7 @@
 #include <sfx2/sidebar/ControllerItem.hxx>
 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
 #include <sfx2/sidebar/EnumContext.hxx>
+#include <sfx2/sidebar/GridLayouter.hxx>
 
 #include <svtools/ctrlbox.hxx>
 #include <svx/tbxcolorupdate.hxx>
@@ -82,6 +83,9 @@ public:
         const SfxPoolItem* pState,
         const bool bIsEnabled);
 
+    // Inherited from vcl Window.
+    virtual void Resize (void);
+
 private:
     //ui controls
     SvxSBFontNameBox* mpFontNameBox;
@@ -131,6 +135,7 @@ private:
 
     ::sfx2::sidebar::EnumContext maContext;
     SfxBindings* mpBindings;
+    ::sfx2::sidebar::GridLayouter maLayouter;
 
     TextPropertyPanel (
         Window* pParent,
diff --git a/sw/source/ui/sidebar/PagePropertyPanel.cxx b/sw/source/ui/sidebar/PagePropertyPanel.cxx
index 5c14cf9..d66920a 100644
--- a/sw/source/ui/sidebar/PagePropertyPanel.cxx
+++ b/sw/source/ui/sidebar/PagePropertyPanel.cxx
@@ -38,6 +38,8 @@
 #include <svx/rulritem.hxx>
 
 #include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/sidebar/Layouter.hxx>
+#include <sfx2/sidebar/ResourceDefinitions.hrc>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/bindings.hxx>
 #include <sfx2/viewsh.hxx>
@@ -54,6 +56,8 @@ const char UNO_MARGIN[]      = ".uno:Margin";
 const char UNO_SIZE[]        = ".uno:Size";
 const char UNO_COLUMN[]      = ".uno:Column";
 
+using namespace ::sfx2::sidebar;
+
 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
 
 namespace {
@@ -184,7 +188,8 @@ PagePropertyPanel::PagePropertyPanel(
 
     , mxUndoManager( getUndoManager( rxFrame ) )
 
-    , mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify( false )
+    , mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify( false ),
+      maLayouter(*this)
 {
     // visible controls
     get(mpToolBoxOrientation, "selectorientation");
@@ -196,6 +201,9 @@ PagePropertyPanel::PagePropertyPanel(
     mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify = true;
 }
 
+
+
+
 PagePropertyPanel::~PagePropertyPanel()
 {
     delete[] maImgSize;
@@ -769,4 +777,16 @@ void PagePropertyPanel::EndUndo()
     }
 }
 
+
+
+
+void PagePropertyPanel::Resize (void)
+{
+    maLayouter.Layout();
+}
+
+
+
+
+
 } } // end of namespace ::sw::sidebar
diff --git a/sw/source/ui/sidebar/PagePropertyPanel.hxx b/sw/source/ui/sidebar/PagePropertyPanel.hxx
index c1f34af..db4487f 100644
--- a/sw/source/ui/sidebar/PagePropertyPanel.hxx
+++ b/sw/source/ui/sidebar/PagePropertyPanel.hxx
@@ -25,6 +25,7 @@
 #include <svx/sidebar/PanelLayout.hxx>
 
 #include <sfx2/sidebar/ControllerItem.hxx>
+#include <sfx2/sidebar/GridLayouter.hxx>
 
 namespace svx { namespace sidebar {
     class PopupControl;
@@ -100,6 +101,9 @@ namespace sw { namespace sidebar {
         void StartUndo();
         void EndUndo();
 
+        // Inherited from vcl Window.
+        virtual void Resize (void);
+
     private:
         PagePropertyPanel(
             Window* pParent,
@@ -200,6 +204,7 @@ namespace sw { namespace sidebar {
         const cssu::Reference< css::document::XUndoManager > mxUndoManager;
 
         bool mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify;
+        ::sfx2::sidebar::GridLayouter maLayouter;
 
         // handler for popup toolboxes to show the popups
         DECL_LINK(ClickOrientationHdl, ToolBox* );


More information about the Libreoffice-commits mailing list