[Libreoffice-commits] core.git: sc/uiconfig vcl/inc vcl/source

Caolán McNamara caolanm at redhat.com
Mon Feb 25 04:58:12 PST 2013


 sc/uiconfig/scalc/ui/sortoptionspage.ui |    2 +-
 vcl/inc/vcl/outdev.hxx                  |    1 +
 vcl/source/control/combobox.cxx         |    4 +---
 vcl/source/control/lstbox.cxx           |    4 +---
 vcl/source/gdi/outdev3.cxx              |    5 +++++
 vcl/source/window/window.cxx            |    2 +-
 6 files changed, 10 insertions(+), 8 deletions(-)

New commits:
commit c1d3315e8d1e4d8be4bcabcf343ef5dd76d63691
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Feb 25 12:41:29 2013 +0000

    Related: fdo#60764 APPFONT is 1/8 avg char *height* & 1/4 avg char *width*
    
    but *sob*, it's not really that, because there's a dialog scale factor which is
    per-language which adds a bit to it depending on the language, MAP_REALAPPFONT
    is the unscaled variant.
    
    but *head in hands*, it's not really that either because if the font was
    considered "too narrow" then the average char width is recalculated in terms of
    the average char height.
    
    *clenches teeth*, add a approximate_char_width and use it directly. It can be
    considered the rough equivalent of
    pango_font_metrics_get_approximate_char_width albeit that it retains the same
    crude 1/8 of the width of "aemnnxEM"
    
    Change-Id: I4c135ca03467447dddf279ac0c187b13371acadb

diff --git a/sc/uiconfig/scalc/ui/sortoptionspage.ui b/sc/uiconfig/scalc/ui/sortoptionspage.ui
index 0fc7eeb..f6815af 100644
--- a/sc/uiconfig/scalc/ui/sortoptionspage.ui
+++ b/sc/uiconfig/scalc/ui/sortoptionspage.ui
@@ -168,7 +168,7 @@
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="margin_left">20</property>
-                    <property name="max_width_chars">72</property>
+                    <property name="max_width_chars">65</property>
                     <accessibility>
                       <relation type="labelled-by" target="sortuser"/>
                     </accessibility>
diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index 0eba3a1..1fb5f25 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -580,6 +580,7 @@ public:
                                       xub_StrLen nLen = STRING_LEN ) const;
     /// Height where any character of the current font fits; in logic coordinates.
     long                GetTextHeight() const;
+    float               approximate_char_width() const;
     void                DrawTextArray( const Point& rStartPt, const XubString& rStr,
                                        const sal_Int32* pDXAry = NULL,
                                        xub_StrLen nIndex = 0,
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 5f9de77..8356a52 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -1066,9 +1066,7 @@ Size ComboBox::CalcMinimumSize() const
         aSz.Width() = mpImplLB->GetMaxEntryWidth();
         if (m_nMaxWidthChars != -1)
         {
-            //MAP_APPFONT == 1/8th avg char
-            long nMaxWidth = LogicToPixel(Size(m_nMaxWidthChars * 8, 0),
-                MapMode(MAP_APPFONT)).Width();
+            long nMaxWidth = m_nMaxWidthChars * approximate_char_width();
             aSz.Width() = std::min(aSz.Width(), nMaxWidth);
         }
         aSz.Width() += getMaxWidthScrollBarAndDownButton();
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index d87c1b3..8880818 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -1348,9 +1348,7 @@ Size ListBox::CalcSubEditSize() const
 
         if (m_nMaxWidthChars != -1)
         {
-            //MAP_APPFONT == 1/8th avg char
-            long nMaxWidth = LogicToPixel(Size(m_nMaxWidthChars * 8, 0),
-                MapMode(MAP_APPFONT)).Width();
+            long nMaxWidth = m_nMaxWidthChars * approximate_char_width();
             aSz.Width() = std::min(aSz.Width(), nMaxWidth);
         }
 
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index 741ddbb..44a4e96 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -5759,6 +5759,11 @@ long OutputDevice::GetTextHeight() const
     return nHeight;
 }
 
+float OutputDevice::approximate_char_width() const
+{
+    return GetTextWidth(rtl::OUString("aemnnxEM")) / 8.0;
+}
+
 // -----------------------------------------------------------------------
 
 void OutputDevice::DrawTextArray( const Point& rStartPt, const String& rStr,
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 309c8a3..8c6ac82 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -211,7 +211,7 @@ void Window::ImplInitAppFontData( Window* pWindow )
 {
     ImplSVData* pSVData = ImplGetSVData();
     long nTextHeight = pWindow->GetTextHeight();
-    long nTextWidth = pWindow->GetTextWidth(rtl::OUString("aemnnxEM"));
+    long nTextWidth = pWindow->approximate_char_width() * 8;
     long nSymHeight = nTextHeight*4;
     // Make the basis wider if the font is too narrow
     // such that the dialog looks symmetrical and does not become too narrow.


More information about the Libreoffice-commits mailing list