Kaydet (Commit) 694e2cbf authored tarafından Caolán McNamara's avatar Caolán McNamara

There's no reason for GetDefaultContentType to be virtual

unroll the logic a bit to simplify the only relevant case and take advantage of
return optimization

Change-Id: I88537e83e8fc6785d3932fb4c591d62319682c9b
üst 46d1a28a
......@@ -500,7 +500,7 @@ public:
return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]);
}
virtual void GetDefaultContentType (UniString& rContentType);
UniString GetDefaultContentType ();
/** Message container methods.
*/
......
......@@ -1033,36 +1033,18 @@ void INetMIMEMessage::SetContentTransferEncoding (
/*
* GetDefaultContentType.
*/
void INetMIMEMessage::GetDefaultContentType (String& rContentType)
UniString INetMIMEMessage::GetDefaultContentType()
{
String aDefaultCT (
"text/plain; charset=us-ascii", RTL_TEXTENCODING_ASCII_US);
if (pParent == NULL)
{
rContentType = aDefaultCT;
}
else
if (pParent != NULL)
{
String aParentCT (pParent->GetContentType());
if (aParentCT.Len() == 0)
pParent->GetDefaultContentType (aParentCT);
aParentCT = pParent->GetDefaultContentType();
if (aParentCT.CompareIgnoreCaseToAscii ("message/", 8) == 0)
{
rContentType = aDefaultCT;
}
else if (aParentCT.CompareIgnoreCaseToAscii ("multipart/", 10) == 0)
{
if (aParentCT.CompareIgnoreCaseToAscii ("multipart/digest") == 0)
rContentType.AssignAscii ("message/rfc822");
else
rContentType = aDefaultCT;
}
else
{
rContentType = aDefaultCT;
}
if (aParentCT.CompareIgnoreCaseToAscii ("multipart/digest") == 0)
return rtl::OUString("message/rfc822");
}
return String("text/plain; charset=us-ascii", RTL_TEXTENCODING_ASCII_US);
}
/*
......
......@@ -1349,8 +1349,7 @@ int INetMIMEMessageStream::GetMsgLine (sal_Char *pData, sal_uIntPtr nSize)
if (aContentType.Len())
{
// Determine default Content-Type.
UniString aDefaultType;
pMsg->GetDefaultContentType (aDefaultType);
UniString aDefaultType = pMsg->GetDefaultContentType();
if (aDefaultType.CompareIgnoreCaseToAscii (
aContentType, aContentType.Len()) == 0)
......@@ -1380,7 +1379,7 @@ int INetMIMEMessageStream::GetMsgLine (sal_Char *pData, sal_uIntPtr nSize)
if (aContentType.Len() == 0)
{
// Determine default Content-Type.
pMsg->GetDefaultContentType (aContentType);
aContentType = pMsg->GetDefaultContentType();
}
eEncoding = GetMsgEncoding (aContentType);
}
......@@ -1739,8 +1738,7 @@ int INetMIMEMessageStream::PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize)
*/
if (pMsg->GetContentType().Len() == 0)
{
String aDefaultCT;
pMsg->GetDefaultContentType (aDefaultCT);
String aDefaultCT = pMsg->GetDefaultContentType();
pMsg->SetContentType (aDefaultCT);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment