include/svl/inettype.hxx | 35 --------------------------- include/tools/inetmime.hxx | 35 +++++++++++++++++++++++++++ svl/qa/unit/test_INetContentType.cxx | 6 ++-- svl/source/misc/inettype.cxx | 45 +---------------------------------- tools/source/inet/inetmime.cxx | 42 ++++++++++++++++++++++++++++++++ ucb/source/core/FileAccess.cxx | 4 +-- 6 files changed, 84 insertions(+), 83 deletions(-)
New commits: commit 2c9d68ff56d02350eda752d699f5ba0425e06142 Author: Chr. Rossmanith <chrrossman...@gmx.de> Date: Thu May 8 12:00:30 2014 +0200 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: Stephan Bergmann <sberg...@redhat.com> diff --git a/include/svl/inettype.hxx b/include/svl/inettype.hxx index b09261eb..8f251ac 100644 --- a/include/svl/inettype.hxx +++ b/include/svl/inettype.hxx @@ -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); diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx index 04b3141..7190c38 100644 --- a/include/tools/inetmime.hxx +++ b/include/tools/inetmime.hxx @@ -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); diff --git a/svl/qa/unit/test_INetContentType.cxx b/svl/qa/unit/test_INetContentType.cxx index a2ce362..b7aa71c 100644 --- a/svl/qa/unit/test_INetContentType.cxx +++ b/svl/qa/unit/test_INetContentType.cxx @@ -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; diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx index bfd812e..074889c 100644 --- a/svl/source/misc/inettype.cxx +++ b/svl/source/misc/inettype.cxx @@ -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) { diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx index 98f1468..ff67d01 100644 --- a/tools/source/inet/inetmime.cxx +++ b/tools/source/inet/inetmime.cxx @@ -956,6 +956,48 @@ sal_Unicode const * INetMIME::scanParameters(sal_Unicode const * 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) { if (rtl_isOctetTextEncoding(eEncoding)) diff --git a/ucb/source/core/FileAccess.cxx b/ucb/source/core/FileAccess.cxx index 158caeb..8c96d49 100644 --- a/ucb/source/core/FileAccess.cxx +++ b/ucb/source/core/FileAccess.cxx @@ -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() ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits