1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #include "FFDataHandler.hxx"
24 
25 #include <ooxml/resourceids.hxx>
26 #include "dmapperLoggers.hxx"
27 
28 namespace writerfilter {
29 namespace dmapper {
30 
31 /************************
32  * class: FFDataHandler *
33  ************************/
34 
FFDataHandler()35 FFDataHandler::FFDataHandler() :
36 LoggedProperties(dmapper_logger, "FFDataHandler"),
37 m_bEnabled(false),
38 m_bCalcOnExit(false),
39 m_nHelpTextType(0),
40 m_nStatusTextType(0),
41 m_nCheckboxHeight(0),
42 m_bCheckboxAutoHeight(false),
43 m_bCheckboxDefault(false),
44 m_bCheckboxChecked(false),
45 m_nTextType(0),
46 m_nTextMaxLength(0)
47 {
48 }
49 
50 
~FFDataHandler()51 FFDataHandler::~FFDataHandler()
52 {
53 }
54 
55 // member: FFDataHandler::name
setName(const rtl::OUString & r_sName)56 void FFDataHandler::setName(const rtl::OUString & r_sName)
57 {
58     m_sName = r_sName;
59 }
60 
getName() const61 const rtl::OUString & FFDataHandler::getName() const
62 {
63     return m_sName;
64 }
65 
66 // member: FFDataHandler::enabled
setEnabled(bool r_enabled)67 void FFDataHandler::setEnabled(bool r_enabled)
68 {
69     m_bEnabled = r_enabled;
70 }
71 
getEnabled() const72 bool FFDataHandler::getEnabled() const
73 {
74     return m_bEnabled;
75 }
76 
77 // member: FFDataHandler::calcOnExit
setCalcOnExit(bool r_calcOnExit)78 void FFDataHandler::setCalcOnExit(bool r_calcOnExit)
79 {
80     m_bCalcOnExit = r_calcOnExit;
81 }
82 
getCalcOnExit() const83 bool FFDataHandler::getCalcOnExit() const
84 {
85     return m_bCalcOnExit;
86 }
87 
88 // member: FFDataHandler::entryMacro
setEntryMacro(const rtl::OUString & r_sEntryMacro)89 void FFDataHandler::setEntryMacro(const rtl::OUString & r_sEntryMacro)
90 {
91     m_sEntryMacro = r_sEntryMacro;
92 }
93 
getEntryMacro() const94 const rtl::OUString & FFDataHandler::getEntryMacro() const
95 {
96     return m_sEntryMacro;
97 }
98 
99 // member: FFDataHandler::exitMacro
setExitMacro(const rtl::OUString & r_sExitMacro)100 void FFDataHandler::setExitMacro(const rtl::OUString & r_sExitMacro)
101 {
102     m_sExitMacro = r_sExitMacro;
103 }
104 
getExitMacro() const105 const rtl::OUString & FFDataHandler::getExitMacro() const
106 {
107     return m_sExitMacro;
108 }
109 
110 // member: FFDataHandler::helpTextType
setHelpTextType(sal_uInt32 r_helpTextType)111 void FFDataHandler::setHelpTextType(sal_uInt32 r_helpTextType)
112 {
113     m_nHelpTextType = r_helpTextType;
114 }
115 
getHelpTextType() const116 sal_uInt32 FFDataHandler::getHelpTextType() const
117 {
118     return m_nHelpTextType;
119 }
120 
121 // member: FFDataHandler::helpText
setHelpText(const rtl::OUString & r_sHelpText)122 void FFDataHandler::setHelpText(const rtl::OUString & r_sHelpText)
123 {
124     m_sHelpText = r_sHelpText;
125 }
126 
getHelpText() const127 const rtl::OUString & FFDataHandler::getHelpText() const
128 {
129     return m_sHelpText;
130 }
131 
132 // member: FFDataHandler::statusTextType
setStatusTextType(sal_uInt32 r_statusTextType)133 void FFDataHandler::setStatusTextType(sal_uInt32 r_statusTextType)
134 {
135     m_nStatusTextType = r_statusTextType;
136 }
137 
getStatusTextType() const138 sal_uInt32 FFDataHandler::getStatusTextType() const
139 {
140     return m_nStatusTextType;
141 }
142 
143 // member: FFDataHandler::statusText
setStatusText(const rtl::OUString & r_sStatusText)144 void FFDataHandler::setStatusText(const rtl::OUString & r_sStatusText)
145 {
146     m_sStatusText = r_sStatusText;
147 }
148 
getStatusText() const149 const rtl::OUString & FFDataHandler::getStatusText() const
150 {
151     return m_sStatusText;
152 }
153 
154 // member: FFDataHandler::checkboxHeight
setCheckboxHeight(sal_uInt32 r_checkboxHeight)155 void FFDataHandler::setCheckboxHeight(sal_uInt32 r_checkboxHeight)
156 {
157     m_nCheckboxHeight = r_checkboxHeight;
158 }
159 
getCheckboxHeight() const160 sal_uInt32 FFDataHandler::getCheckboxHeight() const
161 {
162     return m_nCheckboxHeight;
163 }
164 
165 // member: FFDataHandler::checkboxAutoHeight
setCheckboxAutoHeight(bool r_checkboxAutoHeight)166 void FFDataHandler::setCheckboxAutoHeight(bool r_checkboxAutoHeight)
167 {
168     m_bCheckboxAutoHeight = r_checkboxAutoHeight;
169 }
170 
getCheckboxAutoHeight() const171 bool FFDataHandler::getCheckboxAutoHeight() const
172 {
173     return m_bCheckboxAutoHeight;
174 }
175 
176 // member: FFDataHandler::checkboxDefault
setCheckboxDefault(bool r_checkboxDefault)177 void FFDataHandler::setCheckboxDefault(bool r_checkboxDefault)
178 {
179     m_bCheckboxDefault = r_checkboxDefault;
180 }
181 
getCheckboxDefault() const182 bool FFDataHandler::getCheckboxDefault() const
183 {
184     return m_bCheckboxDefault;
185 }
186 
187 // member: FFDataHandler::checkboxChecked
setCheckboxChecked(bool r_checkboxChecked)188 void FFDataHandler::setCheckboxChecked(bool r_checkboxChecked)
189 {
190     m_bCheckboxChecked = r_checkboxChecked;
191 }
192 
getCheckboxChecked() const193 bool FFDataHandler::getCheckboxChecked() const
194 {
195     return m_bCheckboxChecked;
196 }
197 
198 // member: FFDataHandler::dropDownResult
setDropDownResult(const rtl::OUString & r_sDropDownResult)199 void FFDataHandler::setDropDownResult(const rtl::OUString & r_sDropDownResult)
200 {
201     m_sDropDownResult = r_sDropDownResult;
202 }
203 
getDropDownResult() const204 const rtl::OUString & FFDataHandler::getDropDownResult() const
205 {
206     return m_sDropDownResult;
207 }
208 
209 // member: FFDataHandler::dropDownDefault
setDropDownDefault(const rtl::OUString & r_sDropDownDefault)210 void FFDataHandler::setDropDownDefault(const rtl::OUString & r_sDropDownDefault)
211 {
212     m_sDropDownDefault = r_sDropDownDefault;
213 }
214 
getDropDownDefault() const215 const rtl::OUString & FFDataHandler::getDropDownDefault() const
216 {
217     return m_sDropDownDefault;
218 }
219 
220 // member: FFDataHandler::dropDownEntries
setDropDownEntries(const FFDataHandler::DropDownEntries_t & r_dropDownEntries)221 void FFDataHandler::setDropDownEntries(const FFDataHandler::DropDownEntries_t & r_dropDownEntries)
222 {
223     m_DropDownEntries = r_dropDownEntries;
224 }
225 
getDropDownEntries() const226 const FFDataHandler::DropDownEntries_t & FFDataHandler::getDropDownEntries() const
227 {
228     return m_DropDownEntries;
229 }
230 
dropDownEntriesPushBack(const rtl::OUString & r_Element)231 void FFDataHandler::dropDownEntriesPushBack(const rtl::OUString & r_Element)
232 {
233     m_DropDownEntries.push_back(r_Element);
234 }
235 
236 // member: FFDataHandler::textType
setTextType(sal_uInt32 r_textType)237 void FFDataHandler::setTextType(sal_uInt32 r_textType)
238 {
239     m_nTextType = r_textType;
240 }
241 
getTextType() const242 sal_uInt32 FFDataHandler::getTextType() const
243 {
244     return m_nTextType;
245 }
246 
247 // member: FFDataHandler::textMaxLength
setTextMaxLength(sal_uInt32 r_textMaxLength)248 void FFDataHandler::setTextMaxLength(sal_uInt32 r_textMaxLength)
249 {
250     m_nTextMaxLength = r_textMaxLength;
251 }
252 
getTextMaxLength() const253 sal_uInt32 FFDataHandler::getTextMaxLength() const
254 {
255     return m_nTextMaxLength;
256 }
257 
258 // member: FFDataHandler::textDefault
setTextDefault(const rtl::OUString & r_sTextDefault)259 void FFDataHandler::setTextDefault(const rtl::OUString & r_sTextDefault)
260 {
261     m_sTextDefault = r_sTextDefault;
262 }
263 
getTextDefault() const264 const rtl::OUString & FFDataHandler::getTextDefault() const
265 {
266     return m_sTextDefault;
267 }
268 
269 // member: FFDataHandler::textFormat
setTextFormat(const rtl::OUString & r_sTextFormat)270 void FFDataHandler::setTextFormat(const rtl::OUString & r_sTextFormat)
271 {
272     m_sTextFormat = r_sTextFormat;
273 }
274 
getTextFormat() const275 const rtl::OUString & FFDataHandler::getTextFormat() const
276 {
277     return m_sTextFormat;
278 }
279 
280 
lcl_sprm(Sprm & r_Sprm)281 void FFDataHandler::lcl_sprm(Sprm & r_Sprm)
282 {
283     switch(r_Sprm.getId())
284     {
285     case NS_ooxml::LN_CT_FFData_name:
286     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
287         {
288             m_sName = r_Sprm.getValue()->getString();
289         }
290         break;
291     case NS_ooxml::LN_CT_FFData_enabled:
292     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
293         {
294             m_bEnabled = r_Sprm.getValue()->getInt();
295         }
296         break;
297     case NS_ooxml::LN_CT_FFData_calcOnExit:
298     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
299         {
300             m_bCalcOnExit = r_Sprm.getValue()->getInt();
301         }
302         break;
303     case NS_ooxml::LN_CT_FFData_entryMacro:
304     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
305         {
306             m_sEntryMacro = r_Sprm.getValue()->getString();
307         }
308         break;
309     case NS_ooxml::LN_CT_FFData_exitMacro:
310     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
311         {
312             m_sExitMacro = r_Sprm.getValue()->getString();
313         }
314         break;
315     case NS_ooxml::LN_CT_FFData_helpText:
316     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
317         {
318             resolveSprm(r_Sprm);
319         }
320         break;
321     case NS_ooxml::LN_CT_FFData_statusText:
322     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
323         {
324             resolveSprm(r_Sprm);
325         }
326         break;
327     case NS_ooxml::LN_CT_FFCheckBox_size:
328     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
329         {
330             m_nCheckboxHeight = r_Sprm.getValue()->getInt();
331         }
332         break;
333     case NS_ooxml::LN_CT_FFCheckBox_sizeAuto:
334     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
335         {
336             m_bCheckboxAutoHeight = r_Sprm.getValue()->getInt();
337         }
338         break;
339     case NS_ooxml::LN_CT_FFCheckBox_default:
340     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
341         {
342             m_bCheckboxDefault = r_Sprm.getValue()->getInt();
343         }
344         break;
345     case NS_ooxml::LN_CT_FFCheckBox_checked:
346     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
347         {
348             m_bCheckboxChecked = r_Sprm.getValue()->getInt();
349         }
350         break;
351     case NS_ooxml::LN_CT_FFData_checkBox:
352     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
353         {
354             resolveSprm(r_Sprm);
355         }
356         break;
357     case NS_ooxml::LN_CT_FFDDList_result:
358     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
359         {
360             m_sDropDownResult = r_Sprm.getValue()->getString();
361         }
362         break;
363     case NS_ooxml::LN_CT_FFDDList_default:
364     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
365         {
366             m_sDropDownDefault = r_Sprm.getValue()->getString();
367         }
368         break;
369     case NS_ooxml::LN_CT_FFDDList_listEntry:
370     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
371         {
372             m_DropDownEntries.push_back(r_Sprm.getValue()->getString());;
373         }
374         break;
375     case NS_ooxml::LN_CT_FFData_ddList:
376     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
377         {
378             resolveSprm(r_Sprm);
379         }
380         break;
381     case NS_ooxml::LN_CT_FFTextInput_type:
382     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
383         {
384             m_nTextType = r_Sprm.getValue()->getInt();
385         }
386         break;
387     case NS_ooxml::LN_CT_FFTextInput_default:
388     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
389         {
390             m_sTextDefault = r_Sprm.getValue()->getString();
391         }
392         break;
393     case NS_ooxml::LN_CT_FFTextInput_maxLength:
394     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
395         {
396             m_nTextMaxLength = r_Sprm.getValue()->getInt();
397         }
398         break;
399     case NS_ooxml::LN_CT_FFTextInput_format:
400     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
401         {
402             m_sTextFormat = r_Sprm.getValue()->getString();
403         }
404         break;
405     case NS_ooxml::LN_CT_FFData_textInput:
406     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
407         {
408             resolveSprm(r_Sprm);
409         }
410         break;
411     default:
412 #ifdef DEBUG_DOMAINMAPPER
413         dmapper_logger->element("FFDataHandler.unhandled");
414 #endif
415         break;
416     }
417 }
418 
resolveSprm(Sprm & r_Sprm)419 void FFDataHandler::resolveSprm(Sprm & r_Sprm)
420 {
421     writerfilter::Reference<Properties>::Pointer_t pProperties = r_Sprm.getProps();
422     if( pProperties.get())
423         pProperties->resolve(*this);
424 }
425 
lcl_attribute(Id name,Value & val)426 void FFDataHandler::lcl_attribute(Id name, Value & val)
427 {
428     switch (name)
429     {
430     case NS_ooxml::LN_CT_FFHelpText_type:
431     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
432         {
433             m_nHelpTextType = val.getInt();
434         }
435         break;
436     case NS_ooxml::LN_CT_FFHelpText_val:
437     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
438         {
439             m_sHelpText = val.getString();
440         }
441         break;
442     case NS_ooxml::LN_CT_FFStatusText_type:
443     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
444         {
445             m_nStatusTextType = val.getInt();
446         }
447         break;
448     case NS_ooxml::LN_CT_FFStatusText_val:
449     /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */
450         {
451             m_sStatusText = val.getString();
452         }
453         break;
454     default:
455 #ifdef DEBUG_DOMAINMAPPER
456         dmapper_logger->element("FFDataHandler.unhandled");
457 #endif
458         break;
459     }
460 }
461 
462 }}
463