summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChr. Rossmanith <ChrRossmanith@gmx.de>2013-03-27 21:36:23 +0100
committerLuboš Luňák <l.lunak@suse.cz>2013-03-28 17:54:23 +0100
commit16b446937e026ff5edd097e99b8d9be6ba314562 (patch)
tree23e49c4c30cb1402cbfcae500e1325b2feb17490
parentb7b3a90f5a3fc22247e4eb6b12b55f0366c74241 (diff)
Use OUString / sal_Int32 in vcl(outdev3.cxx,textlayout.cxx)
ImplGetTextLines(), GetCaretPositions(), ImplAddDevFontSubstitute(), AddFontSubstitute() ... https://gerrit.libreoffice.org/3099 Signed-off-by: Luboš Luňák <l.lunak@suse.cz> Change-Id: I781364da7a36afef65aac7a683c1b80fad61671e
-rw-r--r--vcl/inc/textlayout.hxx24
-rw-r--r--vcl/inc/vcl/outdev.hxx14
-rw-r--r--vcl/source/gdi/outdev3.cxx52
-rw-r--r--vcl/source/gdi/textlayout.cxx41
4 files changed, 65 insertions, 66 deletions
diff --git a/vcl/inc/textlayout.hxx b/vcl/inc/textlayout.hxx
index 5e95eabd5619..28f21ebaae2e 100644
--- a/vcl/inc/textlayout.hxx
+++ b/vcl/inc/textlayout.hxx
@@ -41,10 +41,10 @@ namespace vcl
{
public:
virtual long GetTextWidth( const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
- virtual void DrawText( const Point& _rStartPoint, const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength,
+ virtual void DrawText( const Point& _rStartPoint, const OUString& _rText, sal_Int32 _nStartIndex, sal_Int32 _nLength,
MetricVector* _pVector, OUString* _pDisplayText ) = 0;
- virtual bool GetCaretPositions( const XubString& _rText, sal_Int32* _pCaretXArray, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
- virtual xub_StrLen GetTextBreak( const XubString& _rText, long _nMaxTextWidth, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0;
+ virtual bool GetCaretPositions( const OUString& _rText, sal_Int32* _pCaretXArray, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const = 0;
+ virtual xub_StrLen GetTextBreak( const OUString& _rText, long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const = 0;
virtual bool DecomposeTextRectAction() const = 0;
protected:
@@ -74,23 +74,23 @@ namespace vcl
) const;
virtual void DrawText(
const Point& _rStartPoint,
- const XubString& _rText,
- xub_StrLen _nStartIndex,
- xub_StrLen _nLength,
+ const OUString& _rText,
+ sal_Int32 _nStartIndex,
+ sal_Int32 _nLength,
MetricVector* _pVector,
OUString* _pDisplayText
);
virtual bool GetCaretPositions(
- const XubString& _rText,
+ const OUString& _rText,
sal_Int32* _pCaretXArray,
- xub_StrLen _nStartIndex,
- xub_StrLen _nLength
+ sal_Int32 _nStartIndex,
+ sal_Int32 _nLength
) const;
virtual xub_StrLen GetTextBreak(
- const XubString& _rText,
+ const OUString& _rText,
long _nMaxTextWidth,
- xub_StrLen _nStartIndex,
- xub_StrLen _nLength
+ sal_Int32 _nStartIndex,
+ sal_Int32 _nLength
) const;
virtual bool DecomposeTextRectAction() const;
diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index 3f4fdbd81dce..d8cae7d460ed 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -415,7 +415,7 @@ public:
SAL_DLLPRIVATE void ImplGetEmphasisMark( PolyPolygon& rPolyPoly, sal_Bool& rPolyLine, Rectangle& rRect1, Rectangle& rRect2, long& rYOff, long& rWidth, FontEmphasisMark eEmphasis, long nHeight, short nOrient );
SAL_DLLPRIVATE void ImplDrawEmphasisMark( long nBaseX, long nX, long nY, const PolyPolygon& rPolyPoly, sal_Bool bPolyLine, const Rectangle& rRect1, const Rectangle& rRect2 );
static
- SAL_DLLPRIVATE long ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const XubString& rStr, sal_uInt16 nStyle, const ::vcl::ITextLayout& _rLayout );
+ SAL_DLLPRIVATE long ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const OUString& rStr, sal_uInt16 nStyle, const ::vcl::ITextLayout& _rLayout );
SAL_DLLPRIVATE void ImplInitFontList() const;
SAL_DLLPRIVATE void ImplUpdateFontData( bool bNewFontLists );
SAL_DLLPRIVATE static void ImplUpdateAllFontData( bool bNewFontLists );
@@ -505,8 +505,8 @@ public:
SAL_DLLPRIVATE sal_Bool ImplIsRecordLayout() const;
- void ImplAddDevFontSubstitute( const XubString& rFontName,
- const XubString& rReplaceFontName,
+ void ImplAddDevFontSubstitute( const OUString& rFontName,
+ const OUString& rReplaceFontName,
sal_uInt16 nFlags = 0 );
SAL_DLLPRIVATE static FontEmphasisMark ImplGetEmphasisMarkStyle( const Font& rFont );
@@ -583,8 +583,8 @@ public:
xub_StrLen nLen = STRING_LEN );
long GetTextArray( const OUString& rStr, sal_Int32* pDXAry = NULL,
sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const;
- bool GetCaretPositions( const XubString&, sal_Int32* pCaretXArray,
- xub_StrLen nIndex, xub_StrLen nLen,
+ bool GetCaretPositions( const OUString&, sal_Int32* pCaretXArray,
+ sal_Int32 nIndex, sal_Int32 nLen,
sal_Int32* pDXAry = NULL, long nWidth = 0,
sal_Bool bCellBreaking = sal_True ) const;
void DrawStretchText( const Point& rStartPt, sal_uLong nWidth,
@@ -1092,8 +1092,8 @@ public:
static void BeginFontSubstitution();
static void EndFontSubstitution();
- static void AddFontSubstitute( const XubString& rFontName,
- const XubString& rReplaceFontName,
+ static void AddFontSubstitute( const OUString& rFontName,
+ const OUString& rReplaceFontName,
sal_uInt16 nFlags = 0 );
static void RemoveFontSubstitute( sal_uInt16 n );
static sal_uInt16 GetFontSubstituteCount();
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index b588b08d3ccf..19b2598ef359 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -313,8 +313,8 @@ void OutputDevice::EndFontSubstitution()
}
}
-void OutputDevice::AddFontSubstitute( const XubString& rFontName,
- const XubString& rReplaceFontName,
+void OutputDevice::AddFontSubstitute( const OUString& rFontName,
+ const OUString& rReplaceFontName,
sal_uInt16 nFlags )
{
ImplDirectFontSubstitution*& rpSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst;
@@ -342,8 +342,8 @@ ImplFontSubstEntry::ImplFontSubstEntry( const OUString& rFontName,
GetEnglishSearchFontName( maSearchReplaceName );
}
-void OutputDevice::ImplAddDevFontSubstitute( const XubString& rFontName,
- const XubString& rReplaceFontName,
+void OutputDevice::ImplAddDevFontSubstitute( const OUString& rFontName,
+ const OUString& rReplaceFontName,
sal_uInt16 nFlags )
{
ImplInitOutDevData();
@@ -4687,7 +4687,7 @@ void OutputDevice::ImplDrawText( SalLayout& rSalLayout )
}
long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo,
- long nWidth, const XubString& rStr,
+ long nWidth, const OUString& rStr,
sal_uInt16 nStyle, const ::vcl::ITextLayout& _rLayout )
{
DBG_ASSERTWARNING( nWidth >= 0, "ImplGetTextLines: nWidth <= 0!" );
@@ -4697,7 +4697,7 @@ long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo,
long nMaxLineWidth = 0;
rLineInfo.Clear();
- if ( rStr.Len() && (nWidth > 0) )
+ if ( !rStr.isEmpty() && (nWidth > 0) )
{
::rtl::OUString aText( rStr );
uno::Reference < i18n::XBreakIterator > xBI;
@@ -4710,13 +4710,13 @@ long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo,
i18n::LineBreakHyphenationOptions aHyphOptions( xHyph, uno::Sequence <beans::PropertyValue>(), 1 );
i18n::LineBreakUserOptions aUserOptions;
- xub_StrLen nPos = 0;
- xub_StrLen nLen = rStr.Len();
+ sal_Int32 nPos = 0;
+ sal_Int32 nLen = rStr.getLength();
while ( nPos < nLen )
{
- xub_StrLen nBreakPos = nPos;
+ sal_Int32 nBreakPos = nPos;
- while ( ( nBreakPos < nLen ) && ( rStr.GetChar( nBreakPos ) != _CR ) && ( rStr.GetChar( nBreakPos ) != _LF ) )
+ while ( ( nBreakPos < nLen ) && ( rStr[ nBreakPos ] != _CR ) && ( rStr[ nBreakPos ] != _LF ) )
nBreakPos++;
long nLineWidth = _rLayout.GetTextWidth( rStr, nPos, nBreakPos-nPos );
@@ -4749,11 +4749,11 @@ long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo,
i18n::Boundary aBoundary = xBI->getWordBoundary( aText, nBreakPos, rDefLocale, ::com::sun::star::i18n::WordType::DICTIONARY_WORD, sal_True );
// sal_uInt16 nWordStart = nBreakPos;
// sal_uInt16 nBreakPos_OLD = nBreakPos;
- sal_uInt16 nWordStart = nPos;
- sal_uInt16 nWordEnd = (sal_uInt16) aBoundary.endPos;
+ sal_Int32 nWordStart = nPos;
+ sal_Int32 nWordEnd = (sal_Int32) aBoundary.endPos;
DBG_ASSERT( nWordEnd > nWordStart, "ImpBreakLine: Start >= End?" );
- sal_uInt16 nWordLen = nWordEnd - nWordStart;
+ sal_Int32 nWordLen = nWordEnd - nWordStart;
if ( ( nWordEnd >= nSoftBreak ) && ( nWordLen > 3 ) )
{
// #104415# May happen, because getLineBreak may differ from getWordBoudary with DICTIONARY_WORD
@@ -4834,12 +4834,12 @@ long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo,
else
{
// fallback to something really simple
- sal_uInt16 nSpacePos = STRING_LEN;
+ sal_Int32 nSpacePos = rStr.getLength();
long nW = 0;
do
{
- nSpacePos = rStr.SearchBackward( sal_Unicode(' '), nSpacePos );
- if( nSpacePos != STRING_NOTFOUND )
+ nSpacePos = rStr.lastIndexOf( sal_Unicode(' '), nSpacePos );
+ if( nSpacePos != -1 )
{
if( nSpacePos > nPos )
nSpacePos--;
@@ -4847,11 +4847,11 @@ long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo,
}
} while( nW > nWidth );
- if( nSpacePos != STRING_NOTFOUND )
+ if( nSpacePos != -1 )
{
nBreakPos = nSpacePos;
nLineWidth = _rLayout.GetTextWidth( rStr, nPos, nBreakPos-nPos );
- if( nBreakPos < rStr.Len()-1 )
+ if( nBreakPos < rStr.getLength()-1 )
nBreakPos++;
}
}
@@ -4866,11 +4866,11 @@ long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo,
nBreakPos++;
nPos = nBreakPos;
- if ( ( rStr.GetChar( nPos ) == _CR ) || ( rStr.GetChar( nPos ) == _LF ) )
+ if ( ( rStr[ nPos ] == _CR ) || ( rStr[ nPos ] == _LF ) )
{
nPos++;
// CR/LF?
- if ( ( nPos < nLen ) && ( rStr.GetChar( nPos ) == _LF ) && ( rStr.GetChar( nPos-1 ) == _CR ) )
+ if ( ( nPos < nLen ) && ( rStr[ nPos ] == _LF ) && ( rStr[ nPos-1 ] == _CR ) )
nPos++;
}
}
@@ -5578,17 +5578,17 @@ long OutputDevice::GetTextArray( const OUString& rStr, sal_Int32* pDXAry,
return nWidth;
}
-bool OutputDevice::GetCaretPositions( const XubString& rStr, sal_Int32* pCaretXArray,
- xub_StrLen nIndex, xub_StrLen nLen,
+bool OutputDevice::GetCaretPositions( const OUString& rStr, sal_Int32* pCaretXArray,
+ sal_Int32 nIndex, sal_Int32 nLen,
sal_Int32* pDXAry, long nLayoutWidth,
sal_Bool bCellBreaking ) const
{
DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
- if( nIndex >= rStr.Len() )
+ if( nIndex >= rStr.getLength() )
return false;
- if( (sal_uLong)nIndex+nLen >= rStr.Len() )
- nLen = rStr.Len() - nIndex;
+ if( nIndex+nLen >= rStr.getLength() )
+ nLen = rStr.getLength() - nIndex;
// layout complex text
SalLayout* pSalLayout = ImplLayout( rStr, nIndex, nLen,
@@ -6156,7 +6156,7 @@ xub_StrLen OutputDevice::GetTextBreak( const String& rStr, long nTextWidth,
if( nExtraPixelWidth > 0 )
nTextPixelWidth -= nExtraPixelWidth;
- rHyphenatorPos = sal::static_int_cast<xub_StrLen>(pSalLayout->GetTextBreak( nTextPixelWidth, nExtraPixelWidth, nSubPixelFactor ));
+ rHyphenatorPos = sal::static_int_cast<sal_Int32>(pSalLayout->GetTextBreak( nTextPixelWidth, nExtraPixelWidth, nSubPixelFactor ));
if( rHyphenatorPos > nRetVal )
rHyphenatorPos = nRetVal;
diff --git a/vcl/source/gdi/textlayout.cxx b/vcl/source/gdi/textlayout.cxx
index d03ea25b8f2a..5e7032970587 100644
--- a/vcl/source/gdi/textlayout.cxx
+++ b/vcl/source/gdi/textlayout.cxx
@@ -56,21 +56,21 @@ namespace vcl
}
//--------------------------------------------------------------------
- void DefaultTextLayout::DrawText( const Point& _rStartPoint, const XubString& _rText, xub_StrLen _nStartIndex,
- xub_StrLen _nLength, MetricVector* _pVector, OUString* _pDisplayText )
+ void DefaultTextLayout::DrawText( const Point& _rStartPoint, const OUString& _rText, sal_Int32 _nStartIndex,
+ sal_Int32 _nLength, MetricVector* _pVector, OUString* _pDisplayText )
{
m_rTargetDevice.DrawText( _rStartPoint, _rText, _nStartIndex, _nLength, _pVector, _pDisplayText );
}
//--------------------------------------------------------------------
- bool DefaultTextLayout::GetCaretPositions( const XubString& _rText, sal_Int32* _pCaretXArray,
- xub_StrLen _nStartIndex, xub_StrLen _nLength ) const
+ bool DefaultTextLayout::GetCaretPositions( const OUString& _rText, sal_Int32* _pCaretXArray,
+ sal_Int32 _nStartIndex, sal_Int32 _nLength ) const
{
return m_rTargetDevice.GetCaretPositions( _rText, _pCaretXArray, _nStartIndex, _nLength );
}
//--------------------------------------------------------------------
- xub_StrLen DefaultTextLayout::GetTextBreak( const XubString& _rText, long _nMaxTextWidth, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const
+ xub_StrLen DefaultTextLayout::GetTextBreak( const OUString& _rText, long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const
{
return m_rTargetDevice.GetTextBreak( _rText, _nMaxTextWidth, _nStartIndex, _nLength );
}
@@ -92,15 +92,15 @@ namespace vcl
// ITextLayout
virtual long GetTextWidth( const XubString& rStr, xub_StrLen nIndex, xub_StrLen nLen ) const;
- virtual void DrawText( const Point& _rStartPoint, const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength, MetricVector* _pVector, OUString* _pDisplayText );
- virtual bool GetCaretPositions( const XubString& _rText, sal_Int32* _pCaretXArray, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const;
- virtual xub_StrLen GetTextBreak( const XubString& _rText, long _nMaxTextWidth, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const;
+ virtual void DrawText( const Point& _rStartPoint, const OUString& _rText, sal_Int32 _nStartIndex, sal_Int32 _nLength, MetricVector* _pVector, OUString* _pDisplayText );
+ virtual bool GetCaretPositions( const OUString& _rText, sal_Int32* _pCaretXArray, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const;
+ virtual xub_StrLen GetTextBreak( const OUString& _rText, long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const;
virtual bool DecomposeTextRectAction() const;
public:
// equivalents to the respective OutputDevice methods, which take the reference device into account
- long GetTextArray( const XubString& _rText, sal_Int32* _pDXAry, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const;
- Rectangle DrawText( const Rectangle& _rRect, const XubString& _rText, sal_uInt16 _nStyle, MetricVector* _pVector, OUString* _pDisplayText );
+ long GetTextArray( const OUString& _rText, sal_Int32* _pDXAry, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const;
+ Rectangle DrawText( const Rectangle& _rRect, const OUString& _rText, sal_uInt16 _nStyle, MetricVector* _pVector, OUString* _pDisplayText );
protected:
void onBeginDrawText()
@@ -181,9 +181,9 @@ namespace vcl
namespace
{
//................................................................
- bool lcl_normalizeLength( const XubString& _rText, const xub_StrLen _nStartIndex, xub_StrLen& _io_nLength )
+ bool lcl_normalizeLength( const OUString& _rText, const sal_Int32 _nStartIndex, sal_Int32& _io_nLength )
{
- xub_StrLen nTextLength = _rText.Len();
+ sal_Int32 nTextLength = _rText.getLength();
if ( _nStartIndex > nTextLength )
return false;
if ( _nStartIndex + _io_nLength > nTextLength )
@@ -193,8 +193,7 @@ namespace vcl
}
//--------------------------------------------------------------------
- long ReferenceDeviceTextLayout::GetTextArray( const XubString& _rText, sal_Int32* _pDXAry, xub_StrLen _nStartIndex,
- xub_StrLen _nLength ) const
+ long ReferenceDeviceTextLayout::GetTextArray( const OUString& _rText, sal_Int32* _pDXAry, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const
{
if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
return 0;
@@ -230,7 +229,7 @@ namespace vcl
}
//--------------------------------------------------------------------
- void ReferenceDeviceTextLayout::DrawText( const Point& _rStartPoint, const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength, MetricVector* _pVector, OUString* _pDisplayText )
+ void ReferenceDeviceTextLayout::DrawText( const Point& _rStartPoint, const OUString& _rText, sal_Int32 _nStartIndex, sal_Int32 _nLength, MetricVector* _pVector, OUString* _pDisplayText )
{
if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
return;
@@ -242,7 +241,7 @@ namespace vcl
::std::copy(
aGlyphBounds.begin(), aGlyphBounds.end(),
::std::insert_iterator< MetricVector > ( *_pVector, _pVector->end() ) );
- *_pDisplayText += _rText.Copy( _nStartIndex, _nLength );
+ *_pDisplayText += _rText.copy( _nStartIndex, _nLength );
return;
}
@@ -255,8 +254,8 @@ namespace vcl
}
//--------------------------------------------------------------------
- bool ReferenceDeviceTextLayout::GetCaretPositions( const XubString& _rText, sal_Int32* _pCaretXArray,
- xub_StrLen _nStartIndex, xub_StrLen _nLength ) const
+ bool ReferenceDeviceTextLayout::GetCaretPositions( const OUString& _rText, sal_Int32* _pCaretXArray,
+ sal_Int32 _nStartIndex, sal_Int32 _nLength ) const
{
if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
return false;
@@ -269,7 +268,7 @@ namespace vcl
}
//--------------------------------------------------------------------
- xub_StrLen ReferenceDeviceTextLayout::GetTextBreak( const XubString& _rText, long _nMaxTextWidth, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const
+ xub_StrLen ReferenceDeviceTextLayout::GetTextBreak( const OUString& _rText, long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const
{
if ( !lcl_normalizeLength( _rText, _nStartIndex, _nLength ) )
return 0;
@@ -284,9 +283,9 @@ namespace vcl
}
//--------------------------------------------------------------------
- Rectangle ReferenceDeviceTextLayout::DrawText( const Rectangle& _rRect, const XubString& _rText, sal_uInt16 _nStyle, MetricVector* _pVector, OUString* _pDisplayText )
+ Rectangle ReferenceDeviceTextLayout::DrawText( const Rectangle& _rRect, const OUString& _rText, sal_uInt16 _nStyle, MetricVector* _pVector, OUString* _pDisplayText )
{
- if ( !_rText.Len() )
+ if ( _rText.isEmpty() )
return Rectangle();
// determine text layout mode from the RTL-ness of the control whose text we render