[Libreoffice-commits] .: Branch 'feature/cmclayout' - 10 commits - sw/Package_uiconfig.mk sw/uiconfig vcl/inc vcl/source

Caolán McNamara caolan at kemper.freedesktop.org
Fri Jun 15 07:46:42 PDT 2012


 sw/Package_uiconfig.mk         |    1 
 sw/uiconfig/sw/ui/20872.ui     |  445 +++++++++++++++++++++++++++++++++++++++++
 vcl/inc/vcl/builder.hxx        |   26 ++
 vcl/inc/vcl/field.hxx          |    4 
 vcl/source/control/field.cxx   |   33 ++-
 vcl/source/control/lstbox.cxx  |    3 
 vcl/source/control/tabctrl.cxx |   20 -
 vcl/source/window/builder.cxx  |   92 ++++++++
 vcl/source/window/layout.cxx   |   58 +++++
 9 files changed, 663 insertions(+), 19 deletions(-)

New commits:
commit 11afac949068dcf04c4fff904005d89783be8e9b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 15 13:35:15 2012 +0100

    keep empty but spanned rows/cols

diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index ae1f81a..e74ebdf 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -105,6 +105,8 @@ Size VclBox::calculateRequisition() const
 
 void VclBox::setAllocation(const Size &rAllocation)
 {
+    //SetBackground( Color(0x00, 0xFF, 0x00) );
+
     rtl::OString sExpand(RTL_CONSTASCII_STRINGPARAM("expand"));
 
     sal_uInt16 nVisibleChildren = 0, nExpandChildren = 0;
@@ -391,8 +393,13 @@ VclGrid::array_type VclGrid::assembleGrid() const
             const Window *pChild = A[x][y];
             if (pChild)
             {
-                aNonEmptyCols[x] = true;
-                aNonEmptyRows[y] = true;
+                sal_Int32 nWidth = pChild->getWidgetProperty<sal_Int32>(sWidth, 1);
+                for (sal_Int32 nSpanX = 0; nSpanX < nWidth; ++nSpanX)
+                    aNonEmptyCols[x+nSpanX] = true;
+
+                sal_Int32 nHeight = pChild->getWidgetProperty<sal_Int32>(sHeight, 1);
+                for (sal_Int32 nSpanY = 0; nSpanY < nHeight; ++nSpanY)
+                    aNonEmptyRows[y+nSpanY] = true;
             }
         }
     }
@@ -505,6 +512,8 @@ Size VclGrid::calculateRequisition() const
 
 void VclGrid::setAllocation(const Size& rAllocation)
 {
+    //SetBackground( Color(0xFF, 0x00, 0x00) );
+
     array_type A = assembleGrid();
 
     if (isNullGrid(A))
@@ -719,6 +728,8 @@ Size VclFrame::calculateRequisition() const
 
 void VclFrame::setAllocation(const Size &rAllocation)
 {
+    //SetBackground( Color(0xFF, 0x00, 0xFF) );
+
     const FrameStyle &rFrameStyle =
         GetSettings().GetStyleSettings().GetFrameStyle();
     Size aAllocation(rAllocation.Width() - rFrameStyle.left - rFrameStyle.right,
@@ -763,6 +774,8 @@ Size VclAlignment::calculateRequisition() const
 
 void VclAlignment::setAllocation(const Size &rAllocation)
 {
+    //SetBackground( Color(0x00, 0x00, 0xFF) );
+
     Window *pChild = get_child();
     if (!pChild || !pChild->IsVisible())
         return;
commit 7ae01e3bd8acd58745f44cad3ab061d705eb2885
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 15 12:33:10 2012 +0100

    zero-code-change outline numbering dialog layout conversion
    
    a conversion of the outline numbering dialog in writer
    to layout enabled widgets built from a .ui file without
    changing any dialog code
    
    Actual code conversion is optimal in terms of load time,
    memory usage and code size/simplicity.

diff --git a/sw/Package_uiconfig.mk b/sw/Package_uiconfig.mk
index ac84d2a..414630d 100644
--- a/sw/Package_uiconfig.mk
+++ b/sw/Package_uiconfig.mk
@@ -30,6 +30,7 @@ $(eval $(call gb_Package_Package,sw_uiconfig,$(SRCDIR)/sw/uiconfig))
 
 $(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/modules/swriter/ui/titlepage.ui,swriter/ui/titlepage.ui))
 $(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/sw/ui/20705.ui,sw/ui/20705.ui))
+$(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/sw/ui/20872.ui,sw/ui/20872.ui))
 $(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/sw/ui/20876.ui,sw/ui/20876.ui))
 
 $(eval $(call gb_Package_add_file,sw_uiconfig,xml/uiconfig/modules/sglobal/menubar/menubar.xml,sglobal/menubar/menubar.xml))
