diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2013-12-17 05:18:35 -0600 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2013-12-18 01:54:16 +0000 |
commit | 4c539fac018dfd44cd8db52161a8cb930c627da7 (patch) | |
tree | d7530d03926971e58584b64ce618984eb47baf74 | |
parent | 8272ffb8ed00f211a8fbda71136d695b42249b70 (diff) |
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>
-rw-r--r-- | basctl/source/basicide/moduldl2.cxx | 2 | ||||
-rw-r--r-- | canvas/source/opengl/ogl_canvashelper.cxx | 8 | ||||
-rw-r--r-- | canvas/source/vcl/textlayout.cxx | 6 | ||||
-rw-r--r-- | cppcanvas/source/mtfrenderer/textaction.cxx | 3 | ||||
-rw-r--r-- | cui/source/customize/acccfg.cxx | 2 | ||||
-rw-r--r-- | filter/source/graphicfilter/eps/eps.cxx | 2 | ||||
-rw-r--r-- | include/sal/log-areas.dox | 1 | ||||
-rw-r--r-- | include/vcl/outdev.hxx | 30 | ||||
-rw-r--r-- | sc/source/ui/cctrl/checklistmenu.cxx | 3 | ||||
-rw-r--r-- | svtools/source/control/headbar.cxx | 2 | ||||
-rw-r--r-- | svtools/source/control/tabbar.cxx | 4 | ||||
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShapeFontWork.cxx | 8 | ||||
-rw-r--r-- | vcl/inc/outfont.hxx | 35 | ||||
-rw-r--r-- | vcl/source/control/button.cxx | 2 | ||||
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 4 | ||||
-rw-r--r-- | vcl/source/filter/wmf/winmtf.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/cvtsvm.cxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/outdev3.cxx | 175 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/toolbox.cxx | 4 |
20 files changed, 199 insertions, 102 deletions
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index f4d5bad8b326..b52eea9e0013 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -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()); } diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx index 3d4bd55162ed..6ee3dabd4263 100644 --- a/canvas/source/opengl/ogl_canvashelper.cxx +++ b/canvas/source/opengl/ogl_canvashelper.cxx @@ -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 diff --git a/canvas/source/vcl/textlayout.cxx b/canvas/source/vcl/textlayout.cxx index d8a0b14fbed5..29134850e9fc 100644 --- a/canvas/source/vcl/textlayout.cxx +++ b/canvas/source/vcl/textlayout.cxx @@ -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())) diff --git a/cppcanvas/source/mtfrenderer/textaction.cxx b/cppcanvas/source/mtfrenderer/textaction.cxx index 65d1843e1ae0..b231c2129cf8 100644 --- a/cppcanvas/source/mtfrenderer/textaction.cxx +++ b/cppcanvas/source/mtfrenderer/textaction.cxx @@ -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 ); } diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx index b0755361a2d2..0968bbf85ce3 100644 --- a/cui/source/customize/acccfg.cxx +++ b/cui/source/customize/acccfg.cxx @@ -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); } diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index 3a7701572673..effeb74087cb 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -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" ); diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox index ed8e39e59ded..58ffbaa444bc 100644 --- a/include/sal/log-areas.dox +++ b/include/sal/log-areas.dox @@ -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 diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 00016cfa0d75..b0d5089743e2 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -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 ); diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index 2cde8eb453ea..61ef14b2fa93 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -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) diff --git a/svtools/source/control/headbar.cxx b/svtools/source/control/headbar.cxx index cb44b4dd7f24..fb6de9f41fa3 100644 --- a/svtools/source/control/headbar.cxx +++ b/svtools/source/control/headbar.cxx @@ -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(); } diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index c0b8059e8d1c..1f826da7916f 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -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) diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx index 4d6cbdfd4213..e7a67faa93ef 100644 --- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx @@ -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 ); } diff --git a/vcl/inc/outfont.hxx b/vcl/inc/outfont.hxx index 4e1af96bfde1..8229169ddbbc 100644 --- a/vcl/inc/outfont.hxx +++ b/vcl/inc/outfont.hxx @@ -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; - } - - long GetWidth() const { return mnWidth; } - xub_StrLen GetIndex() const { return mnIndex; } - xub_StrLen GetLen() const { return mnLen; } + 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; } + 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& ); diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 085c932a71e0..81143630df47 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -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; diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 640af54cb4a7..474d664534f1 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -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 ); diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx index bfd30eb23b88..31b99da1b2f8 100644 --- a/vcl/source/filter/wmf/winmtf.cxx +++ b/vcl/source/filter/wmf/winmtf.cxx @@ -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 diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx index 630cfcf8b611..46ee97c3a9c1 100644 --- a/vcl/source/gdi/cvtsvm.cxx +++ b/vcl/source/gdi/cvtsvm.cxx @@ -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 diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 7f099373fd01..36c7203064ed 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -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 diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index bebe02687203..be7720e6d9f9 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -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 diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index b59d14336d36..bcde38e4eec0 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -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 ); } |