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


Hi.

I updates the patch.
Could you please push it to libreoffice?

Thanks in advance
Bartosz

W dniu 5 marca 2012 14:38 użytkownik Ivan Timofeev
<timofeev.i.s@gmail.com>napisał:

Hi Bartosz,


On 29.02.2012 13:45, Bartosz wrote:

I converted the SV_DECL_VARARR_SORT and SV_IMPL_VARARR_SORT with
::std::set.
I also made some optimization (cppcheck).

Could you please check this patch and push it into libreoffice.


Oh, sorry, your patch does not apply due to
cgit.freedesktop.org/**libreoffice/core/commit/?id=**
cf2fbadf90c1cb255e39529b856df3**eaef1e0226<http://cgit.freedesktop.org/libreoffice/core/commit/?id=cf2fbadf90c1cb255e39529b856df3eaef1e0226>
by Maciej Rumianowski, but he submitted it prior to your mail. Could you
send another patch (preferably created with "git format-patch")? Thanks a
lot!

Ivan

From c721abb9c9a5e5a5652e6b49219a8cabd95b7ac9 Mon Sep 17 00:00:00 2001
From: Bartosz Kosiorek <gang65@poczta.onet.pl>
Date: Sat, 10 Mar 2012 22:16:16 +0100
Subject: [PATCH 2/2] Replace VARARR_SORT with std

---
 editeng/source/editeng/impedit.hxx  |    6 ++--
 editeng/source/editeng/impedit3.cxx |   50 ++++++++++++++---------------------
 editeng/source/editeng/impedit4.cxx |    4 +-
 3 files changed, 25 insertions(+), 35 deletions(-)

diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 2076d29..5196703 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -905,7 +905,7 @@ public:
     LanguageType        GetDefaultLanguage() const { return eDefLanguage; }
 
 
-    LanguageType        GetLanguage( const EditSelection rSelection ) const;
+    LanguageType        GetLanguage( const EditSelection &rSelection ) const;
     LanguageType        GetLanguage( const EditPaM& rPaM, sal_uInt16* pEndPos = NULL ) const;
     ::com::sun::star::lang::Locale GetLocale( const EditPaM& rPaM ) const;
 
@@ -945,12 +945,12 @@ public:
     //adds one or more portions of text to the SpellPortions depending on language changes
     void            AddPortionIterated(
                         EditView& rEditView,
-                        const EditSelection rSel,
+                        const EditSelection &rSel,
                         ::com::sun::star::uno::Reference< 
::com::sun::star::linguistic2::XSpellAlternatives > xAlt,
                         ::svx::SpellPortions& rToFill);
     //adds one portion to the SpellPortions
     void            AddPortion(
-                        const EditSelection rSel,
+                        const EditSelection &rSel,
                         ::com::sun::star::uno::Reference< 
::com::sun::star::linguistic2::XSpellAlternatives > xAlt,
                         ::svx::SpellPortions& rToFill,
                         bool bIsField );
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index d37d8d9..64c7838 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -68,6 +68,7 @@
 
 #include <editeng/unolingu.hxx>
 
+#include <set>
 #include <math.h>
 #include <vcl/svapp.hxx>
 #include <vcl/metric.hxx>
@@ -86,9 +87,6 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::linguistic2;
 
-SV_DECL_VARARR_SORT( SortedPositions, sal_uInt32, 16 )
-SV_IMPL_VARARR_SORT( SortedPositions, sal_uInt32 );
-
 #define CH_HYPH     '-'
 
 #define RESDIFF     10
@@ -2252,14 +2250,14 @@ sal_uInt16 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, 
sal_uInt16 nP
     return nSplitPortion;
 }
 
-void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& rStart /* , 
sal_Bool bCreateBlockPortions */ )
+void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& rStart )
 {
     sal_uInt16 nStartPos = rStart;
     ContentNode* pNode = pParaPortion->GetNode();
     DBG_ASSERT( pNode->Len(), "CreateTextPortions should not be used for empty paragraphs!" );
 
-    SortedPositions aPositions;
-    aPositions.Insert( (sal_uInt32) 0 );
+    ::std::set< sal_uInt32 > aPositions;
+    aPositions.insert( 0 );
 
     sal_uInt16 nAttr = 0;
     EditCharAttrib* pAttrib = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr );
@@ -2267,23 +2265,23 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, 
sal_uInt16& r
     {
         // Insert Start and End into the Array...
         // The Insert method does not allow for duplicate values....
-        aPositions.Insert( pAttrib->GetStart() );
-        aPositions.Insert( pAttrib->GetEnd() );
+        aPositions.insert( pAttrib->GetStart() );
+        aPositions.insert( pAttrib->GetEnd() );
         nAttr++;
         pAttrib = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr );
     }
-    aPositions.Insert( pNode->Len() );
+    aPositions.insert( pNode->Len() );
 
     if ( pParaPortion->aScriptInfos.empty() )
         ((ImpEditEngine*)this)->InitScriptTypes( GetParaPortions().GetPos( pParaPortion ) );
 
     const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos;
     for ( size_t nT = 0; nT < rTypes.size(); nT++ )
-        aPositions.Insert( rTypes[nT].nStartPos );
+        aPositions.insert( rTypes[nT].nStartPos );
 
     const WritingDirectionInfos& rWritingDirections = pParaPortion->aWritingDirectionInfos;
     for ( size_t nD = 0; nD < rWritingDirections.size(); nD++ )
-        aPositions.Insert( rWritingDirections[nD].nStartPos );
+        aPositions.insert( rWritingDirections[nD].nStartPos );
 
     if ( mpIMEInfos && mpIMEInfos->nLen && mpIMEInfos->pAttribs && ( mpIMEInfos->aPos.GetNode() == 
pNode ) )
     {
@@ -2292,11 +2290,11 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, 
sal_uInt16& r
         {
             if ( mpIMEInfos->pAttribs[n] != nLastAttr )
             {
-                aPositions.Insert( mpIMEInfos->aPos.GetIndex() + n );
+                aPositions.insert( mpIMEInfos->aPos.GetIndex() + n );
                 nLastAttr = mpIMEInfos->pAttribs[n];
             }
         }
-        aPositions.Insert( mpIMEInfos->aPos.GetIndex() + mpIMEInfos->nLen );
+        aPositions.insert( mpIMEInfos->aPos.GetIndex() + mpIMEInfos->nLen );
     }
 
     // From ... Delete:
@@ -2329,18 +2327,16 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, 
sal_uInt16& r
     pParaPortion->GetTextPortions().DeleteFromPortion( nInvPortion );
 
     // A portion may also have been formed by a line break:
-    aPositions.Insert( nPortionStart );
+    aPositions.insert( nPortionStart );
 
-    sal_uInt16 nInvPos;
-#ifdef DBG_UTIL
-    sal_Bool bFound =
-#endif
-                        aPositions.Seek_Entry( nPortionStart, &nInvPos );
+    ::std::set< sal_uInt32 >::iterator nInvPos = aPositions.find(  nPortionStart );
+    DBG_ASSERT( (nInvPos != aPositions.end()), "InvPos ?!" );
 
-    DBG_ASSERT( bFound && ( nInvPos < (aPositions.Count()-1) ), "InvPos ?!" );
-    for ( sal_uInt16 i = nInvPos+1; i < aPositions.Count(); i++ )
+    ::std::set< sal_uInt32 >::iterator i = nInvPos;
+    i++;
+       while ( i != aPositions.end() )
     {
-        TextPortion* pNew = new TextPortion( (sal_uInt16)aPositions[i] - 
(sal_uInt16)aPositions[i-1] );
+        TextPortion* pNew = new TextPortion( static_cast<sal_uInt16>(*i++) - 
static_cast<sal_uInt16>(*nInvPos++) );
         pParaPortion->GetTextPortions().Insert( pNew, pParaPortion->GetTextPortions().Count());
     }
 
@@ -3361,12 +3357,6 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point 
aSta
                                                 }
                                             }
                                         }
-
-                                        // comment
-
-
-
-
                                     }
 
                                     if ( GetStatus().DoOnlineSpelling() && 
!pPortion->GetNode()->GetWrongList()->empty() && pTextPortion->GetLen() )
@@ -3391,8 +3381,8 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point 
aSta
 
                                 pOutDev->Pop();
 
-                                if ( pTmpDXArray )
-                                    delete[] pTmpDXArray;
+                                //The C++ language guarantees that delete p will do nothing if p 
is equal to NULL.
+                                delete[] pTmpDXArray;
 
                                 if ( pTextPortion->GetKind() == PORTIONKIND_FIELD )
                                 {
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index fd4fa31..e8c2c1b 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1996,7 +1996,7 @@ bool ImpEditEngine::SpellSentence(EditView& rEditView,
 
 // Adds one portion to the SpellPortions
 void ImpEditEngine::AddPortion(
-                            const EditSelection rSel,
+                            const EditSelection& rSel,
                             uno::Reference< XSpellAlternatives > xAlt,
                                 ::svx::SpellPortions& rToFill,
                                 bool bIsField)
@@ -2020,7 +2020,7 @@ void ImpEditEngine::AddPortion(
 // Adds one or more portions of text to the SpellPortions depending on language changes
 void ImpEditEngine::AddPortionIterated(
                             EditView& rEditView,
-                            const EditSelection rSel,
+                            const EditSelection& rSel,
                             Reference< XSpellAlternatives > xAlt,
                                 ::svx::SpellPortions& rToFill)
 {
-- 
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.