|
1 /* |
|
2 * Copyright (c) 2010 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 #include "CNPSearchDocument.h" |
|
18 |
|
19 #include "CNPDocumentFieldInterface.h" |
|
20 #include "CNPDocumentField.h" |
|
21 #include <CSearchDocument.h> |
|
22 |
|
23 CNPSearchDocument *CNPSearchDocument::NewL( CSearchDocument* aDocument ) |
|
24 { |
|
25 CNPSearchDocument* self = new (ELeave)CNPSearchDocument( aDocument ); |
|
26 CleanupStack::PushL(self); |
|
27 self->ConstructL(); |
|
28 CleanupStack::Pop(); // self; |
|
29 return self; |
|
30 } |
|
31 |
|
32 CNPSearchDocument::~CNPSearchDocument() |
|
33 { |
|
34 delete iDocument; |
|
35 } |
|
36 |
|
37 CNPSearchDocument::CNPSearchDocument( CSearchDocument* aDocument ) |
|
38 : iDocument( aDocument ) |
|
39 { |
|
40 } |
|
41 |
|
42 void CNPSearchDocument::Deallocate() |
|
43 { |
|
44 // NP Environment no more refers us directly. Still, there might |
|
45 // references to fields left |
|
46 Release(); |
|
47 } |
|
48 |
|
49 void CNPSearchDocument::ConstructL() |
|
50 { |
|
51 InitInterfaceL(); |
|
52 Retain(); // Add one reference for the references held by NP enviroment |
|
53 } |
|
54 |
|
55 void CNPSearchDocument::Retain() |
|
56 { |
|
57 iReferences++; |
|
58 } |
|
59 |
|
60 void CNPSearchDocument::Release() |
|
61 { |
|
62 if ( --iReferences == 0 ) |
|
63 { |
|
64 delete this; |
|
65 } |
|
66 } |
|
67 |
|
68 NPDocumentFieldObject* CNPSearchDocument::FieldL(const TDesC& aName) |
|
69 { |
|
70 const CDocumentField* field = iDocument->Field( aName ); |
|
71 |
|
72 if ( field ) |
|
73 { |
|
74 NPDocumentFieldObject *object = |
|
75 ( NPDocumentFieldObject * ) NPN_CreateObject( iInstanceHandle, NPDocumentFieldClass ); |
|
76 object->plugin = CNPDocumentField::NewL( *this, *field ); |
|
77 return object; |
|
78 } |
|
79 |
|
80 return NULL; |
|
81 } |
|
82 |
|
83 const TDesC& CNPSearchDocument::Id() const |
|
84 { |
|
85 return iDocument->Id(); |
|
86 } |
|
87 |
|
88 const TDesC& CNPSearchDocument::AppClass() const |
|
89 { |
|
90 return iDocument->AppClass(); |
|
91 } |
|
92 |
|
93 const TDesC& CNPSearchDocument::Excerpt() const |
|
94 { |
|
95 return iDocument->Excerpt(); |
|
96 } |
|
97 |
|
98 TInt CNPSearchDocument::FieldCount() const |
|
99 { |
|
100 return iDocument->FieldCount(); |
|
101 } |
|
102 |
|
103 NPDocumentFieldObject* CNPSearchDocument::FieldL( const TInt aIndex ) |
|
104 { |
|
105 if ( aIndex >= 0 && aIndex < iDocument->FieldCount() ) |
|
106 { |
|
107 const CDocumentField& field = iDocument->Field( aIndex ); |
|
108 |
|
109 NPDocumentFieldObject *object = |
|
110 ( NPDocumentFieldObject * ) NPN_CreateObject( iInstanceHandle, NPDocumentFieldClass ); |
|
111 object->plugin = CNPDocumentField::NewL( *this, field ); |
|
112 return object; |
|
113 } |
|
114 return NULL; |
|
115 } |