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


Hi *,

small patches partially cleaning svltools from svarrays.

Best Regards,
    Maciej Rumianowski
From 574028e9cef7bfcfc5d7fcaafa075ad1b8e9bb49 Mon Sep 17 00:00:00 2001
From: Maciej Rumianowski <maciej.rumianowski@gmail.com>
Date: Sat, 25 Feb 2012 14:58:16 +0100
Subject: [PATCH 1/3] Replace VARARR_SORT TESortedPositions with std::set

---
 svtools/source/edit/texteng.cxx |   51 ++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/svtools/source/edit/texteng.cxx b/svtools/source/edit/texteng.cxx
index 74c4119..5369a68 100644
--- a/svtools/source/edit/texteng.cxx
+++ b/svtools/source/edit/texteng.cxx
@@ -64,6 +64,8 @@
 
 #include <unicode/ubidi.h>
 
+#include <set>
+
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::rtl;
@@ -72,9 +74,6 @@ typedef TextView* TextViewPtr;
 SV_DECL_PTRARR( TextViews, TextViewPtr, 0 )
 // SV_IMPL_PTRARR( TextViews, TextViewPtr );
 
-SV_DECL_VARARR_SORT( TESortedPositions, sal_uLong, 16 )
-SV_IMPL_VARARR_SORT( TESortedPositions, sal_uLong )
-
 #define RESDIFF     10
 #define SCRLRANGE   20      // 1/20 der Breite/Hoehe scrollen, wenn im QueryDrop
 
@@ -1822,25 +1821,23 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos )
     TextNode* pNode = pTEParaPortion->GetNode();
     DBG_ASSERT( pNode->GetText().Len(), "CreateTextPortions sollte nicht fuer leere Absaetze 
verwendet werden!" );
 
-    TESortedPositions aPositions;
-    sal_uLong nZero = 0;
-    aPositions.Insert( nZero );
+    std::set<sal_uInt16> aPositions;
+    std::set<sal_uInt16>::iterator aPositionsIt;
+    aPositions.insert(0);
 
     sal_uInt16 nAttribs = pNode->GetCharAttribs().Count();
     for ( sal_uInt16 nAttr = 0; nAttr < nAttribs; nAttr++ )
     {
         TextCharAttrib* pAttrib = pNode->GetCharAttribs().GetAttrib( nAttr );
 
-        // Start und Ende in das Array eintragen...
-        // Die InsertMethode laesst keine doppelten Werte zu....
-        aPositions.Insert( pAttrib->GetStart() );
-        aPositions.Insert( pAttrib->GetEnd() );
+        aPositions.insert( pAttrib->GetStart() );
+        aPositions.insert( pAttrib->GetEnd() );
     }
-    aPositions.Insert( pNode->GetText().Len() );
+    aPositions.insert( pNode->GetText().Len() );
 
     const TEWritingDirectionInfos& rWritingDirections = pTEParaPortion->GetWritingDirectionInfos();
     for ( sal_uInt16 nD = 0; nD < rWritingDirections.Count(); nD++ )
-        aPositions.Insert( rWritingDirections[nD].nStartPos );
+        aPositions.insert( rWritingDirections[nD].nStartPos );
 
     if ( mpIMEInfos && mpIMEInfos->pAttribs && ( mpIMEInfos->aPos.GetPara() == nPara ) )
     {
@@ -1849,7 +1846,7 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos )
         {
             if ( mpIMEInfos->pAttribs[n] != nLastAttr )
             {
-                aPositions.Insert( mpIMEInfos->aPos.GetIndex() + n );
+                aPositions.insert( mpIMEInfos->aPos.GetIndex() + n );
                 nLastAttr = mpIMEInfos->pAttribs[n];
             }
         }
@@ -1858,8 +1855,8 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos )
     sal_uInt16 nTabPos = pNode->GetText().Search( '\t', 0 );
     while ( nTabPos != STRING_NOTFOUND )
     {
-        aPositions.Insert( nTabPos );
-        aPositions.Insert( nTabPos + 1 );
+        aPositions.insert( nTabPos );
+        aPositions.insert( nTabPos + 1 );
         nTabPos = pNode->GetText().Search( '\t', nTabPos+1 );
     }
 
@@ -1892,21 +1889,21 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos )
     pTEParaPortion->GetTextPortions().DeleteFromPortion( nInvPortion );
 
     // Eine Portion kann auch durch einen Zeilenumbruch entstanden sein:
-    aPositions.Insert( nPortionStart );
+    aPositions.insert( nPortionStart );
 
