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