|
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 #include "maindomfragment.h" |
|
24 #include "SenFragmentBase.h" |
|
25 |
|
26 namespace |
|
27 { |
|
28 const TInt KStateParsingDelegate = 100; |
|
29 _LIT8(KMainFragmentXmlns, "urn:main:fragment"); |
|
30 _LIT8(KMainFragmentName, "MainFragment"); |
|
31 _LIT8(KMainFragmentQName, "mn:MainFragment"); |
|
32 _LIT8(KDelegateName, "DelegateFragment"); |
|
33 } |
|
34 |
|
35 CMainDomFragment* CMainDomFragment::NewL() |
|
36 { |
|
37 CMainDomFragment* pNew = NewLC(); |
|
38 CleanupStack::Pop(); // pNew; |
|
39 return pNew; |
|
40 } |
|
41 |
|
42 CMainDomFragment* CMainDomFragment::NewLC() |
|
43 { |
|
44 CMainDomFragment* pNew = new (ELeave) CMainDomFragment; |
|
45 CleanupStack::PushL(pNew); |
|
46 pNew->BaseConstructL(); |
|
47 return pNew; |
|
48 } |
|
49 |
|
50 |
|
51 CMainDomFragment* CMainDomFragment::NewL( |
|
52 const TDesC8& aNsUri, |
|
53 const TDesC8& aLocalName, |
|
54 const TDesC8& aQName |
|
55 ) |
|
56 { |
|
57 CMainDomFragment* pNew = NewLC( aNsUri, aLocalName, aQName ); |
|
58 CleanupStack::Pop(); // pNew; |
|
59 return pNew; |
|
60 } |
|
61 |
|
62 CMainDomFragment* CMainDomFragment::NewLC( |
|
63 const TDesC8& aNsUri, |
|
64 const TDesC8& aLocalName, |
|
65 const TDesC8& aQName |
|
66 ) |
|
67 { |
|
68 CMainDomFragment* pNew = new (ELeave) CMainDomFragment; |
|
69 CleanupStack::PushL(pNew); |
|
70 pNew->BaseConstructL(aNsUri, aLocalName, aQName); |
|
71 return pNew; |
|
72 } |
|
73 |
|
74 |
|
75 CMainDomFragment::CMainDomFragment() |
|
76 : ipDelegateFragment(NULL) |
|
77 { |
|
78 } |
|
79 |
|
80 void CMainDomFragment::BaseConstructL() |
|
81 { |
|
82 CSenDomFragmentBase::BaseConstructL( |
|
83 KMainFragmentXmlns, |
|
84 KMainFragmentName, |
|
85 KMainFragmentQName |
|
86 ); |
|
87 } |
|
88 |
|
89 void CMainDomFragment::BaseConstructL( |
|
90 const TDesC8& aNsUri, |
|
91 const TDesC8& aLocalName, |
|
92 const TDesC8& aQName |
|
93 ) |
|
94 { |
|
95 CSenDomFragmentBase::BaseConstructL(aNsUri, aLocalName, aQName); |
|
96 } |
|
97 |
|
98 CMainDomFragment::~CMainDomFragment() |
|
99 { |
|
100 delete ipDelegateFragment; |
|
101 } |
|
102 |
|
103 void CMainDomFragment::OnStartElementL(const RTagInfo& aElement, |
|
104 const RAttributeArray& aAttributes, |
|
105 TInt aErrorCode) |
|
106 { |
|
107 switch (iState) |
|
108 { |
|
109 case KSenStateSave: |
|
110 { |
|
111 const TPtrC8 saxLocalName = aElement.LocalName().DesC(); |
|
112 |
|
113 if (saxLocalName == KDelegateName) |
|
114 { |
|
115 const TPtrC8 saxNsUri = aElement.Uri().DesC(); |
|
116 const TPtrC8 saxPrefix = aElement.Prefix().DesC(); |
|
117 |
|
118 TXmlEngElement element = AsElementL(); |
|
119 RSenDocument& document = AsDocumentL(); |
|
120 |
|
121 ipDelegateFragment = CDelegateDomFragment::NewL( |
|
122 saxNsUri, saxLocalName, |
|
123 saxPrefix, aAttributes, |
|
124 element, document |
|
125 ); |
|
126 |
|
127 iState = KStateParsingDelegate; |
|
128 |
|
129 OnDelegateParsingL(*ipDelegateFragment); |
|
130 } |
|
131 else |
|
132 { |
|
133 CSenDomFragmentBase::OnStartElementL(aElement, aAttributes, |
|
134 aErrorCode); |
|
135 } |
|
136 break; |
|
137 } |
|
138 default: |
|
139 { |
|
140 CSenDomFragmentBase::OnStartElementL(aElement, aAttributes, |
|
141 aErrorCode); |
|
142 break; |
|
143 } |
|
144 } |
|
145 } |
|
146 |
|
147 void CMainDomFragment::OnEndElementL(const RTagInfo& aElement, |
|
148 TInt aErrorCode) |
|
149 |
|
150 { |
|
151 switch(iState) |
|
152 { |
|
153 case KStateParsingDelegate: |
|
154 { |
|
155 iState = KSenStateSave; |
|
156 break; |
|
157 } |
|
158 |
|
159 default: |
|
160 { |
|
161 CSenDomFragmentBase::OnEndElementL(aElement, aErrorCode); |
|
162 break; |
|
163 } |
|
164 } |
|
165 } |
|
166 |
|
167 void CMainDomFragment::OnResumeParsingFromL(const RTagInfo& aElement, |
|
168 TInt aErrorCode) |
|
169 { |
|
170 SetContentHandler(*this); |
|
171 |
|
172 switch (iState) |
|
173 { |
|
174 // no other states may be resumed(!) |
|
175 case KStateParsingDelegate: |
|
176 { |
|
177 OnEndElementL(aElement, aErrorCode); |
|
178 } |
|
179 break; |
|
180 } |
|
181 } |
|
182 |
|
183 CDelegateDomFragment& CMainDomFragment::DelegateFragment() |
|
184 { |
|
185 return *ipDelegateFragment; |
|
186 } |
|
187 |
|
188 // END OF FILE |
|
189 |