Kaydet (Commit) f683b7fd authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Michael Stahl

Convert SV_DECL_PTRARR_SORT(SwBlockNames) to o3tl::sorted_vector

Change-Id: I85ceda4df9f495bc514e2f37c73097b268822e1e
üst 41627241
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <tools/string.hxx> #include <tools/string.hxx>
#include <tools/datetime.hxx> #include <tools/datetime.hxx>
#include <svl/svarray.hxx> #include <o3tl/sorted_vector.hxx>
class SwPaM; class SwPaM;
...@@ -58,11 +58,11 @@ public: ...@@ -58,11 +58,11 @@ public:
SwBlockName( const String& rShort, const String& rLong, const String& rPackageName ); SwBlockName( const String& rShort, const String& rLong, const String& rPackageName );
// fuer das Einsortieren in das Array // fuer das Einsortieren in das Array
int operator==( const SwBlockName& r ) { return aShort == r.aShort; } bool operator==( const SwBlockName& r ) const { return aShort == r.aShort; }
int operator< ( const SwBlockName& r ) { return aShort < r.aShort; } bool operator< ( const SwBlockName& r ) const { return aShort < r.aShort; }
}; };
SV_DECL_PTRARR_SORT( SwBlockNames, SwBlockName*, 10 ) class SwBlockNames : public o3tl::sorted_vector<SwBlockName*, o3tl::less_ptr_to<SwBlockName> > {};
class SwImpBlocks class SwImpBlocks
......
...@@ -155,14 +155,17 @@ void SwXMLTextBlocks::AddName( const String& rShort, const String& rLong, sal_Bo ...@@ -155,14 +155,17 @@ void SwXMLTextBlocks::AddName( const String& rShort, const String& rLong, sal_Bo
sal_uInt16 nIdx = GetIndex( rShort ); sal_uInt16 nIdx = GetIndex( rShort );
SwBlockName* pNew = NULL; SwBlockName* pNew = NULL;
if( nIdx != (sal_uInt16) -1 ) if( nIdx != (sal_uInt16) -1 )
aNames.DeleteAndDestroy( nIdx ); {
delete aNames[nIdx];
aNames.erase( aNames.begin() + nIdx );
}
aPackageName = GeneratePackageName( rShort ); aPackageName = GeneratePackageName( rShort );
pNew = new SwBlockName( rShort, rLong, aPackageName ); pNew = new SwBlockName( rShort, rLong, aPackageName );
pNew->bIsOnlyTxtFlagInit = sal_True; pNew->bIsOnlyTxtFlagInit = sal_True;
pNew->bIsOnlyTxt = bOnlyTxt; pNew->bIsOnlyTxt = bOnlyTxt;
aNames.C40_PTR_INSERT( SwBlockName, pNew ); aNames.insert( pNew );
bInfoChanged = sal_True; bInfoChanged = sal_True;
} }
void SwXMLTextBlocks::AddName( const String& rShort, const String& rLong, void SwXMLTextBlocks::AddName( const String& rShort, const String& rLong,
...@@ -170,17 +173,20 @@ void SwXMLTextBlocks::AddName( const String& rShort, const String& rLong, ...@@ -170,17 +173,20 @@ void SwXMLTextBlocks::AddName( const String& rShort, const String& rLong,
{ {
sal_uInt16 nIdx = GetIndex( rShort ); sal_uInt16 nIdx = GetIndex( rShort );
if( nIdx != (sal_uInt16) -1 ) if( nIdx != (sal_uInt16) -1 )
aNames.DeleteAndDestroy( nIdx ); {
delete aNames[nIdx];
aNames.erase( aNames.begin() + nIdx );
}
SwBlockName* pNew = new SwBlockName( rShort, rLong, rPackageName ); SwBlockName* pNew = new SwBlockName( rShort, rLong, rPackageName );
pNew->bIsOnlyTxtFlagInit = sal_True; pNew->bIsOnlyTxtFlagInit = sal_True;
pNew->bIsOnlyTxt = bOnlyTxt; pNew->bIsOnlyTxt = bOnlyTxt;
aNames.C40_PTR_INSERT( SwBlockName, pNew ); aNames.insert( pNew );
bInfoChanged = sal_True; bInfoChanged = sal_True;
} }
sal_uLong SwXMLTextBlocks::Delete( sal_uInt16 n ) sal_uLong SwXMLTextBlocks::Delete( sal_uInt16 n )
{ {
String aPckName (aNames[ n ]->aPackageName); String aPckName (aNames[n]->aPackageName);
uno::Reference < container::XNameAccess > xAccess( xBlkRoot, uno::UNO_QUERY ); uno::Reference < container::XNameAccess > xAccess( xBlkRoot, uno::UNO_QUERY );
if ( xAccess.is() && if ( xAccess.is() &&
xAccess->hasByName( aPckName ) && xBlkRoot->isStreamElement( aPckName ) ) xAccess->hasByName( aPckName ) && xBlkRoot->isStreamElement( aPckName ) )
...@@ -206,7 +212,7 @@ sal_uLong SwXMLTextBlocks::Rename( sal_uInt16 nIdx, const String& rNewShort, con ...@@ -206,7 +212,7 @@ sal_uLong SwXMLTextBlocks::Rename( sal_uInt16 nIdx, const String& rNewShort, con
OSL_ENSURE( xBlkRoot.is(), "No storage set" ); OSL_ENSURE( xBlkRoot.is(), "No storage set" );
if(!xBlkRoot.is()) if(!xBlkRoot.is())
return 0; return 0;
rtl::OUString aOldName (aNames[ nIdx ]->aPackageName); rtl::OUString aOldName (aNames[nIdx]->aPackageName);
aShort = rNewShort; aShort = rNewShort;
aPackageName = GeneratePackageName( aShort ); aPackageName = GeneratePackageName( aShort );
......
...@@ -114,7 +114,7 @@ sal_uLong SwXMLTextBlocks::GetDoc( sal_uInt16 nIdx ) ...@@ -114,7 +114,7 @@ sal_uLong SwXMLTextBlocks::GetDoc( sal_uInt16 nIdx )
} }
xml::sax::InputSource aParserInput; xml::sax::InputSource aParserInput;
aParserInput.sSystemId = aNames [ nIdx ] ->aPackageName; aParserInput.sSystemId = aNames[nIdx]->aPackageName;
aParserInput.aInputStream = xStream->getInputStream(); aParserInput.aInputStream = xStream->getInputStream();
...@@ -182,9 +182,9 @@ sal_uLong SwXMLTextBlocks::GetMacroTable( sal_uInt16 nIdx, ...@@ -182,9 +182,9 @@ sal_uLong SwXMLTextBlocks::GetMacroTable( sal_uInt16 nIdx,
{ {
// set current auto text // set current auto text
aShort = aNames[ nIdx ]->aShort; aShort = aNames[nIdx]->aShort;
aLong = aNames[ nIdx ]->aLong; aLong = aNames[nIdx]->aLong;
aPackageName = aNames[ nIdx ]->aPackageName; aPackageName = aNames[nIdx]->aPackageName;
sal_uLong nRet = 0; sal_uLong nRet = 0;
...@@ -603,9 +603,9 @@ sal_uLong SwXMLTextBlocks::SetMacroTable( ...@@ -603,9 +603,9 @@ sal_uLong SwXMLTextBlocks::SetMacroTable(
sal_Bool bFileAlreadyOpen ) sal_Bool bFileAlreadyOpen )
{ {
// set current autotext // set current autotext
aShort = aNames[ nIdx ]->aShort; aShort = aNames[nIdx]->aShort;
aLong = aNames[ nIdx ]->aLong; aLong = aNames[nIdx]->aLong;
aPackageName = aNames[ nIdx ]->aPackageName; aPackageName = aNames[nIdx]->aPackageName;
// start XML autotext event export // start XML autotext event export
sal_uLong nRes = 0; sal_uLong nRes = 0;
......
...@@ -47,8 +47,6 @@ ...@@ -47,8 +47,6 @@
#include <statstr.hrc> #include <statstr.hrc>
#include <swerror.h> #include <swerror.h>
SV_IMPL_OP_PTRARR_SORT( SwBlockNames, SwBlockName* );
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Hash-Code errechnen (muss nicht eindeutig sein) // Hash-Code errechnen (muss nicht eindeutig sein)
...@@ -115,7 +113,7 @@ SwImpBlocks::SwImpBlocks( const String& rFile, sal_Bool ) ...@@ -115,7 +113,7 @@ SwImpBlocks::SwImpBlocks( const String& rFile, sal_Bool )
SwImpBlocks::~SwImpBlocks() SwImpBlocks::~SwImpBlocks()
{ {
aNames.DeleteAndDestroy( 0, aNames.Count() ); aNames.DeleteAndDestroyAll();
} }
// Loeschen des Inhaltes des Dokuments // Loeschen des Inhaltes des Dokuments
...@@ -143,7 +141,7 @@ SwPaM* SwImpBlocks::MakePaM() ...@@ -143,7 +141,7 @@ SwPaM* SwImpBlocks::MakePaM()
sal_uInt16 SwImpBlocks::GetCount() const sal_uInt16 SwImpBlocks::GetCount() const
{ {
return aNames.Count(); return aNames.size();
} }
// Case Insensitive // Case Insensitive
...@@ -151,9 +149,9 @@ sal_uInt16 SwImpBlocks::GetIndex( const String& rShort ) const ...@@ -151,9 +149,9 @@ sal_uInt16 SwImpBlocks::GetIndex( const String& rShort ) const
{ {
String s( GetAppCharClass().uppercase( rShort ) ); String s( GetAppCharClass().uppercase( rShort ) );
sal_uInt16 nHash = Hash( s ); sal_uInt16 nHash = Hash( s );
for( sal_uInt16 i = 0; i < aNames.Count(); i++ ) for( sal_uInt16 i = 0; i < aNames.size(); i++ )
{ {
SwBlockName* pName = aNames[ i ]; const SwBlockName* pName = aNames[ i ];
if( pName->nHashS == nHash if( pName->nHashS == nHash
&& pName->aShort == s ) && pName->aShort == s )
return i; return i;
...@@ -165,9 +163,9 @@ sal_uInt16 SwImpBlocks::GetIndex( const String& rShort ) const ...@@ -165,9 +163,9 @@ sal_uInt16 SwImpBlocks::GetIndex( const String& rShort ) const
sal_uInt16 SwImpBlocks::GetLongIndex( const String& rLong ) const sal_uInt16 SwImpBlocks::GetLongIndex( const String& rLong ) const
{ {
sal_uInt16 nHash = Hash( rLong ); sal_uInt16 nHash = Hash( rLong );
for( sal_uInt16 i = 0; i < aNames.Count(); i++ ) for( sal_uInt16 i = 0; i < aNames.size(); i++ )
{ {
SwBlockName* pName = aNames[ i ]; const SwBlockName* pName = aNames[ i ];
if( pName->nHashL == nHash if( pName->nHashL == nHash
&& pName->aLong == rLong ) && pName->aLong == rLong )
return i; return i;
...@@ -178,23 +176,23 @@ sal_uInt16 SwImpBlocks::GetLongIndex( const String& rLong ) const ...@@ -178,23 +176,23 @@ sal_uInt16 SwImpBlocks::GetLongIndex( const String& rLong ) const
const String& SwImpBlocks::GetShortName( sal_uInt16 n ) const const String& SwImpBlocks::GetShortName( sal_uInt16 n ) const
{ {
if( n < aNames.Count() ) if( n < aNames.size() )
return aNames[ n ]->aShort; return aNames[n]->aShort;
return aEmptyStr; return aEmptyStr;
} }
const String& SwImpBlocks::GetLongName( sal_uInt16 n ) const const String& SwImpBlocks::GetLongName( sal_uInt16 n ) const
{ {
if( n < aNames.Count() ) if( n < aNames.size() )
return aNames[ n ]->aLong; return aNames[n]->aLong;
return aEmptyStr; return aEmptyStr;
} }
rtl::OUString SwImpBlocks::GetPackageName( sal_uInt16 n ) const rtl::OUString SwImpBlocks::GetPackageName( sal_uInt16 n ) const
{ {
if( n < aNames.Count() ) if( n < aNames.size() )
return aNames[ n ]->aPackageName; return aNames[n]->aPackageName;
return rtl::OUString(); return rtl::OUString();
} }
...@@ -203,11 +201,14 @@ void SwImpBlocks::AddName( const String& rShort, const String& rLong, ...@@ -203,11 +201,14 @@ void SwImpBlocks::AddName( const String& rShort, const String& rLong,
{ {
sal_uInt16 nIdx = GetIndex( rShort ); sal_uInt16 nIdx = GetIndex( rShort );
if( nIdx != (sal_uInt16) -1 ) if( nIdx != (sal_uInt16) -1 )
aNames.DeleteAndDestroy( nIdx ); {
delete aNames[nIdx];
aNames.erase( aNames.begin() + nIdx );
}
SwBlockName* pNew = new SwBlockName( rShort, rLong, 0L ); SwBlockName* pNew = new SwBlockName( rShort, rLong, 0L );
pNew->bIsOnlyTxtFlagInit = sal_True; pNew->bIsOnlyTxtFlagInit = sal_True;
pNew->bIsOnlyTxt = bOnlyTxt; pNew->bIsOnlyTxt = bOnlyTxt;
aNames.C40_PTR_INSERT( SwBlockName, pNew ); aNames.insert( pNew );
} }
...@@ -341,7 +342,10 @@ sal_Bool SwTextBlocks::Delete( sal_uInt16 n ) ...@@ -341,7 +342,10 @@ sal_Bool SwTextBlocks::Delete( sal_uInt16 n )
{ {
nErr = pImp->Delete( n ); nErr = pImp->Delete( n );
if( !nErr ) if( !nErr )
pImp->aNames.DeleteAndDestroy( n ); {
delete pImp->aNames[n];
pImp->aNames.erase( pImp->aNames.begin() + n );
}
if( n == pImp->nCur ) if( n == pImp->nCur )
pImp->nCur = (sal_uInt16) -1; pImp->nCur = (sal_uInt16) -1;
if( !nErr ) if( !nErr )
...@@ -383,7 +387,8 @@ sal_uInt16 SwTextBlocks::Rename( sal_uInt16 n, const String* s, const String* l ...@@ -383,7 +387,8 @@ sal_uInt16 SwTextBlocks::Rename( sal_uInt16 n, const String* s, const String* l
if( !nErr ) if( !nErr )
{ {
sal_Bool bOnlyTxt = pImp->aNames[ n ]->bIsOnlyTxt; sal_Bool bOnlyTxt = pImp->aNames[ n ]->bIsOnlyTxt;
pImp->aNames.DeleteAndDestroy( n ); delete pImp->aNames[n];
pImp->aNames.erase( pImp->aNames.begin() + n );
pImp->AddName( aNew, aLong, bOnlyTxt ); pImp->AddName( aNew, aLong, bOnlyTxt );
nErr = pImp->MakeBlockList(); nErr = pImp->MakeBlockList();
} }
...@@ -578,7 +583,7 @@ sal_Bool SwTextBlocks::IsOnlyTextBlock( sal_uInt16 nIdx ) const ...@@ -578,7 +583,7 @@ sal_Bool SwTextBlocks::IsOnlyTextBlock( sal_uInt16 nIdx ) const
sal_Bool bRet = sal_False; sal_Bool bRet = sal_False;
if( pImp && !pImp->bInPutMuchBlocks ) if( pImp && !pImp->bInPutMuchBlocks )
{ {
SwBlockName* pBlkNm = pImp->aNames[ nIdx ]; SwBlockName* pBlkNm = const_cast<SwBlockName*>( pImp->aNames[ nIdx ] );
if( !pBlkNm->bIsOnlyTxtFlagInit && if( !pBlkNm->bIsOnlyTxtFlagInit &&
!pImp->IsFileChanged() && !pImp->OpenFile( sal_True ) ) !pImp->IsFileChanged() && !pImp->OpenFile( sal_True ) )
{ {
...@@ -650,5 +655,4 @@ void SwTextBlocks::SetBaseURL( const String& rURL ) ...@@ -650,5 +655,4 @@ void SwTextBlocks::SetBaseURL( const String& rURL )
pImp->SetBaseURL(rURL); pImp->SetBaseURL(rURL);
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment