Kaydet (Commit) 6cc45bb7 authored tarafından Michael Brauer's avatar Michael Brauer

Auto style pool cache

üst 6e66b2fc
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: impastp1.cxx,v $ * $RCSfile: impastp1.cxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: mib $ $Date: 2000-11-07 13:33:06 $ * last change: $Author: mib $ $Date: 2000-11-20 10:15:09 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -59,6 +59,9 @@ ...@@ -59,6 +59,9 @@
* *
************************************************************************/ ************************************************************************/
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _XMLOFF_XMLASTPL_IMPL_HXX #ifndef _XMLOFF_XMLASTPL_IMPL_HXX
#include "impastpl.hxx" #include "impastpl.hxx"
#endif #endif
...@@ -82,7 +85,8 @@ XMLFamilyData_Impl::XMLFamilyData_Impl( ...@@ -82,7 +85,8 @@ XMLFamilyData_Impl::XMLFamilyData_Impl(
const OUString& rStrPrefix, const OUString& rStrPrefix,
sal_Bool bAsFam ) sal_Bool bAsFam )
: mnFamily( nFamily ), maStrFamilyName( rStrName), mxMapper( rMapper ), maStrPrefix( rStrPrefix ), : mnFamily( nFamily ), maStrFamilyName( rStrName), mxMapper( rMapper ), maStrPrefix( rStrPrefix ),
mnCount( 0 ), mnName( 0 ), bAsFamily( bAsFam ) mnCount( 0 ), mnName( 0 ), bAsFamily( bAsFam ),
pCache( 0 )
{ {
mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 ); mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 );
mpNameList = new SvXMLAutoStylePoolNamesP_Impl( 5, 5 ); mpNameList = new SvXMLAutoStylePoolNamesP_Impl( 5, 5 );
...@@ -92,6 +96,13 @@ XMLFamilyData_Impl::~XMLFamilyData_Impl() ...@@ -92,6 +96,13 @@ XMLFamilyData_Impl::~XMLFamilyData_Impl()
{ {
if( mpParentList ) delete mpParentList; if( mpParentList ) delete mpParentList;
if( mpNameList ) delete mpNameList; if( mpNameList ) delete mpNameList;
DBG_ASSERT( !pCache || !pCache->Count(),
"auto style pool cache is not empty!" );
if( pCache )
{
while( pCache->Count() )
delete pCache->Remove( 0UL );
}
} }
void XMLFamilyData_Impl::ClearEntries() void XMLFamilyData_Impl::ClearEntries()
...@@ -99,6 +110,13 @@ void XMLFamilyData_Impl::ClearEntries() ...@@ -99,6 +110,13 @@ void XMLFamilyData_Impl::ClearEntries()
if( mpParentList ) if( mpParentList )
delete mpParentList; delete mpParentList;
mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 ); mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 );
DBG_ASSERT( !pCache || !pCache->Count(),
"auto style pool cache is not empty!" );
if( pCache )
{
while( pCache->Count() )
delete pCache->Remove( 0UL );
}
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: impastp4.cxx,v $ * $RCSfile: impastp4.cxx,v $
* *
* $Revision: 1.5 $ * $Revision: 1.6 $
* *
* last change: $Author: mib $ $Date: 2000-11-07 13:33:06 $ * last change: $Author: mib $ $Date: 2000-11-20 10:15:09 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -174,7 +174,8 @@ void SvXMLAutoStylePoolP_Impl::RegisterName( sal_Int32 nFamily, const OUString& ...@@ -174,7 +174,8 @@ void SvXMLAutoStylePoolP_Impl::RegisterName( sal_Int32 nFamily, const OUString&
OUString SvXMLAutoStylePoolP_Impl::Add( sal_Int32 nFamily, OUString SvXMLAutoStylePoolP_Impl::Add( sal_Int32 nFamily,
const OUString& rParent, const OUString& rParent,
const vector< XMLPropertyState >& rProperties ) const vector< XMLPropertyState >& rProperties,
sal_Bool bCache )
{ {
OUString sName; OUString sName;
sal_uInt32 nPos; sal_uInt32 nPos;
...@@ -205,11 +206,44 @@ OUString SvXMLAutoStylePoolP_Impl::Add( sal_Int32 nFamily, ...@@ -205,11 +206,44 @@ OUString SvXMLAutoStylePoolP_Impl::Add( sal_Int32 nFamily,
if( pParent->Add( pFamily, rProperties, sName ) ) if( pParent->Add( pFamily, rProperties, sName ) )
pFamily->mnCount++; pFamily->mnCount++;
if( bCache )
{
if( !pFamily->pCache )
pFamily->pCache = new SvXMLAutoStylePoolCache_Impl( 256, 256 );
if( pFamily->pCache->Count() < MAX_CACHE_SIZE )
pFamily->pCache->Insert( new OUString( sName ),
pFamily->pCache->Count() );
}
} }
return sName; return sName;
} }
OUString SvXMLAutoStylePoolP_Impl::AddToCache( sal_Int32 nFamily,
const OUString& rParent )
{
sal_uInt32 nPos;
XMLFamilyData_Impl *pFamily = 0;
XMLFamilyData_Impl aTmp( nFamily );
if( maFamilyList.Seek_Entry( &aTmp, &nPos ) )
{
pFamily = maFamilyList.GetObject( nPos );
}
DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Add: unknown family" );
if( pFamily )
{
if( !pFamily->pCache )
pFamily->pCache = new SvXMLAutoStylePoolCache_Impl( 256, 256 );
if( pFamily->pCache->Count() < MAX_CACHE_SIZE )
pFamily->pCache->Insert( new OUString( rParent ),
pFamily->pCache->Count() );
}
return rParent;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Search for a array of XMLPropertyState ( vector< XMLPropertyState > ) in list // Search for a array of XMLPropertyState ( vector< XMLPropertyState > ) in list
...@@ -244,6 +278,37 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily, ...@@ -244,6 +278,37 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily,
return sName; return sName;
} }
OUString SvXMLAutoStylePoolP_Impl::FindAndRemoveCached( sal_Int32 nFamily ) const
{
OUString sName;
sal_uInt32 nPos;
XMLFamilyData_Impl aTmp( nFamily );
XMLFamilyData_Impl *pFamily = 0;
if( maFamilyList.Seek_Entry( &aTmp, &nPos ) )
{
pFamily = maFamilyList.GetObject( nPos );
}
DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Find: unknown family" );
if( pFamily )
{
DBG_ASSERT( pFamily->pCache, "family doesn't have a cache" );
// The cache may be empty already. This happens if it was filled
// completly.
if( pFamily->pCache && pFamily->pCache->Count() )
{
OUString *pName = pFamily->pCache->Remove( 0UL );
sName = *pName;
delete pName;
}
}
return sName;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// export // export
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: impastpl.hxx,v $ * $RCSfile: impastpl.hxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: mib $ $Date: 2000-11-07 13:33:06 $ * last change: $Author: mib $ $Date: 2000-11-20 10:15:09 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -97,14 +97,20 @@ class SvXMLAutoStylePoolNamesP_Impl; ...@@ -97,14 +97,20 @@ class SvXMLAutoStylePoolNamesP_Impl;
class SvXMLAttributeList; class SvXMLAttributeList;
class SvXMLExportPropertyMapper; class SvXMLExportPropertyMapper;
#define MAX_CACHE_SIZE 65536
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// Implementationclass for stylefamily-information // Implementationclass for stylefamily-information
// //
typedef ::rtl::OUString *OUStringPtr;
DECLARE_LIST( SvXMLAutoStylePoolCache_Impl, OUStringPtr )
class XMLFamilyData_Impl class XMLFamilyData_Impl
{ {
public: public:
SvXMLAutoStylePoolCache_Impl *pCache;
sal_uInt32 mnFamily; sal_uInt32 mnFamily;
::rtl::OUString maStrFamilyName; ::rtl::OUString maStrFamilyName;
UniReference < SvXMLExportPropertyMapper > mxMapper; UniReference < SvXMLExportPropertyMapper > mxMapper;
...@@ -120,9 +126,11 @@ public: ...@@ -120,9 +126,11 @@ public:
XMLFamilyData_Impl( sal_Int32 nFamily, const ::rtl::OUString& rStrName, XMLFamilyData_Impl( sal_Int32 nFamily, const ::rtl::OUString& rStrName,
const UniReference < SvXMLExportPropertyMapper > & rMapper, const UniReference < SvXMLExportPropertyMapper > & rMapper,
const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True ); const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True );
XMLFamilyData_Impl( sal_Int32 nFamily )
: mnFamily( nFamily ), mpParentList( NULL ), XMLFamilyData_Impl( sal_Int32 nFamily ) :
mpNameList( NULL ), mnCount( 0 ), mnName( 0 ) mnFamily( nFamily ), mpParentList( NULL ),
mpNameList( NULL ), mnCount( 0 ), mnName( 0 ),
pCache( 0 )
{} {}
~XMLFamilyData_Impl(); ~XMLFamilyData_Impl();
...@@ -227,10 +235,15 @@ public: ...@@ -227,10 +235,15 @@ public:
void RegisterName( sal_Int32 nFamily, const ::rtl::OUString& rName ); void RegisterName( sal_Int32 nFamily, const ::rtl::OUString& rName );
::rtl::OUString Add( sal_Int32 nFamily, const ::rtl::OUString& rParent, ::rtl::OUString Add( sal_Int32 nFamily, const ::rtl::OUString& rParent,
const ::std::vector< XMLPropertyState >& rProperties ); const ::std::vector< XMLPropertyState >& rProperties,
sal_Bool bCache = sal_False );
::rtl::OUString AddToCache( sal_Int32 nFamily,
const ::rtl::OUString& rParent );
::rtl::OUString Find( sal_Int32 nFamily, const ::rtl::OUString& rParent, ::rtl::OUString Find( sal_Int32 nFamily, const ::rtl::OUString& rParent,
const ::std::vector< XMLPropertyState >& rProperties ) const; const ::std::vector< XMLPropertyState >& rProperties ) const;
::rtl::OUString FindAndRemoveCached( sal_Int32 nFamily ) const;
void exportXML( sal_Int32 nFamily, void exportXML( sal_Int32 nFamily,
const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
const SvXMLUnitConverter& rUnitConverter, const SvXMLUnitConverter& rUnitConverter,
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: xmlaustp.cxx,v $ * $RCSfile: xmlaustp.cxx,v $
* *
* $Revision: 1.7 $ * $Revision: 1.8 $
* *
* last change: $Author: mib $ $Date: 2000-11-07 13:33:06 $ * last change: $Author: mib $ $Date: 2000-11-20 10:15:09 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -275,6 +275,26 @@ OUString SvXMLAutoStylePoolP::Add( sal_Int32 nFamily, ...@@ -275,6 +275,26 @@ OUString SvXMLAutoStylePoolP::Add( sal_Int32 nFamily,
return pImpl->Add( nFamily, rParent, rProperties ); return pImpl->Add( nFamily, rParent, rProperties );
} }
OUString SvXMLAutoStylePoolP::AddAndCache( sal_Int32 nFamily,
const vector< XMLPropertyState >& rProperties )
{
OUString sEmpty;
return pImpl->Add( nFamily, sEmpty, rProperties, sal_True );
}
OUString SvXMLAutoStylePoolP::AddAndCache( sal_Int32 nFamily,
const OUString& rParent,
const vector< XMLPropertyState >& rProperties )
{
return pImpl->Add( nFamily, rParent, rProperties, sal_True );
}
OUString SvXMLAutoStylePoolP::AddAndCache( sal_Int32 nFamily,
const OUString& rParent )
{
return pImpl->AddToCache( nFamily, rParent );
}
OUString SvXMLAutoStylePoolP::Find( sal_Int32 nFamily, OUString SvXMLAutoStylePoolP::Find( sal_Int32 nFamily,
const vector< XMLPropertyState >& rProperties ) const const vector< XMLPropertyState >& rProperties ) const
{ {
...@@ -289,6 +309,12 @@ OUString SvXMLAutoStylePoolP::Find( sal_Int32 nFamily, ...@@ -289,6 +309,12 @@ OUString SvXMLAutoStylePoolP::Find( sal_Int32 nFamily,
return pImpl->Find( nFamily, rParent, rProperties ); return pImpl->Find( nFamily, rParent, rProperties );
} }
OUString SvXMLAutoStylePoolP::FindAndRemoveCached( sal_Int32 nFamily ) const
{
return pImpl->FindAndRemoveCached( nFamily );
}
void SvXMLAutoStylePoolP::exportXML( sal_Int32 nFamily, void SvXMLAutoStylePoolP::exportXML( sal_Int32 nFamily,
const uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler, const uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
const SvXMLUnitConverter& rUnitConverter, const SvXMLUnitConverter& rUnitConverter,
......
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