diff options
-rwxr-xr-x | unusedcode.easy | 9 | ||||
-rw-r--r-- | xmloff/inc/xmloff/XMLFontAutoStylePool.hxx | 5 | ||||
-rw-r--r-- | xmloff/inc/xmloff/XMLTextListAutoStylePool.hxx | 5 | ||||
-rw-r--r-- | xmloff/source/style/XMLFontAutoStylePool.cxx | 22 | ||||
-rw-r--r-- | xmloff/source/style/impastp1.cxx | 34 | ||||
-rw-r--r-- | xmloff/source/style/impastp2.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/style/impastp3.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/style/impastp4.cxx | 13 | ||||
-rw-r--r-- | xmloff/source/style/impastpl.hxx | 11 | ||||
-rw-r--r-- | xmloff/source/style/xmlstyle.cxx | 50 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextListAutoStylePool.cxx | 26 |
11 files changed, 47 insertions, 132 deletions
diff --git a/unusedcode.easy b/unusedcode.easy index 14faca261f21..5e27520ecbc1 100755 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -29,16 +29,11 @@ String::CreateFromAscii(char const*) String::CreateFromAscii(char const*, unsigned short) String::String(unsigned short const*) String::String(unsigned short const*, unsigned short) -SvXMLAutoStylePoolNamesP_Impl::GetPos(rtl::OUString const*) const -SvXMLAutoStylePoolNamesP_Impl::Remove(rtl::OUString*) SvXMLAutoStylePoolParentsP_Impl::GetPos(SvXMLAutoStylePoolParentP_Impl const*) const SvXMLAutoStylePoolParentsP_Impl::Remove(SvXMLAutoStylePoolParentP_Impl*) -SvXMLStyleIndices_Impl::GetPos(SvXMLStyleIndex_Impl const*) const -SvXMLStyleIndices_Impl::Remove(SvXMLStyleIndex_Impl*) SvtSlideSorterBarOptions::AddListenerLink(Link const&) SvtSlideSorterBarOptions::RemoveListenerLink(Link const&) SvxPositionSizeTabPage::GetRect() -SwSortElements::Remove(unsigned short, unsigned short) SwXMLTableColumnsSortByWidth_Impl::GetPos(SwXMLTableColumn_Impl const*) const SwXMLTableColumnsSortByWidth_Impl::Remove(SwXMLTableColumn_Impl*) TempFile::IsValid() const @@ -62,12 +57,8 @@ X11SalGraphics::SetMask(int&, int&, unsigned int&, unsigned int&, int&, int&, un X509Certificate_NssImpl::getImplementation(com::sun::star::uno::Reference<com::sun::star::uno::XInterface>) XMLFamilyDataList_Impl::GetPos(XMLFamilyData_Impl const*) const XMLFamilyDataList_Impl::Remove(XMLFamilyData_Impl*) -XMLFontAutoStylePoolNames_Impl::GetPos(rtl::OUString const*) const -XMLFontAutoStylePoolNames_Impl::Remove(rtl::OUString*) XMLFontAutoStylePool_Impl::GetPos(XMLFontAutoStylePoolEntry_Impl const*) const XMLFontAutoStylePool_Impl::Remove(XMLFontAutoStylePoolEntry_Impl*) -XMLTextListAutoStylePoolNames_Impl::GetPos(rtl::OUString const*) const -XMLTextListAutoStylePoolNames_Impl::Remove(rtl::OUString*) XMLTextListAutoStylePool_Impl::GetPos(XMLTextListAutoStylePoolEntry_Impl const*) const XMLTextListAutoStylePool_Impl::Remove(XMLTextListAutoStylePoolEntry_Impl*) XclExpColorScale::XclExpColorScale(XclExpRoot const&, ScColorScaleFormat const&) diff --git a/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx b/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx index f96e533538f2..4fd666b50efc 100644 --- a/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx +++ b/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx @@ -24,9 +24,10 @@ #include "xmloff/dllapi.h" #include <rtl/ustring.hxx> #include <xmloff/uniref.hxx> +#include <set> class XMLFontAutoStylePool_Impl; -class XMLFontAutoStylePoolNames_Impl; +typedef std::set<rtl::OUString> XMLFontAutoStylePoolNames_Impl; class SvXMLExport; class XMLOFF_DLLPUBLIC XMLFontAutoStylePool : public UniRefBase @@ -34,7 +35,7 @@ class XMLOFF_DLLPUBLIC XMLFontAutoStylePool : public UniRefBase SvXMLExport& rExport; XMLFontAutoStylePool_Impl *pPool; - XMLFontAutoStylePoolNames_Impl *pNames; + XMLFontAutoStylePoolNames_Impl m_aNames; sal_uInt32 nName; protected: diff --git a/xmloff/inc/xmloff/XMLTextListAutoStylePool.hxx b/xmloff/inc/xmloff/XMLTextListAutoStylePool.hxx index 8c398193d3e7..ff84c3a4b2be 100644 --- a/xmloff/inc/xmloff/XMLTextListAutoStylePool.hxx +++ b/xmloff/inc/xmloff/XMLTextListAutoStylePool.hxx @@ -34,6 +34,7 @@ #include "sal/types.h" #include <rtl/ustring.hxx> #include <com/sun/star/ucb/XAnyCompare.hpp> +#include <set> namespace com { namespace sun { namespace star { namespace container { class XIndexReplace; } } } } @@ -41,7 +42,7 @@ namespace rtl { class OUString; } class XMLTextListAutoStylePool_Impl; -class XMLTextListAutoStylePoolNames_Impl; +typedef std::set<rtl::OUString> XMLTextListAutoStylePoolNames_Impl; class XMLTextListAutoStylePoolEntry_Impl; class SvXMLExport; @@ -52,7 +53,7 @@ class XMLOFF_DLLPUBLIC XMLTextListAutoStylePool ::rtl::OUString sPrefix; XMLTextListAutoStylePool_Impl *pPool; - XMLTextListAutoStylePoolNames_Impl *pNames; + XMLTextListAutoStylePoolNames_Impl m_aNames; sal_uInt32 nName; /** this is an optional NumRule compare component for applications where diff --git a/xmloff/source/style/XMLFontAutoStylePool.cxx b/xmloff/source/style/XMLFontAutoStylePool.cxx index a242375d4a60..f6bada32bd3f 100644 --- a/xmloff/source/style/XMLFontAutoStylePool.cxx +++ b/xmloff/source/style/XMLFontAutoStylePool.cxx @@ -42,18 +42,6 @@ using ::rtl::OUStringBuffer; using namespace ::com::sun::star::uno; using namespace ::xmloff::token; -int XMLFontAutoStylePoolNameCmp_Impl( const OUString& r1, - const OUString& r2 ) -{ - return (int)r1.compareTo( r2 ); -} - -DECLARE_CONTAINER_SORT_DEL( XMLFontAutoStylePoolNames_Impl, - OUString ) -IMPL_CONTAINER_SORT( XMLFontAutoStylePoolNames_Impl, - OUString, - XMLFontAutoStylePoolNameCmp_Impl ) - class XMLFontAutoStylePoolEntry_Impl { OUString sName; @@ -148,15 +136,13 @@ IMPL_CONTAINER_SORT( XMLFontAutoStylePool_Impl, XMLFontAutoStylePool::XMLFontAutoStylePool( SvXMLExport& rExp ) : rExport( rExp ), - pPool( new XMLFontAutoStylePool_Impl( 5, 5 ) ), - pNames( new XMLFontAutoStylePoolNames_Impl( 5, 5 ) ) + pPool( new XMLFontAutoStylePool_Impl( 5, 5 ) ) { } XMLFontAutoStylePool::~XMLFontAutoStylePool() { delete pPool; - delete pNames; } OUString XMLFontAutoStylePool::Add( @@ -191,12 +177,12 @@ OUString XMLFontAutoStylePool::Add( if( sName.isEmpty() ) sName = OUString::valueOf( sal_Unicode( 'F' ) ); - if( pNames->Seek_Entry( &sName, 0 ) ) + if( m_aNames.find(sName) != m_aNames.end() ) { sal_Int32 nCount = 1; OUString sPrefix( sName ); sName += OUString::valueOf( nCount ); - while( pNames->Seek_Entry( &sName, 0 ) ) + while( m_aNames.find(sName) != m_aNames.end() ) { sName = sPrefix; sName += OUString::valueOf( ++nCount ); @@ -207,7 +193,7 @@ OUString XMLFontAutoStylePool::Add( new XMLFontAutoStylePoolEntry_Impl( sName, rFamilyName, rStyleName, nFamily, nPitch, eEnc ); pPool->Insert( pEntry ); - pNames->Insert( new OUString( sName ) ); + m_aNames.insert(sName); } return sPoolName; diff --git a/xmloff/source/style/impastp1.cxx b/xmloff/source/style/impastp1.cxx index ec98e9c37a77..4eeffef337d9 100644 --- a/xmloff/source/style/impastp1.cxx +++ b/xmloff/source/style/impastp1.cxx @@ -52,13 +52,13 @@ XMLFamilyData_Impl::XMLFamilyData_Impl( { mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 ); - mpNameList = new SvXMLAutoStylePoolNamesP_Impl( 5, 5 ); + mpNameList = new SvXMLAutoStylePoolNamesP_Impl; } XMLFamilyData_Impl::~XMLFamilyData_Impl() { - if( mpParentList ) delete mpParentList; - if( mpNameList ) delete mpNameList; + delete mpParentList; + delete mpNameList; DBG_ASSERT( !pCache || !pCache->size(), "auto style pool cache is not empty!" ); if( pCache ) { @@ -71,8 +71,7 @@ XMLFamilyData_Impl::~XMLFamilyData_Impl() void XMLFamilyData_Impl::ClearEntries() { - if( mpParentList ) - delete mpParentList; + delete mpParentList; mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 ); DBG_ASSERT( !pCache || !pCache->size(), "auto style pool cache is not empty!" ); if( pCache ) @@ -105,29 +104,4 @@ int XMLFamilyDataSort_Impl( const XMLFamilyData_Impl& r1, const XMLFamilyData_Im IMPL_CONTAINER_SORT( XMLFamilyDataList_Impl, XMLFamilyData_Impl, XMLFamilyDataSort_Impl ) -//############################################################################# -// -// Sorted list of OUString - elements -// - -/////////////////////////////////////////////////////////////////////////////// -// -// Sort-function for OUString-list -// - -int SvXMLAutoStylePoolNamesPCmp_Impl( const OUString& r1, - const OUString& r2 ) -{ - return (int)r1.compareTo( r2 ); -} - -/////////////////////////////////////////////////////////////////////////////// -// -// Implementation of sorted OUString-list -// - -IMPL_CONTAINER_SORT( SvXMLAutoStylePoolNamesP_Impl, - OUString, - SvXMLAutoStylePoolNamesPCmp_Impl ) - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/impastp2.cxx b/xmloff/source/style/impastp2.cxx index 882619d15f0f..b5d3c94b3747 100644 --- a/xmloff/source/style/impastp2.cxx +++ b/xmloff/source/style/impastp2.cxx @@ -58,7 +58,7 @@ SvXMLAutoStylePoolPropertiesP_Impl::SvXMLAutoStylePoolPropertiesP_Impl( XMLFamil sBuffer.append( OUString::valueOf( (sal_Int32)pFamilyData->mnName ) ); msName = sBuffer.makeStringAndClear(); } - while( pFamilyData->mpNameList->Seek_Entry( &msName, 0 ) ); + while( pFamilyData->mpNameList->find(msName) != pFamilyData->mpNameList->end() ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/impastp3.cxx b/xmloff/source/style/impastp3.cxx index d02d3f9027ed..20b1cf0a2f48 100644 --- a/xmloff/source/style/impastp3.cxx +++ b/xmloff/source/style/impastp3.cxx @@ -123,7 +123,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl* pFamilyDa } } - if( !pFamilyData->mpNameList->Seek_Entry( &rName, 0 ) ) + if(pFamilyData->mpNameList->find(rName) == pFamilyData->mpNameList->end()) { SvXMLAutoStylePoolPropertiesP_Impl* pProperties = new SvXMLAutoStylePoolPropertiesP_Impl( pFamilyData, rProperties ); diff --git a/xmloff/source/style/impastp4.cxx b/xmloff/source/style/impastp4.cxx index 389c80b55e20..47793ec9dbf2 100644 --- a/xmloff/source/style/impastp4.cxx +++ b/xmloff/source/style/impastp4.cxx @@ -136,11 +136,7 @@ void SvXMLAutoStylePoolP_Impl::RegisterName( sal_Int32 nFamily, const OUString& DBG_ASSERT( pNames, "SvXMLAutoStylePool_Impl::RegisterName: unknown family" ); if( pNames ) - { - OUString *pName = new OUString( rName ); - if( !pNames->Insert( pName ) ) - delete pName; - } + pNames->insert(rName); } /////////////////////////////////////////////////////////////////////////////// @@ -164,11 +160,12 @@ void SvXMLAutoStylePoolP_Impl::GetRegisteredNames( // iterate over names SvXMLAutoStylePoolNamesP_Impl* pNames = pFamily->mpNameList; - sal_uInt32 nNames = ( pNames != NULL ) ? pNames->Count() : 0; - for( sal_uInt32 j = 0; j < nNames; j++ ) + if (!pNames) + continue; + for (SvXMLAutoStylePoolNamesP_Impl::const_iterator aI = pNames->begin(); aI != pNames->end(); ++aI) { aFamilies.push_back( pFamily->mnFamily ); - aNames.push_back( *pNames->GetObject( j ) ); + aNames.push_back( *aI ); } } diff --git a/xmloff/source/style/impastpl.hxx b/xmloff/source/style/impastpl.hxx index 3392bc9a0ed9..659211f6ff94 100644 --- a/xmloff/source/style/impastpl.hxx +++ b/xmloff/source/style/impastpl.hxx @@ -32,6 +32,7 @@ #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> @@ -41,7 +42,7 @@ class SvXMLAutoStylePoolP; class SvXMLAutoStylePoolParentsP_Impl; -class SvXMLAutoStylePoolNamesP_Impl; +typedef std::set<rtl::OUString> SvXMLAutoStylePoolNamesP_Impl; class SvXMLExportPropertyMapper; class SvXMLExport; @@ -92,14 +93,6 @@ DECLARE_CONTAINER_SORT( XMLFamilyDataList_Impl, XMLFamilyData_Impl ) /////////////////////////////////////////////////////////////////////////////// // -// -// - -DECLARE_CONTAINER_SORT_DEL( SvXMLAutoStylePoolNamesP_Impl, - ::rtl::OUString ) - -/////////////////////////////////////////////////////////////////////////////// -// // Properties of a pool // diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index d99469d70338..f881dec9e554 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -63,6 +63,7 @@ #include "PageMasterImportContext.hxx" #include "PageMasterImportPropMapper.hxx" +#include <set> #include <vector> using ::rtl::OUString; @@ -243,29 +244,29 @@ public: const SvXMLStyleContext *GetStyle() const { return pStyle; } }; -int SvXMLStyleIndexCmp_Impl( const SvXMLStyleIndex_Impl& r1, - const SvXMLStyleIndex_Impl& r2 ) +struct SvXMLStyleIndexCmp_Impl { - int nRet; - if( (sal_uInt16)r1.GetFamily() < (sal_uInt16)r2.GetFamily() ) - nRet = -1; - else if( (sal_uInt16)r1.GetFamily() > (sal_uInt16)r2.GetFamily() ) - nRet = 1; - else - nRet = (int)r1.GetName().compareTo( r2.GetName() ); + bool operator()(const SvXMLStyleIndex_Impl& r1, const SvXMLStyleIndex_Impl& r2) + { + sal_Int32 nRet; - return nRet; -} + if( (sal_uInt16)r1.GetFamily() < (sal_uInt16)r2.GetFamily() ) + nRet = -1; + else if( (sal_uInt16)r1.GetFamily() > (sal_uInt16)r2.GetFamily() ) + nRet = 1; + else + nRet = r1.GetName().compareTo( r2.GetName() ); + + return nRet < 0; + } +}; // --------------------------------------------------------------------- typedef SvXMLStyleContext *SvXMLStyleContextPtr; typedef vector< SvXMLStyleContextPtr > SvXMLStyleContexts_Impl; -DECLARE_CONTAINER_SORT_DEL( SvXMLStyleIndices_Impl, SvXMLStyleIndex_Impl ) -IMPL_CONTAINER_SORT( SvXMLStyleIndices_Impl, SvXMLStyleIndex_Impl, - SvXMLStyleIndexCmp_Impl ) - +typedef std::set<SvXMLStyleIndex_Impl, SvXMLStyleIndexCmp_Impl> SvXMLStyleIndices_Impl; class SvXMLStylesContext_Impl { @@ -357,17 +358,8 @@ const SvXMLStyleContext *SvXMLStylesContext_Impl::FindStyleChildContext( "Performance warning: sdbcx::Index created multiple times" ); #endif ((SvXMLStylesContext_Impl *)this)->pIndices = - new SvXMLStyleIndices_Impl( - sal::static_int_cast< sal_uInt16 >( aStyles.size() ), 5 ); - for( size_t i = 0; i < aStyles.size(); i++ ) - { - SvXMLStyleIndex_Impl* pStyleIndex = new SvXMLStyleIndex_Impl( aStyles[ i ] ); - if (!pIndices->Insert( pStyleIndex )) - { - OSL_FAIL("Here is a double Style"); - delete pStyleIndex; - } - } + new SvXMLStyleIndices_Impl( aStyles.begin(), aStyles.end() ); + SAL_WARN_IF(pIndices->size() != aStyles.size(), "xmloff", "Here is a duplicate Style"); #ifdef DBG_UTIL ((SvXMLStylesContext_Impl *)this)->nIndexCreated++; #endif @@ -376,9 +368,9 @@ const SvXMLStyleContext *SvXMLStylesContext_Impl::FindStyleChildContext( if( pIndices ) { SvXMLStyleIndex_Impl aIndex( nFamily, rName ); - sal_uLong nPos = 0; - if( pIndices->Seek_Entry( &aIndex, &nPos ) ) - pStyle = pIndices->GetObject( nPos )->GetStyle(); + SvXMLStyleIndices_Impl::iterator aFind = pIndices->find(aIndex); + if( aFind != pIndices->end() ) + pStyle = aFind->GetStyle(); } else { diff --git a/xmloff/source/text/XMLTextListAutoStylePool.cxx b/xmloff/source/text/XMLTextListAutoStylePool.cxx index 8becfb762b3e..acf904432c1a 100644 --- a/xmloff/source/text/XMLTextListAutoStylePool.cxx +++ b/xmloff/source/text/XMLTextListAutoStylePool.cxx @@ -46,18 +46,6 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::style; -int XMLTextListAutoStylePoolNameCmp_Impl( const OUString& r1, - const OUString& r2 ) -{ - return (int)r1.compareTo( r2 ); -} - -DECLARE_CONTAINER_SORT_DEL( XMLTextListAutoStylePoolNames_Impl, - OUString ) -IMPL_CONTAINER_SORT( XMLTextListAutoStylePoolNames_Impl, - OUString, - XMLTextListAutoStylePoolNameCmp_Impl ) - class XMLTextListAutoStylePoolEntry_Impl { OUString sName; @@ -132,7 +120,7 @@ XMLTextListAutoStylePoolEntry_Impl::XMLTextListAutoStylePoolEntry_Impl( sBuffer.append( (sal_Int32)rName ); sName = sBuffer.makeStringAndClear(); } - while( rNames.Seek_Entry( &sName, 0 ) ); + while (rNames.find(sName) != rNames.end()); } int XMLTextListAutoStylePoolEntryCmp_Impl( @@ -169,7 +157,6 @@ XMLTextListAutoStylePool::XMLTextListAutoStylePool( SvXMLExport& rExp ) : rExport( rExp ), sPrefix( RTL_CONSTASCII_USTRINGPARAM("L") ), pPool( new XMLTextListAutoStylePool_Impl( 5, 5 ) ), - pNames( new XMLTextListAutoStylePoolNames_Impl( 5, 5 ) ), nName( 0 ) { Reference<ucb::XAnyCompareFactory> xCompareFac( rExp.GetModel(), uno::UNO_QUERY ); @@ -189,18 +176,11 @@ XMLTextListAutoStylePool::~XMLTextListAutoStylePool() while ( nCount-- ) delete pPool->Remove(nCount); delete pPool; - - nCount = pNames->Count(); - while ( nCount-- ) - delete pNames->Remove(nCount); - delete pNames; } void XMLTextListAutoStylePool::RegisterName( const OUString& rName ) { - OUString *pName = new OUString( rName ); - if( !pNames->Insert( pName ) ) - delete pName; + m_aNames.insert(rName); } sal_uInt32 XMLTextListAutoStylePool::Find( XMLTextListAutoStylePoolEntry_Impl* pEntry ) const @@ -244,7 +224,7 @@ OUString XMLTextListAutoStylePool::Add( { XMLTextListAutoStylePoolEntry_Impl *pEntry = new XMLTextListAutoStylePoolEntry_Impl( pPool->Count(), - rNumRules, *pNames, sPrefix, + rNumRules, m_aNames, sPrefix, nName ); pPool->Insert( pEntry ); sName = pEntry->GetName(); |