1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/charconvfw/charconvplugins/src/plugins/gbk.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,121 @@
1.4 +/*
1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <e32std.h>
1.23 +#include <charconv.h>
1.24 +#include "gbk.h"
1.25 +#include <ecom/implementationproxy.h>
1.26 +#include <charactersetconverter.h>
1.27 +
1.28 +class CGBKConverterImpl : public CCharacterSetConverterPluginInterface
1.29 + {
1.30 +
1.31 +public:
1.32 + virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
1.33 +
1.34 + virtual TInt ConvertFromUnicode(
1.35 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.36 + const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
1.37 + TDes8& aForeign,
1.38 + const TDesC16& aUnicode,
1.39 + CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
1.40 +
1.41 + virtual TInt ConvertToUnicode(
1.42 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.43 + TDes16& aUnicode,
1.44 + const TDesC8& aForeign,
1.45 + TInt& aState,
1.46 + TInt& aNumberOfUnconvertibleCharacters,
1.47 + TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
1.48 +
1.49 + virtual TBool IsInThisCharacterSetL(
1.50 + TBool& aSetToTrue,
1.51 + TInt& aConfidenceLevel,
1.52 + const TDesC8& aSample);
1.53 +
1.54 + static CGBKConverterImpl* NewL();
1.55 + virtual ~CGBKConverterImpl();
1.56 +
1.57 +private:
1.58 + CGBKConverterImpl();
1.59 +
1.60 + };
1.61 +
1.62 +
1.63 +const TDesC8& CGBKConverterImpl::ReplacementForUnconvertibleUnicodeCharacters()
1.64 + {
1.65 + return CnvGbk::ReplacementForUnconvertibleUnicodeCharacters();
1.66 + }
1.67 +
1.68 +TInt CGBKConverterImpl::ConvertFromUnicode(
1.69 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.70 + const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
1.71 + TDes8& aForeign,
1.72 + const TDesC16& aUnicode,
1.73 + CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
1.74 + {
1.75 + return CnvGbk::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters);
1.76 + }
1.77 +
1.78 +TInt CGBKConverterImpl::ConvertToUnicode(
1.79 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.80 + TDes16& aUnicode,
1.81 + const TDesC8& aForeign,
1.82 + TInt& /*aState*/,
1.83 + TInt& aNumberOfUnconvertibleCharacters,
1.84 + TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
1.85 + {
1.86 + return CnvGbk::ConvertToUnicode(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
1.87 + }
1.88 +
1.89 +TBool CGBKConverterImpl::IsInThisCharacterSetL(
1.90 + TBool& aSetToTrue,
1.91 + TInt& aConfidenceLevel,
1.92 + const TDesC8& aSample)
1.93 + {
1.94 + aSetToTrue = ETrue;
1.95 + return CnvGbk::IsCharGBBased(aConfidenceLevel, aSample);
1.96 + }
1.97 +
1.98 +CGBKConverterImpl* CGBKConverterImpl::NewL()
1.99 + {
1.100 + CGBKConverterImpl* self = new(ELeave) CGBKConverterImpl();
1.101 + return self;
1.102 + }
1.103 +
1.104 +CGBKConverterImpl::~CGBKConverterImpl()
1.105 + {
1.106 + }
1.107 +
1.108 +CGBKConverterImpl::CGBKConverterImpl()
1.109 + {
1.110 + }
1.111 +
1.112 +
1.113 +const TImplementationProxy ImplementationTable[] =
1.114 + {
1.115 + IMPLEMENTATION_PROXY_ENTRY(0x10003ECB,CGBKConverterImpl::NewL)
1.116 + };
1.117 +
1.118 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
1.119 + {
1.120 + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
1.121 +
1.122 + return ImplementationTable;
1.123 + }
1.124 +