diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-08-02 11:00:20 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-08-02 11:34:02 +0100 |
commit | 5cd8770cbe39f124c69cbceaf745453b7fd63839 (patch) | |
tree | 3cfcd5dbcbdeb73ea12d95ba7ce0faf1c13a99fe /xmloff | |
parent | b90a897069536c571969a917a6b474ebb69a9828 (diff) |
convert XMLFamilyDataList_Impl to boost::ptr_set
Change-Id: I2a23787091828415cf814eb7091f3fa926b5876c
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/style/impastp1.cxx | 22 | ||||
-rw-r--r-- | xmloff/source/style/impastp2.cxx | 17 | ||||
-rw-r--r-- | xmloff/source/style/impastp3.cxx | 16 | ||||
-rw-r--r-- | xmloff/source/style/impastp4.cxx | 359 | ||||
-rw-r--r-- | xmloff/source/style/impastpl.hxx | 13 |
5 files changed, 188 insertions, 239 deletions
diff --git a/xmloff/source/style/impastp1.cxx b/xmloff/source/style/impastp1.cxx index 4eeffef337d9..b1a0bd6bef14 100644 --- a/xmloff/source/style/impastp1.cxx +++ b/xmloff/source/style/impastp1.cxx @@ -82,26 +82,4 @@ void XMLFamilyData_Impl::ClearEntries() } } -/////////////////////////////////////////////////////////////////////////////// -// -// friendfunction of class XMLFamilyData_Impl for sorting listelements -// - -int XMLFamilyDataSort_Impl( const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2 ) -{ - int nRet = 0; - - if( r1.mnFamily != r2.mnFamily ) - nRet = ( r1.mnFamily > r2.mnFamily ? 1 : -1 ); - - return nRet; -} - -/////////////////////////////////////////////////////////////////////////////// -// -// Implementation of sorted list of XMLFamilyData_Impl - elements -// - -IMPL_CONTAINER_SORT( XMLFamilyDataList_Impl, XMLFamilyData_Impl, XMLFamilyDataSort_Impl ) - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/impastp2.cxx b/xmloff/source/style/impastp2.cxx index b5d3c94b3747..6de03bdfc58b 100644 --- a/xmloff/source/style/impastp2.cxx +++ b/xmloff/source/style/impastp2.cxx @@ -44,21 +44,26 @@ using ::rtl::OUStringBuffer; // ctor class SvXMLAutoStylePoolProperties_Impl // -SvXMLAutoStylePoolPropertiesP_Impl::SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl* pFamilyData, const vector< XMLPropertyState >& rProperties ) +SvXMLAutoStylePoolPropertiesP_Impl::SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties ) : maProperties( rProperties ), - mnPos ( pFamilyData->mnCount ) + mnPos ( rFamilyData.mnCount ) { // create a name that hasn't been used before. The created name has not // to be added to the array, because it will never tried again OUStringBuffer sBuffer( 7 ); do { - pFamilyData->mnName++; - sBuffer.append( pFamilyData->maStrPrefix ); - sBuffer.append( OUString::valueOf( (sal_Int32)pFamilyData->mnName ) ); + rFamilyData.mnName++; + sBuffer.append( rFamilyData.maStrPrefix ); + sBuffer.append( OUString::valueOf( (sal_Int32)rFamilyData.mnName ) ); msName = sBuffer.makeStringAndClear(); } - while( pFamilyData->mpNameList->find(msName) != pFamilyData->mpNameList->end() ); + while( rFamilyData.mpNameList->find(msName) != rFamilyData.mpNameList->end() ); +} + +bool operator<( const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2) +{ + return r1.mnFamily < r2.mnFamily; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/impastp3.cxx b/xmloff/source/style/impastp3.cxx index 20b1cf0a2f48..eceed9ed2de9 100644 --- a/xmloff/source/style/impastp3.cxx +++ b/xmloff/source/style/impastp3.cxx @@ -56,7 +56,7 @@ SvXMLAutoStylePoolParentP_Impl::~SvXMLAutoStylePoolParentP_Impl() // if not added, yet. // -sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl* pFamilyData, const vector< XMLPropertyState >& rProperties, OUString& rName, bool bDontSeek ) +sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties, OUString& rName, bool bDontSeek ) { sal_Bool bAdded = sal_False; SvXMLAutoStylePoolPropertiesP_Impl *pProperties = 0; @@ -75,7 +75,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl* pFamilyData, c { break; } - else if( !bDontSeek && pFamilyData->mxMapper->Equals( pIS->GetProperties(), rProperties ) ) + else if( !bDontSeek && rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) ) { pProperties = pIS; break; @@ -84,7 +84,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl* pFamilyData, c if( !pProperties ) { - pProperties = new SvXMLAutoStylePoolPropertiesP_Impl( pFamilyData, rProperties ); + pProperties = new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties ); SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin(); ::std::advance( it, i ); maPropertiesList.insert( it, pProperties ); @@ -103,7 +103,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl* pFamilyData, c // the same properties exists, a new one is added (like with bDontSeek). // -sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl* pFamilyData, const vector< XMLPropertyState >& rProperties, const OUString& rName ) +sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties, const OUString& rName ) { sal_Bool bAdded = sal_False; size_t i = 0; @@ -123,10 +123,10 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl* pFamilyDa } } - if(pFamilyData->mpNameList->find(rName) == pFamilyData->mpNameList->end()) + if(rFamilyData.mpNameList->find(rName) == rFamilyData.mpNameList->end()) { SvXMLAutoStylePoolPropertiesP_Impl* pProperties = - new SvXMLAutoStylePoolPropertiesP_Impl( pFamilyData, rProperties ); + new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties ); // ignore the generated name pProperties->SetName( rName ); SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin(); @@ -143,7 +143,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl* pFamilyDa // Search for a array of XMLPropertyState ( vector< XMLPropertyState > ) in list // -OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl* pFamilyData, const vector< XMLPropertyState >& rProperties ) const +OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties ) const { OUString sName; vector< XMLPropertyState>::size_type nItems = rProperties.size(); @@ -159,7 +159,7 @@ OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl* pFamily { break; } - else if( pFamilyData->mxMapper->Equals( pIS->GetProperties(), rProperties ) ) + else if( rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) ) { sName = pIS->GetName(); break; diff --git a/xmloff/source/style/impastp4.cxx b/xmloff/source/style/impastp4.cxx index 47793ec9dbf2..02b380f4be87 100644 --- a/xmloff/source/style/impastp4.cxx +++ b/xmloff/source/style/impastp4.cxx @@ -56,20 +56,12 @@ using namespace ::xmloff::token; // SvXMLAutoStylePoolP_Impl::SvXMLAutoStylePoolP_Impl( SvXMLExport& rExp) - : rExport( rExp ), - maFamilyList( 5, 5 ) + : rExport( rExp ) { } SvXMLAutoStylePoolP_Impl::~SvXMLAutoStylePoolP_Impl() { - for (;;) { - XMLFamilyData_Impl* pData = maFamilyList.Remove( sal_uLong(0) ); - if (pData == NULL) { - break; - } - delete pData; - } } /////////////////////////////////////////////////////////////////////////////// @@ -85,8 +77,6 @@ void SvXMLAutoStylePoolP_Impl::AddFamily( sal_Bool bAsFamily ) { // store family in a list if not already stored - sal_uLong nPos; - sal_uInt16 nExportFlags = GetExport().getExportFlags(); sal_Bool bStylesOnly = (nExportFlags & EXPORT_STYLES) != 0 && (nExportFlags & EXPORT_CONTENT) == 0; @@ -98,10 +88,7 @@ void SvXMLAutoStylePoolP_Impl::AddFamily( } XMLFamilyData_Impl *pFamily = new XMLFamilyData_Impl( nFamily, rStrName, rMapper, aPrefix, bAsFamily ); - if( !maFamilyList.Seek_Entry( pFamily, &nPos ) ) - maFamilyList.Insert( pFamily ); - else - delete pFamily; + maFamilyList.insert(pFamily); } void SvXMLAutoStylePoolP_Impl::SetFamilyPropSetMapper( @@ -110,14 +97,9 @@ void SvXMLAutoStylePoolP_Impl::SetFamilyPropSetMapper( { XMLFamilyData_Impl aTemporary( nFamily ); - sal_uLong nPos; - - if( maFamilyList.Seek_Entry( &aTemporary, &nPos ) ) - { - XMLFamilyData_Impl* pFamily = maFamilyList.GetObject( nPos ); - if ( pFamily ) - pFamily-> mxMapper = rMapper; - } + XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTemporary); + if (aFind != maFamilyList.end()) + aFind->mxMapper = rMapper; } /////////////////////////////////////////////////////////////////////////////// // @@ -126,17 +108,12 @@ void SvXMLAutoStylePoolP_Impl::SetFamilyPropSetMapper( void SvXMLAutoStylePoolP_Impl::RegisterName( sal_Int32 nFamily, const OUString& rName ) { - SvXMLAutoStylePoolNamesP_Impl *pNames = 0; - - sal_uLong nPos; XMLFamilyData_Impl aTmp( nFamily ); - if( maFamilyList.Seek_Entry( &aTmp, &nPos ) ) - pNames = maFamilyList.GetObject( nPos )->mpNameList; - - DBG_ASSERT( pNames, + XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTmp); + DBG_ASSERT( aFind != maFamilyList.end(), "SvXMLAutoStylePool_Impl::RegisterName: unknown family" ); - if( pNames ) - pNames->insert(rName); + if (aFind != maFamilyList.end()) + aFind->mpNameList->insert(rName); } /////////////////////////////////////////////////////////////////////////////// @@ -153,18 +130,17 @@ void SvXMLAutoStylePoolP_Impl::GetRegisteredNames( vector<OUString> aNames; // iterate over families - sal_uInt32 nCount = maFamilyList.Count(); - for( sal_uInt32 i = 0; i < nCount; i++ ) + for(XMLFamilyDataList_Impl::iterator aJ = maFamilyList.begin(); aJ != maFamilyList.end(); ++aJ) { - XMLFamilyData_Impl* pFamily = maFamilyList.GetObject( i ); + XMLFamilyData_Impl &rFamily = *aJ; // iterate over names - SvXMLAutoStylePoolNamesP_Impl* pNames = pFamily->mpNameList; + SvXMLAutoStylePoolNamesP_Impl* pNames = rFamily.mpNameList; if (!pNames) continue; for (SvXMLAutoStylePoolNamesP_Impl::const_iterator aI = pNames->begin(); aI != pNames->end(); ++aI) { - aFamilies.push_back( pFamily->mnFamily ); + aFamilies.push_back( rFamily.mnFamily ); aNames.push_back( *aI ); } } @@ -192,22 +168,20 @@ sal_Bool SvXMLAutoStylePoolP_Impl::Add(OUString& rName, sal_Int32 nFamily, bool bDontSeek ) { sal_Bool bRet(sal_False); - sal_uLong nPos; - XMLFamilyData_Impl *pFamily = 0; XMLFamilyData_Impl aTemporary( nFamily ); - if( maFamilyList.Seek_Entry( &aTemporary, &nPos ) ) - { - pFamily = maFamilyList.GetObject( nPos ); - } + XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTemporary); + DBG_ASSERT(aFind != maFamilyList.end(), "SvXMLAutoStylePool_Impl::Add: unknown family"); - DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Add: unknown family" ); - if( pFamily ) + if (aFind != maFamilyList.end()) { + XMLFamilyData_Impl &rFamily = *aFind; + SvXMLAutoStylePoolParentP_Impl aTmp( rParent ); SvXMLAutoStylePoolParentP_Impl *pParent = 0; - SvXMLAutoStylePoolParentsP_Impl *pParents = pFamily->mpParentList; + SvXMLAutoStylePoolParentsP_Impl *pParents = rFamily.mpParentList; + sal_uLong nPos; if( pParents->Seek_Entry( &aTmp, &nPos ) ) { pParent = pParents->GetObject( nPos ); @@ -218,18 +192,18 @@ sal_Bool SvXMLAutoStylePoolP_Impl::Add(OUString& rName, sal_Int32 nFamily, pParents->Insert( pParent ); } - if( pParent->Add( pFamily, rProperties, rName, bDontSeek ) ) + if( pParent->Add( rFamily, rProperties, rName, bDontSeek ) ) { - pFamily->mnCount++; + rFamily.mnCount++; bRet = sal_True; } if( bCache ) { - if( !pFamily->pCache ) - pFamily->pCache = new SvXMLAutoStylePoolCache_Impl(); - if( pFamily->pCache->size() < MAX_CACHE_SIZE ) - pFamily->pCache->push_back( new OUString( rName ) ); + if( !rFamily.pCache ) + rFamily.pCache = new SvXMLAutoStylePoolCache_Impl(); + if( rFamily.pCache->size() < MAX_CACHE_SIZE ) + rFamily.pCache->push_back( new OUString( rName ) ); } } @@ -241,22 +215,20 @@ sal_Bool SvXMLAutoStylePoolP_Impl::AddNamed(const OUString& rName, sal_Int32 nFa { // get family and parent the same way as in Add() sal_Bool bRet(sal_False); - sal_uLong nPos; - XMLFamilyData_Impl *pFamily = 0; XMLFamilyData_Impl aTemporary( nFamily ); - if( maFamilyList.Seek_Entry( &aTemporary, &nPos ) ) - { - pFamily = maFamilyList.GetObject( nPos ); - } + XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTemporary); + DBG_ASSERT(aFind != maFamilyList.end(), "SvXMLAutoStylePool_Impl::Add: unknown family"); - DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Add: unknown family" ); - if( pFamily ) + if (aFind != maFamilyList.end()) { + XMLFamilyData_Impl &rFamily = *aFind; + SvXMLAutoStylePoolParentP_Impl aTmp( rParent ); SvXMLAutoStylePoolParentP_Impl *pParent = 0; - SvXMLAutoStylePoolParentsP_Impl *pParents = pFamily->mpParentList; + SvXMLAutoStylePoolParentsP_Impl *pParents = rFamily.mpParentList; + sal_uLong nPos; if( pParents->Seek_Entry( &aTmp, &nPos ) ) { pParent = pParents->GetObject( nPos ); @@ -267,9 +239,9 @@ sal_Bool SvXMLAutoStylePoolP_Impl::AddNamed(const OUString& rName, sal_Int32 nFa pParents->Insert( pParent ); } - if( pParent->AddNamed( pFamily, rProperties, rName ) ) + if( pParent->AddNamed( rFamily, rProperties, rName ) ) { - pFamily->mnCount++; + rFamily.mnCount++; bRet = sal_True; } } @@ -288,24 +260,20 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily, { OUString sName; - sal_uLong nPos; XMLFamilyData_Impl aTemporary( nFamily ); - XMLFamilyData_Impl *pFamily = 0; - if( maFamilyList.Seek_Entry( &aTemporary, &nPos ) ) - { - pFamily = maFamilyList.GetObject( nPos ); - } + XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTemporary); + DBG_ASSERT(aFind != maFamilyList.end(), "SvXMLAutoStylePool_Impl::Find: unknown family"); - DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Find: unknown family" ); - - if( pFamily ) + if (aFind != maFamilyList.end()) { - SvXMLAutoStylePoolParentP_Impl aTmp( rParent ); - + XMLFamilyData_Impl &rFamily = *aFind; const SvXMLAutoStylePoolParentsP_Impl* pParents = - pFamily->mpParentList; + rFamily.mpParentList; + + SvXMLAutoStylePoolParentP_Impl aTmp( rParent ); + sal_uLong nPos; if( pParents->Seek_Entry( &aTmp, &nPos ) ) - sName = pParents->GetObject( nPos )->Find( pFamily, rProperties ); + sName = pParents->GetObject( nPos )->Find( rFamily, rProperties ); } return sName; @@ -323,156 +291,153 @@ void SvXMLAutoStylePoolP_Impl::exportXML( const SvXMLNamespaceMap&, const SvXMLAutoStylePoolP *pAntiImpl) const { - sal_uInt32 nCount = 0; - // Get list of parents for current family (nFamily) - sal_uLong nPos; XMLFamilyData_Impl aTmp( nFamily ); - XMLFamilyData_Impl *pFamily = 0; - if( maFamilyList.Seek_Entry( &aTmp, &nPos ) ) + XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTmp); + DBG_ASSERT( aFind != maFamilyList.end(), + "SvXMLAutoStylePool_Impl::exportXML: unknown family" ); + if (aFind == maFamilyList.end()) + return; + + XMLFamilyData_Impl &rFamily = *aFind; + sal_uInt32 nCount = rFamily.mnCount; + + if (!nCount) + return; + + ///////////////////////////////////////////////////////////////////////////////////// + // create, initialize and fill helper-structure (SvXMLAutoStylePoolProperties_Impl) + // wich contains a parent-name and a SvXMLAutoStylePoolProperties_Impl + // + const SvXMLAutoStylePoolParentsP_Impl *pParents = + rFamily.mpParentList; + + SvXMLAutoStylePoolPExport_Impl* aExpStyles = + new SvXMLAutoStylePoolPExport_Impl[nCount]; + + sal_uInt32 i; + for( i=0; i < nCount; i++ ) { - pFamily = maFamilyList.GetObject( nPos ); - nCount = pFamily->mnCount; + aExpStyles[i].mpParent = 0; + aExpStyles[i].mpProperties = 0; } - DBG_ASSERT( pFamily, - "SvXMLAutoStylePool_Impl::exportXML: unknown family" ); - if( pFamily && nCount > 0 ) + sal_uInt32 nParents = pParents->Count(); + for( i=0; i < nParents; i++ ) { - ///////////////////////////////////////////////////////////////////////////////////// - // create, initialize and fill helper-structure (SvXMLAutoStylePoolProperties_Impl) - // wich contains a parent-name and a SvXMLAutoStylePoolProperties_Impl - // - const SvXMLAutoStylePoolParentsP_Impl *pParents = - pFamily->mpParentList; - - SvXMLAutoStylePoolPExport_Impl* aExpStyles = - new SvXMLAutoStylePoolPExport_Impl[nCount]; - - sal_uInt32 i; - for( i=0; i < nCount; i++ ) + const SvXMLAutoStylePoolParentP_Impl* pParent = + pParents->GetObject( i ); + size_t nProperties = pParent->GetPropertiesList().size(); + for( size_t j = 0; j < nProperties; j++ ) { - aExpStyles[i].mpParent = 0; - aExpStyles[i].mpProperties = 0; - } - - sal_uInt32 nParents = pParents->Count(); - for( i=0; i < nParents; i++ ) - { - const SvXMLAutoStylePoolParentP_Impl* pParent = - pParents->GetObject( i ); - size_t nProperties = pParent->GetPropertiesList().size(); - for( size_t j = 0; j < nProperties; j++ ) + const SvXMLAutoStylePoolPropertiesP_Impl* pProperties = + pParent->GetPropertiesList()[ j ]; + sal_uLong nPos = pProperties->GetPos(); + DBG_ASSERT( nPos < nCount, + "SvXMLAutoStylePool_Impl::exportXML: wrong position" ); + if( nPos < nCount ) { - const SvXMLAutoStylePoolPropertiesP_Impl* pProperties = - pParent->GetPropertiesList()[ j ]; - nPos = pProperties->GetPos(); - DBG_ASSERT( nPos < nCount, - "SvXMLAutoStylePool_Impl::exportXML: wrong position" ); - if( nPos < nCount ) - { - DBG_ASSERT( !aExpStyles[nPos].mpProperties, - "SvXMLAutoStylePool_Impl::exportXML: double position" ); - aExpStyles[nPos].mpProperties = pProperties; - aExpStyles[nPos].mpParent = &pParent->GetParent(); - } + DBG_ASSERT( !aExpStyles[nPos].mpProperties, + "SvXMLAutoStylePool_Impl::exportXML: double position" ); + aExpStyles[nPos].mpProperties = pProperties; + aExpStyles[nPos].mpParent = &pParent->GetParent(); } } + } + + ///////////////////////////////////////////////////////////////////////////////////// + // + // create string to export for each XML-style. That means for each property-list + // + OUString aStrFamilyName = rFamily.maStrFamilyName; - ///////////////////////////////////////////////////////////////////////////////////// - // - // create string to export for each XML-style. That means for each property-list - // - OUString aStrFamilyName = pFamily->maStrFamilyName; + for( i=0; i<nCount; i++ ) + { + DBG_ASSERT( aExpStyles[i].mpProperties, + "SvXMLAutoStylePool_Impl::exportXML: empty position" ); - for( i=0; i<nCount; i++ ) + if( aExpStyles[i].mpProperties ) { - DBG_ASSERT( aExpStyles[i].mpProperties, - "SvXMLAutoStylePool_Impl::exportXML: empty position" ); + GetExport().AddAttribute( + XML_NAMESPACE_STYLE, XML_NAME, + aExpStyles[i].mpProperties->GetName() ); - if( aExpStyles[i].mpProperties ) + if( rFamily.bAsFamily ) { GetExport().AddAttribute( - XML_NAMESPACE_STYLE, XML_NAME, - aExpStyles[i].mpProperties->GetName() ); + XML_NAMESPACE_STYLE, XML_FAMILY, aStrFamilyName ); + } - if( pFamily->bAsFamily ) - { - GetExport().AddAttribute( - XML_NAMESPACE_STYLE, XML_FAMILY, aStrFamilyName ); - } + if( !aExpStyles[i].mpParent->isEmpty() ) + { + GetExport().AddAttribute( + XML_NAMESPACE_STYLE, XML_PARENT_STYLE_NAME, + GetExport().EncodeStyleName( + *aExpStyles[i].mpParent ) ); + } - if( !aExpStyles[i].mpParent->isEmpty() ) - { - GetExport().AddAttribute( - XML_NAMESPACE_STYLE, XML_PARENT_STYLE_NAME, - GetExport().EncodeStyleName( - *aExpStyles[i].mpParent ) ); - } + OUString sName; + if( rFamily.bAsFamily ) + sName = GetXMLToken(XML_STYLE); + else + sName = rFamily.maStrFamilyName; + + pAntiImpl->exportStyleAttributes( + GetExport().GetAttrList(), + nFamily, + aExpStyles[i].mpProperties->GetProperties(), + *rFamily.mxMapper.get() + , GetExport().GetMM100UnitConverter(), + GetExport().GetNamespaceMap() + ); + + SvXMLElementExport aElem( GetExport(), + XML_NAMESPACE_STYLE, sName, + sal_True, sal_True ); - OUString sName; - if( pFamily->bAsFamily ) - sName = GetXMLToken(XML_STYLE); - else - sName = pFamily->maStrFamilyName; - - pAntiImpl->exportStyleAttributes( - GetExport().GetAttrList(), - nFamily, - aExpStyles[i].mpProperties->GetProperties(), - *pFamily->mxMapper.get() - , GetExport().GetMM100UnitConverter(), - GetExport().GetNamespaceMap() - ); - - SvXMLElementExport aElem( GetExport(), - XML_NAMESPACE_STYLE, sName, - sal_True, sal_True ); - - sal_Int32 nStart(-1); - sal_Int32 nEnd(-1); - if (nFamily == XML_STYLE_FAMILY_PAGE_MASTER) + sal_Int32 nStart(-1); + sal_Int32 nEnd(-1); + if (nFamily == XML_STYLE_FAMILY_PAGE_MASTER) + { + nStart = 0; + sal_Int32 nIndex = 0; + UniReference< XMLPropertySetMapper > aPropMapper = + rFamily.mxMapper->getPropertySetMapper(); + sal_Int16 nContextID; + while(nIndex < aPropMapper->GetEntryCount() && nEnd == -1) { - nStart = 0; - sal_Int32 nIndex = 0; - UniReference< XMLPropertySetMapper > aPropMapper = - pFamily->mxMapper->getPropertySetMapper(); - sal_Int16 nContextID; - while(nIndex < aPropMapper->GetEntryCount() && nEnd == -1) - { - nContextID = aPropMapper->GetEntryContextId( nIndex ); - if (nContextID && ((nContextID & CTF_PM_FLAGMASK) != XML_PM_CTF_START)) - nEnd = nIndex; - nIndex++; - } - if (nEnd == -1) + nContextID = aPropMapper->GetEntryContextId( nIndex ); + if (nContextID && ((nContextID & CTF_PM_FLAGMASK) != XML_PM_CTF_START)) nEnd = nIndex; + nIndex++; } - - pFamily->mxMapper->exportXML( - GetExport(), - aExpStyles[i].mpProperties->GetProperties(), - nStart, nEnd, XML_EXPORT_FLAG_IGN_WS ); - - pAntiImpl->exportStyleContent( - GetExport().GetDocHandler(), - nFamily, - aExpStyles[i].mpProperties->GetProperties(), - *pFamily->mxMapper.get(), - GetExport().GetMM100UnitConverter(), - GetExport().GetNamespaceMap() - ); + if (nEnd == -1) + nEnd = nIndex; } - } - delete[] aExpStyles; + rFamily.mxMapper->exportXML( + GetExport(), + aExpStyles[i].mpProperties->GetProperties(), + nStart, nEnd, XML_EXPORT_FLAG_IGN_WS ); + + pAntiImpl->exportStyleContent( + GetExport().GetDocHandler(), + nFamily, + aExpStyles[i].mpProperties->GetProperties(), + *rFamily.mxMapper.get(), + GetExport().GetMM100UnitConverter(), + GetExport().GetNamespaceMap() + ); + } } + + delete[] aExpStyles; } void SvXMLAutoStylePoolP_Impl::ClearEntries() { - for(sal_uInt32 a = 0L; a < maFamilyList.Count(); a++) - maFamilyList[a]->ClearEntries(); + for(XMLFamilyDataList_Impl::iterator aI = maFamilyList.begin(); aI != maFamilyList.end(); ++aI) + aI->ClearEntries(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/impastpl.hxx b/xmloff/source/style/impastpl.hxx index 659211f6ff94..941471dde7c1 100644 --- a/xmloff/source/style/impastpl.hxx +++ b/xmloff/source/style/impastpl.hxx @@ -29,6 +29,7 @@ #ifndef _XMLOFF_XMLASTPL_IMPL_HXX #define _XMLOFF_XMLASTPL_IMPL_HXX +#include <boost/ptr_container/ptr_set.hpp> #include <sal/types.h> #include <svl/cntnrsrt.hxx> #include <rtl/ustring.hxx> @@ -84,12 +85,12 @@ public: {} ~XMLFamilyData_Impl(); - friend int XMLFamilyDataSort_Impl( const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2 ); + friend bool operator<(const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2); void ClearEntries(); }; -DECLARE_CONTAINER_SORT( XMLFamilyDataList_Impl, XMLFamilyData_Impl ) +typedef boost::ptr_set<XMLFamilyData_Impl> XMLFamilyDataList_Impl; /////////////////////////////////////////////////////////////////////////////// // @@ -104,7 +105,7 @@ class SvXMLAutoStylePoolPropertiesP_Impl public: - SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties ); + SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties ); ~SvXMLAutoStylePoolPropertiesP_Impl() { @@ -139,11 +140,11 @@ public: ~SvXMLAutoStylePoolParentP_Impl(); - sal_Bool Add( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties, ::rtl::OUString& rName, bool bDontSeek = false ); + sal_Bool Add( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties, ::rtl::OUString& rName, bool bDontSeek = false ); - sal_Bool AddNamed( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties, const ::rtl::OUString& rName ); + sal_Bool AddNamed( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties, const ::rtl::OUString& rName ); - ::rtl::OUString Find( const XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties ) const; + ::rtl::OUString Find( const XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties ) const; const ::rtl::OUString& GetParent() const { return msParent; } |