28int INetMIMEMessageStream::GetHeaderLine(
char* pData, sal_uInt32 nSize)
34 if (maMsgBuffer.Tell() == 0)
37 n = pSourceMsg->GetHeaderCount();
38 for (i = 0;
i <
n;
i++)
41 if (aHeader.GetValue().getLength())
44 maMsgBuffer.WriteOString( aHeader.GetName() );
45 maMsgBuffer.WriteOString(
": " );
46 maMsgBuffer.WriteOString( aHeader.GetValue() );
47 maMsgBuffer.WriteOString(
"\r\n" );
51 pMsgWrite =
const_cast<char *
>(
static_cast<char const *
>(maMsgBuffer.GetData()));
52 pMsgRead = pMsgWrite + maMsgBuffer.Tell();
55 n = pMsgRead - pMsgWrite;
59 if (nSize < n)
n = nSize;
60 for (i = 0;
i <
n;
i++) *pWBuf++ = *pMsgWrite++;
68 return (pWBuf - pData);
71int INetMIMEMessageStream::GetBodyLine(
char* pData, sal_uInt32 nSize)
74 char* pWEnd =
pData + nSize;
76 if (pSourceMsg->GetDocumentLB())
78 if (pMsgStrm ==
nullptr)
79 pMsgStrm.reset(
new SvStream (pSourceMsg->GetDocumentLB()));
81 sal_uInt32 nRead = pMsgStrm->ReadBytes(pWBuf, (pWEnd - pWBuf));
85 return (pWBuf - pData);
88int INetMIMEMessageStream::GetMsgLine(
char* pData, sal_uInt32 nSize)
91 if (!bHeaderGenerated)
96 if (pSourceMsg->GetParent())
98 OUString aPCT(pSourceMsg->GetParent()->GetContentType());
99 if (aPCT.startsWithIgnoreAsciiCase(
"message/rfc822"))
100 pSourceMsg->SetMIMEVersion(
"1.0");
102 pSourceMsg->SetMIMEVersion(OUString());
106 pSourceMsg->SetMIMEVersion(
"1.0");
110 OUString aContentType(pSourceMsg->GetContentType());
111 if (!aContentType.isEmpty())
114 OUString aDefaultType = pSourceMsg->GetDefaultContentType();
116 if (aDefaultType.equalsIgnoreAsciiCase(aContentType))
119 pSourceMsg->SetContentType(OUString());
124 pSourceMsg->SetContentTransferEncoding(OUString());
131 int nRead = GetHeaderLine(pData, nSize);
142 if (pSourceMsg->IsContainer())
147 if (pChildStrm ==
nullptr)
149 INetMIMEMessage *pChild = pSourceMsg->GetChild(nChildIndex);
156 pChildStrm.reset(
new INetMIMEMessageStream(pChild,
false));
158 if (pSourceMsg->IsMultipart())
161 OString aDelim =
"--" +
162 pSourceMsg->GetMultipartBoundary() +
165 memcpy(pData, aDelim.getStr(),
167 return aDelim.getLength();
176 if (pSourceMsg->IsMultipart())
179 OString aDelim =
"--" +
180 pSourceMsg->GetMultipartBoundary() +
183 memcpy(pData, aDelim.getStr(),
185 return aDelim.getLength();
192 int nRead = pChildStrm->Read(pData, nSize);
209 if (pSourceMsg->GetDocumentLB() ==
nullptr)
216 return GetBodyLine(pData, nSize);
228INetMIMEMessageStream::INetMIMEMessageStream(
229 INetMIMEMessage *pMsg,
bool headerGenerated):
231 bHeaderGenerated(headerGenerated),
238 assert(pMsg !=
nullptr);
239 maMsgBuffer.SetStreamCharSet(RTL_TEXTENCODING_ASCII_US);
240 pRead = pWrite = mvBuffer.data();
243INetMIMEMessageStream::~INetMIMEMessageStream()
248int INetMIMEMessageStream::Read(
char* pData, sal_uInt32 nSize)
251 char* pWEnd =
pData + nSize;
253 while (pWBuf < pWEnd)
256 sal_uInt32
n = pRead - pWrite;
260 sal_uInt32
m = pWEnd - pWBuf;
262 for (sal_uInt32 i = 0;
i <
n;
i++) *pWBuf++ = *pWrite++;
267 pRead = pWrite = mvBuffer.data();
270 int nRead = GetMsgLine(mvBuffer.data(), mvBuffer.size());
274 pRead = mvBuffer.data() + nRead;
278 if (!bHeaderGenerated)
281 bHeaderGenerated =
true;
288 return (pWBuf - pData);
293 return (pWBuf - pData);
std::unique_ptr< sal_Int32[]> pData
#define STREAM_SEEK_TO_BEGIN