summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Powers <jpowers27@cox.net>2010-12-18 19:07:15 -0800
committerJoseph Powers <jpowers27@cox.net>2010-12-18 19:07:15 -0800
commit4d456fcb7a0070c101fb3d2247417c9cfead26eb (patch)
treea3273b51d3039f3e62fc17a931792627f4f32fc1
parentb2447c13296d919caff594fde5e9bd4f8ee4fb87 (diff)
Remove DECLARE_LIST( SwXMLTableLinesCache_Impl, SwXMLTableLinesPtr )
The list is only used in SwXMLExport. ExportTableLinesAutoStyles() adds entries; while ExportTableLines(). It might be posiable to destroy the object with ot deleting the entries; so, I added a call to the destructor to make sure pTableLines is clean before leaving.
-rw-r--r--sw/source/filter/xml/xmlexp.cxx1
-rw-r--r--sw/source/filter/xml/xmlexp.hxx15
-rw-r--r--sw/source/filter/xml/xmltble.cxx45
3 files changed, 37 insertions, 24 deletions
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 74d8cf5920ac..c6265887b42e 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -437,6 +437,7 @@ XMLShapeExport* SwXMLExport::CreateShapeExport()
SwXMLExport::~SwXMLExport()
{
+ DeleteTableLines();
_FinitItemExport();
}
diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx
index 7b081378236a..66e1efef3d23 100644
--- a/sw/source/filter/xml/xmlexp.hxx
+++ b/sw/source/filter/xml/xmlexp.hxx
@@ -33,6 +33,7 @@
#include "xmlitmap.hxx"
#include <xmloff/uniref.hxx>
#include <xmloff/xmltoken.hxx>
+#include <vector>
class SwPaM;
class SwFmt;
@@ -45,12 +46,14 @@ class SwTableLines;
class SwTableBox;
class SwXMLTableColumn_Impl;
class SwXMLTableLines_Impl;
-class SwXMLTableLinesCache_Impl;
class SwXMLTableColumnsSortByWidth_Impl;
class SwXMLTableFrmFmtsSort_Impl;
class SwXMLTableInfo_Impl;
class SwTableNode;
class XMLPropertySetMapper;
+class SwXMLTableLines_Impl;
+
+typedef ::std::vector< SwXMLTableLines_Impl* > SwXMLTableLinesCache_Impl;
class SwXMLExport : public SvXMLExport
{
@@ -61,10 +64,9 @@ class SwXMLExport : public SvXMLExport
SwPaM *pOrigPaM; // the original PaM
#endif
- SvXMLUnitConverter *pTwipUnitConv;
-
- SvXMLExportItemMapper *pTableItemMapper;
- SwXMLTableLinesCache_Impl *pTableLines;
+ SvXMLUnitConverter* pTwipUnitConv;
+ SvXMLExportItemMapper* pTableItemMapper;
+ SwXMLTableLinesCache_Impl* pTableLines;
SvXMLItemMapEntriesRef xTableItemMap;
SvXMLItemMapEntriesRef xTableRowItemMap;
@@ -124,7 +126,8 @@ class SwXMLExport : public SvXMLExport
const ::rtl::OUString sCell;
void setBlockMode();
-
+private:
+ void DeleteTableLines();
protected:
virtual XMLTextParagraphExport* CreateTextParagraphExport();
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index f54d466c7c80..162174d642c2 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -62,8 +62,6 @@
#include "xmltexte.hxx"
#include "xmlexp.hxx"
-#include <vector>
-
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
using namespace ::com::sun::star;
@@ -75,6 +73,7 @@ using namespace ::com::sun::star::container;
using namespace ::xmloff::token;
using table::XCell;
using ::std::vector;
+using ::std::advance;
class SwXMLTableColumn_Impl : public SwWriteTableCol
{
@@ -193,9 +192,6 @@ SwXMLTableLines_Impl::SwXMLTableLines_Impl( const SwTableLines& rLines ) :
}
}
-typedef SwXMLTableLines_Impl *SwXMLTableLinesPtr;
-DECLARE_LIST( SwXMLTableLinesCache_Impl, SwXMLTableLinesPtr )
-
// ---------------------------------------------------------------------
typedef vector< SwFrmFmt* > SwXMLFrmFmts_Impl;
@@ -586,11 +582,11 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines,
sal_Bool bTop )
{
// pass 1: calculate columns
- SwXMLTableLines_Impl *pLines =
- new SwXMLTableLines_Impl( rLines );
+ SwXMLTableLines_Impl *pLines = new SwXMLTableLines_Impl( rLines );
if( !pTableLines )
- pTableLines = new SwXMLTableLinesCache_Impl( 5, 5 );
- pTableLines->Insert( pLines, pTableLines->Count() );
+ pTableLines = new SwXMLTableLinesCache_Impl();
+
+ pTableLines->push_back( pLines );
OUStringBuffer sBuffer( rNamePrefix.getLength() + 8L );
@@ -1028,16 +1024,16 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
{
OSL_ENSURE( pTableLines && pTableLines->Count(),
"SwXMLExport::ExportTableLines: table columns infos missing" );
- if( !pTableLines || 0 == pTableLines->Count() )
+ if( !pTableLines || pTableLines->empty() )
return;
- SwXMLTableLines_Impl *pLines = 0;
- sal_uInt16 nInfoPos;
- for( nInfoPos=0; nInfoPos < pTableLines->Count(); nInfoPos++ )
+ SwXMLTableLines_Impl* pLines = NULL;
+ size_t nInfoPos;
+ for( nInfoPos=0; nInfoPos < pTableLines->size(); nInfoPos++ )
{
- if( pTableLines->GetObject( nInfoPos )->GetLines() == &rLines )
+ if( pTableLines->at( nInfoPos )->GetLines() == &rLines )
{
- pLines = pTableLines->GetObject( nInfoPos );
+ pLines = pTableLines->at( nInfoPos );
break;
}
}
@@ -1048,11 +1044,14 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
if( !pLines )
return;
- pTableLines->Remove( nInfoPos );
- if( 0 == pTableLines->Count() )
+ SwXMLTableLinesCache_Impl::iterator it = pTableLines->begin();
+ advance( it, nInfoPos );
+ pTableLines->erase( it );
+
+ if( pTableLines->empty() )
{
delete pTableLines ;
- pTableLines = 0;
+ pTableLines = NULL;
}
// pass 2: export columns
@@ -1246,5 +1245,15 @@ void SwXMLTextParagraphExport::exportTable(
((SwXMLExport&)GetExport()).SetShowProgress( bOldShowProgress );
}
+void SwXMLExport::DeleteTableLines()
+{
+ if ( pTableLines )
+ {
+ for ( size_t i = 0, n = pTableLines->size(); i < n; ++i )
+ delete pTableLines->at( i );
+ pTableLines->clear();
+ delete pTableLines;
+ }
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */