[Libreoffice-commits] core.git: 8 commits - include/tools tools/qa tools/source
Stephan Bergmann
sbergman at redhat.com
Thu Sep 17 13:25:33 PDT 2015
include/tools/inetmime.hxx | 465 ---
include/tools/inetmsg.hxx | 8
tools/qa/cppunit/test_inetmime.cxx | 3
tools/source/inet/inetmime.cxx | 5183 +++++++++++++++----------------------
tools/source/inet/inetmsg.cxx | 7
5 files changed, 2246 insertions(+), 3420 deletions(-)
New commits:
commit 9ce08dcc2e32c5554ddf71b79173f8854e0568ad
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Sep 17 21:19:56 2015 +0200
writeHeaderFieldBody is only called with bInitialSpace = false
Change-Id: Ib7fe0bee6339bfad0f63794fec3dfb3f24333ff4
diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx
index 37ca4f0..5a0254a 100644
--- a/include/tools/inetmime.hxx
+++ b/include/tools/inetmime.hxx
@@ -205,8 +205,7 @@ public:
static void writeHeaderFieldBody(INetMIMEOutputSink & rSink,
const OUString& rBody,
- rtl_TextEncoding ePreferredEncoding,
- bool bInitialSpace = true);
+ rtl_TextEncoding ePreferredEncoding);
static OUString decodeHeaderFieldBody(const OString& rBody);
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index 95b8852..5e75767 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -972,9 +972,6 @@ createPreferredCharsetList(rtl_TextEncoding eEncoding)
class INetMIMEEncodedWordOutputSink
{
-public:
- enum Space { SPACE_NO, SPACE_ALWAYS };
-
private:
enum { BUFFER_SIZE = 256 };
@@ -988,7 +985,6 @@ private:
STATE_BAD };
INetMIMEOutputSink & m_rSink;
- Space m_eInitialSpace;
sal_uInt32 m_nExtraSpaces;
INetMIMECharsetList_Impl * m_pEncodingList;
sal_Unicode * m_pBuffer;
@@ -1003,7 +999,6 @@ private:
public:
inline INetMIMEEncodedWordOutputSink(INetMIMEOutputSink & rTheSink,
- Space eTheInitialSpace,
rtl_TextEncoding ePreferredEncoding);
~INetMIMEEncodedWordOutputSink();
@@ -1016,10 +1011,8 @@ public:
};
inline INetMIMEEncodedWordOutputSink::INetMIMEEncodedWordOutputSink(
- INetMIMEOutputSink & rTheSink,
- Space eTheInitialSpace, rtl_TextEncoding ePreferredEncoding):
+ INetMIMEOutputSink & rTheSink, rtl_TextEncoding ePreferredEncoding):
m_rSink(rTheSink),
- m_eInitialSpace(eTheInitialSpace),
m_nExtraSpaces(0),
m_pEncodingList(createPreferredCharsetList(ePreferredEncoding)),
m_ePrevCoding(CODING_NONE),
@@ -1190,9 +1183,6 @@ needsEncodedWordEscape(sal_uInt32 nChar)
void INetMIMEEncodedWordOutputSink::finish(bool bWriteTrailer)
{
- if (m_eInitialSpace == SPACE_ALWAYS && m_nExtraSpaces == 0)
- m_nExtraSpaces = 1;
-
if (m_eEncodedWordState == STATE_SECOND_EQUALS)
{
// If the text is already an encoded word, copy it verbatim:
@@ -1405,7 +1395,6 @@ void INetMIMEEncodedWordOutputSink::finish(bool bWriteTrailer)
}
}
- m_eInitialSpace = SPACE_NO;
m_nExtraSpaces = 0;
m_pEncodingList->reset();
m_pBufferEnd = m_pBuffer;
@@ -2398,15 +2387,9 @@ sal_Unicode const * INetMIME::scanContentType(
// static
void INetMIME::writeHeaderFieldBody(INetMIMEOutputSink & rSink,
const OUString& rBody,
- rtl_TextEncoding ePreferredEncoding,
- bool bInitialSpace)
+ rtl_TextEncoding ePreferredEncoding)
{
- INetMIMEEncodedWordOutputSink
- aOutput(rSink,
- bInitialSpace ?
- INetMIMEEncodedWordOutputSink::SPACE_ALWAYS :
- INetMIMEEncodedWordOutputSink::SPACE_NO,
- ePreferredEncoding);
+ INetMIMEEncodedWordOutputSink aOutput(rSink, ePreferredEncoding);
aOutput.write(rBody.getStr(), rBody.getStr() + rBody.getLength());
aOutput.flush();
}
diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx
index d6ae40b..8b74bd0 100644
--- a/tools/source/inet/inetmsg.cxx
+++ b/tools/source/inet/inetmsg.cxx
@@ -47,7 +47,7 @@ void INetMIMEMessage::SetHeaderField_Impl (
{
INetMIMEOutputSink aSink;
INetMIME::writeHeaderFieldBody (
- aSink, rValue, osl_getThreadTextEncoding(), false);
+ aSink, rValue, osl_getThreadTextEncoding());
SetHeaderField_Impl (
INetMessageHeader (rName, aSink.takeBuffer()), rnIndex);
}
commit a68b0ef5c1b205e8994b9789765b42bcf028e9e5
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Sep 17 21:11:22 2015 +0200
CODING_QUOTED has become unused
Change-Id: I012b7d407cb50ba01fcc3b98ea2fe1968ec74a28
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index 4f0e17d..95b8852 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -80,8 +80,6 @@ const sal_Unicode * skipLinearWhiteSpaceComment(const sal_Unicode *
const sal_Unicode *
pEnd);
-inline bool needsQuotedStringEscape(sal_uInt32 nChar);
-
const sal_Unicode * skipQuotedString(const sal_Unicode * pBegin,
const sal_Unicode * pEnd);
@@ -160,11 +158,6 @@ inline bool startsWithLineFolding(const sal_Unicode * pBegin,
&& isWhiteSpace(pBegin[2]); // CR, LF
}
-inline bool needsQuotedStringEscape(sal_uInt32 nChar)
-{
- return nChar == '"' || nChar == '\\';
-}
-
inline rtl_TextEncoding translateToMIME(rtl_TextEncoding eEncoding)
{
#if defined WNT
@@ -985,8 +978,7 @@ public:
private:
enum { BUFFER_SIZE = 256 };
- enum Coding { CODING_NONE, CODING_QUOTED, CODING_ENCODED,
- CODING_ENCODED_TERMINATED };
+ enum Coding { CODING_NONE, CODING_ENCODED, CODING_ENCODED_TERMINATED };
enum EncodedWordState { STATE_INITIAL, STATE_FIRST_EQUALS,
STATE_FIRST_QUESTION, STATE_CHARSET,
@@ -1206,8 +1198,6 @@ void INetMIMEEncodedWordOutputSink::finish(bool bWriteTrailer)
// If the text is already an encoded word, copy it verbatim:
switch (m_ePrevCoding)
{
- case CODING_QUOTED:
- m_rSink << '"';
case CODING_NONE:
while (m_nExtraSpaces-- > 0)
{
@@ -1238,10 +1228,6 @@ void INetMIMEEncodedWordOutputSink::finish(bool bWriteTrailer)
case CODING_NONE:
switch (m_ePrevCoding)
{
- case CODING_QUOTED:
- m_eCoding = CODING_QUOTED;
- break;
-
case CODING_ENCODED:
m_rSink << "?=";
break;
@@ -1254,49 +1240,7 @@ void INetMIMEEncodedWordOutputSink::finish(bool bWriteTrailer)
m_rSink << ' ';
}
m_rSink.write(m_pBuffer, m_pBufferEnd);
- if (m_eCoding == CODING_QUOTED && bWriteTrailer)
- {
- m_rSink << '"';
- m_eCoding = CODING_NONE;
- }
- break;
-
- case CODING_QUOTED:
- {
- bool bInsertLeadingQuote = true;
- switch (m_ePrevCoding)
- {
- case CODING_QUOTED:
- bInsertLeadingQuote = false;
- break;
-
- case CODING_ENCODED:
- m_rSink << "?=";
- break;
-
- default:
- break;
- }
- while (m_nExtraSpaces-- > 0)
- {
- m_rSink << ' ';
- }
- if (bInsertLeadingQuote)
- m_rSink << '"';
- for (const sal_Unicode * p = m_pBuffer; p != m_pBufferEnd;
- ++p)
- {
- if (needsQuotedStringEscape(*p))
- m_rSink << '\\';
- m_rSink << sal_Char(*p);
- }
- if (bWriteTrailer)
- {
- m_rSink << '"';
- m_eCoding = CODING_NONE;
- }
break;
- }
case CODING_ENCODED:
{
@@ -1311,8 +1255,6 @@ void INetMIMEEncodedWordOutputSink::finish(bool bWriteTrailer)
switch (m_ePrevCoding)
{
- case CODING_QUOTED:
- m_rSink << '"';
case CODING_NONE:
while (m_nExtraSpaces-- > 0)
{
commit 8fdd28093074902cac342c2be143d0352f27fa4c
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Sep 17 20:56:36 2015 +0200
CONTEXT_TEXT is the only unused Context
Change-Id: Ibacc88a60a313fd503935deef93881236cd8ec7f
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index a110666..4f0e17d 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -980,10 +980,6 @@ createPreferredCharsetList(rtl_TextEncoding eEncoding)
class INetMIMEEncodedWordOutputSink
{
public:
- enum Context { CONTEXT_TEXT = 1,
- CONTEXT_COMMENT = 2,
- CONTEXT_PHRASE = 4 };
-
enum Space { SPACE_NO, SPACE_ALWAYS };
private:
@@ -1000,7 +996,6 @@ private:
STATE_BAD };
INetMIMEOutputSink & m_rSink;
- Context m_eContext;
Space m_eInitialSpace;
sal_uInt32 m_nExtraSpaces;
INetMIMECharsetList_Impl * m_pEncodingList;
@@ -1012,13 +1007,10 @@ private:
Coding m_eCoding;
EncodedWordState m_eEncodedWordState;
- inline bool needsEncodedWordEscape(sal_uInt32 nChar) const;
-
void finish(bool bWriteTrailer);
public:
inline INetMIMEEncodedWordOutputSink(INetMIMEOutputSink & rTheSink,
- Context eTheContext,
Space eTheInitialSpace,
rtl_TextEncoding ePreferredEncoding);
@@ -1032,10 +1024,9 @@ public:
};
inline INetMIMEEncodedWordOutputSink::INetMIMEEncodedWordOutputSink(
- INetMIMEOutputSink & rTheSink, Context eTheContext,
+ INetMIMEOutputSink & rTheSink,
Space eTheInitialSpace, rtl_TextEncoding ePreferredEncoding):
m_rSink(rTheSink),
- m_eContext(eTheContext),
m_eInitialSpace(eTheInitialSpace),
m_nExtraSpaces(0),
m_pEncodingList(createPreferredCharsetList(ePreferredEncoding)),
@@ -1069,140 +1060,140 @@ inline bool INetMIMEEncodedWordOutputSink::flush()
return m_ePrevCoding != CODING_NONE;
}
-static const sal_Char aEscape[128]
- = { INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x00
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x01
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x02
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x03
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x04
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x05
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x06
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x07
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x08
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x09
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x0A
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x0B
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x0C
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x0D
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x0E
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x0F
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x10
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x11
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x12
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x13
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x14
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x15
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x16
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x17
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x18
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x19
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x1A
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x1B
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x1C
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x1D
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x1E
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // 0x1F
- 0, // ' '
- 0, // '!'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '"'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '#'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '$'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '%'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '&'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '''
- INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '('
- INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // ')'
- 0, // '*'
- 0, // '+'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // ','
- 0, // '-'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '.'
- 0, // '/'
- 0, // '0'
- 0, // '1'
- 0, // '2'
- 0, // '3'
- 0, // '4'
- 0, // '5'
- 0, // '6'
- 0, // '7'
- 0, // '8'
- 0, // '9'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // ':'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // ';'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '<'
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '='
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '>'
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '?'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '@'
- 0, // 'A'
- 0, // 'B'
- 0, // 'C'
- 0, // 'D'
- 0, // 'E'
- 0, // 'F'
- 0, // 'G'
- 0, // 'H'
- 0, // 'I'
- 0, // 'J'
- 0, // 'K'
- 0, // 'L'
- 0, // 'M'
- 0, // 'N'
- 0, // 'O'
- 0, // 'P'
- 0, // 'Q'
- 0, // 'R'
- 0, // 'S'
- 0, // 'T'
- 0, // 'U'
- 0, // 'V'
- 0, // 'W'
- 0, // 'X'
- 0, // 'Y'
- 0, // 'Z'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '['
- INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '\'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // ']'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '^'
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '_'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '`'
- 0, // 'a'
- 0, // 'b'
- 0, // 'c'
- 0, // 'd'
- 0, // 'e'
- 0, // 'f'
- 0, // 'g'
- 0, // 'h'
- 0, // 'i'
- 0, // 'j'
- 0, // 'k'
- 0, // 'l'
- 0, // 'm'
- 0, // 'n'
- 0, // 'o'
- 0, // 'p'
- 0, // 'q'
- 0, // 'r'
- 0, // 's'
- 0, // 't'
- 0, // 'u'
- 0, // 'v'
- 0, // 'w'
- 0, // 'x'
- 0, // 'y'
- 0, // 'z'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '{'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '|'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '}'
- INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE, // '~'
- INetMIMEEncodedWordOutputSink::CONTEXT_TEXT | INetMIMEEncodedWordOutputSink::CONTEXT_COMMENT | INetMIMEEncodedWordOutputSink::CONTEXT_PHRASE }; // DEL
+static const bool aEscape[128]
+ = { true, // 0x00
+ true, // 0x01
+ true, // 0x02
+ true, // 0x03
+ true, // 0x04
+ true, // 0x05
+ true, // 0x06
+ true, // 0x07
+ true, // 0x08
+ true, // 0x09
+ true, // 0x0A
+ true, // 0x0B
+ true, // 0x0C
+ true, // 0x0D
+ true, // 0x0E
+ true, // 0x0F
+ true, // 0x10
+ true, // 0x11
+ true, // 0x12
+ true, // 0x13
+ true, // 0x14
+ true, // 0x15
+ true, // 0x16
+ true, // 0x17
+ true, // 0x18
+ true, // 0x19
+ true, // 0x1A
+ true, // 0x1B
+ true, // 0x1C
+ true, // 0x1D
+ true, // 0x1E
+ true, // 0x1F
+ false, // ' '
+ false, // '!'
+ false, // '"'
+ false, // '#'
+ false, // '$'
+ false, // '%'
+ false, // '&'
+ false, // '''
+ false, // '('
+ false, // ')'
+ false, // '*'
+ false, // '+'
+ false, // ','
+ false, // '-'
+ false, // '.'
+ false, // '/'
+ false, // '0'
+ false, // '1'
+ false, // '2'
+ false, // '3'
+ false, // '4'
+ false, // '5'
+ false, // '6'
+ false, // '7'
+ false, // '8'
+ false, // '9'
+ false, // ':'
+ false, // ';'
+ false, // '<'
+ true, // '='
+ false, // '>'
+ true, // '?'
+ false, // '@'
+ false, // 'A'
+ false, // 'B'
+ false, // 'C'
+ false, // 'D'
+ false, // 'E'
+ false, // 'F'
+ false, // 'G'
+ false, // 'H'
+ false, // 'I'
+ false, // 'J'
+ false, // 'K'
+ false, // 'L'
+ false, // 'M'
+ false, // 'N'
+ false, // 'O'
+ false, // 'P'
+ false, // 'Q'
+ false, // 'R'
+ false, // 'S'
+ false, // 'T'
+ false, // 'U'
+ false, // 'V'
+ false, // 'W'
+ false, // 'X'
+ false, // 'Y'
+ false, // 'Z'
+ false, // '['
+ false, // '\'
+ false, // ']'
+ false, // '^'
+ true, // '_'
+ false, // '`'
+ false, // 'a'
+ false, // 'b'
+ false, // 'c'
+ false, // 'd'
+ false, // 'e'
+ false, // 'f'
+ false, // 'g'
+ false, // 'h'
+ false, // 'i'
+ false, // 'j'
+ false, // 'k'
+ false, // 'l'
+ false, // 'm'
+ false, // 'n'
+ false, // 'o'
+ false, // 'p'
+ false, // 'q'
+ false, // 'r'
+ false, // 's'
+ false, // 't'
+ false, // 'u'
+ false, // 'v'
+ false, // 'w'
+ false, // 'x'
+ false, // 'y'
+ false, // 'z'
+ false, // '{'
+ false, // '|'
+ false, // '}'
+ false, // '~'
+ true }; // DEL
inline bool
-INetMIMEEncodedWordOutputSink::needsEncodedWordEscape(sal_uInt32 nChar) const
+needsEncodedWordEscape(sal_uInt32 nChar)
{
- return !rtl::isAscii(nChar) || aEscape[nChar] & m_eContext;
+ return !rtl::isAscii(nChar) || aEscape[nChar];
}
void INetMIMEEncodedWordOutputSink::finish(bool bWriteTrailer)
@@ -1577,144 +1568,137 @@ INetMIMEEncodedWordOutputSink::WriteUInt32(sal_uInt32 nChar)
m_pEncodingList->includes(nChar);
// Update coding:
- enum { TENQ = 1, // CONTEXT_TEXT, CODING_ENCODED
- CENQ = 2, // CONTEXT_COMMENT, CODING_ENCODED
- PQTD = 4, // CONTEXT_PHRASE, CODING_QUOTED
- PENQ = 8 }; // CONTEXT_PHRASE, CODING_ENCODED
- static const sal_Char aMinimal[128]
- = { TENQ | CENQ | PENQ, // 0x00
- TENQ | CENQ | PENQ, // 0x01
- TENQ | CENQ | PENQ, // 0x02
- TENQ | CENQ | PENQ, // 0x03
- TENQ | CENQ | PENQ, // 0x04
- TENQ | CENQ | PENQ, // 0x05
- TENQ | CENQ | PENQ, // 0x06
- TENQ | CENQ | PENQ, // 0x07
- TENQ | CENQ | PENQ, // 0x08
- TENQ | CENQ | PENQ, // 0x09
- TENQ | CENQ | PENQ, // 0x0A
- TENQ | CENQ | PENQ, // 0x0B
- TENQ | CENQ | PENQ, // 0x0C
- TENQ | CENQ | PENQ, // 0x0D
- TENQ | CENQ | PENQ, // 0x0E
- TENQ | CENQ | PENQ, // 0x0F
- TENQ | CENQ | PENQ, // 0x10
- TENQ | CENQ | PENQ, // 0x11
- TENQ | CENQ | PENQ, // 0x12
- TENQ | CENQ | PENQ, // 0x13
- TENQ | CENQ | PENQ, // 0x14
- TENQ | CENQ | PENQ, // 0x15
- TENQ | CENQ | PENQ, // 0x16
- TENQ | CENQ | PENQ, // 0x17
- TENQ | CENQ | PENQ, // 0x18
- TENQ | CENQ | PENQ, // 0x19
- TENQ | CENQ | PENQ, // 0x1A
- TENQ | CENQ | PENQ, // 0x1B
- TENQ | CENQ | PENQ, // 0x1C
- TENQ | CENQ | PENQ, // 0x1D
- TENQ | CENQ | PENQ, // 0x1E
- TENQ | CENQ | PENQ, // 0x1F
- 0, // ' '
- 0, // '!'
- PQTD , // '"'
- 0, // '#'
- 0, // '$'
- 0, // '%'
- 0, // '&'
- 0, // '''
- CENQ | PQTD , // '('
- CENQ | PQTD , // ')'
- 0, // '*'
- 0, // '+'
- PQTD , // ','
- 0, // '-'
- PQTD , // '.'
- 0, // '/'
- 0, // '0'
- 0, // '1'
- 0, // '2'
- 0, // '3'
- 0, // '4'
- 0, // '5'
- 0, // '6'
- 0, // '7'
- 0, // '8'
- 0, // '9'
- PQTD , // ':'
- PQTD , // ';'
- PQTD , // '<'
- 0, // '='
- PQTD , // '>'
- 0, // '?'
- PQTD , // '@'
- 0, // 'A'
- 0, // 'B'
- 0, // 'C'
- 0, // 'D'
- 0, // 'E'
- 0, // 'F'
- 0, // 'G'
- 0, // 'H'
- 0, // 'I'
- 0, // 'J'
- 0, // 'K'
- 0, // 'L'
- 0, // 'M'
- 0, // 'N'
- 0, // 'O'
- 0, // 'P'
- 0, // 'Q'
- 0, // 'R'
- 0, // 'S'
- 0, // 'T'
- 0, // 'U'
- 0, // 'V'
- 0, // 'W'
- 0, // 'X'
- 0, // 'Y'
- 0, // 'Z'
- PQTD , // '['
- CENQ | PQTD , // '\'
- PQTD , // ']'
- 0, // '^'
- 0, // '_'
- 0, // '`'
- 0, // 'a'
- 0, // 'b'
- 0, // 'c'
- 0, // 'd'
- 0, // 'e'
- 0, // 'f'
- 0, // 'g'
- 0, // 'h'
- 0, // 'i'
- 0, // 'j'
- 0, // 'k'
- 0, // 'l'
- 0, // 'm'
- 0, // 'n'
- 0, // 'o'
- 0, // 'p'
- 0, // 'q'
- 0, // 'r'
- 0, // 's'
- 0, // 't'
- 0, // 'u'
- 0, // 'v'
- 0, // 'w'
- 0, // 'x'
- 0, // 'y'
- 0, // 'z'
- 0, // '{'
- 0, // '|'
- 0, // '}'
- 0, // '~'
- TENQ | CENQ | PENQ }; // DEL
+ static const bool aMinimal[128]
+ = { true, // 0x00
+ true, // 0x01
+ true, // 0x02
+ true, // 0x03
+ true, // 0x04
+ true, // 0x05
+ true, // 0x06
+ true, // 0x07
+ true, // 0x08
+ true, // 0x09
+ true, // 0x0A
+ true, // 0x0B
+ true, // 0x0C
+ true, // 0x0D
+ true, // 0x0E
+ true, // 0x0F
+ true, // 0x10
+ true, // 0x11
+ true, // 0x12
+ true, // 0x13
+ true, // 0x14
+ true, // 0x15
+ true, // 0x16
+ true, // 0x17
+ true, // 0x18
+ true, // 0x19
+ true, // 0x1A
+ true, // 0x1B
+ true, // 0x1C
+ true, // 0x1D
+ true, // 0x1E
+ true, // 0x1F
+ false, // ' '
+ false, // '!'
+ false, // '"'
+ false, // '#'
+ false, // '$'
+ false, // '%'
+ false, // '&'
+ false, // '''
+ false, // '('
+ false, // ')'
+ false, // '*'
+ false, // '+'
+ false, // ','
+ false, // '-'
+ false, // '.'
+ false, // '/'
+ false, // '0'
+ false, // '1'
+ false, // '2'
+ false, // '3'
+ false, // '4'
+ false, // '5'
+ false, // '6'
+ false, // '7'
+ false, // '8'
+ false, // '9'
+ false, // ':'
+ false, // ';'
+ false, // '<'
+ false, // '='
+ false, // '>'
+ false, // '?'
+ false, // '@'
+ false, // 'A'
+ false, // 'B'
+ false, // 'C'
+ false, // 'D'
+ false, // 'E'
+ false, // 'F'
+ false, // 'G'
+ false, // 'H'
+ false, // 'I'
+ false, // 'J'
+ false, // 'K'
+ false, // 'L'
+ false, // 'M'
+ false, // 'N'
+ false, // 'O'
+ false, // 'P'
+ false, // 'Q'
+ false, // 'R'
+ false, // 'S'
+ false, // 'T'
+ false, // 'U'
+ false, // 'V'
+ false, // 'W'
+ false, // 'X'
+ false, // 'Y'
+ false, // 'Z'
+ false, // '['
+ false, // '\'
+ false, // ']'
+ false, // '^'
+ false, // '_'
+ false, // '`'
+ false, // 'a'
+ false, // 'b'
+ false, // 'c'
+ false, // 'd'
+ false, // 'e'
+ false, // 'f'
+ false, // 'g'
+ false, // 'h'
+ false, // 'i'
+ false, // 'j'
+ false, // 'k'
+ false, // 'l'
+ false, // 'm'
+ false, // 'n'
+ false, // 'o'
+ false, // 'p'
+ false, // 'q'
+ false, // 'r'
+ false, // 's'
+ false, // 't'
+ false, // 'u'
+ false, // 'v'
+ false, // 'w'
+ false, // 'x'
+ false, // 'y'
+ false, // 'z'
+ false, // '{'
+ false, // '|'
+ false, // '}'
+ false, // '~'
+ true }; // DEL
Coding eNewCoding = !rtl::isAscii(nChar) ? CODING_ENCODED :
- m_eContext == CONTEXT_PHRASE ?
- Coding(aMinimal[nChar] >> 2) :
- aMinimal[nChar] & m_eContext ? CODING_ENCODED :
- CODING_NONE;
+ aMinimal[nChar] ? CODING_ENCODED : CODING_NONE;
if (eNewCoding > m_eCoding)
m_eCoding = eNewCoding;
@@ -2476,7 +2460,7 @@ void INetMIME::writeHeaderFieldBody(INetMIMEOutputSink & rSink,
bool bInitialSpace)
{
INetMIMEEncodedWordOutputSink
- aOutput(rSink, INetMIMEEncodedWordOutputSink::CONTEXT_TEXT,
+ aOutput(rSink,
bInitialSpace ?
INetMIMEEncodedWordOutputSink::SPACE_ALWAYS :
INetMIMEEncodedWordOutputSink::SPACE_NO,
commit 7a2a02163b2f71d413683a9bc52959c5f01cae11
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Sep 17 20:24:05 2015 +0200
Make various INetMIME members local to inetmime.cxx
(and remove those that are then identified as unused)
Change-Id: I5be9d306705837b995b91a13922bc1fb9fed4902
diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx
index 9dc9f4e..37ca4f0 100644
--- a/include/tools/inetmime.hxx
+++ b/include/tools/inetmime.hxx
@@ -87,15 +87,6 @@ typedef std::unordered_map<OString, INetContentTypeParameter, OStringHash>
class TOOLS_DLLPUBLIC INetMIME
{
public:
- /** Check for US-ASCII white space character.
-
- @param nChar Some UCS-4 character.
-
- @return True if nChar is a US-ASCII white space character (US-ASCII
- 0x09 or 0x20).
- */
- static inline bool isWhiteSpace(sal_uInt32 nChar);
-
/** Check for US-ASCII visible character.
@param nChar Some UCS-4 character.
@@ -115,26 +106,6 @@ public:
*/
static bool isAtomChar(sal_uInt32 nChar);
- /** Check whether some character is valid within an RFC 2045 <token>.
-
- @param nChar Some UCS-4 character.
-
- @return True if nChar is valid within an RFC 2047 <token> (US-ASCII
- 'A'--'Z', 'a'--'z', '0'--'9', '!', '#', '$', '%', '&', ''', '*', '+',
- '-', '.', '^', '_', '`', '{', '|', '}', or '~').
- */
- static bool isTokenChar(sal_uInt32 nChar);
-
- /** Check whether some character is valid within an RFC 2047 <token>.
-
- @param nChar Some UCS-4 character.
-
- @return True if nChar is valid within an RFC 2047 <token> (US-ASCII
- 'A'--'Z', 'a'--'z', '0'--'9', '!', '#', '$', '%', '&', ''', '*', '+',
- '-', '^', '_', '`', '{', '|', '}', or '~').
- */
- static bool isEncodedWordTokenChar(sal_uInt32 nChar);
-
/** Check whether some character is valid within an RFC 2060 <atom>.
@param nChar Some UCS-4 character.
@@ -166,17 +137,6 @@ public:
*/
static inline int getHexWeight(sal_uInt32 nChar);
- /** Get the Base 64 digit weight of a US-ASCII character.
-
- @param nChar Some UCS-4 character.
-
- @return If nChar is a US-ASCII Base 64 digit character (US-ASCII
- 'A'--'F', or 'a'--'f', '0'--'9', '+', or '/'), return the
- corresponding weight (0--63); if nChar is the US-ASCII Base 64 padding
- character (US-ASCII '='), return -1; otherwise, return -2.
- */
- static inline int getBase64Weight(sal_uInt32 nChar);
-
/** Get a hexadecimal digit encoded as US-ASCII.
@param nWeight Must be in the range 0--15, inclusive.
@@ -200,70 +160,14 @@ public:
@return True if the two strings are equal, ignoring the case of US-
ASCII alphabetic characters (US-ASCII 'A'--'Z' and 'a'--'z').
*/
- static bool equalIgnoreCase(const sal_Char * pBegin1,
- const sal_Char * pEnd1,
- const sal_Char * pString2);
-
- /** Check two US-ASCII strings for equality, ignoring case.
-
- @param pBegin1 Points to the start of the first string, must not be
- null.
-
- @param pEnd1 Points past the end of the first string, must be >=
- pBegin1.
-
- @param pString2 Points to the start of the null terminated second
- string, must not be null.
-
- @return True if the two strings are equal, ignoring the case of US-
- ASCII alphabetic characters (US-ASCII 'A'--'Z' and 'a'--'z').
- */
static bool equalIgnoreCase(const sal_Unicode * pBegin1,
const sal_Unicode * pEnd1,
const sal_Char * pString2);
- static inline bool startsWithLineBreak(const sal_Unicode * pBegin,
- const sal_Unicode * pEnd);
-
- static inline bool startsWithLineFolding(const sal_Unicode * pBegin,
- const sal_Unicode * pEnd);
-
- static const sal_Unicode * skipLinearWhiteSpace(const sal_Unicode *
- pBegin,
- const sal_Unicode * pEnd);
-
- static const sal_Unicode * skipComment(const sal_Unicode * pBegin,
- const sal_Unicode * pEnd);
-
- static const sal_Unicode * skipLinearWhiteSpaceComment(const sal_Unicode *
- pBegin,
- const sal_Unicode *
- pEnd);
-
- static inline bool needsQuotedStringEscape(sal_uInt32 nChar);
-
- static const sal_Char * skipQuotedString(const sal_Char * pBegin,
- const sal_Char * pEnd);
-
- static const sal_Unicode * skipQuotedString(const sal_Unicode * pBegin,
- const sal_Unicode * pEnd);
-
static bool scanUnsigned(const sal_Unicode *& rBegin,
const sal_Unicode * pEnd, bool bLeadingZeroes,
sal_uInt32 & rValue);
- static const sal_Unicode * scanQuotedBlock(const sal_Unicode * pBegin,
- const sal_Unicode * pEnd,
- sal_uInt32 nOpening,
- sal_uInt32 nClosing,
- sal_Size & rLength,
- bool & rModify);
-
- static sal_Unicode const * scanParameters(sal_Unicode const * pBegin,
- sal_Unicode const * pEnd,
- INetContentTypeParameterList *
- pParameters);
-
/** Parse the body of an RFC 2045 Content-Type header field.
@param pBegin The range (that must be valid) from non-null pBegin,
@@ -299,53 +203,11 @@ public:
OUString * pType = 0, OUString * pSubType = 0,
INetContentTypeParameterList * pParameters = 0);
- static inline rtl_TextEncoding translateToMIME(rtl_TextEncoding
- eEncoding);
-
- static inline rtl_TextEncoding translateFromMIME(rtl_TextEncoding
- eEncoding);
-
- static const sal_Char * getCharsetName(rtl_TextEncoding eEncoding);
-
- static rtl_TextEncoding getCharsetEncoding(const sal_Char * pBegin,
- const sal_Char * pEnd);
-
- static inline bool isMIMECharsetEncoding(rtl_TextEncoding eEncoding);
-
- static sal_Unicode * convertToUnicode(const sal_Char * pBegin,
- const sal_Char * pEnd,
- rtl_TextEncoding eEncoding,
- sal_Size & rSize);
-
- static sal_Char * convertFromUnicode(const sal_Unicode * pBegin,
- const sal_Unicode * pEnd,
- rtl_TextEncoding eEncoding,
- sal_Size & rSize);
-
- /** Get the number of octets required to encode an UCS-4 character using
- UTF-8 encoding.
-
- @param nChar Some UCS-4 character.
-
- @return The number of octets required (in the range 1--6, inclusive).
- */
- static inline int getUTF8OctetCount(sal_uInt32 nChar);
-
- static inline void writeEscapeSequence(INetMIMEOutputSink & rSink,
- sal_uInt32 nChar);
-
- static void writeUTF8(INetMIMEOutputSink & rSink, sal_uInt32 nChar);
-
static void writeHeaderFieldBody(INetMIMEOutputSink & rSink,
const OUString& rBody,
rtl_TextEncoding ePreferredEncoding,
bool bInitialSpace = true);
- static bool translateUTF8Char(const sal_Char *& rBegin,
- const sal_Char * pEnd,
- rtl_TextEncoding eEncoding,
- sal_uInt32 & rCharacter);
-
static OUString decodeHeaderFieldBody(const OString& rBody);
/** Get the UTF-32 character at the head of a UTF-16 encoded string.
@@ -363,27 +225,9 @@ public:
*/
static inline sal_uInt32 getUTF32Character(const sal_Unicode *& rBegin,
const sal_Unicode * pEnd);
-
- /** Put the UTF-16 encoding of a UTF-32 character into a buffer.
-
- @param pBuffer Points to a buffer, must not be null.
-
- @param nUTF32 An UTF-32 character, must be in the range 0..0x10FFFF.
-
- @return A pointer past the UTF-16 characters put into the buffer
- (i.e., pBuffer + 1 or pBuffer + 2).
- */
- static inline sal_Unicode * putUTF32Character(sal_Unicode * pBuffer,
- sal_uInt32 nUTF32);
};
// static
-inline bool INetMIME::isWhiteSpace(sal_uInt32 nChar)
-{
- return nChar == '\t' || nChar == ' ';
-}
-
-// static
inline bool INetMIME::isVisible(sal_uInt32 nChar)
{
return nChar >= '!' && nChar <= '~';
@@ -404,92 +248,6 @@ inline int INetMIME::getHexWeight(sal_uInt32 nChar)
}
// static
-inline int INetMIME::getBase64Weight(sal_uInt32 nChar)
-{
- return rtl::isAsciiUpperCase(nChar) ? int(nChar - 'A') :
- rtl::isAsciiLowerCase(nChar) ? int(nChar - 'a' + 26) :
- rtl::isAsciiDigit(nChar) ? int(nChar - '0' + 52) :
- nChar == '+' ? 62 :
- nChar == '/' ? 63 :
- nChar == '=' ? -1 : -2;
-}
-
-// static
-
-
-// static
-inline bool INetMIME::startsWithLineBreak(const sal_Unicode * pBegin,
- const sal_Unicode * pEnd)
-{
- DBG_ASSERT(pBegin && pBegin <= pEnd,
- "INetMIME::startsWithLineBreak(): Bad sequence");
-
- return pEnd - pBegin >= 2 && pBegin[0] == 0x0D && pBegin[1] == 0x0A;
- // CR, LF
-}
-
-// static
-inline bool INetMIME::startsWithLineFolding(const sal_Unicode * pBegin,
- const sal_Unicode * pEnd)
-{
- DBG_ASSERT(pBegin && pBegin <= pEnd,
- "INetMIME::startsWithLineFolding(): Bad sequence");
-
- return pEnd - pBegin >= 3 && pBegin[0] == 0x0D && pBegin[1] == 0x0A
- && isWhiteSpace(pBegin[2]); // CR, LF
-}
-
-// static
-
-
-// static
-inline bool INetMIME::needsQuotedStringEscape(sal_uInt32 nChar)
-{
- return nChar == '"' || nChar == '\\';
-}
-
-// static
-inline rtl_TextEncoding INetMIME::translateToMIME(rtl_TextEncoding eEncoding)
-{
-#if defined WNT
- return eEncoding == RTL_TEXTENCODING_MS_1252 ?
- RTL_TEXTENCODING_ISO_8859_1 : eEncoding;
-#else // WNT
- return eEncoding;
-#endif // WNT
-}
-
-// static
-inline rtl_TextEncoding INetMIME::translateFromMIME(rtl_TextEncoding
- eEncoding)
-{
-#if defined WNT
- return eEncoding == RTL_TEXTENCODING_ISO_8859_1 ?
- RTL_TEXTENCODING_MS_1252 : eEncoding;
-#else
- return eEncoding;
-#endif
-}
-
-// static
-inline bool INetMIME::isMIMECharsetEncoding(rtl_TextEncoding eEncoding)
-{
- return rtl_isOctetTextEncoding(eEncoding);
-}
-
-// static
-inline int INetMIME::getUTF8OctetCount(sal_uInt32 nChar)
-{
- DBG_ASSERT(nChar < 0x80000000, "INetMIME::getUTF8OctetCount(): Bad char");
-
- return nChar < 0x80 ? 1 :
- nChar < 0x800 ? 2 :
- nChar <= 0x10000 ? 3 :
- nChar <= 0x200000 ? 4 :
- nChar <= 0x4000000 ? 5 : 6;
-}
-
-// static
inline sal_uInt32 INetMIME::getUTF32Character(const sal_Unicode *& rBegin,
const sal_Unicode * pEnd)
{
@@ -505,22 +263,6 @@ inline sal_uInt32 INetMIME::getUTF32Character(const sal_Unicode *& rBegin,
return *rBegin++;
}
-// static
-inline sal_Unicode * INetMIME::putUTF32Character(sal_Unicode * pBuffer,
- sal_uInt32 nUTF32)
-{
- DBG_ASSERT(nUTF32 <= 0x10FFFF, "INetMIME::putUTF32Character(): Bad char");
- if (nUTF32 < 0x10000)
- *pBuffer++ = sal_Unicode(nUTF32);
- else
- {
- nUTF32 -= 0x10000;
- *pBuffer++ = sal_Unicode(0xD800 | (nUTF32 >> 10));
- *pBuffer++ = sal_Unicode(0xDC00 | (nUTF32 & 0x3FF));
- }
- return pBuffer;
-}
-
class INetMIMEOutputSink
{
private:
@@ -636,15 +378,6 @@ inline INetMIMEOutputSink & INetMIMEOutputSink::operator <<(const sal_Char *
return *this;
}
-// static
-inline void INetMIME::writeEscapeSequence(INetMIMEOutputSink & rSink,
- sal_uInt32 nChar)
-{
- DBG_ASSERT(nChar <= 0xFF, "INetMIME::writeEscapeSequence(): Bad char");
- rSink << '=' << sal_uInt8(getHexDigit(nChar >> 4))
- << sal_uInt8(getHexDigit(nChar & 15));
-}
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index f94d179..a110666 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -29,6 +29,380 @@
namespace {
+/** Check for US-ASCII white space character.
+
+ @param nChar Some UCS-4 character.
+
+ @return True if nChar is a US-ASCII white space character (US-ASCII
+ 0x09 or 0x20).
+ */
+inline bool isWhiteSpace(sal_uInt32 nChar);
+
+/** Check whether some character is valid within an RFC 2045 <token>.
+
+ @param nChar Some UCS-4 character.
+
+ @return True if nChar is valid within an RFC 2047 <token> (US-ASCII
+ 'A'--'Z', 'a'--'z', '0'--'9', '!', '#', '$', '%', '&', ''', '*', '+',
+ '-', '.', '^', '_', '`', '{', '|', '}', or '~').
+ */
+bool isTokenChar(sal_uInt32 nChar);
+
+/** Check whether some character is valid within an RFC 2047 <token>.
+
+ @param nChar Some UCS-4 character.
+
+ @return True if nChar is valid within an RFC 2047 <token> (US-ASCII
+ 'A'--'Z', 'a'--'z', '0'--'9', '!', '#', '$', '%', '&', ''', '*', '+',
+ '-', '^', '_', '`', '{', '|', '}', or '~').
+ */
+bool isEncodedWordTokenChar(sal_uInt32 nChar);
+
+/** Get the Base 64 digit weight of a US-ASCII character.
+
+ @param nChar Some UCS-4 character.
+
+ @return If nChar is a US-ASCII Base 64 digit character (US-ASCII
+ 'A'--'F', or 'a'--'f', '0'--'9', '+', or '/'), return the
+ corresponding weight (0--63); if nChar is the US-ASCII Base 64 padding
+ character (US-ASCII '='), return -1; otherwise, return -2.
+ */
+inline int getBase64Weight(sal_uInt32 nChar);
+
+inline bool startsWithLineFolding(const sal_Unicode * pBegin,
+ const sal_Unicode * pEnd);
+
+const sal_Unicode * skipComment(const sal_Unicode * pBegin,
+ const sal_Unicode * pEnd);
+
+const sal_Unicode * skipLinearWhiteSpaceComment(const sal_Unicode *
+ pBegin,
+ const sal_Unicode *
+ pEnd);
+
+inline bool needsQuotedStringEscape(sal_uInt32 nChar);
+
+const sal_Unicode * skipQuotedString(const sal_Unicode * pBegin,
+ const sal_Unicode * pEnd);
+
+sal_Unicode const * scanParameters(sal_Unicode const * pBegin,
+ sal_Unicode const * pEnd,
+ INetContentTypeParameterList *
+ pParameters);
+
+inline rtl_TextEncoding translateToMIME(rtl_TextEncoding
+ eEncoding);
+
+inline rtl_TextEncoding translateFromMIME(rtl_TextEncoding
+ eEncoding);
+
+const sal_Char * getCharsetName(rtl_TextEncoding eEncoding);
+
+rtl_TextEncoding getCharsetEncoding(const sal_Char * pBegin,
+ const sal_Char * pEnd);
+
+inline bool isMIMECharsetEncoding(rtl_TextEncoding eEncoding);
+
+sal_Unicode * convertToUnicode(const sal_Char * pBegin,
+ const sal_Char * pEnd,
+ rtl_TextEncoding eEncoding,
+ sal_Size & rSize);
+
+sal_Char * convertFromUnicode(const sal_Unicode * pBegin,
+ const sal_Unicode * pEnd,
+ rtl_TextEncoding eEncoding,
+ sal_Size & rSize);
+
+inline void writeEscapeSequence(INetMIMEOutputSink & rSink,
+ sal_uInt32 nChar);
+
+void writeUTF8(INetMIMEOutputSink & rSink, sal_uInt32 nChar);
+
+bool translateUTF8Char(const sal_Char *& rBegin,
+ const sal_Char * pEnd,
+ rtl_TextEncoding eEncoding,
+ sal_uInt32 & rCharacter);
+
+/** Put the UTF-16 encoding of a UTF-32 character into a buffer.
+
+ @param pBuffer Points to a buffer, must not be null.
+
+ @param nUTF32 An UTF-32 character, must be in the range 0..0x10FFFF.
+
+ @return A pointer past the UTF-16 characters put into the buffer
+ (i.e., pBuffer + 1 or pBuffer + 2).
+ */
+inline sal_Unicode * putUTF32Character(sal_Unicode * pBuffer,
+ sal_uInt32 nUTF32);
+
+inline bool isWhiteSpace(sal_uInt32 nChar)
+{
+ return nChar == '\t' || nChar == ' ';
+}
+
+inline int getBase64Weight(sal_uInt32 nChar)
+{
+ return rtl::isAsciiUpperCase(nChar) ? int(nChar - 'A') :
+ rtl::isAsciiLowerCase(nChar) ? int(nChar - 'a' + 26) :
+ rtl::isAsciiDigit(nChar) ? int(nChar - '0' + 52) :
+ nChar == '+' ? 62 :
+ nChar == '/' ? 63 :
+ nChar == '=' ? -1 : -2;
+}
+
+inline bool startsWithLineFolding(const sal_Unicode * pBegin,
+ const sal_Unicode * pEnd)
+{
+ DBG_ASSERT(pBegin && pBegin <= pEnd,
+ "startsWithLineFolding(): Bad sequence");
+
+ return pEnd - pBegin >= 3 && pBegin[0] == 0x0D && pBegin[1] == 0x0A
+ && isWhiteSpace(pBegin[2]); // CR, LF
+}
+
+inline bool needsQuotedStringEscape(sal_uInt32 nChar)
+{
+ return nChar == '"' || nChar == '\\';
+}
+
+inline rtl_TextEncoding translateToMIME(rtl_TextEncoding eEncoding)
+{
+#if defined WNT
+ return eEncoding == RTL_TEXTENCODING_MS_1252 ?
+ RTL_TEXTENCODING_ISO_8859_1 : eEncoding;
+#else // WNT
+ return eEncoding;
+#endif // WNT
+}
+
+inline rtl_TextEncoding translateFromMIME(rtl_TextEncoding
+ eEncoding)
+{
+#if defined WNT
+ return eEncoding == RTL_TEXTENCODING_ISO_8859_1 ?
+ RTL_TEXTENCODING_MS_1252 : eEncoding;
+#else
+ return eEncoding;
+#endif
+}
+
+inline bool isMIMECharsetEncoding(rtl_TextEncoding eEncoding)
+{
+ return rtl_isOctetTextEncoding(eEncoding);
+}
+
+sal_Unicode * convertToUnicode(const sal_Char * pBegin,
+ const sal_Char * pEnd,
+ rtl_TextEncoding eEncoding,
+ sal_Size & rSize)
+{
+ if (eEncoding == RTL_TEXTENCODING_DONTKNOW)
+ return 0;
+ rtl_TextToUnicodeConverter hConverter
+ = rtl_createTextToUnicodeConverter(eEncoding);
+ rtl_TextToUnicodeContext hContext
+ = rtl_createTextToUnicodeContext(hConverter);
+ sal_Unicode * pBuffer;
+ sal_uInt32 nInfo;
+ for (sal_Size nBufferSize = pEnd - pBegin;;
+ nBufferSize += nBufferSize / 3 + 1)
+ {
+ pBuffer = new sal_Unicode[nBufferSize];
+ sal_Size nSrcCvtBytes;
+ rSize = rtl_convertTextToUnicode(
+ hConverter, hContext, pBegin, pEnd - pBegin, pBuffer,
+ nBufferSize,
+ RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
+ | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
+ | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR,
+ &nInfo, &nSrcCvtBytes);
+ if (nInfo != RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL)
+ break;
+ delete[] pBuffer;
+ rtl_resetTextToUnicodeContext(hConverter, hContext);
+ }
+ rtl_destroyTextToUnicodeContext(hConverter, hContext);
+ rtl_destroyTextToUnicodeConverter(hConverter);
+ if (nInfo != 0)
+ {
+ delete[] pBuffer;
+ pBuffer = 0;
+ }
+ return pBuffer;
+}
+
+sal_Char * convertFromUnicode(const sal_Unicode * pBegin,
+ const sal_Unicode * pEnd,
+ rtl_TextEncoding eEncoding,
+ sal_Size & rSize)
+{
+ if (eEncoding == RTL_TEXTENCODING_DONTKNOW)
+ return 0;
+ rtl_UnicodeToTextConverter hConverter
+ = rtl_createUnicodeToTextConverter(eEncoding);
+ rtl_UnicodeToTextContext hContext
+ = rtl_createUnicodeToTextContext(hConverter);
+ sal_Char * pBuffer;
+ sal_uInt32 nInfo;
+ for (sal_Size nBufferSize = pEnd - pBegin;;
+ nBufferSize += nBufferSize / 3 + 1)
+ {
+ pBuffer = new sal_Char[nBufferSize];
+ sal_Size nSrcCvtBytes;
+ rSize = rtl_convertUnicodeToText(
+ hConverter, hContext, pBegin, pEnd - pBegin, pBuffer,
+ nBufferSize,
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
+ | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
+ | RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE
+ | RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR,
+ &nInfo, &nSrcCvtBytes);
+ if (nInfo != RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)
+ break;
+ delete[] pBuffer;
+ rtl_resetUnicodeToTextContext(hConverter, hContext);
+ }
+ rtl_destroyUnicodeToTextContext(hConverter, hContext);
+ rtl_destroyUnicodeToTextConverter(hConverter);
+ if (nInfo != 0)
+ {
+ delete[] pBuffer;
+ pBuffer = 0;
+ }
+ return pBuffer;
+}
+
+inline sal_Unicode * putUTF32Character(sal_Unicode * pBuffer,
+ sal_uInt32 nUTF32)
+{
+ DBG_ASSERT(nUTF32 <= 0x10FFFF, "putUTF32Character(): Bad char");
+ if (nUTF32 < 0x10000)
+ *pBuffer++ = sal_Unicode(nUTF32);
+ else
+ {
+ nUTF32 -= 0x10000;
+ *pBuffer++ = sal_Unicode(0xD800 | (nUTF32 >> 10));
+ *pBuffer++ = sal_Unicode(0xDC00 | (nUTF32 & 0x3FF));
+ }
+ return pBuffer;
+}
+
+inline void writeEscapeSequence(INetMIMEOutputSink & rSink,
+ sal_uInt32 nChar)
+{
+ DBG_ASSERT(nChar <= 0xFF, "writeEscapeSequence(): Bad char");
+ rSink << '=' << sal_uInt8(INetMIME::getHexDigit(nChar >> 4))
+ << sal_uInt8(INetMIME::getHexDigit(nChar & 15));
+}
+
+void writeUTF8(INetMIMEOutputSink & rSink, sal_uInt32 nChar)
+{
+ // See RFC 2279 for a discussion of UTF-8.
+ DBG_ASSERT(nChar < 0x80000000, "writeUTF8(): Bad char");
+
+ if (nChar < 0x80)
+ rSink << sal_Char(nChar);
+ else if (nChar < 0x800)
+ rSink << sal_Char(nChar >> 6 | 0xC0)
+ << sal_Char((nChar & 0x3F) | 0x80);
+ else if (nChar < 0x10000)
+ rSink << sal_Char(nChar >> 12 | 0xE0)
+ << sal_Char((nChar >> 6 & 0x3F) | 0x80)
+ << sal_Char((nChar & 0x3F) | 0x80);
+ else if (nChar < 0x200000)
+ rSink << sal_Char(nChar >> 18 | 0xF0)
+ << sal_Char((nChar >> 12 & 0x3F) | 0x80)
+ << sal_Char((nChar >> 6 & 0x3F) | 0x80)
+ << sal_Char((nChar & 0x3F) | 0x80);
+ else if (nChar < 0x4000000)
+ rSink << sal_Char(nChar >> 24 | 0xF8)
+ << sal_Char((nChar >> 18 & 0x3F) | 0x80)
+ << sal_Char((nChar >> 12 & 0x3F) | 0x80)
+ << sal_Char((nChar >> 6 & 0x3F) | 0x80)
+ << sal_Char((nChar & 0x3F) | 0x80);
+ else
+ rSink << sal_Char(nChar >> 30 | 0xFC)
+ << sal_Char((nChar >> 24 & 0x3F) | 0x80)
+ << sal_Char((nChar >> 18 & 0x3F) | 0x80)
+ << sal_Char((nChar >> 12 & 0x3F) | 0x80)
+ << sal_Char((nChar >> 6 & 0x3F) | 0x80)
+ << sal_Char((nChar & 0x3F) | 0x80);
+}
+
+bool translateUTF8Char(const sal_Char *& rBegin,
+ const sal_Char * pEnd,
+ rtl_TextEncoding eEncoding,
+ sal_uInt32 & rCharacter)
+{
+ if (rBegin == pEnd || static_cast< unsigned char >(*rBegin) < 0x80
+ || static_cast< unsigned char >(*rBegin) >= 0xFE)
+ return false;
+
+ int nCount;
+ sal_uInt32 nMin;
+ sal_uInt32 nUCS4;
+ const sal_Char * p = rBegin;
+ if (static_cast< unsigned char >(*p) < 0xE0)
+ {
+ nCount = 1;
+ nMin = 0x80;
+ nUCS4 = static_cast< unsigned char >(*p) & 0x1F;
+ }
+ else if (static_cast< unsigned char >(*p) < 0xF0)
+ {
+ nCount = 2;
+ nMin = 0x800;
+ nUCS4 = static_cast< unsigned char >(*p) & 0xF;
+ }
+ else if (static_cast< unsigned char >(*p) < 0xF8)
+ {
+ nCount = 3;
+ nMin = 0x10000;
+ nUCS4 = static_cast< unsigned char >(*p) & 7;
+ }
+ else if (static_cast< unsigned char >(*p) < 0xFC)
+ {
+ nCount = 4;
+ nMin = 0x200000;
+ nUCS4 = static_cast< unsigned char >(*p) & 3;
+ }
+ else
+ {
+ nCount = 5;
+ nMin = 0x4000000;
+ nUCS4 = static_cast< unsigned char >(*p) & 1;
+ }
+ ++p;
+
+ for (; nCount-- > 0; ++p)
+ if ((static_cast< unsigned char >(*p) & 0xC0) == 0x80)
+ nUCS4 = (nUCS4 << 6) | (static_cast< unsigned char >(*p) & 0x3F);
+ else
+ return false;
+
+ if (nUCS4 < nMin || nUCS4 > 0x10FFFF)
+ return false;
+
+ if (eEncoding >= RTL_TEXTENCODING_UCS4)
+ rCharacter = nUCS4;
+ else
+ {
+ sal_Unicode aUTF16[2];
+ const sal_Unicode * pUTF16End = putUTF32Character(aUTF16, nUCS4);
+ sal_Size nSize;
+ sal_Char * pBuffer = convertFromUnicode(aUTF16, pUTF16End, eEncoding,
+ nSize);
+ if (!pBuffer)
+ return false;
+ DBG_ASSERT(nSize == 1,
+ "translateUTF8Char(): Bad conversion");
+ rCharacter = *pBuffer;
+ delete[] pBuffer;
+ }
+ rBegin = p;
+ return true;
+}
+
class Charset
{
rtl_TextEncoding m_eEncoding;
@@ -262,7 +636,7 @@ bool parseParameters(ParameterList const & rInput,
rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW;
if (bCharset)
eEncoding
- = INetMIME::getCharsetEncoding(p->m_aCharset.getStr(),
+ = getCharsetEncoding(p->m_aCharset.getStr(),
p->m_aCharset.getStr()
+ rInput.m_pList->
m_aCharset.
@@ -274,7 +648,7 @@ bool parseParameters(ParameterList const & rInput,
{
sal_Size nSize;
sal_Unicode * pUnicode
- = INetMIME::convertToUnicode(pNext->m_aValue.getStr(),
+ = convertToUnicode(pNext->m_aValue.getStr(),
pNext->m_aValue.getStr()
+ pNext->m_aValue.getLength(),
bCharset && p->m_bExtended ?
@@ -282,7 +656,7 @@ bool parseParameters(ParameterList const & rInput,
RTL_TEXTENCODING_UTF8,
nSize);
if (!pUnicode && !(bCharset && p->m_bExtended))
- pUnicode = INetMIME::convertToUnicode(
+ pUnicode = convertToUnicode(
pNext->m_aValue.getStr(),
pNext->m_aValue.getStr()
+ pNext->m_aValue.getLength(),
@@ -594,7 +968,7 @@ createPreferredCharsetList(rtl_TextEncoding eEncoding)
break;
default: //@@@ more cases are missing!
- OSL_FAIL("INetMIME::createPreferredCharsetList():"
+ OSL_FAIL("createPreferredCharsetList():"
" Unsupported encoding");
break;
}
@@ -921,7 +1295,7 @@ void INetMIMEEncodedWordOutputSink::finish(bool bWriteTrailer)
for (const sal_Unicode * p = m_pBuffer; p != m_pBufferEnd;
++p)
{
- if (INetMIME::needsQuotedStringEscape(*p))
+ if (needsQuotedStringEscape(*p))
m_rSink << '\\';
m_rSink << sal_Char(*p);
}
@@ -939,10 +1313,10 @@ void INetMIMEEncodedWordOutputSink::finish(bool bWriteTrailer)
= m_pEncodingList->
getPreferredEncoding(RTL_TEXTENCODING_UTF8);
rtl_TextEncoding eMIMEEncoding
- = INetMIME::translateToMIME(eCharsetEncoding);
+ = translateToMIME(eCharsetEncoding);
const sal_Char * pCharsetName
- = INetMIME::getCharsetName(eMIMEEncoding);
+ = getCharsetName(eMIMEEncoding);
switch (m_ePrevCoding)
{
@@ -993,44 +1367,44 @@ void INetMIMEEncodedWordOutputSink::finish(bool bWriteTrailer)
"INetMIMEEncodedWordOutputSink::finish():"
" Bad char");
if (nUTF32 < 0x80)
- INetMIME::writeEscapeSequence(m_rSink,
+ writeEscapeSequence(m_rSink,
nUTF32);
else if (nUTF32 < 0x800)
{
- INetMIME::writeEscapeSequence(m_rSink,
+ writeEscapeSequence(m_rSink,
(nUTF32 >> 6)
| 0xC0);
- INetMIME::writeEscapeSequence(m_rSink,
+ writeEscapeSequence(m_rSink,
(nUTF32 & 0x3F)
| 0x80);
}
else if (nUTF32 < 0x10000)
{
- INetMIME::writeEscapeSequence(m_rSink,
+ writeEscapeSequence(m_rSink,
(nUTF32 >> 12)
| 0xE0);
- INetMIME::writeEscapeSequence(m_rSink,
+ writeEscapeSequence(m_rSink,
((nUTF32 >> 6)
& 0x3F)
| 0x80);
- INetMIME::writeEscapeSequence(m_rSink,
+ writeEscapeSequence(m_rSink,
(nUTF32 & 0x3F)
| 0x80);
}
else
{
- INetMIME::writeEscapeSequence(m_rSink,
+ writeEscapeSequence(m_rSink,
(nUTF32 >> 18)
| 0xF0);
- INetMIME::writeEscapeSequence(m_rSink,
+ writeEscapeSequence(m_rSink,
((nUTF32 >> 12)
& 0x3F)
| 0x80);
- INetMIME::writeEscapeSequence(m_rSink,
+ writeEscapeSequence(m_rSink,
((nUTF32 >> 6)
& 0x3F)
| 0x80);
- INetMIME::writeEscapeSequence(m_rSink,
+ writeEscapeSequence(m_rSink,
(nUTF32 & 0x3F)
| 0x80);
}
@@ -1075,7 +1449,7 @@ void INetMIMEEncodedWordOutputSink::finish(bool bWriteTrailer)
sal_uInt32 nUCS4 = static_cast<unsigned char>(pTargetBuffer[k]);
bool bEscape = needsEncodedWordEscape(nUCS4);
if (bEscape)
- INetMIME::writeEscapeSequence(m_rSink, nUCS4);
+ writeEscapeSequence(m_rSink, nUCS4);
else
m_rSink << sal_Char(nUCS4);
}
@@ -1142,7 +1516,7 @@ INetMIMEEncodedWordOutputSink::WriteUInt32(sal_uInt32 nChar)
break;
case STATE_FIRST_QUESTION:
- if (INetMIME::isEncodedWordTokenChar(nChar))
+ if (isEncodedWordTokenChar(nChar))
m_eEncodedWordState = STATE_CHARSET;
else
m_eEncodedWordState = STATE_BAD;
@@ -1151,7 +1525,7 @@ INetMIMEEncodedWordOutputSink::WriteUInt32(sal_uInt32 nChar)
case STATE_CHARSET:
if (nChar == '?')
m_eEncodedWordState = STATE_SECOND_QUESTION;
- else if (!INetMIME::isEncodedWordTokenChar(nChar))
+ else if (!isEncodedWordTokenChar(nChar))
m_eEncodedWordState = STATE_BAD;
break;
@@ -1360,36 +1734,7 @@ INetMIMEEncodedWordOutputSink::WriteUInt32(sal_uInt32 nChar)
return *this;
}
-}
-
-// INetMIME
-
-// static
-bool INetMIME::isAtomChar(sal_uInt32 nChar)
-{
- static const bool aMap[128]
- = { false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false,
- false, true, false, true, true, true, true, true, // !"#$%&'
- false, false, true, true, false, true, false, true, //()*+,-./
- true, true, true, true, true, true, true, true, //01234567
- true, true, false, false, false, true, false, true, //89:;<=>?
- false, true, true, true, true, true, true, true, //@ABCDEFG
- true, true, true, true, true, true, true, true, //HIJKLMNO
- true, true, true, true, true, true, true, true, //PQRSTUVW
- true, true, true, false, false, false, true, true, //XYZ[\]^_
- true, true, true, true, true, true, true, true, //`abcdefg
- true, true, true, true, true, true, true, true, //hijklmno
- true, true, true, true, true, true, true, true, //pqrstuvw
- true, true, true, true, true, true, true, false //xyz{|}~
- };
- return rtl::isAscii(nChar) && aMap[nChar];
-}
-
-// static
-bool INetMIME::isTokenChar(sal_uInt32 nChar)
+bool isTokenChar(sal_uInt32 nChar)
{
static const bool aMap[128]
= { false, false, false, false, false, false, false, false,
@@ -1412,8 +1757,7 @@ bool INetMIME::isTokenChar(sal_uInt32 nChar)
return rtl::isAscii(nChar) && aMap[nChar];
}
-// static
-bool INetMIME::isEncodedWordTokenChar(sal_uInt32 nChar)
+bool isEncodedWordTokenChar(sal_uInt32 nChar)
{
static const bool aMap[128]
= { false, false, false, false, false, false, false, false,
@@ -1436,106 +1780,11 @@ bool INetMIME::isEncodedWordTokenChar(sal_uInt32 nChar)
return rtl::isAscii(nChar) && aMap[nChar];
}
-// static
-bool INetMIME::isIMAPAtomChar(sal_uInt32 nChar)
-{
- static const bool aMap[128]
- = { false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false,
- false, true, false, true, true, false, true, true, // !"#$%&'
- false, false, false, true, true, true, true, true, //()*+,-./
- true, true, true, true, true, true, true, true, //01234567
- true, true, true, true, true, true, true, true, //89:;<=>?
- true, true, true, true, true, true, true, true, //@ABCDEFG
- true, true, true, true, true, true, true, true, //HIJKLMNO
- true, true, true, true, true, true, true, true, //PQRSTUVW
- true, true, true, true, false, true, true, true, //XYZ[\]^_
- true, true, true, true, true, true, true, true, //`abcdefg
- true, true, true, true, true, true, true, true, //hijklmno
- true, true, true, true, true, true, true, true, //pqrstuvw
- true, true, true, false, true, true, true, false //xyz{|}~
- };
- return rtl::isAscii(nChar) && aMap[nChar];
-}
-
-// static
-sal_uInt32 INetMIME::getHexDigit(int nWeight)
-{
- DBG_ASSERT(nWeight >= 0 && nWeight < 16,
- "INetMIME::getHexDigit(): Bad weight");
-
- static const sal_Char aDigits[16]
- = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
- 'D', 'E', 'F' };
- return aDigits[nWeight];
-}
-
-// static
-bool INetMIME::equalIgnoreCase(const sal_Char * pBegin1,
- const sal_Char * pEnd1,
- const sal_Char * pString2)
-{
- DBG_ASSERT(pBegin1 && pBegin1 <= pEnd1 && pString2,
- "INetMIME::equalIgnoreCase(): Bad sequences");
-
- while (*pString2 != 0)
- if (pBegin1 == pEnd1
- || rtl::toAsciiUpperCase(*pBegin1++) != rtl::toAsciiUpperCase(*pString2++))
- return false;
- return pBegin1 == pEnd1;
-}
-
-// static
-bool INetMIME::equalIgnoreCase(const sal_Unicode * pBegin1,
- const sal_Unicode * pEnd1,
- const sal_Char * pString2)
-{
- DBG_ASSERT(pBegin1 && pBegin1 <= pEnd1 && pString2,
- "INetMIME::equalIgnoreCase(): Bad sequences");
-
- while (*pString2 != 0)
- if (pBegin1 == pEnd1
- || rtl::toAsciiUpperCase(*pBegin1++) != rtl::toAsciiUpperCase(*pString2++))
- return false;
- return pBegin1 == pEnd1;
-}
-
-// static
-const sal_Unicode * INetMIME::skipLinearWhiteSpace(const sal_Unicode * pBegin,
- const sal_Unicode * pEnd)
-{
- DBG_ASSERT(pBegin && pBegin <= pEnd,
- "INetMIME::skipLinearWhiteSpace(): Bad sequence");
-
- while (pBegin != pEnd)
- switch (*pBegin)
- {
- case '\t':
- case ' ':
- ++pBegin;
- break;
-
- case 0x0D: // CR
- if (startsWithLineFolding(pBegin, pEnd))
- pBegin += 3;
- else
- return pBegin;
- break;
-
- default:
- return pBegin;
- }
- return pBegin;
-}
-
-// static
-const sal_Unicode * INetMIME::skipComment(const sal_Unicode * pBegin,
+const sal_Unicode * skipComment(const sal_Unicode * pBegin,
const sal_Unicode * pEnd)
{
DBG_ASSERT(pBegin && pBegin <= pEnd,
- "INetMIME::skipComment(): Bad sequence");
+ "skipComment(): Bad sequence");
if (pBegin != pEnd && *pBegin == '(')
{
@@ -1561,14 +1810,13 @@ const sal_Unicode * INetMIME::skipComment(const sal_Unicode * pBegin,
return pBegin;
}
-// static
-const sal_Unicode * INetMIME::skipLinearWhiteSpaceComment(const sal_Unicode *
+const sal_Unicode * skipLinearWhiteSpaceComment(const sal_Unicode *
pBegin,
const sal_Unicode *
pEnd)
{
DBG_ASSERT(pBegin && pBegin <= pEnd,
- "INetMIME::skipLinearWhiteSpaceComment(): Bad sequence");
+ "skipLinearWhiteSpaceComment(): Bad sequence");
while (pBegin != pEnd)
switch (*pBegin)
@@ -1600,40 +1848,11 @@ const sal_Unicode * INetMIME::skipLinearWhiteSpaceComment(const sal_Unicode *
return pBegin;
}
-// static
-const sal_Char * INetMIME::skipQuotedString(const sal_Char * pBegin,
- const sal_Char * pEnd)
-{
- DBG_ASSERT(pBegin && pBegin <= pEnd,
- "INetMIME::skipQuotedString(): Bad sequence");
-
- if (pBegin != pEnd && *pBegin == '"')
- for (const sal_Char * p = pBegin + 1; p != pEnd;)
- switch (*p++)
- {
- case 0x0D: // CR
- if (pEnd - p < 2 || *p++ != 0x0A // LF
- || !isWhiteSpace(*p++))
- return pBegin;
- break;
-
- case '"':
- return p;
-
- case '\\':
- if (p != pEnd)
- ++p;
- break;
- }
- return pBegin;
-}
-
-// static
-const sal_Unicode * INetMIME::skipQuotedString(const sal_Unicode * pBegin,
+const sal_Unicode * skipQuotedString(const sal_Unicode * pBegin,
const sal_Unicode * pEnd)
{
DBG_ASSERT(pBegin && pBegin <= pEnd,
- "INetMIME::skipQuotedString(): Bad sequence");
+ "skipQuotedString(): Bad sequence");
if (pBegin != pEnd && *pBegin == '"')
for (const sal_Unicode * p = pBegin + 1; p != pEnd;)
@@ -1656,103 +1875,7 @@ const sal_Unicode * INetMIME::skipQuotedString(const sal_Unicode * pBegin,
return pBegin;
}
-// static
-bool INetMIME::scanUnsigned(const sal_Unicode *& rBegin,
- const sal_Unicode * pEnd, bool bLeadingZeroes,
- sal_uInt32 & rValue)
-{
- sal_uInt64 nTheValue = 0;
- const sal_Unicode * p = rBegin;
- for ( ; p != pEnd; ++p)
- {
- int nWeight = getWeight(*p);
- if (nWeight < 0)
- break;
- nTheValue = 10 * nTheValue + nWeight;
- if (nTheValue > std::numeric_limits< sal_uInt32 >::max())
- return false;
- }
- if (nTheValue == 0 && (p == rBegin || (!bLeadingZeroes && p - rBegin != 1)))
- return false;
- rBegin = p;
- rValue = sal_uInt32(nTheValue);
- return true;
-}
-
-// static
-const sal_Unicode * INetMIME::scanQuotedBlock(const sal_Unicode * pBegin,
- const sal_Unicode * pEnd,
- sal_uInt32 nOpening,
- sal_uInt32 nClosing,
- sal_Size & rLength,
- bool & rModify)
-{
- DBG_ASSERT(pBegin && pBegin <= pEnd,
- "INetMIME::scanQuotedBlock(): Bad sequence");
-
- if (pBegin != pEnd && *pBegin == nOpening)
- {
- ++rLength;
- ++pBegin;
- while (pBegin != pEnd)
- if (*pBegin == nClosing)
- {
- ++rLength;
- return ++pBegin;
- }
- else
- {
- sal_uInt32 c = *pBegin++;
- switch (c)
- {
- case 0x0D: // CR
- if (pBegin != pEnd && *pBegin == 0x0A) // LF
- if (pEnd - pBegin >= 2 && isWhiteSpace(pBegin[1]))
- {
- ++rLength;
- rModify = true;
- pBegin += 2;
- }
- else
- {
- rLength += 3;
- rModify = true;
- ++pBegin;
- }
- else
- ++rLength;
- break;
-
- case '\\':
- ++rLength;
- if (pBegin != pEnd)
- {
- if (startsWithLineBreak(pBegin, pEnd)
- && (pEnd - pBegin < 3
- || !isWhiteSpace(pBegin[2])))
- {
- rLength += 3;
- rModify = true;
- pBegin += 2;
- }
- else
- ++pBegin;
- }
- break;
-
- default:
- ++rLength;
- if (!rtl::isAscii(c))
- rModify = true;
- break;
- }
- }
- }
- return pBegin;
-}
-
-// static
-sal_Unicode const * INetMIME::scanParameters(sal_Unicode const * pBegin,
+sal_Unicode const * scanParameters(sal_Unicode const * pBegin,
sal_Unicode const * pEnd,
INetContentTypeParameterList *
pParameters)
@@ -1788,7 +1911,7 @@ sal_Unicode const * INetMIME::scanParameters(sal_Unicode const * pBegin,
{
++p;
if (p != pEnd && rtl::isAsciiDigit(*p)
- && !scanUnsigned(p, pEnd, false, nSection))
+ && !INetMIME::scanUnsigned(p, pEnd, false, nSection))
break;
}
@@ -1886,8 +2009,8 @@ sal_Unicode const * INetMIME::scanParameters(sal_Unicode const * pBegin,
break;
if (nChar == '%' && p + 1 < pEnd)
{
- int nWeight1 = getHexWeight(p[0]);
- int nWeight2 = getHexWeight(p[1]);
+ int nWeight1 = INetMIME::getHexWeight(p[0]);
+ int nWeight2 = INetMIME::getHexWeight(p[1]);
if (nWeight1 >= 0 && nWeight2 >= 0)
{
aSink << sal_Char(nWeight1 << 4 | nWeight2);
@@ -1895,7 +2018,7 @@ sal_Unicode const * INetMIME::scanParameters(sal_Unicode const * pBegin,
continue;
}
}
- INetMIME::writeUTF8(aSink, nChar);
+ writeUTF8(aSink, nChar);
}
aValue = aSink.takeBuffer();
}
@@ -1937,7 +2060,7 @@ sal_Unicode const * INetMIME::scanParameters(sal_Unicode const * pBegin,
}
nChar = INetMIME::getUTF32Character(p, pEnd);
}
- INetMIME::writeUTF8(aSink, nChar);
+ writeUTF8(aSink, nChar);
}
if (bInvalid)
break;
@@ -1969,55 +2092,12 @@ sal_Unicode const * INetMIME::scanParameters(sal_Unicode const * pBegin,
return parseParameters(aList, pParameters) ? pParameterBegin : pBegin;
}
-// static
-sal_Unicode const * INetMIME::scanContentType(
- sal_Unicode const * pBegin, sal_Unicode const * pEnd, OUString * pType,
- OUString * pSubType, INetContentTypeParameterList * pParameters)
-{
- sal_Unicode const * p = INetMIME::skipLinearWhiteSpaceComment(pBegin, pEnd);
- sal_Unicode const * pTypeBegin = p;
- while (p != pEnd && INetMIME::isTokenChar(*p))
- {
- ++p;
- }
- if (p == pTypeBegin)
- return 0;
- sal_Unicode const * pTypeEnd = p;
-
- p = INetMIME::skipLinearWhiteSpaceComment(p, pEnd);
- if (p == pEnd || *p++ != '/')
- return 0;
-
- p = INetMIME::skipLinearWhiteSpaceComment(p, pEnd);
- sal_Unicode const * pSubTypeBegin = p;
- while (p != pEnd && INetMIME::isTokenChar(*p))
- {
- ++p;
- }
- if (p == pSubTypeBegin)
- return 0;
- sal_Unicode const * pSubTypeEnd = p;
-
- if (pType != 0)
- {
- *pType = OUString(pTypeBegin, pTypeEnd - pTypeBegin).toAsciiLowerCase();
- }
- if (pSubType != 0)
- {
- *pSubType = OUString(pSubTypeBegin, pSubTypeEnd - pSubTypeBegin)
- .toAsciiLowerCase();
- }
-
- return INetMIME::scanParameters(p, pEnd, pParameters);
-}
-
-// static
-const sal_Char * INetMIME::getCharsetName(rtl_TextEncoding eEncoding)
+const sal_Char * getCharsetName(rtl_TextEncoding eEncoding)
{
if (rtl_isOctetTextEncoding(eEncoding))
{
char const * p = rtl_getMimeCharsetFromTextEncoding(eEncoding);
- DBG_ASSERT(p, "INetMIME::getCharsetName(): Unsupported encoding");
+ DBG_ASSERT(p, "getCharsetName(): Unsupported encoding");
return p;
}
else
@@ -2030,12 +2110,24 @@ const sal_Char * INetMIME::getCharsetName(rtl_TextEncoding eEncoding)
return "ISO-10646-UCS-2";
default:
- OSL_FAIL("INetMIME::getCharsetName(): Unsupported encoding");
+ OSL_FAIL("getCharsetName(): Unsupported encoding");
return 0;
}
}
-namespace {
+bool equalIgnoreCase(const sal_Char * pBegin1,
+ const sal_Char * pEnd1,
+ const sal_Char * pString2)
+{
+ DBG_ASSERT(pBegin1 && pBegin1 <= pEnd1 && pString2,
+ "equalIgnoreCase(): Bad sequences");
+
+ while (*pString2 != 0)
+ if (pBegin1 == pEnd1
+ || rtl::toAsciiUpperCase(*pBegin1++) != rtl::toAsciiUpperCase(*pString2++))
+ return false;
+ return pBegin1 == pEnd1;
+}
struct EncodingEntry
{
@@ -2223,142 +2315,158 @@ EncodingEntry const aEncodingMap[]
{ "ISO-10646-UCS-2", RTL_TEXTENCODING_UCS2 },
{ "CSUNICODE", RTL_TEXTENCODING_UCS2 } };
-template< typename T >
-inline rtl_TextEncoding getCharsetEncoding_Impl(T const * pBegin,
- T const * pEnd)
+rtl_TextEncoding getCharsetEncoding(sal_Char const * pBegin,
+ sal_Char const * pEnd)
{
for (sal_Size i = 0; i < sizeof aEncodingMap / sizeof (EncodingEntry);
++i)
- if (INetMIME::equalIgnoreCase(pBegin, pEnd, aEncodingMap[i].m_aName))
+ if (equalIgnoreCase(pBegin, pEnd, aEncodingMap[i].m_aName))
return aEncodingMap[i].m_eEncoding;
return RTL_TEXTENCODING_DONTKNOW;
}
}
+// INetMIME
+
// static
-rtl_TextEncoding INetMIME::getCharsetEncoding(sal_Char const * pBegin,
- sal_Char const * pEnd)
+bool INetMIME::isAtomChar(sal_uInt32 nChar)
{
- return getCharsetEncoding_Impl(pBegin, pEnd);
+ static const bool aMap[128]
+ = { false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, true, false, true, true, true, true, true, // !"#$%&'
+ false, false, true, true, false, true, false, true, //()*+,-./
+ true, true, true, true, true, true, true, true, //01234567
+ true, true, false, false, false, true, false, true, //89:;<=>?
+ false, true, true, true, true, true, true, true, //@ABCDEFG
+ true, true, true, true, true, true, true, true, //HIJKLMNO
+ true, true, true, true, true, true, true, true, //PQRSTUVW
+ true, true, true, false, false, false, true, true, //XYZ[\]^_
+ true, true, true, true, true, true, true, true, //`abcdefg
+ true, true, true, true, true, true, true, true, //hijklmno
+ true, true, true, true, true, true, true, true, //pqrstuvw
+ true, true, true, true, true, true, true, false //xyz{|}~
+ };
+ return rtl::isAscii(nChar) && aMap[nChar];
}
// static
-sal_Unicode * INetMIME::convertToUnicode(const sal_Char * pBegin,
- const sal_Char * pEnd,
- rtl_TextEncoding eEncoding,
- sal_Size & rSize)
+bool INetMIME::isIMAPAtomChar(sal_uInt32 nChar)
{
- if (eEncoding == RTL_TEXTENCODING_DONTKNOW)
- return 0;
- rtl_TextToUnicodeConverter hConverter
- = rtl_createTextToUnicodeConverter(eEncoding);
- rtl_TextToUnicodeContext hContext
- = rtl_createTextToUnicodeContext(hConverter);
- sal_Unicode * pBuffer;
- sal_uInt32 nInfo;
- for (sal_Size nBufferSize = pEnd - pBegin;;
- nBufferSize += nBufferSize / 3 + 1)
+ static const bool aMap[128]
+ = { false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false,
+ false, true, false, true, true, false, true, true, // !"#$%&'
+ false, false, false, true, true, true, true, true, //()*+,-./
+ true, true, true, true, true, true, true, true, //01234567
+ true, true, true, true, true, true, true, true, //89:;<=>?
+ true, true, true, true, true, true, true, true, //@ABCDEFG
+ true, true, true, true, true, true, true, true, //HIJKLMNO
+ true, true, true, true, true, true, true, true, //PQRSTUVW
+ true, true, true, true, false, true, true, true, //XYZ[\]^_
+ true, true, true, true, true, true, true, true, //`abcdefg
+ true, true, true, true, true, true, true, true, //hijklmno
+ true, true, true, true, true, true, true, true, //pqrstuvw
+ true, true, true, false, true, true, true, false //xyz{|}~
+ };
+ return rtl::isAscii(nChar) && aMap[nChar];
+}
+
+// static
+sal_uInt32 INetMIME::getHexDigit(int nWeight)
+{
+ DBG_ASSERT(nWeight >= 0 && nWeight < 16,
+ "INetMIME::getHexDigit(): Bad weight");
+
+ static const sal_Char aDigits[16]
+ = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
+ 'D', 'E', 'F' };
+ return aDigits[nWeight];
+}
+
+// static
+bool INetMIME::equalIgnoreCase(const sal_Unicode * pBegin1,
+ const sal_Unicode * pEnd1,
+ const sal_Char * pString2)
+{
+ DBG_ASSERT(pBegin1 && pBegin1 <= pEnd1 && pString2,
+ "INetMIME::equalIgnoreCase(): Bad sequences");
+
+ while (*pString2 != 0)
+ if (pBegin1 == pEnd1
+ || rtl::toAsciiUpperCase(*pBegin1++) != rtl::toAsciiUpperCase(*pString2++))
+ return false;
+ return pBegin1 == pEnd1;
+}
+
+// static
+bool INetMIME::scanUnsigned(const sal_Unicode *& rBegin,
+ const sal_Unicode * pEnd, bool bLeadingZeroes,
+ sal_uInt32 & rValue)
+{
+ sal_uInt64 nTheValue = 0;
+ const sal_Unicode * p = rBegin;
+ for ( ; p != pEnd; ++p)
{
- pBuffer = new sal_Unicode[nBufferSize];
- sal_Size nSrcCvtBytes;
- rSize = rtl_convertTextToUnicode(
- hConverter, hContext, pBegin, pEnd - pBegin, pBuffer,
- nBufferSize,
- RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
- | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
- | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR,
- &nInfo, &nSrcCvtBytes);
- if (nInfo != RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL)
+ int nWeight = getWeight(*p);
+ if (nWeight < 0)
break;
- delete[] pBuffer;
- rtl_resetTextToUnicodeContext(hConverter, hContext);
- }
- rtl_destroyTextToUnicodeContext(hConverter, hContext);
- rtl_destroyTextToUnicodeConverter(hConverter);
- if (nInfo != 0)
- {
- delete[] pBuffer;
- pBuffer = 0;
+ nTheValue = 10 * nTheValue + nWeight;
+ if (nTheValue > std::numeric_limits< sal_uInt32 >::max())
+ return false;
}
- return pBuffer;
+ if (nTheValue == 0 && (p == rBegin || (!bLeadingZeroes && p - rBegin != 1)))
+ return false;
+ rBegin = p;
+ rValue = sal_uInt32(nTheValue);
+ return true;
}
// static
-sal_Char * INetMIME::convertFromUnicode(const sal_Unicode * pBegin,
- const sal_Unicode * pEnd,
- rtl_TextEncoding eEncoding,
- sal_Size & rSize)
+sal_Unicode const * INetMIME::scanContentType(
+ sal_Unicode const * pBegin, sal_Unicode const * pEnd, OUString * pType,
+ OUString * pSubType, INetContentTypeParameterList * pParameters)
{
- if (eEncoding == RTL_TEXTENCODING_DONTKNOW)
- return 0;
- rtl_UnicodeToTextConverter hConverter
- = rtl_createUnicodeToTextConverter(eEncoding);
- rtl_UnicodeToTextContext hContext
- = rtl_createUnicodeToTextContext(hConverter);
- sal_Char * pBuffer;
- sal_uInt32 nInfo;
- for (sal_Size nBufferSize = pEnd - pBegin;;
- nBufferSize += nBufferSize / 3 + 1)
+ sal_Unicode const * p = skipLinearWhiteSpaceComment(pBegin, pEnd);
+ sal_Unicode const * pTypeBegin = p;
+ while (p != pEnd && isTokenChar(*p))
{
- pBuffer = new sal_Char[nBufferSize];
- sal_Size nSrcCvtBytes;
- rSize = rtl_convertUnicodeToText(
- hConverter, hContext, pBegin, pEnd - pBegin, pBuffer,
- nBufferSize,
- RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
- | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
- | RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE
- | RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR,
- &nInfo, &nSrcCvtBytes);
- if (nInfo != RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)
- break;
- delete[] pBuffer;
- rtl_resetUnicodeToTextContext(hConverter, hContext);
+ ++p;
}
- rtl_destroyUnicodeToTextContext(hConverter, hContext);
- rtl_destroyUnicodeToTextConverter(hConverter);
- if (nInfo != 0)
+ if (p == pTypeBegin)
+ return 0;
+ sal_Unicode const * pTypeEnd = p;
+
+ p = skipLinearWhiteSpaceComment(p, pEnd);
+ if (p == pEnd || *p++ != '/')
+ return 0;
+
+ p = skipLinearWhiteSpaceComment(p, pEnd);
+ sal_Unicode const * pSubTypeBegin = p;
+ while (p != pEnd && isTokenChar(*p))
{
- delete[] pBuffer;
- pBuffer = 0;
+ ++p;
}
- return pBuffer;
-}
+ if (p == pSubTypeBegin)
+ return 0;
+ sal_Unicode const * pSubTypeEnd = p;
-// static
-void INetMIME::writeUTF8(INetMIMEOutputSink & rSink, sal_uInt32 nChar)
-{
- // See RFC 2279 for a discussion of UTF-8.
- DBG_ASSERT(nChar < 0x80000000, "INetMIME::writeUTF8(): Bad char");
+ if (pType != 0)
+ {
+ *pType = OUString(pTypeBegin, pTypeEnd - pTypeBegin).toAsciiLowerCase();
+ }
+ if (pSubType != 0)
+ {
+ *pSubType = OUString(pSubTypeBegin, pSubTypeEnd - pSubTypeBegin)
+ .toAsciiLowerCase();
+ }
- if (nChar < 0x80)
- rSink << sal_Char(nChar);
- else if (nChar < 0x800)
- rSink << sal_Char(nChar >> 6 | 0xC0)
- << sal_Char((nChar & 0x3F) | 0x80);
- else if (nChar < 0x10000)
- rSink << sal_Char(nChar >> 12 | 0xE0)
- << sal_Char((nChar >> 6 & 0x3F) | 0x80)
- << sal_Char((nChar & 0x3F) | 0x80);
- else if (nChar < 0x200000)
- rSink << sal_Char(nChar >> 18 | 0xF0)
- << sal_Char((nChar >> 12 & 0x3F) | 0x80)
- << sal_Char((nChar >> 6 & 0x3F) | 0x80)
- << sal_Char((nChar & 0x3F) | 0x80);
- else if (nChar < 0x4000000)
- rSink << sal_Char(nChar >> 24 | 0xF8)
- << sal_Char((nChar >> 18 & 0x3F) | 0x80)
- << sal_Char((nChar >> 12 & 0x3F) | 0x80)
- << sal_Char((nChar >> 6 & 0x3F) | 0x80)
- << sal_Char((nChar & 0x3F) | 0x80);
- else
- rSink << sal_Char(nChar >> 30 | 0xFC)
- << sal_Char((nChar >> 24 & 0x3F) | 0x80)
- << sal_Char((nChar >> 18 & 0x3F) | 0x80)
- << sal_Char((nChar >> 12 & 0x3F) | 0x80)
- << sal_Char((nChar >> 6 & 0x3F) | 0x80)
- << sal_Char((nChar & 0x3F) | 0x80);
+ return scanParameters(p, pEnd, pParameters);
}
// static
@@ -2378,81 +2486,6 @@ void INetMIME::writeHeaderFieldBody(INetMIMEOutputSink & rSink,
}
// static
-bool INetMIME::translateUTF8Char(const sal_Char *& rBegin,
- const sal_Char * pEnd,
- rtl_TextEncoding eEncoding,
- sal_uInt32 & rCharacter)
-{
- if (rBegin == pEnd || static_cast< unsigned char >(*rBegin) < 0x80
- || static_cast< unsigned char >(*rBegin) >= 0xFE)
- return false;
-
- int nCount;
- sal_uInt32 nMin;
- sal_uInt32 nUCS4;
- const sal_Char * p = rBegin;
- if (static_cast< unsigned char >(*p) < 0xE0)
- {
- nCount = 1;
- nMin = 0x80;
- nUCS4 = static_cast< unsigned char >(*p) & 0x1F;
- }
- else if (static_cast< unsigned char >(*p) < 0xF0)
- {
- nCount = 2;
- nMin = 0x800;
- nUCS4 = static_cast< unsigned char >(*p) & 0xF;
- }
- else if (static_cast< unsigned char >(*p) < 0xF8)
- {
- nCount = 3;
- nMin = 0x10000;
- nUCS4 = static_cast< unsigned char >(*p) & 7;
- }
- else if (static_cast< unsigned char >(*p) < 0xFC)
- {
- nCount = 4;
- nMin = 0x200000;
- nUCS4 = static_cast< unsigned char >(*p) & 3;
- }
- else
- {
- nCount = 5;
- nMin = 0x4000000;
- nUCS4 = static_cast< unsigned char >(*p) & 1;
- }
- ++p;
-
- for (; nCount-- > 0; ++p)
- if ((static_cast< unsigned char >(*p) & 0xC0) == 0x80)
- nUCS4 = (nUCS4 << 6) | (static_cast< unsigned char >(*p) & 0x3F);
- else
- return false;
-
- if (nUCS4 < nMin || nUCS4 > 0x10FFFF)
- return false;
-
- if (eEncoding >= RTL_TEXTENCODING_UCS4)
- rCharacter = nUCS4;
- else
- {
- sal_Unicode aUTF16[2];
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list