Avoid potential negative array index access to cached text.
[LibreOffice.git] / writerfilter / source / dmapper / FFDataHandler.cxx
blob507327cf8333b1ffca2463c072c29fb51f071b56
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "FFDataHandler.hxx"
20 #include "TagLogger.hxx"
22 #include <ooxml/resourceids.hxx>
24 namespace writerfilter::dmapper {
26 /************************
27 * class: FFDataHandler *
28 ************************/
30 FFDataHandler::FFDataHandler() :
31 LoggedProperties("FFDataHandler"),
32 m_nCheckboxHeight(0),
33 m_bCheckboxAutoHeight(false),
34 m_nCheckboxChecked(-1),
35 m_nCheckboxDefault(-1),
36 m_nTextMaxLength(0)
41 FFDataHandler::~FFDataHandler()
46 bool FFDataHandler::getCheckboxChecked() const
48 if (m_nCheckboxChecked != -1)
49 return m_nCheckboxChecked;
50 else if (m_nCheckboxDefault != -1)
51 return m_nCheckboxDefault;
52 else
53 return false;
57 void FFDataHandler::lcl_sprm(Sprm & r_Sprm)
59 switch(r_Sprm.getId())
61 case NS_ooxml::LN_CT_FFData_name:
63 m_sName = r_Sprm.getValue()->getString();
65 break;
66 case NS_ooxml::LN_CT_FFData_helpText:
68 resolveSprm(r_Sprm);
70 break;
71 case NS_ooxml::LN_CT_FFData_statusText:
73 resolveSprm(r_Sprm);
75 break;
76 case NS_ooxml::LN_CT_FFData_entryMacro:
78 m_sEntryMacro = r_Sprm.getValue()->getString();
80 break;
81 case NS_ooxml::LN_CT_FFData_exitMacro:
83 m_sExitMacro = r_Sprm.getValue()->getString();
85 break;
86 case NS_ooxml::LN_CT_FFCheckBox_size:
88 m_nCheckboxHeight = r_Sprm.getValue()->getInt();
90 break;
91 case NS_ooxml::LN_CT_FFCheckBox_sizeAuto:
93 m_bCheckboxAutoHeight = r_Sprm.getValue()->getInt();
95 break;
96 case NS_ooxml::LN_CT_FFCheckBox_checked:
98 m_nCheckboxChecked = r_Sprm.getValue()->getInt();
100 break;
101 case NS_ooxml::LN_CT_FFCheckBox_default:
103 m_nCheckboxDefault = r_Sprm.getValue()->getInt();
105 break;
106 case NS_ooxml::LN_CT_FFData_checkBox:
108 resolveSprm(r_Sprm);
110 break;
111 case NS_ooxml::LN_CT_FFDDList_result:
113 m_sDropDownResult = r_Sprm.getValue()->getString();
115 break;
116 case NS_ooxml::LN_CT_FFDDList_listEntry:
118 m_DropDownEntries.push_back(r_Sprm.getValue()->getString());
120 break;
121 case NS_ooxml::LN_CT_FFData_ddList:
123 resolveSprm(r_Sprm);
125 break;
126 case NS_ooxml::LN_CT_FFTextInput_type:
128 m_sTextType = r_Sprm.getValue()->getString();
130 break;
131 case NS_ooxml::LN_CT_FFTextInput_default:
133 m_sTextDefault = r_Sprm.getValue()->getString();
135 break;
136 case NS_ooxml::LN_CT_FFTextInput_maxLength:
138 m_nTextMaxLength = r_Sprm.getValue()->getInt();
140 break;
141 case NS_ooxml::LN_CT_FFTextInput_format:
143 m_sTextFormat = r_Sprm.getValue()->getString();
145 break;
146 case NS_ooxml::LN_CT_FFData_textInput:
148 resolveSprm(r_Sprm);
150 break;
151 default:
152 #ifdef DBG_UTIL
153 TagLogger::getInstance().element("unhandled");
154 #endif
155 break;
159 void FFDataHandler::resolveSprm(Sprm & r_Sprm)
161 writerfilter::Reference<Properties>::Pointer_t pProperties = r_Sprm.getProps();
162 if( pProperties)
163 pProperties->resolve(*this);
166 void FFDataHandler::lcl_attribute(Id name, Value & val)
168 switch (name)
170 case NS_ooxml::LN_CT_FFHelpText_val:
172 m_sHelpText = val.getString();
174 break;
175 case NS_ooxml::LN_CT_FFStatusText_val:
177 m_sStatusText = val.getString();
179 break;
180 default:
181 #ifdef DBG_UTIL
182 TagLogger::getInstance().element("unhandled");
183 #endif
184 break;
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */