|
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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "xnnodeappif.h" |
|
20 #include "xnuiengineappif.h" |
|
21 #include "xnproperty.h" |
|
22 |
|
23 #include "transactionelement.h" |
|
24 #include "xmluicontrollerpanic.h" |
|
25 #include "aixmluiutils.h" |
|
26 #include "aixmluiconstants.h" |
|
27 |
|
28 #include "contentprioritymap.h" |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 using namespace AiXmlUiController; |
|
33 using namespace AiUiDef::xml; |
|
34 |
|
35 /** |
|
36 * Template method implementation |
|
37 */ |
|
38 void MTransactionElement::CommitL( TBool& aLayoutChanged, RPropertyHashMap& aPropertyHashMap ) |
|
39 { |
|
40 // Update UI element data |
|
41 UpdateDataL(); |
|
42 |
|
43 // Update CSS properties |
|
44 ApplyPublishingPolicy( aLayoutChanged, aPropertyHashMap ); |
|
45 } |
|
46 |
|
47 CTransactionElement::CTransactionElement( AiUtility::CContentPriorityMap& aContentPriorityMap ) |
|
48 : iContentPriorityMap( aContentPriorityMap ), |
|
49 iContentPriority( KErrNotFound ) |
|
50 { |
|
51 } |
|
52 |
|
53 CTransactionElement::~CTransactionElement() |
|
54 { |
|
55 } |
|
56 |
|
57 void CTransactionElement::Reset() |
|
58 { |
|
59 iTarget = NULL; |
|
60 |
|
61 iContentPriority = KErrNotFound; |
|
62 |
|
63 iElementLink.Deque(); |
|
64 |
|
65 iPolicyArray.Reset(); |
|
66 } |
|
67 |
|
68 RAiPolicyElementArray& CTransactionElement::PolicyArray() |
|
69 { |
|
70 return iPolicyArray; |
|
71 } |
|
72 |
|
73 void CTransactionElement::SetContentPriority( TInt aPriority ) |
|
74 { |
|
75 iContentPriority = aPriority; |
|
76 } |
|
77 |
|
78 void CTransactionElement::SetCssPropertyMap( CCssPropertyMap* aPropertyMap ) |
|
79 { |
|
80 iPropertyMap = aPropertyMap; |
|
81 } |
|
82 |
|
83 void CTransactionElement::SetTarget(CXnNodeAppIf& aTarget) |
|
84 { |
|
85 __ASSERT_DEBUG( !iTarget, Panic( ETargetNodeNotNull ) ); |
|
86 iTarget = &aTarget; |
|
87 } |
|
88 |
|
89 void CTransactionElement::ApplyPublishingPolicy( TBool& aLayoutChanged, RPropertyHashMap& aPropertyHashMap ) |
|
90 { |
|
91 // Ignore errors if CSS property could not be modified |
|
92 TRAP_IGNORE( DoApplyPublishingPolicyL( aLayoutChanged, aPropertyHashMap ) ); |
|
93 } |
|
94 |
|
95 void CTransactionElement::DoApplyPublishingPolicyL( TBool& aLayoutChanged, RPropertyHashMap& aPropertyHashMap ) |
|
96 { |
|
97 RArray<CXnNodeAppIf*> targetArray; |
|
98 CleanupClosePushL( targetArray ); |
|
99 |
|
100 for ( TInt i = 0; i < iPolicyArray.Count() && iPropertyMap; ++i ) |
|
101 { |
|
102 TAiPolicyElement& element = iPolicyArray[ i ]; |
|
103 |
|
104 RArray<TAiPolicyElement> elementArray; |
|
105 CleanupClosePushL( elementArray ); |
|
106 |
|
107 TBool found = EFalse; |
|
108 for( TInt i2 = 0; i2 < targetArray.Count(); ++i2 ) |
|
109 { |
|
110 // find from target array |
|
111 if( targetArray[i2] == &(element.Target()) ) |
|
112 { |
|
113 found = ETrue; |
|
114 break; |
|
115 } |
|
116 } |
|
117 |
|
118 if( !found ) |
|
119 { |
|
120 // Mark this target to be processed |
|
121 targetArray.Append( &(element.Target()) ); |
|
122 |
|
123 for( TInt i3 = 0; i3 < iPolicyArray.Count(); ++i3 ) |
|
124 { |
|
125 TAiPolicyElement& element2 = iPolicyArray[ i3 ]; |
|
126 // find form target array |
|
127 if( &(element.Target()) == &(element2.Target()) ) |
|
128 { |
|
129 elementArray.Append( element2 ); |
|
130 } |
|
131 } |
|
132 |
|
133 SetPropertiesToHashMapL( elementArray, *iPropertyMap, aPropertyHashMap ); |
|
134 |
|
135 } |
|
136 |
|
137 CleanupStack::PopAndDestroy(); // elementArray |
|
138 |
|
139 /*SetPropertyL( element.Target(), |
|
140 element.Name(), |
|
141 element.Value(), |
|
142 *iPropertyMap );*/ |
|
143 } |
|
144 |
|
145 CleanupStack::PopAndDestroy(); // targetArray |
|
146 |
|
147 if ( iPolicyArray.Count() > 0 ) |
|
148 { |
|
149 aLayoutChanged |= ETrue; |
|
150 } |
|
151 } |
|
152 |
|
153 CXnNodeAppIf& CTransactionElement::Target() const |
|
154 { |
|
155 __ASSERT_DEBUG( iTarget, Panic( ETargetNodeNull ) ); |
|
156 return *iTarget; |
|
157 } |
|
158 |
|
159 void CTransactionElement::UpdateContentPriorityL() |
|
160 { |
|
161 if ( iTarget && iContentPriority > KErrNotFound ) // Clear must be done with ClearContentPriority |
|
162 { |
|
163 const TDesC8* uiElementId = LeaveIfNull( PropertyValue( |
|
164 *iTarget, |
|
165 XnPropertyNames::common::KId ), |
|
166 KErrGeneral ); |
|
167 |
|
168 User::LeaveIfError( iContentPriorityMap.SetCurrentPriority( |
|
169 *uiElementId, |
|
170 iContentPriority ) ); |
|
171 } |
|
172 } |
|
173 |
|
174 void CTransactionElement::ClearContentPriorityL() |
|
175 { |
|
176 if( iTarget ) |
|
177 { |
|
178 const TDesC8* uiElementId = LeaveIfNull( PropertyValue( |
|
179 *iTarget, |
|
180 XnPropertyNames::common::KId ), |
|
181 KErrGeneral ); |
|
182 |
|
183 iContentPriorityMap.ClearPriority( *uiElementId ); |
|
184 } |
|
185 } |
|
186 |
|
187 // End of File |