[Libreoffice-commits] .: 5 commits - sw/source vcl/inc vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Oct 19 00:45:06 PDT 2012


 sw/source/ui/cctrl/actctrl.cxx  |    2 -
 vcl/inc/svids.hrc               |    2 +
 vcl/inc/vcl/edit.hxx            |    2 -
 vcl/inc/vcl/fixed.hxx           |    3 ++
 vcl/source/control/combobox.cxx |    6 ++--
 vcl/source/control/edit.cxx     |    4 +-
 vcl/source/control/fixed.cxx    |   35 +++++++++++++++++++++--
 vcl/source/src/btntext.src      |   10 ++++++
 vcl/source/window/builder.cxx   |   59 ++++++++++++++++++----------------------
 9 files changed, 81 insertions(+), 42 deletions(-)

New commits:
commit 06b8cdc503e021a644219a064503433482d98d48
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Oct 19 08:43:02 2012 +0100

    SetMaxWidthInChars -> SetMinWidthInChars
    
    Change-Id: Ie7b6f8c07beb5895a1437e3da1cc57084e1da114

diff --git a/sw/source/ui/cctrl/actctrl.cxx b/sw/source/ui/cctrl/actctrl.cxx
index 18c2ac4..6300fee 100644
--- a/sw/source/ui/cctrl/actctrl.cxx
+++ b/sw/source/ui/cctrl/actctrl.cxx
@@ -129,7 +129,7 @@ void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
 extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTableNameEdit(Window *pParent, VclBuilder::stringmap &)
 {
     TableNameEdit* pTableNameEdit = new TableNameEdit(pParent);
-    pTableNameEdit->SetMaxWidthInChars(25);
+    pTableNameEdit->SetMinWidthInChars(25);
     return pTableNameEdit;
 }
 
commit e20ebf2653bdd42e90ae97f1e77aa4591907b882
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 18 22:07:56 2012 +0100

    support width-chars property for labels
    
    Change-Id: Iba51f30a5e74d1e486bce10901ccb58f3488ce97

diff --git a/vcl/inc/vcl/fixed.hxx b/vcl/inc/vcl/fixed.hxx
index 397e3cf..1d6f1bf 100644
--- a/vcl/inc/vcl/fixed.hxx
+++ b/vcl/inc/vcl/fixed.hxx
@@ -45,6 +45,7 @@ class VCL_DLLPUBLIC FixedText : public Control
 {
 private:
     sal_Int32 m_nMaxWidthChars;
+    sal_Int32 m_nMinWidthChars;
 
     using Control::ImplInitSettings;
     using Window::ImplInit;
@@ -75,6 +76,8 @@ public:
 
     void setMaxWidthChars(sal_Int32 nWidth);
     sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; }
+    void setMinWidthChars(sal_Int32 nWidth);
+    sal_Int32 getMinWidthChars() const { return m_nMinWidthChars; }
     static Size     CalcMinimumTextSize(Control const* pControl, long nMaxWidth = 0x7fffffff);
     static Size     getTextDimensions(Control const *pControl, const OUString &rTxt, long nMaxWidth);
     Size            CalcMinimumSize(long nMaxWidth = 0x7fffffff) const;
diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx
index 9d35c1f..f330d8f 100644
--- a/vcl/source/control/fixed.cxx
+++ b/vcl/source/control/fixed.cxx
@@ -33,7 +33,7 @@
 #include "vcl/dialog.hxx"
 #include "vcl/event.hxx"
 #include "vcl/fixed.hxx"
-
+#include <comphelper/string.hxx>
 #include "controldata.hxx"
 #include "window.h"
 
@@ -157,6 +157,7 @@ void FixedText::ImplInitSettings( sal_Bool bFont,
 FixedText::FixedText( Window* pParent, WinBits nStyle )
     : Control(WINDOW_FIXEDTEXT)
     , m_nMaxWidthChars(-1)
+    , m_nMinWidthChars(-1)
 {
     ImplInit( pParent, nStyle );
 }
@@ -166,6 +167,7 @@ FixedText::FixedText( Window* pParent, WinBits nStyle )
 FixedText::FixedText( Window* pParent, const ResId& rResId )
     : Control(WINDOW_FIXEDTEXT)
     , m_nMaxWidthChars(-1)
+    , m_nMinWidthChars(-1)
 {
     rResId.SetRT( RSC_TEXT );
     WinBits nStyle = ImplInitRes( rResId );
@@ -193,6 +195,7 @@ void FixedText::take_properties(Window &rOther)
 FixedText::FixedText( Window* pParent, const ResId& rResId, bool bDisableAccessibleLabelForRelation )
     : Control( WINDOW_FIXEDTEXT )
     , m_nMaxWidthChars(-1)
+    , m_nMinWidthChars(-1)
 {
     rResId.SetRT( RSC_TEXT );
     WinBits nStyle = ImplInitRes( rResId );
@@ -446,7 +449,17 @@ Size FixedText::GetOptimalSize(WindowSizeType eType) const
                 nMaxAvailWidth = getTextDimensions(this,
                     rTxt.copy(0, m_nMaxWidthChars), 0x7fffffff).Width();
             }
-            return CalcMinimumSize(nMaxAvailWidth);
+            Size aRet = CalcMinimumSize(nMaxAvailWidth);
+            if (m_nMinWidthChars != -1)
+            {
+                OUStringBuffer aBuf;
+                comphelper::string::padToLength(aBuf, m_nMinWidthChars, 'x');
+                Size aMinAllowed = getTextDimensions(this,
+                    aBuf.makeStringAndClear(), 0x7fffffff);
+                if (aMinAllowed.Width() > aRet.Width())
+                    aRet = aMinAllowed;
+            }
+            return aRet;
         }
         default:
             return Control::GetOptimalSize( eType );
@@ -470,10 +483,21 @@ void FixedText::setMaxWidthChars(sal_Int32 nWidth)
     }
 }
 
