[Libreoffice-commits] .: 6 commits - svl/Package_inc.mk svl/inc sw/source xmloff/source
Michael Stahl
mst at kemper.freedesktop.org
Thu Aug 2 14:51:27 PDT 2012
svl/Package_inc.mk | 1
svl/inc/svl/cntnrsrt.hxx | 166 ------------------------
sw/source/filter/xml/xmltble.cxx | 33 ++--
xmloff/source/style/XMLFontAutoStylePool.cxx | 71 +++++-----
xmloff/source/style/impastp1.cxx | 4
xmloff/source/style/impastp3.cxx | 20 --
xmloff/source/style/impastp4.cxx | 43 +++---
xmloff/source/style/impastpl.hxx | 16 +-
xmloff/source/style/xmlstyle.cxx | 1
xmloff/source/text/XMLTextListAutoStylePool.cxx | 81 +++++------
10 files changed, 128 insertions(+), 308 deletions(-)
New commits:
commit ad99d4eeb60d4d18a93fcc78973b5f5dd20c0fbb
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Aug 2 23:49:21 2012 +0200
SvXMLAutoStylePoolP_Impl: try to make MSVC happy
Change-Id: Ifecfa196923b7fdde51839d74bef46e840bae501
diff --git a/xmloff/source/style/impastp4.cxx b/xmloff/source/style/impastp4.cxx
index 3eecb55..194c516 100644
--- a/xmloff/source/style/impastp4.cxx
+++ b/xmloff/source/style/impastp4.cxx
@@ -263,12 +263,14 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily,
OUString sName;
XMLFamilyData_Impl aTemporary( nFamily );
- XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTemporary);
- DBG_ASSERT(aFind != maFamilyList.end(), "SvXMLAutoStylePool_Impl::Find: unknown family");
+ XMLFamilyDataList_Impl::const_iterator const iter =
+ maFamilyList.find(aTemporary);
+ OSL_ENSURE(iter != maFamilyList.end(),
+ "SvXMLAutoStylePool_Impl::Find: unknown family");
- if (aFind != maFamilyList.end())
+ if (iter != maFamilyList.end())
{
- XMLFamilyData_Impl &rFamily = *aFind;
+ XMLFamilyData_Impl const& rFamily = *iter;
const SvXMLAutoStylePoolParentsP_Impl* pParents =
rFamily.mpParentList;
commit e38940a137c5d3b474421ac0721a995dac46f8dd
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Aug 2 23:37:16 2012 +0200
cntnrsrt.hxx: remove dead code
Change-Id: I004101e814ac3eb1de7a518c2dd9b1f14683eca8
diff --git a/svl/Package_inc.mk b/svl/Package_inc.mk
index ae63792..e518219 100644
--- a/svl/Package_inc.mk
+++ b/svl/Package_inc.mk
@@ -30,7 +30,6 @@ $(eval $(call gb_Package_add_file,svl_inc,inc/svl/broadcast.hxx,svl/broadcast.hx
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/cenumitm.hxx,svl/cenumitm.hxx))
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/cintitem.hxx,svl/cintitem.hxx))
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/cjkoptions.hxx,svl/cjkoptions.hxx))
-$(eval $(call gb_Package_add_file,svl_inc,inc/svl/cntnrsrt.hxx,svl/cntnrsrt.hxx))
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/cntwall.hxx,svl/cntwall.hxx))
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/cntwids.hrc,svl/cntwids.hrc))
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/converter.hxx,svl/converter.hxx))
diff --git a/svl/inc/svl/cntnrsrt.hxx b/svl/inc/svl/cntnrsrt.hxx
deleted file mode 100644
index c3d3856..0000000
--- a/svl/inc/svl/cntnrsrt.hxx
+++ /dev/null
@@ -1,166 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#ifndef _CNTRSRT_HXX
-#define _CNTRSRT_HXX
-
-/***********************************************************************
-*
-* Hier folgt die Beschreibung fuer die exportierten Makros:
-*
-* DECLARE_CONTAINER_SORT( ClassName, Type )
-* IMPL_CONTAINER_SORT( ClassName, Type, SortFunc )
-*
-* Definiert eine von Container abgeleitete Klasse "ClassName",
-* in der die Elemente des Typs "Type" sortiert enthalten sind.
-* Dazu muss einer Funktion "SortFunc" definiert sein, die als
-* Paramter zwei "const Type&" erwartet und 0 zurueckgibt, wenn
-* beide gleich sind, -1 wenn der erste Paramter kleiner ist als
-* der zweite und +1 wenn der erste Paramter groesser ist als
-* der zweite.
-*
-* Die Zugriffs-Methoden entsprechen in etwa denen der Container-
-* Klasse, mit Ausnahme von Insert, DeleteAndDestroy und Seek_Entry,
-* der den SV-Pointer-Arrays entsprechen.
-*
-* DECLARE_CONTAINER_SORT_DEL( ClassName, Type )
-* IMPL_CONTAINER_SORT( ClassName, Type, SortFunc )
-*
-* Wie DECLARE_CONTAINER_SORT, nur dass beim Aufruf des Destruktors
-* alle im Conatiner vorhandenen Objekte geloescht werden.
-*/
-
-#include <tools/contnr.hxx>
-
-#define DECLARE_CONTAINER_SORT_COMMON( ClassName, Type ) \
- ClassName( const ClassName& ); \
- ClassName& operator =( const ClassName& ); \
-public: \
- using Container::Count; \
- \
- ClassName( sal_uInt16 InitSize, sal_uInt16 ReSize ) : \
- Container( CONTAINER_MAXBLOCKSIZE, InitSize, ReSize ) {} \
- \
- sal_Bool Insert( Type* pObj ); \
- \
- Type *Remove( sal_uLong nPos ) \
- { return (Type *)Container::Remove( nPos ); } \
- \
- Type *Remove( Type* pObj ); \
- \
- void DeleteAndDestroy( sal_uLong nPos ) \
- { \
- Type *pObj = Remove( nPos ); \
- if( pObj ) \
- delete pObj; \
- } \
- \
- void DeleteAndDestroy() \
- { while( Count() ) DeleteAndDestroy( 0 ); } \
- \
- Type* GetObject( sal_uLong nPos ) const \
- { return (Type *)Container::GetObject( nPos ); } \
- \
- Type* operator[]( sal_uLong nPos ) const \
- { return GetObject(nPos); } \
- \
- sal_Bool Seek_Entry( const Type *pObj, sal_uLong* pPos ) const; \
- \
- sal_uLong GetPos( const Type* pObj ) const; \
-
-
-#define DECLARE_CONTAINER_SORT( ClassName, Type ) \
-class ClassName : private Container \
-{ \
- DECLARE_CONTAINER_SORT_COMMON( ClassName, Type ) \
- ~ClassName() {} \
-}; \
-
-
-#define DECLARE_CONTAINER_SORT_DEL( ClassName, Type ) \
-class ClassName : private Container \
-{ \
- DECLARE_CONTAINER_SORT_COMMON( ClassName, Type ) \
- ~ClassName() { DeleteAndDestroy(); } \
-}; \
-
-
-#define IMPL_CONTAINER_SORT( ClassName, Type, SortFunc ) \
-sal_Bool ClassName::Insert( Type *pObj ) \
-{ \
- sal_uLong nPos; \
- sal_Bool bExist = Seek_Entry( pObj, &nPos ); \
- if( !bExist ) \
- Container::Insert( pObj, nPos ); \
- return !bExist; \
-} \
- \
-Type *ClassName::Remove( Type* pObj ) \
-{ \
- sal_uLong nPos; \
- if( Seek_Entry( pObj, &nPos ) ) \
- return Remove( nPos ); \
- else \
- return 0; \
-} \
- \
-sal_uLong ClassName::GetPos( const Type* pObj ) const \
-{ \
- sal_uLong nPos; \
- if( Seek_Entry( pObj, &nPos ) ) \
- return nPos; \
- else \
- return CONTAINER_ENTRY_NOTFOUND; \
-} \
- \
-sal_Bool ClassName::Seek_Entry( const Type* pObj, sal_uLong* pPos ) const \
-{ \
- register sal_uLong nO = Count(), \
- nM, \
- nU = 0; \
- if( nO > 0 ) \
- { \
- nO--; \
- while( nU <= nO ) \
- { \
- nM = nU + ( nO - nU ) / 2; \
- int nCmp = SortFunc( *GetObject(nM), *pObj ); \
- \
- if( 0 == nCmp ) \
- { \
- if( pPos ) *pPos = nM; \
- return sal_True; \
- } \
- else if( nCmp < 0 ) \
- nU = nM + 1; \
- else if( nM == 0 ) \
- { \
- if( pPos ) *pPos = nU; \
- return sal_False; \
- } \
- else \
- nO = nM - 1; \
- } \
- } \
- if( pPos ) *pPos = nU; \
- return sal_False; \
-} \
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index eb3c518..4acd7eb 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -36,7 +36,6 @@
#include <xmloff/xmltoken.hxx>
#include <xmloff/xmluconv.hxx>
#include <xmloff/numehelp.hxx>
-#include <svl/cntnrsrt.hxx>
#include <svl/zforlist.hxx>
#include <editeng/brshitem.hxx>
#include <editeng/boxitem.hxx>
diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx
index 380dd48..aabfdc4 100644
--- a/xmloff/source/style/xmlstyle.cxx
+++ b/xmloff/source/style/xmlstyle.cxx
@@ -39,7 +39,6 @@
#include <com/sun/star/style/XAutoStyleFamily.hpp>
#include "PageMasterPropMapper.hxx"
#include <tools/debug.hxx>
-#include <svl/cntnrsrt.hxx>
#include <svl/itemset.hxx>
#include <xmloff/nmspmap.hxx>
#include "xmloff/xmlnmspe.hxx"
commit d81c7f47c98d88dc30822dd9e0550461afe77dbf
Author: Noel Grandin <noel at peralex.com>
Date: Thu Aug 2 14:42:48 2012 +0200
STL'ify DECLARE_CONTAINER_SORT_DEL(SvXMLAutoStylePoolParentsP_Impl)
Change-Id: I54f1595198b65058d3dd7f3304e0acb75cd55291
diff --git a/xmloff/source/style/impastp1.cxx b/xmloff/source/style/impastp1.cxx
index b1a0bd6..ca70002 100644
--- a/xmloff/source/style/impastp1.cxx
+++ b/xmloff/source/style/impastp1.cxx
@@ -51,7 +51,7 @@ XMLFamilyData_Impl::XMLFamilyData_Impl(
mnCount( 0 ), mnName( 0 ), maStrPrefix( rStrPrefix ), bAsFamily( bAsFam )
{
- mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 );
+ mpParentList = new SvXMLAutoStylePoolParentsP_Impl;
mpNameList = new SvXMLAutoStylePoolNamesP_Impl;
}
@@ -72,7 +72,7 @@ XMLFamilyData_Impl::~XMLFamilyData_Impl()
void XMLFamilyData_Impl::ClearEntries()
{
delete mpParentList;
- mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 );
+ mpParentList = new SvXMLAutoStylePoolParentsP_Impl;
DBG_ASSERT( !pCache || !pCache->size(), "auto style pool cache is not empty!" );
if( pCache )
{
diff --git a/xmloff/source/style/impastp3.cxx b/xmloff/source/style/impastp3.cxx
index eceed9e..d89dc48 100644
--- a/xmloff/source/style/impastp3.cxx
+++ b/xmloff/source/style/impastp3.cxx
@@ -169,24 +169,4 @@ OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl& rFamily
return sName;
}
-///////////////////////////////////////////////////////////////////////////////
-//
-// Sort-function for sorted list of SvXMLAutoStylePoolParent_Impl-elements
-//
-
-int SvXMLAutoStylePoolParentPCmp_Impl( const SvXMLAutoStylePoolParentP_Impl& r1,
- const SvXMLAutoStylePoolParentP_Impl& r2)
-{
- return (int)r1.GetParent().compareTo( r2.GetParent() );
-}
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// Implementation of sorted list of SvXMLAutoStylePoolParent_Impl-elements
-//
-
-IMPL_CONTAINER_SORT( SvXMLAutoStylePoolParentsP_Impl,
- SvXMLAutoStylePoolParentP_Impl,
- SvXMLAutoStylePoolParentPCmp_Impl )
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/style/impastp4.cxx b/xmloff/source/style/impastp4.cxx
index 02b380f..3eecb55 100644
--- a/xmloff/source/style/impastp4.cxx
+++ b/xmloff/source/style/impastp4.cxx
@@ -181,15 +181,16 @@ sal_Bool SvXMLAutoStylePoolP_Impl::Add(OUString& rName, sal_Int32 nFamily,
SvXMLAutoStylePoolParentP_Impl *pParent = 0;
SvXMLAutoStylePoolParentsP_Impl *pParents = rFamily.mpParentList;
- sal_uLong nPos;
- if( pParents->Seek_Entry( &aTmp, &nPos ) )
+ SvXMLAutoStylePoolParentsP_Impl::const_iterator const it2 =
+ pParents->find(&aTmp);
+ if (it2 != pParents->end())
{
- pParent = pParents->GetObject( nPos );
+ pParent = *it2;
}
else
{
pParent = new SvXMLAutoStylePoolParentP_Impl( rParent );
- pParents->Insert( pParent );
+ pParents->insert( pParent );
}
if( pParent->Add( rFamily, rProperties, rName, bDontSeek ) )
@@ -228,15 +229,16 @@ sal_Bool SvXMLAutoStylePoolP_Impl::AddNamed(const OUString& rName, sal_Int32 nFa
SvXMLAutoStylePoolParentP_Impl *pParent = 0;
SvXMLAutoStylePoolParentsP_Impl *pParents = rFamily.mpParentList;
- sal_uLong nPos;
- if( pParents->Seek_Entry( &aTmp, &nPos ) )
+ SvXMLAutoStylePoolParentsP_Impl::const_iterator const it2 =
+ pParents->find(&aTmp);
+ if (it2 != pParents->end())
{
- pParent = pParents->GetObject( nPos );
+ pParent = *it2;
}
else
{
pParent = new SvXMLAutoStylePoolParentP_Impl( rParent );
- pParents->Insert( pParent );
+ pParents->insert( pParent );
}
if( pParent->AddNamed( rFamily, rProperties, rName ) )
@@ -271,9 +273,12 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily,
rFamily.mpParentList;
SvXMLAutoStylePoolParentP_Impl aTmp( rParent );
- sal_uLong nPos;
- if( pParents->Seek_Entry( &aTmp, &nPos ) )
- sName = pParents->GetObject( nPos )->Find( rFamily, rProperties );
+ SvXMLAutoStylePoolParentsP_Impl::const_iterator const it2 =
+ pParents->find(&aTmp);
+ if (it2 != pParents->end())
+ {
+ sName = (*it2)->Find( rFamily, rProperties );
+ }
}
return sName;
@@ -322,11 +327,9 @@ void SvXMLAutoStylePoolP_Impl::exportXML(
aExpStyles[i].mpProperties = 0;
}
- sal_uInt32 nParents = pParents->Count();
- for( i=0; i < nParents; i++ )
+ for (size_t k = 0; k < pParents->size(); k++)
{
- const SvXMLAutoStylePoolParentP_Impl* pParent =
- pParents->GetObject( i );
+ const SvXMLAutoStylePoolParentP_Impl *const pParent = (*pParents)[k];
size_t nProperties = pParent->GetPropertiesList().size();
for( size_t j = 0; j < nProperties; j++ )
{
diff --git a/xmloff/source/style/impastpl.hxx b/xmloff/source/style/impastpl.hxx
index 941471d..2056740 100644
--- a/xmloff/source/style/impastpl.hxx
+++ b/xmloff/source/style/impastpl.hxx
@@ -31,13 +31,13 @@
#include <boost/ptr_container/ptr_set.hpp>
#include <sal/types.h>
-#include <svl/cntnrsrt.hxx>
#include <rtl/ustring.hxx>
#include <set>
#include <vector>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <o3tl/sorted_vector.hxx>
#include <xmloff/maptype.hxx>
#include <xmloff/xmlexppr.hxx>
@@ -154,8 +154,18 @@ public:
}
};
-DECLARE_CONTAINER_SORT_DEL( SvXMLAutoStylePoolParentsP_Impl,
- SvXMLAutoStylePoolParentP_Impl )
+struct SvXMLAutoStylePoolParentPCmp_Impl
+{
+ bool operator()( SvXMLAutoStylePoolParentP_Impl* const& lhs, SvXMLAutoStylePoolParentP_Impl* const& rhs) const
+ {
+ return lhs->GetParent().compareTo( rhs->GetParent() ) < 0;
+ }
+};
+class SvXMLAutoStylePoolParentsP_Impl : public o3tl::sorted_vector<SvXMLAutoStylePoolParentP_Impl*, SvXMLAutoStylePoolParentPCmp_Impl>
+{
+public:
+ ~SvXMLAutoStylePoolParentsP_Impl() { DeleteAndDestroyAll(); }
+};
///////////////////////////////////////////////////////////////////////////////
//
commit efe1a44e473497be1be99c10dcefbc77f36041e3
Author: Noel Grandin <noel at peralex.com>
Date: Thu Aug 2 16:23:40 2012 +0200
STL'ify DECLARE_CONTAINER_SORT(XMLTextListAutoStylePool_Impl)
Change-Id: Ib9aa0e619434acde5b4dd93b43b231ba23adb63e
diff --git a/xmloff/source/text/XMLTextListAutoStylePool.cxx b/xmloff/source/text/XMLTextListAutoStylePool.cxx
index acf9044..443265f 100644
--- a/xmloff/source/text/XMLTextListAutoStylePool.cxx
+++ b/xmloff/source/text/XMLTextListAutoStylePool.cxx
@@ -27,7 +27,7 @@
************************************************************************/
#include <tools/debug.hxx>
-#include <svl/cntnrsrt.hxx>
+#include <o3tl/sorted_vector.hxx>
#include <com/sun/star/ucb/XAnyCompareFactory.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/container/XIndexReplace.hpp>
@@ -123,40 +123,34 @@ XMLTextListAutoStylePoolEntry_Impl::XMLTextListAutoStylePoolEntry_Impl(
while (rNames.find(sName) != rNames.end());
}
-int XMLTextListAutoStylePoolEntryCmp_Impl(
- const XMLTextListAutoStylePoolEntry_Impl& r1,
- const XMLTextListAutoStylePoolEntry_Impl& r2 )
+struct XMLTextListAutoStylePoolEntryCmp_Impl
{
- int nRet;
- if( r1.IsNamed() )
+ bool operator()(
+ XMLTextListAutoStylePoolEntry_Impl* const& r1,
+ XMLTextListAutoStylePoolEntry_Impl* const& r2 ) const
{
- if( r2.IsNamed() )
- nRet = (int)r1.GetInternalName().compareTo( r2.GetInternalName());
- else
- nRet = -1;
- }
- else
- {
- if( r2.IsNamed() )
- nRet = 1;
+ if( r1->IsNamed() )
+ {
+ if( r2->IsNamed() )
+ return r1->GetInternalName().compareTo( r2->GetInternalName() ) < 0;
+ else
+ return true;
+ }
else
- nRet = (int)(r1.GetNumRules().get() - r2.GetNumRules().get());
+ {
+ if( r2->IsNamed() )
+ return false;
+ else
+ return r1->GetNumRules().get() < r2->GetNumRules().get();
+ }
}
-
- return nRet;
-}
-
-typedef XMLTextListAutoStylePoolEntry_Impl *XMLTextListAutoStylePoolEntryPtr;
-DECLARE_CONTAINER_SORT( XMLTextListAutoStylePool_Impl,
- XMLTextListAutoStylePoolEntry_Impl )
-IMPL_CONTAINER_SORT( XMLTextListAutoStylePool_Impl,
- XMLTextListAutoStylePoolEntry_Impl,
- XMLTextListAutoStylePoolEntryCmp_Impl )
+};
+class XMLTextListAutoStylePool_Impl : public o3tl::sorted_vector<XMLTextListAutoStylePoolEntry_Impl*, XMLTextListAutoStylePoolEntryCmp_Impl> {};
XMLTextListAutoStylePool::XMLTextListAutoStylePool( SvXMLExport& rExp ) :
rExport( rExp ),
sPrefix( RTL_CONSTASCII_USTRINGPARAM("L") ),
- pPool( new XMLTextListAutoStylePool_Impl( 5, 5 ) ),
+ pPool( new XMLTextListAutoStylePool_Impl ),
nName( 0 )
{
Reference<ucb::XAnyCompareFactory> xCompareFac( rExp.GetModel(), uno::UNO_QUERY );
@@ -172,9 +166,7 @@ XMLTextListAutoStylePool::XMLTextListAutoStylePool( SvXMLExport& rExp ) :
XMLTextListAutoStylePool::~XMLTextListAutoStylePool()
{
// The XMLTextListAutoStylePoolEntry_Impl object in the pool need delete explicitly in dtor.
- sal_uLong nCount = pPool->Count();
- while ( nCount-- )
- delete pPool->Remove(nCount);
+ pPool->DeleteAndDestroyAll();
delete pPool;
}
@@ -185,25 +177,26 @@ void XMLTextListAutoStylePool::RegisterName( const OUString& rName )
sal_uInt32 XMLTextListAutoStylePool::Find( XMLTextListAutoStylePoolEntry_Impl* pEntry ) const
{
- sal_uLong nPos;
if( !pEntry->IsNamed() && mxNumRuleCompare.is() )
{
- const sal_uInt32 nCount = pPool->Count();
+ const sal_uInt32 nCount = pPool->size();
uno::Any aAny1, aAny2;
aAny1 <<= pEntry->GetNumRules();
- for( nPos = 0; nPos < nCount; nPos++ )
+ for( sal_uLong nPos = 0; nPos < nCount; nPos++ )
{
- aAny2 <<= pPool->GetObject(nPos)->GetNumRules();
+ aAny2 <<= (*pPool)[nPos]->GetNumRules();
if( mxNumRuleCompare->compare( aAny1, aAny2 ) == 0 )
return nPos;
}
}
- else if( pPool->Seek_Entry( pEntry, &nPos ) )
+ else
{
- return nPos;
+ XMLTextListAutoStylePool_Impl::const_iterator it = pPool->find( pEntry );
+ if( it != pPool->end() )
+ return it - pPool->begin();
}
return (sal_uInt32)-1;
@@ -218,15 +211,15 @@ OUString XMLTextListAutoStylePool::Add(
sal_uInt32 nPos = Find( &aTmp );
if( nPos != (sal_uInt32)-1 )
{
- sName = pPool->GetObject( nPos )->GetName();
+ sName = (*pPool)[ nPos ]->GetName();
}
else
{
XMLTextListAutoStylePoolEntry_Impl *pEntry =
- new XMLTextListAutoStylePoolEntry_Impl( pPool->Count(),
+ new XMLTextListAutoStylePoolEntry_Impl( pPool->size(),
rNumRules, m_aNames, sPrefix,
nName );
- pPool->Insert( pEntry );
+ pPool->insert( pEntry );
sName = pEntry->GetName();
}
@@ -241,7 +234,7 @@ OUString XMLTextListAutoStylePool::Add(
sal_uInt32 nPos = Find( &aTmp );
if( nPos != (sal_uInt32)-1 )
- sName = pPool->GetObject( nPos )->GetName();
+ sName = (*pPool)[ nPos ]->GetName();
return sName;
}
@@ -253,19 +246,19 @@ OUString XMLTextListAutoStylePool::Add(
XMLTextListAutoStylePoolEntry_Impl aTmp( rInternalName );
sal_uInt32 nPos = Find( &aTmp );
if( nPos != (sal_uInt32)-1 )
- sName = pPool->GetObject( nPos )->GetName();
+ sName = (*pPool)[ nPos ]->GetName();
return sName;
}
void XMLTextListAutoStylePool::exportXML() const
{
- sal_uInt32 nCount = pPool->Count();
+ sal_uInt32 nCount = pPool->size();
if( !nCount )
return;
XMLTextListAutoStylePoolEntry_Impl **aExpEntries =
- new XMLTextListAutoStylePoolEntryPtr[nCount];
+ new XMLTextListAutoStylePoolEntry_Impl*[nCount];
sal_uInt32 i;
for( i=0; i < nCount; i++ )
@@ -274,7 +267,7 @@ void XMLTextListAutoStylePool::exportXML() const
}
for( i=0; i < nCount; i++ )
{
- XMLTextListAutoStylePoolEntry_Impl *pEntry = pPool->GetObject(i);
+ XMLTextListAutoStylePoolEntry_Impl *pEntry = (*pPool)[i];
DBG_ASSERT( pEntry->GetPos() < nCount, "Illegal pos" );
aExpEntries[pEntry->GetPos()] = pEntry;
}
commit 0df18265ef1c36c52a1954cda0f4726421cbd5a2
Author: Noel Grandin <noel at peralex.com>
Date: Thu Aug 2 14:54:13 2012 +0200
STL'ify DECLARE_CONTAINER_SORT_DEL(XMLFontAutoStylePool_Impl)
Change-Id: Ic02f143a0e0f01a6cbc88c47d20e0c27dca17a74
diff --git a/xmloff/source/style/XMLFontAutoStylePool.cxx b/xmloff/source/style/XMLFontAutoStylePool.cxx
index f6bada3..ce61666 100644
--- a/xmloff/source/style/XMLFontAutoStylePool.cxx
+++ b/xmloff/source/style/XMLFontAutoStylePool.cxx
@@ -26,7 +26,7 @@
*
************************************************************************/
-#include <svl/cntnrsrt.hxx>
+#include <o3tl/sorted_vector.hxx>
#include <tools/fontenum.hxx>
#include "xmloff/xmlnmspe.hxx"
#include <xmloff/xmltoken.hxx>
@@ -106,37 +106,40 @@ inline XMLFontAutoStylePoolEntry_Impl::XMLFontAutoStylePoolEntry_Impl(
eEnc( eE )
{
}
-int XMLFontAutoStylePoolEntryCmp_Impl(
- const XMLFontAutoStylePoolEntry_Impl& r1,
- const XMLFontAutoStylePoolEntry_Impl& r2 )
-{
- sal_Int8 nEnc1(r1.GetEncoding() != RTL_TEXTENCODING_SYMBOL);
- sal_Int8 nEnc2(r2.GetEncoding() != RTL_TEXTENCODING_SYMBOL);
- if( nEnc1 != nEnc2 )
- return nEnc1 - nEnc2;
- else if( r1.GetPitch() != r2.GetPitch() )
- return (int)r1.GetPitch() - (int)r2.GetPitch();
- else if( r1.GetFamily() != r2.GetFamily() )
- return (int)r1.GetFamily() - (int)r2.GetFamily();
- else
+
+struct XMLFontAutoStylePoolEntryCmp_Impl {
+ bool operator()(
+ XMLFontAutoStylePoolEntry_Impl* const& r1,
+ XMLFontAutoStylePoolEntry_Impl* const& r2 ) const
{
- sal_Int32 nCmp = r1.GetFamilyName().compareTo( r2.GetFamilyName() );
- if( 0 == nCmp )
- return (int)r1.GetStyleName().compareTo( r2.GetStyleName() );
+ sal_Int8 nEnc1(r1->GetEncoding() != RTL_TEXTENCODING_SYMBOL);
+ sal_Int8 nEnc2(r2->GetEncoding() != RTL_TEXTENCODING_SYMBOL);
+ if( nEnc1 != nEnc2 )
+ return nEnc1 < nEnc2;
+ else if( r1->GetPitch() != r2->GetPitch() )
+ return r1->GetPitch() < r2->GetPitch();
+ else if( r1->GetFamily() != r2->GetFamily() )
+ return r1->GetFamily() < r2->GetFamily();
else
- return (int)nCmp;
+ {
+ sal_Int32 nCmp = r1->GetFamilyName().compareTo( r2->GetFamilyName() );
+ if( 0 == nCmp )
+ return r1->GetStyleName().compareTo( r2->GetStyleName() ) < 0;
+ else
+ return nCmp < 0;
+ }
}
-}
+};
-DECLARE_CONTAINER_SORT_DEL( XMLFontAutoStylePool_Impl,
- XMLFontAutoStylePoolEntry_Impl )
-IMPL_CONTAINER_SORT( XMLFontAutoStylePool_Impl,
- XMLFontAutoStylePoolEntry_Impl,
- XMLFontAutoStylePoolEntryCmp_Impl )
+class XMLFontAutoStylePool_Impl : public o3tl::sorted_vector<XMLFontAutoStylePoolEntry_Impl*, XMLFontAutoStylePoolEntryCmp_Impl>
+{
+public:
+ ~XMLFontAutoStylePool_Impl() { DeleteAndDestroyAll(); }
+};
XMLFontAutoStylePool::XMLFontAutoStylePool( SvXMLExport& rExp ) :
rExport( rExp ),
- pPool( new XMLFontAutoStylePool_Impl( 5, 5 ) )
+ pPool( new XMLFontAutoStylePool_Impl )
{
}
@@ -155,10 +158,10 @@ OUString XMLFontAutoStylePool::Add(
OUString sPoolName;
XMLFontAutoStylePoolEntry_Impl aTmp( rFamilyName, rStyleName, nFamily,
nPitch, eEnc );
- sal_uLong nPos;
- if( pPool->Seek_Entry( &aTmp, &nPos ) )
+ XMLFontAutoStylePool_Impl::const_iterator it = pPool->find( &aTmp );
+ if( it != pPool->end() )
{
- sPoolName = pPool->GetObject( nPos )->GetName();
+ sPoolName = (*it)->GetName();
}
else
{
@@ -192,7 +195,7 @@ OUString XMLFontAutoStylePool::Add(
XMLFontAutoStylePoolEntry_Impl *pEntry =
new XMLFontAutoStylePoolEntry_Impl( sName, rFamilyName, rStyleName,
nFamily, nPitch, eEnc );
- pPool->Insert( pEntry );
+ pPool->insert( pEntry );
m_aNames.insert(sName);
}
@@ -209,10 +212,10 @@ OUString XMLFontAutoStylePool::Add(
OUString sName;
XMLFontAutoStylePoolEntry_Impl aTmp( rFamilyName, rStyleName, nFamily,
nPitch, eEnc );
- sal_uLong nPos;
- if( pPool->Seek_Entry( &aTmp, &nPos ) )
+ XMLFontAutoStylePool_Impl::const_iterator it = pPool->find( &aTmp );
+ if( it != pPool->end() )
{
- sName = pPool->GetObject( nPos )->GetName();
+ sName = (*it)->GetName();
}
return sName;
@@ -232,10 +235,10 @@ void XMLFontAutoStylePool::exportXML()
XMLFontEncodingPropHdl aEncHdl;
const SvXMLUnitConverter& rUnitConv = GetExport().GetMM100UnitConverter();
- sal_uInt32 nCount = pPool->Count();
+ sal_uInt32 nCount = pPool->size();
for( sal_uInt32 i=0; i<nCount; i++ )
{
- const XMLFontAutoStylePoolEntry_Impl *pEntry = pPool->GetObject( i );
+ const XMLFontAutoStylePoolEntry_Impl *pEntry = (*pPool)[ i ];
GetExport().AddAttribute( XML_NAMESPACE_STYLE,
XML_NAME, pEntry->GetName() );
commit d0f5ff78740df2540873c4091786672b63063491
Author: Noel Grandin <noel at peralex.com>
Date: Thu Aug 2 13:32:13 2012 +0200
STL'ify DECLARE_CONTAINER_SORT(SwXMLTableColumnsSortByWidth_Impl)
Change-Id: Icd480f74dacb41d869fb511a0d2630d8b3711343
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index db5ff9c..eb3c518 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -95,14 +95,16 @@ public:
sal_uInt32 GetRelWidth() const { return nRelWidth; }
};
-sal_Int32 SwXMLTableColumnCmpWidth_Impl( const SwXMLTableColumn_Impl& r1,
- const SwXMLTableColumn_Impl& r2 )
+struct SwXMLTableColumnCmpWidth_Impl
{
- sal_Int32 n = (sal_Int32)r1.GetWidthOpt() - (sal_Int32)r2.GetWidthOpt();
- if( !n )
- n = (sal_Int32)r1.GetRelWidth() - (sal_Int32)r2.GetRelWidth();
- return n;
-}
+ bool operator()( SwXMLTableColumn_Impl* const& lhs, SwXMLTableColumn_Impl* const& rhs ) const
+ {
+ sal_Int32 n = (sal_Int32)lhs->GetWidthOpt() - (sal_Int32)rhs->GetWidthOpt();
+ if( !n )
+ n = (sal_Int32)lhs->GetRelWidth() - (sal_Int32)rhs->GetRelWidth();
+ return n < 0;
+ }
+};
// ---------------------------------------------------------------------
@@ -111,10 +113,7 @@ public:
~SwXMLTableColumns_Impl() { DeleteAndDestroyAll(); }
};
-DECLARE_CONTAINER_SORT( SwXMLTableColumnsSortByWidth_Impl,
- SwXMLTableColumn_Impl )
-IMPL_CONTAINER_SORT( SwXMLTableColumnsSortByWidth_Impl, SwXMLTableColumn_Impl,
- SwXMLTableColumnCmpWidth_Impl )
+class SwXMLTableColumnsSortByWidth_Impl : public o3tl::sorted_vector<SwXMLTableColumn_Impl*, SwXMLTableColumnCmpWidth_Impl> {};
class SwXMLTableLines_Impl
{
@@ -630,11 +629,10 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
pColumn->SetWidthOpt( nColAbsWidth, sal_False );
}
- sal_uLong nExpPos = 0;
- if( rExpCols.Seek_Entry( pColumn, &nExpPos ) )
+ SwXMLTableColumnsSortByWidth_Impl::const_iterator it = rExpCols.find( pColumn );
+ if( it != rExpCols.end() )
{
- pColumn->SetStyleName(
- rExpCols.GetObject(nExpPos)->GetStyleName() );
+ pColumn->SetStyleName( (*it)->GetStyleName() );
}
else
{
@@ -653,7 +651,7 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
pColumn->SetStyleName( sBuffer.makeStringAndClear() );
ExportTableColumnStyle( *pColumn );
- rExpCols.Insert( pColumn );
+ rExpCols.insert( pColumn );
}
}
}
@@ -773,7 +771,7 @@ void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd )
ExportTableFmt( *pTblFmt, nAbsWidth );
OUString sName( pTblFmt->GetName() );
- SwXMLTableColumnsSortByWidth_Impl aExpCols( 10, 10 );
+ SwXMLTableColumnsSortByWidth_Impl aExpCols;
SwXMLTableFrmFmtsSort_Impl aExpRows( 10, 10 );
SwXMLTableFrmFmtsSort_Impl aExpCells( 10, 10 );
SwXMLTableInfo_Impl aTblInfo( &rTbl );
More information about the Libreoffice-commits
mailing list