[Libreoffice-commits] core.git: 10 commits - forms/source include/rtl include/tools sal/CppunitTest_sal_rtl_strings.mk sal/qa sw/inc sw/source tools/source
Stephan Bergmann
sbergman at redhat.com
Thu Sep 10 14:04:59 PDT 2015
forms/source/component/DatabaseForm.cxx | 11
include/rtl/string.hxx | 49 +
include/tools/inetmsg.hxx | 130 --
include/tools/inetstrm.hxx | 105 --
sal/CppunitTest_sal_rtl_strings.mk | 1
sal/qa/rtl/strings/test_ostring.cxx | 92 +
sw/inc/fesh.hxx | 2
sw/source/core/frmedt/fefly1.cxx | 2
sw/source/uibase/shells/basesh.cxx | 2
tools/source/inet/inetmsg.cxx | 602 ------------
tools/source/inet/inetstrm.cxx | 1513 ++------------------------------
11 files changed, 324 insertions(+), 2185 deletions(-)
New commits:
commit 62f489c88ea0067adb0f6762c6bc331c2c51005d
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Sep 10 22:13:08 2015 +0200
loplugin:staticmethods
Change-Id: I00acce39f94653ef8e2465f15ba572b619a1c7fb
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index 6e66129..2cda774 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -380,7 +380,7 @@ public:
bool IsFrmSelected() const;
bool GetFlyFrmAttr( SfxItemSet &rSet ) const;
bool SetFlyFrmAttr( SfxItemSet &rSet );
- SfxItemSet makeItemSetFromFormatAnchor(SfxItemPool& rPool, const SwFormatAnchor &rAnchor) const;
+ static SfxItemSet makeItemSetFromFormatAnchor(SfxItemPool& rPool, const SwFormatAnchor &rAnchor);
bool ResetFlyFrmAttr( sal_uInt16 nWhich, const SfxItemSet* pSet = 0 );
const SwFrameFormat *NewFlyFrm( const SfxItemSet &rSet, bool bAnchValid = false,
SwFrameFormat *pParent = 0 );
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 3f126fb..d1cda53 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -1053,7 +1053,7 @@ bool SwFEShell::SetFlyFrmAttr( SfxItemSet& rSet )
return bRet;
}
-SfxItemSet SwFEShell::makeItemSetFromFormatAnchor(SfxItemPool& rPool, const SwFormatAnchor &rAnchor) const
+SfxItemSet SwFEShell::makeItemSetFromFormatAnchor(SfxItemPool& rPool, const SwFormatAnchor &rAnchor)
{
// The set also includes VERT/HORI_ORIENT, because the align
// shall be changed in FEShell::SetFlyFrmAttr/SetFlyFrmAnchor,
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 07eb9ee..92898c5 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -1013,7 +1013,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
else if (rSh.IsFrmSelected())
{
SwFormatAnchor aAnc(eSet, rSh.GetPhyPageNum());
- SfxItemSet aSet(rSh.makeItemSetFromFormatAnchor(GetPool(), aAnc));
+ SfxItemSet aSet(SwFEShell::makeItemSetFromFormatAnchor(GetPool(), aAnc));
rSh.SetFlyFrmAttr(aSet);
}
// if new anchor is 'as char' and it is a Math object and the usual
commit 1a9293242b90920b24880cbc69406296cae581df
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Sep 10 20:45:41 2015 +0200
Remove unused INetMIMEMessage parts
Change-Id: Ica7d3e7e52ccdfe833ac10567c6f5f7bb7085dee
diff --git a/include/tools/inetmsg.hxx b/include/tools/inetmsg.hxx
index 3d3002c..fa4d159 100644
--- a/include/tools/inetmsg.hxx
+++ b/include/tools/inetmsg.hxx
@@ -50,9 +50,6 @@ public:
: m_aName (rHdr.m_aName), m_aValue (rHdr.m_aValue)
{}
- ~INetMessageHeader()
- {}
-
INetMessageHeader& operator= (const INetMessageHeader& rHdr)
{
m_aName = rHdr.m_aName;
@@ -62,57 +59,15 @@ public:
const OString& GetName() const { return m_aName; }
const OString& GetValue() const { return m_aValue; }
-
- friend SvStream& WriteINetMessageHeader(
- SvStream& rStrm, const INetMessageHeader& rHdr)
- {
- write_uInt16_lenPrefixed_uInt8s_FromOString(rStrm, rHdr.m_aName);
- write_uInt16_lenPrefixed_uInt8s_FromOString(rStrm, rHdr.m_aValue);
- return rStrm;
- }
-
- friend SvStream& ReadINetMessageHeader (
- SvStream& rStrm, INetMessageHeader& rHdr)
- {
- rHdr.m_aName = read_uInt16_lenPrefixed_uInt8s_ToOString(rStrm);
- rHdr.m_aValue = read_uInt16_lenPrefixed_uInt8s_ToOString(rStrm);
- return rStrm;
- }
-};
-
-/**
- RFC822 fields
-*/
-enum class InetMessageField
-{
- BCC = 0,
- CC = 1,
- COMMENTS = 2,
- DATE = 3,
- FROM = 4,
- IN_REPLY_TO = 5,
- KEYWORDS = 6,
- MESSAGE_ID = 7,
- REFERENCES = 8,
- REPLY_TO = 9,
- RETURN_PATH = 10,
- SENDER = 11,
- SUBJECT = 12,
- TO = 13,
- X_MAILER = 14,
- RETURN_RECEIPT_TO = 15,
- NUMHDR = 16,
};
enum class InetMessageMime
{
VERSION = 0,
- CONTENT_DESCRIPTION = 1,
- CONTENT_DISPOSITION = 2,
- CONTENT_ID = 3,
- CONTENT_TYPE = 4,
- CONTENT_TRANSFER_ENCODING = 5,
- NUMHDR = 6,
+ CONTENT_DISPOSITION = 1,
+ CONTENT_TYPE = 2,
+ CONTENT_TRANSFER_ENCODING = 3,
+ NUMHDR = 4,
};
class TOOLS_DLLPUBLIC INetMIMEMessage
@@ -120,29 +75,12 @@ class TOOLS_DLLPUBLIC INetMIMEMessage
::std::vector< INetMessageHeader* >
m_aHeaderList;
- sal_uIntPtr m_nDocSize;
- OUString m_aDocName;
SvLockBytesRef m_xDocLB;
- void ListCleanup_Impl();
- void ListCopy (const INetMIMEMessage& rMsg);
-
- ::std::map<InetMessageField, sal_uIntPtr> m_nRFC822Index;
-
::std::map<InetMessageMime, sal_uIntPtr> m_nMIMEIndex;
INetMIMEMessage* pParent;
::std::vector< INetMIMEMessage* > 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; }
OUString GetHeaderValue_Impl (
sal_uIntPtr nIndex, INetMIME::HeaderFieldType eType) const
@@ -176,23 +114,21 @@ class TOOLS_DLLPUBLIC INetMIMEMessage
const OUString &rValue,
sal_uIntPtr &rnIndex);
- sal_uIntPtr SetRFC822HeaderField (
- const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex);
+ bool IsMessage() const
+ {
+ OUString aType (GetContentType());
+ return aType.matchIgnoreAsciiCase("message/");
+ }
+
+ INetMIMEMessage (const INetMIMEMessage& rMsg) = delete;
+ INetMIMEMessage& operator= (const INetMIMEMessage& rMsg) = delete;
public:
INetMIMEMessage();
- INetMIMEMessage (const INetMIMEMessage& rMsg);
~INetMIMEMessage();
- INetMIMEMessage& operator= (const INetMIMEMessage& rMsg);
-
sal_uIntPtr GetHeaderCount() const { return m_aHeaderList.size(); }
- OUString GetHeaderValue (sal_uIntPtr nIndex) const
- {
- return GetHeaderValue_Impl (nIndex, INetMIME::HEADER_FIELD_TEXT);
- }
-
INetMessageHeader GetHeaderField (sal_uIntPtr nIndex) const
{
if ( nIndex < m_aHeaderList.size() ) {
@@ -202,36 +138,23 @@ public:
}
}
- sal_uIntPtr SetHeaderField (
- const INetMessageHeader &rField,
- sal_uIntPtr nIndex = ((sal_uIntPtr)-1)
- );
-
- sal_uIntPtr GetDocumentSize() const { return m_nDocSize; }
- void SetDocumentSize (sal_uIntPtr nSize) { m_nDocSize = nSize; }
-
SvLockBytes* GetDocumentLB() const { return m_xDocLB; }
void SetDocumentLB (SvLockBytes *pDocLB) { m_xDocLB = pDocLB; }
static bool ParseDateField (
const OUString& rDateField, DateTime& rDateTime);
- static INetMIMEMessage* CreateMessage (
- const INetMIMEMessage& rMsg);
-
void SetMIMEVersion (const OUString& rVersion);
void SetContentDisposition (const OUString& rDisposition);
void SetContentType (const OUString& rType);
OUString GetContentType() const
{
- return GetHeaderValue (m_nMIMEIndex.at(InetMessageMime::CONTENT_TYPE));
+ return GetHeaderValue_Impl(
+ m_nMIMEIndex.at(InetMessageMime::CONTENT_TYPE),
+ INetMIME::HEADER_FIELD_TEXT);
}
void SetContentTransferEncoding (const OUString& rEncoding);
- OUString GetContentTransferEncoding() const
- {
- return GetHeaderValue (m_nMIMEIndex.at(InetMessageMime::CONTENT_TRANSFER_ENCODING));
- }
OUString GetDefaultContentType ();
@@ -241,11 +164,6 @@ public:
{
return (IsMessage() || IsMultipart());
}
- bool IsMessage() const
- {
- OUString aType (GetContentType());
- return aType.matchIgnoreAsciiCase("message/");
- }
bool IsMultipart() const
{
OUString aType (GetContentType());
@@ -261,6 +179,8 @@ public:
bool EnableAttachMultipartFormDataChild();
bool AttachChild (
INetMIMEMessage& rChildMsg, bool bOwner = true );
+
+ const OString& GetMultipartBoundary() const { return m_aBoundary; }
};
#endif
diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx
index bf12438..099e6bf 100644
--- a/tools/source/inet/inetmsg.cxx
+++ b/tools/source/inet/inetmsg.cxx
@@ -40,40 +40,6 @@ inline bool ascii_isLetter( sal_Unicode ch )
return (( (ch >= 0x0041) && (ch <= 0x005A)) || ((ch >= 0x0061) && (ch <= 0x007A)));
}
-inline sal_Unicode ascii_toLowerCase( sal_Unicode ch )
-{
- if ( (ch >= 0x0041) && (ch <= 0x005A) )
- return ch + 0x20;
- else
- return ch;
-}
-
-void INetMIMEMessage::ListCleanup_Impl()
-{
- // Cleanup.
- sal_uIntPtr i, n = m_aHeaderList.size();
- for (i = 0; i < n; i++)
- delete m_aHeaderList[ i ];
- m_aHeaderList.clear();
-}
-
-void INetMIMEMessage::ListCopy (const INetMIMEMessage &rMsg)
-{
- if (!(this == &rMsg))
- {
- // Cleanup.
- ListCleanup_Impl();
-
- // Copy.
- sal_uIntPtr i, n = rMsg.GetHeaderCount();
- for (i = 0; i < n; i++)
- {
- INetMessageHeader *p = rMsg.m_aHeaderList[ i ];
- m_aHeaderList.push_back( new INetMessageHeader(*p) );
- }
- }
-}
-
void INetMIMEMessage::SetHeaderField_Impl (
INetMIME::HeaderFieldType eType,
const OString &rName,
@@ -87,43 +53,6 @@ void INetMIMEMessage::SetHeaderField_Impl (
INetMessageHeader (rName, aSink.takeBuffer()), rnIndex);
}
-static const std::map<InetMessageField, const char *> ImplINetRFC822MessageHeaderData =
-{
- { InetMessageField::BCC, "BCC" } ,
- { InetMessageField::CC, "CC" } ,
- { InetMessageField::COMMENTS, "Comments" } ,
- { InetMessageField::DATE, "Date" } ,
- { InetMessageField::FROM, "From" } ,
- { InetMessageField::IN_REPLY_TO, "In-Reply-To" } ,
- { InetMessageField::KEYWORDS, "Keywords" } ,
- { InetMessageField::MESSAGE_ID, "Message-ID" } ,
- { InetMessageField::REFERENCES, "References" } ,
- { InetMessageField::REPLY_TO, "Reply-To" } ,
- { InetMessageField::RETURN_PATH, "Return-Path" } ,
- { InetMessageField::SUBJECT, "Subject" } ,
- { InetMessageField::SENDER, "Sender" } ,
- { InetMessageField::TO, "To" } ,
- { InetMessageField::X_MAILER, "X-Mailer" } ,
- { InetMessageField::RETURN_RECEIPT_TO, "Return-Receipt-To" } ,
-};
-
-/*
- State of RFC822 header parsing
-*/
-enum class HeaderState
-{
- BEGIN,
- CHECK,
- OK,
- JUNK,
-
- TOKEN_RE,
- TOKEN_RETURNMINUS,
- TOKEN_XMINUS,
- LETTER_C,
- LETTER_S
-};
-
/* ParseDateField and local helper functions.
*
* Parses a String in (implied) GMT format into class Date and tools::Time objects.
@@ -276,483 +205,29 @@ bool INetMIMEMessage::ParseDateField (
(rDateTime.GetHour() > 23) ));
}
-// Header Field Parser
-sal_uIntPtr INetMIMEMessage::SetRFC822HeaderField (
- const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex)
-{
- OString aName (rHeader.GetName());
- const sal_Char *pData = aName.getStr();
- const sal_Char *pStop = pData + aName.getLength() + 1;
- const sal_Char *check = "";
-
- InetMessageField nIdx = static_cast<InetMessageField>(CONTAINER_APPEND);
- HeaderState eState = HeaderState::BEGIN;
- HeaderState eOkState = HeaderState::OK;
-
- while (pData < pStop)
- {
- switch (eState)
- {
- case HeaderState::BEGIN:
- eState = HeaderState::CHECK;
- eOkState = HeaderState::OK;
-
- switch (ascii_toLowerCase (*pData))
- {
- case 'b':
- check = "cc";
- nIdx = InetMessageField::BCC;
- break;
-
- case 'c':
- eState = HeaderState::LETTER_C;
- break;
-
- case 'd':
- check = "ate";
- nIdx = InetMessageField::DATE;
- break;
-
- case 'f':
- check = "rom";
- nIdx = InetMessageField::FROM;
- break;
-
- case 'i':
- check = "n-reply-to";
- nIdx = InetMessageField::IN_REPLY_TO;
- break;
-
- case 'k':
- check = "eywords";
- nIdx = InetMessageField::KEYWORDS;
- break;
-
- case 'm':
- check = "essage-id";
- nIdx = InetMessageField::MESSAGE_ID;
- break;
-
- case 'r':
- check = "e";
- eOkState = HeaderState::TOKEN_RE;
- break;
-
- case 's':
- eState = HeaderState::LETTER_S;
- break;
-
- case 't':
- check = "o";
- nIdx = InetMessageField::TO;
- break;
-
- case 'x':
- check = "-";
- eOkState = HeaderState::TOKEN_XMINUS;
- break;
-
- default:
- eState = HeaderState::JUNK;
- break;
- }
- pData++;
- break;
-
- case HeaderState::TOKEN_RE:
- eState = HeaderState::CHECK;
- eOkState = HeaderState::OK;
-
- switch (ascii_toLowerCase (*pData))
- {
- case 'f':
- check = "erences";
- nIdx = InetMessageField::REFERENCES;
- break;
-
- case 'p':
- check = "ly-to";
- nIdx = InetMessageField::REPLY_TO;
- break;
-
- case 't':
- check = "urn-";
- eOkState = HeaderState::TOKEN_RETURNMINUS;
- break;
-
- default:
- eState = HeaderState::JUNK;
- break;
- }
- pData++;
- break;
-
- case HeaderState::TOKEN_RETURNMINUS:
- eState = HeaderState::CHECK;
- eOkState = HeaderState::OK;
-
- switch (ascii_toLowerCase (*pData))
- {
- case 'p':
- check = "ath";
- nIdx = InetMessageField::RETURN_PATH;
- break;
-
- case 'r':
- check = "eceipt-to";
- nIdx = InetMessageField::RETURN_RECEIPT_TO;
- break;
-
- default:
- eState = HeaderState::JUNK;
- break;
- }
- pData++;
- break;
-
- case HeaderState::TOKEN_XMINUS:
- eState = HeaderState::CHECK;
- eOkState = HeaderState::OK;
-
- switch (ascii_toLowerCase (*pData))
- {
- case 'm':
- check = "ailer";
- nIdx = InetMessageField::X_MAILER;
- break;
-
- default:
- eState = HeaderState::JUNK;
- break;
- }
- pData++;
- break;
-
- case HeaderState::LETTER_C:
- eState = HeaderState::CHECK;
- eOkState = HeaderState::OK;
-
- switch (ascii_toLowerCase (*pData))
- {
- case 'c':
- check = "";
- nIdx = InetMessageField::CC;
- break;
-
- case 'o':
- check = "mments";
- nIdx = InetMessageField::COMMENTS;
- break;
-
- default:
- eState = HeaderState::JUNK;
- break;
- }
- pData++;
- break;
-
- case HeaderState::LETTER_S:
- eState = HeaderState::CHECK;
- eOkState = HeaderState::OK;
-
- switch (ascii_toLowerCase (*pData))
- {
- case 'e':
- check = "nder";
- nIdx = InetMessageField::SENDER;
- break;
-
- case 'u':
- check = "bject";
- nIdx = InetMessageField::SUBJECT;
- break;
-
- default:
- eState = HeaderState::JUNK;
- break;
- }
- pData++;
- break;
-
- case HeaderState::CHECK:
- if (*check)
- {
- while (*pData && *check &&
- (ascii_toLowerCase (*pData) == *check))
- {
- pData++;
- check++;
- }
- }
- else
- {
- check = pData;
- }
- eState = (*check == '\0') ? eOkState : HeaderState::JUNK;
- break;
-
- case HeaderState::OK:
- pData = pStop;
- SetHeaderField_Impl (
- INetMessageHeader( ImplINetRFC822MessageHeaderData.at(nIdx), rHeader.GetValue() ),
- m_nRFC822Index[nIdx]);
- nNewIndex = m_nRFC822Index[nIdx];
- break;
-
- default: // INETMSG_RFC822_JUNK
- pData = pStop;
- SetHeaderField_Impl(rHeader, nNewIndex);
- break;
- }
- }
- return nNewIndex;
-}
-
static const std::map<InetMessageMime, const char*> ImplINetMIMEMessageHeaderData =
{
{ InetMessageMime::VERSION, "MIME-Version"},
- { InetMessageMime::CONTENT_DESCRIPTION, "Content-Description"},
{ InetMessageMime::CONTENT_DISPOSITION, "Content-Disposition"},
- { InetMessageMime::CONTENT_ID, "Content-ID"},
{ InetMessageMime::CONTENT_TYPE, "Content-Type"},
{ InetMessageMime::CONTENT_TRANSFER_ENCODING, "Content-Transfer-Encoding"}
};
-enum _ImplINetMIMEMessageHeaderState
-{
- INETMSG_MIME_BEGIN,
- INETMSG_MIME_CHECK,
- INETMSG_MIME_OK,
- INETMSG_MIME_JUNK,
-
- INETMSG_MIME_TOKEN_CONTENT,
- INETMSG_MIME_TOKEN_CONTENT_D,
- INETMSG_MIME_TOKEN_CONTENT_T
-};
-
INetMIMEMessage::INetMIMEMessage()
- : m_nDocSize(0),
- pParent(NULL),
- bHeaderParsed(false)
+ : pParent(NULL)
{
- for (sal_uInt16 i = 0; i < static_cast<int>(InetMessageField::NUMHDR); i++)
- m_nRFC822Index[static_cast<InetMessageField>(i)] = CONTAINER_ENTRY_NOTFOUND;
for (sal_uInt16 i = 0; i < static_cast<int>(InetMessageMime::NUMHDR); i++)
m_nMIMEIndex[static_cast<InetMessageMime>(i)] = CONTAINER_ENTRY_NOTFOUND;
}
-INetMIMEMessage::INetMIMEMessage (const INetMIMEMessage& rMsg)
- : m_nDocSize(rMsg.m_nDocSize),
- m_aDocName(rMsg.m_aDocName),
- m_xDocLB(rMsg.m_xDocLB),
- pParent(NULL)
-{
- ListCopy (rMsg);
- m_nRFC822Index = rMsg.m_nRFC822Index;
- CopyImp (rMsg);
-}
-
-INetMIMEMessage& INetMIMEMessage::operator= (
- const INetMIMEMessage& rMsg)
-{
- if (this != &rMsg)
- {
- m_nDocSize = rMsg.m_nDocSize;
- m_aDocName = rMsg.m_aDocName;
- m_xDocLB = rMsg.m_xDocLB;
- ListCopy (rMsg);
- m_nRFC822Index = rMsg.m_nRFC822Index;
- CleanupImp();
- CopyImp (rMsg);
- }
- return *this;
-}
-
INetMIMEMessage::~INetMIMEMessage()
{
- ListCleanup_Impl();
- CleanupImp();
-}
-
-void INetMIMEMessage::CleanupImp()
-{
- for( size_t i = 0, n = aChildren.size(); i < n; ++i ) {
- delete aChildren[ i ];
- }
- aChildren.clear();
-}
-
-void INetMIMEMessage::CopyImp (const INetMIMEMessage& rMsg)
-{
- bHeaderParsed = rMsg.bHeaderParsed;
-
- size_t i;
- m_nMIMEIndex = rMsg.m_nMIMEIndex;
- m_aBoundary = rMsg.m_aBoundary;
-
- for (i = 0; i < rMsg.aChildren.size(); i++)
- {
- INetMIMEMessage *pChild = rMsg.aChildren[ i ];
-
- if (pChild->pParent == &rMsg)
- {
- pChild = INetMIMEMessage::CreateMessage (*pChild);
- pChild->pParent = this;
- }
- aChildren.push_back( pChild );
+ for (auto i: m_aHeaderList) {
+ delete i;
}
-}
-
-INetMIMEMessage *INetMIMEMessage::CreateMessage (
- const INetMIMEMessage& rMsg)
-{
- return new INetMIMEMessage (rMsg);
-}
-
-// Header Field Parser
-sal_uIntPtr INetMIMEMessage::SetHeaderField (
- const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex)
-{
- OString aName (rHeader.GetName());
- const sal_Char *pData = aName.getStr();
- const sal_Char *pStop = pData + aName.getLength() + 1;
- const sal_Char *check = "";
-
- InetMessageMime nIdx = static_cast<InetMessageMime>(CONTAINER_APPEND);
- int eState = INETMSG_MIME_BEGIN;
- int eOkState = INETMSG_MIME_OK;
-
- while (pData < pStop)
- {
- switch (eState)
- {
- case INETMSG_MIME_BEGIN:
- eState = INETMSG_MIME_CHECK;
- eOkState = INETMSG_MIME_OK;
-
- switch (ascii_toLowerCase (*pData))
- {
- case 'c':
- check = "ontent-";
- eOkState = INETMSG_MIME_TOKEN_CONTENT;
- break;
-
- case 'm':
- check = "ime-version";
- nIdx = InetMessageMime::VERSION;
- break;
-
- default:
- eState = INETMSG_MIME_JUNK;
- break;
- }
- pData++;
- break;
-
- case INETMSG_MIME_TOKEN_CONTENT:
- eState = INETMSG_MIME_CHECK;
- eOkState = INETMSG_MIME_OK;
-
- switch (ascii_toLowerCase (*pData))
- {
- case 'd':
- eState = INETMSG_MIME_TOKEN_CONTENT_D;
- break;
-
- case 'i':
- check = "d";
- nIdx = InetMessageMime::CONTENT_ID;
- break;
-
- case 't':
- eState = INETMSG_MIME_TOKEN_CONTENT_T;
- break;
-
- default:
- eState = INETMSG_MIME_JUNK;
- break;
- }
- pData++;
- break;
-
- case INETMSG_MIME_TOKEN_CONTENT_D:
- eState = INETMSG_MIME_CHECK;
- eOkState = INETMSG_MIME_OK;
-
- switch (ascii_toLowerCase (*pData))
- {
- case 'e':
- check = "scription";
- nIdx = InetMessageMime::CONTENT_DESCRIPTION;
- break;
-
- case 'i':
- check = "sposition";
- nIdx = InetMessageMime::CONTENT_DISPOSITION;
- break;
-
- default:
- eState = INETMSG_MIME_JUNK;
- break;
- }
- pData++;
- break;
-
- case INETMSG_MIME_TOKEN_CONTENT_T:
- eState = INETMSG_MIME_CHECK;
- eOkState = INETMSG_MIME_OK;
-
- switch (ascii_toLowerCase (*pData))
- {
- case 'r':
- check = "ansfer-encoding";
- nIdx = InetMessageMime::CONTENT_TRANSFER_ENCODING;
- break;
-
- case 'y':
- check = "pe";
- nIdx = InetMessageMime::CONTENT_TYPE;
- break;
-
- default:
- eState = INETMSG_MIME_JUNK;
- break;
- }
- pData++;
- break;
-
- case INETMSG_MIME_CHECK:
- if (*check)
- {
- while (*pData && *check &&
- (ascii_toLowerCase (*pData) == *check))
- {
- pData++;
- check++;
- }
- }
- else
- {
- check = pData;
- }
- eState = (*check == '\0') ? eOkState : INETMSG_MIME_JUNK;
- break;
-
- case INETMSG_MIME_OK:
- pData = pStop;
- SetHeaderField_Impl (
- INetMessageHeader( ImplINetMIMEMessageHeaderData.at(nIdx), rHeader.GetValue()),
- m_nMIMEIndex[nIdx]);
- nNewIndex = m_nMIMEIndex[nIdx];
- break;
-
- default: // INETMSG_MIME_JUNK
- pData = pStop;
- nNewIndex = SetRFC822HeaderField(rHeader, nNewIndex);
- break;
- }
+ for (auto i: aChildren) {
+ delete i;
}
- return nNewIndex;
}
void INetMIMEMessage::SetMIMEVersion (const OUString& rVersion)
commit 9371a5f0a03ef1e98e8984edf3bb81cffa14f36f
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Sep 10 17:36:44 2015 +0200
More INetMIMEMessageStream clean up
Change-Id: Ibb2b93261e2d8ef370ac106766e39685a03a6ef3
diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx
index 90d3760..7e43b0d 100644
--- a/include/tools/inetstrm.hxx
+++ b/include/tools/inetstrm.hxx
@@ -27,17 +27,6 @@ class INetMIMEMessage;
class SvMemoryStream;
class SvStream;
-enum INetStreamStatus
-{
- INETSTREAM_STATUS_ERROR = -1
-};
-
-enum INetMessageStreamState
-{
- INETMSG_EOL_BEGIN,
- INETMSG_EOL_DONE
-};
-
class TOOLS_DLLPUBLIC INetMIMEMessageStream
{
INetMIMEMessage *pSourceMsg;
@@ -53,7 +42,7 @@ class TOOLS_DLLPUBLIC INetMIMEMessageStream
sal_Char *pMsgRead;
sal_Char *pMsgWrite;
- int eState;
+ bool done;
sal_uIntPtr nChildIndex;
INetMIMEMessageStream *pChildStrm;
@@ -61,20 +50,15 @@ class TOOLS_DLLPUBLIC INetMIMEMessageStream
INetMIMEMessageStream (const INetMIMEMessageStream& rStrm) SAL_DELETED_FUNCTION;
INetMIMEMessageStream& operator= (const INetMIMEMessageStream& rStrm) SAL_DELETED_FUNCTION;
- int GetInnerMsgLine(sal_Char *pData, sal_uIntPtr nSize);
- int GetOuterMsgLine(sal_Char *pData, sal_uIntPtr nSize);
+ int GetHeaderLine(sal_Char *pData, sal_uIntPtr nSize);
+ int GetBodyLine(sal_Char *pData, sal_uIntPtr nSize);
+ int GetMsgLine(sal_Char *pData, sal_uIntPtr nSize);
public:
- INetMIMEMessageStream (sal_uIntPtr nBufferSize = 2048);
+ explicit INetMIMEMessageStream(INetMIMEMessage *pMsg, bool headerGenerated);
~INetMIMEMessageStream();
int Read (sal_Char *pData, sal_uIntPtr nSize);
-
- INetMIMEMessage *GetSourceMessage() const { return pSourceMsg; }
- void SetSourceMessage (INetMIMEMessage *pMsg) { pSourceMsg = pMsg; }
-
- void SetHeaderGenerated() { bHeaderGenerated = true; }
- bool IsHeaderGenerated() const { return bHeaderGenerated; }
};
#endif
diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx
index b984b32..1a2da1b 100644
--- a/tools/source/inet/inetstrm.cxx
+++ b/tools/source/inet/inetstrm.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cassert>
+
#include <comphelper/string.hxx>
#include <sal/log.hxx>
#include <sal/types.h>
@@ -24,147 +28,141 @@
#include <tools/inetmsg.hxx>
#include <tools/inetstrm.hxx>
-#include <ctype.h>
-
-int INetMIMEMessageStream::GetInnerMsgLine(sal_Char* pData, sal_uIntPtr nSize)
+int INetMIMEMessageStream::GetHeaderLine(sal_Char* pData, sal_uIntPtr nSize)
{
- if (pSourceMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
sal_Char* pWBuf = pData;
- sal_Char* pWEnd = pData + nSize;
- if (!bHeaderGenerated)
- {
- sal_uIntPtr i, n;
+ sal_uIntPtr i, n;
- if (pMsgBuffer->Tell() == 0)
+ if (pMsgBuffer->Tell() == 0)
+ {
+ // Insert formatted header into buffer.
+ n = pSourceMsg->GetHeaderCount();
+ for (i = 0; i < n; i++)
{
- // Insert formatted header into buffer.
- n = pSourceMsg->GetHeaderCount();
- for (i = 0; i < n; i++)
+ INetMessageHeader aHeader (pSourceMsg->GetHeaderField(i));
+ if (aHeader.GetValue().getLength())
{
- INetMessageHeader aHeader (pSourceMsg->GetHeaderField(i));
- if (aHeader.GetValue().getLength())
- {
- // NYI: Folding long lines.
- pMsgBuffer->WriteCharPtr( aHeader.GetName().getStr() );
- pMsgBuffer->WriteCharPtr( ": " );
- pMsgBuffer->WriteCharPtr( aHeader.GetValue().getStr() );
- pMsgBuffer->WriteCharPtr( "\r\n" );
- }
+ // NYI: Folding long lines.
+ pMsgBuffer->WriteCharPtr( aHeader.GetName().getStr() );
+ pMsgBuffer->WriteCharPtr( ": " );
+ pMsgBuffer->WriteCharPtr( aHeader.GetValue().getStr() );
+ pMsgBuffer->WriteCharPtr( "\r\n" );
}
-
- pMsgWrite = const_cast<char *>(static_cast<sal_Char const *>(pMsgBuffer->GetData()));
- pMsgRead = pMsgWrite + pMsgBuffer->Tell();
}
- n = pMsgRead - pMsgWrite;
- if (n > 0)
- {
- // Move to caller.
- if (nSize < n) n = nSize;
- for (i = 0; i < n; i++) *pWBuf++ = *pMsgWrite++;
- }
- else
- {
- // Reset buffer.
- pMsgBuffer->Seek(STREAM_SEEK_TO_BEGIN);
- }
+ pMsgWrite = const_cast<char *>(static_cast<sal_Char const *>(pMsgBuffer->GetData()));
+ pMsgRead = pMsgWrite + pMsgBuffer->Tell();
+ }
+
+ n = pMsgRead - pMsgWrite;
+ if (n > 0)
+ {
+ // Move to caller.
+ if (nSize < n) n = nSize;
+ for (i = 0; i < n; i++) *pWBuf++ = *pMsgWrite++;
}
else
{
- if (pSourceMsg->GetDocumentLB())
- {
- if (pMsgStrm == NULL)
- pMsgStrm = new SvStream (pSourceMsg->GetDocumentLB());
-
- sal_uIntPtr nRead = pMsgStrm->Read(pWBuf, (pWEnd - pWBuf));
- pWBuf += nRead;
- }
+ // Reset buffer.
+ pMsgBuffer->Seek(STREAM_SEEK_TO_BEGIN);
}
+
return (pWBuf - pData);
}
-int INetMIMEMessageStream::GetOuterMsgLine(sal_Char* pData, sal_uIntPtr nSize)
+int INetMIMEMessageStream::GetBodyLine(sal_Char* pData, sal_uIntPtr nSize)
{
- // Check for message container.
- INetMIMEMessage* pMsg = GetSourceMessage();
- if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
+ sal_Char* pWBuf = pData;
+ sal_Char* pWEnd = pData + nSize;
+
+ if (pSourceMsg->GetDocumentLB())
+ {
+ if (pMsgStrm == NULL)
+ pMsgStrm = new SvStream (pSourceMsg->GetDocumentLB());
+
+ sal_uIntPtr nRead = pMsgStrm->Read(pWBuf, (pWEnd - pWBuf));
+ pWBuf += nRead;
+ }
+ return (pWBuf - pData);
+}
+
+int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
+{
// Check for header or body.
- if (!IsHeaderGenerated())
+ if (!bHeaderGenerated)
{
- if (eState == INETMSG_EOL_BEGIN)
+ if (!done)
{
// Prepare special header fields.
- if (pMsg->GetParent())
+ if (pSourceMsg->GetParent())
{
- OUString aPCT(pMsg->GetParent()->GetContentType());
+ OUString aPCT(pSourceMsg->GetParent()->GetContentType());
if (aPCT.startsWithIgnoreAsciiCase("message/rfc822"))
- pMsg->SetMIMEVersion("1.0");
+ pSourceMsg->SetMIMEVersion("1.0");
else
- pMsg->SetMIMEVersion(OUString());
+ pSourceMsg->SetMIMEVersion(OUString());
}
else
{
- pMsg->SetMIMEVersion("1.0");
+ pSourceMsg->SetMIMEVersion("1.0");
}
// Check ContentType.
- OUString aContentType(pMsg->GetContentType());
+ OUString aContentType(pSourceMsg->GetContentType());
if (!aContentType.isEmpty())
{
// Determine default Content-Type.
- OUString aDefaultType = pMsg->GetDefaultContentType();
+ OUString aDefaultType = pSourceMsg->GetDefaultContentType();
if (aDefaultType.equalsIgnoreAsciiCase(aContentType))
{
// No need to specify default.
- pMsg->SetContentType(OUString());
+ pSourceMsg->SetContentType(OUString());
}
}
// No need to specify default.
- pMsg->SetContentTransferEncoding(OUString());
+ pSourceMsg->SetContentTransferEncoding(OUString());
// Mark we're done.
- eState = INETMSG_EOL_DONE;
+ done = true;
}
// Generate the message header.
- int nRead = GetInnerMsgLine(pData, nSize);
+ int nRead = GetHeaderLine(pData, nSize);
if (nRead <= 0)
{
// Reset state.
- eState = INETMSG_EOL_BEGIN;
+ done = false;
}
return nRead;
}
else
{
// Generate the message body.
- if (pMsg->IsContainer())
+ if (pSourceMsg->IsContainer())
{
// Encapsulated message body.
- while (eState == INETMSG_EOL_BEGIN)
+ while (!done)
{
if (pChildStrm == NULL)
{
- INetMIMEMessage *pChild = pMsg->GetChild(nChildIndex);
+ INetMIMEMessage *pChild = pSourceMsg->GetChild(nChildIndex);
if (pChild)
{
// Increment child index.
nChildIndex++;
// Create child stream.
- pChildStrm = new INetMIMEMessageStream;
- pChildStrm->SetSourceMessage(pChild);
+ pChildStrm = new INetMIMEMessageStream(pChild, false);
- if (pMsg->IsMultipart())
+ if (pSourceMsg->IsMultipart())
{
// Insert multipart delimiter.
OStringBuffer aDelim("--");
- aDelim.append(pMsg->GetMultipartBoundary());
+ aDelim.append(pSourceMsg->GetMultipartBoundary());
aDelim.append("\r\n");
memcpy(pData, aDelim.getStr(),
@@ -175,14 +173,14 @@ int INetMIMEMessageStream::GetOuterMsgLine(sal_Char* pData, sal_uIntPtr nSize)
else
{
// No more parts. Mark we're done.
- eState = INETMSG_EOL_DONE;
+ done = true;
nChildIndex = 0;
- if (pMsg->IsMultipart())
+ if (pSourceMsg->IsMultipart())
{
// Insert close delimiter.
OStringBuffer aDelim("--");
- aDelim.append(pMsg->GetMultipartBoundary());
+ aDelim.append(pSourceMsg->GetMultipartBoundary());
aDelim.append("--\r\n");
memcpy(pData, aDelim.getStr(),
@@ -212,30 +210,32 @@ int INetMIMEMessageStream::GetOuterMsgLine(sal_Char* pData, sal_uIntPtr nSize)
else
{
// Single part message body.
- if (pMsg->GetDocumentLB() == NULL)
+ if (pSourceMsg->GetDocumentLB() == NULL)
{
// Empty message body.
return 0;
}
// No Encoding.
- return GetInnerMsgLine(pData, nSize);
+ return GetBodyLine(pData, nSize);
}
}
}
-INetMIMEMessageStream::INetMIMEMessageStream(sal_uIntPtr nBufferSize):
- pSourceMsg(NULL),
- bHeaderGenerated(false),
- nBufSiz(nBufferSize),
+INetMIMEMessageStream::INetMIMEMessageStream(
+ INetMIMEMessage *pMsg, bool headerGenerated):
+ pSourceMsg(pMsg),
+ bHeaderGenerated(headerGenerated),
+ nBufSiz(2048),
pMsgStrm(NULL),
pMsgBuffer(new SvMemoryStream),
pMsgRead(NULL),
pMsgWrite(NULL),
- eState(INETMSG_EOL_BEGIN),
+ done(false),
nChildIndex(0),
pChildStrm(NULL)
{
+ assert(pMsg != nullptr);
pMsgBuffer->SetStreamCharSet(RTL_TEXTENCODING_ASCII_US);
pBuffer = new sal_Char[nBufSiz];
pRead = pWrite = pBuffer;
@@ -251,8 +251,6 @@ INetMIMEMessageStream::~INetMIMEMessageStream()
int INetMIMEMessageStream::Read(sal_Char* pData, sal_uIntPtr nSize)
{
- if (pSourceMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
sal_Char* pWBuf = pData;
sal_Char* pWEnd = pData + nSize;
@@ -273,7 +271,7 @@ int INetMIMEMessageStream::Read(sal_Char* pData, sal_uIntPtr nSize)
pRead = pWrite = pBuffer;
// Read next message line.
- int nRead = GetOuterMsgLine(pBuffer, nBufSiz);
+ int nRead = GetMsgLine(pBuffer, nBufSiz);
if (nRead > 0)
{
// Set read pointer.
commit 82285ab5c9778cc16a6976f4036ec7188037c6b9
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Sep 10 17:08:11 2015 +0200
Merge INetMessageIStream into INetMIMEMessageStream
Change-Id: Ic3d9cd117b3f911a7cb1317fc9d1d2e9d8f1ff42
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 8f7d916..56dd4a9 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -545,9 +545,7 @@ Sequence<sal_Int8> ODatabaseForm::GetDataMultiPartEncoded(const Reference<XContr
aSuccObjList.clear();
// Create MessageStream for parent
- INetMIMEMessageStream aMessStream;
- aMessStream.SetSourceMessage( &aParent );
- aMessStream.SetHeaderGenerated();
+ INetMIMEMessageStream aMessStream(&aParent, true);
// Copy MessageStream to SvStream
SvMemoryStream aMemStream;
diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx
index 83c5592..90d3760 100644
--- a/include/tools/inetstrm.hxx
+++ b/include/tools/inetstrm.hxx
@@ -38,8 +38,7 @@ enum INetMessageStreamState
INETMSG_EOL_DONE
};
-/// Message Generator Interface.
-class INetMessageIStream
+class TOOLS_DLLPUBLIC INetMIMEMessageStream
{
INetMIMEMessage *pSourceMsg;
bool bHeaderGenerated;
@@ -54,44 +53,28 @@ class INetMessageIStream
sal_Char *pMsgRead;
sal_Char *pMsgWrite;
- INetMessageIStream (const INetMessageIStream& rStrm) SAL_DELETED_FUNCTION;
- INetMessageIStream& operator= (const INetMessageIStream& rStrm) SAL_DELETED_FUNCTION;
-
-protected:
- virtual int GetMsgLine (sal_Char *pData, sal_uIntPtr nSize);
-
-public:
- INetMessageIStream (sal_uIntPtr nBufferSize = 2048);
- virtual ~INetMessageIStream();
-
- TOOLS_DLLPUBLIC int Read (sal_Char *pData, sal_uIntPtr nSize);
-
- INetMIMEMessage *GetSourceMessage() const { return pSourceMsg; }
- void SetSourceMessage (INetMIMEMessage *pMsg) { pSourceMsg = pMsg; }
-
- void SetHeaderGenerated() { bHeaderGenerated = true; }
- bool IsHeaderGenerated() const { return bHeaderGenerated; }
-};
-
-class TOOLS_DLLPUBLIC INetMIMEMessageStream
- : public INetMessageIStream
-{
int eState;
sal_uIntPtr nChildIndex;
INetMIMEMessageStream *pChildStrm;
- SvMemoryStream *pMsgBuffer;
-
INetMIMEMessageStream (const INetMIMEMessageStream& rStrm) SAL_DELETED_FUNCTION;
INetMIMEMessageStream& operator= (const INetMIMEMessageStream& rStrm) SAL_DELETED_FUNCTION;
-protected:
- virtual int GetMsgLine (sal_Char *pData, sal_uIntPtr nSize) SAL_OVERRIDE;
+ int GetInnerMsgLine(sal_Char *pData, sal_uIntPtr nSize);
+ int GetOuterMsgLine(sal_Char *pData, sal_uIntPtr nSize);
public:
INetMIMEMessageStream (sal_uIntPtr nBufferSize = 2048);
- virtual ~INetMIMEMessageStream();
+ ~INetMIMEMessageStream();
+
+ int Read (sal_Char *pData, sal_uIntPtr nSize);
+
+ INetMIMEMessage *GetSourceMessage() const { return pSourceMsg; }
+ void SetSourceMessage (INetMIMEMessage *pMsg) { pSourceMsg = pMsg; }
+
+ void SetHeaderGenerated() { bHeaderGenerated = true; }
+ bool IsHeaderGenerated() const { return bHeaderGenerated; }
};
#endif
diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx
index a3c76e7..b984b32 100644
--- a/tools/source/inet/inetstrm.cxx
+++ b/tools/source/inet/inetstrm.cxx
@@ -26,80 +26,7 @@
#include <ctype.h>
-// INetMessageIStream
-
-INetMessageIStream::INetMessageIStream(sal_uIntPtr nBufferSize)
- : pSourceMsg(NULL)
- , bHeaderGenerated(false)
- , nBufSiz(nBufferSize)
- , pMsgStrm(NULL)
- , pMsgBuffer(new SvMemoryStream)
- , pMsgRead(NULL)
- , pMsgWrite(NULL)
-{
- pMsgBuffer->SetStreamCharSet(RTL_TEXTENCODING_ASCII_US);
- pBuffer = new sal_Char[nBufSiz];
- pRead = pWrite = pBuffer;
-}
-
-INetMessageIStream::~INetMessageIStream()
-{
- delete [] pBuffer;
- delete pMsgBuffer;
- delete pMsgStrm;
-}
-
-int INetMessageIStream::Read(sal_Char* pData, sal_uIntPtr nSize)
-{
- if (pSourceMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- sal_Char* pWBuf = pData;
- sal_Char* pWEnd = pData + nSize;
-
- while (pWBuf < pWEnd)
- {
- // Caller's buffer not yet filled.
- sal_uIntPtr n = pRead - pWrite;
- if (n > 0)
- {
- // Bytes still in buffer.
- sal_uIntPtr m = pWEnd - pWBuf;
- if (m < n) n = m;
- for (sal_uIntPtr i = 0; i < n; i++) *pWBuf++ = *pWrite++;
- }
- else
- {
- // Buffer empty. Reset to <Begin-of-Buffer>.
- pRead = pWrite = pBuffer;
-
- // Read next message line.
- int nRead = GetMsgLine(pBuffer, nBufSiz);
- if (nRead > 0)
- {
- // Set read pointer.
- pRead = pBuffer + nRead;
- }
- else
- {
- if (!bHeaderGenerated)
- {
- // Header generated. Insert empty line.
- bHeaderGenerated = true;
- *pRead++ = '\r';
- *pRead++ = '\n';
- }
- else
- {
- // Body generated.
- return (pWBuf - pData);
- }
- }
- }
- }
- return (pWBuf - pData);
-}
-
-int INetMessageIStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
+int INetMIMEMessageStream::GetInnerMsgLine(sal_Char* pData, sal_uIntPtr nSize)
{
if (pSourceMsg == NULL) return INETSTREAM_STATUS_ERROR;
@@ -158,25 +85,7 @@ int INetMessageIStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
return (pWBuf - pData);
}
-// INetMIMEMessageStream
-
-INetMIMEMessageStream::INetMIMEMessageStream(sal_uIntPtr nBufferSize)
- : INetMessageIStream(nBufferSize),
- eState (INETMSG_EOL_BEGIN),
- nChildIndex (0),
- pChildStrm (NULL),
- pMsgBuffer (NULL)
-{
-}
-
-INetMIMEMessageStream::~INetMIMEMessageStream()
-{
- delete pChildStrm;
- delete pMsgBuffer;
-}
-
-/// Message Generator
-int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
+int INetMIMEMessageStream::GetOuterMsgLine(sal_Char* pData, sal_uIntPtr nSize)
{
// Check for message container.
INetMIMEMessage* pMsg = GetSourceMessage();
@@ -223,7 +132,7 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
}
// Generate the message header.
- int nRead = INetMessageIStream::GetMsgLine(pData, nSize);
+ int nRead = GetInnerMsgLine(pData, nSize);
if (nRead <= 0)
{
// Reset state.
@@ -310,9 +219,84 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
}
// No Encoding.
- return INetMessageIStream::GetMsgLine(pData, nSize);
+ return GetInnerMsgLine(pData, nSize);
+ }
+ }
+}
+
+INetMIMEMessageStream::INetMIMEMessageStream(sal_uIntPtr nBufferSize):
+ pSourceMsg(NULL),
+ bHeaderGenerated(false),
+ nBufSiz(nBufferSize),
+ pMsgStrm(NULL),
+ pMsgBuffer(new SvMemoryStream),
+ pMsgRead(NULL),
+ pMsgWrite(NULL),
+ eState(INETMSG_EOL_BEGIN),
+ nChildIndex(0),
+ pChildStrm(NULL)
+{
+ pMsgBuffer->SetStreamCharSet(RTL_TEXTENCODING_ASCII_US);
+ pBuffer = new sal_Char[nBufSiz];
+ pRead = pWrite = pBuffer;
+}
+
+INetMIMEMessageStream::~INetMIMEMessageStream()
+{
+ delete pChildStrm;
+ delete [] pBuffer;
+ delete pMsgBuffer;
+ delete pMsgStrm;
+}
+
+int INetMIMEMessageStream::Read(sal_Char* pData, sal_uIntPtr nSize)
+{
+ if (pSourceMsg == NULL) return INETSTREAM_STATUS_ERROR;
+
+ sal_Char* pWBuf = pData;
+ sal_Char* pWEnd = pData + nSize;
+
+ while (pWBuf < pWEnd)
+ {
+ // Caller's buffer not yet filled.
+ sal_uIntPtr n = pRead - pWrite;
+ if (n > 0)
+ {
+ // Bytes still in buffer.
+ sal_uIntPtr m = pWEnd - pWBuf;
+ if (m < n) n = m;
+ for (sal_uIntPtr i = 0; i < n; i++) *pWBuf++ = *pWrite++;
+ }
+ else
+ {
+ // Buffer empty. Reset to <Begin-of-Buffer>.
+ pRead = pWrite = pBuffer;
+
+ // Read next message line.
+ int nRead = GetOuterMsgLine(pBuffer, nBufSiz);
+ if (nRead > 0)
+ {
+ // Set read pointer.
+ pRead = pBuffer + nRead;
+ }
+ else
+ {
+ if (!bHeaderGenerated)
+ {
+ // Header generated. Insert empty line.
+ bHeaderGenerated = true;
+ *pRead++ = '\r';
+ *pRead++ = '\n';
+ }
+ else
+ {
+ // Body generated.
+ return (pWBuf - pData);
+ }
+ }
}
}
+ return (pWBuf - pData);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 4464e5dbca7cab6ec91d19914eddd934cb354aa7
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Sep 10 15:08:21 2015 +0200
No need for INetMIMEMessageStream encoding
...in the only use case in ODatabaseForm
Change-Id: I0282a9f60b05f279a11dcf1990e68b7e017ea3aa
diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx
index 9793732..83c5592 100644
--- a/include/tools/inetstrm.hxx
+++ b/include/tools/inetstrm.hxx
@@ -35,10 +35,7 @@ enum INetStreamStatus
enum INetMessageStreamState
{
INETMSG_EOL_BEGIN,
- INETMSG_EOL_DONE,
- INETMSG_EOL_SCR,
- INETMSG_EOL_FCR,
- INETMSG_EOL_FSP
+ INETMSG_EOL_DONE
};
/// Message Generator Interface.
@@ -76,14 +73,6 @@ public:
bool IsHeaderGenerated() const { return bHeaderGenerated; }
};
-enum INetMessageEncoding
-{
- INETMSG_ENCODING_7BIT,
- INETMSG_ENCODING_BINARY,
- INETMSG_ENCODING_QUOTED,
- INETMSG_ENCODING_BASE64
-};
-
class TOOLS_DLLPUBLIC INetMIMEMessageStream
: public INetMessageIStream
{
@@ -92,14 +81,8 @@ class TOOLS_DLLPUBLIC INetMIMEMessageStream
sal_uIntPtr nChildIndex;
INetMIMEMessageStream *pChildStrm;
- INetMessageEncoding eEncoding;
- INetMessageIStream *pEncodeStrm;
-
SvMemoryStream *pMsgBuffer;
- static INetMessageEncoding GetMsgEncoding (
- const OUString& rContentType);
-
INetMIMEMessageStream (const INetMIMEMessageStream& rStrm) SAL_DELETED_FUNCTION;
INetMIMEMessageStream& operator= (const INetMIMEMessageStream& rStrm) SAL_DELETED_FUNCTION;
diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx
index 053b649..a3c76e7 100644
--- a/tools/source/inet/inetstrm.cxx
+++ b/tools/source/inet/inetstrm.cxx
@@ -26,55 +26,6 @@
#include <ctype.h>
-/** Quoted-Printable Encoding */
-class INetMessageEncodeQPStream_Impl : public INetMessageIStream
-{
- SvStream* pMsgStrm;
-
- sal_uIntPtr nMsgBufSiz;
- sal_Char* pMsgBuffer;
- sal_Char* pMsgRead;
- sal_Char* pMsgWrite;
-
- sal_uIntPtr nTokBufSiz;
- sal_Char* pTokBuffer;
- sal_Char* pTokRead;
- sal_Char* pTokWrite;
-
- INetMessageStreamState eState;
- bool bDone;
-
- virtual int GetMsgLine(sal_Char* pData, sal_uIntPtr nSize) SAL_OVERRIDE;
-
-public:
- explicit INetMessageEncodeQPStream_Impl(sal_uIntPtr nMsgBufferSize = 1024);
- virtual ~INetMessageEncodeQPStream_Impl();
-};
-
-/** Base64 Encoding */
-class INetMessageEncode64Stream_Impl : public INetMessageIStream
-{
- SvStream* pMsgStrm;
-
- sal_uIntPtr nMsgBufSiz;
- sal_uInt8* pMsgBuffer;
- sal_uInt8* pMsgRead;
- sal_uInt8* pMsgWrite;
-
- sal_uIntPtr nTokBufSiz;
- sal_Char* pTokBuffer;
- sal_Char* pTokRead;
- sal_Char* pTokWrite;
-
- bool bDone;
-
- virtual int GetMsgLine(sal_Char* pData, sal_uIntPtr nSize) SAL_OVERRIDE;
-
-public:
- explicit INetMessageEncode64Stream_Impl(sal_uIntPtr nMsgBufferSize = 2048);
- virtual ~INetMessageEncode64Stream_Impl();
-};
-
// INetMessageIStream
INetMessageIStream::INetMessageIStream(sal_uIntPtr nBufferSize)
@@ -207,364 +158,6 @@ int INetMessageIStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
return (pWBuf - pData);
}
-// INetMessageEncodeQPStream_Impl
-
-static const sal_Char hex2pr[16] = {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'A', 'B', 'C', 'D', 'E', 'F'
-};
-
-INetMessageEncodeQPStream_Impl::INetMessageEncodeQPStream_Impl( sal_uIntPtr nMsgBufferSize)
- : INetMessageIStream (),
- pMsgStrm (NULL),
- nMsgBufSiz (nMsgBufferSize),
- nTokBufSiz (80),
- eState (INETMSG_EOL_SCR),
- bDone (false)
-{
- SetHeaderGenerated();
-
- pMsgBuffer = new sal_Char[nMsgBufSiz];
- pMsgRead = pMsgWrite = pMsgBuffer;
-
- pTokBuffer = new sal_Char[nTokBufSiz];
- pTokRead = pTokWrite = pTokBuffer;
-}
-
-INetMessageEncodeQPStream_Impl::~INetMessageEncodeQPStream_Impl()
-{
- delete pMsgStrm;
- delete [] pMsgBuffer;
- delete [] pTokBuffer;
-}
-
-int INetMessageEncodeQPStream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
-{
- INetMIMEMessage* pMsg = GetSourceMessage();
- if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- if (pMsg->GetDocumentLB() == NULL) return 0;
- if (pMsgStrm == NULL) pMsgStrm = new SvStream(pMsg->GetDocumentLB());
-
- sal_Char* pWBuf = pData;
- while (pWBuf < (pData + nSize))
- {
- // Caller's buffer not yet filled.
- if ((pMsgRead - pMsgWrite) > 0)
- {
- // Bytes still in message buffer.
- if ((eState != INETMSG_EOL_BEGIN) &&
- ((pTokRead - pTokBuffer) < 72))
- {
- // Token buffer not yet filled.
- if (eState == INETMSG_EOL_FCR)
- {
- eState = INETMSG_EOL_BEGIN;
- if (*pMsgWrite != '\n')
- {
- // Convert orphant <CR> into <CR><LF> sequence.
- *pTokRead++ = '\n';
- }
- *pTokRead++ = *pMsgWrite++;
- }
- else if ((*pMsgWrite == ' ') || (*pMsgWrite == '\t'))
- {
- eState = INETMSG_EOL_FSP;
- *pTokRead++ = *pMsgWrite++;
- }
- else if (*pMsgWrite == '\r')
- {
- // Found <CR>.
- if (eState == INETMSG_EOL_FSP)
- {
- // Encode last (trailing space) character.
- sal_uInt8 c = (sal_uInt8)(*(--pTokRead));
- *pTokRead++ = '=';
- *pTokRead++ = hex2pr[((c & 0xf0) >> 4)];
- *pTokRead++ = hex2pr[((c & 0x0f) )];
- }
- eState = INETMSG_EOL_FCR;
- *pTokRead++ = *pMsgWrite++;
- }
- else if (*pMsgWrite == '\n')
- {
- // Found <LF> only.
- if (eState == INETMSG_EOL_FSP)
- {
- // Encode last (trailing space) character.
- sal_uInt8 c = (sal_uInt8)(*(--pTokRead));
- *pTokRead++ = '=';
- *pTokRead++ = hex2pr[((c & 0xf0) >> 4)];
- *pTokRead++ = hex2pr[((c & 0x0f) )];
- }
- eState = INETMSG_EOL_BEGIN;
-
- // Convert orphant <LF> into <CR><LF> sequence.
- *pTokRead++ = '\r';
- *pTokRead++ = *pMsgWrite++;
- }
- else if (*pMsgWrite == '=')
- {
- // Escape character itself MUST be encoded, of course.
- sal_uInt8 c = (sal_uInt8)(*pMsgWrite++);
- *pTokRead++ = '=';
- *pTokRead++ = hex2pr[((c & 0xf0) >> 4)];
- *pTokRead++ = hex2pr[((c & 0x0f) )];
-
- eState = INETMSG_EOL_SCR;
- }
- else if (((sal_uInt8)(*pMsgWrite) > 0x20) &&
- ((sal_uInt8)(*pMsgWrite) < 0x7f) )
- {
- /*
- * Some printable ASCII character.
- * (Encode EBCDIC special characters (NYI)).
- */
- *pTokRead++ = *pMsgWrite++;
- eState = INETMSG_EOL_SCR;
- }
- else
- {
- // Encode any other character.
- sal_uInt8 c = (sal_uInt8)(*pMsgWrite++);
- *pTokRead++ = '=';
- *pTokRead++ = hex2pr[((c & 0xf0) >> 4)];
- *pTokRead++ = hex2pr[((c & 0x0f) )];
-
- eState = INETMSG_EOL_SCR;
- }
- }
- else
- {
- // Check for maximum line length.
- if (eState != INETMSG_EOL_BEGIN)
- {
- // Insert soft line break.
- *pTokRead++ = '=';
- *pTokRead++ = '\r';
- *pTokRead++ = '\n';
-
- eState = INETMSG_EOL_BEGIN;
- }
-
- // Copy to caller's buffer.
- if ((pTokRead - pTokWrite) > 0)
- {
- // Bytes still in token buffer.
- *pWBuf++ = *pTokWrite++;
- }
- else
- {
- // Token buffer empty. Reset to <Begin-of-Buffer>.
- pTokRead = pTokWrite = pTokBuffer;
- eState = INETMSG_EOL_SCR;
- }
- }
- }
- else
- {
- // Message buffer empty. Reset to <Begin-of-Buffer>.
- pMsgRead = pMsgWrite = pMsgBuffer;
-
- // Read next message block.
- sal_uIntPtr nRead = pMsgStrm->Read(pMsgBuffer, nMsgBufSiz);
- if (nRead > 0)
- {
- // Set read pointer.
- pMsgRead = (pMsgBuffer + nRead);
- }
- else
- {
- // Nothing more ro read.
- if (!bDone)
- {
- // Append final <CR><LF> and mark we're done.
- *pTokRead++ = '\r';
- *pTokRead++ = '\n';
-
- bDone = true;
- }
- else
- {
- // Already done all encoding.
- if ((pTokRead - pTokWrite) > 0)
- {
- // Bytes still in token buffer.
- *pWBuf++ = *pTokWrite++;
- }
- else
- {
- // Token buffer empty. Reset to <Begin-of-Buffer>.
- pTokRead = pTokWrite = pTokBuffer;
-
- // Return.
- return (pWBuf - pData);
- }
- }
- }
- }
- }
- return (pWBuf - pData);
-}
-
-// INetMessageEncode64Stream_Impl
-
-static const sal_Char six2pr[64] = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
-};
-
-INetMessageEncode64Stream_Impl::INetMessageEncode64Stream_Impl(
- sal_uIntPtr nMsgBufferSize)
- : INetMessageIStream(),
- pMsgStrm (NULL),
- nMsgBufSiz (nMsgBufferSize),
- nTokBufSiz (80),
- bDone (false)
-{
- SetHeaderGenerated();
-
- pMsgBuffer = new sal_uInt8[nMsgBufSiz];
- pMsgRead = pMsgWrite = pMsgBuffer;
-
- pTokBuffer = new sal_Char[nTokBufSiz];
- pTokRead = pTokWrite = pTokBuffer;
-}
-
-INetMessageEncode64Stream_Impl::~INetMessageEncode64Stream_Impl()
-{
- delete pMsgStrm;
- delete [] pMsgBuffer;
- delete [] pTokBuffer;
-}
-
-int INetMessageEncode64Stream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
-{
- INetMIMEMessage* pMsg = GetSourceMessage();
- if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- if (pMsg->GetDocumentLB() == NULL) return 0;
- if (pMsgStrm == NULL) pMsgStrm = new SvStream(pMsg->GetDocumentLB());
-
- sal_Char* pWBuf = pData;
- while (pWBuf < (pData + nSize))
- {
- // Caller's buffer not yet filled.
- if ((pMsgRead - pMsgWrite) > 0)
- {
- // Bytes still in message buffer.
- if ((pTokRead - pTokBuffer) < 72)
- {
- // Token buffer not yet filled.
- switch ((pTokRead - pTokBuffer) % 4)
- {
- case 0:
- *pTokRead++ = six2pr[(int)(*pMsgWrite >> 2)];
- break;
-
- case 1:
- *pTokRead++ = six2pr[ (int)(((*pMsgWrite << 4) & 060) |
- (((*(pMsgWrite + 1)) >> 4) & 017))];
- pMsgWrite++;
- break;
-
- case 2:
- *pTokRead++ = six2pr[ (int)(((*pMsgWrite << 2) & 074) |
- (((*(pMsgWrite + 1)) >> 6) & 003))];
- pMsgWrite++;
- break;
-
- default: // == case 3
- *pTokRead++ = six2pr[(int)(*pMsgWrite & 077)];
- pMsgWrite++;
- break;
- }
- }
- else if ((pTokRead - pTokBuffer) == 72)
- {
- // Maximum line length. Append <CR><LF>.
- *pTokRead++ = '\r';
- *pTokRead++ = '\n';
- }
- else
- {
- if ((pTokRead - pTokWrite) > 0)
- {
- // Bytes still in token buffer.
- *pWBuf++ = *pTokWrite++;
- }
- else
- {
- // Token buffer empty. Reset to <Begin-of-Buffer>.
- pTokRead = pTokWrite = pTokBuffer;
- }
- }
- }
- else
- {
- // Message buffer empty. Reset to <Begin-of-Buffer>.
- pMsgRead = pMsgWrite = pMsgBuffer;
-
- // Read next message block.
- sal_uIntPtr nRead = pMsgStrm->Read(pMsgBuffer, nMsgBufSiz);
- if (nRead > 0)
- {
- // Set read pointer.
- pMsgRead = (pMsgBuffer + nRead);
- }
- else
- {
- // Nothing more to read.
- if (!bDone)
- {
- // Append pad character(s) and final <CR><LF>.
- switch ((pTokRead - pTokBuffer) % 4)
- {
- case 2:
- *pTokRead++ = '=';
- // Fall through for 2nd pad character.
- case 3:
- *pTokRead++ = '=';
- break;
-
- default:
- break;
- }
- *pTokRead++ = '\r';
- *pTokRead++ = '\n';
-
- // Mark we're done.
- bDone = true;
- }
- else
- {
- // Already done all encoding.
- if ((pTokRead - pTokWrite) > 0)
- {
- // Bytes still in token buffer.
- *pWBuf++ = *pTokWrite++;
- }
- else
- {
- // Token buffer empty. Reset to <Begin-of-Buffer>.
- pTokRead = pTokWrite = pTokBuffer;
-
- // Reset done flag, if everything has been done.
- // if (pWBuf == pData) bDone = false;
-
- // Return.
- return (pWBuf - pData);
- }
- }
- }
- }
- } // while (pWBuf < (pData + nSize))
- return (pWBuf - pData);
-}
-
// INetMIMEMessageStream
INetMIMEMessageStream::INetMIMEMessageStream(sal_uIntPtr nBufferSize)
@@ -572,8 +165,6 @@ INetMIMEMessageStream::INetMIMEMessageStream(sal_uIntPtr nBufferSize)
eState (INETMSG_EOL_BEGIN),
nChildIndex (0),
pChildStrm (NULL),
- eEncoding (INETMSG_ENCODING_BINARY),
- pEncodeStrm (NULL),
pMsgBuffer (NULL)
{
}
@@ -581,43 +172,9 @@ INetMIMEMessageStream::INetMIMEMessageStream(sal_uIntPtr nBufferSize)
INetMIMEMessageStream::~INetMIMEMessageStream()
{
delete pChildStrm;
- delete pEncodeStrm;
delete pMsgBuffer;
}
-INetMessageEncoding
-INetMIMEMessageStream::GetMsgEncoding(const OUString& rContentType)
-{
- if (rContentType.startsWithIgnoreAsciiCase("message") ||
- rContentType.startsWithIgnoreAsciiCase("multipart"))
- {
- return INETMSG_ENCODING_7BIT;
- }
- if (rContentType.startsWithIgnoreAsciiCase("text"))
- {
- if (rContentType.startsWithIgnoreAsciiCase("text/plain"))
- {
- if (comphelper::string::getTokenCount(rContentType, '=') > 1)
- {
- OUString aCharset(rContentType.getToken(1, '='));
- aCharset = comphelper::string::stripStart(aCharset, ' ');
- aCharset = comphelper::string::stripStart(aCharset, '"');
-
- if (aCharset.startsWithIgnoreAsciiCase("us-ascii"))
- return INETMSG_ENCODING_7BIT;
- else
- return INETMSG_ENCODING_QUOTED;
- }
- else
- return INETMSG_ENCODING_7BIT;
- }
- else
- return INETMSG_ENCODING_QUOTED;
- }
-
- return INETMSG_ENCODING_BASE64;
-}
-
/// Message Generator
int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
{
@@ -658,51 +215,8 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
}
}
- // Check Encoding.
- OUString aEncoding(pMsg->GetContentTransferEncoding());
- if (!aEncoding.isEmpty())
- {
- // Use given Encoding.
- if (aEncoding.startsWithIgnoreAsciiCase("base64"))
- {
- eEncoding = INETMSG_ENCODING_BASE64;
- }
- else if (aEncoding.startsWithIgnoreAsciiCase("quoted-printable"))
- {
- eEncoding = INETMSG_ENCODING_QUOTED;
- }
- else
- {
- eEncoding = INETMSG_ENCODING_7BIT;
- }
- }
- else
- {
- // Use default Encoding for (given|default) Content-Type.
- if (aContentType.isEmpty())
- {
- // Determine default Content-Type.
- aContentType = pMsg->GetDefaultContentType();
- }
- eEncoding = GetMsgEncoding(aContentType);
- }
-
- // Set Content-Transfer-Encoding header.
- if (eEncoding == INETMSG_ENCODING_BASE64)
- {
- // Base64.
- pMsg->SetContentTransferEncoding("base64");
- }
- else if (eEncoding == INETMSG_ENCODING_QUOTED)
- {
- // Quoted-Printable.
- pMsg->SetContentTransferEncoding("quoted-printable");
- }
- else
- {
- // No need to specify default.
- pMsg->SetContentTransferEncoding(OUString());
- }
+ // No need to specify default.
+ pMsg->SetContentTransferEncoding(OUString());
// Mark we're done.
eState = INETMSG_EOL_DONE;
@@ -795,49 +309,8 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
return 0;
}
- // Check whether message body needs to be encoded.
- if (eEncoding == INETMSG_ENCODING_7BIT)
- {
- // No Encoding.
- return INetMessageIStream::GetMsgLine(pData, nSize);
- }
-
- // Apply appropriate Encoding.
- while (eState == INETMSG_EOL_BEGIN)
- {
- if (pEncodeStrm == NULL)
- {
- // Create encoder stream.
- if (eEncoding == INETMSG_ENCODING_QUOTED)
- {
- // Quoted-Printable Encoding.
- pEncodeStrm = new INetMessageEncodeQPStream_Impl;
- }
- else
- {
- // Base64 Encoding.
- pEncodeStrm = new INetMessageEncode64Stream_Impl;
- }
- pEncodeStrm->SetSourceMessage(pMsg);
- }
-
- // Read encoded message.
- int nRead = pEncodeStrm->Read(pData, nSize);
- if (nRead > 0)
- {
- return nRead;
- }
- else
- {
- // Cleanup exhausted encoder stream.
- delete pEncodeStrm;
- pEncodeStrm = NULL;
-
- // Mark we're done.
- eState = INETMSG_EOL_DONE;
- }
- }
- return 0;
+ // No Encoding.
+ return INetMessageIStream::GetMsgLine(pData, nSize);
}
}
}
commit 8cb1f9ac1ce90b324307711f752591a1acc9a6df
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Sep 10 14:58:26 2015 +0200
A charset is not a content transfer encoding
...the code was in this odd shape ever since
bf4154eb5307ec8c35f000fd1df39ef3abb2eb6d "initial import"
Change-Id: Ic931b99267bb6501f15119636f13391f1d065ed4
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 2c0e67c..8f7d916 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -997,12 +997,13 @@ void ODatabaseForm::InsertTextPart( INetMIMEMessage& rParent, const OUString& rN
aContentDisp.append(rName);
aContentDisp.append('\"');
pChild->SetContentDisposition(aContentDisp.makeStringAndClear());
- pChild->SetContentType(OUString("text/plain"));
rtl_TextEncoding eSystemEncoding = osl_getThreadTextEncoding();
const sal_Char* pBestMatchingEncoding = rtl_getBestMimeCharsetFromTextEncoding( eSystemEncoding );
OUString aBestMatchingEncoding = OUString::createFromAscii(pBestMatchingEncoding);
- pChild->SetContentTransferEncoding(aBestMatchingEncoding);
+ pChild->SetContentType(
+ "text/plain; charset=\"" + aBestMatchingEncoding + "\"");
+ pChild->SetContentTransferEncoding("8bit");
// Body
SvMemoryStream* pStream = new SvMemoryStream;
commit 40bcf53b5d663010efa8360c0d7dd0fe222bacfb
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Sep 10 13:49:11 2015 +0200
Remove unused INetMessageOStream functionality
Change-Id: I34ee4750f30635809b8e23cbf1bd0e16f269f549
diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx
index ea6be1f..9793732 100644
--- a/include/tools/inetstrm.hxx
+++ b/include/tools/inetstrm.hxx
@@ -29,9 +29,6 @@ class SvStream;
enum INetStreamStatus
{
- INETSTREAM_STATUS_LOADED = -4,
- INETSTREAM_STATUS_WOULDBLOCK = -3,
- INETSTREAM_STATUS_OK = -2,
INETSTREAM_STATUS_ERROR = -1
};
@@ -41,9 +38,7 @@ enum INetMessageStreamState
INETMSG_EOL_DONE,
INETMSG_EOL_SCR,
INETMSG_EOL_FCR,
- INETMSG_EOL_FLF,
- INETMSG_EOL_FSP,
- INETMSG_EOL_FESC
+ INETMSG_EOL_FSP
};
/// Message Generator Interface.
@@ -81,35 +76,6 @@ public:
bool IsHeaderGenerated() const { return bHeaderGenerated; }
};
-/// Message Parser Interface.
-class INetMessageOStream
-{
- INetMIMEMessage *pTargetMsg;
- bool bHeaderParsed;
-
- INetMessageStreamState eOState;
-
- SvMemoryStream *pMsgBuffer;
-
- INetMessageOStream (const INetMessageOStream& rStrm) SAL_DELETED_FUNCTION;
- INetMessageOStream& operator= (const INetMessageOStream& rStrm) SAL_DELETED_FUNCTION;
-
-protected:
- virtual int PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize);
-
-public:
- INetMessageOStream();
- virtual ~INetMessageOStream();
-
- int Write (const sal_Char *pData, sal_uIntPtr nSize);
-
- INetMIMEMessage *GetTargetMessage() const { return pTargetMsg; }
- void SetTargetMessage (INetMIMEMessage *pMsg) { pTargetMsg = pMsg; }
-
- void ParseHeader (bool bParse = true) { bHeaderParsed = !bParse; }
- bool IsHeaderParsed() const { return bHeaderParsed; }
-};
-
enum INetMessageEncoding
{
INETMSG_ENCODING_7BIT,
@@ -119,8 +85,7 @@ enum INetMessageEncoding
};
class TOOLS_DLLPUBLIC INetMIMEMessageStream
- : public INetMessageIStream,
- public INetMessageOStream
+ : public INetMessageIStream
{
int eState;
@@ -129,7 +94,6 @@ class TOOLS_DLLPUBLIC INetMIMEMessageStream
INetMessageEncoding eEncoding;
INetMessageIStream *pEncodeStrm;
- INetMessageOStream *pDecodeStrm;
SvMemoryStream *pMsgBuffer;
@@ -141,7 +105,6 @@ class TOOLS_DLLPUBLIC INetMIMEMessageStream
protected:
virtual int GetMsgLine (sal_Char *pData, sal_uIntPtr nSize) SAL_OVERRIDE;
- virtual int PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize) SAL_OVERRIDE;
public:
INetMIMEMessageStream (sal_uIntPtr nBufferSize = 2048);
diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx
index 9836f39..053b649 100644
--- a/tools/source/inet/inetstrm.cxx
+++ b/tools/source/inet/inetstrm.cxx
@@ -26,11 +26,6 @@
#include <ctype.h>
-inline bool SAL_CALL ascii_isWhitespace( sal_Unicode ch )
-{
- return ((ch <= 0x20) && ch);
-}
-
/** Quoted-Printable Encoding */
class INetMessageEncodeQPStream_Impl : public INetMessageIStream
{
@@ -56,22 +51,6 @@ public:
virtual ~INetMessageEncodeQPStream_Impl();
};
-/** Quoted-Printable Decoding */
-class INetMessageDecodeQPStream_Impl : public INetMessageOStream
-{
- INetMessageStreamState eState;
- SvMemoryStream *pMsgBuffer;
-
- sal_uIntPtr nTokBufLen;
- sal_Char pTokBuffer[4];
-
- virtual int PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) SAL_OVERRIDE;
-
-public:
- INetMessageDecodeQPStream_Impl();
- virtual ~INetMessageDecodeQPStream_Impl();
-};
-
/** Base64 Encoding */
class INetMessageEncode64Stream_Impl : public INetMessageIStream
{
@@ -96,23 +75,6 @@ public:
virtual ~INetMessageEncode64Stream_Impl();
};
-/** Base64 Decoding */
-class INetMessageDecode64Stream_Impl : public INetMessageOStream
-{
- INetMessageStreamState eState;
-
- sal_uIntPtr nMsgBufSiz;
- sal_Char* pMsgBuffer;
- sal_Char* pMsgRead;
- sal_Char* pMsgWrite;
-
- virtual int PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize) SAL_OVERRIDE;
-
-public:
- explicit INetMessageDecode64Stream_Impl(sal_uIntPtr nMsgBufferSize = 128);
- virtual ~INetMessageDecode64Stream_Impl();
-};
-
// INetMessageIStream
INetMessageIStream::INetMessageIStream(sal_uIntPtr nBufferSize)
@@ -245,172 +207,6 @@ int INetMessageIStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
return (pWBuf - pData);
}
-// INetMessageOStream
-
-INetMessageOStream::INetMessageOStream()
- : pTargetMsg (NULL),
- bHeaderParsed (false),
- eOState (INETMSG_EOL_BEGIN),
- pMsgBuffer (new SvMemoryStream)
-{
-}
-
-INetMessageOStream::~INetMessageOStream()
-{
- if (pMsgBuffer->Tell() > 0)
- PutMsgLine(static_cast<const sal_Char*>(pMsgBuffer->GetData()), pMsgBuffer->Tell());
- delete pMsgBuffer;
-
- if (pTargetMsg)
- {
- SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pTargetMsg->GetDocumentLB());
- if (pLB)
- {
- pLB->Flush();
- pLB->Terminate();
- }
- }
-}
-
-/// Simple Field Parsing (RFC822, Appendix B)
-int INetMessageOStream::Write(const sal_Char* pData, sal_uIntPtr nSize)
-{
- if (pTargetMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- const sal_Char* pStop = (pData + nSize);
-
- while (!bHeaderParsed && (pData < pStop))
- {
- if (eOState == INETMSG_EOL_BEGIN)
- {
- if ((*pData == '\r') || (*pData == '\n'))
- {
- /*
- * Empty Line. Separates header fields from message body.
- * Skip this and any 2nd line break character (if any).
- */
- pData++;
- if ((pData < pStop) && ((*pData == '\r') || (*pData == '\n')))
- pData++;
-
- // Emit any buffered last header field.
- if (pMsgBuffer->Tell() > 0)
- {
- pMsgBuffer->WriteChar( '\0' );
- int status = PutMsgLine( static_cast<const sal_Char*>(pMsgBuffer->GetData()),
- pMsgBuffer->Tell());
- if (status != INETSTREAM_STATUS_OK) return status;
- }
-
- // Reset to begin.
- eOState = INETMSG_EOL_BEGIN;
- pMsgBuffer->Seek(STREAM_SEEK_TO_BEGIN);
-
- // Mark header parsed.
- bHeaderParsed = true;
- }
- else if ((*pData == ' ') || (*pData == '\t'))
- {
- // Continuation line. Unfold multi-line field-body.
- pMsgBuffer->WriteChar( ' ' );
- pData++;
- }
- else
- {
- // Begin of new header field.
- if (pMsgBuffer->Tell() > 0)
- {
- // Emit buffered header field now.
- pMsgBuffer->WriteChar( '\0' );
- int status = PutMsgLine(static_cast<const sal_Char*>(pMsgBuffer->GetData()),
- pMsgBuffer->Tell());
- if (status != INETSTREAM_STATUS_OK) return status;
- }
-
- // Reset to begin of buffer.
- pMsgBuffer->Seek(STREAM_SEEK_TO_BEGIN);
-
- // Insert current character into buffer.
- pMsgBuffer->WriteChar( *pData++ );
- }
-
- // Search for next line break character.
- if (!bHeaderParsed) eOState = INETMSG_EOL_SCR;
- }
- else if (eOState == INETMSG_EOL_FCR)
- {
- // Skip line break character.
- pData++;
-
- // Mark begin of line.
- eOState = INETMSG_EOL_BEGIN;
- }
- else if ((*pData == '\r') || (*pData == '\n'))
- {
- if (*pData == '\r') pData++;
- eOState = INETMSG_EOL_FCR;
- }
- else if (ascii_isWhitespace(*pData & 0x7f))
- {
- // Any <LWS> is folded into a single <SP> character.
- sal_Char c = *(static_cast<const sal_Char*>(pMsgBuffer->GetData()) + pMsgBuffer->Tell() - 1);
- if (!ascii_isWhitespace(c & 0x7f)) pMsgBuffer->WriteChar( ' ' );
-
- // Skip over this <LWS> character.
- pData++;
- }
- else
- {
- // Any other character is inserted into line buffer.
- pMsgBuffer->WriteChar( *pData++ );
- }
- }
-
- if (bHeaderParsed && (pData < pStop))
- {
- // Put message body down-stream.
- return PutMsgLine(pData, (pStop - pData));
- }
-
- return INETSTREAM_STATUS_OK;
-}
-
-int INetMessageOStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize)
-{
- // Check for message container.
- if (pTargetMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- // Check for header or body.
- if (!IsHeaderParsed())
- {
- OString aField(pData);
- sal_Int32 nPos = aField.indexOf(':');
- if (nPos != -1)
- {
- OString aName( aField.copy(0, nPos));
- OString aValue( aField.copy(nPos + 1, aField.getLength() - nPos + 1));
- aValue = comphelper::string::stripStart(aValue, ' ');
-
- pTargetMsg->SetHeaderField( INetMessageHeader (aName, aValue));
- }
- }
- else
- {
- SvOpenLockBytes *pLB = PTR_CAST(SvOpenLockBytes, pTargetMsg->GetDocumentLB());
- if (pLB == NULL)
- return INETSTREAM_STATUS_WOULDBLOCK;
-
- sal_Size nDocSiz = pTargetMsg->GetDocumentSize();
- sal_Size nWrite = 0;
-
- pLB->FillAppend(pData, nSize, &nWrite);
- pTargetMsg->SetDocumentSize(nDocSiz + nWrite);
-
- if (nWrite < nSize) return INETSTREAM_STATUS_ERROR;
- }
- return INETSTREAM_STATUS_OK;
-}
-
// INetMessageEncodeQPStream_Impl
static const sal_Char hex2pr[16] = {
@@ -611,125 +407,6 @@ int INetMessageEncodeQPStream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSiz
return (pWBuf - pData);
}
-// INetMessageDecodeQPStream_Impl
-
-static const sal_uInt8 pr2hex[128] = {
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-
- 0x10, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
-
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10
-};
-
-INetMessageDecodeQPStream_Impl::INetMessageDecodeQPStream_Impl()
- : INetMessageOStream(),
- eState (INETMSG_EOL_BEGIN),
- pMsgBuffer (new SvMemoryStream),
- nTokBufLen (0)
-{
- ParseHeader(false);
-}
-
-INetMessageDecodeQPStream_Impl::~INetMessageDecodeQPStream_Impl()
-{
- delete pMsgBuffer;
-}
-
-int INetMessageDecodeQPStream_Impl::PutMsgLine( const sal_Char* pData,
- sal_uIntPtr nSize)
-{
- INetMIMEMessage* pMsg = GetTargetMessage();
- if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB());
- if (pLB == NULL) return INETSTREAM_STATUS_WOULDBLOCK;
-
- const sal_Char* pStop = pData + nSize;
- while (pData < pStop)
- {
- if (eState == INETMSG_EOL_FESC)
- {
- *(pTokBuffer + nTokBufLen++) = static_cast< char >(toupper(*pData));
- pData++;
- if (nTokBufLen == 2)
- {
- if ((*pTokBuffer == '\r') || (*pTokBuffer == '\n'))
- {
- // Soft line break (=<CR><LF>). Emit buffer now.
- eState = INETMSG_EOL_BEGIN;
- }
- else
- {
- // Decode token.
- pMsgBuffer->WriteUChar( sal_uInt8 (
- (pr2hex[(int)(pTokBuffer[0] & 0x7f)] << 4) |
- (pr2hex[(int)(pTokBuffer[1] & 0x7f)] & 15) ) );
-
- // Search for next <CR>.
- eState = INETMSG_EOL_SCR;
- }
-
- // Reset token buffer.
- nTokBufLen = 0;
- }
- }
- else if (*pData == '=')
- {
- // Found escape character.
- pData++;
- eState = INETMSG_EOL_FESC;
- }
- else if (eState == INETMSG_EOL_FCR)
- {
- pMsgBuffer->WriteChar( *pData++ );
- eState = INETMSG_EOL_BEGIN;
- }
- else if (*pData == '\r')
- {
- pMsgBuffer->WriteChar( *pData++ );
- eState = INETMSG_EOL_FCR;
- }
- else
- {
- pMsgBuffer->WriteChar( *pData++ );
- }
-
- if (eState == INETMSG_EOL_BEGIN)
- {
- sal_Size nRead = pMsgBuffer->Tell();
- if (nRead > 0)
- {
- // Emit buffer.
- sal_Size nDocSiz = pMsg->GetDocumentSize();
- sal_Size nWrite = 0;
-
- pLB->FillAppend(pMsgBuffer->GetData(), nRead, &nWrite);
- pMsg->SetDocumentSize(nDocSiz + nWrite);
-
- if (nWrite < nRead) return INETSTREAM_STATUS_ERROR;
-
- pMsgBuffer->Seek(STREAM_SEEK_TO_BEGIN);
- }
- eState = INETMSG_EOL_SCR;
- }
- }
- return INETSTREAM_STATUS_OK;
-}
-
// INetMessageEncode64Stream_Impl
static const sal_Char six2pr[64] = {
@@ -888,163 +565,6 @@ int INetMessageEncode64Stream_Impl::GetMsgLine(sal_Char* pData, sal_uIntPtr nSiz
return (pWBuf - pData);
}
-// INetMessageDecode64Stream_Impl
-
-static const sal_uInt8 pr2six[256] = {
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x3E, 0x40, 0x40, 0x40, 0x3F,
- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
- 0x3C, 0x3D, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
- 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
- 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
- 0x17, 0x18, 0x19, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
- 0x31, 0x32, 0x33, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
-
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40
-};
-
-INetMessageDecode64Stream_Impl::INetMessageDecode64Stream_Impl(
- sal_uIntPtr nMsgBufferSize)
- : INetMessageOStream(),
- eState (INETMSG_EOL_SCR),
- nMsgBufSiz (nMsgBufferSize)
-{
- ParseHeader(false);
-
- pMsgBuffer = new sal_Char[nMsgBufSiz];
- pMsgRead = pMsgWrite = pMsgBuffer;
-}
-
-INetMessageDecode64Stream_Impl::~INetMessageDecode64Stream_Impl()
-{
- delete [] pMsgBuffer;
-}
-
-int INetMessageDecode64Stream_Impl::PutMsgLine(const sal_Char* pData,
- sal_uIntPtr nSize)
-{
- INetMIMEMessage* pMsg = GetTargetMessage();
- if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- SvOpenLockBytes* pLB = PTR_CAST(SvOpenLockBytes, pMsg->GetDocumentLB());
- if (pLB == NULL) return INETSTREAM_STATUS_WOULDBLOCK;
-
- const sal_Char* pStop = (pData + nSize);
- while (pData < pStop)
- {
- if (pr2six[(int)(*pData)] > 63)
- {
- /*
- * Character not in base64 alphabet.
- * Check for <End-of-Stream> or Junk.
- */
- if (*pData == '=')
- {
- // Final pad character -> Done.
- sal_Size nDocSiz = pMsg->GetDocumentSize();
- sal_Size nRead = pMsgWrite - pMsgBuffer;
- sal_Size nWrite = 0;
-
- pLB->FillAppend(pMsgBuffer, nRead, &nWrite);
- pMsg->SetDocumentSize(nDocSiz + nWrite);
-
- if (nWrite < nRead)
- return INETSTREAM_STATUS_ERROR;
- else
- return INETSTREAM_STATUS_LOADED;
- }
- else if (eState == INETMSG_EOL_FCR)
- {
- // Skip any line break character.
- if ((*pData == '\r') || (*pData == '\n')) pData++;
-
- // Store decoded message buffer contents.
- sal_Size nDocSiz = pMsg->GetDocumentSize();
- sal_Size nRead = pMsgWrite - pMsgBuffer;
- sal_Size nWrite = 0;
-
- pLB->FillAppend(pMsgBuffer, nRead, &nWrite);
- pMsg->SetDocumentSize(nDocSiz + nWrite);
-
- if (nWrite < nRead) return INETSTREAM_STATUS_ERROR;
-
- // Reset to <Begin-of-Buffer>.
- pMsgWrite = pMsgBuffer;
- eState = INETMSG_EOL_SCR;
- }
- else if ((*pData == '\r') || (*pData == '\n'))
- {
- // Skip any line break character.
- pData++;
- eState = INETMSG_EOL_FCR;
- }
- else
- {
- // Skip any junk character (may be transmission error).
- pData++;
- }
- }
- else
- {
- // Decode any other character into message buffer.
- switch ((pMsgRead - pMsgBuffer) % 4)
- {
- case 0:
- *pMsgWrite = (pr2six[(int)(*pData++)] << 2);
- pMsgRead++;
- break;
-
- case 1:
- *pMsgWrite++ |= (pr2six[(int)(*pData )] >> 4);
- *pMsgWrite = (pr2six[(int)(*pData++)] << 4);
- pMsgRead++;
- break;
-
- case 2:
- *pMsgWrite++ |= (pr2six[(int)(*pData )] >> 2);
- *pMsgWrite = (pr2six[(int)(*pData++)] << 6);
- pMsgRead++;
- break;
-
- default: // == case 3
- *pMsgWrite++ |= (pr2six[(int)(*pData++)]);
- pMsgRead = pMsgBuffer;
- break;
- } // switch ((pMsgRead - pMsgBuffer) % 4)
- }
- } // while (pData < pStop)
- return INETSTREAM_STATUS_OK;
-}
-
// INetMIMEMessageStream
INetMIMEMessageStream::INetMIMEMessageStream(sal_uIntPtr nBufferSize)
@@ -1054,7 +574,6 @@ INetMIMEMessageStream::INetMIMEMessageStream(sal_uIntPtr nBufferSize)
pChildStrm (NULL),
eEncoding (INETMSG_ENCODING_BINARY),
pEncodeStrm (NULL),
- pDecodeStrm (NULL),
pMsgBuffer (NULL)
{
}
@@ -1063,7 +582,6 @@ INetMIMEMessageStream::~INetMIMEMessageStream()
{
delete pChildStrm;
delete pEncodeStrm;
- delete pDecodeStrm;
delete pMsgBuffer;
}
@@ -1324,232 +842,4 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize)
}
}
-/// Message Parser
-int INetMIMEMessageStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize)
-{
- // Check for message container.
- INetMIMEMessage* pMsg = GetTargetMessage();
- if (pMsg == NULL) return INETSTREAM_STATUS_ERROR;
-
- // Check for header or body.
- if (!IsHeaderParsed())
- {
- // Parse the message header.
- int nRet = INetMessageOStream::PutMsgLine(pData, nSize);
- return nRet;
- }
- else
- {
- pMsg->SetHeaderParsed();
- // Parse the message body.
- if (pMsg->IsContainer())
- {
-
- // Content-Transfer-Encoding MUST be "7bit" (RFC1521).
- if (pMsg->IsMessage())
- {
- if( !pChildStrm )
- {
- // Encapsulated message.
- INetMIMEMessage* pNewMessage = new INetMIMEMessage;
- pNewMessage->SetDocumentLB( new SvAsyncLockBytes(new SvMemoryStream(), false));
- pMsg->AttachChild( *pNewMessage );
-
- // Encapsulated message body. Create message parser stream.
- pChildStrm = new INetMIMEMessageStream;
- pChildStrm->SetTargetMessage( pNewMessage );
-
- // Initialize control variables.
- eState = INETMSG_EOL_BEGIN;
- }
- if ( nSize > 0)
- {
- // Bytes still in buffer. Put message down-stream.
- int status = pChildStrm->Write( pData, nSize );
- if (status != INETSTREAM_STATUS_OK)
- return status;
- }
-
- return INetMessageOStream::PutMsgLine(pData, nSize);
- }
- else
- {
-
- // Multipart message body. Initialize multipart delimiters.
- // Multipart message.
- if (pMsg->GetMultipartBoundary().getLength() == 0)
- {
- // Determine boundary.
- OString aType(OUStringToOString(
- pMsg->GetContentType(), RTL_TEXTENCODING_ASCII_US));
- OString aLowerType(aType.toAsciiLowerCase());
-
- sal_Int32 nPos = aLowerType.indexOf("boundary=");
- OString aBoundary(aType.copy(nPos + 9));
-
- aBoundary = comphelper::string::strip(aBoundary, ' ');
- aBoundary = comphelper::string::strip(aBoundary, '"');
-
- // Save boundary.
- pMsg->SetMultipartBoundary(aBoundary);
- }
-
- OString aPlainDelim(pMsg->GetMultipartBoundary());
- OString aDelim = OStringBuffer("--").
- append(aPlainDelim).
- makeStringAndClear();
- OString aPlainClose = OStringBuffer(
- aPlainDelim).
- append("--").
- makeStringAndClear();
- OString aClose = OStringBuffer(
- aDelim).
- append("--").
- makeStringAndClear();
-
- if (pMsgBuffer == NULL) pMsgBuffer = new SvMemoryStream;
- pMsgBuffer->Write(pData, nSize);
- sal_uIntPtr nBufSize = pMsgBuffer->Tell();
-
- const sal_Char* pChar;
- const sal_Char* pOldPos;
- int status;
- for( pOldPos = pChar = static_cast<const sal_Char*>(pMsgBuffer->GetData()); nBufSize--;
- pChar++ )
- {
- if( *pChar == '\r' || *pChar == '\n' )
- {
- if( aDelim.compareTo(pOldPos, aDelim.getLength())
- != -1 &&
- aClose.compareTo(pOldPos, aClose.getLength())
- != -1 &&
- aPlainDelim.compareTo(pOldPos, aPlainDelim.getLength())
- != -1 &&
- aPlainClose.compareTo(pOldPos, aPlainClose.getLength())
- != -1 )
- {
- if( nBufSize &&
- ( pChar[1] == '\r' || pChar[1] == '\n' ) )
- nBufSize--, pChar++;
- if( pChildStrm )
- {
- status = pChildStrm->Write(
- pOldPos, pChar - pOldPos + 1 );
- if( status != INETSTREAM_STATUS_OK )
- return status;
- }
- else {
- SAL_WARN( "tools.stream", "Boundary not found." );
- }
- status = INetMessageOStream::PutMsgLine(
- pOldPos, pChar - pOldPos + 1 );
- if( status != INETSTREAM_STATUS_OK )
- return status;
- pOldPos = pChar + 1;
- }
- else
- {
- if( nBufSize &&
- ( pChar[1] == '\r' || pChar[1] == '\n' ) )
- nBufSize--, pChar++;
- pOldPos = pChar + 1;
- DELETEZ( pChildStrm );
-
- if (aClose.compareTo(pOldPos, aClose.getLength())
- != -1 &&
- aPlainClose.compareTo(pOldPos, aClose.getLength())
- != -1 )
- {
- // Encapsulated message.
- INetMIMEMessage* pNewMessage =
- new INetMIMEMessage;
- pNewMessage->SetDocumentLB(
- new SvAsyncLockBytes(
- new SvMemoryStream(), false));
-
- pMsg->AttachChild( *pNewMessage );
-
- // Encapsulated message body. Create message parser stream.
- pChildStrm = new INetMIMEMessageStream;
- pChildStrm->SetTargetMessage( pNewMessage );
-
- // Initialize control variables.
- }
- eState = INETMSG_EOL_BEGIN;
- status = INetMessageOStream::PutMsgLine(
- pOldPos, pChar - pOldPos + 1 );
- if( status != INETSTREAM_STATUS_OK )
- return status;
- }
- }
- }
- if( pOldPos < pChar )
- {
- SvMemoryStream* pNewStream = new SvMemoryStream;
- pNewStream->Write( pOldPos, pChar - pOldPos );
- SvMemoryStream* pTmp = pMsgBuffer;
- pMsgBuffer = pNewStream;
- delete pTmp;
- }
- else
- {
- pMsgBuffer->Seek( 0L );
- pMsgBuffer->SetStreamSize( 0 );
- }
- return INETSTREAM_STATUS_OK;
- }
- }
- else
- {
- /*
- * Single part message.
- * Remove any ContentTransferEncoding.
- */
- if (pMsg->GetContentType().isEmpty())
- {
- pMsg->SetContentType(pMsg->GetDefaultContentType());
- }
-
- if (eEncoding == INETMSG_ENCODING_BINARY)
- {
- OUString aEncoding(pMsg->GetContentTransferEncoding());
- if (aEncoding.startsWithIgnoreAsciiCase("base64"))
- {
- eEncoding = INETMSG_ENCODING_BASE64;
- }
- else if (aEncoding.startsWithIgnoreAsciiCase("quoted-printable"))
- {
- eEncoding = INETMSG_ENCODING_QUOTED;
- }
- else
- {
- eEncoding = INETMSG_ENCODING_7BIT;
- }
- }
-
- if (eEncoding == INETMSG_ENCODING_7BIT)
- {
- // No decoding necessary.
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list