-    sal_uInt16 nInvPos;
-    #ifdef DBG_UTIL
-    sal_Bool bFound =
-    #endif
-        aPositions.Seek_Entry( nPortionStart, &nInvPos );
-    DBG_ASSERT( bFound && ( nInvPos < (aPositions.Count()-1) ), "InvPos ?!" );
-    for ( sal_uInt16 i = nInvPos+1; i < aPositions.Count(); i++ )
+    aPositionsIt = aPositions.find( nPortionStart );
+    DBG_ASSERT( aPositionsIt != aPositions.end(), "nPortionStart not found" );
+
+    if ( aPositionsIt != aPositions.end() )
     {
-        TETextPortion* pNew = new TETextPortion( (sal_uInt16)aPositions[i] - 
(sal_uInt16)aPositions[i-1] );
-        pTEParaPortion->GetTextPortions().Insert( pNew, pTEParaPortion->GetTextPortions().Count());
+        std::set<sal_uInt16>::iterator nextIt = aPositionsIt;
+        for ( ++nextIt; nextIt != aPositions.end(); ++aPositionsIt, ++nextIt )
+        {
+            TETextPortion* pNew = new TETextPortion( *nextIt - *aPositionsIt );
+            pTEParaPortion->GetTextPortions().Insert( pNew, 
pTEParaPortion->GetTextPortions().Count());
+        }
     }
-
-    DBG_ASSERT( pTEParaPortion->GetTextPortions().Count(), "Keine Portions?!" );
+    DBG_ASSERT( pTEParaPortion->GetTextPortions().Count(), "No Portions?!" );
 }
 
 void TextEngine::RecalcTextPortion( sal_uLong nPara, sal_uInt16 nStartPos, short nNewChars )
-- 
1.7.5.4

From a648822050d6aca61ee95f744c23bf8df57bc853 Mon Sep 17 00:00:00 2001
From: Maciej Rumianowski <maciej.rumianowski@gmail.com>
Date: Sat, 25 Feb 2012 15:34:30 +0100
Subject: [PATCH 2/3] Replace VARARR TEWritingDirectionInfos with std::vector

---
 svtools/source/edit/textdat2.hxx |    8 ++++----
 svtools/source/edit/textdata.cxx |    5 ++---
 svtools/source/edit/texteng.cxx  |   35 ++++++++++++++++++-----------------
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/svtools/source/edit/textdat2.hxx b/svtools/source/edit/textdat2.hxx
index 945fd233..c34f5ec 100644
--- a/svtools/source/edit/textdat2.hxx
+++ b/svtools/source/edit/textdat2.hxx
@@ -35,6 +35,8 @@
 #include <vcl/virdev.hxx>
 #include <vcl/cursor.hxx>
 
+#include <vector>
+
 class TextNode;
 class TextView;
 
@@ -117,8 +119,6 @@ struct TEWritingDirectionInfo
     }
 };
 
-SV_DECL_VARARR( TEWritingDirectionInfos, TEWritingDirectionInfo, 0 )
-
 class TextLine
 {
 private:
@@ -202,7 +202,7 @@ private:
 
     TextLines               maLines;
     TETextPortionList       maTextPortions;
-    TEWritingDirectionInfos maWritingDirectionInfos;
+    std::vector<TEWritingDirectionInfo> maWritingDirectionInfos;
 
 
     sal_uInt16              mnInvalidPosStart;
@@ -233,7 +233,7 @@ public:
     TextNode*           GetNode() const             { return mpNode; }
     TextLines&          GetLines()                  { return maLines; }
     TETextPortionList&  GetTextPortions()           { return maTextPortions; }
-    TEWritingDirectionInfos& GetWritingDirectionInfos() { return maWritingDirectionInfos; }
+    std::vector<TEWritingDirectionInfo>& GetWritingDirectionInfos() { return 
maWritingDirectionInfos; }
 
 
     sal_uInt16              GetLineNumber( sal_uInt16 nIndex, sal_Bool bInclEnd );
diff --git a/svtools/source/edit/textdata.cxx b/svtools/source/edit/textdata.cxx
index 4023c86..894887d 100644
--- a/svtools/source/edit/textdata.cxx
+++ b/svtools/source/edit/textdata.cxx
@@ -33,7 +33,6 @@
 #include <tools/debug.hxx>
 
 SV_IMPL_PTRARR( TextLines, TextLinePtr );
-SV_IMPL_VARARR( TEWritingDirectionInfos, TEWritingDirectionInfo );
 
 
 // -------------------------------------------------------------------------
@@ -173,7 +172,7 @@ void TEParaPortion::MarkInvalid( sal_uInt16 nStart, short nDiff )
         }
     }
 
