|
1 // Copyright (c) 2005-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 "HtmlParserPlugin.h" |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <ecom/implementationproxy.h> |
|
20 #include <xml/stringdictionarycollection.h> |
|
21 #include <xml/contenthandler.h> |
|
22 |
|
23 #include "HtmlParser.h" |
|
24 using namespace Xml; |
|
25 |
|
26 MParser* CHtmlParserPlugin::EcomNewL( TAny* aInitParams ) |
|
27 { |
|
28 // The cast to the MParser interface is a particular to the Xml Framework. Ecom plug-ins usually |
|
29 // return the pointer to the C class. |
|
30 return static_cast< MParser* >( CHtmlParserPlugin::NewL( aInitParams ) ); |
|
31 } |
|
32 |
|
33 /* |
|
34 CHtmlParserPlugin::NewL is for testing and can only be accessed by linking directly to XmlParser.o |
|
35 |
|
36 */ |
|
37 CHtmlParserPlugin* CHtmlParserPlugin::NewL( TAny* aInitParams ) |
|
38 { |
|
39 TParserInitParams* p = reinterpret_cast< TParserInitParams* >( aInitParams ); |
|
40 |
|
41 CHtmlParserPlugin* self = new( ELeave ) CHtmlParserPlugin( p->iContentHandler ); |
|
42 |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL ( p->iStringDictionaryCollection ); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 CHtmlParserPlugin::CHtmlParserPlugin( MContentHandler* aContentHandler ) : |
|
51 iContentHandler( *aContentHandler ) |
|
52 { |
|
53 } |
|
54 |
|
55 void CHtmlParserPlugin::ConstructL ( Xml::RStringDictionaryCollection* aStringDictionaryCollection ) |
|
56 { |
|
57 iHtmlParser = CHtmlParser::NewL ( iContentHandler, aStringDictionaryCollection->StringPool() ); |
|
58 } |
|
59 |
|
60 /* |
|
61 Used by framework to delete this object |
|
62 */ |
|
63 void CHtmlParserPlugin::Release() |
|
64 { |
|
65 delete this; |
|
66 } |
|
67 |
|
68 /* |
|
69 Private destructor - only accessible from Release method |
|
70 */ |
|
71 CHtmlParserPlugin::~CHtmlParserPlugin() |
|
72 { |
|
73 delete iHtmlParser; |
|
74 } |
|
75 |
|
76 TInt CHtmlParserPlugin::EnableFeature( TInt /* aParseMode */ ) |
|
77 { |
|
78 return ETrue; |
|
79 } |
|
80 |
|
81 TInt CHtmlParserPlugin::DisableFeature( TInt /* aParseMode */ ) |
|
82 { |
|
83 return ETrue; |
|
84 } |
|
85 |
|
86 TBool CHtmlParserPlugin::IsFeatureEnabled( TInt /* aParseMode */ ) const |
|
87 { |
|
88 return ETrue; |
|
89 } |
|
90 |
|
91 void CHtmlParserPlugin::SetContentSink( Xml::MContentHandler& aContentHandler ) |
|
92 { |
|
93 iHtmlParser->SetContentSink ( aContentHandler ); |
|
94 return; |
|
95 } |
|
96 |
|
97 void CHtmlParserPlugin::ParseChunkL( const TDesC8& aChunk ) |
|
98 { |
|
99 ParseChunkInPartsL ( aChunk ); |
|
100 } |
|
101 |
|
102 void CHtmlParserPlugin::ParseLastChunkL( const TDesC8& aFinalChunk ) |
|
103 { |
|
104 ParseChunkInPartsL ( aFinalChunk, ETrue ); |
|
105 return; |
|
106 } |
|
107 |
|
108 void CHtmlParserPlugin::ParseChunkInPartsL( const TDesC8& aChunk, TBool aLast /* = EFalse */ ) |
|
109 { |
|
110 if ( ( aChunk.Length () > 0 ) || aLast ) |
|
111 { |
|
112 iHtmlParser->ParseL ( aChunk, aLast ); |
|
113 } |
|
114 } |
|
115 |
|
116 |
|
117 const TInt KUidHtmlParserPlugin = 0x10272787; |
|
118 |
|
119 const TImplementationProxy ImplementationTable[] = { |
|
120 IMPLEMENTATION_PROXY_ENTRY( KUidHtmlParserPlugin, CHtmlParserPlugin::EcomNewL ) |
|
121 }; |
|
122 |
|
123 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
124 { |
|
125 |
|
126 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
127 |
|
128 return ImplementationTable; |
|
129 } |
|
130 |
|
131 #ifndef EKA2 |
|
132 GLDEF_C TInt E32Dll(TDllReason) |
|
133 { |
|
134 return KErrNone; |
|
135 } |
|
136 #endif |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |