messagingfw/wappushfw/plugins/StringDictionaries/ServiceLoading/Sl1_0StringDict00.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <e32std.h>
       
    17 #include <ecom/implementationproxy.h>
       
    18 
       
    19 #include <xml/plugins/dictionarycodepage.h>
       
    20 
       
    21 #include <xml/xmlframeworkerrors.h>
       
    22 
       
    23 #include "Sl1_0StringDict00.h"
       
    24 #include "sl1_0stringdict00tagtable.h"
       
    25 #include "sl1_0stringdict00attributetable.h"
       
    26 #include "sl1_0stringdict00attributevaluetable.h"
       
    27 
       
    28 using namespace Xml;
       
    29 
       
    30 MStringDictionary* CSl1_0StringDict00::NewL(TAny* aStringPool)
       
    31 	{
       
    32 	CSl1_0StringDict00* self = new(ELeave) CSl1_0StringDict00(reinterpret_cast<RStringPool*>(aStringPool));
       
    33 	CleanupStack::PushL(self);
       
    34 	self->ConstructL();
       
    35 	CleanupStack::Pop(self);
       
    36 	return (static_cast<MStringDictionary*>(self));
       
    37 	}
       
    38 
       
    39 
       
    40 
       
    41 CSl1_0StringDict00::CSl1_0StringDict00(RStringPool* aStringPool)
       
    42 :	iStringPool(*aStringPool)
       
    43 	{
       
    44 	// do nothing;
       
    45 	}
       
    46 
       
    47 
       
    48 
       
    49 void CSl1_0StringDict00::ConstructL()
       
    50 	{
       
    51 	// we don't own this stringpool
       
    52 	iStringPool.OpenL(Sl1_0StringDict00TagTable::Table);
       
    53 	iStringPool.OpenL(Sl1_0StringDict00AttributeTable::Table);
       
    54 	iStringPool.OpenL(Sl1_0StringDict00AttributeValueTable::Table);
       
    55 
       
    56 	iCodepage00Table = CDictionaryCodePage::NewL(
       
    57 		&Sl1_0StringDict00TagTable::Table, 
       
    58 		&Sl1_0StringDict00AttributeTable::Table, 
       
    59 		&Sl1_0StringDict00AttributeValueTable::Table, 
       
    60 		0); // codepage
       
    61 
       
    62 	// Construct the correlation mapping
       
    63 	iCodepage00Table->ConstructIndexMappingL(iTagCodePage00, CDictionaryCodePage::EStringTypeElement);
       
    64 	iCodepage00Table->ConstructIndexMappingL(iAttributeCodePage00, CDictionaryCodePage::EStringTypeAttribute);
       
    65 	iCodepage00Table->ConstructIndexMappingL(iAttributeValueCodePage00, CDictionaryCodePage::EStringTypeAttributeValue);
       
    66 	}
       
    67 
       
    68 
       
    69 
       
    70 
       
    71 void CSl1_0StringDict00::Release()
       
    72 	{
       
    73 	delete (this);
       
    74 	}
       
    75 
       
    76 
       
    77 
       
    78 
       
    79 CSl1_0StringDict00::~CSl1_0StringDict00()
       
    80 	{
       
    81 	delete iCodepage00Table;
       
    82 	}
       
    83 
       
    84 
       
    85 
       
    86 void CSl1_0StringDict00::ElementL(TInt aToken, RString& aElement) const
       
    87 	{
       
    88 	TInt index = iCodepage00Table->StringPoolIndexFromToken(
       
    89 					aToken, CDictionaryCodePage::EStringTypeElement);
       
    90 
       
    91 	if (index == KErrXmlStringPoolTableNotFound)
       
    92 		{
       
    93 		User::Leave(KErrXmlUnsupportedElement);
       
    94 		}
       
    95 
       
    96 	// when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable()
       
    97 	aElement = iStringPool.String(
       
    98 		index,
       
    99 		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
       
   100 	}
       
   101 
       
   102 
       
   103 
       
   104 void CSl1_0StringDict00::AttributeL(TInt aToken, RString& aAttribute) const
       
   105 	{
       
   106 	TInt index = iCodepage00Table->StringPoolIndexFromToken(
       
   107 					aToken, CDictionaryCodePage::EStringTypeAttribute);
       
   108 
       
   109 	if (index == KErrXmlStringPoolTableNotFound)
       
   110 		{
       
   111 		User::Leave(KErrXmlUnsupportedAttribute);
       
   112 		}
       
   113 
       
   114 	// when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable()
       
   115 	aAttribute = iStringPool.String(
       
   116 		index,
       
   117 		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeAttribute)));
       
   118 	};
       
   119 
       
   120 
       
   121 
       
   122 void CSl1_0StringDict00::AttributeValuePairL(TInt aToken, RString& aAttribute, RString& aValue) const
       
   123 	{
       
   124 	AttributeL(aToken, aAttribute);
       
   125 	AttributeValueL(aToken, aValue);
       
   126 	};
       
   127 	
       
   128 
       
   129 
       
   130 void CSl1_0StringDict00::AttributeValueL(TInt aToken, RString& aValue) const
       
   131 	{
       
   132 	TInt index = iCodepage00Table->StringPoolIndexFromToken(
       
   133 					aToken, CDictionaryCodePage::EStringTypeAttributeValue);
       
   134 
       
   135 	if (index == KErrXmlStringPoolTableNotFound)
       
   136 		{
       
   137 		User::Leave(KErrXmlUnsupportedAttributeValue);
       
   138 		}
       
   139 
       
   140 	// when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable()
       
   141 	aValue = iStringPool.String(
       
   142 		index,
       
   143 		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeAttributeValue)));
       
   144 	};
       
   145 
       
   146 
       
   147 
       
   148 TBool CSl1_0StringDict00::CompareThisDictionary(const RString& aDictionaryDescription) const
       
   149 	{
       
   150 	// If this string dictionary has many codepages then all these comparisons should go here.
       
   151 	// Remember, the string dictionary loads up all the RStringTables into its RStringPool
       
   152 	// on construction. So if the comparison fails we do not have it.
       
   153 	return (
       
   154 		(aDictionaryDescription == iStringPool.String(Sl1_0StringDict00TagTable::EUri, Sl1_0StringDict00TagTable::Table))		||
       
   155 		(aDictionaryDescription == iStringPool.String(Sl1_0StringDict00TagTable::EPublicId, Sl1_0StringDict00TagTable::Table))||
       
   156 		(aDictionaryDescription == iStringPool.String(Sl1_0StringDict00TagTable::EFormalPublicId, Sl1_0StringDict00TagTable::Table)));
       
   157 	}
       
   158 
       
   159 
       
   160 
       
   161 TInt CSl1_0StringDict00::SwitchCodePage(TInt aCodePage)
       
   162 	{
       
   163 	// We only have one codepage sp can't switch
       
   164 	if (aCodePage != iCodePage)
       
   165 		{
       
   166 		return KErrXmlMissingStringDictionary;
       
   167 		}
       
   168 	return iCodePage;
       
   169 	}
       
   170 
       
   171 		
       
   172 
       
   173 
       
   174 		
       
   175 /**
       
   176 This method obtains the public identifier from the StringTable.
       
   177 Either the formal or non formal public id will do.
       
   178 The stringDictionary .rss files must list both these as wbxml
       
   179 documents have one or the other.
       
   180 
       
   181 @param				aPubId The public identifier for this string 
       
   182 					dictionary.
       
   183 */
       
   184 
       
   185 void CSl1_0StringDict00::PublicIdentifier(RString& aPubId)
       
   186 	{
       
   187 	aPubId = iStringPool.String(
       
   188 		Sl1_0StringDict00TagTable::EFormalPublicId,
       
   189 		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
       
   190 	}
       
   191 
       
   192 
       
   193 /**
       
   194 The element types in the Device Information DTD are defined within
       
   195 a namespace associated with the Uri/Urn available from the StringTable.
       
   196 The RString need not be closed, but closing is harmless. 
       
   197 
       
   198 @param				aUri The associated namespace for this string 
       
   199 					dictionary.
       
   200 */
       
   201 
       
   202 void CSl1_0StringDict00::NamespaceUri(RString& aUri)
       
   203 	{
       
   204 	aUri = iStringPool.String(
       
   205 		Sl1_0StringDict00TagTable::EUri,
       
   206 		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
       
   207 	}
       
   208 
       
   209 
       
   210 
       
   211 const TInt KUidSLStringDictPlugin = 0x10282652;
       
   212 
       
   213 // __________________________________________________________________________
       
   214 // Exported proxy for instantiation method resolution
       
   215 // Define the interface UIDs
       
   216 const TImplementationProxy ImplementationTable[] = {
       
   217 	IMPLEMENTATION_PROXY_ENTRY(KUidSLStringDictPlugin, CSl1_0StringDict00::NewL)
       
   218 };
       
   219 
       
   220 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   221 	{
       
   222 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   223 
       
   224 	return ImplementationTable;
       
   225 	}
       
   226 
       
   227 #ifndef EKA2
       
   228 /** DLL Entry point */
       
   229 GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
       
   230 	{
       
   231 	return(KErrNone);
       
   232 	}
       
   233 #endif