Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3097

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/97/3097/1

Use OUString and sal_Int32 in GetTextWidth()

Change-Id: I0b3cdbe8576300d098027cc98d7dff841d148f18
---
M basctl/source/basicide/baside2.cxx
M basctl/source/basicide/baside2b.cxx
M basctl/source/basicide/linenumberwindow.cxx
M vcl/inc/vcl/outdev.hxx
M vcl/source/gdi/outdev3.cxx
5 files changed, 9 insertions(+), 14 deletions(-)



diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index f8962c5..f8690cc 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -888,7 +888,7 @@
 
     // nLinepPage is not correct if there's a line break
     sal_uInt16 nLinespPage = (sal_uInt16) (aPaperSz.Height()/nLineHeight);
-    sal_uInt16 nCharspLine = (sal_uInt16) (aPaperSz.Width() / pPrinter->GetTextWidth( 'X' ) );
+    sal_uInt16 nCharspLine = (sal_uInt16) (aPaperSz.Width() / pPrinter->GetTextWidth( "X" ) );
     sal_uLong nParas = GetEditEngine()->GetParagraphCount();
 
     sal_uInt16 nPages = (sal_uInt16) (nParas/nLinespPage+1 );
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index bb81726..bc683f6 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -786,7 +786,7 @@
     {
         rModulWindow.GetHScrollBar()->SetVisibleSize( aOutSz.Width() );
         rModulWindow.GetHScrollBar()->SetPageSize( aOutSz.Width() * 8 / 10 );
-        rModulWindow.GetHScrollBar()->SetLineSize( GetTextWidth( OUString('x') ) );
+        rModulWindow.GetHScrollBar()->SetLineSize( GetTextWidth( "x" ) );
         rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
         rModulWindow.GetHScrollBar()->Show();
     }
diff --git a/basctl/source/basicide/linenumberwindow.cxx 
b/basctl/source/basicide/linenumberwindow.cxx
index 2bd4dbe..56d01cf 100644
--- a/basctl/source/basicide/linenumberwindow.cxx
+++ b/basctl/source/basicide/linenumberwindow.cxx
@@ -41,7 +41,7 @@
     m_nCurYOffset(0)
 {
     SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor()));
-    m_nBaseWidth = GetTextWidth('8');
+    m_nBaseWidth = GetTextWidth("8");
     m_nWidth = m_nBaseWidth * 3 + m_nBaseWidth / 2;
 }
 
@@ -79,7 +79,7 @@
 
     // FIXME: it would be best if we could get notified of a font change
     // rather than doing that re-calculation at each Paint event
-    m_nBaseWidth = GetTextWidth(OUString('8'));
+    m_nBaseWidth = GetTextWidth("8");
 
     // reserve enough for 3 sigit minimum, with a bit to spare for confort
     m_nWidth = m_nBaseWidth * 3 + m_nBaseWidth / 2;
diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index 44a5979..3f4fdbd 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -573,8 +573,7 @@
     void                DrawText( const Point& rStartPt, const XubString& rStr,
                                   xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN,
                                   MetricVector* pVector = NULL, OUString* pDisplayText = NULL );
-    long                GetTextWidth( const XubString& rStr, xub_StrLen nIndex = 0,
-                                      xub_StrLen nLen = STRING_LEN ) const;
+    long                GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = 
-1 ) const;
     /// Height where any character of the current font fits; in logic coordinates.
     long                GetTextHeight() const;
     float               approximate_char_width() const;
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index 4ce3714..b588b08 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -5470,15 +5470,11 @@
         mpAlphaVDev->DrawText( rStartPt, rStr, nIndex, nLen, pVector, pDisplayText );
 }
 
-long OutputDevice::GetTextWidth( const String& rStr,
-                                 xub_StrLen nIndex, xub_StrLen nLen ) const
+long OutputDevice::GetTextWidth( const OUString& rStr, sal_Int32 nIndex, sal_Int32 nLen ) const
 {
     DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
 
-    sal_Int32 nLen2 = (nLen == STRING_LEN) ? -1 : nLen; // only needed until nLen is sal_Int32
-    sal_Int32 nIndex2 = nIndex;                            // ditto
-    OUString aTmpStr(rStr);
-    long nWidth = GetTextArray( aTmpStr, NULL, nIndex2, nLen2 );
+    long nWidth = GetTextArray( rStr, NULL, nIndex, nLen );
 
     return nWidth;
 }
@@ -5504,7 +5500,7 @@
 
 float OutputDevice::approximate_char_width() const
 {
-    return GetTextWidth(rtl::OUString("aemnnxEM")) / 8.0;
+    return GetTextWidth("aemnnxEM") / 8.0;
 }
 
 void OutputDevice::DrawTextArray( const Point& rStartPt, const String& rStr,
@@ -6357,7 +6353,7 @@
     }
     else
     {
-        long nTextWidth = _rLayout.GetTextWidth( aStr, 0, STRING_LEN );
+        long nTextWidth = _rLayout.GetTextWidth( aStr, 0, -1 );
 
         // Evt. Text kuerzen
         if ( nTextWidth > nWidth )

-- 
To view, visit https://gerrit.libreoffice.org/3097
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b3cdbe8576300d098027cc98d7dff841d148f18
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Christina Roßmanith <ChrRossmanith@web.de>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.