diff --git a/sw/uiconfig/sw/ui/20872.ui b/sw/uiconfig/sw/ui/20872.ui
new file mode 100644
index 0000000..777d049
--- /dev/null
+++ b/sw/uiconfig/sw/ui/20872.ui
@@ -0,0 +1,445 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkAdjustment" id="adjustment1">
+    <property name="upper">19.989999999999998</property>
+    <property name="step_increment">0.050000000000000003</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment2">
+    <property name="lower">-19.989999999999998</property>
+    <property name="upper">19.989999999999998</property>
+    <property name="step_increment">0.050000000000000003</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkListStore" id="liststore1">
+    <columns>
+      <!-- column-name gchararray1 -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Left</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Centered</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Right</col>
+      </row>
+    </data>
+  </object>
+  <object class="GtkBox" id="20872">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="margin_left">10</property>
+    <property name="margin_right">10</property>
+    <child>
+      <object class="GtkFrame" id="frame3">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label_xalign">0</property>
+        <property name="shadow_type">none</property>
+        <child>
+          <object class="GtkAlignment" id="alignment5">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="left_padding">12</property>
+            <child>
+              <object class="GtkTreeView" id="2">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="headers_visible">False</property>
+                <property name="search_column">0</property>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection" id="treeview-selection6"/>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child type="label">
+          <object class="GtkLabel" id="1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Level</property>
+            <property name="use_markup">True</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkFrame" id="frame4">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label_xalign">0</property>
+        <property name="shadow_type">none</property>
+        <child>
+          <object class="GtkAlignment" id="alignment6">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="left_padding">12</property>
+            <child>
+              <object class="GtkBox" id="box6">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkGrid" id="grid1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="row_spacing">10</property>
+                    <property name="column_spacing">10</property>
+                    <child>
+                      <object class="GtkLabel" id="17">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Numbering followed by</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="21">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Numbering Alignment</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="23">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Aligned at</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">3</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="25">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Indent at</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">4</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBox" id="22">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="26">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="invisible_char_set">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">4</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="19">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes">at</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="20">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="invisible_char_set">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="24">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="invisible_char_set">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">3</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBox" id="18">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="model">liststore2</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkDrawingArea" id="15">
+                        <property name="width_request">300</property>
+                        <property name="height_request">150</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">10</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="13">
+                        <property name="label" translatable="yes">Default</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="valign">end</property>
+                        <property name="use_action_appearance">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">10</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Indent</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">5</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="5">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="adjustment">adjustment2</property>
+                        <property name="digits">2</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">5</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="6">
+                        <property name="label" translatable="yes">Relative</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">6</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="7">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Width of numbering</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">7</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="8">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="adjustment">adjustment1</property>
+                        <property name="digits">2</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">7</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="10">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="adjustment">adjustment1</property>
+                        <property name="digits">2</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">8</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="9">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Minimum space numbering &lt;-&gt; textlabel</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">8</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="11">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Numbering alignment</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">9</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBox" id="12">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="model">liststore1</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">9</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child type="label">
+          <object class="GtkLabel" id="3">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Position and spacing</property>
+            <property name="use_markup">True</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">True</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+  </object>
+  <object class="GtkListStore" id="liststore2">
+    <columns>
+      <!-- column-name gchararray1 -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Tap stop</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Space</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Nothing</col>
+      </row>
+    </data>
+  </object>
+</interface>
commit 20b02044e402557bc9cf000e212c6eb4634cd954
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 15 12:30:19 2012 +0100

    adjustment implementation

diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
index d62d126..7a21a99 100644
--- a/vcl/inc/vcl/builder.hxx
+++ b/vcl/inc/vcl/builder.hxx
@@ -36,9 +36,12 @@
 #include <vector>
 
 class ListBox;
+class MetricField;
 
 class VCL_DLLPUBLIC VclBuilder
 {
+public:
+    typedef std::map<rtl::OString, rtl::OString> stringmap;
 private:
     //todo merge into Windows UniqueID/HelpID ?
     struct WinAndId
@@ -91,6 +94,25 @@ private:
     ListStore *get_model_by_name(rtl::OString sID);
     static void mungemodel(ListBox &rTarget, ListStore &rStore);
 
+    typedef stringmap Adjustment;
+
+    struct AdjustmentAndId
+    {
+        rtl::OString m_sID;
+        Adjustment m_aAdjustment;
+        AdjustmentAndId(const rtl::OString &rId, Adjustment &rAdjustment)
+            : m_sID(rId)
+        {
+            m_aAdjustment.swap(rAdjustment);
+        }
+    };
+    std::vector<AdjustmentAndId> m_aAdjustments;
+
+    typedef StringPair SpinButtonAdjustmentMap;
+    std::vector<SpinButtonAdjustmentMap> m_aAdjustmentMaps;
+    Adjustment *get_adjustment_by_name(rtl::OString sID);
+    static void mungeadjustment(MetricField &rTarget, Adjustment &rAdjustment);
+
     rtl::OString m_sID;
     Window *m_pParent;
 public:
@@ -104,13 +126,12 @@ public:
     //splice replacement into the tree instead of it, without
     //taking ownership of it
     bool replace(rtl::OString sID, Window &rReplacement);
-
-    typedef std::map<rtl::OString, rtl::OString> stringmap;
 private:
     Window *insertObject(Window *pParent, const rtl::OString &rClass, const rtl::OString &rID, stringmap &rVec);
     Window *makeObject(Window *pParent, const rtl::OString &rClass, const rtl::OString &rID, stringmap &rVec);
     bool extractGroup(const rtl::OString &id, stringmap &rVec);
     bool extractModel(const rtl::OString &id, stringmap &rVec);
+    bool extractAdjustment(const rtl::OString &id, stringmap &rVec);
 
     void handleChild(Window *pParent, xmlreader::XmlReader &reader);
     Window* handleObject(Window *pParent, xmlreader::XmlReader &reader);
@@ -119,6 +140,7 @@ private:
     void collectProperty(xmlreader::XmlReader &reader, stringmap &rVec);
 
     void handleListStore(xmlreader::XmlReader &reader, const rtl::OString &rID);
+    void handleAdjustment(const rtl::OString &rID, stringmap &rProperties);
     void handleTabChild(Window *pParent, xmlreader::XmlReader &reader);
 
     //Helpers to retrofit all the existing code the the builder
commit 72bbdd7a741e5cbd167a1106f2df2489b4855936
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 15 12:29:25 2012 +0100

    improve TabControl::GetOptimalSize

diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index ccf6b4c..bca23c8 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -2180,8 +2180,8 @@ Size TabControl::GetOptimalSize(WindowSizeType eType) const
     default:
     {
         Size aOptimalPageSize(0, 0);
-        Size aOptimalTabSize(0, 0);
-        long nTotalTabWidths = 0;
+        long nTabLabelsBottom = 0;
+        long nTotalTabLabelWidths = 0;
 
         for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin();
              it != mpTabCtrlData->maItemList.end(); ++it )
@@ -2198,19 +2198,19 @@ Size TabControl::GetOptimalSize(WindowSizeType eType) const
             if (aPageSize.Height() > aOptimalPageSize.Height())
                 aOptimalPageSize.Height() = aPageSize.Height();
 
-            ImplTabItem* pItem = const_cast<ImplTabItem*>(&(*it));
+            sal_uInt16 nPos = it - mpTabCtrlData->maItemList.begin();
             TabControl* pThis = const_cast<TabControl*>(this);
-            Size aTabSize = pThis->ImplGetItemSize(pItem, LONG_MAX);
-            if (aTabSize.Height() > aOptimalTabSize.Height())
-                aOptimalTabSize.Height() = aTabSize.Height();
-            nTotalTabWidths += aTabSize.Width();
+            Rectangle aTabRect = pThis->ImplGetTabRect(nPos, aPageSize.Width(), aPageSize.Height());
+            if (aTabRect.Bottom() > nTabLabelsBottom)
+                nTabLabelsBottom = aTabRect.Bottom();
+            nTotalTabLabelWidths += aTabRect.GetWidth();
         }
 
         Size aOptimalSize(aOptimalPageSize);