-    maWritingDirectionInfos.Remove( 0, maWritingDirectionInfos.Count() );
+    maWritingDirectionInfos.clear();
 
     mbInvalid = sal_True;
 }
@@ -191,7 +190,7 @@ void TEParaPortion::MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 /*nEnd*/
 //      nInvalidPosEnd = pNode->Len();
     }
 
-    maWritingDirectionInfos.Remove( 0, maWritingDirectionInfos.Count() );
+    maWritingDirectionInfos.clear();
 
     mnInvalidDiff = 0;
     mbInvalid = sal_True;
diff --git a/svtools/source/edit/texteng.cxx b/svtools/source/edit/texteng.cxx
index 5369a68..1ab2a8f 100644
--- a/svtools/source/edit/texteng.cxx
+++ b/svtools/source/edit/texteng.cxx
@@ -65,6 +65,7 @@
 #include <unicode/ubidi.h>
 
 #include <set>
+#include <vector>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -1835,9 +1836,9 @@ void TextEngine::CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos )
     }
     aPositions.insert( pNode->GetText().Len() );
 
-    const TEWritingDirectionInfos& rWritingDirections = pTEParaPortion->GetWritingDirectionInfos();
-    for ( sal_uInt16 nD = 0; nD < rWritingDirections.Count(); nD++ )
-        aPositions.insert( rWritingDirections[nD].nStartPos );
+    const std::vector<TEWritingDirectionInfo>& rWritingDirections = 
pTEParaPortion->GetWritingDirectionInfos();
+    for ( std::vector<TEWritingDirectionInfo>::const_iterator it = rWritingDirections.begin(); it 
!= rWritingDirections.end(); ++it )
+        aPositions.insert( (*it).nStartPos );
 
     if ( mpIMEInfos && mpIMEInfos->pAttribs && ( mpIMEInfos->aPos.GetPara() == nPara ) )
     {
@@ -2252,10 +2253,10 @@ sal_Bool TextEngine::CreateLines( sal_uLong nPara )
     const sal_uInt16 nInvalidEnd =  nInvalidStart + Abs( nInvalidDiff );
     sal_Bool bQuickFormat = sal_False;
 
-    if ( !pTEParaPortion->GetWritingDirectionInfos().Count() )
+    if ( pTEParaPortion->GetWritingDirectionInfos().empty() )
         ImpInitWritingDirections( nPara );
 
-    if ( pTEParaPortion->GetWritingDirectionInfos().Count() == 1 )
+    if ( pTEParaPortion->GetWritingDirectionInfos().size() == 1 )
     {
         if ( pTEParaPortion->IsSimpleInvalid() && ( nInvalidDiff > 0 ) )
         {
@@ -3015,8 +3016,8 @@ void TextEngine::SetRightToLeft( sal_Bool bR2L )
 void TextEngine::ImpInitWritingDirections( sal_uLong nPara )
 {
     TEParaPortion* pParaPortion = mpTEParaPortions->GetObject( nPara );
-    TEWritingDirectionInfos& rInfos = pParaPortion->GetWritingDirectionInfos();
-    rInfos.Remove( 0, rInfos.Count() );
+    std::vector<TEWritingDirectionInfo>& rInfos = pParaPortion->GetWritingDirectionInfos();
+    rInfos.clear();
 
     if ( pParaPortion->GetNode()->GetText().Len() )
     {
@@ -3042,7 +3043,7 @@ void TextEngine::ImpInitWritingDirections( sal_uLong nPara )
         for ( sal_uInt16 nIdx = 0; nIdx < nCount; ++nIdx )
         {
             ubidi_getLogicalRun( pBidi, nStart, &nEnd, &nCurrDir );
-            rInfos.Insert( TEWritingDirectionInfo( nCurrDir, (sal_uInt16)nStart, (sal_uInt16)nEnd 
), rInfos.Count() );
+            rInfos.push_back( TEWritingDirectionInfo( nCurrDir, (sal_uInt16)nStart, 
(sal_uInt16)nEnd ) );
             nStart = nEnd;
         }
 
@@ -3050,8 +3051,8 @@ void TextEngine::ImpInitWritingDirections( sal_uLong nPara )
     }
 
     // No infos mean no CTL and default dir is L2R...
-    if ( !rInfos.Count() )
-        rInfos.Insert( TEWritingDirectionInfo( 0, 0, 
(sal_uInt16)pParaPortion->GetNode()->GetText().Len() ), rInfos.Count() );
+    if ( rInfos.empty() )
+        rInfos.push_back( TEWritingDirectionInfo( 0, 0, 
(sal_uInt16)pParaPortion->GetNode()->GetText().Len() ) );
 
 }
 
@@ -3063,19 +3064,19 @@ sal_uInt8 TextEngine::ImpGetRightToLeft( sal_uLong nPara, sal_uInt16 nPos, 
sal_u
     if ( pNode && pNode->GetText().Len() )
     {
         TEParaPortion* pParaPortion = mpTEParaPortions->GetObject( nPara );
-        if ( !pParaPortion->GetWritingDirectionInfos().Count() )
+        if ( pParaPortion->GetWritingDirectionInfos().empty() )
             ImpInitWritingDirections( nPara );
 
-        TEWritingDirectionInfos& rDirInfos = pParaPortion->GetWritingDirectionInfos();
-        for ( sal_uInt16 n = 0; n < rDirInfos.Count(); n++ )
+        std::vector<TEWritingDirectionInfo>& rDirInfos = pParaPortion->GetWritingDirectionInfos();
+        for ( std::vector<TEWritingDirectionInfo>::const_iterator rDirInfosIt = rDirInfos.begin(); 
rDirInfosIt != rDirInfos.end(); ++rDirInfosIt )
         {
-            if ( ( rDirInfos[n].nStartPos <= nPos ) && ( rDirInfos[n].nEndPos >= nPos ) )
+            if ( ( (*rDirInfosIt).nStartPos <= nPos ) && ( (*rDirInfosIt).nEndPos >= nPos ) )
                {
-                nRightToLeft = rDirInfos[n].nType;
+                nRightToLeft = (*rDirInfosIt).nType;
                 if ( pStart )
-                    *pStart = rDirInfos[n].nStartPos;
+                    *pStart = (*rDirInfosIt).nStartPos;
                 if ( pEnd )
-                    *pEnd = rDirInfos[n].nEndPos;
+                    *pEnd = (*rDirInfosIt).nEndPos;
                 break;
             }
         }
-- 
1.7.5.4

From 8a41843bd053bdb84fb055086bde75e3b135ecac Mon Sep 17 00:00:00 2001
From: Maciej Rumianowski <maciej.rumianowski@gmail.com>
Date: Sat, 25 Feb 2012 16:07:42 +0100
Subject: [PATCH 3/3] Remove unused code TESortedPositions and
 TEWritingDirectionInfos

---
 unusedcode.easy |   12 ------------
 1 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/unusedcode.easy b/unusedcode.easy
index e845b81..8db0c02 100755
--- a/unusedcode.easy
+++ b/unusedcode.easy
@@ -406,18 +406,6 @@ SwpHtStart::Insert(SwTxtAttr const**, unsigned short)
 SwpHtStart::Insert(SwpHtStart const*, unsigned short, unsigned short)
 SwpHtStart::Remove(SwTxtAttr const*&, unsigned short)
 SystemChildWindow::SystemChildWindow(Window*, ResId const&)
-TESortedPositions::Insert(TESortedPositions const*, unsigned short, unsigned short)
-TESortedPositions::Insert(unsigned long const&, unsigned short&)
-TESortedPositions::Insert(unsigned long const*, unsigned short)
-TESortedPositions::Remove(unsigned long const&, unsigned short)
-TESortedPositions::Remove(unsigned short, unsigned short)
-TESortedPositions_SAR::Replace(unsigned long const&, unsigned short)
-TESortedPositions_SAR::Replace(unsigned long const*, unsigned short, unsigned short)
-TESortedPositions_SAR::_ForEach(unsigned short, unsigned short, unsigned char (*)(unsigned long 
const&, void*), void*)
-TEWritingDirectionInfos::Insert(TEWritingDirectionInfos const*, unsigned short, unsigned short, 
unsigned short)
-TEWritingDirectionInfos::Replace(TEWritingDirectionInfo const&, unsigned short)
-TEWritingDirectionInfos::Replace(TEWritingDirectionInfo const*, unsigned short, unsigned short)
-TEWritingDirectionInfos::_ForEach(unsigned short, unsigned short, unsigned char 
(*)(TEWritingDirectionInfo const&, void*), void*)
 TaskBar::TaskBar(Window*, long)
 TaskStatusFieldItem::TaskStatusFieldItem()
 TempFile::IsValid() const
-- 
1.7.5.4


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.