nss: upgrade to release 3.73
[LibreOffice.git] / xmloff / inc / txtvfldi.hxx
blob5cfca16c312b085293f7151d0330340f15275cb5
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 .
20 /** @#file
22 * XML import of all variable related text fields plus database display field
25 #ifndef INCLUDED_XMLOFF_INC_TXTVFLDI_HXX
26 #define INCLUDED_XMLOFF_INC_TXTVFLDI_HXX
28 #include "txtfldi.hxx"
29 #include <com/sun/star/beans/XPropertySet.hpp>
32 /** helper class: parses value-type and associated value attributes */
33 class XMLValueImportHelper final
35 SvXMLImport& rImport;
36 XMLTextImportHelper& rHelper;
38 OUString sValue; /// string value (only valid if bStringValueOK)
39 double fValue; /// double value (only valid if bFloatValueOK)
40 sal_Int32 nFormatKey; /// format key (only valid of bFormatOK)
41 OUString sFormula; /// formula string
42 OUString sDefault; /// default (see bStringDefault/bFormulaDef.)
43 bool bIsDefaultLanguage;/// format (of nFormatKey) has system language?
45 bool bStringType; /// is this a string (or a float) type?
46 bool bFormatOK; /// have we read a style:data-style-name attr.?
47 bool bStringValueOK; /// have we read a string-value attr.?
48 bool bFormulaOK; /// have we read the formula attribute?
50 const bool bSetType; /// should PrepareField set the SetExp subtype?
51 const bool bSetValue; /// should PrepareField set content/value?
52 const bool bSetStyle; /// should PrepareField set NumberFormat?
53 const bool bSetFormula; /// should PrepareField set Formula?
55 public:
56 XMLValueImportHelper(
57 SvXMLImport& rImprt, /// XML Import
58 XMLTextImportHelper& rHlp, /// text import helper
59 bool bType, /// process type (PrepareField)
60 bool bStyle, /// process data style (P.F.)
61 bool bValue, /// process value (Prep.Field)
62 bool bFormula); /// process formula (Prep.F.)
64 /// process attribute values
65 void ProcessAttribute( sal_Int32 nAttrToken,
66 const OUString& sAttrValue );
68 /// prepare XTextField for insertion into document
69 void PrepareField(
70 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet);
72 /// is value a string (rather than double)?
73 bool IsStringValue() const { return bStringType; }
75 /// has format been read?
76 bool IsFormatOK() const { return bFormatOK; }
78 void SetDefault(const OUString& sStr) { sDefault = sStr; }
82 /**
83 * abstract parent class for all variable related fields
84 * - variable-set/get/decl (not -decls),
85 * - user-field-get/decl (not -decls),
86 * - sequence/-decl (not -decls),
87 * - expression,
88 * - text-input
90 * Processes the following attributes:
91 * - name
92 * - formula
93 * - display
94 * - value, value-type, data-style-name (via XMLValueImportHelper)
95 * - description.
97 * Each attribute has a corresponding member, a bool variable to indicate
98 * whether it was set or not, and a bool variable whether it should be set
99 * using the standard property name.
101 * bValid is set true, when name is found!
102 * (Most variable related fields are valid, if a name is
103 * found. However, some are always valid. In this case, setting bValid
104 * does not matter.)
106 class XMLVarFieldImportContext : public XMLTextFieldImportContext
108 private:
109 OUString sName; /// name attribute
110 OUString sFormula; /// formula attribute
111 OUString sDescription; /// description
112 OUString sHelp; /// help text
113 OUString sHint; /// hint
114 XMLValueImportHelper aValueHelper; /// value, value-type, and style
115 bool bDisplayFormula; /// display formula?(rather than value)
116 bool bDisplayNone; /// hide field?
118 bool bFormulaOK; /// sFormula was set
119 bool bDescriptionOK; /// sDescription was set
120 bool bHelpOK; /// sHelp was set
121 bool bHintOK; /// sHint was set
122 bool bDisplayOK; /// sDisplayFormula/-None were set
124 bool bSetFormula; /// set Formula property
125 bool bSetFormulaDefault; /// use content as default for formula
126 bool bSetDescription; /// set sDescription with Hint-property
127 bool bSetHelp;
128 bool bSetHint;
129 bool bSetVisible; /// set IsVisible
130 bool bSetDisplayFormula; /// set DisplayFormula (sub type???)
131 bool bSetPresentation; /// set presentation frm elem. content?
133 public:
136 XMLVarFieldImportContext(
137 // for XMLTextFieldImportContext:
138 SvXMLImport& rImport, /// XML Import
139 XMLTextImportHelper& rHlp, /// text import helper
140 const char* pServiceName, /// name of SO API service
141 sal_uInt16 nPrfx, /// namespace prefix
142 const OUString& rLocalName, /// element name w/o prefix
143 // config variables for PrepareField behavior:
144 bool bFormula, /// set Formula property
145 bool bFormulaDefault, /// use content as default for formula
146 bool bDescription, /// set sDescription with Hint-property
147 bool bHelp,
148 bool bHint,
149 bool bVisible, /// set IsVisible (display attr)
150 bool bDisplayFormula, /// set ??? (display attr.)
151 bool bType, /// set value type with ???-property
152 bool bStyle, /// set data style (NumberFormat-Prop.)
153 bool bValue, /// set value with Content/Value-Prop.
154 bool bPresentation); /// set presentation from elem. content
156 protected:
157 /// process attribute values
158 virtual void ProcessAttribute( sal_Int32 nAttrToken,
159 const OUString& sAttrValue ) override;
161 /// prepare XTextField for insertion into document
162 virtual void PrepareField(
163 const css::uno::Reference<
164 css::beans::XPropertySet> & xPropertySet) override;
166 // various accessor methods:
167 const OUString& GetName() const { return sName; }
168 bool IsStringValue() const { return aValueHelper.IsStringValue();}
172 /** import variable get fields (<text:variable-get>) */
173 class XMLVariableGetFieldImportContext final : public XMLVarFieldImportContext
175 public:
178 XMLVariableGetFieldImportContext(
179 SvXMLImport& rImport, /// XML Import
180 XMLTextImportHelper& rHlp, /// Text import helper
181 sal_uInt16 nPrfx, /// namespace prefix
182 const OUString& rLocalName); /// element name w/o prefix
185 private:
186 /// prepare XTextField for insertion into document
187 virtual void PrepareField(
188 const css::uno::Reference<
189 css::beans::XPropertySet> & xPropertySet) override;
193 /** import expression fields (<text:expression>) */
194 class XMLExpressionFieldImportContext final : public XMLVarFieldImportContext
196 public:
198 XMLExpressionFieldImportContext(
199 SvXMLImport& rImport, /// XML Import
200 XMLTextImportHelper& rHlp, /// Text import helper
201 sal_uInt16 nPrfx, /// namespace prefix
202 const OUString& sLocalName); /// element name w/o prefix
204 private:
205 virtual void PrepareField(
206 const css::uno::Reference<
207 css::beans::XPropertySet> & xPropertySet) override;
210 /*** import text input fields (<text:text-input>) */
211 class XMLTextInputFieldImportContext final : public XMLVarFieldImportContext
213 public:
215 XMLTextInputFieldImportContext(
216 SvXMLImport& rImport, /// XML Import
217 XMLTextImportHelper& rHlp, /// Text import helper
218 sal_uInt16 nPrfx, /// namespace prefix
219 const OUString& sLocalName); /// element name w/o prefix
221 private:
222 virtual void PrepareField(
223 const css::uno::Reference<
224 css::beans::XPropertySet> & xPropertySet) override;
229 * upperclass for variable/user-set, var/user-input, and sequence fields
230 * inds field master of appropriate type and attaches field to it.
232 class XMLSetVarFieldImportContext : public XMLVarFieldImportContext
234 const VarType eFieldType;
236 public:
239 XMLSetVarFieldImportContext(
240 // for XMLTextFieldImportContext:
241 SvXMLImport& rImport, /// see XMLTextFieldImportContext
242 XMLTextImportHelper& rHlp, /// see XMLTextFieldImportContext
243 const char* pServiceName, /// see XMLTextFieldImportContext
244 sal_uInt16 nPrfx, /// see XMLTextFieldImportContext
245 const OUString& rLocalName, /// see XMLTextFieldImportContext
246 // for finding appropriate field master (see endFastElement())
247 VarType eVarType, /// variable type
248 // config variables:
249 bool bFormula, /// see XMLTextFieldImportContext
250 bool bFormulaDefault, /// see XMLTextFieldImportContext
251 bool bDescription, /// see XMLTextFieldImportContext
252 bool bHelp, /// see XMLTextFieldImportContext
253 bool bHint, /// see XMLTextFieldImportContext
254 bool bVisible, /// see XMLTextFieldImportContext
255 bool bDisplayFormula, /// see XMLTextFieldImportContext
256 bool bType, /// see XMLTextFieldImportContext
257 bool bStyle, /// see XMLTextFieldImportContext
258 bool bValue, /// see XMLTextFieldImportContext
259 bool bPresentation); /// see XMLTextFieldImportContext
261 protected:
263 /// create XTextField, attach master and insert into document;
264 /// also calls PrepareTextField
265 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
267 /// find appropriate field master
268 bool FindFieldMaster(
269 css::uno::Reference<
270 css::beans::XPropertySet> & xMaster);
274 /** import variable set fields (<text:variable-set>) */
275 class XMLVariableSetFieldImportContext final : public XMLSetVarFieldImportContext
277 public:
279 XMLVariableSetFieldImportContext(
280 SvXMLImport& rImport, /// XML Import
281 XMLTextImportHelper& rHlp, /// Text import helper
282 sal_uInt16 nPrfx, /// namespace prefix
283 const OUString& rLocalName); /// element name w/o prefix
285 private:
286 /// prepare XTextField for insertion into document
287 virtual void PrepareField(
288 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
292 /** variable input fields (<text:variable-input>) */
293 class XMLVariableInputFieldImportContext final : public XMLSetVarFieldImportContext
295 public:
298 XMLVariableInputFieldImportContext(
299 SvXMLImport& rImport, /// XML Import
300 XMLTextImportHelper& rHlp, /// Text import helper
301 sal_uInt16 nPrfx, /// namespace prefix
302 const OUString& rLocalName); /// element name w/o prefix
304 private:
306 /// prepare XTextField for insertion into document
307 virtual void PrepareField(
308 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
312 /** user fields (<text:user-field-get>) */
313 class XMLUserFieldImportContext final : public XMLSetVarFieldImportContext
316 public:
319 XMLUserFieldImportContext(
320 SvXMLImport& rImport, /// XML Import
321 XMLTextImportHelper& rHlp, /// Text import helper
322 sal_uInt16 nPrfx, /// namespace prefix
323 const OUString& rLocalName); /// element name w/o prefix
326 /** user input fields (<text:user-field-input>) */
327 class XMLUserFieldInputImportContext final : public XMLVarFieldImportContext
330 public:
333 XMLUserFieldInputImportContext(
334 SvXMLImport& rImport, /// XML Import
335 XMLTextImportHelper& rHlp, /// Text import helper
336 sal_uInt16 nPrfx, /// namespace prefix
337 const OUString& rLocalName); /// element name w/o prefix
339 virtual void PrepareField(
340 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
344 /** sequence fields (<text:sequence>) */
345 class XMLSequenceFieldImportContext final : public XMLSetVarFieldImportContext
347 OUString sNumFormat;
348 OUString sNumFormatSync;
349 OUString sRefName;
351 bool bRefNameOK;
353 public:
356 XMLSequenceFieldImportContext(
357 SvXMLImport& rImport, /// XML Import
358 XMLTextImportHelper& rHlp, /// Text import helper
359 sal_uInt16 nPrfx, /// namespace prefix
360 const OUString& rLocalName); /// element name w/o prefix
362 private:
364 /// process attribute values
365 virtual void ProcessAttribute( sal_Int32 nAttrToken,
366 const OUString& sAttrValue ) override;
368 /// prepare XTextField for insertion into document
369 virtual void PrepareField(
370 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
375 * variable declaration container for all variable fields
376 * (variable-decls, user-field-decls, sequence-decls)
378 class XMLVariableDeclsImportContext final : public SvXMLImportContext
380 enum VarType eVarDeclsContextType;
381 XMLTextImportHelper& rImportHelper;
383 public:
386 XMLVariableDeclsImportContext(
387 SvXMLImport& rImport, /// XML Import
388 XMLTextImportHelper& rHlp, /// text import helper
389 sal_uInt16 nPrfx, /// namespace prefix
390 const OUString& rLocalName, /// element name w/o prefix
391 enum VarType eVarType); /// variable type
393 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
394 sal_Int32 nElement,
395 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
399 * variable field declarations
400 * (variable-decl, user-field-decl, sequence-decl)
402 class XMLVariableDeclImportContext final : public SvXMLImportContext
404 public:
407 XMLVariableDeclImportContext(
408 SvXMLImport& rImport, /// XML Import
409 XMLTextImportHelper& rHlp, /// text import helper
410 sal_Int32 nElement,
411 const css::uno::Reference< css::xml::sax::XFastAttributeList> & xAttrList,/// list of element attributes
412 enum VarType eVarType); /// variable type
414 /// get field master for name and rename if appropriate
415 static bool FindFieldMaster(css::uno::Reference<css::beans::XPropertySet> & xMaster,
416 SvXMLImport& rImport,
417 XMLTextImportHelper& rHelper,
418 const OUString& sVarName,
419 enum VarType eVarType);
423 /** import table formula fields (deprecated; for Writer 2.0 compatibility) */
424 class XMLTableFormulaImportContext final : public XMLTextFieldImportContext
426 XMLValueImportHelper aValueHelper;
428 bool bIsShowFormula;
430 public:
432 XMLTableFormulaImportContext(
433 SvXMLImport& rImport, /// XML Import
434 XMLTextImportHelper& rHlp, /// text import helper
435 sal_uInt16 nPrfx, /// namespace prefix
436 const OUString& rLocalName); /// element name w/o prefix
438 private:
440 /// process attribute values
441 virtual void ProcessAttribute( sal_Int32 nAttrToken,
442 const OUString& sAttrValue ) override;
444 /// prepare XTextField for insertion into document
445 virtual void PrepareField(
446 const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
450 /** import database display fields (<text:database-display>) */
451 class XMLDatabaseDisplayImportContext final : public XMLDatabaseFieldImportContext
453 XMLValueImportHelper aValueHelper;
455 OUString sColumnName;
456 bool bColumnOK;
458 bool bDisplay;
459 bool bDisplayOK;
461 public:
464 XMLDatabaseDisplayImportContext(
465 SvXMLImport& rImport, /// XML Import
466 XMLTextImportHelper& rHlp, /// text import helper
467 sal_uInt16 nPrfx, /// namespace prefix
468 const OUString& rLocalName); /// element name w/o prefix
470 private:
472 /// process attribute values
473 virtual void ProcessAttribute( sal_Int32 nAttrToken,
474 const OUString& sAttrValue ) override;
476 /// create, prepare and insert database field master and database field
477 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
480 #endif
482 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */