Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/3160
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/60/3160/1
Use OUString and sal_Int32 in GetNonMnemonicString() and GetCtrlTextWidth()
Change-Id: I599d03686a020841dc3c18ca75ffcc96889a95a6
---
M vcl/inc/vcl/outdev.hxx
M vcl/source/gdi/outdev3.cxx
M vcl/source/gdi/pdfwriter_impl.cxx
M vcl/source/window/menu.cxx
4 files changed, 30 insertions(+), 32 deletions(-)
diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index df433ff..f63c7ec 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -622,12 +622,12 @@
void DrawCtrlText( const Point& rPos, const XubString& rStr,
xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN,
sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC, MetricVector*
pVector = NULL, OUString* pDisplayText = NULL );
- long GetCtrlTextWidth( const XubString& rStr, xub_StrLen nIndex = 0,
- xub_StrLen nLen = STRING_LEN,
+ long GetCtrlTextWidth( const OUString& rStr, sal_Int32 nIndex = 0,
+ sal_Int32 nLen = -1,
sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC ) const;
- static XubString GetNonMnemonicString( const XubString& rStr, xub_StrLen& rMnemonicPos );
- static XubString GetNonMnemonicString( const XubString& rStr )
- { xub_StrLen nDummy; return GetNonMnemonicString( rStr, nDummy ); }
+ static OUString GetNonMnemonicString( const OUString& rStr, sal_Int32& rMnemonicPos );
+ static OUString GetNonMnemonicString( const OUString& rStr )
+ { sal_Int32 nDummy; return GetNonMnemonicString( rStr, nDummy ); }
sal_Bool GetTextBoundRect( Rectangle& rRect,
const String& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0,
xub_StrLen nLen = STRING_LEN,
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index ec06af0..f966cc0 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -6228,7 +6228,7 @@
long nTextHeight = rTargetDevice.GetTextHeight();
TextAlign eAlign = rTargetDevice.GetTextAlign();
- xub_StrLen nMnemonicPos = STRING_NOTFOUND;
+ sal_Int32 nMnemonicPos = -1;
String aStr = rOrigStr;
if ( nStyle & TEXT_DRAW_MNEMONIC )
@@ -6239,7 +6239,6 @@
// Mehrzeiligen Text behandeln wir anders
if ( nStyle & TEXT_DRAW_MULTILINE )
{
-
XubString aLastLine;
ImplMultiTextLineInfo aMultiLineInfo;
ImplTextLineInfo* pLineInfo;
@@ -6392,7 +6391,7 @@
long nMnemonicX = 0;
long nMnemonicY = 0;
long nMnemonicWidth = 0;
- if ( nMnemonicPos != STRING_NOTFOUND )
+ if ( nMnemonicPos != -1 )
{
sal_Int32* pCaretXArray = (sal_Int32*) alloca( 2 * sizeof(sal_Int32) * aStr.Len() );
/*sal_Bool bRet =*/ _rLayout.GetCaretPositions( aStr, pCaretXArray, 0, aStr.Len() );
@@ -6412,7 +6411,7 @@
_rLayout.DrawText( aPos, aStr, 0, STRING_LEN, pVector, pDisplayText );
if ( bDrawMnemonics )
{
- if ( nMnemonicPos != STRING_NOTFOUND )
+ if ( nMnemonicPos != -1 )
rTargetDevice.ImplDrawMnemonicLine( nMnemonicX, nMnemonicY, nMnemonicWidth );
}
rTargetDevice.Pop();
@@ -6422,7 +6421,7 @@
_rLayout.DrawText( aPos, aStr, 0, STRING_LEN, pVector, pDisplayText );
if ( bDrawMnemonics )
{
- if ( nMnemonicPos != STRING_NOTFOUND )
+ if ( nMnemonicPos != -1 )
rTargetDevice.ImplDrawMnemonicLine( nMnemonicX, nMnemonicY, nMnemonicWidth );
}
}
@@ -6817,7 +6816,7 @@
nLen = rStr.Len() - nIndex;
XubString aStr = rStr;
- xub_StrLen nMnemonicPos = STRING_NOTFOUND;
+ sal_Int32 nMnemonicPos = -1;
long nMnemonicX = 0;
long nMnemonicY = 0;
@@ -6825,7 +6824,7 @@
if ( (nStyle & TEXT_DRAW_MNEMONIC) && nLen > 1 )
{
aStr = GetNonMnemonicString( aStr, nMnemonicPos );
- if ( nMnemonicPos != STRING_NOTFOUND )
+ if ( nMnemonicPos != -1 )
{
if( nMnemonicPos < nIndex )
--nIndex;
@@ -6923,21 +6922,21 @@
mpAlphaVDev->DrawCtrlText( rPos, rStr, nIndex, nLen, nStyle, pVector, pDisplayText );
}
-long OutputDevice::GetCtrlTextWidth( const String& rStr,
- xub_StrLen nIndex, xub_StrLen nLen,
+long OutputDevice::GetCtrlTextWidth( const OUString& rStr,
+ sal_Int32 nIndex, sal_Int32 nLen,
sal_uInt16 nStyle ) const
{
DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
if ( nStyle & TEXT_DRAW_MNEMONIC )
{
- xub_StrLen nMnemonicPos;
- XubString aStr = GetNonMnemonicString( rStr, nMnemonicPos );
- if ( nMnemonicPos != STRING_NOTFOUND )
+ sal_Int32 nMnemonicPos;
+ OUString aStr = GetNonMnemonicString( rStr, nMnemonicPos );
+ if ( nMnemonicPos != -1 )
{
if ( nMnemonicPos < nIndex )
nIndex--;
- else if ( (nLen < STRING_LEN) &&
+ else if ( (nLen < -1) &&
(nMnemonicPos >= nIndex) && (nMnemonicPos < (sal_uLong)(nIndex+nLen)) )
nLen--;
}
@@ -6947,27 +6946,27 @@
return GetTextWidth( rStr, nIndex, nLen );
}
-String OutputDevice::GetNonMnemonicString( const String& rStr, xub_StrLen& rMnemonicPos )
+OUString OutputDevice::GetNonMnemonicString( const OUString& rStr, sal_Int32& rMnemonicPos )
{
- String aStr = rStr;
- xub_StrLen nLen = aStr.Len();
- xub_StrLen i = 0;
+ OUString aStr = rStr;
+ sal_Int32 nLen = aStr.getLength();
+ sal_Int32 i = 0;
- rMnemonicPos = STRING_NOTFOUND;
+ rMnemonicPos = -1;
while ( i < nLen )
{
- if ( aStr.GetChar( i ) == '~' )
+ if ( aStr[ i ] == '~' )
{
- if ( aStr.GetChar( i+1 ) != '~' )
+ if ( aStr[ i+1 ] != '~' )
{
- if ( rMnemonicPos == STRING_NOTFOUND )
+ if ( rMnemonicPos == -1 )
rMnemonicPos = i;
- aStr.Erase( i, 1 );
+ aStr = aStr.replaceAt( i, 1, "" );
nLen--;
}
else
{
- aStr.Erase( i, 1 );
+ aStr = aStr.replaceAt( i, 1, "" );
nLen--;
i++;
}
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 1307193..5e6126e 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -8107,11 +8107,10 @@
Point aPos = rRect.TopLeft();
long nTextHeight = m_pReferenceDevice->GetTextHeight();
- xub_StrLen nMnemonicPos = STRING_NOTFOUND;
String aStr = rOrigStr;
if ( nStyle & TEXT_DRAW_MNEMONIC )
- aStr = m_pReferenceDevice->GetNonMnemonicString( aStr, nMnemonicPos );
+ aStr = m_pReferenceDevice->GetNonMnemonicString( aStr );
// multiline text
if ( nStyle & TEXT_DRAW_MULTILINE )
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index c8e02ad..9f2ab0c 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2595,11 +2595,11 @@
static String getShortenedString( const String& i_rLong, Window* i_pWin, long i_nMaxWidth )
{
- xub_StrLen nPos = STRING_NOTFOUND;
+ sal_Int32 nPos = -1;
String aNonMnem( OutputDevice::GetNonMnemonicString( i_rLong, nPos ) );
aNonMnem = i_pWin->GetEllipsisString( aNonMnem, i_nMaxWidth, TEXT_DRAW_CENTERELLIPSIS );
// re-insert mnemonic
- if( nPos != STRING_NOTFOUND )
+ if( nPos != -1 )
{
if( nPos < aNonMnem.Len() && i_rLong.GetChar(nPos+1) == aNonMnem.GetChar(nPos) )
{
--
To view, visit https://gerrit.libreoffice.org/3160
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I599d03686a020841dc3c18ca75ffcc96889a95a6
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Christina Roßmanith <ChrRossmanith@web.de>
Context
- [PATCH] Use OUString and sal_Int32 in GetNonMnemonicString() and Get... · via Code Review
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.