[Libreoffice-commits] .: 2 commits - cui/source

Caolán McNamara caolan at kemper.freedesktop.org
Mon Dec 12 08:34:42 PST 2011


 cui/source/dialogs/pastedlg.cxx |   26 ++++++++++++--------------
 cui/source/inc/pastedlg.hxx     |    4 ++--
 2 files changed, 14 insertions(+), 16 deletions(-)

New commits:
commit d6e21fd53cda06460f2c1611ef5d0744132d87bc
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Dec 12 16:32:34 2011 +0000

    now with an STL map we don't have to do our own mem allocation

diff --git a/cui/source/dialogs/pastedlg.cxx b/cui/source/dialogs/pastedlg.cxx
index 656a813..99cb187 100644
--- a/cui/source/dialogs/pastedlg.cxx
+++ b/cui/source/dialogs/pastedlg.cxx
@@ -112,11 +112,6 @@ void SvPasteObjectDialog::SetDefault()
 
 SvPasteObjectDialog::~SvPasteObjectDialog()
 {
-    ::std::map< SotFormatStringId, String* >::iterator it;
-    for(it = aSupplementMap.begin(); it != aSupplementMap.end(); ++it)
-    {
-        delete it->second;
-    }
 }
 
 /*************************************************************************
@@ -124,9 +119,7 @@ SvPasteObjectDialog::~SvPasteObjectDialog()
 *************************************************************************/
 void SvPasteObjectDialog::Insert( SotFormatStringId nFormat, const String& rFormatName )
 {
-    String * pStr = new String( rFormatName );
-    if( !aSupplementMap.insert( ::std::make_pair( nFormat, pStr ) ).second )
-        delete pStr;
+    aSupplementMap.insert( ::std::make_pair( nFormat, rFormatName ) );
 }
 
 sal_uLong SvPasteObjectDialog::GetFormat( const TransferableDataHelper& rHelper,
@@ -155,15 +148,15 @@ sal_uLong SvPasteObjectDialog::GetFormat( const TransferableDataHelper& rHelper,
         ::com::sun::star::datatransfer::DataFlavor aFlavor( *aIter );
         SotFormatStringId nFormat = (*aIter++).mnSotId;
 
-        String* pName = NULL;
-        String aName;
-        ::std::map< SotFormatStringId, String* >::iterator itName;
-        itName = aSupplementMap.find( nFormat );
+        ::std::map< SotFormatStringId, String >::iterator itName =
+            aSupplementMap.find( nFormat );
 
         // if there is an "Embed Source" or and "Embedded Object" on the
         // Clipboard we read the Description and the Source of this object
         // from an accompanied "Object Descriptor" format on the clipboard
         // Remember: these formats mostly appear together on the clipboard
+        String aName;
+        const String* pName = NULL;
         if ( itName == aSupplementMap.end() )
         {
             SvPasteObjectHelper::GetEmbeddedName(rHelper,aName,aSourceName,nFormat);
@@ -172,7 +165,7 @@ sal_uLong SvPasteObjectDialog::GetFormat( const TransferableDataHelper& rHelper,
         }
         else
         {
-            pName = itName->second;
+            pName = &(itName->second);
         }
 
         if( pName )
@@ -181,7 +174,8 @@ sal_uLong SvPasteObjectDialog::GetFormat( const TransferableDataHelper& rHelper,
 
             if( SOT_FORMATSTR_ID_EMBED_SOURCE == nFormat )
             {
-                if( aDesc.maClassName != aEmptyNm )                                {
+                if( aDesc.maClassName != aEmptyNm )
+                {
                     aSourceName = aDesc.maDisplayName;
 
                     if( aDesc.maClassName == aObjClassName )
diff --git a/cui/source/inc/pastedlg.hxx b/cui/source/inc/pastedlg.hxx
index ddf4ccb..21dee34 100644
--- a/cui/source/inc/pastedlg.hxx
+++ b/cui/source/inc/pastedlg.hxx
@@ -60,7 +60,7 @@ class SvPasteObjectDialog : public ModalDialog
     OKButton aOKButton1;
     CancelButton aCancelButton1;
     HelpButton aHelpButton1;
-    ::std::map< SotFormatStringId, String* > aSupplementMap;
+    ::std::map< SotFormatStringId, String > aSupplementMap;
     SvGlobalName    aObjClassName;
     String          aObjName;
     sal_uInt16          nAspect;
commit 57054f84f66c4d2db8d117a4043e0fbcbd0ee528
Author: Marcel Metz <mmetz at adrian-broher.net>
Date:   Mon Dec 12 16:25:22 2011 +0000

    Related: fdo#38832 Replace Table with std::map

diff --git a/cui/source/dialogs/pastedlg.cxx b/cui/source/dialogs/pastedlg.cxx
index 47fdf2f..656a813 100644
--- a/cui/source/dialogs/pastedlg.cxx
+++ b/cui/source/dialogs/pastedlg.cxx
@@ -112,11 +112,10 @@ void SvPasteObjectDialog::SetDefault()
 
 SvPasteObjectDialog::~SvPasteObjectDialog()
 {
-    void * pStr = aSupplementTable.First();
-    while( pStr )
+    ::std::map< SotFormatStringId, String* >::iterator it;
+    for(it = aSupplementMap.begin(); it != aSupplementMap.end(); ++it)
     {
-        delete (String *)pStr;
-        pStr = aSupplementTable.Next();
+        delete it->second;
     }
 }
 
@@ -126,7 +125,7 @@ SvPasteObjectDialog::~SvPasteObjectDialog()
 void SvPasteObjectDialog::Insert( SotFormatStringId nFormat, const String& rFormatName )
 {
     String * pStr = new String( rFormatName );
-    if( !aSupplementTable.Insert( nFormat, pStr ) )
+    if( !aSupplementMap.insert( ::std::make_pair( nFormat, pStr ) ).second )
         delete pStr;
 }
 
@@ -156,20 +155,25 @@ sal_uLong SvPasteObjectDialog::GetFormat( const TransferableDataHelper& rHelper,
         ::com::sun::star::datatransfer::DataFlavor aFlavor( *aIter );
         SotFormatStringId nFormat = (*aIter++).mnSotId;
 
-        String* pName = (String*) aSupplementTable.Get( nFormat );
+        String* pName = NULL;
         String aName;
+        ::std::map< SotFormatStringId, String* >::iterator itName;
+        itName = aSupplementMap.find( nFormat );
 
         // if there is an "Embed Source" or and "Embedded Object" on the
         // Clipboard we read the Description and the Source of this object
         // from an accompanied "Object Descriptor" format on the clipboard
         // Remember: these formats mostly appear together on the clipboard
-        if ( !pName )
+        if ( itName == aSupplementMap.end() )
         {
             SvPasteObjectHelper::GetEmbeddedName(rHelper,aName,aSourceName,nFormat);
             if ( aName.Len() )
                 pName = &aName;
         }
-
+        else
+        {
+            pName = itName->second;
+        }
 
         if( pName )
         {
diff --git a/cui/source/inc/pastedlg.hxx b/cui/source/inc/pastedlg.hxx
index 93c6ff4..ddf4ccb 100644
--- a/cui/source/inc/pastedlg.hxx
+++ b/cui/source/inc/pastedlg.hxx
@@ -29,7 +29,7 @@
 #ifndef _PASTEDLG_HXX
 #define _PASTEDLG_HXX
 
-#include <tools/table.hxx>
+#include <map>
 #include <sot/formats.hxx>
 #include <tools/globname.hxx>
 #include <svtools/transfer.hxx>
@@ -60,7 +60,7 @@ class SvPasteObjectDialog : public ModalDialog
     OKButton aOKButton1;
     CancelButton aCancelButton1;
     HelpButton aHelpButton1;
-    Table           aSupplementTable;
+    ::std::map< SotFormatStringId, String* > aSupplementMap;
     SvGlobalName    aObjClassName;
     String          aObjName;
     sal_uInt16          nAspect;


More information about the Libreoffice-commits mailing list