|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Transaction element for publishing empty content |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "xntype.h" |
|
20 #include "xnnewsticker.h" |
|
21 #include "xnbitmap.h" |
|
22 #include "xntext.h" |
|
23 #include "xntexteditor.h" |
|
24 #include "emptycontenttransactionelement.h" |
|
25 #include "aixmluiconstants.h" |
|
26 #include "aixmluiutils.h" |
|
27 |
|
28 using namespace AiXmlUiController; |
|
29 using namespace XnImageInterface; |
|
30 using namespace XnTextInterface; |
|
31 using namespace AiUiDef::xml; |
|
32 |
|
33 const TInt KControlIndexOffset = 1; |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 CEmptyContentTransactionElement::CEmptyContentTransactionElement( |
|
38 AiUtility::CContentPriorityMap& aContentPriorityMap) |
|
39 : CTransactionElement( aContentPriorityMap ), |
|
40 iIndex( KErrNotFound ) |
|
41 { |
|
42 } |
|
43 |
|
44 CEmptyContentTransactionElement* CEmptyContentTransactionElement::NewL( |
|
45 AiUtility::CContentPriorityMap& aContentPriorityMap) |
|
46 { |
|
47 CEmptyContentTransactionElement* self = |
|
48 new( ELeave ) CEmptyContentTransactionElement( aContentPriorityMap ); |
|
49 return self; |
|
50 } |
|
51 |
|
52 CEmptyContentTransactionElement::~CEmptyContentTransactionElement() |
|
53 { |
|
54 } |
|
55 |
|
56 void CEmptyContentTransactionElement::InitializeL( CXnNodeAppIf& aTarget, TInt aIndex ) |
|
57 { |
|
58 SetTarget( aTarget ); |
|
59 |
|
60 // Indexes in XML theme run 1...n, but in control interface 0...n-1 |
|
61 iIndex = aIndex - KControlIndexOffset; |
|
62 } |
|
63 |
|
64 void CEmptyContentTransactionElement::Reset() |
|
65 { |
|
66 CTransactionElement::Reset(); |
|
67 iIndex = KErrNotFound; |
|
68 } |
|
69 |
|
70 void CEmptyContentTransactionElement::UpdateDataL() |
|
71 { |
|
72 CXnType* type = Target().Type(); |
|
73 |
|
74 if ( type->Type() == XnImageInterface::MXnImageInterface::Type() ) |
|
75 { |
|
76 MXnImageInterface* image( NULL ); |
|
77 XnComponentInterface::MakeInterfaceL( image, Target() ); |
|
78 |
|
79 LeaveIfNull( image, KErrNotSupported ); |
|
80 |
|
81 // Clears the bitmaps from component |
|
82 image->SetContentBitmaps( NULL, NULL ); |
|
83 } |
|
84 else if ( type->Type() == XnTextInterface::MXnTextInterface::Type() ) // text element |
|
85 { |
|
86 // Get control interface |
|
87 XnTextInterface::MXnTextInterface* text( NULL ); |
|
88 XnComponentInterface::MakeInterfaceL( text, Target() ); |
|
89 |
|
90 LeaveIfNull( text, KErrNotSupported ); |
|
91 |
|
92 // Clears the text from component |
|
93 text->SetTextL( KNullDesC ); |
|
94 } |
|
95 else if ( type->Type() == XnTextEditorInterface::MXnTextEditorInterface::Type() ) // texteditor element |
|
96 { |
|
97 // Get control interface |
|
98 XnTextEditorInterface::MXnTextEditorInterface* editor( NULL ); |
|
99 XnComponentInterface::MakeInterfaceL( editor, Target() ); |
|
100 |
|
101 LeaveIfNull( editor, KErrNotSupported ); |
|
102 |
|
103 // Clears the text from component |
|
104 editor->SetTextL( KNullDesC ); |
|
105 } |
|
106 else |
|
107 { |
|
108 CXnNodeAppIf* parent( Target().ParentL() ); |
|
109 LeaveIfNull( parent, KErrNotSupported ); |
|
110 |
|
111 const TDesC8& parentType( parent->Type()->Type() ); |
|
112 |
|
113 if ( parentType == XnNewstickerInterface::MXnNewstickerInterface::Type() ) |
|
114 { |
|
115 XnNewstickerInterface::MXnNewstickerInterface* newsticker( NULL ); |
|
116 XnComponentInterface::MakeInterfaceL( newsticker, *parent ); |
|
117 |
|
118 LeaveIfNull( newsticker, KErrNotSupported ); |
|
119 |
|
120 CXnProperty* prop( Target().GetPropertyL( |
|
121 XnPropertyNames::title::KTitleIndex ) ); |
|
122 |
|
123 LeaveIfNull( prop, KErrNotSupported ); |
|
124 |
|
125 TInt index( KErrNotFound ); |
|
126 |
|
127 TLex8 lex( prop->StringValue() ); |
|
128 lex.Val( index ); |
|
129 |
|
130 newsticker->DeleteTitle( index ); |
|
131 } |
|
132 } |
|
133 |
|
134 // Clear current content priority |
|
135 ClearContentPriorityL(); |
|
136 } |
|
137 |
|
138 // End of file |