-        aOptimalSize.Height() += aOptimalTabSize.Height();
+        aOptimalSize.Height() += nTabLabelsBottom;
 
-        if (nTotalTabWidths > aOptimalSize.Width())
-            aOptimalSize.Width() = nTotalTabWidths;
+        if (nTotalTabLabelWidths > aOptimalSize.Width())
+            aOptimalSize.Width() = nTotalTabLabelWidths;
 
         aOptimalSize.Width() += TAB_OFFSET * 2;
         aOptimalSize.Height() += TAB_OFFSET * 2;
commit e50f91a6f9d36621c6f1d70c146116353972a2d1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 15 10:19:41 2012 +0100

    drop empty rows/cols in VclGrid

diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 79c63fe..ae1f81a 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
commit 0281ed12365665c5325b74d70bc1b42d6b04a8ad
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 14 21:03:05 2012 +0100

    MultiListBox replace by builder as well

diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index e08ae21..04192ee 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -1587,6 +1587,9 @@ MultiListBox::MultiListBox( Window* pParent, WinBits nStyle ) :
 MultiListBox::MultiListBox( Window* pParent, const ResId& rResId ) :
     ListBox( WINDOW_MULTILISTBOX )
 {
+    if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
+        return;
+
     rResId.SetRT( RSC_MULTILISTBOX );
     WinBits nStyle = ImplInitRes( rResId );
     ImplInit( pParent, nStyle );
commit 79167803f1a1c43193901b4bb721c1c734b6eac4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 14 14:20:49 2012 +0100

    implement GtkAdjustment import + apply

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index e39b6ef..5073ac0 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -64,7 +64,7 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUri, rtl::OString sID)
          aEnd = m_aModelMaps.end(); aI != aEnd; ++aI)
     {
         ListBox *pTarget = static_cast<ListBox*>(get_by_name(aI->m_sID));
-        ListStore *pStore = static_cast<ListStore*>(get_model_by_name(aI->m_sValue));
+        ListStore *pStore = get_model_by_name(aI->m_sValue);
         SAL_WARN_IF(!pTarget || !pStore, "vcl", "missing elements of combobox/liststore");
         if (pTarget && pStore)
             mungemodel(*pTarget, *pStore);
@@ -78,6 +78,20 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUri, rtl::OString sID)
     }
     std::vector<ModelAndId>().swap(m_aModels);
 
+    //Set SpinButton adjustments when everything has been imported
+    for (std::vector<SpinButtonAdjustmentMap>::iterator aI = m_aAdjustmentMaps.begin(),
+         aEnd = m_aAdjustmentMaps.end(); aI != aEnd; ++aI)
+    {
+        MetricField *pTarget = static_cast<MetricField*>(get_by_name(aI->m_sID));
+        Adjustment *pAdjustment = get_adjustment_by_name(aI->m_sValue);
+        SAL_WARN_IF(!pTarget || !pAdjustment, "vcl", "missing elements of spinbutton/adjustment");
+        if (pTarget && pAdjustment)
+            mungeadjustment(*pTarget, *pAdjustment);
+    }
+    //drop maps now
+    std::vector<SpinButtonAdjustmentMap>().swap(m_aAdjustmentMaps);
+    std::vector<AdjustmentAndId>().swap(m_aAdjustments);
+
     //auto-show (really necessary ?, maybe drop it when complete)
     for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(),
          aEnd = m_aChildren.end(); aI != aEnd; ++aI)
@@ -166,6 +180,18 @@ bool VclBuilder::extractGroup(const rtl::OString &id, stringmap &rMap)
     return false;
 }
 
+bool VclBuilder::extractAdjustment(const rtl::OString &id, stringmap &rMap)
+{
+    VclBuilder::stringmap::iterator aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("adjustment")));
+    if (aFind != rMap.end())
+    {
+        m_aAdjustmentMaps.push_back(SpinButtonAdjustmentMap(id, aFind->second));
+        rMap.erase(aFind);
+        return true;
+    }
+    return false;
+}
+
 bool VclBuilder::extractModel(const rtl::OString &id, stringmap &rMap)
 {
     VclBuilder::stringmap::iterator aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("model")));
@@ -243,7 +269,10 @@ Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, const
     else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkCheckButton")))
         pWindow = new CheckBox(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK);
     else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkSpinButton")))
+    {
+        extractAdjustment(id, rMap);
         pWindow = new MetricField(pParent, WB_RIGHT|WB_SPIN|WB_BORDER|WB_3DLOOK);
+    }
     else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkComboBox")))
     {
         extractModel(id, rMap);
@@ -532,6 +561,11 @@ void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader)
     }
 }
 
+void VclBuilder::handleAdjustment(const rtl::OString &rID, stringmap &rProperties)
+{
+    m_aAdjustments.push_back(AdjustmentAndId(rID, rProperties));
+}
+
 void VclBuilder::handleListStore(xmlreader::XmlReader &reader, const rtl::OString &rID)
 {
     m_aModels.push_back(ModelAndId(rID, new ListStore));
@@ -638,6 +672,12 @@ Window* VclBuilder::handleObject(Window *pParent, xmlreader::XmlReader &reader)
             break;
     }
 
+    if (sClass.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkAdjustment")))
+    {
+        handleAdjustment(sID, aProperties);
+        return NULL;
+    }
+
     if (!pCurrentChild)
         pCurrentChild = insertObject(pParent, sClass, sID, aProperties);
 
@@ -793,6 +833,18 @@ VclBuilder::ListStore *VclBuilder::get_model_by_name(rtl::OString sID)
     return NULL;
 }
 
+VclBuilder::Adjustment *VclBuilder::get_adjustment_by_name(rtl::OString sID)
+{
+    for (std::vector<AdjustmentAndId>::iterator aI = m_aAdjustments.begin(),
+         aEnd = m_aAdjustments.end(); aI != aEnd; ++aI)
+    {
+        if (aI->m_sID.equals(sID))
+            return &(aI->m_aAdjustment);
+    }
+
+    return NULL;
+}
+
 void VclBuilder::swapGuts(Window &rOrig, Window &rReplacement)
 {
 #if 1
@@ -867,4 +919,40 @@ void VclBuilder::mungemodel(ListBox &rTarget, ListStore &rStore)
         rTarget.SelectEntryPos(0);
 }
 
+void VclBuilder::mungeadjustment(MetricField &rTarget, Adjustment &rAdjustment)
+{
+    int nMul = rtl_math_pow10Exp(1, rTarget.GetDecimalDigits());
+
+    for (stringmap::iterator aI = rAdjustment.begin(), aEnd = rAdjustment.end(); aI != aEnd; ++aI)
+    {
+        const rtl::OString &rKey = aI->first;
+        const rtl::OString &rValue = aI->second;
+
+        if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("upper")))
+        {
+            sal_Int64 nUpper = rValue.toDouble() * nMul;
+            rTarget.SetMax(nUpper);
+            rTarget.SetLast(nUpper);
+        }
+        else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("lower")))
+        {
+            sal_Int64 nLower = rValue.toDouble() * nMul;
+            rTarget.SetMin(nLower);
+            rTarget.SetFirst(nLower);
+        }
+        else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("value")))
+        {
+            sal_Int64 nValue = rValue.toDouble() * nMul;
+            rTarget.SetValue(nValue);
+        }
+        else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("step-increment")))
+        {
+            sal_Int64 nSpinSize = rValue.toDouble() * nMul;
+            rTarget.SetSpinSize(nSpinSize);
+        }
+        else
+            fprintf(stderr, "unhandled property %s\n", rKey.getStr());
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 6423b7d8142c07ffe2525a53e218157726f1d93e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 14 11:07:59 2012 +0100

    make default dropdown list length shorter

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 144f613..e39b6ef 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -248,7 +248,7 @@ Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, const
     {
         extractModel(id, rMap);
         ListBox *pListBox = new ListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK);
