Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsSaveAsCharset_h__ |
michael@0 | 7 | #define nsSaveAsCharset_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsStringFwd.h" |
michael@0 | 10 | #include "nsTArray.h" |
michael@0 | 11 | #include "nsISaveAsCharset.h" |
michael@0 | 12 | |
michael@0 | 13 | |
michael@0 | 14 | #define MASK_FALLBACK(a) (nsISaveAsCharset::mask_Fallback & (a)) |
michael@0 | 15 | #define MASK_ENTITY(a) (nsISaveAsCharset::mask_Entity & (a)) |
michael@0 | 16 | #define MASK_CHARSET_FALLBACK(a) (nsISaveAsCharset::mask_CharsetFallback & (a)) |
michael@0 | 17 | #define ATTR_NO_FALLBACK(a) (nsISaveAsCharset::attr_FallbackNone == MASK_FALLBACK(a) && \ |
michael@0 | 18 | nsISaveAsCharset::attr_EntityAfterCharsetConv != MASK_ENTITY(a)) |
michael@0 | 19 | |
michael@0 | 20 | class nsIUnicodeEncoder; |
michael@0 | 21 | class nsIEntityConverter; |
michael@0 | 22 | |
michael@0 | 23 | class nsSaveAsCharset : public nsISaveAsCharset |
michael@0 | 24 | { |
michael@0 | 25 | public: |
michael@0 | 26 | |
michael@0 | 27 | // |
michael@0 | 28 | // implementation methods |
michael@0 | 29 | // |
michael@0 | 30 | nsSaveAsCharset(); |
michael@0 | 31 | virtual ~nsSaveAsCharset(); |
michael@0 | 32 | |
michael@0 | 33 | // |
michael@0 | 34 | // nsISupports |
michael@0 | 35 | // |
michael@0 | 36 | NS_DECL_ISUPPORTS |
michael@0 | 37 | |
michael@0 | 38 | // |
michael@0 | 39 | // nsIEntityConverter |
michael@0 | 40 | // |
michael@0 | 41 | NS_IMETHOD Init(const char *charset, uint32_t attr, uint32_t entityVersion); |
michael@0 | 42 | |
michael@0 | 43 | NS_IMETHOD Convert(const char16_t *inString, char **_retval); |
michael@0 | 44 | |
michael@0 | 45 | NS_IMETHODIMP GetCharset(char * *aCharset); |
michael@0 | 46 | |
michael@0 | 47 | protected: |
michael@0 | 48 | |
michael@0 | 49 | NS_IMETHOD DoCharsetConversion(const char16_t *inString, char **outString); |
michael@0 | 50 | |
michael@0 | 51 | NS_IMETHOD DoConversionFallBack(uint32_t inUCS4, char *outString, int32_t bufferLength); |
michael@0 | 52 | |
michael@0 | 53 | // do the fallback, reallocate the buffer if necessary |
michael@0 | 54 | // need to pass destination buffer info (size, current position and estimation of rest of the conversion) |
michael@0 | 55 | NS_IMETHOD HandleFallBack(uint32_t character, char **outString, int32_t *bufferLength, |
michael@0 | 56 | int32_t *currentPos, int32_t estimatedLength); |
michael@0 | 57 | |
michael@0 | 58 | nsresult SetupUnicodeEncoder(const char* charset); |
michael@0 | 59 | |
michael@0 | 60 | nsresult SetupCharsetList(const char *charsetList); |
michael@0 | 61 | |
michael@0 | 62 | const char * GetNextCharset(); |
michael@0 | 63 | |
michael@0 | 64 | uint32_t mAttribute; // conversion attribute |
michael@0 | 65 | uint32_t mEntityVersion; // see nsIEntityConverter |
michael@0 | 66 | nsCOMPtr<nsIUnicodeEncoder> mEncoder; // encoder (convert from unicode) |
michael@0 | 67 | nsCOMPtr<nsIEntityConverter> mEntityConverter; |
michael@0 | 68 | nsTArray<nsCString> mCharsetList; |
michael@0 | 69 | int32_t mCharsetListIndex; |
michael@0 | 70 | }; |
michael@0 | 71 | |
michael@0 | 72 | #endif |