summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2012-03-10 22:16:16 +0100
committerIvan Timofeev <timofeev.i.s@gmail.com>2012-03-12 15:58:54 +0400
commitf2d0fcc26be481c2f872056fb3b8402169d124d8 (patch)
tree820d99c52c5778a99aade6b66cccb5df64e19e5f /editeng
parent80e33b0cf3dbb5cfec90daf22068a71fb2669c4a (diff)
Replace VARARR_SORT with std
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/impedit.hxx6
-rw-r--r--editeng/source/editeng/impedit3.cxx50
-rw-r--r--editeng/source/editeng/impedit4.cxx4
3 files changed, 25 insertions, 35 deletions
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 2076d29231da..5196703ad7a9 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 d37d8d98af78..a7919a2c7a57 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 fd4fa31d08dd..e8c2c1b2f0f5 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)
{