[Libreoffice-commits] .: tools/inc tools/source

Joseph Powers jpowers at kemper.freedesktop.org
Fri Jul 8 07:32:06 PDT 2011


 tools/inc/tools/inetmsg.hxx    |   17 ++++++++---------
 tools/source/inet/inetmsg.cxx  |   24 ++++++++++--------------
 tools/source/inet/inetstrm.cxx |    4 +---
 3 files changed, 19 insertions(+), 26 deletions(-)

New commits:
commit f9437ca8e69b481b120519b8b78938dda62dda4a
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Fri Jul 8 07:28:01 2011 -0700

    Replace List with std::vector< INetMIMEMessage* >
    
    I also removed "sal_uIntPtr nNumChildren;". The use was question able at
    best. Its count could be off because AttachChild() set it to size() if the
    child was added; however, if the child wasn't added the person doing the
    AttachChild() was also incrementing the count.
    
    Related to the removal of nNumChildren, I also removed the GetChildCount()
    & SetChildCount() methods because they where only used around the broken
    AttachChild() code.

diff --git a/tools/inc/tools/inetmsg.hxx b/tools/inc/tools/inetmsg.hxx
index 24928cf..45b9241 100644
--- a/tools/inc/tools/inetmsg.hxx
+++ b/tools/inc/tools/inetmsg.hxx
@@ -455,19 +455,19 @@ enum INetMessageContainerType
     INETMSG_MULTIPART_FORM_DATA
 };
 
+class INetMIMEMessage;
+typedef ::std::vector< INetMIMEMessage* > INetMIMEMessgeList_impl;
 class TOOLS_DLLPUBLIC INetMIMEMessage : public INetRFC822Message
 {
-    sal_uIntPtr           m_nIndex[INETMSG_MIME_NUMHDR];
+    sal_uIntPtr             m_nIndex[INETMSG_MIME_NUMHDR];
 
-    INetMIMEMessage *pParent;
-    sal_uIntPtr           nNumChildren;
-    List            aChildren;
-    ByteString      m_aBoundary;
-    sal_Bool            bHeaderParsed;
+    INetMIMEMessage*        pParent;
+    INetMIMEMessgeList_impl aChildren;
+    ByteString              m_aBoundary;
+    sal_Bool                bHeaderParsed;
 
     friend class INetMIMEMessageStream;
 
-    void SetChildCount (sal_uIntPtr nCount) { nNumChildren = nCount; }
     const ByteString& GetMultipartBoundary (void) const { return m_aBoundary; }
     void SetMultipartBoundary (const ByteString& rBnd) { m_aBoundary = rBnd; }
 
@@ -554,10 +554,9 @@ public:
         return (aType.CompareIgnoreCaseToAscii("multipart/", 10) == 0);
     }
 
-    sal_uIntPtr GetChildCount (void) const { return nNumChildren; }
     INetMIMEMessage* GetChild (sal_uIntPtr nIndex) const
     {
-        return ((INetMIMEMessage *)(aChildren.GetObject (nIndex)));
+        return ( nIndex < aChildren.size() ) ? aChildren[ nIndex ] : NULL;
     }
     INetMIMEMessage* GetParent (void) const { return pParent; }
 
diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx
index 776df97..72767a8 100644
--- a/tools/source/inet/inetmsg.cxx
+++ b/tools/source/inet/inetmsg.cxx
@@ -960,7 +960,6 @@ enum _ImplINetMIMEMessageHeaderState
 INetMIMEMessage::INetMIMEMessage (void)
     : INetRFC822Message (),
       pParent       (NULL),
-      nNumChildren  (0),
       bHeaderParsed (sal_False)
 {
     for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++)
@@ -1008,9 +1007,10 @@ INetMIMEMessage::~INetMIMEMessage (void)
  */
 void INetMIMEMessage::CleanupImp (void)
 {
-    INetMIMEMessage *pChild = NULL;
-    while ((pChild = (INetMIMEMessage *)(aChildren.Remove())) != NULL)
-        if (pChild->pParent == this) delete pChild;
+    for( size_t i = 0, n = aChildren.size(); i < n; ++i ) {
+        delete aChildren[ i ];
+    }
+    aChildren.clear();
 }
 
 /*
@@ -1020,24 +1020,22 @@ void INetMIMEMessage::CopyImp (const INetMIMEMessage& rMsg)
 {
     bHeaderParsed = rMsg.bHeaderParsed;
 
-    sal_uInt16 i;
+    size_t i;
     for (i = 0; i < INETMSG_MIME_NUMHDR; i++)
         m_nIndex[i] = rMsg.m_nIndex[i];
 
     m_aBoundary = rMsg.m_aBoundary;
-    nNumChildren = rMsg.nNumChildren;
 
-    for (i = 0; i < rMsg.aChildren.Count(); i++)
+    for (i = 0; i < rMsg.aChildren.size(); i++)
     {
-        INetMIMEMessage *pChild =
-            (INetMIMEMessage *)(rMsg.aChildren.GetObject (i));
+        INetMIMEMessage *pChild = rMsg.aChildren[ i ];
 
         if (pChild->pParent == &rMsg)
         {
             pChild = pChild->CreateMessage (*pChild);
             pChild->pParent = this;
         }
-        aChildren.Insert (pChild, LIST_APPEND);
+        aChildren.push_back( pChild );
     }
 }
 
@@ -1366,8 +1364,7 @@ sal_Bool INetMIMEMessage::AttachChild (
     if (IsContainer() /*&& rChildMsg.GetContentType().Len() */)
     {
         if (bOwner) rChildMsg.pParent = this;
-        aChildren.Insert (&rChildMsg, LIST_APPEND);
-        nNumChildren = aChildren.Count();
+        aChildren.push_back( &rChildMsg );
 
         return sal_True;
     }
@@ -1582,7 +1579,7 @@ SvStream& INetMIMEMessage::operator<< (SvStream& rStrm) const
 #else
     rStrm.WriteByteString (m_aBoundary);
 #endif
-    rStrm << static_cast<sal_uInt32>(nNumChildren);
+    rStrm << static_cast<sal_uInt32>(aChildren.size());
 
     return rStrm;
 }
@@ -1607,7 +1604,6 @@ SvStream& INetMIMEMessage::operator>> (SvStream& rStrm)
     rStrm.ReadByteString (m_aBoundary);
 #endif
     rStrm >> nTemp;
-    nNumChildren = nTemp;
 
     return rStrm;
 }
diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx
index 3217959..ff90411 100644
--- a/tools/source/inet/inetstrm.cxx
+++ b/tools/source/inet/inetstrm.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
@@ -1621,7 +1621,6 @@ int INetMIMEMessageStream::PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize)
                 if( !pChildStrm )
                 {
                     // Encapsulated message.
-                    pMsg->SetChildCount( pMsg->GetChildCount() + 1);
                     INetMIMEMessage* pNewMessage = new INetMIMEMessage;
                     pNewMessage->SetDocumentLB (
                         new SvAsyncLockBytes(new SvCacheStream, sal_False));
@@ -1731,7 +1730,6 @@ int INetMIMEMessageStream::PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize)
                                 != COMPARE_EQUAL )
                             {
                                 // Encapsulated message.
-                                pMsg->SetChildCount(pMsg->GetChildCount() + 1);
                                 INetMIMEMessage* pNewMessage =
                                     new INetMIMEMessage;
                                 pNewMessage->SetDocumentLB (


More information about the Libreoffice-commits mailing list