vcl get rid of xub_StrLen and STRING_LEN in outdev3

a new log section (sal.rtl.xub) is used to display alert in case of
suspicious len == 0xFFFF (aka STRING_LEN)

Change-Id: I3ed2aa7896e12592be9e003580dd6c8eda4add5e
Reviewed-on: https://gerrit.libreoffice.org/7117
Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com>
This commit is contained in:
Norbert Thiebaud
2013-12-18 01:54:16 +00:00
parent 8272ffb8ed
commit 4c539fac01
20 changed files with 198 additions and 101 deletions
+1 -1
View File
@@ -150,7 +150,7 @@ void LibLBoxString::Paint(const Point& rPos, SvTreeListBox& rDev, const SvViewDa
&& xDlgLibContainer->isLibraryReadOnly(aLibName));
}
if (bReadOnly)
rDev.DrawCtrlText(rPos, GetText(), 0, STRING_LEN, TEXT_DRAW_DISABLE);
rDev.DrawCtrlText(rPos, GetText(), 0, -1, TEXT_DRAW_DISABLE);
else
rDev.DrawText(rPos, GetText());
}
+4 -4
View File
@@ -787,8 +787,8 @@ namespace oglcanvas
aVDev.GetTextOutlines(rAct.maPolyPolys,
rTxt.Text,
0,
(xub_StrLen)rTxt.StartPosition,
(xub_StrLen)rTxt.Length,
rTxt.StartPosition,
rTxt.Length,
true,
0,
pDXArray.get() );
@@ -799,8 +799,8 @@ namespace oglcanvas
aVDev.GetTextOutlines(rAct.maPolyPolys,
rTxt.Text,
0,
(xub_StrLen)rTxt.StartPosition,
(xub_StrLen)rTxt.Length );
rTxt.StartPosition,
rTxt.Length );
}
// own copy, for thread safety
+3 -3
View File
@@ -128,9 +128,9 @@ namespace vclcanvas
if (aVDev.GetTextOutlines(
aOutlines,
maText.Text,
::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition),
::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition),
::canvas::tools::numeric_cast<sal_uInt16>(maText.Length),
maText.StartPosition,
maText.StartPosition,
maText.Length,
sal_False,
0,
aOffsets.get()))
+1 -2
View File
@@ -200,8 +200,7 @@ namespace cppcanvas
::boost::scoped_array< sal_Int32 > pCharWidths( new sal_Int32[nLen] );
rVDev.GetTextArray( rText, pCharWidths.get(),
static_cast<sal_uInt16>(nStartPos),
static_cast<sal_uInt16>(nLen) );
nStartPos, nLen );
return setupDXArray( pCharWidths.get(), nLen, rState );
}
+1 -1
View File
@@ -652,7 +652,7 @@ void SfxAccCfgLBoxString_Impl::Paint(
if (pUserData->m_bIsConfigurable)
rDevice.DrawText(aPos, GetText());
else
rDevice.DrawCtrlText(aPos, GetText(), 0, STRING_LEN, TEXT_DRAW_DISABLE);
rDevice.DrawCtrlText(aPos, GetText(), 0, -1, TEXT_DRAW_DISABLE);
}
+1 -1
View File
@@ -2112,7 +2112,7 @@ void PSWriter::ImplText( const OUString& rUniString, const Point& rPos, const sa
sal_Bool bOldLineColor = bLineColor;
bLineColor = sal_False;
std::vector<PolyPolygon> aPolyPolyVec;
if ( aVirDev.GetTextOutlines( aPolyPolyVec, rUniString, 0, 0, STRING_LEN, sal_True, nWidth, pDXArry ) )
if ( aVirDev.GetTextOutlines( aPolyPolyVec, rUniString, 0, 0, -1, sal_True, nWidth, pDXArry ) )
{
// always adjust text position to match baseline alignment
ImplWriteLine( "pum" );
+1
View File
@@ -24,6 +24,7 @@ certain functionality.
@li @c sal.file
@li @c sal.osl - SAL OSL library
@li @c sal.rtl - SAL RTL library
@li @c sal.rtl.xub - SAL RTL warnings related to possible String->OUString conversion issues.
@li @c sal.textenc - the textencoding SAL library
@section basctl
+15 -15
View File
@@ -570,7 +570,7 @@ public:
sal_Bool bUnderlineAbove = sal_False );
void DrawText( const Point& rStartPt, const OUString& rStr,
xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN,
sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
MetricVector* pVector = NULL, OUString* pDisplayText = NULL );
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.
@@ -578,8 +578,8 @@ public:
float approximate_char_width() const;
void DrawTextArray( const Point& rStartPt, const OUString& rStr,
const sal_Int32* pDXAry = NULL,
xub_StrLen nIndex = 0,
xub_StrLen nLen = STRING_LEN );
sal_Int32 nIndex = 0,
sal_Int32 nLen = -1 );
long GetTextArray( const OUString& rStr, sal_Int32* pDXAry = NULL,
sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const;
bool GetCaretPositions( const OUString&, sal_Int32* pCaretXArray,
@@ -588,7 +588,7 @@ public:
sal_Bool bCellBreaking = sal_True ) const;
void DrawStretchText( const Point& rStartPt, sal_uLong nWidth,
const OUString& rStr,
xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN );
sal_Int32 nIndex = 0, sal_Int32 nLen = -1 );
sal_Int32 GetTextBreak( const OUString& rStr, long nTextWidth,
sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
long nCharExtra = 0 ) const;
@@ -619,29 +619,29 @@ public:
OUString GetEllipsisString( const OUString& rStr, long nMaxWidth,
sal_uInt16 nStyle = TEXT_DRAW_ENDELLIPSIS ) const;
void DrawCtrlText( const Point& rPos, const OUString& rStr,
xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN,
sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC, MetricVector* pVector = NULL, OUString* pDisplayText = NULL );
long GetCtrlTextWidth( const OUString& 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 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 OUString& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN,
const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const;
sal_Bool GetTextOutline( PolyPolygon&,
const OUString& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0,
xub_StrLen nLen = STRING_LEN, sal_Bool bOptimize = sal_True,
const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0,
sal_Int32 nLen = -1, sal_Bool bOptimize = sal_True,
sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const;
sal_Bool GetTextOutlines( PolyPolyVector&,
const OUString& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0,
xub_StrLen nLen = STRING_LEN, sal_Bool bOptimize = sal_True,
const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0,
sal_Int32 nLen = -1, sal_Bool bOptimize = sal_True,
sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const;
sal_Bool GetTextOutlines( ::basegfx::B2DPolyPolygonVector&,
const OUString& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0,
xub_StrLen nLen = STRING_LEN, sal_Bool bOptimize = sal_True,
const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0,
sal_Int32 nLen = -1, sal_Bool bOptimize = sal_True,
sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const;
sal_Bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex,
int nLen, int nBase, MetricVector& rVector );
@@ -901,7 +901,7 @@ public:
SystemFontData GetSysFontData( int nFallbacklevel ) const;
SystemTextLayoutData GetSysTextLayoutData( const Point& rStartPt, const OUString& rStr,
xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN,
sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
const sal_Int32* pDXAry = NULL ) const;
void SetTextColor( const Color& rColor );
+2 -1
View File
@@ -355,7 +355,8 @@ void ScMenuFloatingWindow::drawMenuItem(size_t nPos)
DecorationView aDecoView(this);
long nXOffset = 5;
long nYOffset = (aSize.Height() - maLabelFont.GetHeight())/2;
DrawCtrlText(Point(aPos.X()+nXOffset, aPos.Y() + nYOffset), maMenuItems[nPos].maText, 0, STRING_LEN,
DrawCtrlText(Point(aPos.X()+nXOffset, aPos.Y() + nYOffset), maMenuItems[nPos].maText, 0,
maMenuItems[nPos].maText.getLength(),
maMenuItems[nPos].mbEnabled ? TEXT_DRAW_MNEMONIC : TEXT_DRAW_DISABLE);
if (maMenuItems[nPos].mpSubMenuWin)
+1 -1
View File
@@ -515,7 +515,7 @@ void HeaderBar::ImplDrawItem( OutputDevice* pDev,
if ( IsEnabled() )
pDev->DrawText( Point( nTxtPos, nTxtPosY ), pItem->maOutText );
else
pDev->DrawCtrlText( Point( nTxtPos, nTxtPosY ), pItem->maOutText, 0, STRING_LEN, TEXT_DRAW_DISABLE );
pDev->DrawCtrlText( Point( nTxtPos, nTxtPosY ), pItem->maOutText, 0, pItem->maOutText.getLength(), TEXT_DRAW_DISABLE );
if( aSelectionTextColor != Color( COL_TRANSPARENT ) )
pDev->Pop();
}
+2 -2
View File
@@ -1197,8 +1197,8 @@ public:
if (mbEnabled)
mrParent.DrawText(aPos, aText);
else
mrParent.DrawCtrlText(
aPos, aText, 0, STRING_LEN, (TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC));
mrParent.DrawCtrlText( aPos, aText, 0, aText.getLength(),
(TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC));
}
void drawOverTopBorder(bool b3DTab)
@@ -283,9 +283,9 @@ void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, F
{
FWCharacterData aCharacterData;
OUString aCharText( (sal_Unicode)rText[ i ] );
if ( aVirDev.GetTextOutlines( aCharacterData.vOutlines, aCharText, 0, 0, STRING_LEN, sal_True, nWidth, pDXArry ) )
if ( aVirDev.GetTextOutlines( aCharacterData.vOutlines, aCharText, 0, 0, -1, sal_True, nWidth, pDXArry ) )
{
sal_Int32 nTextWidth = aVirDev.GetTextWidth( aCharText, 0, STRING_LEN );
sal_Int32 nTextWidth = aVirDev.GetTextWidth( aCharText);
std::vector< PolyPolygon >::iterator aOutlineIter = aCharacterData.vOutlines.begin();
std::vector< PolyPolygon >::iterator aOutlineIEnd = aCharacterData.vOutlines.end();
if ( aOutlineIter == aOutlineIEnd )
@@ -335,13 +335,13 @@ void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, F
if ( ( nCharScaleWidth != 100 ) && nCharScaleWidth )
{ // applying character spacing
pDXArry = new sal_Int32[ rText.getLength() ];
aVirDev.GetTextArray( rText, pDXArry, 0, STRING_LEN );
aVirDev.GetTextArray( rText, pDXArry);
FontMetric aFontMetric( aVirDev.GetFontMetric() );
aFont.SetWidth( (sal_Int32)( (double)aFontMetric.GetWidth() * ( (double)100 / (double)nCharScaleWidth ) ) );
aVirDev.SetFont( aFont );
}
FWCharacterData aCharacterData;
if ( aVirDev.GetTextOutlines( aCharacterData.vOutlines, rText, 0, 0, STRING_LEN, sal_True, nWidth, pDXArry ) )
if ( aVirDev.GetTextOutlines( aCharacterData.vOutlines, rText, 0, 0, -1, sal_True, nWidth, pDXArry ) )
{
aParagraphIter->vCharacters.push_back( aCharacterData );
}
+19 -14
View File
@@ -367,20 +367,25 @@ class ImplTextLineInfo
{
private:
long mnWidth;
xub_StrLen mnIndex;
xub_StrLen mnLen;
sal_Int32 mnIndex;
sal_Int32 mnLen;
public:
ImplTextLineInfo( long nWidth, xub_StrLen nIndex, xub_StrLen nLen )
{
mnWidth = nWidth;
mnIndex = nIndex;
mnLen = nLen;
}
ImplTextLineInfo( long nWidth, sal_Int32 nIndex, sal_Int32 nLen )
{
if(nIndex == -1 || nIndex == 0x0FFFF || nLen == -1 || nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"ImplTextLine Info Suspicious arguments nIndex:" << nIndex << " nLen:" << nLen);
}
mnWidth = nWidth;
mnIndex = nIndex;
mnLen = nLen;
}
long GetWidth() const { return mnWidth; }
xub_StrLen GetIndex() const { return mnIndex; }
xub_StrLen GetLen() const { return mnLen; }
long GetWidth() const { return mnWidth; }
sal_Int32 GetIndex() const { return mnIndex; }
sal_Int32 GetLen() const { return mnLen; }
};
#define MULTITEXTLINEINFO_RESIZE 16
@@ -390,8 +395,8 @@ class ImplMultiTextLineInfo
{
private:
PImplTextLineInfo* mpLines;
xub_StrLen mnLines;
xub_StrLen mnSize;
sal_Int32 mnLines;
sal_Int32 mnSize;
public:
ImplMultiTextLineInfo();
@@ -402,7 +407,7 @@ public:
ImplTextLineInfo* GetLine( sal_uInt16 nLine ) const
{ return mpLines[nLine]; }
xub_StrLen Count() const { return mnLines; }
sal_Int32 Count() const { return mnLines; }
private:
ImplMultiTextLineInfo( const ImplMultiTextLineInfo& );
+1 -1
View File
@@ -2268,7 +2268,7 @@ void RadioButton::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
aTxtPos.X() += aImageRect.Right()+8;
aTxtPos.Y() += (rSize.Height()-nTextHeight)/2;
}
pDev->DrawCtrlText( aTxtPos, aText, 0, STRING_LEN, TEXT_DRAW_MNEMONIC, pVector, pDisplayText );
pDev->DrawCtrlText( aTxtPos, aText, 0, aText.getLength(), TEXT_DRAW_MNEMONIC, pVector, pDisplayText );
}
rMouseRect = aImageRect;
+2 -2
View File
@@ -1009,8 +1009,8 @@ void TabControl::ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bo
if( ! pItem->mbEnabled )
nStyle |= TEXT_DRAW_DISABLE;
DrawCtrlText( Point( nXPos + aImageSize.Width(), nYPos ),
pItem->maFormatText,
0, STRING_LEN, nStyle,
pItem->maFormatText, 0,
pItem->maFormatText.getLength(), nStyle,
bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL,
bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL
);
+1 -1
View File
@@ -1546,7 +1546,7 @@ void WinMtfOutput::DrawText( Point& rPosition, OUString& rText, sal_Int32* pDXAr
pDX = new sal_Int32[ rText.getLength() ];
aVDev.SetMapMode( MAP_100TH_MM );
aVDev.SetFont( maLatestFont );
aVDev.GetTextArray( rText, pDX, 0, STRING_LEN );
aVDev.GetTextArray( rText, pDX, 0, rText.getLength());
}
mpGDIMetaFile->AddAction( new MetaTextArrayAction( rPosition, rText, pDX, 0, STRING_LEN ) );
if ( !pDXArry ) // this means we have created our own array
+2 -2
View File
@@ -847,7 +847,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
case( GDI_TEXTARRAY_ACTION ):
{
sal_Int32* pDXAry = NULL;
sal_Int32 nIndex, nLen, nAryLen;
sal_Int32 nIndex, nLen, nAryLen;
rIStm >> aPt >> nIndex >> nLen >> nTmp >> nAryLen;
if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_UINT16 - 1 ) ) )
@@ -875,7 +875,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
{
sal_Int32* pTmpAry = new sal_Int32[nStrLen];
aFontVDev.GetTextArray( aStr, pTmpAry, (sal_uInt16) nIndex, (sal_uInt16) nLen );
aFontVDev.GetTextArray( aStr, pTmpAry, nIndex, nLen );
// now, the difference between the
// last and the second last DX array
+133 -42
View File
@@ -5327,10 +5327,20 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos,
}
void OutputDevice::DrawText( const Point& rStartPt, const OUString& rStr,
xub_StrLen nIndex, xub_StrLen nLen,
sal_Int32 nIndex, sal_Int32 nLen,
MetricVector* pVector, OUString* pDisplayText
)
{
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"GetTextOutlines Suspicious arguments nLen:" << nLen);
}
if( (nLen < 0) || (nIndex + nLen >= rStr.getLength()))
{
nLen = rStr.getLength() - nIndex;
}
if( mpOutDevData && mpOutDevData->mpRecordLayout )
{
pVector = &mpOutDevData->mpRecordLayout->m_aUnicodeBoundRects;
@@ -5439,9 +5449,17 @@ float OutputDevice::approximate_char_width() const
void OutputDevice::DrawTextArray( const Point& rStartPt, const OUString& rStr,
const sal_Int32* pDXAry,
xub_StrLen nIndex, xub_StrLen nLen )
sal_Int32 nIndex, sal_Int32 nLen )
{
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"DrawTextArray Suspicious arguments nLen:" << nLen);
}
if( nLen < 0 || nIndex + nLen >= rStr.getLength() )
{
nLen = rStr.getLength() - nIndex;
}
if ( mpMetaFile )
mpMetaFile->AddAction( new MetaTextArrayAction( rStartPt, rStr, pDXAry, nIndex, nLen ) );
@@ -5469,13 +5487,19 @@ long OutputDevice::GetTextArray( const OUString& rStr, sal_Int32* pDXAry,
sal_Int32 nIndex, sal_Int32 nLen ) const
{
// MEM: default nLen = STRING_LENGTH
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"GetTextArray Suspicious arguments nLen:" << nLen);
}
if( nIndex >= rStr.getLength() )
return 0;
if( nLen < 0 || nIndex+nLen >= rStr.getLength() )
if( nLen < 0 || nIndex + nLen >= rStr.getLength() )
{
nLen = rStr.getLength() - nIndex;
}
// do layout
SalLayout* pSalLayout = ImplLayout( rStr, nIndex, nLen );
if( !pSalLayout )
@@ -5577,8 +5601,17 @@ bool OutputDevice::GetCaretPositions( const OUString& rStr, sal_Int32* pCaretXAr
void OutputDevice::DrawStretchText( const Point& rStartPt, sal_uLong nWidth,
const OUString& rStr,
xub_StrLen nIndex, xub_StrLen nLen )
sal_Int32 nIndex, sal_Int32 nLen )
{
if(nIndex < 0 || nIndex == 0x0FFFF || nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"DrawStretchText Suspicious arguments nIndex:" << nIndex << " nLen:" << nLen);
}
if( (nLen < 0) || (nIndex + nLen >= rStr.getLength()))
{
nLen = rStr.getLength() - nIndex;
}
if ( mpMetaFile )
mpMetaFile->AddAction( new MetaStretchTextAction( rStartPt, nWidth, rStr, nIndex, nLen ) );
@@ -6097,14 +6130,14 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& r
OUString aLastLine;
ImplMultiTextLineInfo aMultiLineInfo;
ImplTextLineInfo* pLineInfo;
xub_StrLen i;
xub_StrLen nLines;
xub_StrLen nFormatLines;
sal_Int32 i;
sal_Int32 nLines;
sal_Int32 nFormatLines;
if ( nTextHeight )
{
long nMaxTextWidth = ImplGetTextLines( aMultiLineInfo, nWidth, aStr, nStyle, _rLayout );
nLines = (xub_StrLen)(nHeight/nTextHeight);
nLines = (sal_Int32)(nHeight/nTextHeight);
nFormatLines = aMultiLineInfo.Count();
if ( !nLines )
nLines = 1;
@@ -6168,8 +6201,8 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& r
aPos.X() += nWidth-pLineInfo->GetWidth();
else if ( nStyle & TEXT_DRAW_CENTER )
aPos.X() += (nWidth-pLineInfo->GetWidth())/2;
xub_StrLen nIndex = pLineInfo->GetIndex();
xub_StrLen nLineLen = pLineInfo->GetLen();
sal_Int32 nIndex = pLineInfo->GetIndex();
sal_Int32 nLineLen = pLineInfo->GetLen();
_rLayout.DrawText( aPos, aStr, nIndex, nLineLen, pVector, pDisplayText );
if ( bDrawMnemonics )
{
@@ -6375,7 +6408,7 @@ Rectangle OutputDevice::GetTextRect( const Rectangle& rRect,
{
Rectangle aRect = rRect;
xub_StrLen nLines;
sal_Int32 nLines;
long nWidth = rRect.GetWidth();
long nMaxWidth;
long nTextHeight = GetTextHeight();
@@ -6388,8 +6421,8 @@ Rectangle OutputDevice::GetTextRect( const Rectangle& rRect,
{
ImplMultiTextLineInfo aMultiLineInfo;
ImplTextLineInfo* pLineInfo;
xub_StrLen nFormatLines;
xub_StrLen i;
sal_Int32 nFormatLines;
sal_Int32 i;
nMaxWidth = 0;
DefaultTextLayout aDefaultLayout( *const_cast< OutputDevice* >( this ) );
@@ -6631,10 +6664,20 @@ OUString OutputDevice::ImplGetEllipsisString( const OutputDevice& rTargetDevice,
}
void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr,
xub_StrLen nIndex, xub_StrLen nLen,
sal_Int32 nIndex, sal_Int32 nLen,
sal_uInt16 nStyle, MetricVector* pVector, OUString* pDisplayText )
{
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"DrawCtrlText Suspicious arguments nLen:" << nLen);
}
if( (nLen < 0) || (nIndex + nLen >= rStr.getLength()))
{
nLen = rStr.getLength() - nIndex;
}
if ( !IsDeviceOutputNecessary() || (nIndex >= rStr.getLength()) )
return;
@@ -6649,9 +6692,11 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr,
if( nIndex >= rStr.getLength() )
return;
if( (sal_Int32)nIndex+nLen >= rStr.getLength() )
nLen = rStr.getLength() - nIndex;
if( (nLen < 0) || (nIndex + nLen >= rStr.getLength()))
{
nLen = rStr.getLength() - nIndex;
}
OUString aStr = rStr;
sal_Int32 nMnemonicPos = -1;
@@ -6664,8 +6709,10 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr,
if ( nMnemonicPos != -1 )
{
if( nMnemonicPos < nIndex )
{
--nIndex;
else if( nLen < STRING_LEN )
}
else
{
if( nMnemonicPos < (nIndex+nLen) )
--nLen;
@@ -6760,9 +6807,19 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr,
}
long OutputDevice::GetCtrlTextWidth( const OUString& rStr,
xub_StrLen nIndex, xub_StrLen nLen,
sal_Int32 nIndex, sal_Int32 nLen,
sal_uInt16 nStyle ) const
{
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"GetCtrlTextWidth Suspicious arguments nLen:" << nLen);
}
/* defensive code */
if( (nLen < 0) || (nIndex + nLen >= rStr.getLength()))
{
nLen = rStr.getLength() - nIndex;
}
if ( nStyle & TEXT_DRAW_MNEMONIC )
{
@@ -6772,8 +6829,7 @@ long OutputDevice::GetCtrlTextWidth( const OUString& rStr,
{
if ( nMnemonicPos < nIndex )
nIndex--;
else if ( (nLen < STRING_LEN) &&
(nMnemonicPos >= nIndex) && ((sal_uLong)nMnemonicPos < (sal_uLong)(nIndex+nLen)) )
else if ( (nMnemonicPos >= nIndex) && ((sal_uLong)nMnemonicPos < (sal_uLong)(nIndex+nLen)) )
nLen--;
}
return GetTextWidth( aStr, nIndex, nLen );
@@ -7018,9 +7074,18 @@ SystemFontData OutputDevice::GetSysFontData(int nFallbacklevel) const
*
* @return SystemTextLayoutData
**/
SystemTextLayoutData OutputDevice::GetSysTextLayoutData(const Point& rStartPt, const OUString& rStr, xub_StrLen nIndex, xub_StrLen nLen,
SystemTextLayoutData OutputDevice::GetSysTextLayoutData(const Point& rStartPt, const OUString& rStr, sal_Int32 nIndex, sal_Int32 nLen,
const sal_Int32* pDXAry) const
{
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"GetSysTextLayoutData Suspicious arguments nLen:" << nLen);
}
if( (nLen < 0) || (nIndex + nLen >= rStr.getLength()))
{
nLen = rStr.getLength() - nIndex;
}
SystemTextLayoutData aSysLayoutData;
aSysLayoutData.nSize = sizeof(aSysLayoutData);
@@ -7100,7 +7165,7 @@ xub_StrLen OutputDevice::ValidateKashidas ( const OUString& rTxt,
}
sal_Bool OutputDevice::GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr,
int nIndex, int nLen, int nBase, MetricVector& rVector )
int nIndex, int nLen, int nBase, MetricVector& rVector )
{
rVector.clear();
@@ -7111,7 +7176,7 @@ sal_Bool OutputDevice::GetGlyphBoundRects( const Point& rOrigin, const OUString&
Rectangle aRect;
for( int i = 0; i < nLen; i++ )
{
if( !GetTextBoundRect( aRect, rStr, sal::static_int_cast<xub_StrLen>(nBase), sal::static_int_cast<xub_StrLen>(nIndex+i), 1 ) )
if( !GetTextBoundRect( aRect, rStr, nBase, nIndex + i, 1 ) )
break;
aRect.Move( rOrigin.X(), rOrigin.Y() );
rVector.push_back( aRect );
@@ -7121,9 +7186,15 @@ sal_Bool OutputDevice::GetGlyphBoundRects( const Point& rOrigin, const OUString&
}
sal_Bool OutputDevice::GetTextBoundRect( Rectangle& rRect,
const OUString& rStr, xub_StrLen nBase, xub_StrLen nIndex, xub_StrLen nLen,
sal_uLong nLayoutWidth, const sal_Int32* pDXAry ) const
const OUString& rStr, sal_Int32 nBase,
sal_Int32 nIndex, sal_Int32 nLen,
sal_uLong nLayoutWidth, const sal_Int32* pDXAry ) const
{
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"GetTextBoundRect Suspicious arguments nLen:" << nLen);
}
sal_Bool bRet = sal_False;
rRect.SetEmpty();
@@ -7134,8 +7205,8 @@ sal_Bool OutputDevice::GetTextBoundRect( Rectangle& rRect,
long nXOffset = 0;
if( nBase != nIndex )
{
xub_StrLen nStart = std::min( nBase, nIndex );
xub_StrLen nOfsLen = std::max( nBase, nIndex ) - nStart;
sal_Int32 nStart = std::min( nBase, nIndex );
sal_Int32 nOfsLen = std::max( nBase, nIndex ) - nStart;
pSalLayout = ImplLayout( rStr, nStart, nOfsLen, aPoint, nLayoutWidth, pDXAry );
if( pSalLayout )
{
@@ -7295,9 +7366,15 @@ sal_Bool OutputDevice::GetTextBoundRect( Rectangle& rRect,
}
sal_Bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector,
const OUString& rStr, xub_StrLen nBase, xub_StrLen nIndex, xub_StrLen nLen,
sal_Bool bOptimize, sal_uLong nTWidth, const sal_Int32* pDXArray ) const
const OUString& rStr, sal_Int32 nBase,
sal_Int32 nIndex, sal_Int32 nLen,
sal_Bool bOptimize, sal_uLong nTWidth, const sal_Int32* pDXArray ) const
{
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"GetTextOutlines Suspicious arguments nLen:" << nLen);
}
// the fonts need to be initialized
if( mbNewFont )
ImplNewFont();
@@ -7308,8 +7385,10 @@ sal_Bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector
sal_Bool bRet = sal_False;
rVector.clear();
if( nLen == STRING_LEN )
if( nLen < 0 )
{
nLen = rStr.getLength() - nIndex;
}
rVector.reserve( nLen );
// we want to get the Rectangle in logical units, so to
@@ -7327,8 +7406,8 @@ sal_Bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector
long nXOffset = 0;
if( nBase != nIndex )
{
xub_StrLen nStart = std::min( nBase, nIndex );
xub_StrLen nOfsLen = std::max( nBase, nIndex ) - nStart;
sal_Int32 nStart = std::min( nBase, nIndex );
sal_Int32 nOfsLen = std::max( nBase, nIndex ) - nStart;
pSalLayout = ImplLayout( rStr, nStart, nOfsLen, Point(0,0), nTWidth, pDXArray );
if( pSalLayout )
{
@@ -7432,8 +7511,8 @@ sal_Bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector
nXOffset = 0;
if( nBase != nIndex )
{
xub_StrLen nStart = ((nBase < nIndex) ? nBase : nIndex);
xub_StrLen nLength = ((nBase > nIndex) ? nBase : nIndex) - nStart;
sal_Int32 nStart = ((nBase < nIndex) ? nBase : nIndex);
sal_Int32 nLength = ((nBase > nIndex) ? nBase : nIndex) - nStart;
pSalLayout = aVDev.ImplLayout( rStr, nStart, nLength, Point(0,0), nTWidth, pDXArray );
if( pSalLayout )
{
@@ -7455,7 +7534,7 @@ sal_Bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector
bool bSuccess = false;
// draw character into virtual device
pSalLayout = aVDev.ImplLayout( rStr, static_cast< xub_StrLen >(nCharPos), 1, Point(0,0), nTWidth, pDXArray );
pSalLayout = aVDev.ImplLayout( rStr, nCharPos, 1, Point(0,0), nTWidth, pDXArray );
if (pSalLayout == 0)
return false;
long nCharWidth = pSalLayout->GetTextWidth();
@@ -7522,9 +7601,16 @@ sal_Bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector
}
sal_Bool OutputDevice::GetTextOutlines( PolyPolyVector& rResultVector,
const OUString& rStr, xub_StrLen nBase, xub_StrLen nIndex,
xub_StrLen nLen, sal_Bool bOptimize, sal_uLong nTWidth, const sal_Int32* pDXArray ) const
const OUString& rStr, sal_Int32 nBase,
sal_Int32 nIndex, sal_Int32 nLen, sal_Bool bOptimize,
sal_uLong nTWidth, const sal_Int32* pDXArray ) const
{
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"GetTextOutlines Suspicious arguments nLen:" << nLen);
}
rResultVector.clear();
// get the basegfx polypolygon vector
@@ -7542,10 +7628,15 @@ sal_Bool OutputDevice::GetTextOutlines( PolyPolyVector& rResultVector,
return sal_True;
}
sal_Bool OutputDevice::GetTextOutline( PolyPolygon& rPolyPoly,
const OUString& rStr, xub_StrLen nBase, xub_StrLen nIndex, xub_StrLen nLen,
sal_Bool bOptimize, sal_uLong nTWidth, const sal_Int32* pDXArray ) const
sal_Bool OutputDevice::GetTextOutline( PolyPolygon& rPolyPoly, const OUString& rStr,
sal_Int32 nBase, sal_Int32 nIndex, sal_Int32 nLen,
sal_Bool bOptimize, sal_uLong nTWidth, const sal_Int32* pDXArray ) const
{
if(nLen == 0x0FFFF)
{
SAL_INFO("sal.rtl.xub",
"GetTextOutline Suspicious arguments nLen:" << nLen);
}
rPolyPoly.Clear();
// get the basegfx polypolygon vector
+2 -2
View File
@@ -7567,7 +7567,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
else if( pCharPosAry[i] >= nMinCharPos && pCharPosAry[i] <= nMaxCharPos )
{
int nChars = 1;
aUnicodes.push_back( rText[ sal::static_int_cast<xub_StrLen>(pCharPosAry[i]) ] );
aUnicodes.push_back( rText[ pCharPosAry[i] ] );
pUnicodesPerGlyph[i] = 1;
// try to handle ligatures and such
if( i < nGlyphs-1 )
@@ -7581,7 +7581,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
nChars = 1;
pUnicodesPerGlyph[i] = nChars;
for( int n = 1; n < nChars; n++ )
aUnicodes.push_back( rText[ sal::static_int_cast<xub_StrLen>(pCharPosAry[i]+n) ] );
aUnicodes.push_back( rText[ pCharPosAry[i] + n ] );
}
// #i36691# hack that is needed because currently the pGlyphs[]
// argument is ignored for embeddable fonts and so the layout
+2 -2
View File
@@ -3138,7 +3138,7 @@ void ToolBox::ImplDrawItem( sal_uInt16 nPos, sal_uInt16 nHighlight, sal_Bool bPa
mpData->m_pLayoutData->m_aLineItemIds.push_back( pItem->mnId );
mpData->m_pLayoutData->m_aLineItemPositions.push_back( nPos );
}
DrawCtrlText( aPos, pItem->maText, 0, STRING_LEN, TEXT_DRAW_MNEMONIC, pVector, pDisplayText );
DrawCtrlText( aPos, pItem->maText, 0, pItem->maText.getLength(), TEXT_DRAW_MNEMONIC, pVector, pDisplayText );
if ( bClip )
SetClipRegion();
SetFont( aOldFont );
@@ -3307,7 +3307,7 @@ void ToolBox::ImplDrawItem( sal_uInt16 nPos, sal_uInt16 nHighlight, sal_Bool bPa
mpData->m_pLayoutData->m_aLineItemPositions.push_back( nPos );
}
DrawCtrlText( Point( nTextOffX, nTextOffY ), pItem->maText,
0, STRING_LEN, nTextStyle, pVector, pDisplayText );
0, pItem->maText.getLength(), nTextStyle, pVector, pDisplayText );
if ( bRotate )
SetFont( aOldFont );
}