2002-07-25 01:27:57 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:21:17 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2002-07-25 01:27:57 +04:00
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
2002-07-25 01:27:57 +04:00
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2002-07-25 01:27:57 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:21:17 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2002-07-25 01:27:57 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:21:17 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2002-07-25 01:27:57 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:21:17 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2002-07-25 01:27:57 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "nsUCSupport.h"
|
|
|
|
#include "nsUCConstructors.h"
|
|
|
|
|
|
|
|
template<class T>
|
2002-09-07 05:17:57 +04:00
|
|
|
inline NS_METHOD StabilizedQueryInterface(T* aNewObject,
|
2002-07-25 01:27:57 +04:00
|
|
|
REFNSIID aIID,
|
|
|
|
void **aResult)
|
|
|
|
{
|
|
|
|
NS_ADDREF(aNewObject);
|
|
|
|
nsresult rv = aNewObject->QueryInterface(aIID, aResult);
|
|
|
|
NS_RELEASE(aNewObject);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2002-09-07 05:17:57 +04:00
|
|
|
NS_METHOD
|
2003-02-26 04:15:36 +03:00
|
|
|
CreateMultiTableDecoder(PRInt32 aTableCount, const uRange * aRangeArray,
|
2006-08-07 11:57:31 +04:00
|
|
|
uScanClassID * aScanClassArray,
|
2002-07-25 01:27:57 +04:00
|
|
|
uMappingTable ** aMappingTable,
|
|
|
|
PRUint32 aMaxLengthFactor,
|
|
|
|
nsISupports* aOuter,
|
|
|
|
REFNSIID aIID,
|
|
|
|
void** aResult)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (aOuter)
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
|
|
|
nsMultiTableDecoderSupport* decoder =
|
|
|
|
new nsMultiTableDecoderSupport(aTableCount, aRangeArray,
|
2006-08-07 11:57:31 +04:00
|
|
|
aScanClassArray, aMappingTable,
|
2002-07-25 01:27:57 +04:00
|
|
|
aMaxLengthFactor);
|
|
|
|
if (!decoder)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return StabilizedQueryInterface(decoder, aIID, aResult);
|
|
|
|
}
|
|
|
|
|
2002-09-07 05:17:57 +04:00
|
|
|
NS_METHOD
|
|
|
|
CreateMultiTableEncoder(PRInt32 aTableCount,
|
2006-08-07 11:57:31 +04:00
|
|
|
uScanClassID * aScanClassArray,
|
|
|
|
uShiftOutTable ** aShiftOutTable,
|
2002-07-25 01:27:57 +04:00
|
|
|
uMappingTable ** aMappingTable,
|
|
|
|
PRUint32 aMaxLengthFactor,
|
|
|
|
nsISupports* aOuter,
|
|
|
|
REFNSIID aIID,
|
|
|
|
void** aResult)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (aOuter)
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
|
|
|
nsMultiTableEncoderSupport* encoder =
|
|
|
|
new nsMultiTableEncoderSupport(aTableCount,
|
2006-08-07 11:57:31 +04:00
|
|
|
aScanClassArray,
|
|
|
|
aShiftOutTable,
|
|
|
|
aMappingTable,
|
2002-07-25 01:27:57 +04:00
|
|
|
aMaxLengthFactor);
|
|
|
|
if (!encoder)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return StabilizedQueryInterface(encoder, aIID, aResult);
|
|
|
|
}
|
|
|
|
|
2002-09-07 05:17:57 +04:00
|
|
|
NS_METHOD
|
2006-08-07 11:57:31 +04:00
|
|
|
CreateMultiTableEncoder(PRInt32 aTableCount,
|
|
|
|
uScanClassID * aScanClassArray,
|
|
|
|
uMappingTable ** aMappingTable,
|
|
|
|
PRUint32 aMaxLengthFactor,
|
|
|
|
nsISupports* aOuter,
|
|
|
|
REFNSIID aIID,
|
|
|
|
void** aResult)
|
|
|
|
{
|
|
|
|
return CreateMultiTableEncoder(aTableCount, aScanClassArray,
|
|
|
|
nsnull,
|
|
|
|
aMappingTable, aMaxLengthFactor,
|
|
|
|
aOuter, aIID, aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
|
|
|
CreateTableEncoder(uScanClassID aScanClass,
|
|
|
|
uShiftOutTable * aShiftOutTable,
|
2002-09-07 05:17:57 +04:00
|
|
|
uMappingTable * aMappingTable,
|
|
|
|
PRUint32 aMaxLengthFactor,
|
|
|
|
nsISupports* aOuter,
|
|
|
|
REFNSIID aIID,
|
|
|
|
void** aResult)
|
2002-07-25 01:27:57 +04:00
|
|
|
{
|
|
|
|
if (aOuter)
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
|
|
|
nsTableEncoderSupport* encoder =
|
2006-08-07 11:57:31 +04:00
|
|
|
new nsTableEncoderSupport(aScanClass,
|
|
|
|
aShiftOutTable, aMappingTable,
|
2002-07-25 01:27:57 +04:00
|
|
|
aMaxLengthFactor);
|
|
|
|
if (!encoder)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return StabilizedQueryInterface(encoder, aIID, aResult);
|
|
|
|
}
|
2002-09-07 05:17:57 +04:00
|
|
|
|
|
|
|
NS_METHOD
|
2006-08-07 11:57:31 +04:00
|
|
|
CreateTableEncoder(uScanClassID aScanClass,
|
|
|
|
uMappingTable * aMappingTable,
|
|
|
|
PRUint32 aMaxLengthFactor,
|
|
|
|
nsISupports* aOuter,
|
|
|
|
REFNSIID aIID,
|
|
|
|
void** aResult)
|
|
|
|
{
|
|
|
|
return CreateTableEncoder(aScanClass, nsnull,
|
|
|
|
aMappingTable, aMaxLengthFactor,
|
|
|
|
aOuter, aIID, aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
|
|
|
CreateTableDecoder(uScanClassID aScanClass,
|
|
|
|
uShiftInTable * aShiftInTable,
|
2002-09-07 05:17:57 +04:00
|
|
|
uMappingTable * aMappingTable,
|
|
|
|
PRUint32 aMaxLengthFactor,
|
|
|
|
nsISupports* aOuter,
|
|
|
|
REFNSIID aIID,
|
|
|
|
void** aResult)
|
|
|
|
{
|
|
|
|
if (aOuter)
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
|
|
|
nsTableDecoderSupport* decoder =
|
2006-08-07 11:57:31 +04:00
|
|
|
new nsTableDecoderSupport(aScanClass, aShiftInTable, aMappingTable,
|
2002-09-07 05:17:57 +04:00
|
|
|
aMaxLengthFactor);
|
|
|
|
if (!decoder)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return StabilizedQueryInterface(decoder, aIID, aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
2006-08-07 11:57:31 +04:00
|
|
|
CreateOneByteDecoder(uMappingTable * aMappingTable,
|
2002-09-07 05:17:57 +04:00
|
|
|
|
|
|
|
nsISupports* aOuter,
|
|
|
|
REFNSIID aIID,
|
|
|
|
void** aResult)
|
|
|
|
{
|
|
|
|
if (aOuter) return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
|
|
|
nsOneByteDecoderSupport* decoder =
|
2006-08-07 11:57:31 +04:00
|
|
|
new nsOneByteDecoderSupport(aMappingTable);
|
2002-09-07 05:17:57 +04:00
|
|
|
|
|
|
|
if (!decoder)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return StabilizedQueryInterface(decoder, aIID, aResult);
|
|
|
|
}
|