Kaydet (Commit) ffb837ee authored tarafından Chr. Rossmanith's avatar Chr. Rossmanith Kaydeden (comit) Fridrich Strba

Use OUString and sal_Int32 in GetTextArray() and ImplLayout()

Change-Id: I2c1e5b7d53c0d78f2ccf9ac317a7ff40298cd68d
Reviewed-on: https://gerrit.libreoffice.org/2967Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Reviewed-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
Tested-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
üst a89fda4b
...@@ -378,10 +378,9 @@ public: ...@@ -378,10 +378,9 @@ public:
SAL_DLLPRIVATE bool ImplSelectClipRegion( const Region&, SalGraphics* pGraphics = NULL ); SAL_DLLPRIVATE bool ImplSelectClipRegion( const Region&, SalGraphics* pGraphics = NULL );
SAL_DLLPRIVATE void ImplSetClipRegion( const Region* pRegion ); SAL_DLLPRIVATE void ImplSetClipRegion( const Region* pRegion );
SAL_DLLPRIVATE SalLayout* ImplLayout( const String&, xub_StrLen nIndex, SAL_DLLPRIVATE SalLayout* ImplLayout( const OUString&, sal_Int32 nIndex, sal_Int32 nLen,
xub_StrLen nLen, const Point& rLogicPos = Point(0,0), const Point& rLogicPos = Point(0,0), long nLogicWidth=0,
long nLogicWidth=0, const sal_Int32* pLogicDXArray=NULL, const sal_Int32* pLogicDXArray=NULL, bool bFilter = false ) const;
bool bFilter = false ) const;
SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen, SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen,
long nPixelWidth, const sal_Int32* pPixelDXArray ) const; long nPixelWidth, const sal_Int32* pPixelDXArray ) const;
SAL_DLLPRIVATE SalLayout* ImplGlyphFallbackLayout( SalLayout*, ImplLayoutArgs& ) const; SAL_DLLPRIVATE SalLayout* ImplGlyphFallbackLayout( SalLayout*, ImplLayoutArgs& ) const;
...@@ -583,9 +582,8 @@ public: ...@@ -583,9 +582,8 @@ public:
const sal_Int32* pDXAry = NULL, const sal_Int32* pDXAry = NULL,
xub_StrLen nIndex = 0, xub_StrLen nIndex = 0,
xub_StrLen nLen = STRING_LEN ); xub_StrLen nLen = STRING_LEN );
long GetTextArray( const XubString& rStr, sal_Int32* pDXAry = NULL, long GetTextArray( const OUString& rStr, sal_Int32* pDXAry = NULL,
xub_StrLen nIndex = 0, sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const;
xub_StrLen nLen = STRING_LEN ) const;
bool GetCaretPositions( const XubString&, sal_Int32* pCaretXArray, bool GetCaretPositions( const XubString&, sal_Int32* pCaretXArray,
xub_StrLen nIndex, xub_StrLen nLen, xub_StrLen nIndex, xub_StrLen nLen,
sal_Int32* pDXAry = NULL, long nWidth = 0, sal_Int32* pDXAry = NULL, long nWidth = 0,
......
...@@ -5475,7 +5475,11 @@ long OutputDevice::GetTextWidth( const String& rStr, ...@@ -5475,7 +5475,11 @@ long OutputDevice::GetTextWidth( const String& rStr,
{ {
DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
long nWidth = GetTextArray( rStr, NULL, nIndex, nLen ); 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 );
return nWidth; return nWidth;
} }
...@@ -5532,15 +5536,17 @@ void OutputDevice::DrawTextArray( const Point& rStartPt, const String& rStr, ...@@ -5532,15 +5536,17 @@ void OutputDevice::DrawTextArray( const Point& rStartPt, const String& rStr,
mpAlphaVDev->DrawTextArray( rStartPt, rStr, pDXAry, nIndex, nLen ); mpAlphaVDev->DrawTextArray( rStartPt, rStr, pDXAry, nIndex, nLen );
} }
long OutputDevice::GetTextArray( const String& rStr, sal_Int32* pDXAry, long OutputDevice::GetTextArray( const OUString& rStr, sal_Int32* pDXAry,
xub_StrLen nIndex, xub_StrLen nLen ) const sal_Int32 nIndex, sal_Int32 nLen ) const
{ {
// MEM: default nLen = STRING_LENGTH
DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
if( nIndex >= rStr.Len() ) if( nIndex >= rStr.getLength() )
return 0; return 0;
if( (sal_uLong)nIndex+nLen >= rStr.Len() )
nLen = rStr.Len() - nIndex; if( nLen < 0 || nIndex+nLen >= rStr.getLength() )
nLen = rStr.getLength() - nIndex;
// do layout // do layout
SalLayout* pSalLayout = ImplLayout( rStr, nIndex, nLen ); SalLayout* pSalLayout = ImplLayout( rStr, nIndex, nLen );
...@@ -5776,12 +5782,8 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr, ...@@ -5776,12 +5782,8 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr,
return aLayoutArgs; return aLayoutArgs;
} }
SalLayout* OutputDevice::ImplLayout( const String& rOrigStr, SalLayout* OutputDevice::ImplLayout( const OUString& rOrigStr, sal_Int32 nMinIndex, sal_Int32 nLen,
xub_StrLen nMinIndex, const Point& rLogicalPos, long nLogicalWidth, const sal_Int32* pDXArray,
xub_StrLen nLen,
const Point& rLogicalPos,
long nLogicalWidth,
const sal_Int32* pDXArray,
bool bFilter ) const bool bFilter ) const
{ {
// we need a graphics // we need a graphics
...@@ -5797,28 +5799,21 @@ SalLayout* OutputDevice::ImplLayout( const String& rOrigStr, ...@@ -5797,28 +5799,21 @@ SalLayout* OutputDevice::ImplLayout( const String& rOrigStr,
ImplInitFont(); ImplInitFont();
// check string index and length // check string index and length
if( (unsigned)nMinIndex + nLen > rOrigStr.Len() ) if( nMinIndex + nLen > rOrigStr.getLength() )
{ {
const int nNewLen = (int)rOrigStr.Len() - nMinIndex; const sal_Int32 nNewLen = rOrigStr.getLength() - nMinIndex;
if( nNewLen <= 0 ) if( nNewLen <= 0 )
return NULL; return NULL;
nLen = static_cast<xub_StrLen>(nNewLen); nLen = nNewLen;
} }
String aStr = rOrigStr; OUString aStr = rOrigStr;
// filter out special markers // filter out special markers
if( bFilter ) if( bFilter )
{ {
sal_Int32 nCutStart, nCutStop, nOrgLen = nLen; sal_Int32 nCutStart, nCutStop, nOrgLen = nLen;
OUString aTmpStr(aStr); bool bFiltered = mpGraphics->filterText( rOrigStr, aStr, nMinIndex, nLen, nCutStart, nCutStop );
OUString aTmpOrigStr(rOrigStr); // only needed until rOrigStr is OUString
sal_Int32 nMinIndex2=nMinIndex; // ditto
sal_Int32 nLen2=nLen; // ditto
bool bFiltered = mpGraphics->filterText( aTmpOrigStr, aTmpStr, nMinIndex2, nLen2, nCutStart, nCutStop );
nLen = nLen2; // ditto
nMinIndex = nMinIndex2; // ditto
aStr = aTmpStr;
if( !nLen ) if( !nLen )
return NULL; return NULL;
...@@ -5843,9 +5838,7 @@ SalLayout* OutputDevice::ImplLayout( const String& rOrigStr, ...@@ -5843,9 +5838,7 @@ SalLayout* OutputDevice::ImplLayout( const String& rOrigStr,
// convert from logical units to physical units // convert from logical units to physical units
// recode string if needed // recode string if needed
if( mpFontEntry->mpConversion ) { if( mpFontEntry->mpConversion ) {
OUString aTmpStr(aStr); // only needed until aStr is OUString as well mpFontEntry->mpConversion->RecodeString( aStr, 0, aStr.getLength() );
mpFontEntry->mpConversion->RecodeString( aTmpStr, 0, aTmpStr.getLength() );
aStr = String(aTmpStr);
} }
long nPixelWidth = nLogicalWidth; long nPixelWidth = nLogicalWidth;
...@@ -5863,13 +5856,7 @@ SalLayout* OutputDevice::ImplLayout( const String& rOrigStr, ...@@ -5863,13 +5856,7 @@ SalLayout* OutputDevice::ImplLayout( const String& rOrigStr,
pDXArray = pTempDXAry; pDXArray = pTempDXAry;
} }
OUString aTmpStr(aStr); // only needed until aStr is OUString as well ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nMinIndex, nLen, nPixelWidth, pDXArray );
sal_Int32 nMinIndex2=nMinIndex; // ditto
sal_Int32 nLen2=nLen; // ditto
ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aTmpStr, nMinIndex, nLen, nPixelWidth, pDXArray );
aStr = String(aTmpStr); // ditto
nLen = nLen2; // ditto
nMinIndex = nMinIndex2; // ditto
// get matching layout object for base font // get matching layout object for base font
SalLayout* pSalLayout = NULL; SalLayout* pSalLayout = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment