Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3099

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/99/3099/1

Use OUString / sal_Int32 in vcl(outdev3.cxx,textlayout.cxx)

ImplGetTextLines(), GetCaretPositions(), ImplAddDevFontSubstitute(), AddFontSubstitute() ...

Change-Id: I781364da7a36afef65aac7a683c1b80fad61671e
---
M vcl/inc/textlayout.hxx
M vcl/inc/vcl/outdev.hxx
M vcl/source/gdi/outdev3.cxx
M vcl/source/gdi/textlayout.cxx
4 files changed, 65 insertions(+), 66 deletions(-)



diff --git a/vcl/inc/textlayout.hxx b/vcl/inc/textlayout.hxx
index 5e95eab..28f21eb 100644
--- a/vcl/inc/textlayout.hxx
+++ b/vcl/inc/textlayout.hxx
@@ -41,10 +41,10 @@
     {
     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 @@
                             ) 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 e0dbd6c..a1424f6 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -415,7 +415,7 @@
     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 @@
 
     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 @@
                                        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 @@
 
     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 49e5b33..55194f3 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -313,8 +313,8 @@
     }
 }
 
-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 @@
     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 @@
 }
 
 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 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 @@
         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 @@
                             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 @@
                 else
                 {
                     // fallback to something really simple
-                    sal_uInt16 nSpacePos = STRING_LEN;
+                    sal_Int32 nSpacePos = -1;
                     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 @@
                         }
                     } 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 @@
                 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 @@
     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 @@
         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 d03ea25..5e70329 100644
--- a/vcl/source/gdi/textlayout.cxx
+++ b/vcl/source/gdi/textlayout.cxx
@@ -56,21 +56,21 @@
     }
 
     //--------------------------------------------------------------------
-    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 @@
 
         // 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
     {
         //................................................................
-        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 @@
     }
 
     //--------------------------------------------------------------------
-    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 @@
     }
 
     //--------------------------------------------------------------------
-    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 @@
             ::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 @@
     }
 
     //--------------------------------------------------------------------
-    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 @@
     }
 
     //--------------------------------------------------------------------
-    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 @@
     }
 
     //--------------------------------------------------------------------
-    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

-- 
To view, visit https://gerrit.libreoffice.org/3099
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I781364da7a36afef65aac7a683c1b80fad61671e
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Christina Roßmanith <ChrRossmanith@web.de>


Context


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.