-        pListBox->SetDropDownLineCount(64); //arbitrary
+        pListBox->SetDropDownLineCount(16); //arbitrary
         pWindow = pListBox;
     }
     else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkTreeView")))
commit 74141f89ea99cee0c9bc476404000d50a75b2398
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 14 11:07:22 2012 +0100

    copy properties of metricfields

diff --git a/vcl/inc/vcl/field.hxx b/vcl/inc/vcl/field.hxx
index 0d93209..e7a5eb4 100644
--- a/vcl/inc/vcl/field.hxx
+++ b/vcl/inc/vcl/field.hxx
@@ -218,6 +218,8 @@ public:
 
     sal_Int64               Normalize( sal_Int64 nValue ) const;
     sal_Int64               Denormalize( sal_Int64 nValue ) const;
+
+    void take_properties(NumericFormatter &rOther);
 };
 
 // -------------------
@@ -278,6 +280,8 @@ public:
 
     void                    SetCustomConvertHdl( const Link& rLink ) { maCustomConvertLink = rLink; }
     const Link&             GetCustomConvertHdl() const { return maCustomConvertLink; }
+
+    void take_properties(MetricFormatter &rOther);
 };
 
 
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 4c7cd5b..f1c8149 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -775,6 +775,23 @@ void NumericFormatter::ImplNewFieldValue( sal_Int64 nNewValue )
     }
 }
 
+void NumericFormatter::take_properties(NumericFormatter &rOther)
+{
+    mnFieldValue = rOther.mnFieldValue;
+    mnLastValue = rOther.mnLastValue;
+    mnMin = rOther.mnMin;
+    mnMax = rOther.mnMax;
+    mnCorrectedValue = rOther.mnCorrectedValue;
+    mnType = rOther.mnType;
+    mnDecimalDigits = rOther.mnDecimalDigits;
+    mbThousandSep = rOther.mbThousandSep;
+    mbShowTrailingZeros = rOther.mbThousandSep;
+
+    mnSpinSize = rOther.mnSpinSize;
+    mnFirst = rOther.mnFirst;
+    mnLast = rOther.mnLast;
+}
+
 // -----------------------------------------------------------------------
 
 NumericField::NumericField( Window* pParent, WinBits nWinStyle ) :
@@ -1675,6 +1692,15 @@ MetricField::MetricField( Window* pParent, const ResId& rResId ) :
         Show();
 }
 
+void MetricFormatter::take_properties(MetricFormatter &rOtherField)
+{
+    maCustomUnitText = rOtherField.maCustomUnitText;
+    maCurUnitText = rOtherField.maCurUnitText;
+    mnBaseValue = rOtherField.mnBaseValue;
+    meUnit = rOtherField.meUnit;
+    NumericFormatter::take_properties(rOtherField);
+}
+
 void MetricField::take_properties(Window &rOther)
 {
     if (!GetParent())
@@ -1686,10 +1712,7 @@ void MetricField::take_properties(Window &rOther)
     SpinField::take_properties(rOther);
 
     MetricField &rOtherField = static_cast<MetricField&>(rOther);
-    maCustomUnitText = rOtherField.maCustomUnitText;
-    maCurUnitText = rOtherField.maCurUnitText;
-    mnBaseValue = rOtherField.mnBaseValue;
-    meUnit = rOtherField.meUnit;
+    MetricFormatter::take_properties(rOtherField);
 }
 
 bool MetricField::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
commit b05b744cfaea2bc521c8402c98a5f6ee70dad58d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 14 10:47:39 2012 +0100

    implement number of decimal places

diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index a5b720d..4c7cd5b 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -1699,6 +1699,8 @@ bool MetricField::set_property(const rtl::OString &rKey, const rtl::OString &rVa
         maCustomUnitText = rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8);
         meUnit = FUNIT_CUSTOM;
     }
+    else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("digits")))
+        SetDecimalDigits(rValue.toInt32());
     else
         return SpinField::set_property(rKey, rValue);
     return true;


More information about the Libreoffice-commits mailing list