Kaydet (Commit) 5cd8770c authored tarafından Caolán McNamara's avatar Caolán McNamara

convert XMLFamilyDataList_Impl to boost::ptr_set

Change-Id: I2a23787091828415cf814eb7091f3fa926b5876c
üst b90a8970
...@@ -51,8 +51,6 @@ VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer(Size const&, Fraction cons ...@@ -51,8 +51,6 @@ VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer(Size const&, Fraction cons
Window::PostUserEvent(unsigned long&, unsigned long, void*) Window::PostUserEvent(unsigned long&, unsigned long, void*)
X11SalGraphics::SetMask(int&, int&, unsigned int&, unsigned int&, int&, int&, unsigned long) X11SalGraphics::SetMask(int&, int&, unsigned int&, unsigned int&, int&, int&, unsigned long)
X509Certificate_NssImpl::getImplementation(com::sun::star::uno::Reference<com::sun::star::uno::XInterface>) 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*)
XMLFontAutoStylePool_Impl::GetPos(XMLFontAutoStylePoolEntry_Impl const*) const XMLFontAutoStylePool_Impl::GetPos(XMLFontAutoStylePoolEntry_Impl const*) const
XMLFontAutoStylePool_Impl::Remove(XMLFontAutoStylePoolEntry_Impl*) XMLFontAutoStylePool_Impl::Remove(XMLFontAutoStylePoolEntry_Impl*)
XMLTextListAutoStylePool_Impl::GetPos(XMLTextListAutoStylePoolEntry_Impl const*) const XMLTextListAutoStylePool_Impl::GetPos(XMLTextListAutoStylePoolEntry_Impl const*) const
......
...@@ -82,26 +82,4 @@ void XMLFamilyData_Impl::ClearEntries() ...@@ -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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -44,21 +44,26 @@ using ::rtl::OUStringBuffer; ...@@ -44,21 +44,26 @@ using ::rtl::OUStringBuffer;
// ctor class SvXMLAutoStylePoolProperties_Impl // 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 ), : maProperties( rProperties ),
mnPos ( pFamilyData->mnCount ) mnPos ( rFamilyData.mnCount )
{ {
// create a name that hasn't been used before. The created name has not // 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 // to be added to the array, because it will never tried again
OUStringBuffer sBuffer( 7 ); OUStringBuffer sBuffer( 7 );
do do
{ {
pFamilyData->mnName++; rFamilyData.mnName++;
sBuffer.append( pFamilyData->maStrPrefix ); sBuffer.append( rFamilyData.maStrPrefix );
sBuffer.append( OUString::valueOf( (sal_Int32)pFamilyData->mnName ) ); sBuffer.append( OUString::valueOf( (sal_Int32)rFamilyData.mnName ) );
msName = sBuffer.makeStringAndClear(); 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -56,7 +56,7 @@ SvXMLAutoStylePoolParentP_Impl::~SvXMLAutoStylePoolParentP_Impl() ...@@ -56,7 +56,7 @@ SvXMLAutoStylePoolParentP_Impl::~SvXMLAutoStylePoolParentP_Impl()
// if not added, yet. // 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; sal_Bool bAdded = sal_False;
SvXMLAutoStylePoolPropertiesP_Impl *pProperties = 0; SvXMLAutoStylePoolPropertiesP_Impl *pProperties = 0;
...@@ -75,7 +75,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl* pFamilyData, c ...@@ -75,7 +75,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl* pFamilyData, c
{ {
break; break;
} }
else if( !bDontSeek && pFamilyData->mxMapper->Equals( pIS->GetProperties(), rProperties ) ) else if( !bDontSeek && rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) )
{ {
pProperties = pIS; pProperties = pIS;
break; break;
...@@ -84,7 +84,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl* pFamilyData, c ...@@ -84,7 +84,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl* pFamilyData, c
if( !pProperties ) if( !pProperties )
{ {
pProperties = new SvXMLAutoStylePoolPropertiesP_Impl( pFamilyData, rProperties ); pProperties = new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties );
SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin(); SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin();
::std::advance( it, i ); ::std::advance( it, i );
maPropertiesList.insert( it, pProperties ); maPropertiesList.insert( it, pProperties );
...@@ -103,7 +103,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl* pFamilyData, c ...@@ -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). // 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; sal_Bool bAdded = sal_False;
size_t i = 0; size_t i = 0;
...@@ -123,10 +123,10 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl* pFamilyDa ...@@ -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 = SvXMLAutoStylePoolPropertiesP_Impl* pProperties =
new SvXMLAutoStylePoolPropertiesP_Impl( pFamilyData, rProperties ); new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties );
// ignore the generated name // ignore the generated name
pProperties->SetName( rName ); pProperties->SetName( rName );
SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin(); SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin();
...@@ -143,7 +143,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl* pFamilyDa ...@@ -143,7 +143,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl* pFamilyDa
// Search for a array of XMLPropertyState ( vector< XMLPropertyState > ) in list // 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; OUString sName;
vector< XMLPropertyState>::size_type nItems = rProperties.size(); vector< XMLPropertyState>::size_type nItems = rProperties.size();
...@@ -159,7 +159,7 @@ OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl* pFamily ...@@ -159,7 +159,7 @@ OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl* pFamily
{ {
break; break;
} }
else if( pFamilyData->mxMapper->Equals( pIS->GetProperties(), rProperties ) ) else if( rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) )
{ {
sName = pIS->GetName(); sName = pIS->GetName();
break; break;
......
...@@ -56,20 +56,12 @@ using namespace ::xmloff::token; ...@@ -56,20 +56,12 @@ using namespace ::xmloff::token;
// //
SvXMLAutoStylePoolP_Impl::SvXMLAutoStylePoolP_Impl( SvXMLExport& rExp) SvXMLAutoStylePoolP_Impl::SvXMLAutoStylePoolP_Impl( SvXMLExport& rExp)
: rExport( rExp ), : rExport( rExp )
maFamilyList( 5, 5 )
{ {
} }
SvXMLAutoStylePoolP_Impl::~SvXMLAutoStylePoolP_Impl() 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( ...@@ -85,8 +77,6 @@ void SvXMLAutoStylePoolP_Impl::AddFamily(
sal_Bool bAsFamily ) sal_Bool bAsFamily )
{ {
// store family in a list if not already stored // store family in a list if not already stored
sal_uLong nPos;
sal_uInt16 nExportFlags = GetExport().getExportFlags(); sal_uInt16 nExportFlags = GetExport().getExportFlags();
sal_Bool bStylesOnly = (nExportFlags & EXPORT_STYLES) != 0 && (nExportFlags & EXPORT_CONTENT) == 0; sal_Bool bStylesOnly = (nExportFlags & EXPORT_STYLES) != 0 && (nExportFlags & EXPORT_CONTENT) == 0;
...@@ -98,10 +88,7 @@ void SvXMLAutoStylePoolP_Impl::AddFamily( ...@@ -98,10 +88,7 @@ void SvXMLAutoStylePoolP_Impl::AddFamily(
} }
XMLFamilyData_Impl *pFamily = new XMLFamilyData_Impl( nFamily, rStrName, rMapper, aPrefix, bAsFamily ); XMLFamilyData_Impl *pFamily = new XMLFamilyData_Impl( nFamily, rStrName, rMapper, aPrefix, bAsFamily );
if( !maFamilyList.Seek_Entry( pFamily, &nPos ) ) maFamilyList.insert(pFamily);
maFamilyList.Insert( pFamily );
else
delete pFamily;
} }
void SvXMLAutoStylePoolP_Impl::SetFamilyPropSetMapper( void SvXMLAutoStylePoolP_Impl::SetFamilyPropSetMapper(
...@@ -110,14 +97,9 @@ void SvXMLAutoStylePoolP_Impl::SetFamilyPropSetMapper( ...@@ -110,14 +97,9 @@ void SvXMLAutoStylePoolP_Impl::SetFamilyPropSetMapper(
{ {
XMLFamilyData_Impl aTemporary( nFamily ); XMLFamilyData_Impl aTemporary( nFamily );
sal_uLong nPos; XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTemporary);
if (aFind != maFamilyList.end())
if( maFamilyList.Seek_Entry( &aTemporary, &nPos ) ) aFind->mxMapper = rMapper;
{
XMLFamilyData_Impl* pFamily = maFamilyList.GetObject( nPos );
if ( pFamily )
pFamily-> mxMapper = rMapper;
}
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
...@@ -126,17 +108,12 @@ void SvXMLAutoStylePoolP_Impl::SetFamilyPropSetMapper( ...@@ -126,17 +108,12 @@ void SvXMLAutoStylePoolP_Impl::SetFamilyPropSetMapper(
void SvXMLAutoStylePoolP_Impl::RegisterName( sal_Int32 nFamily, const OUString& rName ) void SvXMLAutoStylePoolP_Impl::RegisterName( sal_Int32 nFamily, const OUString& rName )
{ {
SvXMLAutoStylePoolNamesP_Impl *pNames = 0;
sal_uLong nPos;
XMLFamilyData_Impl aTmp( nFamily ); XMLFamilyData_Impl aTmp( nFamily );
if( maFamilyList.Seek_Entry( &aTmp, &nPos ) ) XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTmp);
pNames = maFamilyList.GetObject( nPos )->mpNameList; DBG_ASSERT( aFind != maFamilyList.end(),
DBG_ASSERT( pNames,
"SvXMLAutoStylePool_Impl::RegisterName: unknown family" ); "SvXMLAutoStylePool_Impl::RegisterName: unknown family" );
if( pNames ) if (aFind != maFamilyList.end())
pNames->insert(rName); aFind->mpNameList->insert(rName);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -153,18 +130,17 @@ void SvXMLAutoStylePoolP_Impl::GetRegisteredNames( ...@@ -153,18 +130,17 @@ void SvXMLAutoStylePoolP_Impl::GetRegisteredNames(
vector<OUString> aNames; vector<OUString> aNames;
// iterate over families // iterate over families
sal_uInt32 nCount = maFamilyList.Count(); for(XMLFamilyDataList_Impl::iterator aJ = maFamilyList.begin(); aJ != maFamilyList.end(); ++aJ)
for( sal_uInt32 i = 0; i < nCount; i++ )
{ {
XMLFamilyData_Impl* pFamily = maFamilyList.GetObject( i ); XMLFamilyData_Impl &rFamily = *aJ;
// iterate over names // iterate over names
SvXMLAutoStylePoolNamesP_Impl* pNames = pFamily->mpNameList; SvXMLAutoStylePoolNamesP_Impl* pNames = rFamily.mpNameList;
if (!pNames) if (!pNames)
continue; continue;
for (SvXMLAutoStylePoolNamesP_Impl::const_iterator aI = pNames->begin(); aI != pNames->end(); ++aI) 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 ); aNames.push_back( *aI );
} }
} }
...@@ -192,22 +168,20 @@ sal_Bool SvXMLAutoStylePoolP_Impl::Add(OUString& rName, sal_Int32 nFamily, ...@@ -192,22 +168,20 @@ sal_Bool SvXMLAutoStylePoolP_Impl::Add(OUString& rName, sal_Int32 nFamily,
bool bDontSeek ) bool bDontSeek )
{ {
sal_Bool bRet(sal_False); sal_Bool bRet(sal_False);
sal_uLong nPos;
XMLFamilyData_Impl *pFamily = 0;
XMLFamilyData_Impl aTemporary( nFamily ); XMLFamilyData_Impl aTemporary( nFamily );
if( maFamilyList.Seek_Entry( &aTemporary, &nPos ) ) XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTemporary);
{ DBG_ASSERT(aFind != maFamilyList.end(), "SvXMLAutoStylePool_Impl::Add: unknown family");
pFamily = maFamilyList.GetObject( nPos );
}
DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Add: unknown family" ); if (aFind != maFamilyList.end())
if( pFamily )
{ {
XMLFamilyData_Impl &rFamily = *aFind;
SvXMLAutoStylePoolParentP_Impl aTmp( rParent ); SvXMLAutoStylePoolParentP_Impl aTmp( rParent );
SvXMLAutoStylePoolParentP_Impl *pParent = 0; SvXMLAutoStylePoolParentP_Impl *pParent = 0;
SvXMLAutoStylePoolParentsP_Impl *pParents = pFamily->mpParentList; SvXMLAutoStylePoolParentsP_Impl *pParents = rFamily.mpParentList;
sal_uLong nPos;
if( pParents->Seek_Entry( &aTmp, &nPos ) ) if( pParents->Seek_Entry( &aTmp, &nPos ) )
{ {
pParent = pParents->GetObject( nPos ); pParent = pParents->GetObject( nPos );
...@@ -218,18 +192,18 @@ sal_Bool SvXMLAutoStylePoolP_Impl::Add(OUString& rName, sal_Int32 nFamily, ...@@ -218,18 +192,18 @@ sal_Bool SvXMLAutoStylePoolP_Impl::Add(OUString& rName, sal_Int32 nFamily,
pParents->Insert( pParent ); pParents->Insert( pParent );
} }
if( pParent->Add( pFamily, rProperties, rName, bDontSeek ) ) if( pParent->Add( rFamily, rProperties, rName, bDontSeek ) )
{ {
pFamily->mnCount++; rFamily.mnCount++;
bRet = sal_True; bRet = sal_True;
} }
if( bCache ) if( bCache )
{ {
if( !pFamily->pCache ) if( !rFamily.pCache )
pFamily->pCache = new SvXMLAutoStylePoolCache_Impl(); rFamily.pCache = new SvXMLAutoStylePoolCache_Impl();
if( pFamily->pCache->size() < MAX_CACHE_SIZE ) if( rFamily.pCache->size() < MAX_CACHE_SIZE )
pFamily->pCache->push_back( new OUString( rName ) ); rFamily.pCache->push_back( new OUString( rName ) );
} }
} }
...@@ -241,22 +215,20 @@ sal_Bool SvXMLAutoStylePoolP_Impl::AddNamed(const OUString& rName, sal_Int32 nFa ...@@ -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() // get family and parent the same way as in Add()
sal_Bool bRet(sal_False); sal_Bool bRet(sal_False);
sal_uLong nPos;
XMLFamilyData_Impl *pFamily = 0;
XMLFamilyData_Impl aTemporary( nFamily ); XMLFamilyData_Impl aTemporary( nFamily );
if( maFamilyList.Seek_Entry( &aTemporary, &nPos ) ) XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTemporary);
{ DBG_ASSERT(aFind != maFamilyList.end(), "SvXMLAutoStylePool_Impl::Add: unknown family");
pFamily = maFamilyList.GetObject( nPos );
}
DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Add: unknown family" ); if (aFind != maFamilyList.end())
if( pFamily )
{ {
XMLFamilyData_Impl &rFamily = *aFind;
SvXMLAutoStylePoolParentP_Impl aTmp( rParent ); SvXMLAutoStylePoolParentP_Impl aTmp( rParent );
SvXMLAutoStylePoolParentP_Impl *pParent = 0; SvXMLAutoStylePoolParentP_Impl *pParent = 0;
SvXMLAutoStylePoolParentsP_Impl *pParents = pFamily->mpParentList; SvXMLAutoStylePoolParentsP_Impl *pParents = rFamily.mpParentList;
sal_uLong nPos;
if( pParents->Seek_Entry( &aTmp, &nPos ) ) if( pParents->Seek_Entry( &aTmp, &nPos ) )
{ {
pParent = pParents->GetObject( nPos ); pParent = pParents->GetObject( nPos );
...@@ -267,9 +239,9 @@ sal_Bool SvXMLAutoStylePoolP_Impl::AddNamed(const OUString& rName, sal_Int32 nFa ...@@ -267,9 +239,9 @@ sal_Bool SvXMLAutoStylePoolP_Impl::AddNamed(const OUString& rName, sal_Int32 nFa
pParents->Insert( pParent ); pParents->Insert( pParent );
} }
if( pParent->AddNamed( pFamily, rProperties, rName ) ) if( pParent->AddNamed( rFamily, rProperties, rName ) )
{ {
pFamily->mnCount++; rFamily.mnCount++;
bRet = sal_True; bRet = sal_True;
} }
} }
...@@ -288,24 +260,20 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily, ...@@ -288,24 +260,20 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily,
{ {
OUString sName; OUString sName;
sal_uLong nPos;
XMLFamilyData_Impl aTemporary( nFamily ); XMLFamilyData_Impl aTemporary( nFamily );
XMLFamilyData_Impl *pFamily = 0; XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTemporary);
if( maFamilyList.Seek_Entry( &aTemporary, &nPos ) ) DBG_ASSERT(aFind != maFamilyList.end(), "SvXMLAutoStylePool_Impl::Find: unknown family");
{
pFamily = maFamilyList.GetObject( nPos );
}
DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Find: unknown family" ); if (aFind != maFamilyList.end())
if( pFamily )
{ {
SvXMLAutoStylePoolParentP_Impl aTmp( rParent ); XMLFamilyData_Impl &rFamily = *aFind;
const SvXMLAutoStylePoolParentsP_Impl* pParents = const SvXMLAutoStylePoolParentsP_Impl* pParents =
pFamily->mpParentList; rFamily.mpParentList;
SvXMLAutoStylePoolParentP_Impl aTmp( rParent );
sal_uLong nPos;
if( pParents->Seek_Entry( &aTmp, &nPos ) ) if( pParents->Seek_Entry( &aTmp, &nPos ) )
sName = pParents->GetObject( nPos )->Find( pFamily, rProperties ); sName = pParents->GetObject( nPos )->Find( rFamily, rProperties );
} }
return sName; return sName;
...@@ -323,156 +291,153 @@ void SvXMLAutoStylePoolP_Impl::exportXML( ...@@ -323,156 +291,153 @@ void SvXMLAutoStylePoolP_Impl::exportXML(
const SvXMLNamespaceMap&, const SvXMLNamespaceMap&,
const SvXMLAutoStylePoolP *pAntiImpl) const const SvXMLAutoStylePoolP *pAntiImpl) const
{ {
sal_uInt32 nCount = 0;
// Get list of parents for current family (nFamily) // Get list of parents for current family (nFamily)
sal_uLong nPos;
XMLFamilyData_Impl aTmp( nFamily ); XMLFamilyData_Impl aTmp( nFamily );
XMLFamilyData_Impl *pFamily = 0; XMLFamilyDataList_Impl::iterator aFind = maFamilyList.find(aTmp);
if( maFamilyList.Seek_Entry( &aTmp, &nPos ) ) 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 ); aExpStyles[i].mpParent = 0;
nCount = pFamily->mnCount; aExpStyles[i].mpProperties = 0;
} }
DBG_ASSERT( pFamily, sal_uInt32 nParents = pParents->Count();
"SvXMLAutoStylePool_Impl::exportXML: unknown family" ); for( i=0; i < nParents; i++ )
if( pFamily && nCount > 0 )
{ {
///////////////////////////////////////////////////////////////////////////////////// const SvXMLAutoStylePoolParentP_Impl* pParent =
// create, initialize and fill helper-structure (SvXMLAutoStylePoolProperties_Impl) pParents->GetObject( i );
// wich contains a parent-name and a SvXMLAutoStylePoolProperties_Impl size_t nProperties = pParent->GetPropertiesList().size();
// for( size_t j = 0; j < nProperties; j++ )
const SvXMLAutoStylePoolParentsP_Impl *pParents =
pFamily->mpParentList;
SvXMLAutoStylePoolPExport_Impl* aExpStyles =
new SvXMLAutoStylePoolPExport_Impl[nCount];
sal_uInt32 i;
for( i=0; i < nCount; i++ )
{ {
aExpStyles[i].mpParent = 0; const SvXMLAutoStylePoolPropertiesP_Impl* pProperties =
aExpStyles[i].mpProperties = 0; pParent->GetPropertiesList()[ j ];
} sal_uLong nPos = pProperties->GetPos();
DBG_ASSERT( nPos < nCount,
sal_uInt32 nParents = pParents->Count(); "SvXMLAutoStylePool_Impl::exportXML: wrong position" );
for( i=0; i < nParents; i++ ) if( nPos < nCount )
{
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 = DBG_ASSERT( !aExpStyles[nPos].mpProperties,
pParent->GetPropertiesList()[ j ]; "SvXMLAutoStylePool_Impl::exportXML: double position" );
nPos = pProperties->GetPos(); aExpStyles[nPos].mpProperties = pProperties;
DBG_ASSERT( nPos < nCount, aExpStyles[nPos].mpParent = &pParent->GetParent();
"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();
}
} }
} }
}
/////////////////////////////////////////////////////////////////////////////////////
//
// create string to export for each XML-style. That means for each property-list
//
OUString aStrFamilyName = rFamily.maStrFamilyName;
///////////////////////////////////////////////////////////////////////////////////// for( i=0; i<nCount; i++ )
// {
// create string to export for each XML-style. That means for each property-list DBG_ASSERT( aExpStyles[i].mpProperties,
// "SvXMLAutoStylePool_Impl::exportXML: empty position" );
OUString aStrFamilyName = pFamily->maStrFamilyName;
for( i=0; i<nCount; i++ ) if( aExpStyles[i].mpProperties )
{ {
DBG_ASSERT( aExpStyles[i].mpProperties, GetExport().AddAttribute(
"SvXMLAutoStylePool_Impl::exportXML: empty position" ); XML_NAMESPACE_STYLE, XML_NAME,
aExpStyles[i].mpProperties->GetName() );
if( aExpStyles[i].mpProperties ) if( rFamily.bAsFamily )
{ {
GetExport().AddAttribute( GetExport().AddAttribute(
XML_NAMESPACE_STYLE, XML_NAME, XML_NAMESPACE_STYLE, XML_FAMILY, aStrFamilyName );
aExpStyles[i].mpProperties->GetName() ); }
if( pFamily->bAsFamily ) if( !aExpStyles[i].mpParent->isEmpty() )
{ {
GetExport().AddAttribute( GetExport().AddAttribute(
XML_NAMESPACE_STYLE, XML_FAMILY, aStrFamilyName ); XML_NAMESPACE_STYLE, XML_PARENT_STYLE_NAME,
} GetExport().EncodeStyleName(
*aExpStyles[i].mpParent ) );
}
if( !aExpStyles[i].mpParent->isEmpty() ) OUString sName;
{ if( rFamily.bAsFamily )
GetExport().AddAttribute( sName = GetXMLToken(XML_STYLE);
XML_NAMESPACE_STYLE, XML_PARENT_STYLE_NAME, else
GetExport().EncodeStyleName( sName = rFamily.maStrFamilyName;
*aExpStyles[i].mpParent ) );
} 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; sal_Int32 nStart(-1);
if( pFamily->bAsFamily ) sal_Int32 nEnd(-1);
sName = GetXMLToken(XML_STYLE); if (nFamily == XML_STYLE_FAMILY_PAGE_MASTER)
else {
sName = pFamily->maStrFamilyName; nStart = 0;
sal_Int32 nIndex = 0;
pAntiImpl->exportStyleAttributes( UniReference< XMLPropertySetMapper > aPropMapper =
GetExport().GetAttrList(), rFamily.mxMapper->getPropertySetMapper();
nFamily, sal_Int16 nContextID;
aExpStyles[i].mpProperties->GetProperties(), while(nIndex < aPropMapper->GetEntryCount() && nEnd == -1)
*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)
{ {
nStart = 0; nContextID = aPropMapper->GetEntryContextId( nIndex );
sal_Int32 nIndex = 0; if (nContextID && ((nContextID & CTF_PM_FLAGMASK) != XML_PM_CTF_START))
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)
nEnd = nIndex; nEnd = nIndex;
nIndex++;
} }
if (nEnd == -1)
pFamily->mxMapper->exportXML( nEnd = nIndex;
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()
);
} }
}
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() void SvXMLAutoStylePoolP_Impl::ClearEntries()
{ {
for(sal_uInt32 a = 0L; a < maFamilyList.Count(); a++) for(XMLFamilyDataList_Impl::iterator aI = maFamilyList.begin(); aI != maFamilyList.end(); ++aI)
maFamilyList[a]->ClearEntries(); aI->ClearEntries();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#ifndef _XMLOFF_XMLASTPL_IMPL_HXX #ifndef _XMLOFF_XMLASTPL_IMPL_HXX
#define _XMLOFF_XMLASTPL_IMPL_HXX #define _XMLOFF_XMLASTPL_IMPL_HXX
#include <boost/ptr_container/ptr_set.hpp>
#include <sal/types.h> #include <sal/types.h>
#include <svl/cntnrsrt.hxx> #include <svl/cntnrsrt.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
...@@ -84,12 +85,12 @@ public: ...@@ -84,12 +85,12 @@ public:
{} {}
~XMLFamilyData_Impl(); ~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(); void ClearEntries();
}; };
DECLARE_CONTAINER_SORT( XMLFamilyDataList_Impl, XMLFamilyData_Impl ) typedef boost::ptr_set<XMLFamilyData_Impl> XMLFamilyDataList_Impl;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
...@@ -104,7 +105,7 @@ class SvXMLAutoStylePoolPropertiesP_Impl ...@@ -104,7 +105,7 @@ class SvXMLAutoStylePoolPropertiesP_Impl
public: public:
SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties ); SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties );
~SvXMLAutoStylePoolPropertiesP_Impl() ~SvXMLAutoStylePoolPropertiesP_Impl()
{ {
...@@ -139,11 +140,11 @@ public: ...@@ -139,11 +140,11 @@ public:
~SvXMLAutoStylePoolParentP_Impl(); ~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; } const ::rtl::OUString& GetParent() const { return msParent; }
......
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