[Libreoffice-commits] .: sw/source

Joseph Powers jpowers at kemper.freedesktop.org
Sat Dec 18 19:34:04 PST 2010


 sw/source/filter/xml/xmlexp.cxx  |    3 +-
 sw/source/filter/xml/xmlexp.hxx  |   17 ++++++++------
 sw/source/filter/xml/xmltble.cxx |   45 +++++++++++++++++++++++----------------
 3 files changed, 39 insertions(+), 26 deletions(-)

New commits:
commit e7f4cc5fe2b4d610d6956dc86bd8683e183964d5
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Sat Dec 18 19:07:15 2010 -0800

    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.

diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 10ec2ae..82df5d4 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -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 e613d6d..9e248da 100644
--- a/sw/source/filter/xml/xmlexp.hxx
+++ b/sw/source/filter/xml/xmlexp.hxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -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 c2763f2..1e4cf6c 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: */


More information about the Libreoffice-commits mailing list