xml/wbxmlparser/src/sd_syncml/syncml1_2stringdictionary01.cpp
changeset 0 e35f40988205
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 // Copyright (c) 2003-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/xmlframeworkerrors.h>
       
    20 #include <xml/plugins/dictionarycodepage.h>
       
    21 
       
    22 #include "syncml1_2stringdictionary01.h"
       
    23 #include "syncml1_2codepage01tagtable.h"
       
    24 
       
    25 using namespace Xml;
       
    26 
       
    27 MStringDictionary* CSyncml1_2StringDictionary01::NewL(TAny* aStringPool)
       
    28 	{
       
    29 	CSyncml1_2StringDictionary01* self = new(ELeave) CSyncml1_2StringDictionary01(reinterpret_cast<RStringPool*>(aStringPool));
       
    30 	CleanupStack::PushL(self);
       
    31 	self->ConstructL();
       
    32 	CleanupStack::Pop(self);
       
    33 	return (static_cast<MStringDictionary*>(self));
       
    34 	}
       
    35 
       
    36 
       
    37 
       
    38 CSyncml1_2StringDictionary01::CSyncml1_2StringDictionary01(RStringPool* aStringPool)
       
    39 :	iStringPool(*aStringPool),
       
    40 	iCodePage(1)
       
    41 	{
       
    42 	// do nothing;
       
    43 	}
       
    44 
       
    45 
       
    46 
       
    47 void CSyncml1_2StringDictionary01::ConstructL()
       
    48 	{
       
    49 	// we don't own this stringpool
       
    50 	iStringPool.OpenL(Syncml1_2CodePage01TagTable::Table);
       
    51 
       
    52 	iCodepage01Table = CDictionaryCodePage::NewL(&Syncml1_2CodePage01TagTable::Table, 0, 0, 1);
       
    53 
       
    54 	// Construct the correlation mapping
       
    55 	iCodepage01Table->ConstructIndexMappingL(iCodePage01, CDictionaryCodePage::EStringTypeElement);
       
    56 	}
       
    57 
       
    58 
       
    59 
       
    60 
       
    61 void CSyncml1_2StringDictionary01::Release()
       
    62 	{
       
    63 	delete (this);
       
    64 	}
       
    65 
       
    66 
       
    67 
       
    68 
       
    69 CSyncml1_2StringDictionary01::~CSyncml1_2StringDictionary01()
       
    70 	{
       
    71 	if (iCodepage01Table)
       
    72 		{
       
    73 		delete iCodepage01Table;
       
    74 		}
       
    75 	}
       
    76 
       
    77 
       
    78 
       
    79 void CSyncml1_2StringDictionary01::ElementL(TInt aToken, RString& aElement) const
       
    80 	{
       
    81 	TInt index = iCodepage01Table->StringPoolIndexFromToken(
       
    82 					aToken, CDictionaryCodePage::EStringTypeElement);
       
    83 
       
    84 	if (index == KErrXmlStringPoolTableNotFound)
       
    85 		{
       
    86 		User::Leave(KErrXmlUnsupportedElement);
       
    87 		}
       
    88 
       
    89 	// when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable()
       
    90 	aElement = iStringPool.String(
       
    91 		index,
       
    92 		*(iCodepage01Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
       
    93 	}
       
    94 
       
    95 
       
    96 
       
    97 void CSyncml1_2StringDictionary01::AttributeL(TInt /*aToken*/, RString& /*aAttribute*/) const
       
    98 	{
       
    99 	// SyncML does not have attributes
       
   100 	User::Leave(KErrXmlUnsupportedAttribute);
       
   101 	};
       
   102 
       
   103 
       
   104 
       
   105 void CSyncml1_2StringDictionary01::AttributeValuePairL(TInt /*aToken*/, RString& /*aAttribute*/, RString& /*aValue*/) const
       
   106 	{
       
   107 	// SyncML does not have attributes
       
   108 	User::Leave(KErrXmlUnsupportedAttribute);
       
   109 	};
       
   110 	
       
   111 
       
   112 
       
   113 void CSyncml1_2StringDictionary01::AttributeValueL(TInt /*aToken*/, RString& /*aValue*/) const
       
   114 	{
       
   115 	// SyncML does not have attributes
       
   116 	User::Leave(KErrXmlUnsupportedAttributeValue);
       
   117 	};
       
   118 
       
   119 
       
   120 
       
   121 TBool CSyncml1_2StringDictionary01::CompareThisDictionary(const RString& aDictionaryDescription) const
       
   122 	{
       
   123 	// If this string dictionary has many codepages then all these comparisons should go here.
       
   124 	// Remember, the string dictionary loads up all the RStringTables into its RStringPool
       
   125 	// on construction. So if the comparison fails we do not have it.
       
   126 	return (
       
   127 		(aDictionaryDescription == iStringPool.String(Syncml1_2CodePage01TagTable::EUrn, Syncml1_2CodePage01TagTable::Table))		||
       
   128 		(aDictionaryDescription == iStringPool.String(Syncml1_2CodePage01TagTable::EPublicId, Syncml1_2CodePage01TagTable::Table))||
       
   129 		(aDictionaryDescription == iStringPool.String(Syncml1_2CodePage01TagTable::EFormalPublicId, Syncml1_2CodePage01TagTable::Table)));
       
   130 	}
       
   131 
       
   132 
       
   133 
       
   134 TInt CSyncml1_2StringDictionary01::SwitchCodePage(TInt aCodePage)
       
   135 	{
       
   136 	// We only have one codepage sp can't switch
       
   137 	if (aCodePage != iCodePage)
       
   138 		{
       
   139 		return KErrXmlMissingStringDictionary;
       
   140 		}
       
   141 	return iCodePage;
       
   142 	}
       
   143 
       
   144 		
       
   145 
       
   146 		
       
   147 /**
       
   148 This method obtains the public identifier from the StringTable.
       
   149 Either the formal or non formal public id will do.
       
   150 The stringDictionary .rss files must list both these as wbxml
       
   151 documents have one or the other.
       
   152 
       
   153 @param				aPubId The public identifier for this string 
       
   154 					dictionary.
       
   155 */
       
   156 
       
   157 void CSyncml1_2StringDictionary01::PublicIdentifier(RString& aPubId)
       
   158 	{
       
   159 	// Better to use the element table as some documents don't have attributes.
       
   160 	aPubId = iStringPool.String(
       
   161 		Syncml1_2CodePage01TagTable::EFormalPublicId,
       
   162 		*(iCodepage01Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
       
   163 	}
       
   164 
       
   165 
       
   166 /**
       
   167 The element types in the Device Information DTD are defined within
       
   168 a namespace associated with the Uri/Urn available from the StringTable.
       
   169 The RString need not be closed, but closing is harmless. 
       
   170 
       
   171 @param				aUri The associated namespace for this string 
       
   172 					dictionary.
       
   173 */
       
   174 
       
   175 void CSyncml1_2StringDictionary01::NamespaceUri(RString& aUri)
       
   176 	{
       
   177 	// Better to use the element table as some documents don't have attributes.
       
   178 	aUri = iStringPool.String(
       
   179 		Syncml1_2CodePage01TagTable::EUrn,
       
   180 		*(iCodepage01Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
       
   181 	}
       
   182 
       
   183 
       
   184 // __________________________________________________________________________
       
   185 // Exported proxy for instantiation method resolution
       
   186 // Define the interface UIDs
       
   187 const TImplementationProxy ImplementationTable[] = {
       
   188 	IMPLEMENTATION_PROXY_ENTRY(0x10207FA8,CSyncml1_2StringDictionary01::NewL)
       
   189 };
       
   190 
       
   191 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   192 	{
       
   193 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   194 
       
   195 	return ImplementationTable;
       
   196 	}
       
   197