+void FixedText::setMinWidthChars(sal_Int32 nWidth)
+{
+    if (nWidth != m_nMinWidthChars)
+    {
+        m_nMinWidthChars = nWidth;
+        queue_resize();
+    }
+}
+
 bool FixedText::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
 {
     if (rKey == "max-width-chars")
         setMaxWidthChars(rValue.toInt32());
+    else if (rKey == "width-chars")
+        setMinWidthChars(rValue.toInt32());
     else
         return Control::set_property(rKey, rValue);
     return true;
commit 9aa8e185d49cd694ac1e00771c1ef2c02cf08382
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 18 21:48:41 2012 +0100

    minimize calls to queue_resize
    
    Change-Id: Idbb7da30c985253a37ff6fe0e86fe04dec2dbbeb

diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx
index 254494c..9d35c1f 100644
--- a/vcl/source/control/fixed.cxx
+++ b/vcl/source/control/fixed.cxx
@@ -463,8 +463,11 @@ void FixedText::FillLayoutData() const
 
 void FixedText::setMaxWidthChars(sal_Int32 nWidth)
 {
-    m_nMaxWidthChars = nWidth;
-    queue_resize();
+    if (nWidth != m_nMaxWidthChars)
+    {
+        m_nMaxWidthChars = nWidth;
+        queue_resize();
+    }
 }
 
 bool FixedText::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
commit 3b696181ebf1fd4c3ecff4a1fc9ed84a5db9b3e3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 18 21:45:26 2012 +0100

    SetMaxWidthInChars should be SetMinWidthInChars
    
    Change-Id: I5cf508e7930eb7e04016ffa43683f76a07e5173e

diff --git a/vcl/inc/vcl/edit.hxx b/vcl/inc/vcl/edit.hxx
index 1fd0168..7ddab48 100644
--- a/vcl/inc/vcl/edit.hxx
+++ b/vcl/inc/vcl/edit.hxx
@@ -199,7 +199,7 @@ public:
     virtual void        SetMaxTextLen( xub_StrLen nMaxLen = EDIT_NOLIMIT );
     virtual xub_StrLen  GetMaxTextLen() const { return mnMaxTextLen; }
 
-    void                SetMaxWidthInChars(sal_Int32 nMinWidthInChars);
+    void                SetMinWidthInChars(sal_Int32 nMinWidthInChars);
     sal_Int32           GetMinWidthInChars() const { return mnMinWidthInChars; }
 
     virtual void        SetSelection( const Selection& rSelection );
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 90515cc..3ec6e64 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -61,7 +61,7 @@ ComboBox::ComboBox( WindowType nType ) :
     Edit( nType )
 {
     ImplInitComboBoxData();
-    SetMaxWidthInChars(0);
+    SetMinWidthInChars(0);
 }
 
 // -----------------------------------------------------------------------
@@ -71,7 +71,7 @@ ComboBox::ComboBox( Window* pParent, WinBits nStyle ) :
 {
     ImplInitComboBoxData();
     ImplInit( pParent, nStyle );
-    SetMaxWidthInChars(0);
+    SetMinWidthInChars(0);
 }
 
 // -----------------------------------------------------------------------
@@ -85,7 +85,7 @@ ComboBox::ComboBox( Window* pParent, const ResId& rResId ) :
     ImplInit( pParent, nStyle );
     ImplLoadRes( rResId );
 
-    SetMaxWidthInChars(0);
+    SetMinWidthInChars(0);
     if ( !(nStyle & WB_HIDE ) )
         Show();
 }
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 962df08..7d2c476 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -219,7 +219,7 @@ Edit::Edit( Window* pParent, const ResId& rResId ) :
         Show();
 }
 
-void Edit::SetMaxWidthInChars(sal_Int32 nMinWidthInChars)
+void Edit::SetMinWidthInChars(sal_Int32 nMinWidthInChars)
 {
     if (mnMinWidthInChars != nMinWidthInChars)
     {
@@ -231,7 +231,7 @@ void Edit::SetMaxWidthInChars(sal_Int32 nMinWidthInChars)
 bool Edit::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
 {
     if (rKey == "width-chars")
-        SetMaxWidthInChars(rValue.toInt32());
+        SetMinWidthInChars(rValue.toInt32());
     else if (rKey == "editable")
         SetReadOnly(!toBool(rValue));
     else if (rKey == "visibility")
commit 4e5fdfb31e62300b20f8122a73206722b1d4fc0f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 18 21:31:09 2012 +0100

    add stock new and edit button texts
    
    Change-Id: Ia8f5f6592211e50323de66a4177f752a1adcf584

diff --git a/vcl/inc/svids.hrc b/vcl/inc/svids.hrc
index 4951c5c..e0a64f6 100644
--- a/vcl/inc/svids.hrc
+++ b/vcl/inc/svids.hrc
@@ -151,6 +151,8 @@
 #define SV_BUTTONTEXT_ADD                   10112
 #define SV_BUTTONTEXT_DELETE                10113
 #define SV_BUTTONTEXT_REMOVE                10114
+#define SV_BUTTONTEXT_NEW                   10115
+#define SV_BUTTONTEXT_EDIT                  10116
 
 #define SV_STDTEXT_FIRST                    SV_STDTEXT_SERVICENOTAVAILABLE
 #define SV_STDTEXT_SERVICENOTAVAILABLE      10200
diff --git a/vcl/source/src/btntext.src b/vcl/source/src/btntext.src
index d415a1f..8bfbdbb 100644
--- a/vcl/source/src/btntext.src
+++ b/vcl/source/src/btntext.src
@@ -96,3 +96,13 @@ String SV_BUTTONTEXT_REMOVE
 {
     Text [ en-US ] = "~Remove";
 };
+
+String SV_BUTTONTEXT_NEW
+{
+    Text [ en-US ] = "~New";
+};
+
+String SV_BUTTONTEXT_EDIT
+{
+    Text [ en-US ] = "~Edit";
+};
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 073be0d..735bde1 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -332,6 +332,32 @@ namespace
         return bInconsistent;
     }
 
+    OUString getStockText(const OString &rType)
+    {
+        if (rType == "gtk-ok")
+            return (VclResId(SV_BUTTONTEXT_OK).toString());
+        else if (rType == "gtk-cancel")
+            return (VclResId(SV_BUTTONTEXT_CANCEL).toString());
+        else if (rType == "gtk-help")
+            return (VclResId(SV_BUTTONTEXT_HELP).toString());
+        else if (rType == "gtk-close")
+            return (VclResId(SV_BUTTONTEXT_CLOSE).toString());
+        else if (rType == "gtk-revert-to-saved")
+            return (VclResId(SV_BUTTONTEXT_RESET).toString());
+        else if (rType == "gtk-add")
+            return (VclResId(SV_BUTTONTEXT_ADD).toString());
+        else if (rType == "gtk-delete")
+            return (VclResId(SV_BUTTONTEXT_DELETE).toString());
+        else if (rType == "gtk-remove")
+            return (VclResId(SV_BUTTONTEXT_REMOVE).toString());
+        else if (rType == "gtk-new")
+            return (VclResId(SV_BUTTONTEXT_NEW).toString());
+        else if (rType == "gtk-edit")
+            return (VclResId(SV_BUTTONTEXT_EDIT).toString());
+        SAL_WARN("vcl.layout", "unknown stock type: " << rType.getStr());
+        return OUString();
+    }
+
     Window * extractStockAndBuildButton(Window *pParent, VclBuilder::stringmap &rMap)
     {
         WinBits nBits = WB_CENTER|WB_VCENTER|WB_3DLOOK;
@@ -374,39 +400,10 @@ namespace
                 pBtn->SetSymbol(SYMBOL_PREV);
                 pWindow = pBtn;
             }
-            else if (sType == "gtk-close")
-            {
-                PushButton *pBtn = new PushButton(pParent, nBits);
-                pBtn->SetText(VclResId(SV_BUTTONTEXT_CLOSE).toString());
-                pWindow = pBtn;
-            }
-            else if (sType == "gtk-revert-to-saved")
-            {
-                PushButton *pBtn = new PushButton(pParent, nBits);
-                pBtn->SetText(VclResId(SV_BUTTONTEXT_RESET).toString());
-                pWindow = pBtn;
-            }
-            else if (sType == "gtk-add")
-            {
-                PushButton *pBtn = new PushButton(pParent, nBits);
-                pBtn->SetText(VclResId(SV_BUTTONTEXT_ADD).toString());
-                pWindow = pBtn;
-            }
-            else if (sType == "gtk-delete")
-            {
-                PushButton *pBtn = new PushButton(pParent, nBits);
-                pBtn->SetText(VclResId(SV_BUTTONTEXT_DELETE).toString());
-                pWindow = pBtn;
-            }
-            else if (sType == "gtk-remove")
-            {
-                PushButton *pBtn = new PushButton(pParent, nBits);
-                pBtn->SetText(VclResId(SV_BUTTONTEXT_REMOVE).toString());
-                pWindow = pBtn;
-            }
             else
             {
-                SAL_WARN("vcl.layout", "unknown stock type: " << sType.getStr());
+                pWindow = new PushButton(pParent, nBits);
+                pWindow->SetText(getStockText(sType));
             }
         }
 


More information about the Libreoffice-commits mailing list