2001-09-26 04:47:52 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-10-12 03:47:27 +04:00
|
|
|
|
2010-08-18 14:17:12 +04:00
|
|
|
#ifndef nsSaveAsCharset_h__
|
|
|
|
#define nsSaveAsCharset_h__
|
|
|
|
|
2013-09-27 20:45:04 +04:00
|
|
|
#include "nsStringFwd.h"
|
2009-01-22 07:15:34 +03:00
|
|
|
#include "nsTArray.h"
|
1999-10-12 03:47:27 +04:00
|
|
|
#include "nsISaveAsCharset.h"
|
2014-05-08 13:32:00 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1999-10-12 03:47:27 +04:00
|
|
|
|
|
|
|
#define MASK_FALLBACK(a) (nsISaveAsCharset::mask_Fallback & (a))
|
|
|
|
#define MASK_ENTITY(a) (nsISaveAsCharset::mask_Entity & (a))
|
2002-04-26 02:49:19 +04:00
|
|
|
#define MASK_CHARSET_FALLBACK(a) (nsISaveAsCharset::mask_CharsetFallback & (a))
|
1999-10-12 03:47:27 +04:00
|
|
|
#define ATTR_NO_FALLBACK(a) (nsISaveAsCharset::attr_FallbackNone == MASK_FALLBACK(a) && \
|
|
|
|
nsISaveAsCharset::attr_EntityAfterCharsetConv != MASK_ENTITY(a))
|
|
|
|
|
|
|
|
class nsIUnicodeEncoder;
|
|
|
|
class nsIEntityConverter;
|
|
|
|
|
|
|
|
class nsSaveAsCharset : public nsISaveAsCharset
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//
|
|
|
|
// implementation methods
|
|
|
|
//
|
|
|
|
nsSaveAsCharset();
|
|
|
|
|
|
|
|
//
|
|
|
|
// nsISupports
|
|
|
|
//
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
//
|
|
|
|
// nsIEntityConverter
|
|
|
|
//
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Init(const char *charset, uint32_t attr, uint32_t entityVersion) override;
|
1999-10-12 03:47:27 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Convert(const char16_t *inString, char **_retval) override;
|
1999-10-12 03:47:27 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHODIMP GetCharset(char * *aCharset) override;
|
2002-04-26 02:49:19 +04:00
|
|
|
|
1999-10-12 03:47:27 +04:00
|
|
|
protected:
|
|
|
|
|
2014-06-24 02:40:02 +04:00
|
|
|
virtual ~nsSaveAsCharset();
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
NS_IMETHOD DoCharsetConversion(const char16_t *inString, char **outString);
|
1999-10-12 03:47:27 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD DoConversionFallBack(uint32_t inUCS4, char *outString, int32_t bufferLength);
|
1999-10-12 03:47:27 +04:00
|
|
|
|
|
|
|
// do the fallback, reallocate the buffer if necessary
|
|
|
|
// need to pass destination buffer info (size, current position and estimation of rest of the conversion)
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD HandleFallBack(uint32_t character, char **outString, int32_t *bufferLength,
|
|
|
|
int32_t *currentPos, int32_t estimatedLength);
|
1999-10-12 03:47:27 +04:00
|
|
|
|
2002-04-26 02:49:19 +04:00
|
|
|
nsresult SetupUnicodeEncoder(const char* charset);
|
|
|
|
|
|
|
|
nsresult SetupCharsetList(const char *charsetList);
|
|
|
|
|
|
|
|
const char * GetNextCharset();
|
1999-10-12 03:47:27 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mAttribute; // conversion attribute
|
|
|
|
uint32_t mEntityVersion; // see nsIEntityConverter
|
2002-04-26 02:49:19 +04:00
|
|
|
nsCOMPtr<nsIUnicodeEncoder> mEncoder; // encoder (convert from unicode)
|
|
|
|
nsCOMPtr<nsIEntityConverter> mEntityConverter;
|
2009-01-22 07:15:34 +03:00
|
|
|
nsTArray<nsCString> mCharsetList;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mCharsetListIndex;
|
1999-10-12 03:47:27 +04:00
|
|
|
};
|
|
|
|
|
2010-08-18 14:17:12 +04:00
|
|
|
#endif
|