ByteString->rtl::OString[Buffer]

This commit is contained in:
Caolán McNamara
2011-11-16 21:20:20 +00:00
parent 7bab4645ce
commit c4927a1b76
3 changed files with 92 additions and 109 deletions

View File

@@ -80,26 +80,16 @@ public:
friend SvStream& operator<< ( friend SvStream& operator<< (
SvStream& rStrm, const INetMessageHeader& rHdr) SvStream& rStrm, const INetMessageHeader& rHdr)
{ {
#ifdef ENABLE_BYTESTRING_STREAM_OPERATORS
rStrm << rHdr.m_aName;
rStrm << rHdr.m_aValue;
#else
rStrm.WriteByteString (rHdr.m_aName); rStrm.WriteByteString (rHdr.m_aName);
rStrm.WriteByteString (rHdr.m_aValue); rStrm.WriteByteString (rHdr.m_aValue);
#endif
return rStrm; return rStrm;
} }
friend SvStream& operator>> ( friend SvStream& operator>> (
SvStream& rStrm, INetMessageHeader& rHdr) SvStream& rStrm, INetMessageHeader& rHdr)
{ {
#ifdef ENABLE_BYTESTRING_STREAM_OPERATORS
rStrm >> rHdr.m_aName;
rStrm >> rHdr.m_aValue;
#else
rStrm.ReadByteString (rHdr.m_aName); rStrm.ReadByteString (rHdr.m_aName);
rStrm.ReadByteString (rHdr.m_aValue); rStrm.ReadByteString (rHdr.m_aValue);
#endif
return rStrm; return rStrm;
} }
}; };
@@ -160,7 +150,7 @@ protected:
void SetHeaderField_Impl ( void SetHeaderField_Impl (
INetMIME::HeaderFieldType eType, INetMIME::HeaderFieldType eType,
const ByteString &rName, const rtl::OString &rName,
const UniString &rValue, const UniString &rValue,
sal_uIntPtr &rnIndex); sal_uIntPtr &rnIndex);

View File

