xml/wbxmlparser/src/sd_syncml/syncml1_1stringdictionary00.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_1stringdictionary00.h"
       
    23 #include "syncml1_1codepage00tagtable.h"
       
    24 
       
    25 using namespace Xml;
       
    26 
       
    27 Xml::MStringDictionary* CSyncml1_1StringDictionary00::NewL(TAny* aStringPool)
       
    28 	{
       
    29 	CSyncml1_1StringDictionary00* self = new(ELeave) CSyncml1_1StringDictionary00(reinterpret_cast<RStringPool*>(aStringPool));
       
    30 	CleanupStack::PushL(self);
       
    31 	self->ConstructL();
       
    32 	CleanupStack::Pop(self);
       
    33 	return self;
       
    34 	}
       
    35 
       
    36 
       
    37 
       
    38 CSyncml1_1StringDictionary00::CSyncml1_1StringDictionary00(RStringPool* aStringPool)
       
    39 :	iStringPool(*aStringPool),
       
    40 	iCodePage(0)
       
    41 	{
       
    42 	// do nothing;
       
    43 	}
       
    44 
       
    45 
       
    46 
       
    47 void CSyncml1_1StringDictionary00::ConstructL()
       
    48 	{
       
    49 	// we don't own this stringpool
       
    50 	iStringPool.OpenL(Syncml1_1CodePage00TagTable::Table);
       
    51 
       
    52 	iCodepage00Table = Xml::CDictionaryCodePage::NewL(&Syncml1_1CodePage00TagTable::Table, 0, 0, 0);
       
    53 
       
    54 	// Construct the correlation mapping
       
    55 	iCodepage00Table->ConstructIndexMappingL(iCodePage00, Xml::CDictionaryCodePage::EStringTypeElement);
       
    56 	}
       
    57 
       
    58 
       
    59 
       
    60 
       
    61 void CSyncml1_1StringDictionary00::Release()
       
    62 	{
       
    63 	delete (this);
       
    64 	}
       
    65 
       
    66 
       
    67 
       
    68 
       
    69 CSyncml1_1StringDictionary00::~CSyncml1_1StringDictionary00()
       
    70 	{
       
    71 	if (iCodepage00Table)
       
    72 		{
       
    73 		delete iCodepage00Table;
       
    74 		}
       
    75 	}
       
    76 
       
    77 
       
    78 
       
    79 void CSyncml1_1StringDictionary00::ElementL(TInt aToken, RString& aElement) const
       
    80 	{
       
    81 	TInt index = iCodepage00Table->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 		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
       
    93 	}
       
    94 
       
    95 
       
    96 
       
    97 void CSyncml1_1StringDictionary00::AttributeL(TInt /*aToken*/, RString& /*aAttribute*/) const
       
    98 	{
       
    99 	// SyncML does not have attributes
       
   100 	User::Leave(KErrXmlUnsupportedAttribute);
       
   101 	};
       
   102 
       
   103 
       
   104 
       
   105 void CSyncml1_1StringDictionary00::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_1StringDictionary00::AttributeValueL(TInt /*aToken*/, RString& /*aValue*/) const
       
   114 	{
       
   115 	// SyncML does not have attributes
       
   116 	User::Leave(KErrXmlUnsupportedAttributeValue);
       
   117 	};
       
   118 
       
   119 
       
   120 
       
   121 TBool CSyncml1_1StringDictionary00::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 	// For backward compatibility with SyncML 1.0, EUrnBC,EPublicIdBC,EFormalPublicIdBC added in .st file
       
   127 	return (
       
   128 		(aDictionaryDescription == iStringPool.String(Syncml1_1CodePage00TagTable::EUrn, Syncml1_1CodePage00TagTable::Table))		||
       
   129 		(aDictionaryDescription == iStringPool.String(Syncml1_1CodePage00TagTable::EPublicId, Syncml1_1CodePage00TagTable::Table))||
       
   130 		(aDictionaryDescription == iStringPool.String(Syncml1_1CodePage00TagTable::EFormalPublicId, Syncml1_1CodePage00TagTable::Table))||
       
   131 		(aDictionaryDescription == iStringPool.String(Syncml1_1CodePage00TagTable::EUrnBC, Syncml1_1CodePage00TagTable::Table))		||
       
   132 		(aDictionaryDescription == iStringPool.String(Syncml1_1CodePage00TagTable::EPublicIdBC, Syncml1_1CodePage00TagTable::Table))||
       
   133 		(aDictionaryDescription == iStringPool.String(Syncml1_1CodePage00TagTable::EFormalPublicIdBC, Syncml1_1CodePage00TagTable::Table)));
       
   134 	}
       
   135 
       
   136 
       
   137 
       
   138 TInt CSyncml1_1StringDictionary00::SwitchCodePage(TInt aCodePage)
       
   139 	{
       
   140 	// We only have one codepage sp can't switch
       
   141 	if (aCodePage != iCodePage)
       
   142 		{
       
   143 		return KErrXmlMissingStringDictionary;
       
   144 		}
       
   145 	return iCodePage;
       
   146 	}
       
   147 
       
   148 		
       
   149 /**
       
   150 This method obtains the public identifier from the StringTable.
       
   151 Either the formal or non formal public id will do.
       
   152 The stringDictionary .rss files must list both these as wbxml
       
   153 documents have one or the other.
       
   154 
       
   155 @param				aPubId The public identifier for this string 
       
   156 					dictionary.
       
   157 */
       
   158 
       
   159 void CSyncml1_1StringDictionary00::PublicIdentifier(RString& aPubId)
       
   160 	{
       
   161 	// Better to use the element table as some documents don't have attributes.
       
   162 	aPubId = iStringPool.String(
       
   163 		Syncml1_1CodePage00TagTable::EFormalPublicId,
       
   164 		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
       
   165 	}
       
   166 
       
   167 
       
   168 /**
       
   169 The element types in the Device Information DTD are defined within
       
   170 a namespace associated with the Uri/Urn available from the StringTable.
       
   171 The RString need not be closed, but closing is harmless. 
       
   172 
       
   173 @param				aUri The associated namespace for this string 
       
   174 					dictionary.
       
   175 */
       
   176 
       
   177 void CSyncml1_1StringDictionary00::NamespaceUri(RString& aUri)
       
   178 	{
       
   179 	// Better to use the element table as some documents don't have attributes.
       
   180 	aUri = iStringPool.String(
       
   181 		Syncml1_1CodePage00TagTable::EUrn,
       
   182 		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
       
   183 	}
       
   184 
       
   185 
       
   186 // __________________________________________________________________________
       
   187 // Exported proxy for instantiation method resolution
       
   188 // Define the interface UIDs
       
   189 const TImplementationProxy ImplementationTable[] = {
       
   190 	IMPLEMENTATION_PROXY_ENTRY(0x101FA950,CSyncml1_1StringDictionary00::NewL)
       
   191 };
       
   192 
       
   193 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   194 	{
       
   195 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   196 
       
   197 	return ImplementationTable;
       
   198 	}
       
   199