Kaydet (Commit) 2c9d68ff authored tarafından Chr. Rossmanith's avatar Chr. Rossmanith Kaydeden (comit) Stephan Bergmann

move INetContentTypes::scan() to INetMIME::scanContentType()

to avoid circular dependencies between svl and tools when using
INetContentType::scan functionality for future handling of data urls in
urlobj.cxx

Change-Id: Iad13286769e8906aebf8208e4f532151ff2f3d13
Signed-off-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 797c8e71
......@@ -251,41 +251,6 @@ public:
static bool GetExtensionFromURL(OUString const & rURL, OUString & rExtension);
/** Parse the body of an RFC 2045 Content-Type header field.
@param pBegin The range (that must be valid) from non-null pBegin,
inclusive. to non-null pEnd, exclusive, forms the body of the
Content-Type header field. It must be of the form
token "/" token *(";" token "=" (token / quoted-string))
with intervening linear white space and comments (cf. RFCs 822, 2045).
The RFC 2231 extension are supported. The encoding of rMediaType
should be US-ASCII, but any Unicode values in the range U+0080..U+FFFF
are interpretet 'as appropriate.'
@param pType If not null, returns the type (the first of the above
tokens), in US-ASCII encoding and converted to lower case.
@param pSubType If not null, returns the sub-type (the second of the
above tokens), in US-ASCII encoding and converted to lower case.
@param pParameters If not null, returns the parameters as a list of
INetContentTypeParameters (the attributes are in US-ASCII encoding and
converted to lower case, the values are in Unicode encoding). If
null, only the syntax of the parameters is checked, but they are not
returned.
@return Null if the syntax of the field body is incorrect (i.e., does
not start with type and sub-type tokens). Otherwise, a pointer past the
longest valid input prefix. If null is returned, none of the output
parameters will be modified.
*/
static sal_Unicode const * scan(
sal_Unicode const *pBegin, sal_Unicode const * pEnd,
OUString * pType = 0, OUString * pSubType = 0,
INetContentTypeParameterList * pParameters = 0);
static bool parse(OUString const & rMediaType, OUString & rType,
OUString & rSubType,
INetContentTypeParameterList * pParameters = 0);
......
......@@ -356,6 +356,41 @@ public:
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,
inclusive. to non-null pEnd, exclusive, forms the body of the
Content-Type header field. It must be of the form
token "/" token *(";" token "=" (token / quoted-string))
with intervening linear white space and comments (cf. RFCs 822, 2045).
The RFC 2231 extension are supported. The encoding of rMediaType
should be US-ASCII, but any Unicode values in the range U+0080..U+FFFF
are interpretet 'as appropriate.'
@param pType If not null, returns the type (the first of the above
tokens), in US-ASCII encoding and converted to lower case.
@param pSubType If not null, returns the sub-type (the second of the
above tokens), in US-ASCII encoding and converted to lower case.
@param pParameters If not null, returns the parameters as a list of
INetContentTypeParameters (the attributes are in US-ASCII encoding and
converted to lower case, the values are in Unicode encoding). If
null, only the syntax of the parameters is checked, but they are not
returned.
@return Null if the syntax of the field body is incorrect (i.e., does
not start with type and sub-type tokens). Otherwise, a pointer past the
longest valid input prefix. If null is returned, none of the output
parameters will be modified.
*/
static sal_Unicode const * scanContentType(
sal_Unicode const *pBegin, sal_Unicode const * pEnd,
OUString * pType = 0, OUString * pSubType = 0,
INetContentTypeParameterList * pParameters = 0);
static inline rtl_TextEncoding translateToMIME(rtl_TextEncoding
eEncoding);
......
......@@ -41,7 +41,7 @@ void Test::testBad() {
OUString in("foo=bar");
CPPUNIT_ASSERT_EQUAL(
static_cast<sal_Unicode const *>(0),
INetContentTypes::scan(in.getStr(), in.getStr() + in.getLength()));
INetMIME::scanContentType(in.getStr(), in.getStr() + in.getLength()));
OUString t;
OUString s;
INetContentTypeParameterList ps;
......@@ -56,7 +56,7 @@ void Test::testFull() {
OUString in("foo/bar;baz=boz");
CPPUNIT_ASSERT_EQUAL(
in.getStr() + in.getLength(),
INetContentTypes::scan(in.getStr(), in.getStr() + in.getLength()));
INetMIME::scanContentType(in.getStr(), in.getStr() + in.getLength()));
OUString t;
OUString s;
INetContentTypeParameterList ps;
......@@ -72,7 +72,7 @@ void Test::testFollow() {
OUString in("foo/bar;baz=boz;base64,");
CPPUNIT_ASSERT_EQUAL(
in.getStr() + std::strlen("foo/bar;baz=boz"),
INetContentTypes::scan(in.getStr(), in.getStr() + in.getLength()));
INetMIME::scanContentType(in.getStr(), in.getStr() + in.getLength()));
OUString t;
OUString s;
INetContentTypeParameterList ps;
......
......@@ -18,6 +18,7 @@
*/
#include <tools/wldcrd.hxx>
#include <tools/inetmime.hxx>
#include <rtl/instance.hxx>
#include <svl/inettype.hxx>
#include <svl/svl.hrc>
......@@ -778,48 +779,6 @@ bool INetContentTypes::GetExtensionFromURL(OUString const & rURL,
return false;
}
// static
sal_Unicode const * INetContentTypes::scan(
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);
}
bool INetContentTypes::parse(
OUString const & rMediaType, OUString & rType, OUString & rSubType,
INetContentTypeParameterList * pParameters)
......@@ -829,7 +788,7 @@ bool INetContentTypes::parse(
OUString t;
OUString s;
INetContentTypeParameterList p;
if (scan(b, e, &t, &s, pParameters == 0 ? 0 : &p) == e) {
if (INetMIME::scanContentType(b, e, &t, &s, pParameters == 0 ? 0 : &p) == e) {
rType = t;
rSubType = s;
if (pParameters != 0) {
......
......@@ -955,6 +955,48 @@ 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)
{
......
......@@ -434,11 +434,11 @@ OUString OFileAccess::getContentType( const OUString& FileURL )
return aTypeStr;
}
DateTime OFileAccess::getDateTimeModified( const OUString& FileURL )
::com::sun::star::util::DateTime OFileAccess::getDateTimeModified( const OUString& FileURL )
throw(CommandAbortedException, Exception, RuntimeException, std::exception)
{
INetURLObject aFileObj( FileURL, INET_PROT_FILE );
DateTime aDateTime;
::com::sun::star::util::DateTime aDateTime;
Reference< XCommandEnvironment > aCmdEnv;
ucbhelper::Content aYoung( aFileObj.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv, comphelper::getProcessComponentContext() );
......
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