@@ -110,7 +110,7 @@ void INetMessage::ListCopy (const INetMessage &rMsg)
*/ */
void INetMessage::SetHeaderField_Impl ( void INetMessage::SetHeaderField_Impl (
INetMIME::HeaderFieldType eType, INetMIME::HeaderFieldType eType,
const ByteString &rName, const rtl::OString &rName,
const UniString &rValue, const UniString &rValue,
sal_uIntPtr &rnIndex) sal_uIntPtr &rnIndex)
{ {
@@ -194,33 +194,33 @@ namespace
{ {
struct ImplINetRFC822MessageHeaderDataImpl struct ImplINetRFC822MessageHeaderDataImpl
{ {
const ByteString* operator()() const rtl::OString* operator()()
{ {
static const ByteString _ImplINetRFC822MessageHeaderData[] = static const rtl::OString _ImplINetRFC822MessageHeaderData[] =
{ {
ByteString ("BCC"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("BCC")),
ByteString ("CC"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("CC")),
ByteString ("Comments"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Comments")),
ByteString ("Date"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Date")),
ByteString ("From"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("From")),
ByteString ("In-Reply-To"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("In-Reply-To")),
ByteString ("Keywords"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Keywords")),
ByteString ("Message-ID"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Message-ID")),
ByteString ("References"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("References")),
ByteString ("Reply-To"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Reply-To")),
ByteString ("Return-Path"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Return-Path")),
ByteString ("Subject"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Subject")),
ByteString ("Sender"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Sender")),
ByteString ("To"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("To")),
ByteString ("X-Mailer"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("X-Mailer")),
ByteString ("Return-Receipt-To") rtl::OString(RTL_CONSTASCII_STRINGPARAM("Return-Receipt-To"))
}; };
return &_ImplINetRFC822MessageHeaderData[0]; return &_ImplINetRFC822MessageHeaderData[0];
} }
}; };
struct ImplINetRFC822MessageHeaderData struct ImplINetRFC822MessageHeaderData
: public rtl::StaticAggregate< const ByteString, ImplINetRFC822MessageHeaderDataImpl > {}; : public rtl::StaticAggregate< const rtl::OString, ImplINetRFC822MessageHeaderDataImpl > {};
} }
#define HDR(n) ImplINetRFC822MessageHeaderData::get()[(n)] #define HDR(n) ImplINetRFC822MessageHeaderData::get()[(n)]
@@ -305,28 +305,28 @@ static const sal_Char *months[12] =
/* /*
* ParseDateField and local helper functions. * ParseDateField and local helper functions.
*/ */
static sal_uInt16 ParseNumber (const ByteString& rStr, sal_uInt16& nIndex) static sal_uInt16 ParseNumber(const rtl::OString& rStr, sal_uInt16& nIndex)
{ {
sal_uInt16 n = nIndex; sal_uInt16 n = nIndex;
while ((n < rStr.Len()) && ascii_isDigit(rStr.GetChar(n))) n++; while ((n < rStr.getLength()) && ascii_isDigit(rStr[n])) n++;
rtl::OString aNum (rStr.Copy (nIndex, (n - nIndex))); rtl::OString aNum(rStr.copy(nIndex, (n - nIndex)));
nIndex = n; nIndex = n;
return (sal_uInt16)(aNum.toInt32()); return (sal_uInt16)(aNum.toInt32());
} }
static sal_uInt16 ParseMonth (const ByteString& rStr, sal_uInt16& nIndex) static sal_uInt16 ParseMonth(const rtl::OString& rStr, sal_uInt16& nIndex)
{ {
sal_uInt16 n = nIndex; sal_uInt16 n = nIndex;
while ((n < rStr.Len()) && ascii_isLetter(rStr.GetChar(n))) n++; while ((n < rStr.getLength()) && ascii_isLetter(rStr[n])) n++;
ByteString aMonth (rStr.Copy (nIndex, 3)); rtl::OString aMonth(rStr.copy(nIndex, 3));
nIndex = n; nIndex = n;
sal_uInt16 i; sal_uInt16 i;
for (i = 0; i < 12; i++) for (i = 0; i < 12; i++)
if (aMonth.CompareIgnoreCaseToAscii (months[i]) == 0) break; if (aMonth.equalsIgnoreAsciiCase(months[i])) break;
return (i + 1); return (i + 1);
} }
@@ -446,9 +446,9 @@ sal_Bool INetRFC822Message::ParseDateField (
sal_uIntPtr INetRFC822Message::SetHeaderField ( sal_uIntPtr INetRFC822Message::SetHeaderField (
const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex) const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex)
{ {
ByteString aName (rHeader.GetName()); rtl::OString aName (rHeader.GetName());
const sal_Char *pData = aName.GetBuffer(); const sal_Char *pData = aName.getStr();
const sal_Char *pStop = pData + aName.Len() + 1; const sal_Char *pStop = pData + aName.getLength() + 1;
const sal_Char *check = ""; const sal_Char *check = "";
sal_uIntPtr nIdx = LIST_APPEND; sal_uIntPtr nIdx = LIST_APPEND;
@@ -716,23 +716,23 @@ namespace
{ {
struct ImplINetMIMEMessageHeaderDataImpl struct ImplINetMIMEMessageHeaderDataImpl
{ {
const ByteString* operator()() const rtl::OString* operator()()
{ {
static const ByteString _ImplINetMIMEMessageHeaderData[] = static const rtl::OString _ImplINetMIMEMessageHeaderData[] =
{ {
ByteString ("MIME-Version"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("MIME-Version")),
ByteString ("Content-Description"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Content-Description")),
ByteString ("Content-Disposition"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Content-Disposition")),
ByteString ("Content-ID"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Content-ID")),
ByteString ("Content-Type"), rtl::OString(RTL_CONSTASCII_STRINGPARAM("Content-Type")),
ByteString ("Content-Transfer-Encoding") rtl::OString(RTL_CONSTASCII_STRINGPARAM("Content-Transfer-Encoding"))
}; };
return &_ImplINetMIMEMessageHeaderData[0]; return &_ImplINetMIMEMessageHeaderData[0];
} }
}; };
struct ImplINetMIMEMessageHeaderData struct ImplINetMIMEMessageHeaderData
: public rtl::StaticAggregate< const ByteString, ImplINetMIMEMessageHeaderDataImpl > {}; : public rtl::StaticAggregate< const rtl::OString, ImplINetMIMEMessageHeaderDataImpl > {};
} }
#define MIMEHDR(n) ImplINetMIMEMessageHeaderData::get()[(n)] #define MIMEHDR(n) ImplINetMIMEMessageHeaderData::get()[(n)]
@@ -853,9 +853,9 @@ INetMIMEMessage *INetMIMEMessage::CreateMessage (
sal_uIntPtr INetMIMEMessage::SetHeaderField ( sal_uIntPtr INetMIMEMessage::SetHeaderField (
const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex) const INetMessageHeader &rHeader, sal_uIntPtr nNewIndex)
{ {
ByteString aName (rHeader.GetName()); rtl::OString aName (rHeader.GetName());
const sal_Char *pData = aName.GetBuffer(); const sal_Char *pData = aName.getStr();
const sal_Char *pStop = pData + aName.Len() + 1; const sal_Char *pStop = pData + aName.getLength() + 1;
const sal_Char *check = ""; const sal_Char *check = "";
sal_uIntPtr nIdx = LIST_APPEND; sal_uIntPtr nIdx = LIST_APPEND;
@@ -1077,40 +1077,40 @@ sal_Bool INetMIMEMessage::EnableAttachChild (INetMessageContainerType eType)
return sal_False; return sal_False;
// Setup Content-Type header field. // Setup Content-Type header field.
ByteString aContentType; rtl::OStringBuffer aContentType;
switch (eType) switch (eType)
{ {
case INETMSG_MESSAGE_RFC822: case INETMSG_MESSAGE_RFC822:
aContentType = "message/rfc822"; aContentType.append(RTL_CONSTASCII_STRINGPARAM("message/rfc822"));
break; break;
case INETMSG_MULTIPART_ALTERNATIVE: case INETMSG_MULTIPART_ALTERNATIVE:
aContentType = "multipart/alternative"; aContentType.append(RTL_CONSTASCII_STRINGPARAM("multipart/alternative"));
break; break;
case INETMSG_MULTIPART_DIGEST: case INETMSG_MULTIPART_DIGEST:
aContentType = "multipart/digest"; aContentType.append(RTL_CONSTASCII_STRINGPARAM("multipart/digest"));
break; break;
case INETMSG_MULTIPART_PARALLEL: case INETMSG_MULTIPART_PARALLEL:
aContentType = "multipart/parallel"; aContentType.append(RTL_CONSTASCII_STRINGPARAM("multipart/parallel"));
break; break;
case INETMSG_MULTIPART_RELATED: case INETMSG_MULTIPART_RELATED:
aContentType = "multipart/related"; aContentType.append(RTL_CONSTASCII_STRINGPARAM("multipart/related"));
break; break;
case INETMSG_MULTIPART_FORM_DATA: case INETMSG_MULTIPART_FORM_DATA:
aContentType = "multipart/form-data"; aContentType.append(RTL_CONSTASCII_STRINGPARAM("multipart/form-data"));
break; break;
default: default:
aContentType = "multipart/mixed"; aContentType.append(RTL_CONSTASCII_STRINGPARAM("multipart/mixed"));
break; break;
} }
// Setup boundary for multipart types. // Setup boundary for multipart types.
if (aContentType.CompareIgnoreCaseToAscii ("multipart/", 10) == 0) if (aContentType.toString().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("multipart/")))
{ {
// Generate a unique boundary from current time. // Generate a unique boundary from current time.
sal_Char sTail[16 + 1]; sal_Char sTail[16 + 1];
@@ -1124,13 +1124,13 @@ sal_Bool INetMIMEMessage::EnableAttachChild (INetMessageContainerType eType)
m_aBoundary += sTail; m_aBoundary += sTail;
// Append boundary as ContentType parameter. // Append boundary as ContentType parameter.
aContentType += "; boundary="; aContentType.append(RTL_CONSTASCII_STRINGPARAM("; boundary="));
aContentType += m_aBoundary; aContentType.append(m_aBoundary);
} }
// Set header fields. // Set header fields.
SetMIMEVersion (String (CONSTASCII_STRINGPARAM("1.0"))); SetMIMEVersion (String (CONSTASCII_STRINGPARAM("1.0")));
SetContentType (String (aContentType, RTL_TEXTENCODING_ASCII_US)); SetContentType (rtl::OStringToOUString(aContentType.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US));
SetContentTransferEncoding (String (CONSTASCII_STRINGPARAM("7bit"))); SetContentTransferEncoding (String (CONSTASCII_STRINGPARAM("7bit")));
// Done. // Done.
@@ -1163,11 +1163,7 @@ SvStream& INetMIMEMessage::operator<< (SvStream& rStrm) const
for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++)
rStrm << static_cast<sal_uInt32>(m_nIndex[i]); rStrm << static_cast<sal_uInt32>(m_nIndex[i]);
#ifdef ENABLE_BYTESTRING_STREAM_OPERATORS
rStrm << m_aBoundary;
#else
rStrm.WriteByteString (m_aBoundary); rStrm.WriteByteString (m_aBoundary);
#endif
rStrm << static_cast<sal_uInt32>(aChildren.size()); rStrm << static_cast<sal_uInt32>(aChildren.size());
return rStrm; return rStrm;
@@ -1187,11 +1183,8 @@ SvStream& INetMIMEMessage::operator>> (SvStream& rStrm)
m_nIndex[i] = nTemp; m_nIndex[i] = nTemp;
} }
#ifdef ENABLE_BYTESTRING_STREAM_OPERATORS
rStrm >> m_aBoundary;
#else
rStrm.ReadByteString (m_aBoundary); rStrm.ReadByteString (m_aBoundary);
#endif
rStrm >> nTemp; rStrm >> nTemp;
return rStrm; return rStrm;

View File

@@ -203,17 +203,15 @@ class ErrHdl_Impl
const ErrorInfo*, String&, sal_uInt16&); const ErrorInfo*, String&, sal_uInt16&);
}; };
static void aDspFunc(const String &rErr, const String &rAction) static void aDspFunc(const String &rErr, const String &rAction)
{ {
ByteString aErr("Aktion: "); rtl::OStringBuffer aErr(RTL_CONSTASCII_STRINGPARAM("Aktion: "));
aErr+= ByteString( rAction, RTL_TEXTENCODING_ASCII_US ); aErr.append(rtl::OUStringToOString(rAction, RTL_TEXTENCODING_ASCII_US));
aErr+=" Fehler: "; aErr.append(RTL_CONSTASCII_STRINGPARAM(" Fehler: "));
aErr+= ByteString( rErr, RTL_TEXTENCODING_ASCII_US ); aErr.append(rtl::OUStringToOString(rErr, RTL_TEXTENCODING_ASCII_US));
OSL_FAIL(aErr.GetBuffer()); OSL_FAIL(aErr.getStr());
} }
ErrorContext::ErrorContext(Window *pWinP) ErrorContext::ErrorContext(Window *pWinP)
{ {
EDcrData *pData=EDcrData::GetData(); EDcrData *pData=EDcrData::GetData();
@@ -327,45 +325,47 @@ sal_uInt16 ErrorHandler::HandleError_Impl(
if(ErrHdl_Impl::CreateString(pData->pFirstHdl,pInfo,aErr,nErrFlags)) if(ErrHdl_Impl::CreateString(pData->pFirstHdl,pInfo,aErr,nErrFlags))
{ {
if (bJustCreateString) if (bJustCreateString)
{
rError = aErr;
return 1;
}
else
{
if(!pData->pDsp)
{ {
ByteString aStr("Action: "); rError = aErr;
aStr += ByteString( aAction, RTL_TEXTENCODING_ASCII_US ); return 1;
aStr += ByteString("\nFehler: ");
aStr += ByteString( aErr, RTL_TEXTENCODING_ASCII_US );
OSL_FAIL( aStr.GetBuffer() );
} }
else else
{ {
delete pInfo; if(!pData->pDsp)
if(!pData->bIsWindowDsp) {
{ rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Action: "));
(*(BasicDisplayErrorFunc*)pData->pDsp)(aErr,aAction); aStr.append(rtl::OUStringToOString(aAction, RTL_TEXTENCODING_ASCII_US));
return 0; aStr.append(RTL_CONSTASCII_STRINGPARAM("\nFehler: "));
aStr.append(rtl::OUStringToOString(aErr, RTL_TEXTENCODING_ASCII_US));
OSL_FAIL(aStr.getStr());
}
else
{
delete pInfo;
if(!pData->bIsWindowDsp)
{
(*(BasicDisplayErrorFunc*)pData->pDsp)(aErr,aAction);
return 0;
}
else
{
if( nFlags != USHRT_MAX )
nErrFlags = nFlags;
return (*(WindowDisplayErrorFunc*)pData->pDsp)(
pParent, nErrFlags, aErr, aAction);
}
}
} }
else
{
if( nFlags != USHRT_MAX )
nErrFlags = nFlags;
return (*(WindowDisplayErrorFunc*)pData->pDsp)(
pParent, nErrFlags, aErr, aAction);
}
}
}
} }
OSL_FAIL("Error nicht behandelt"); OSL_FAIL("Error nicht behandelt");
// Error 1 ist General Error im Sfx // Error 1 ist General Error im Sfx
if(pInfo->GetErrorCode()!=1) { if(pInfo->GetErrorCode()!=1)
{
HandleError_Impl(1, USHRT_MAX, bJustCreateString, rError); HandleError_Impl(1, USHRT_MAX, bJustCreateString, rError);
} }
else { else
{
OSL_FAIL("Error 1 nicht gehandeled"); OSL_FAIL("Error 1 nicht gehandeled");
} }
delete pInfo; delete pInfo;