forms/source/component/DatabaseForm.cxx | 2 include/tools/inetmsg.hxx | 279 +++++++++-------------------- include/tools/inetstrm.hxx | 94 +-------- sfx2/source/doc/objmisc.cxx | 2 tools/source/inet/inetmsg.cxx | 203 +++------------------ tools/source/inet/inetstrm.cxx | 74 +------ unotools/source/ucbhelper/ucblockbytes.cxx | 2 7 files changed, 162 insertions(+), 494 deletions(-)
New commits: commit c4e8d9793a334d19eab68c80313a81d98427cdae Author: Stephan Bergmann <[email protected]> Date: Wed Feb 11 16:47:51 2015 +0100 Remove redundant overloads ...now that INetMessage got folded into INetMIMEMessage Change-Id: Id824c6b53ff30ecb2912ec4ad0f9e6c73db1e424 diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx index 8ad5940..481ca16 100644 --- a/include/tools/inetstrm.hxx +++ b/include/tools/inetstrm.hxx @@ -147,26 +147,6 @@ protected: public: INetMIMEMessageStream (sal_uIntPtr nBufferSize = 2048); virtual ~INetMIMEMessageStream (void); - - using INetMessageIStream::SetSourceMessage; - void SetSourceMessage (INetMIMEMessage *pMsg) - { - INetMessageIStream::SetSourceMessage (pMsg); - } - INetMIMEMessage *GetSourceMessage (void) const - { - return static_cast<INetMIMEMessage *>(INetMessageIStream::GetSourceMessage()); - } - - using INetMessageOStream::SetTargetMessage; - void SetTargetMessage (INetMIMEMessage *pMsg) - { - INetMessageOStream::SetTargetMessage (pMsg); - } - INetMIMEMessage *GetTargetMessage (void) const - { - return static_cast<INetMIMEMessage *>(INetMessageOStream::GetTargetMessage()); - } }; #endif commit db11071ce4409bb149f6f08dda06e669c933f78e Author: Stephan Bergmann <[email protected]> Date: Wed Feb 11 16:44:21 2015 +0100 Fold INetMessageIOStream into INetMIMEMessageStream Change-Id: I5aa24881d6a4625f1d2249fda8788bb03ef02e27 diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx index c3ada5c..8ad5940 100644 --- a/include/tools/inetstrm.hxx +++ b/include/tools/inetstrm.hxx @@ -110,18 +110,6 @@ public: bool IsHeaderParsed (void) const { return bHeaderParsed; } }; -class INetMessageIOStream - : public INetMessageIStream, - public INetMessageOStream -{ - INetMessageIOStream (const INetMessageIOStream& rStrm) SAL_DELETED_FUNCTION; - INetMessageIOStream& operator= (const INetMessageIOStream& rStrm) SAL_DELETED_FUNCTION; - -public: - INetMessageIOStream (sal_uIntPtr nBufferSize = 2048); - virtual ~INetMessageIOStream (void); -}; - enum INetMessageEncoding { INETMSG_ENCODING_7BIT, @@ -131,7 +119,9 @@ enum INetMessageEncoding INETMSG_ENCODING_BASE64 }; -class TOOLS_DLLPUBLIC INetMIMEMessageStream : public INetMessageIOStream +class TOOLS_DLLPUBLIC INetMIMEMessageStream + : public INetMessageIStream, + public INetMessageOStream { int eState; diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index e0792cd..ed555b0 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -410,18 +410,6 @@ int INetMessageOStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) return INETSTREAM_STATUS_OK; } -// INetMessageIOStream - -INetMessageIOStream::INetMessageIOStream(sal_uIntPtr nBufferSize) - : INetMessageIStream (nBufferSize), - INetMessageOStream () -{ -} - -INetMessageIOStream::~INetMessageIOStream(void) -{ -} - // INetMessageEncodeQPStream_Impl static const sal_Char hex2pr[16] = { @@ -1059,7 +1047,7 @@ int INetMessageDecode64Stream_Impl::PutMsgLine(const sal_Char* pData, // INetMIMEMessageStream INetMIMEMessageStream::INetMIMEMessageStream(sal_uIntPtr nBufferSize) - : INetMessageIOStream(nBufferSize), + : INetMessageIStream(nBufferSize), eState (INETMSG_EOL_BEGIN), nChildIndex (0), pChildStrm (NULL), @@ -1202,7 +1190,7 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize) } // Generate the message header. - int nRead = INetMessageIOStream::GetMsgLine(pData, nSize); + int nRead = INetMessageIStream::GetMsgLine(pData, nSize); if (nRead <= 0) { // Reset state. @@ -1292,7 +1280,7 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize) if (eEncoding == INETMSG_ENCODING_7BIT) { // No Encoding. - return INetMessageIOStream::GetMsgLine(pData, nSize); + return INetMessageIStream::GetMsgLine(pData, nSize); } // Apply appropriate Encoding. @@ -1346,7 +1334,7 @@ int INetMIMEMessageStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) if (!IsHeaderParsed()) { // Parse the message header. - int nRet = INetMessageIOStream::PutMsgLine(pData, nSize); + int nRet = INetMessageOStream::PutMsgLine(pData, nSize); return nRet; } else @@ -1381,7 +1369,7 @@ int INetMIMEMessageStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) return status; } - return INetMessageIOStream::PutMsgLine(pData, nSize); + return INetMessageOStream::PutMsgLine(pData, nSize); } else { @@ -1452,7 +1440,7 @@ int INetMIMEMessageStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) else { SAL_WARN( "tools.stream", "Boundary not found." ); } - status = INetMessageIOStream::PutMsgLine( + status = INetMessageOStream::PutMsgLine( pOldPos, pChar - pOldPos + 1 ); if( status != INETSTREAM_STATUS_OK ) return status; @@ -1487,7 +1475,7 @@ int INetMIMEMessageStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) // Initialize control variables. } eState = INETMSG_EOL_BEGIN; - status = INetMessageIOStream::PutMsgLine( + status = INetMessageOStream::PutMsgLine( pOldPos, pChar - pOldPos + 1 ); if( status != INETSTREAM_STATUS_OK ) return status; @@ -1541,7 +1529,7 @@ int INetMIMEMessageStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) if (eEncoding == INETMSG_ENCODING_7BIT) { // No decoding necessary. - return INetMessageIOStream::PutMsgLine(pData, nSize); + return INetMessageOStream::PutMsgLine(pData, nSize); } else { commit df1c438046dfa5f138bb645a2c576de8f4dd860e Author: Stephan Bergmann <[email protected]> Date: Wed Feb 11 16:36:02 2015 +0100 Fold INetOStream into INetMessageOStream Change-Id: I062fa91cc05edae3c2879583cbbf8e8c8acfe482 diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx index 2676315..c3ada5c 100644 --- a/include/tools/inetstrm.hxx +++ b/include/tools/inetstrm.hxx @@ -35,22 +35,6 @@ enum INetStreamStatus INETSTREAM_STATUS_ERROR = -1 }; -class INetOStream -{ - INetOStream (const INetOStream& rStrm) SAL_DELETED_FUNCTION; - INetOStream& operator= (const INetOStream& rStrm) SAL_DELETED_FUNCTION; - -protected: - virtual int PutData ( - const sal_Char *pData, sal_uIntPtr nSize) = 0; - -public: - INetOStream (); - virtual ~INetOStream (void); - - int Write (const sal_Char *pData, sal_uIntPtr nSize); -}; - enum INetMessageStreamState { INETMSG_EOL_BEGIN, @@ -98,7 +82,7 @@ public: }; /// Message Parser Interface. -class INetMessageOStream : public INetOStream +class INetMessageOStream { INetMIMEMessage *pTargetMsg; bool bHeaderParsed; @@ -107,8 +91,6 @@ class INetMessageOStream : public INetOStream SvMemoryStream *pMsgBuffer; - virtual int PutData (const sal_Char *pData, sal_uIntPtr nSize) SAL_OVERRIDE; - INetMessageOStream (const INetMessageOStream& rStrm) SAL_DELETED_FUNCTION; INetMessageOStream& operator= (const INetMessageOStream& rStrm) SAL_DELETED_FUNCTION; @@ -119,6 +101,8 @@ public: INetMessageOStream (void); virtual ~INetMessageOStream (void); + int Write (const sal_Char *pData, sal_uIntPtr nSize); + INetMIMEMessage *GetTargetMessage (void) const { return pTargetMsg; } void SetTargetMessage (INetMIMEMessage *pMsg) { pTargetMsg = pMsg; } diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index a1f2b1b..e0792cd 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -112,21 +112,6 @@ public: virtual ~INetMessageDecode64Stream_Impl(void); }; -// INetOStream - -INetOStream::INetOStream() -{ -} - -INetOStream::~INetOStream(void) -{ -} - -int INetOStream::Write(const sal_Char* pData, sal_uIntPtr nSize) -{ - return PutData(pData, nSize); -} - // INetMessageIStream INetMessageIStream::INetMessageIStream(sal_uIntPtr nBufferSize) @@ -287,7 +272,7 @@ INetMessageOStream::~INetMessageOStream(void) } /// Simple Field Parsing (RFC822, Appendix B) -int INetMessageOStream::PutData(const sal_Char* pData, sal_uIntPtr nSize) +int INetMessageOStream::Write(const sal_Char* pData, sal_uIntPtr nSize) { if (pTargetMsg == NULL) return INETSTREAM_STATUS_ERROR; commit ba2cb77315fa37f6fd911d9f10fc1e74c56272ca Author: Stephan Bergmann <[email protected]> Date: Wed Feb 11 16:31:57 2015 +0100 Fold INetIStream into INetMessageIStream Change-Id: I882a8bc2048149307383491cc77c4e10f5e99a52 diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx index 30b5e48..2676315 100644 --- a/include/tools/inetstrm.hxx +++ b/include/tools/inetstrm.hxx @@ -35,21 +35,6 @@ enum INetStreamStatus INETSTREAM_STATUS_ERROR = -1 }; -class TOOLS_DLLPUBLIC INetIStream -{ - INetIStream (const INetIStream& rStrm) SAL_DELETED_FUNCTION; - INetIStream& operator= (const INetIStream& rStrm) SAL_DELETED_FUNCTION; - -protected: - virtual int GetData (sal_Char *pData, sal_uIntPtr nSize) = 0; - -public: - INetIStream (); - virtual ~INetIStream (void); - - int Read (sal_Char *pData, sal_uIntPtr nSize); -}; - class INetOStream { INetOStream (const INetOStream& rStrm) SAL_DELETED_FUNCTION; @@ -78,7 +63,7 @@ enum INetMessageStreamState }; /// Message Generator Interface. -class INetMessageIStream : public INetIStream +class INetMessageIStream { INetMIMEMessage *pSourceMsg; bool bHeaderGenerated; @@ -93,8 +78,6 @@ class INetMessageIStream : public INetIStream sal_Char *pMsgRead; sal_Char *pMsgWrite; - virtual int GetData (sal_Char *pData, sal_uIntPtr nSize) SAL_OVERRIDE; - INetMessageIStream (const INetMessageIStream& rStrm) SAL_DELETED_FUNCTION; INetMessageIStream& operator= (const INetMessageIStream& rStrm) SAL_DELETED_FUNCTION; @@ -105,6 +88,8 @@ public: INetMessageIStream (sal_uIntPtr nBufferSize = 2048); virtual ~INetMessageIStream (void); + TOOLS_DLLPUBLIC int Read (sal_Char *pData, sal_uIntPtr nSize); + INetMIMEMessage *GetSourceMessage (void) const { return pSourceMsg; } void SetSourceMessage (INetMIMEMessage *pMsg) { pSourceMsg = pMsg; } diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index cc24dff..a1f2b1b 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -112,21 +112,6 @@ public: virtual ~INetMessageDecode64Stream_Impl(void); }; -// INetIStream - -INetIStream::INetIStream() -{ -} - -INetIStream::~INetIStream(void) -{ -} - -int INetIStream::Read(sal_Char* pData, sal_uIntPtr nSize) -{ - return GetData(pData, nSize); -} - // INetOStream INetOStream::INetOStream() @@ -165,7 +150,7 @@ INetMessageIStream::~INetMessageIStream(void) delete pMsgStrm; } -int INetMessageIStream::GetData(sal_Char* pData, sal_uIntPtr nSize) +int INetMessageIStream::Read(sal_Char* pData, sal_uIntPtr nSize) { if (pSourceMsg == NULL) return INETSTREAM_STATUS_ERROR; commit c27ab70f2664e8728a4aec8cc39d6c89d016c319 Author: Stephan Bergmann <[email protected]> Date: Wed Feb 11 16:25:30 2015 +0100 GenerateHeader(false) -> SetHeaderGenerated() Change-Id: I41f06c92589e6b1839e39d840a479f1a184b47dd diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 753fe89..bb2c6a8 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -564,7 +564,7 @@ Sequence<sal_Int8> ODatabaseForm::GetDataMultiPartEncoded(const Reference<XContr // Create MessageStream for parent INetMIMEMessageStream aMessStream; aMessStream.SetSourceMessage( &aParent ); - aMessStream.GenerateHeader( false ); + aMessStream.SetHeaderGenerated(); // Copy MessageStream to SvStream SvMemoryStream aMemStream; diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx index 09ee43e..30b5e48 100644 --- a/include/tools/inetstrm.hxx +++ b/include/tools/inetstrm.hxx @@ -108,7 +108,7 @@ public: INetMIMEMessage *GetSourceMessage (void) const { return pSourceMsg; } void SetSourceMessage (INetMIMEMessage *pMsg) { pSourceMsg = pMsg; } - void GenerateHeader (bool bGen = true) { bHeaderGenerated = !bGen; } + void SetHeaderGenerated() { bHeaderGenerated = true; } bool IsHeaderGenerated (void) const { return bHeaderGenerated; } }; diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index a6fbf23..cc24dff 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -467,7 +467,7 @@ INetMessageEncodeQPStream_Impl::INetMessageEncodeQPStream_Impl( sal_uIntPtr nMsg eState (INETMSG_EOL_SCR), bDone (false) { - GenerateHeader (false); + SetHeaderGenerated(); pMsgBuffer = new sal_Char[nMsgBufSiz]; pMsgRead = pMsgWrite = pMsgBuffer; @@ -789,7 +789,7 @@ INetMessageEncode64Stream_Impl::INetMessageEncode64Stream_Impl( nTokBufSiz (80), bDone (false) { - GenerateHeader(false); + SetHeaderGenerated(); pMsgBuffer = new sal_uInt8[nMsgBufSiz]; pMsgRead = pMsgWrite = pMsgBuffer; commit 2c5ce8ea8eb98f2d82986448af448d11b60a3ea1 Author: Stephan Bergmann <[email protected]> Date: Wed Feb 11 16:14:44 2015 +0100 Remove unused INetMIMEMessage streaming operators Change-Id: Ifbbfb1213d78a87fffd7a40e10deaf29dd7a96b8 diff --git a/include/tools/inetmsg.hxx b/include/tools/inetmsg.hxx index eb14ffc..3d354fb 100644 --- a/include/tools/inetmsg.hxx +++ b/include/tools/inetmsg.hxx @@ -414,12 +414,6 @@ public: INetMessageContainerType eType = INETMSG_MULTIPART_MIXED); bool AttachChild ( INetMIMEMessage& rChildMsg, bool bOwner = true ); - - // Stream operators. - - friend SvStream& operator <<(SvStream& rStrm, const INetMIMEMessage& rMsg); - - friend SvStream& operator >>(SvStream& rStrm, INetMIMEMessage& rMsg); }; #endif diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index 7a78170..49d97ca 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -882,71 +882,4 @@ bool INetMIMEMessage::AttachChild(INetMIMEMessage& rChildMsg, bool bOwner) return false; } -SvStream& operator <<(SvStream& rStrm, const INetMIMEMessage& rMsg) -{ - rStrm.WriteUInt32( rMsg.m_nDocSize ); - write_uInt16_lenPrefixed_uInt8s_FromOUString(rStrm, rMsg.m_aDocName, RTL_TEXTENCODING_UTF8); - - sal_uIntPtr n = rMsg.m_aHeaderList.size(); - rStrm.WriteUInt32( n ); - - for (sal_uIntPtr i = 0; i < n; i++) - WriteINetMessageHeader( rStrm, *( rMsg.m_aHeaderList[ i ] ) ); - - for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) - rStrm.WriteUInt32( rMsg.m_nRFC822Index[i] ); - - for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) - rStrm.WriteUInt32( rMsg.m_nMIMEIndex[i] ); - - write_uInt16_lenPrefixed_uInt8s_FromOString(rStrm, rMsg.m_aBoundary); - rStrm.WriteUInt32( rMsg.aChildren.size() ); - - return rStrm; -} - -SvStream& operator >>(SvStream& rStrm, INetMIMEMessage& rMsg) -{ - // Cleanup. - rMsg.m_nDocSize = 0; - rMsg.m_xDocLB.Clear(); - rMsg.ListCleanup_Impl(); - - sal_uInt32 nTemp; - - // Copy. - rStrm.ReadUInt32( nTemp ); - rMsg.m_nDocSize = nTemp; - rMsg.m_aDocName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rStrm, RTL_TEXTENCODING_UTF8); - - sal_uIntPtr n = 0; - rStrm.ReadUInt32( nTemp ); - n = nTemp; - - for (sal_uIntPtr i = 0; i < n; i++) - { - INetMessageHeader *p = new INetMessageHeader(); - ReadINetMessageHeader( rStrm, *p ); - rMsg.m_aHeaderList.push_back( p ); - } - - for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) - { - rStrm.ReadUInt32( nTemp ); - rMsg.m_nRFC822Index[i] = nTemp; - } - - for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) - { - rStrm.ReadUInt32( nTemp ); - rMsg.m_nMIMEIndex[i] = nTemp; - } - - rMsg.m_aBoundary = read_uInt16_lenPrefixed_uInt8s_ToOString(rStrm); - - rStrm.ReadUInt32( nTemp ); - - return rStrm; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit ca6be614e2d380f854b0c7187bd4220a9fb232a3 Author: Stephan Bergmann <[email protected]> Date: Wed Feb 11 16:14:14 2015 +0100 Fold INetRFC822Message into INetMIMEMessage Change-Id: I9b02b8f758c3f0613a7b017d8822fc16ebfc9dec diff --git a/include/tools/inetmsg.hxx b/include/tools/inetmsg.hxx index fb6370a..eb14ffc 100644 --- a/include/tools/inetmsg.hxx +++ b/include/tools/inetmsg.hxx @@ -99,7 +99,29 @@ typedef ::std::vector< INetMessageHeader* > HeaderList_impl; #define INETMSG_RFC822_RETURN_RECEIPT_TO 15 #define INETMSG_RFC822_NUMHDR 16 -class TOOLS_DLLPUBLIC INetRFC822Message +#define INETMSG_MIME_VERSION 0 +#define INETMSG_MIME_CONTENT_DESCRIPTION 1 +#define INETMSG_MIME_CONTENT_DISPOSITION 2 +#define INETMSG_MIME_CONTENT_ID 3 +#define INETMSG_MIME_CONTENT_TYPE 4 +#define INETMSG_MIME_CONTENT_TRANSFER_ENCODING 5 +#define INETMSG_MIME_NUMHDR 6 + +enum INetMessageContainerType +{ + INETMSG_MESSAGE_RFC822, + INETMSG_MULTIPART_MIXED, + INETMSG_MULTIPART_ALTERNATIVE, + INETMSG_MULTIPART_DIGEST, + INETMSG_MULTIPART_PARALLEL, + INETMSG_MULTIPART_RELATED, + INETMSG_MULTIPART_FORM_DATA +}; + +class INetMIMEMessage; +typedef ::std::vector< INetMIMEMessage* > INetMIMEMessgeList_impl; + +class TOOLS_DLLPUBLIC INetMIMEMessage { HeaderList_impl m_aHeaderList; @@ -108,11 +130,25 @@ class TOOLS_DLLPUBLIC INetRFC822Message SvLockBytesRef m_xDocLB; void ListCleanup_Impl(); - void ListCopy (const INetRFC822Message& rMsg); + void ListCopy (const INetMIMEMessage& rMsg); + + sal_uIntPtr m_nRFC822Index[INETMSG_RFC822_NUMHDR]; + + sal_uIntPtr m_nMIMEIndex[INETMSG_MIME_NUMHDR]; + INetMIMEMessage* pParent; + INetMIMEMessgeList_impl aChildren; + OString m_aBoundary; + bool bHeaderParsed; + + friend class INetMIMEMessageStream; + + const OString& GetMultipartBoundary() const { return m_aBoundary; } + void SetMultipartBoundary (const OString& rBnd) { m_aBoundary = rBnd; } - sal_uIntPtr m_nIndex[INETMSG_RFC822_NUMHDR]; + void CleanupImp(); + void CopyImp (const INetMIMEMessage& rMsg); + void SetHeaderParsed() { bHeaderParsed = true; } -protected: OUString GetHeaderName_Impl ( sal_uIntPtr nIndex, rtl_TextEncoding eEncoding) const { @@ -155,15 +191,15 @@ protected: const OUString &rValue, sal_uIntPtr &rnIndex); - virtual SvStream& operator<< (SvStream& rStrm) const; - virtual SvStream& operator>> (SvStream& rStrm); + sal_uIntPtr SetRFC822HeaderField ( + const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex); public: - INetRFC822Message(); - INetRFC822Message (const INetRFC822Message& rMsg); - virtual ~INetRFC822Message(); + INetMIMEMessage(); + INetMIMEMessage (const INetMIMEMessage& rMsg); + ~INetMIMEMessage(); - INetRFC822Message& operator= (const INetRFC822Message& rMsg); + INetMIMEMessage& operator= (const INetMIMEMessage& rMsg); sal_uIntPtr GetHeaderCount() const { return m_aHeaderList.size(); } @@ -186,7 +222,7 @@ public: } } - virtual sal_uIntPtr SetHeaderField ( + sal_uIntPtr SetHeaderField ( const INetMessageHeader &rField, sal_uIntPtr nIndex = ((sal_uIntPtr)-1) ); @@ -203,235 +239,150 @@ public: static bool ParseDateField ( const OUString& rDateField, DateTime& rDateTime); + bool HeaderParsed() const { return bHeaderParsed; } + + INetMIMEMessage* CreateMessage ( + const INetMIMEMessage& rMsg) const; + // Header fields. OUString GetBCC() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_BCC], + m_nRFC822Index[INETMSG_RFC822_BCC], INetMIME::HEADER_FIELD_ADDRESS); } OUString GetCC() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_CC], + m_nRFC822Index[INETMSG_RFC822_CC], INetMIME::HEADER_FIELD_ADDRESS); } OUString GetComments() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_COMMENTS], + m_nRFC822Index[INETMSG_RFC822_COMMENTS], INetMIME::HEADER_FIELD_TEXT); } OUString GetDate() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_DATE], + m_nRFC822Index[INETMSG_RFC822_DATE], INetMIME::HEADER_FIELD_STRUCTURED); } OUString GetFrom() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_FROM], + m_nRFC822Index[INETMSG_RFC822_FROM], INetMIME::HEADER_FIELD_ADDRESS); } OUString GetInReplyTo() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_IN_REPLY_TO], + m_nRFC822Index[INETMSG_RFC822_IN_REPLY_TO], INetMIME::HEADER_FIELD_ADDRESS); // ??? MESSAGE_ID ??? } OUString GetKeywords() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_KEYWORDS], + m_nRFC822Index[INETMSG_RFC822_KEYWORDS], INetMIME::HEADER_FIELD_PHRASE); } OUString GetMessageID() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_MESSAGE_ID], + m_nRFC822Index[INETMSG_RFC822_MESSAGE_ID], INetMIME::HEADER_FIELD_MESSAGE_ID); } OUString GetReferences() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_REFERENCES], + m_nRFC822Index[INETMSG_RFC822_REFERENCES], INetMIME::HEADER_FIELD_ADDRESS); } OUString GetReplyTo() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_REPLY_TO], + m_nRFC822Index[INETMSG_RFC822_REPLY_TO], INetMIME::HEADER_FIELD_ADDRESS); } OUString GetReturnPath() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_RETURN_PATH], + m_nRFC822Index[INETMSG_RFC822_RETURN_PATH], INetMIME::HEADER_FIELD_ADDRESS); } OUString GetReturnReceiptTo() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_RETURN_RECEIPT_TO], + m_nRFC822Index[INETMSG_RFC822_RETURN_RECEIPT_TO], INetMIME::HEADER_FIELD_ADDRESS); } OUString GetSender() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_SENDER], + m_nRFC822Index[INETMSG_RFC822_SENDER], INetMIME::HEADER_FIELD_ADDRESS); } OUString GetSubject() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_SUBJECT], + m_nRFC822Index[INETMSG_RFC822_SUBJECT], INetMIME::HEADER_FIELD_TEXT); } OUString GetTo() const { return GetHeaderValue_Impl ( - m_nIndex[INETMSG_RFC822_TO], + m_nRFC822Index[INETMSG_RFC822_TO], INetMIME::HEADER_FIELD_TEXT); } - // Stream operators. - - friend SvStream& WriteINetMessage( - SvStream& rStrm, const INetRFC822Message& rMsg) - { - return rMsg.operator<< (rStrm); - } - - friend SvStream& ReadINetMessage ( - SvStream& rStrm, INetRFC822Message& rMsg) - { - return rMsg.operator>> (rStrm); - } - - friend SvStream& operator<< ( - SvStream& rStrm, const INetRFC822Message& rMsg) - { - return rMsg.operator<< (rStrm); - } - - friend SvStream& operator>> ( - SvStream& rStrm, INetRFC822Message& rMsg) - { - return rMsg.operator>> (rStrm); - } -}; - -#define INETMSG_MIME_VERSION 0 -#define INETMSG_MIME_CONTENT_DESCRIPTION 1 -#define INETMSG_MIME_CONTENT_DISPOSITION 2 -#define INETMSG_MIME_CONTENT_ID 3 -#define INETMSG_MIME_CONTENT_TYPE 4 -#define INETMSG_MIME_CONTENT_TRANSFER_ENCODING 5 -#define INETMSG_MIME_NUMHDR 6 - -enum INetMessageContainerType -{ - INETMSG_MESSAGE_RFC822, - INETMSG_MULTIPART_MIXED, - INETMSG_MULTIPART_ALTERNATIVE, - INETMSG_MULTIPART_DIGEST, - INETMSG_MULTIPART_PARALLEL, - INETMSG_MULTIPART_RELATED, - 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]; - INetMIMEMessage* pParent; - INetMIMEMessgeList_impl aChildren; - OString m_aBoundary; - bool bHeaderParsed; - - friend class INetMIMEMessageStream; - - const OString& GetMultipartBoundary() const { return m_aBoundary; } - void SetMultipartBoundary (const OString& rBnd) { m_aBoundary = rBnd; } - - void CleanupImp(); - void CopyImp (const INetMIMEMessage& rMsg); - void SetHeaderParsed() { bHeaderParsed = true; } - -protected: - virtual SvStream& operator<< (SvStream& rStrm) const SAL_OVERRIDE; - virtual SvStream& operator>> (SvStream& rStrm) SAL_OVERRIDE; - -public: - INetMIMEMessage(); - INetMIMEMessage (const INetMIMEMessage& rMsg); - virtual ~INetMIMEMessage(); - - INetMIMEMessage& operator= (const INetMIMEMessage& rMsg); - - bool HeaderParsed() const { return bHeaderParsed; } - - INetMIMEMessage* CreateMessage ( - const INetMIMEMessage& rMsg) const; - - using INetRFC822Message::SetHeaderField; - virtual sal_uIntPtr SetHeaderField ( - const INetMessageHeader &rHeader, - sal_uIntPtr nIndex = ((sal_uIntPtr)-1) - ) SAL_OVERRIDE; - - // Header fields. - void SetMIMEVersion (const OUString& rVersion); OUString GetMIMEVersion() const { - return GetHeaderValue (m_nIndex[INETMSG_MIME_VERSION]); + return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_VERSION]); } OUString GetContentDescription() const { - return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_DESCRIPTION]); + return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_CONTENT_DESCRIPTION]); } void SetContentDisposition (const OUString& rDisposition); OUString GetContentDisposition() const { - return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_DISPOSITION]); + return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_CONTENT_DISPOSITION]); } OUString GetContentID() const { - return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_ID]); + return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_CONTENT_ID]); } void SetContentType (const OUString& rType); OUString GetContentType() const { - return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TYPE]); + return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_CONTENT_TYPE]); } void SetContentTransferEncoding (const OUString& rEncoding); OUString GetContentTransferEncoding() const { - return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]); + return GetHeaderValue (m_nMIMEIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]); } OUString GetDefaultContentType (); @@ -466,17 +417,9 @@ public: // Stream operators. - friend SvStream& operator<< ( - SvStream& rStrm, const INetMIMEMessage& rMsg) - { - return rMsg.operator<< (rStrm); - } + friend SvStream& operator <<(SvStream& rStrm, const INetMIMEMessage& rMsg); - friend SvStream& operator>> ( - SvStream& rStrm, INetMIMEMessage& rMsg) - { - return rMsg.operator>> (rStrm); - } + friend SvStream& operator >>(SvStream& rStrm, INetMIMEMessage& rMsg); }; #endif diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx index b5c4e04..09ee43e 100644 --- a/include/tools/inetstrm.hxx +++ b/include/tools/inetstrm.hxx @@ -23,7 +23,6 @@ #include <sal/types.h> #include <rtl/ustring.hxx> -class INetRFC822Message; class INetMIMEMessage; class SvMemoryStream; class SvStream; @@ -81,7 +80,7 @@ enum INetMessageStreamState /// Message Generator Interface. class INetMessageIStream : public INetIStream { - INetRFC822Message *pSourceMsg; + INetMIMEMessage *pSourceMsg; bool bHeaderGenerated; sal_uIntPtr nBufSiz; @@ -106,8 +105,8 @@ public: INetMessageIStream (sal_uIntPtr nBufferSize = 2048); virtual ~INetMessageIStream (void); - INetRFC822Message *GetSourceMessage (void) const { return pSourceMsg; } - void SetSourceMessage (INetRFC822Message *pMsg) { pSourceMsg = pMsg; } + INetMIMEMessage *GetSourceMessage (void) const { return pSourceMsg; } + void SetSourceMessage (INetMIMEMessage *pMsg) { pSourceMsg = pMsg; } void GenerateHeader (bool bGen = true) { bHeaderGenerated = !bGen; } bool IsHeaderGenerated (void) const { return bHeaderGenerated; } @@ -116,7 +115,7 @@ public: /// Message Parser Interface. class INetMessageOStream : public INetOStream { - INetRFC822Message *pTargetMsg; + INetMIMEMessage *pTargetMsg; bool bHeaderParsed; INetMessageStreamState eOState; @@ -135,8 +134,8 @@ public: INetMessageOStream (void); virtual ~INetMessageOStream (void); - INetRFC822Message *GetTargetMessage (void) const { return pTargetMsg; } - void SetTargetMessage (INetRFC822Message *pMsg) { pTargetMsg = pMsg; } + INetMIMEMessage *GetTargetMessage (void) const { return pTargetMsg; } + void SetTargetMessage (INetMIMEMessage *pMsg) { pTargetMsg = pMsg; } void ParseHeader (bool bParse = true) { bHeaderParsed = !bParse; } bool IsHeaderParsed (void) const { return bHeaderParsed; } @@ -193,7 +192,7 @@ public: using INetMessageIStream::SetSourceMessage; void SetSourceMessage (INetMIMEMessage *pMsg) { - INetMessageIStream::SetSourceMessage ((INetRFC822Message *)pMsg); + INetMessageIStream::SetSourceMessage (pMsg); } INetMIMEMessage *GetSourceMessage (void) const { @@ -203,7 +202,7 @@ public: using INetMessageOStream::SetTargetMessage; void SetTargetMessage (INetMIMEMessage *pMsg) { - INetMessageOStream::SetTargetMessage ((INetRFC822Message *)pMsg); + INetMessageOStream::SetTargetMessage (pMsg); } INetMIMEMessage *GetTargetMessage (void) const { diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 4c8746f..4deb194 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1638,7 +1638,7 @@ void SfxHeaderAttributes_Impl::SetAttribute( const SvKeyValue& rKV ) else if( rKV.GetKey().equalsIgnoreAsciiCase( "expires" ) ) { DateTime aDateTime( DateTime::EMPTY ); - if( INetRFC822Message::ParseDateField( rKV.GetValue(), aDateTime ) ) + if( INetMIMEMessage::ParseDateField( rKV.GetValue(), aDateTime ) ) { aDateTime.ConvertToLocalTime(); pDoc->GetMedium()->SetExpired_Impl( aDateTime ); diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index a710bc2..7a78170 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -48,7 +48,7 @@ inline sal_Unicode ascii_toLowerCase( sal_Unicode ch ) return ch; } -void INetRFC822Message::ListCleanup_Impl() +void INetMIMEMessage::ListCleanup_Impl() { // Cleanup. sal_uIntPtr i, n = m_aHeaderList.size(); @@ -57,7 +57,7 @@ void INetRFC822Message::ListCleanup_Impl() m_aHeaderList.clear(); } -void INetRFC822Message::ListCopy (const INetRFC822Message &rMsg) +void INetMIMEMessage::ListCopy (const INetMIMEMessage &rMsg) { if (!(this == &rMsg)) { @@ -74,7 +74,7 @@ void INetRFC822Message::ListCopy (const INetRFC822Message &rMsg) } } -void INetRFC822Message::SetHeaderField_Impl ( +void INetMIMEMessage::SetHeaderField_Impl ( INetMIME::HeaderFieldType eType, const OString &rName, const OUString &rValue, @@ -121,42 +121,6 @@ enum _ImplINetRFC822MessageHeaderState INETMSG_RFC822_LETTER_S }; -INetRFC822Message::INetRFC822Message() - : m_nDocSize(0) -{ - for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) - m_nIndex[i] = CONTAINER_ENTRY_NOTFOUND; -} - -INetRFC822Message::INetRFC822Message (const INetRFC822Message& rMsg) - : m_nDocSize (rMsg.m_nDocSize), - m_aDocName (rMsg.m_aDocName), - m_xDocLB (rMsg.m_xDocLB) -{ - ListCopy (rMsg); - for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) - m_nIndex[i] = rMsg.m_nIndex[i]; -} - -INetRFC822Message& INetRFC822Message::operator= (const INetRFC822Message& rMsg) -{ - if (this != &rMsg) - { - m_nDocSize = rMsg.m_nDocSize; - m_aDocName = rMsg.m_aDocName; - m_xDocLB = rMsg.m_xDocLB; - ListCopy (rMsg); - for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) - m_nIndex[i] = rMsg.m_nIndex[i]; - } - return *this; -} - -INetRFC822Message::~INetRFC822Message() -{ - ListCleanup_Impl(); -} - /* ParseDateField and local helper functions. * * Parses a String in (implied) GMT format into class Date and tools::Time objects. @@ -200,7 +164,7 @@ static sal_uInt16 ParseMonth(const OString& rStr, sal_uInt16& nIndex) return (i + 1); } -bool INetRFC822Message::ParseDateField ( +bool INetMIMEMessage::ParseDateField ( const OUString& rDateFieldW, DateTime& rDateTime) { OString aDateField(OUStringToOString(rDateFieldW, @@ -310,7 +274,7 @@ bool INetRFC822Message::ParseDateField ( } // Header Field Parser -sal_uIntPtr INetRFC822Message::SetHeaderField ( +sal_uIntPtr INetMIMEMessage::SetRFC822HeaderField ( const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex) { OString aName (rHeader.GetName()); @@ -528,8 +492,8 @@ sal_uIntPtr INetRFC822Message::SetHeaderField ( pData = pStop; SetHeaderField_Impl ( INetMessageHeader( ImplINetRFC822MessageHeaderData[nIdx], rHeader.GetValue() ), - m_nIndex[nIdx]); - nNewIndex = m_nIndex[nIdx]; + m_nRFC822Index[nIdx]); + nNewIndex = m_nRFC822Index[nIdx]; break; default: // INETMSG_RFC822_JUNK @@ -541,57 +505,6 @@ sal_uIntPtr INetRFC822Message::SetHeaderField ( return nNewIndex; } -SvStream& INetRFC822Message::operator<< (SvStream& rStrm) const -{ - rStrm.WriteUInt32( m_nDocSize ); - write_uInt16_lenPrefixed_uInt8s_FromOUString(rStrm, m_aDocName, RTL_TEXTENCODING_UTF8); - - sal_uIntPtr n = m_aHeaderList.size(); - rStrm.WriteUInt32( n ); - - for (sal_uIntPtr i = 0; i < n; i++) - WriteINetMessageHeader( rStrm, *( m_aHeaderList[ i ] ) ); - - for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) - rStrm.WriteUInt32( m_nIndex[i] ); - - return rStrm; -} - -SvStream& INetRFC822Message::operator>> (SvStream& rStrm) -{ - // Cleanup. - m_nDocSize = 0; - m_xDocLB.Clear(); - ListCleanup_Impl(); - - sal_uInt32 nTemp; - - // Copy. - rStrm.ReadUInt32( nTemp ); - m_nDocSize = nTemp; - m_aDocName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rStrm, RTL_TEXTENCODING_UTF8); - - sal_uIntPtr n = 0; - rStrm.ReadUInt32( nTemp ); - n = nTemp; - - for (sal_uIntPtr i = 0; i < n; i++) - { - INetMessageHeader *p = new INetMessageHeader(); - ReadINetMessageHeader( rStrm, *p ); - m_aHeaderList.push_back( p ); - } - - for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) - { - rStrm.ReadUInt32( nTemp ); - m_nIndex[i] = nTemp; - } - - return rStrm; -} - static const char* ImplINetMIMEMessageHeaderData[] = { "MIME-Version", @@ -615,18 +528,25 @@ enum _ImplINetMIMEMessageHeaderState }; INetMIMEMessage::INetMIMEMessage() - : INetRFC822Message (), - pParent (NULL), - bHeaderParsed (false) + : m_nDocSize(0), + pParent(NULL), + bHeaderParsed(false) { + for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) + m_nRFC822Index[i] = CONTAINER_ENTRY_NOTFOUND; for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) - m_nIndex[i] = CONTAINER_ENTRY_NOTFOUND; + m_nMIMEIndex[i] = CONTAINER_ENTRY_NOTFOUND; } INetMIMEMessage::INetMIMEMessage (const INetMIMEMessage& rMsg) - : INetRFC822Message (rMsg) - , pParent(NULL) + : m_nDocSize(rMsg.m_nDocSize), + m_aDocName(rMsg.m_aDocName), + m_xDocLB(rMsg.m_xDocLB), + pParent(NULL) { + ListCopy (rMsg); + for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) + m_nRFC822Index[i] = rMsg.m_nRFC822Index[i]; CopyImp (rMsg); } @@ -635,9 +555,12 @@ INetMIMEMessage& INetMIMEMessage::operator= ( { if (this != &rMsg) { - // Assign base. - INetRFC822Message::operator= (rMsg); - + m_nDocSize = rMsg.m_nDocSize; + m_aDocName = rMsg.m_aDocName; + m_xDocLB = rMsg.m_xDocLB; + ListCopy (rMsg); + for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) + m_nRFC822Index[i] = rMsg.m_nRFC822Index[i]; CleanupImp(); CopyImp (rMsg); } @@ -646,6 +569,7 @@ INetMIMEMessage& INetMIMEMessage::operator= ( INetMIMEMessage::~INetMIMEMessage() { + ListCleanup_Impl(); CleanupImp(); } @@ -663,7 +587,7 @@ void INetMIMEMessage::CopyImp (const INetMIMEMessage& rMsg) size_t i; for (i = 0; i < INETMSG_MIME_NUMHDR; i++) - m_nIndex[i] = rMsg.m_nIndex[i]; + m_nMIMEIndex[i] = rMsg.m_nMIMEIndex[i]; m_aBoundary = rMsg.m_aBoundary; @@ -819,14 +743,13 @@ sal_uIntPtr INetMIMEMessage::SetHeaderField ( pData = pStop; SetHeaderField_Impl ( INetMessageHeader( ImplINetMIMEMessageHeaderData[nIdx], rHeader.GetValue()), - m_nIndex[nIdx]); - nNewIndex = m_nIndex[nIdx]; + m_nMIMEIndex[nIdx]); + nNewIndex = m_nMIMEIndex[nIdx]; break; default: // INETMSG_MIME_JUNK pData = pStop; - nNewIndex = INetRFC822Message::SetHeaderField ( - rHeader, nNewIndex); + nNewIndex = SetRFC822HeaderField(rHeader, nNewIndex); break; } } @@ -838,7 +761,7 @@ void INetMIMEMessage::SetMIMEVersion (const OUString& rVersion) SetHeaderField_Impl ( INetMIME::HEADER_FIELD_TEXT, ImplINetMIMEMessageHeaderData[INETMSG_MIME_VERSION], rVersion, - m_nIndex[INETMSG_MIME_VERSION]); + m_nMIMEIndex[INETMSG_MIME_VERSION]); } void INetMIMEMessage::SetContentDisposition (const OUString& rDisposition) @@ -846,7 +769,7 @@ void INetMIMEMessage::SetContentDisposition (const OUString& rDisposition) SetHeaderField_Impl ( INetMIME::HEADER_FIELD_TEXT, ImplINetMIMEMessageHeaderData[INETMSG_MIME_CONTENT_DISPOSITION], rDisposition, - m_nIndex[INETMSG_MIME_CONTENT_DISPOSITION]); + m_nMIMEIndex[INETMSG_MIME_CONTENT_DISPOSITION]); } void INetMIMEMessage::SetContentType (const OUString& rType) @@ -854,7 +777,7 @@ void INetMIMEMessage::SetContentType (const OUString& rType) SetHeaderField_Impl ( INetMIME::HEADER_FIELD_TEXT, ImplINetMIMEMessageHeaderData[INETMSG_MIME_CONTENT_TYPE], rType, - m_nIndex[INETMSG_MIME_CONTENT_TYPE]); + m_nMIMEIndex[INETMSG_MIME_CONTENT_TYPE]); } void INetMIMEMessage::SetContentTransferEncoding ( @@ -863,7 +786,7 @@ void INetMIMEMessage::SetContentTransferEncoding ( SetHeaderField_Impl ( INetMIME::HEADER_FIELD_TEXT, ImplINetMIMEMessageHeaderData[INETMSG_MIME_CONTENT_TRANSFER_ENCODING], rEncoding, - m_nIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]); + m_nMIMEIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]); } OUString INetMIMEMessage::GetDefaultContentType() @@ -959,31 +882,67 @@ bool INetMIMEMessage::AttachChild(INetMIMEMessage& rChildMsg, bool bOwner) return false; } -SvStream& INetMIMEMessage::operator<< (SvStream& rStrm) const +SvStream& operator <<(SvStream& rStrm, const INetMIMEMessage& rMsg) { - INetRFC822Message::operator<< (rStrm); + rStrm.WriteUInt32( rMsg.m_nDocSize ); + write_uInt16_lenPrefixed_uInt8s_FromOUString(rStrm, rMsg.m_aDocName, RTL_TEXTENCODING_UTF8); + + sal_uIntPtr n = rMsg.m_aHeaderList.size(); + rStrm.WriteUInt32( n ); + + for (sal_uIntPtr i = 0; i < n; i++) + WriteINetMessageHeader( rStrm, *( rMsg.m_aHeaderList[ i ] ) ); + + for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) + rStrm.WriteUInt32( rMsg.m_nRFC822Index[i] ); for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) - rStrm.WriteUInt32( m_nIndex[i] ); + rStrm.WriteUInt32( rMsg.m_nMIMEIndex[i] ); - write_uInt16_lenPrefixed_uInt8s_FromOString(rStrm, m_aBoundary); - rStrm.WriteUInt32( aChildren.size() ); + write_uInt16_lenPrefixed_uInt8s_FromOString(rStrm, rMsg.m_aBoundary); + rStrm.WriteUInt32( rMsg.aChildren.size() ); return rStrm; } -SvStream& INetMIMEMessage::operator>> (SvStream& rStrm) +SvStream& operator >>(SvStream& rStrm, INetMIMEMessage& rMsg) { - INetRFC822Message::operator>> (rStrm); + // Cleanup. + rMsg.m_nDocSize = 0; + rMsg.m_xDocLB.Clear(); + rMsg.ListCleanup_Impl(); sal_uInt32 nTemp; + + // Copy. + rStrm.ReadUInt32( nTemp ); + rMsg.m_nDocSize = nTemp; + rMsg.m_aDocName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rStrm, RTL_TEXTENCODING_UTF8); + + sal_uIntPtr n = 0; + rStrm.ReadUInt32( nTemp ); + n = nTemp; + + for (sal_uIntPtr i = 0; i < n; i++) + { + INetMessageHeader *p = new INetMessageHeader(); + ReadINetMessageHeader( rStrm, *p ); + rMsg.m_aHeaderList.push_back( p ); + } + + for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) + { + rStrm.ReadUInt32( nTemp ); + rMsg.m_nRFC822Index[i] = nTemp; + } + for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) { rStrm.ReadUInt32( nTemp ); - m_nIndex[i] = nTemp; + rMsg.m_nMIMEIndex[i] = nTemp; } - m_aBoundary = read_uInt16_lenPrefixed_uInt8s_ToOString(rStrm); + rMsg.m_aBoundary = read_uInt16_lenPrefixed_uInt8s_ToOString(rStrm); rStrm.ReadUInt32( nTemp ); diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index 8764622..a6fbf23 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -485,7 +485,7 @@ INetMessageEncodeQPStream_Impl::~INetMessageEncodeQPStream_Impl(void) int INetMessageEncodeQPStream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize) { - INetRFC822Message* pMsg = GetSourceMessage(); + INetMIMEMessage* pMsg = GetSourceMessage(); if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; if (pMsg->GetDocumentLB() == NULL) return 0; @@ -693,7 +693,7 @@ INetMessageDecodeQPStream_Impl::~INetMessageDecodeQPStream_Impl(void) int INetMessageDecodeQPStream_Impl::PutMsgLine( const sal_Char* pData, sal_uIntPtr nSize) { - INetRFC822Message* pMsg = GetTargetMessage(); + INetMIMEMessage* pMsg = GetTargetMessage(); if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB()); @@ -807,7 +807,7 @@ INetMessageEncode64Stream_Impl::~INetMessageEncode64Stream_Impl(void) int INetMessageEncode64Stream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize) { - INetRFC822Message* pMsg = GetSourceMessage(); + INetMIMEMessage* pMsg = GetSourceMessage(); if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; if (pMsg->GetDocumentLB() == NULL) return 0; @@ -993,7 +993,7 @@ INetMessageDecode64Stream_Impl::~INetMessageDecode64Stream_Impl(void) int INetMessageDecode64Stream_Impl::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) { - INetRFC822Message* pMsg = GetTargetMessage(); + INetMIMEMessage* pMsg = GetTargetMessage(); if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB()); diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx index 1fcf878..a4f8c1f 100644 --- a/unotools/source/ucbhelper/ucblockbytes.cxx +++ b/unotools/source/ucbhelper/ucblockbytes.cxx @@ -196,7 +196,7 @@ void SAL_CALL UcbPropertiesChangeListener_Impl::propertiesChange ( const Sequenc if (aName.compareToIgnoreAsciiCaseAscii("Expires") == 0) { DateTime aExpires (0, 0); - if (INetRFC822Message::ParseDateField (aValue, aExpires)) + if (INetMIMEMessage::ParseDateField (aValue, aExpires)) { aExpires.ConvertToLocalTime(); m_xLockBytes->SetExpireDate_Impl( aExpires ); commit 3939b6d64df3b7ca495d0afb06876e5f5a492116 Author: Stephan Bergmann <[email protected]> Date: Wed Feb 11 15:14:23 2015 +0100 Fold INetMessage into INetRFC822Message Change-Id: I89ba13c02954364044b215ba7df7c563720b92f9 diff --git a/include/tools/inetmsg.hxx b/include/tools/inetmsg.hxx index 912595c..fb6370a 100644 --- a/include/tools/inetmsg.hxx +++ b/include/tools/inetmsg.hxx @@ -81,7 +81,25 @@ public: typedef ::std::vector< INetMessageHeader* > HeaderList_impl; -class INetMessage +#define INETMSG_RFC822_BCC 0 +#define INETMSG_RFC822_CC 1 +#define INETMSG_RFC822_COMMENTS 2 +#define INETMSG_RFC822_DATE 3 +#define INETMSG_RFC822_FROM 4 +#define INETMSG_RFC822_IN_REPLY_TO 5 +#define INETMSG_RFC822_KEYWORDS 6 +#define INETMSG_RFC822_MESSAGE_ID 7 +#define INETMSG_RFC822_REFERENCES 8 +#define INETMSG_RFC822_REPLY_TO 9 +#define INETMSG_RFC822_RETURN_PATH 10 +#define INETMSG_RFC822_SENDER 11 +#define INETMSG_RFC822_SUBJECT 12 +#define INETMSG_RFC822_TO 13 +#define INETMSG_RFC822_X_MAILER 14 +#define INETMSG_RFC822_RETURN_RECEIPT_TO 15 +#define INETMSG_RFC822_NUMHDR 16 + +class TOOLS_DLLPUBLIC INetRFC822Message { HeaderList_impl m_aHeaderList; @@ -90,7 +108,9 @@ class INetMessage SvLockBytesRef m_xDocLB; void ListCleanup_Impl(); - void ListCopy (const INetMessage& rMsg); + void ListCopy (const INetRFC822Message& rMsg); + + sal_uIntPtr m_nIndex[INETMSG_RFC822_NUMHDR]; protected: OUString GetHeaderName_Impl ( @@ -139,25 +159,11 @@ protected: virtual SvStream& operator>> (SvStream& rStrm); public: - INetMessage() : m_nDocSize(0) {} - virtual ~INetMessage(); - - INetMessage (const INetMessage& rMsg) - : m_nDocSize (rMsg.m_nDocSize), - m_aDocName (rMsg.m_aDocName), - m_xDocLB (rMsg.m_xDocLB) - { - ListCopy (rMsg); - } + INetRFC822Message(); + INetRFC822Message (const INetRFC822Message& rMsg); + virtual ~INetRFC822Message(); - INetMessage& operator= (const INetMessage& rMsg) - { - m_nDocSize = rMsg.m_nDocSize; - m_aDocName = rMsg.m_aDocName; - m_xDocLB = rMsg.m_xDocLB; - ListCopy (rMsg); - return *this; - } + INetRFC822Message& operator= (const INetRFC822Message& rMsg); sal_uIntPtr GetHeaderCount() const { return m_aHeaderList.size(); } @@ -194,61 +200,9 @@ public: SvLockBytes* GetDocumentLB() const { return m_xDocLB; } void SetDocumentLB (SvLockBytes *pDocLB) { m_xDocLB = pDocLB; } - friend SvStream& WriteINetMessage( - SvStream& rStrm, const INetMessage& rMsg) - { - return rMsg.operator<< (rStrm); - } - - friend SvStream& ReadINetMessage ( - SvStream& rStrm, INetMessage& rMsg) - { - return rMsg.operator>> (rStrm); - } -}; - -#define INETMSG_RFC822_BCC 0 -#define INETMSG_RFC822_CC 1 -#define INETMSG_RFC822_COMMENTS 2 -#define INETMSG_RFC822_DATE 3 -#define INETMSG_RFC822_FROM 4 -#define INETMSG_RFC822_IN_REPLY_TO 5 -#define INETMSG_RFC822_KEYWORDS 6 -#define INETMSG_RFC822_MESSAGE_ID 7 -#define INETMSG_RFC822_REFERENCES 8 -#define INETMSG_RFC822_REPLY_TO 9 -#define INETMSG_RFC822_RETURN_PATH 10 -#define INETMSG_RFC822_SENDER 11 -#define INETMSG_RFC822_SUBJECT 12 -#define INETMSG_RFC822_TO 13 -#define INETMSG_RFC822_X_MAILER 14 -#define INETMSG_RFC822_RETURN_RECEIPT_TO 15 -#define INETMSG_RFC822_NUMHDR 16 - -class TOOLS_DLLPUBLIC INetRFC822Message : public INetMessage -{ - sal_uIntPtr m_nIndex[INETMSG_RFC822_NUMHDR]; - -protected: - virtual SvStream& operator<< (SvStream& rStrm) const SAL_OVERRIDE; - virtual SvStream& operator>> (SvStream& rStrm) SAL_OVERRIDE; - -public: - INetRFC822Message(); - INetRFC822Message (const INetRFC822Message& rMsg); - virtual ~INetRFC822Message(); - - INetRFC822Message& operator= (const INetRFC822Message& rMsg); - static bool ParseDateField ( const OUString& rDateField, DateTime& rDateTime); - using INetMessage::SetHeaderField; - virtual sal_uIntPtr SetHeaderField ( - const INetMessageHeader &rHeader, - sal_uIntPtr nIndex = ((sal_uIntPtr)-1) - ) SAL_OVERRIDE; - // Header fields. OUString GetBCC() const @@ -358,6 +312,18 @@ public: // Stream operators. + friend SvStream& WriteINetMessage( + SvStream& rStrm, const INetRFC822Message& rMsg) + { + return rMsg.operator<< (rStrm); + } + + friend SvStream& ReadINetMessage ( + SvStream& rStrm, INetRFC822Message& rMsg) + { + return rMsg.operator>> (rStrm); + } + friend SvStream& operator<< ( SvStream& rStrm, const INetRFC822Message& rMsg) { diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx index 6801293..b5c4e04 100644 --- a/include/tools/inetstrm.hxx +++ b/include/tools/inetstrm.hxx @@ -23,7 +23,7 @@ #include <sal/types.h> #include <rtl/ustring.hxx> -class INetMessage; +class INetRFC822Message; class INetMIMEMessage; class SvMemoryStream; class SvStream; @@ -81,7 +81,7 @@ enum INetMessageStreamState /// Message Generator Interface. class INetMessageIStream : public INetIStream { - INetMessage *pSourceMsg; + INetRFC822Message *pSourceMsg; bool bHeaderGenerated; sal_uIntPtr nBufSiz; @@ -106,8 +106,8 @@ public: INetMessageIStream (sal_uIntPtr nBufferSize = 2048); virtual ~INetMessageIStream (void); - INetMessage *GetSourceMessage (void) const { return pSourceMsg; } - void SetSourceMessage (INetMessage *pMsg) { pSourceMsg = pMsg; } + INetRFC822Message *GetSourceMessage (void) const { return pSourceMsg; } + void SetSourceMessage (INetRFC822Message *pMsg) { pSourceMsg = pMsg; } void GenerateHeader (bool bGen = true) { bHeaderGenerated = !bGen; } bool IsHeaderGenerated (void) const { return bHeaderGenerated; } @@ -116,7 +116,7 @@ public: /// Message Parser Interface. class INetMessageOStream : public INetOStream { - INetMessage *pTargetMsg; + INetRFC822Message *pTargetMsg; bool bHeaderParsed; INetMessageStreamState eOState; @@ -135,8 +135,8 @@ public: INetMessageOStream (void); virtual ~INetMessageOStream (void); - INetMessage *GetTargetMessage (void) const { return pTargetMsg; } - void SetTargetMessage (INetMessage *pMsg) { pTargetMsg = pMsg; } + INetRFC822Message *GetTargetMessage (void) const { return pTargetMsg; } + void SetTargetMessage (INetRFC822Message *pMsg) { pTargetMsg = pMsg; } void ParseHeader (bool bParse = true) { bHeaderParsed = !bParse; } bool IsHeaderParsed (void) const { return bHeaderParsed; } @@ -193,7 +193,7 @@ public: using INetMessageIStream::SetSourceMessage; void SetSourceMessage (INetMIMEMessage *pMsg) { - INetMessageIStream::SetSourceMessage ((INetMessage *)pMsg); + INetMessageIStream::SetSourceMessage ((INetRFC822Message *)pMsg); } INetMIMEMessage *GetSourceMessage (void) const { @@ -203,7 +203,7 @@ public: using INetMessageOStream::SetTargetMessage; void SetTargetMessage (INetMIMEMessage *pMsg) { - INetMessageOStream::SetTargetMessage ((INetMessage *)pMsg); + INetMessageOStream::SetTargetMessage ((INetRFC822Message *)pMsg); } INetMIMEMessage *GetTargetMessage (void) const { diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index 42c7a5f..a710bc2 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -48,12 +48,7 @@ inline sal_Unicode ascii_toLowerCase( sal_Unicode ch ) return ch; } -INetMessage::~INetMessage() -{ - ListCleanup_Impl(); -} - -void INetMessage::ListCleanup_Impl() +void INetRFC822Message::ListCleanup_Impl() { // Cleanup. sal_uIntPtr i, n = m_aHeaderList.size(); @@ -62,7 +57,7 @@ void INetMessage::ListCleanup_Impl() m_aHeaderList.clear(); } -void INetMessage::ListCopy (const INetMessage &rMsg) +void INetRFC822Message::ListCopy (const INetRFC822Message &rMsg) { if (!(this == &rMsg)) { @@ -79,7 +74,7 @@ void INetMessage::ListCopy (const INetMessage &rMsg) } } -void INetMessage::SetHeaderField_Impl ( +void INetRFC822Message::SetHeaderField_Impl ( INetMIME::HeaderFieldType eType, const OString &rName, const OUString &rValue, @@ -92,57 +87,6 @@ void INetMessage::SetHeaderField_Impl ( INetMessageHeader (rName, aSink.takeBuffer()), rnIndex); } -sal_uIntPtr INetMessage::SetHeaderField ( - const INetMessageHeader &rHeader, sal_uIntPtr nIndex) -{ - sal_uIntPtr nResult = nIndex; - SetHeaderField_Impl (rHeader, nResult); - return nResult; -} - -SvStream& INetMessage::operator<< (SvStream& rStrm) const -{ - rStrm.WriteUInt32( m_nDocSize ); - write_uInt16_lenPrefixed_uInt8s_FromOUString(rStrm, m_aDocName, RTL_TEXTENCODING_UTF8); - - sal_uIntPtr i, n = m_aHeaderList.size(); - rStrm.WriteUInt32( n ); - - for (i = 0; i < n; i++) - WriteINetMessageHeader( rStrm, *( m_aHeaderList[ i ] ) ); - - return rStrm; -} - -SvStream& INetMessage::operator>> (SvStream& rStrm) -{ - // Cleanup. - m_nDocSize = 0; - m_xDocLB.Clear(); - ListCleanup_Impl(); - - sal_uInt32 nTemp; - - // Copy. - rStrm.ReadUInt32( nTemp ); - m_nDocSize = nTemp; - m_aDocName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rStrm, RTL_TEXTENCODING_UTF8); - - sal_uIntPtr i, n = 0; - rStrm.ReadUInt32( nTemp ); - n = nTemp; - - for (i = 0; i < n; i++) - { - INetMessageHeader *p = new INetMessageHeader(); - ReadINetMessageHeader( rStrm, *p ); - m_aHeaderList.push_back( p ); - } - - // Done. - return rStrm; -} - static const char * ImplINetRFC822MessageHeaderData[] = { "BCC", @@ -178,15 +122,18 @@ enum _ImplINetRFC822MessageHeaderState }; INetRFC822Message::INetRFC822Message() - : INetMessage() + : m_nDocSize(0) { for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) m_nIndex[i] = CONTAINER_ENTRY_NOTFOUND; } INetRFC822Message::INetRFC822Message (const INetRFC822Message& rMsg) - : INetMessage (rMsg) + : m_nDocSize (rMsg.m_nDocSize), + m_aDocName (rMsg.m_aDocName), + m_xDocLB (rMsg.m_xDocLB) { + ListCopy (rMsg); for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) m_nIndex[i] = rMsg.m_nIndex[i]; } @@ -195,8 +142,10 @@ INetRFC822Message& INetRFC822Message::operator= (const INetRFC822Message& rMsg) { if (this != &rMsg) { - INetMessage::operator= (rMsg); - + m_nDocSize = rMsg.m_nDocSize; + m_aDocName = rMsg.m_aDocName; + m_xDocLB = rMsg.m_xDocLB; + ListCopy (rMsg); for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) m_nIndex[i] = rMsg.m_nIndex[i]; } @@ -205,6 +154,7 @@ INetRFC822Message& INetRFC822Message::operator= (const INetRFC822Message& rMsg) INetRFC822Message::~INetRFC822Message() { + ListCleanup_Impl(); } /* ParseDateField and local helper functions. @@ -584,7 +534,7 @@ sal_uIntPtr INetRFC822Message::SetHeaderField ( default: // INETMSG_RFC822_JUNK pData = pStop; - nNewIndex = INetMessage::SetHeaderField (rHeader, nNewIndex); + SetHeaderField_Impl(rHeader, nNewIndex); break; } } @@ -593,7 +543,14 @@ sal_uIntPtr INetRFC822Message::SetHeaderField ( SvStream& INetRFC822Message::operator<< (SvStream& rStrm) const { - INetMessage::operator<< (rStrm); + rStrm.WriteUInt32( m_nDocSize ); + write_uInt16_lenPrefixed_uInt8s_FromOUString(rStrm, m_aDocName, RTL_TEXTENCODING_UTF8); + + sal_uIntPtr n = m_aHeaderList.size(); + rStrm.WriteUInt32( n ); + + for (sal_uIntPtr i = 0; i < n; i++) + WriteINetMessageHeader( rStrm, *( m_aHeaderList[ i ] ) ); for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) rStrm.WriteUInt32( m_nIndex[i] ); @@ -603,9 +560,29 @@ SvStream& INetRFC822Message::operator<< (SvStream& rStrm) const SvStream& INetRFC822Message::operator>> (SvStream& rStrm) { - INetMessage::operator>> (rStrm); + // Cleanup. + m_nDocSize = 0; + m_xDocLB.Clear(); + ListCleanup_Impl(); sal_uInt32 nTemp; + + // Copy. + rStrm.ReadUInt32( nTemp ); + m_nDocSize = nTemp; + m_aDocName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rStrm, RTL_TEXTENCODING_UTF8); + + sal_uIntPtr n = 0; + rStrm.ReadUInt32( nTemp ); + n = nTemp; + + for (sal_uIntPtr i = 0; i < n; i++) + { + INetMessageHeader *p = new INetMessageHeader(); + ReadINetMessageHeader( rStrm, *p ); + m_aHeaderList.push_back( p ); + } + for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) { rStrm.ReadUInt32( nTemp ); diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index bb34374..8764622 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -485,7 +485,7 @@ INetMessageEncodeQPStream_Impl::~INetMessageEncodeQPStream_Impl(void) int INetMessageEncodeQPStream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize) { - INetMessage* pMsg = GetSourceMessage(); + INetRFC822Message* pMsg = GetSourceMessage(); if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; if (pMsg->GetDocumentLB() == NULL) return 0; @@ -693,7 +693,7 @@ INetMessageDecodeQPStream_Impl::~INetMessageDecodeQPStream_Impl(void) int INetMessageDecodeQPStream_Impl::PutMsgLine( const sal_Char* pData, sal_uIntPtr nSize) { - INetMessage* pMsg = GetTargetMessage(); + INetRFC822Message* pMsg = GetTargetMessage(); if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB()); @@ -807,7 +807,7 @@ INetMessageEncode64Stream_Impl::~INetMessageEncode64Stream_Impl(void) int INetMessageEncode64Stream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize) { - INetMessage* pMsg = GetSourceMessage(); + INetRFC822Message* pMsg = GetSourceMessage(); if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; if (pMsg->GetDocumentLB() == NULL) return 0; @@ -993,7 +993,7 @@ INetMessageDecode64Stream_Impl::~INetMessageDecode64Stream_Impl(void) int INetMessageDecode64Stream_Impl::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) { - INetMessage* pMsg = GetTargetMessage(); + INetRFC822Message* pMsg = GetTargetMessage(); if (pMsg == NULL) return INETSTREAM_STATUS_ERROR; SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB()); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
