|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #include "maindomfragment.h" |
|
26 #include "SenFragmentBase.h" |
|
27 |
|
28 namespace |
|
29 { |
|
30 const TInt KStateParsingDelegate = 100; |
|
31 _LIT8(KMainFragmentXmlns, "urn:main:fragment"); |
|
32 _LIT8(KMainFragmentName, "MainFragment"); |
|
33 _LIT8(KMainFragmentQName, "mn:MainFragment"); |
|
34 _LIT8(KDelegateName, "DelegateFragment"); |
|
35 } |
|
36 |
|
37 CMainDomFragment* CMainDomFragment::NewL() |
|
38 { |
|
39 CMainDomFragment* pNew = NewLC(); |
|
40 CleanupStack::Pop(); // pNew; |
|
41 return pNew; |
|
42 } |
|
43 |
|
44 CMainDomFragment* CMainDomFragment::NewLC() |
|
45 { |
|
46 CMainDomFragment* pNew = new (ELeave) CMainDomFragment; |
|
47 CleanupStack::PushL(pNew); |
|
48 pNew->BaseConstructL(); |
|
49 return pNew; |
|
50 } |
|
51 |
|
52 |
|
53 CMainDomFragment* CMainDomFragment::NewL( |
|
54 const TDesC8& aNsUri, |
|
55 const TDesC8& aLocalName, |
|
56 const TDesC8& aQName |
|
57 ) |
|
58 { |
|
59 CMainDomFragment* pNew = NewLC( aNsUri, aLocalName, aQName ); |
|
60 CleanupStack::Pop(); // pNew; |
|
61 return pNew; |
|
62 } |
|
63 |
|
64 CMainDomFragment* CMainDomFragment::NewLC( |
|
65 const TDesC8& aNsUri, |
|
66 const TDesC8& aLocalName, |
|
67 const TDesC8& aQName |
|
68 ) |
|
69 { |
|
70 CMainDomFragment* pNew = new (ELeave) CMainDomFragment; |
|
71 CleanupStack::PushL(pNew); |
|
72 pNew->BaseConstructL(aNsUri, aLocalName, aQName); |
|
73 return pNew; |
|
74 } |
|
75 |
|
76 |
|
77 CMainDomFragment::CMainDomFragment() |
|
78 : ipDelegateFragment(NULL) |
|
79 { |
|
80 } |
|
81 |
|
82 void CMainDomFragment::BaseConstructL() |
|
83 { |
|
84 CSenDomFragmentBase::BaseConstructL( |
|
85 KMainFragmentXmlns, |
|
86 KMainFragmentName, |
|
87 KMainFragmentQName |
|
88 ); |
|
89 } |
|
90 |
|
91 void CMainDomFragment::BaseConstructL( |
|
92 const TDesC8& aNsUri, |
|
93 const TDesC8& aLocalName, |
|
94 const TDesC8& aQName |
|
95 ) |
|
96 { |
|
97 CSenDomFragmentBase::BaseConstructL(aNsUri, aLocalName, aQName); |
|
98 } |
|
99 |
|
100 CMainDomFragment::~CMainDomFragment() |
|
101 { |
|
102 delete ipDelegateFragment; |
|
103 } |
|
104 |
|
105 void CMainDomFragment::OnStartElementL(const RTagInfo& aElement, |
|
106 const RAttributeArray& aAttributes, |
|
107 TInt aErrorCode) |
|
108 { |
|
109 switch (iState) |
|
110 { |
|
111 case KSenStateSave: |
|
112 { |
|
113 const TPtrC8 saxLocalName = aElement.LocalName().DesC(); |
|
114 |
|
115 if (saxLocalName == KDelegateName) |
|
116 { |
|
117 const TPtrC8 saxNsUri = aElement.Uri().DesC(); |
|
118 const TPtrC8 saxPrefix = aElement.Prefix().DesC(); |
|
119 |
|
120 TXmlEngElement element = AsElementL(); |
|
121 RSenDocument& document = AsDocumentL(); |
|
122 |
|
123 ipDelegateFragment = CDelegateDomFragment::NewL( |
|
124 saxNsUri, saxLocalName, |
|
125 saxPrefix, aAttributes, |
|
126 element, document |
|
127 ); |
|
128 |
|
129 iState = KStateParsingDelegate; |
|
130 |
|
131 OnDelegateParsingL(*ipDelegateFragment); |
|
132 } |
|
133 else |
|
134 { |
|
135 CSenDomFragmentBase::OnStartElementL(aElement, aAttributes, |
|
136 aErrorCode); |
|
137 } |
|
138 break; |
|
139 } |
|
140 default: |
|
141 { |
|
142 CSenDomFragmentBase::OnStartElementL(aElement, aAttributes, |
|
143 aErrorCode); |
|
144 break; |
|
145 } |
|
146 } |
|
147 } |
|
148 |
|
149 void CMainDomFragment::OnEndElementL(const RTagInfo& aElement, |
|
150 TInt aErrorCode) |
|
151 |
|
152 { |
|
153 switch(iState) |
|
154 { |
|
155 case KStateParsingDelegate: |
|
156 { |
|
157 iState = KSenStateSave; |
|
158 break; |
|
159 } |
|
160 |
|
161 default: |
|
162 { |
|
163 CSenDomFragmentBase::OnEndElementL(aElement, aErrorCode); |
|
164 break; |
|
165 } |
|
166 } |
|
167 } |
|
168 |
|
169 void CMainDomFragment::OnResumeParsingFromL(const RTagInfo& aElement, |
|
170 TInt aErrorCode) |
|
171 { |
|
172 SetContentHandler(*this); |
|
173 |
|
174 switch (iState) |
|
175 { |
|
176 // no other states may be resumed(!) |
|
177 case KStateParsingDelegate: |
|
178 { |
|
179 OnEndElementL(aElement, aErrorCode); |
|
180 } |
|
181 break; |
|
182 } |
|
183 } |
|
184 |
|
185 CDelegateDomFragment& CMainDomFragment::DelegateFragment() |
|
186 { |
|
187 return *ipDelegateFragment; |
|
188 } |
|
189 |
|
190 // END OF FILE |
|
191 |