1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*63bba73cSAndrew Rist * distributed with this work for additional information
6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at
10*63bba73cSAndrew Rist *
11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist *
13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the
17*63bba73cSAndrew Rist * specific language governing permissions and limitations
18*63bba73cSAndrew Rist * under the License.
19*63bba73cSAndrew Rist *
20*63bba73cSAndrew Rist *************************************************************/
21*63bba73cSAndrew Rist
22*63bba73cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir /** @#file
28cdf0e10cSrcweir *
29cdf0e10cSrcweir * export of all variable related text fields (and database display field)
30cdf0e10cSrcweir */
31cdf0e10cSrcweir #include "txtvfldi.hxx"
32cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
33cdf0e10cSrcweir #include <xmloff/txtimp.hxx>
34cdf0e10cSrcweir #include <xmloff/xmlnumi.hxx>
35cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
36cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
37cdf0e10cSrcweir #include "xmloff/i18nmap.hxx"
38cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
39cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
40cdf0e10cSrcweir #include <xmloff/xmlement.hxx>
41cdf0e10cSrcweir #include <com/sun/star/text/SetVariableType.hpp>
42cdf0e10cSrcweir #include <com/sun/star/text/XTextField.hpp>
43cdf0e10cSrcweir #include <com/sun/star/text/XDependentTextField.hpp>
44cdf0e10cSrcweir #include <com/sun/star/text/XTextFieldsSupplier.hpp>
45cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
46cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
47cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp>
49cdf0e10cSrcweir
50cdf0e10cSrcweir #ifndef _RTL_USTRING
51cdf0e10cSrcweir #include <rtl/ustring.hxx>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #include <tools/debug.hxx>
54cdf0e10cSrcweir
55cdf0e10cSrcweir
56cdf0e10cSrcweir // service names
57cdf0e10cSrcweir static const sal_Char sAPI_textfield_prefix[] = "com.sun.star.text.TextField.";
58cdf0e10cSrcweir static const sal_Char sAPI_fieldmaster_prefix[] = "com.sun.star.text.FieldMaster.";
59cdf0e10cSrcweir static const sal_Char sAPI_input[] = "Input";
60cdf0e10cSrcweir static const sal_Char sAPI_input_user[] = "InputUser";
61cdf0e10cSrcweir static const sal_Char sAPI_get_expression[] = "GetExpression";
62cdf0e10cSrcweir static const sal_Char sAPI_set_expression[] = "SetExpression";
63cdf0e10cSrcweir static const sal_Char sAPI_user[] = "User";
64cdf0e10cSrcweir static const sal_Char sAPI_table_formula[] = "TableFormula";
65cdf0e10cSrcweir static const sal_Char sAPI_database[] = "com.sun.star.text.TextField.Database";
66cdf0e10cSrcweir static const sal_Char sAPI_fieldmaster_database[] = "com.sun.star.text.FieldMaster.Database";
67cdf0e10cSrcweir
68cdf0e10cSrcweir // property names
69cdf0e10cSrcweir static const sal_Char sAPI_hint[] = "Hint";
70cdf0e10cSrcweir static const sal_Char sAPI_help[] = "Help";
71cdf0e10cSrcweir static const sal_Char sAPI_tooltip[] = "Tooltip";
72cdf0e10cSrcweir static const sal_Char sAPI_content[] = "Content";
73cdf0e10cSrcweir static const sal_Char sAPI_sub_type[] = "SubType";
74cdf0e10cSrcweir static const sal_Char sAPI_is_expression[] = "IsExpression";
75cdf0e10cSrcweir static const sal_Char sAPI_is_input[] = "Input";
76cdf0e10cSrcweir static const sal_Char sAPI_is_show_formula[] = "IsShowFormula";
77cdf0e10cSrcweir static const sal_Char sAPI_numbering_type[] = "NumberingType";
78cdf0e10cSrcweir static const sal_Char sAPI_number_format[] = "NumberFormat";
79cdf0e10cSrcweir static const sal_Char sAPI_name[] = "Name";
80cdf0e10cSrcweir static const sal_Char sAPI_numbering_separator[] = "NumberingSeparator";
81cdf0e10cSrcweir static const sal_Char sAPI_chapter_numbering_level[]= "ChapterNumberingLevel";
82cdf0e10cSrcweir static const sal_Char sAPI_value[] = "Value";
83cdf0e10cSrcweir static const sal_Char sAPI_is_visible[] = "IsVisible";
84cdf0e10cSrcweir static const sal_Char sAPI_variable_subtype[] = "VariableSubtype";
85cdf0e10cSrcweir static const sal_Char sAPI_data_column_name[] = "DataColumnName";
86cdf0e10cSrcweir static const sal_Char sAPI_is_data_base_format[] = "DataBaseFormat";
87cdf0e10cSrcweir static const sal_Char sAPI_current_presentation[] = "CurrentPresentation";
88cdf0e10cSrcweir static const sal_Char sAPI_sequence_value[] = "SequenceValue";
89cdf0e10cSrcweir static const sal_Char sAPI_is_fixed_language[] = "IsFixedLanguage";
90cdf0e10cSrcweir
91cdf0e10cSrcweir
92cdf0e10cSrcweir using ::rtl::OUString;
93cdf0e10cSrcweir using ::rtl::OUStringBuffer;
94cdf0e10cSrcweir
95cdf0e10cSrcweir using namespace ::com::sun::star;
96cdf0e10cSrcweir using namespace ::com::sun::star::uno;
97cdf0e10cSrcweir using namespace ::com::sun::star::beans;
98cdf0e10cSrcweir using namespace ::com::sun::star::text;
99cdf0e10cSrcweir using namespace ::com::sun::star::style;
100cdf0e10cSrcweir using namespace ::xmloff::token;
101cdf0e10cSrcweir
102cdf0e10cSrcweir
103cdf0e10cSrcweir
104cdf0e10cSrcweir //
105cdf0e10cSrcweir // XMLVarFieldImportContext: superclass for all variable related fields
106cdf0e10cSrcweir //
107cdf0e10cSrcweir
108cdf0e10cSrcweir TYPEINIT1( XMLVarFieldImportContext, XMLTextFieldImportContext );
109cdf0e10cSrcweir
XMLVarFieldImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,const sal_Char * pServiceName,sal_uInt16 nPrfx,const OUString & rLocalName,sal_Bool bName,sal_Bool bFormula,sal_Bool bFormulaDefault,sal_Bool bDescription,sal_Bool bHelp,sal_Bool bHint,sal_Bool bVisible,sal_Bool bIsDisplayFormula,sal_Bool bType,sal_Bool bStyle,sal_Bool bValue,sal_Bool bPresentation)110cdf0e10cSrcweir XMLVarFieldImportContext::XMLVarFieldImportContext(
111cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp,
112cdf0e10cSrcweir const sal_Char* pServiceName, sal_uInt16 nPrfx,
113cdf0e10cSrcweir const OUString& rLocalName,
114cdf0e10cSrcweir sal_Bool bName, sal_Bool bFormula, sal_Bool bFormulaDefault,
115cdf0e10cSrcweir sal_Bool bDescription, sal_Bool bHelp, sal_Bool bHint, sal_Bool bVisible,
116cdf0e10cSrcweir sal_Bool bIsDisplayFormula,
117cdf0e10cSrcweir sal_Bool bType, sal_Bool bStyle, sal_Bool bValue,
118cdf0e10cSrcweir sal_Bool bPresentation) :
119cdf0e10cSrcweir XMLTextFieldImportContext(rImport, rHlp, pServiceName, nPrfx, rLocalName),
120cdf0e10cSrcweir sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content)),
121cdf0e10cSrcweir sPropertyHint(RTL_CONSTASCII_USTRINGPARAM(sAPI_hint)),
122cdf0e10cSrcweir sPropertyHelp(RTL_CONSTASCII_USTRINGPARAM(sAPI_help)),
123cdf0e10cSrcweir sPropertyTooltip(RTL_CONSTASCII_USTRINGPARAM(sAPI_tooltip)),
124cdf0e10cSrcweir sPropertyIsVisible(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_visible)),
125cdf0e10cSrcweir sPropertyIsDisplayFormula(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_show_formula)),
126cdf0e10cSrcweir sPropertyCurrentPresentation(RTL_CONSTASCII_USTRINGPARAM(sAPI_current_presentation)),
127cdf0e10cSrcweir aValueHelper(rImport, rHlp, bType, bStyle, bValue, sal_False),
128cdf0e10cSrcweir bDisplayFormula(sal_False),
129cdf0e10cSrcweir bDisplayNone(sal_False),
130cdf0e10cSrcweir bNameOK(sal_False),
131cdf0e10cSrcweir bFormulaOK(sal_False),
132cdf0e10cSrcweir bDescriptionOK(sal_False),
133cdf0e10cSrcweir bHelpOK(sal_False),
134cdf0e10cSrcweir bHintOK(sal_False),
135cdf0e10cSrcweir bDisplayOK(sal_False),
136cdf0e10cSrcweir bSetName(bName),
137cdf0e10cSrcweir bSetFormula(bFormula),
138cdf0e10cSrcweir bSetFormulaDefault(bFormulaDefault),
139cdf0e10cSrcweir bSetDescription(bDescription),
140cdf0e10cSrcweir bSetHelp(bHelp),
141cdf0e10cSrcweir bSetHint(bHint),
142cdf0e10cSrcweir bSetVisible(bVisible),
143cdf0e10cSrcweir bSetDisplayFormula(bIsDisplayFormula),
144cdf0e10cSrcweir bSetPresentation(bPresentation)
145cdf0e10cSrcweir {
146cdf0e10cSrcweir }
147cdf0e10cSrcweir
ProcessAttribute(sal_uInt16 nAttrToken,const OUString & sAttrValue)148cdf0e10cSrcweir void XMLVarFieldImportContext::ProcessAttribute(
149cdf0e10cSrcweir sal_uInt16 nAttrToken,
150cdf0e10cSrcweir const OUString& sAttrValue )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir switch (nAttrToken)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir case XML_TOK_TEXTFIELD_NAME:
155cdf0e10cSrcweir sName = sAttrValue;
156cdf0e10cSrcweir bNameOK = sal_True;
157cdf0e10cSrcweir bValid = sal_True; // we assume: field with name is valid!
158cdf0e10cSrcweir break;
159cdf0e10cSrcweir case XML_TOK_TEXTFIELD_DESCRIPTION:
160cdf0e10cSrcweir sDescription = sAttrValue;
161cdf0e10cSrcweir bDescriptionOK = sal_True;
162cdf0e10cSrcweir break;
163cdf0e10cSrcweir case XML_TOK_TEXTFIELD_HELP:
164cdf0e10cSrcweir sHelp = sAttrValue;
165cdf0e10cSrcweir bHelpOK = true;
166cdf0e10cSrcweir break;
167cdf0e10cSrcweir case XML_TOK_TEXTFIELD_HINT:
168cdf0e10cSrcweir sHint = sAttrValue;
169cdf0e10cSrcweir bHintOK = true;
170cdf0e10cSrcweir break;
171cdf0e10cSrcweir case XML_TOK_TEXTFIELD_FORMULA:
172cdf0e10cSrcweir {
173cdf0e10cSrcweir OUString sTmp;
174cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
175cdf0e10cSrcweir _GetKeyByAttrName( sAttrValue, &sTmp, sal_False );
176cdf0e10cSrcweir if( XML_NAMESPACE_OOOW == nPrefix )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir sFormula = sTmp;
179cdf0e10cSrcweir bFormulaOK = sal_True;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir else
182cdf0e10cSrcweir sFormula = sAttrValue;
183cdf0e10cSrcweir }
184cdf0e10cSrcweir break;
185cdf0e10cSrcweir case XML_TOK_TEXTFIELD_DISPLAY:
186cdf0e10cSrcweir if (IsXMLToken(sAttrValue, XML_FORMULA))
187cdf0e10cSrcweir {
188cdf0e10cSrcweir bDisplayFormula = sal_True;
189cdf0e10cSrcweir bDisplayNone = sal_False;
190cdf0e10cSrcweir bDisplayOK = sal_True;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir else if (IsXMLToken(sAttrValue, XML_VALUE))
193cdf0e10cSrcweir {
194cdf0e10cSrcweir bDisplayFormula = sal_False;
195cdf0e10cSrcweir bDisplayNone = sal_False;
196cdf0e10cSrcweir bDisplayOK = sal_True;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir else if (IsXMLToken(sAttrValue, XML_NONE))
199cdf0e10cSrcweir {
200cdf0e10cSrcweir bDisplayFormula = sal_False;
201cdf0e10cSrcweir bDisplayNone = sal_True;
202cdf0e10cSrcweir bDisplayOK = sal_True;
203cdf0e10cSrcweir } // else: no change
204cdf0e10cSrcweir DBG_ASSERT(!(bDisplayFormula && bDisplayNone),
205cdf0e10cSrcweir "illegal display values");
206cdf0e10cSrcweir break;
207cdf0e10cSrcweir default:
208cdf0e10cSrcweir // delegate all others to value helper
209cdf0e10cSrcweir aValueHelper.ProcessAttribute(nAttrToken, sAttrValue);
210cdf0e10cSrcweir break;
211cdf0e10cSrcweir }
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
PrepareField(const Reference<XPropertySet> & xPropertySet)214cdf0e10cSrcweir void XMLVarFieldImportContext::PrepareField(
215cdf0e10cSrcweir const Reference<XPropertySet> & xPropertySet)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir // bSetName: not implemented
218cdf0e10cSrcweir
219cdf0e10cSrcweir if (bSetFormula)
220cdf0e10cSrcweir {
221cdf0e10cSrcweir if (!bFormulaOK && bSetFormulaDefault)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir sFormula = GetContent();
224cdf0e10cSrcweir bFormulaOK = sal_True;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
227cdf0e10cSrcweir if (bFormulaOK)
228cdf0e10cSrcweir {
229cdf0e10cSrcweir Any aAny;
230cdf0e10cSrcweir aAny <<= sFormula;
231cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyContent, aAny);
232cdf0e10cSrcweir }
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
235cdf0e10cSrcweir if (bSetDescription && bDescriptionOK)
236cdf0e10cSrcweir {
237cdf0e10cSrcweir Any aAny;
238cdf0e10cSrcweir aAny <<= sDescription;
239cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyHint, aAny);
240cdf0e10cSrcweir }
241cdf0e10cSrcweir
242cdf0e10cSrcweir if (bSetHelp && bHelpOK)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir Any aAny;
245cdf0e10cSrcweir aAny <<= sHelp;
246cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyHelp, aAny);
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
249cdf0e10cSrcweir if (bSetHint && bHintOK)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir Any aAny;
252cdf0e10cSrcweir aAny <<= sHint;
253cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyTooltip, aAny);
254cdf0e10cSrcweir }
255cdf0e10cSrcweir
256cdf0e10cSrcweir if (bSetVisible && bDisplayOK)
257cdf0e10cSrcweir {
258cdf0e10cSrcweir Any aAny;
259cdf0e10cSrcweir sal_Bool bTmp = ! (bDisplayNone && bDisplayOK);
260cdf0e10cSrcweir aAny.setValue( &bTmp, ::getBooleanCppuType());
261cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyIsVisible, aAny);
262cdf0e10cSrcweir }
263cdf0e10cSrcweir
264cdf0e10cSrcweir // workaround for #no-bug#: display formula by default
265cdf0e10cSrcweir if (xPropertySet->getPropertySetInfo()->
266cdf0e10cSrcweir hasPropertyByName(sPropertyIsDisplayFormula) &&
267cdf0e10cSrcweir !bSetDisplayFormula)
268cdf0e10cSrcweir {
269cdf0e10cSrcweir bDisplayFormula = sal_False;
270cdf0e10cSrcweir bSetDisplayFormula = sal_True;
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
273cdf0e10cSrcweir
274cdf0e10cSrcweir if (bSetDisplayFormula)
275cdf0e10cSrcweir {
276cdf0e10cSrcweir Any aAny;
277cdf0e10cSrcweir sal_Bool bTmp = bDisplayFormula && bDisplayOK;
278cdf0e10cSrcweir aAny.setValue( &bTmp, ::getBooleanCppuType());
279cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyIsDisplayFormula, aAny);
280cdf0e10cSrcweir }
281cdf0e10cSrcweir
282cdf0e10cSrcweir // delegate to value helper
283cdf0e10cSrcweir aValueHelper.SetDefault(GetContent());
284cdf0e10cSrcweir aValueHelper.PrepareField(xPropertySet);
285cdf0e10cSrcweir
286cdf0e10cSrcweir // finally, set the curren presentation
287cdf0e10cSrcweir if (bSetPresentation)
288cdf0e10cSrcweir {
289cdf0e10cSrcweir Any aAny;
290cdf0e10cSrcweir aAny <<= GetContent();
291cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyCurrentPresentation, aAny);
292cdf0e10cSrcweir }
293cdf0e10cSrcweir }
294cdf0e10cSrcweir
295cdf0e10cSrcweir
296cdf0e10cSrcweir
297cdf0e10cSrcweir
298cdf0e10cSrcweir
299cdf0e10cSrcweir //
300cdf0e10cSrcweir // variable set fields
301cdf0e10cSrcweir //
302cdf0e10cSrcweir
303cdf0e10cSrcweir TYPEINIT1( XMLSetVarFieldImportContext, XMLVarFieldImportContext );
304cdf0e10cSrcweir
XMLSetVarFieldImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,const sal_Char * pServiceName,sal_uInt16 nPrfx,const OUString & rLocalName,VarType eVarType,sal_Bool bName,sal_Bool bFormula,sal_Bool bFormulaDefault,sal_Bool bDescription,sal_Bool bHelp,sal_Bool bHint,sal_Bool bVisible,sal_Bool bIsDisplayFormula,sal_Bool bType,sal_Bool bStyle,sal_Bool bValue,sal_Bool bPresentation)305cdf0e10cSrcweir XMLSetVarFieldImportContext::XMLSetVarFieldImportContext(
306cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp,
307cdf0e10cSrcweir const sal_Char* pServiceName, sal_uInt16 nPrfx,
308cdf0e10cSrcweir const OUString& rLocalName, VarType eVarType,
309cdf0e10cSrcweir sal_Bool bName, sal_Bool bFormula, sal_Bool bFormulaDefault,
310cdf0e10cSrcweir sal_Bool bDescription, sal_Bool bHelp, sal_Bool bHint, sal_Bool bVisible, sal_Bool bIsDisplayFormula,
311cdf0e10cSrcweir sal_Bool bType, sal_Bool bStyle, sal_Bool bValue, sal_Bool bPresentation) :
312cdf0e10cSrcweir XMLVarFieldImportContext(rImport, rHlp, pServiceName,
313cdf0e10cSrcweir nPrfx, rLocalName,
314cdf0e10cSrcweir bName, bFormula, bFormulaDefault,
315cdf0e10cSrcweir bDescription, bHelp, bHint, bVisible, bIsDisplayFormula,
316cdf0e10cSrcweir bType, bStyle, bValue, bPresentation),
317cdf0e10cSrcweir eFieldType(eVarType)
318cdf0e10cSrcweir {
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
EndElement()321cdf0e10cSrcweir void XMLSetVarFieldImportContext::EndElement()
322cdf0e10cSrcweir {
323cdf0e10cSrcweir // should we call PrepareField on the field, or rather on it's master?
324cdf0e10cSrcweir // currently: call on field (just like superclass)
325cdf0e10cSrcweir // possible alternatives: call on master
326cdf0e10cSrcweir // call field or master depending on variable
327cdf0e10cSrcweir // PrepareMaster() in addition to PrepareField()
328cdf0e10cSrcweir
329cdf0e10cSrcweir DBG_ASSERT(GetServiceName().getLength()>0, "no service name for element!");
330cdf0e10cSrcweir
331cdf0e10cSrcweir if (bValid)
332cdf0e10cSrcweir {
333cdf0e10cSrcweir DBG_ASSERT(GetName().getLength()>0, "variable name needed!");
334cdf0e10cSrcweir
335cdf0e10cSrcweir // find field master
336cdf0e10cSrcweir Reference<XPropertySet> xMaster;
337cdf0e10cSrcweir if (FindFieldMaster(xMaster))
338cdf0e10cSrcweir {
339cdf0e10cSrcweir // create field/Service
340cdf0e10cSrcweir Reference<XPropertySet> xPropSet;
341cdf0e10cSrcweir if (CreateField(xPropSet, OUString::createFromAscii(sAPI_textfield_prefix) + GetServiceName()))
342cdf0e10cSrcweir {
343cdf0e10cSrcweir Reference<XDependentTextField> xDepTextField(xPropSet, UNO_QUERY);
344cdf0e10cSrcweir if (xDepTextField.is())
345cdf0e10cSrcweir {
346cdf0e10cSrcweir // attach field to field master
347cdf0e10cSrcweir xDepTextField->attachTextFieldMaster(xMaster);
348cdf0e10cSrcweir
349cdf0e10cSrcweir // attach field to document
350cdf0e10cSrcweir Reference<XTextContent> xTextContent(xPropSet, UNO_QUERY);
351cdf0e10cSrcweir if (xTextContent.is())
352cdf0e10cSrcweir {
353cdf0e10cSrcweir try {
354cdf0e10cSrcweir // insert, set field properties and exit!
355cdf0e10cSrcweir GetImportHelper().InsertTextContent(xTextContent);
356cdf0e10cSrcweir PrepareField(xPropSet);
357cdf0e10cSrcweir } catch (lang::IllegalArgumentException & /*e*/)
358cdf0e10cSrcweir {
359cdf0e10cSrcweir // ignore e: #i54023#
360cdf0e10cSrcweir };
361cdf0e10cSrcweir return;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir }
364cdf0e10cSrcweir }
365cdf0e10cSrcweir }
366cdf0e10cSrcweir }
367cdf0e10cSrcweir
368cdf0e10cSrcweir // above: exit on success; so for all error cases we end up here!
369cdf0e10cSrcweir // write element content
370cdf0e10cSrcweir GetImportHelper().InsertString(GetContent());
371cdf0e10cSrcweir }
372cdf0e10cSrcweir
FindFieldMaster(Reference<XPropertySet> & xMaster)373cdf0e10cSrcweir sal_Bool XMLSetVarFieldImportContext::FindFieldMaster(
374cdf0e10cSrcweir Reference<XPropertySet> & xMaster)
375cdf0e10cSrcweir {
376cdf0e10cSrcweir // currently: delegate to XMLVariableDeclImportContext;
377cdf0e10cSrcweir // shoud eventually go here
378cdf0e10cSrcweir return XMLVariableDeclImportContext::FindFieldMaster(xMaster,
379cdf0e10cSrcweir GetImport(),
380cdf0e10cSrcweir GetImportHelper(),
381cdf0e10cSrcweir GetName(),
382cdf0e10cSrcweir eFieldType);
383cdf0e10cSrcweir }
384cdf0e10cSrcweir
385cdf0e10cSrcweir
386cdf0e10cSrcweir
387cdf0e10cSrcweir //
388cdf0e10cSrcweir // sequence field
389cdf0e10cSrcweir //
390cdf0e10cSrcweir
391cdf0e10cSrcweir TYPEINIT1( XMLSequenceFieldImportContext, XMLSetVarFieldImportContext );
392cdf0e10cSrcweir
XMLSequenceFieldImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & rLocalName)393cdf0e10cSrcweir XMLSequenceFieldImportContext::XMLSequenceFieldImportContext(
394cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp,
395cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& rLocalName) :
396cdf0e10cSrcweir XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
397cdf0e10cSrcweir nPrfx, rLocalName, VarTypeSequence,
398cdf0e10cSrcweir // name, formula
399cdf0e10cSrcweir sal_True, sal_True, sal_True,
400cdf0e10cSrcweir sal_False, sal_False, sal_False, sal_False,
401cdf0e10cSrcweir sal_False,
402cdf0e10cSrcweir sal_False, sal_False, sal_False, sal_True),
403cdf0e10cSrcweir
404cdf0e10cSrcweir sPropertyNumberFormat(RTL_CONSTASCII_USTRINGPARAM(sAPI_number_format)),
405cdf0e10cSrcweir sPropertySequenceValue(RTL_CONSTASCII_USTRINGPARAM(sAPI_sequence_value)),
406cdf0e10cSrcweir sNumFormat(OUString::valueOf(sal_Unicode('1'))),
407cdf0e10cSrcweir sNumFormatSync(GetXMLToken(XML_FALSE)),
408cdf0e10cSrcweir bRefNameOK(sal_False)
409cdf0e10cSrcweir {
410cdf0e10cSrcweir }
411cdf0e10cSrcweir
ProcessAttribute(sal_uInt16 nAttrToken,const OUString & sAttrValue)412cdf0e10cSrcweir void XMLSequenceFieldImportContext::ProcessAttribute(
413cdf0e10cSrcweir sal_uInt16 nAttrToken, const OUString& sAttrValue )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir switch (nAttrToken)
416cdf0e10cSrcweir {
417cdf0e10cSrcweir case XML_TOK_TEXTFIELD_NUM_FORMAT:
418cdf0e10cSrcweir sNumFormat = sAttrValue;
419cdf0e10cSrcweir break;
420cdf0e10cSrcweir case XML_TOK_TEXTFIELD_NUM_LETTER_SYNC:
421cdf0e10cSrcweir sNumFormatSync = sAttrValue;
422cdf0e10cSrcweir break;
423cdf0e10cSrcweir case XML_TOK_TEXTFIELD_REF_NAME:
424cdf0e10cSrcweir sRefName = sAttrValue;
425cdf0e10cSrcweir bRefNameOK = sal_True;
426cdf0e10cSrcweir break;
427cdf0e10cSrcweir default:
428cdf0e10cSrcweir // delegate to super class (name, formula)
429cdf0e10cSrcweir XMLSetVarFieldImportContext::ProcessAttribute(nAttrToken,
430cdf0e10cSrcweir sAttrValue);
431cdf0e10cSrcweir break;
432cdf0e10cSrcweir } // switch
433cdf0e10cSrcweir }
434cdf0e10cSrcweir
PrepareField(const Reference<XPropertySet> & xPropertySet)435cdf0e10cSrcweir void XMLSequenceFieldImportContext::PrepareField(
436cdf0e10cSrcweir const Reference<XPropertySet> & xPropertySet)
437cdf0e10cSrcweir {
438cdf0e10cSrcweir // delegate to super class (formula)
439cdf0e10cSrcweir XMLSetVarFieldImportContext::PrepareField(xPropertySet);
440cdf0e10cSrcweir
441cdf0e10cSrcweir // set format
442cdf0e10cSrcweir sal_Int16 nNumType = NumberingType::ARABIC;
443cdf0e10cSrcweir GetImport().GetMM100UnitConverter().convertNumFormat( nNumType, sNumFormat, sNumFormatSync );
444cdf0e10cSrcweir Any aAny;
445cdf0e10cSrcweir aAny <<= nNumType;
446cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyNumberFormat, aAny);
447cdf0e10cSrcweir
448cdf0e10cSrcweir // handle reference name
449cdf0e10cSrcweir if (bRefNameOK)
450cdf0e10cSrcweir {
451cdf0e10cSrcweir aAny = xPropertySet->getPropertyValue(sPropertySequenceValue);
452cdf0e10cSrcweir sal_Int16 nValue = 0;
453cdf0e10cSrcweir aAny >>= nValue;
454cdf0e10cSrcweir GetImportHelper().InsertSequenceID(sRefName, GetName(), nValue);
455cdf0e10cSrcweir }
456cdf0e10cSrcweir }
457cdf0e10cSrcweir
458cdf0e10cSrcweir
459cdf0e10cSrcweir
460cdf0e10cSrcweir //
461cdf0e10cSrcweir // variable set field
462cdf0e10cSrcweir //
463cdf0e10cSrcweir
464cdf0e10cSrcweir TYPEINIT1( XMLVariableSetFieldImportContext, XMLSetVarFieldImportContext );
465cdf0e10cSrcweir
XMLVariableSetFieldImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & rLocalName)466cdf0e10cSrcweir XMLVariableSetFieldImportContext::XMLVariableSetFieldImportContext(
467cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp,
468cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& rLocalName) :
469cdf0e10cSrcweir XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
470cdf0e10cSrcweir nPrfx, rLocalName, VarTypeSimple,
471cdf0e10cSrcweir // name, formula, value&type, style,
472cdf0e10cSrcweir // display none
473cdf0e10cSrcweir sal_True, sal_True, sal_True,
474cdf0e10cSrcweir sal_False, sal_False, sal_False,
475cdf0e10cSrcweir sal_True, sal_False,
476cdf0e10cSrcweir sal_True, sal_True, sal_True,
477cdf0e10cSrcweir sal_True),
478cdf0e10cSrcweir sPropertySubType(RTL_CONSTASCII_USTRINGPARAM(sAPI_sub_type))
479cdf0e10cSrcweir {
480cdf0e10cSrcweir }
481cdf0e10cSrcweir
PrepareField(const Reference<XPropertySet> & xPropertySet)482cdf0e10cSrcweir void XMLVariableSetFieldImportContext::PrepareField(
483cdf0e10cSrcweir const Reference<XPropertySet> & xPropertySet)
484cdf0e10cSrcweir {
485cdf0e10cSrcweir // set type
486cdf0e10cSrcweir Any aAny;
487cdf0e10cSrcweir aAny <<= (IsStringValue()? SetVariableType::STRING : SetVariableType::VAR);
488cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertySubType, aAny);
489cdf0e10cSrcweir
490cdf0e10cSrcweir // the remainder is handled by super class
491cdf0e10cSrcweir XMLSetVarFieldImportContext::PrepareField(xPropertySet);
492cdf0e10cSrcweir }
493cdf0e10cSrcweir
494cdf0e10cSrcweir
495cdf0e10cSrcweir
496cdf0e10cSrcweir //
497cdf0e10cSrcweir // variable input field
498cdf0e10cSrcweir //
499cdf0e10cSrcweir
500cdf0e10cSrcweir TYPEINIT1( XMLVariableInputFieldImportContext, XMLSetVarFieldImportContext );
501cdf0e10cSrcweir
XMLVariableInputFieldImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & rLocalName)502cdf0e10cSrcweir XMLVariableInputFieldImportContext::XMLVariableInputFieldImportContext(
503cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
504cdf0e10cSrcweir const OUString& rLocalName) :
505cdf0e10cSrcweir XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
506cdf0e10cSrcweir nPrfx, rLocalName, VarTypeSimple,
507cdf0e10cSrcweir // name, description, display none/formula,
508cdf0e10cSrcweir // value&type, style, formula
509cdf0e10cSrcweir sal_True, sal_True, sal_True,
510cdf0e10cSrcweir sal_True, sal_True, sal_True,
511cdf0e10cSrcweir sal_True, sal_False,
512cdf0e10cSrcweir sal_True, sal_True, sal_True,
513cdf0e10cSrcweir sal_True),
514cdf0e10cSrcweir sPropertySubType(RTL_CONSTASCII_USTRINGPARAM(sAPI_sub_type)),
515cdf0e10cSrcweir sPropertyIsInput(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_input))
516cdf0e10cSrcweir {
517cdf0e10cSrcweir }
518cdf0e10cSrcweir
PrepareField(const Reference<XPropertySet> & xPropertySet)519cdf0e10cSrcweir void XMLVariableInputFieldImportContext::PrepareField(
520cdf0e10cSrcweir const Reference<XPropertySet> & xPropertySet)
521cdf0e10cSrcweir {
522cdf0e10cSrcweir // set type (input field)
523cdf0e10cSrcweir Any aAny;
524cdf0e10cSrcweir sal_Bool bTrue = sal_True;
525cdf0e10cSrcweir aAny.setValue( &bTrue, ::getBooleanCppuType() );
526cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyIsInput, aAny);
527cdf0e10cSrcweir
528cdf0e10cSrcweir // set type
529cdf0e10cSrcweir aAny <<= (IsStringValue()? SetVariableType::STRING : SetVariableType::VAR);
530cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertySubType, aAny);
531cdf0e10cSrcweir
532cdf0e10cSrcweir // the remainder is handled by super class
533cdf0e10cSrcweir XMLSetVarFieldImportContext::PrepareField(xPropertySet);
534cdf0e10cSrcweir }
535cdf0e10cSrcweir
536cdf0e10cSrcweir
537cdf0e10cSrcweir
538cdf0e10cSrcweir //
539cdf0e10cSrcweir // user field
540cdf0e10cSrcweir //
541cdf0e10cSrcweir
542cdf0e10cSrcweir TYPEINIT1( XMLUserFieldImportContext, XMLSetVarFieldImportContext );
543cdf0e10cSrcweir
XMLUserFieldImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & rLocalName)544cdf0e10cSrcweir XMLUserFieldImportContext::XMLUserFieldImportContext(
545cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp,
546cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& rLocalName) :
547cdf0e10cSrcweir XMLSetVarFieldImportContext(rImport, rHlp, sAPI_user, nPrfx,
548cdf0e10cSrcweir rLocalName, VarTypeUserField,
549cdf0e10cSrcweir // name, display none/formula, style
550cdf0e10cSrcweir sal_True, sal_False, sal_False,
551cdf0e10cSrcweir sal_False, sal_False, sal_False, sal_True,
552cdf0e10cSrcweir sal_True,
553cdf0e10cSrcweir sal_False, sal_True, sal_False,
554cdf0e10cSrcweir sal_False)
555cdf0e10cSrcweir {
556cdf0e10cSrcweir }
557cdf0e10cSrcweir
558cdf0e10cSrcweir
559cdf0e10cSrcweir
560cdf0e10cSrcweir //
561cdf0e10cSrcweir // user input field
562cdf0e10cSrcweir //
563cdf0e10cSrcweir
564cdf0e10cSrcweir TYPEINIT1( XMLUserFieldInputImportContext, XMLVarFieldImportContext );
565cdf0e10cSrcweir
566cdf0e10cSrcweir // bug: doesn't work (SO API lacking)
XMLUserFieldInputImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & rLocalName)567cdf0e10cSrcweir XMLUserFieldInputImportContext::XMLUserFieldInputImportContext(
568cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
569cdf0e10cSrcweir const OUString& rLocalName) :
570cdf0e10cSrcweir XMLVarFieldImportContext(rImport, rHlp, sAPI_input_user,
571cdf0e10cSrcweir nPrfx, rLocalName,
572cdf0e10cSrcweir // name, description, style
573cdf0e10cSrcweir sal_True, sal_False, sal_False,
574cdf0e10cSrcweir sal_True, sal_False, sal_False,
575cdf0e10cSrcweir sal_False, sal_False,
576cdf0e10cSrcweir sal_False /*???*/, sal_True, sal_False,
577cdf0e10cSrcweir sal_False)
578cdf0e10cSrcweir {
579cdf0e10cSrcweir }
580cdf0e10cSrcweir
PrepareField(const Reference<XPropertySet> & xPropertySet)581cdf0e10cSrcweir void XMLUserFieldInputImportContext::PrepareField(
582cdf0e10cSrcweir const Reference<XPropertySet> & xPropertySet)
583cdf0e10cSrcweir {
584cdf0e10cSrcweir Any aAny;
585cdf0e10cSrcweir aAny <<= GetName();
586cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyContent, aAny);
587cdf0e10cSrcweir
588cdf0e10cSrcweir // delegate to super class
589cdf0e10cSrcweir XMLVarFieldImportContext::PrepareField(xPropertySet);
590cdf0e10cSrcweir }
591cdf0e10cSrcweir
592cdf0e10cSrcweir
593cdf0e10cSrcweir //
594cdf0e10cSrcweir // variable get field
595cdf0e10cSrcweir //
596cdf0e10cSrcweir
597cdf0e10cSrcweir TYPEINIT1( XMLVariableGetFieldImportContext, XMLVarFieldImportContext );
598cdf0e10cSrcweir
XMLVariableGetFieldImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & rLocalName)599cdf0e10cSrcweir XMLVariableGetFieldImportContext::XMLVariableGetFieldImportContext(
600cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp,
601cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& rLocalName) :
602cdf0e10cSrcweir XMLVarFieldImportContext(rImport, rHlp, sAPI_get_expression,
603cdf0e10cSrcweir nPrfx, rLocalName,
604cdf0e10cSrcweir // name, style, display formula
605cdf0e10cSrcweir sal_True, sal_False, sal_False,
606cdf0e10cSrcweir sal_False, sal_False, sal_False,
607cdf0e10cSrcweir sal_False, sal_True,
608cdf0e10cSrcweir sal_True, sal_True, sal_False,
609cdf0e10cSrcweir sal_True),
610cdf0e10cSrcweir sPropertySubType(RTL_CONSTASCII_USTRINGPARAM(sAPI_sub_type))
611cdf0e10cSrcweir {
612cdf0e10cSrcweir }
613cdf0e10cSrcweir
PrepareField(const Reference<XPropertySet> & xPropertySet)614cdf0e10cSrcweir void XMLVariableGetFieldImportContext::PrepareField(
615cdf0e10cSrcweir const Reference<XPropertySet> & xPropertySet)
616cdf0e10cSrcweir {
617cdf0e10cSrcweir // set name
618cdf0e10cSrcweir Any aAny;
619cdf0e10cSrcweir aAny <<= GetName();
620cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyContent, aAny);
621cdf0e10cSrcweir
622cdf0e10cSrcweir // the remainder is handled by super class
623cdf0e10cSrcweir XMLVarFieldImportContext::PrepareField(xPropertySet);
624cdf0e10cSrcweir }
625cdf0e10cSrcweir
626cdf0e10cSrcweir
627cdf0e10cSrcweir
628cdf0e10cSrcweir //
629cdf0e10cSrcweir // expression field
630cdf0e10cSrcweir //
631cdf0e10cSrcweir
632cdf0e10cSrcweir TYPEINIT1( XMLExpressionFieldImportContext, XMLVarFieldImportContext );
633cdf0e10cSrcweir
XMLExpressionFieldImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & rLocalName)634cdf0e10cSrcweir XMLExpressionFieldImportContext::XMLExpressionFieldImportContext(
635cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp,
636cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& rLocalName) :
637cdf0e10cSrcweir XMLVarFieldImportContext(rImport, rHlp, sAPI_get_expression,
638cdf0e10cSrcweir nPrfx, rLocalName,
639cdf0e10cSrcweir // formula, type, style, display formula
640cdf0e10cSrcweir sal_False, sal_True, sal_True,
641cdf0e10cSrcweir sal_False, sal_False, sal_False,
642cdf0e10cSrcweir sal_False, sal_True,
643cdf0e10cSrcweir sal_True, sal_True, sal_False,
644cdf0e10cSrcweir sal_True),
645cdf0e10cSrcweir sPropertySubType(RTL_CONSTASCII_USTRINGPARAM(sAPI_sub_type))
646cdf0e10cSrcweir {
647cdf0e10cSrcweir bValid = sal_True; // always valid
648cdf0e10cSrcweir }
649cdf0e10cSrcweir
650cdf0e10cSrcweir
PrepareField(const Reference<XPropertySet> & xPropertySet)651cdf0e10cSrcweir void XMLExpressionFieldImportContext::PrepareField(
652cdf0e10cSrcweir const Reference<XPropertySet> & xPropertySet)
653cdf0e10cSrcweir {
654cdf0e10cSrcweir sal_Int16 nSubType = SetVariableType::FORMULA;
655cdf0e10cSrcweir Any aAny;
656cdf0e10cSrcweir aAny <<= nSubType;
657cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertySubType, aAny);
658cdf0e10cSrcweir
659cdf0e10cSrcweir // delegate to super class
660cdf0e10cSrcweir XMLVarFieldImportContext::PrepareField(xPropertySet);
661cdf0e10cSrcweir }
662cdf0e10cSrcweir
663cdf0e10cSrcweir
664cdf0e10cSrcweir
665cdf0e10cSrcweir //
666cdf0e10cSrcweir // text input field
667cdf0e10cSrcweir //
668cdf0e10cSrcweir
669cdf0e10cSrcweir TYPEINIT1( XMLTextInputFieldImportContext, XMLVarFieldImportContext );
670cdf0e10cSrcweir
XMLTextInputFieldImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & sLocalName)671cdf0e10cSrcweir XMLTextInputFieldImportContext::XMLTextInputFieldImportContext(
672cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp,
673cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& sLocalName) :
674cdf0e10cSrcweir XMLVarFieldImportContext(rImport, rHlp, sAPI_input,
675cdf0e10cSrcweir nPrfx, sLocalName,
676cdf0e10cSrcweir // description
677cdf0e10cSrcweir sal_False, sal_False, sal_False,
678cdf0e10cSrcweir sal_True, sal_True, sal_True,
679cdf0e10cSrcweir sal_False, sal_False,
680cdf0e10cSrcweir sal_False, sal_False, sal_False,
681cdf0e10cSrcweir sal_False),
682cdf0e10cSrcweir sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content))
683cdf0e10cSrcweir {
684cdf0e10cSrcweir bValid = sal_True; // always valid
685cdf0e10cSrcweir }
686cdf0e10cSrcweir
PrepareField(const Reference<XPropertySet> & xPropertySet)687cdf0e10cSrcweir void XMLTextInputFieldImportContext::PrepareField(
688cdf0e10cSrcweir const Reference<XPropertySet> & xPropertySet)
689cdf0e10cSrcweir {
690cdf0e10cSrcweir XMLVarFieldImportContext::PrepareField(xPropertySet);
691cdf0e10cSrcweir
692cdf0e10cSrcweir Any aAny;
693cdf0e10cSrcweir aAny <<= GetContent();
694cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyContent, aAny);
695cdf0e10cSrcweir }
696cdf0e10cSrcweir
697cdf0e10cSrcweir
698cdf0e10cSrcweir //
699cdf0e10cSrcweir // table formula field
700cdf0e10cSrcweir //
701cdf0e10cSrcweir
702cdf0e10cSrcweir TYPEINIT1( XMLTableFormulaImportContext, XMLTextFieldImportContext );
703cdf0e10cSrcweir
XMLTableFormulaImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & rLocalName)704cdf0e10cSrcweir XMLTableFormulaImportContext::XMLTableFormulaImportContext(
705cdf0e10cSrcweir SvXMLImport& rImport,
706cdf0e10cSrcweir XMLTextImportHelper& rHlp,
707cdf0e10cSrcweir sal_uInt16 nPrfx,
708cdf0e10cSrcweir const OUString& rLocalName) :
709cdf0e10cSrcweir XMLTextFieldImportContext(rImport, rHlp, sAPI_table_formula,
710cdf0e10cSrcweir nPrfx, rLocalName),
711cdf0e10cSrcweir sPropertyIsShowFormula(RTL_CONSTASCII_USTRINGPARAM("IsShowFormula")),
712cdf0e10cSrcweir sPropertyCurrentPresentation(
713cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("CurrentPresentation")),
714cdf0e10cSrcweir aValueHelper(rImport, rHlp, sal_False, sal_True, sal_False, sal_True),
715cdf0e10cSrcweir sFormula(),
716cdf0e10cSrcweir bIsShowFormula(sal_False)
717cdf0e10cSrcweir {
718cdf0e10cSrcweir }
719cdf0e10cSrcweir
~XMLTableFormulaImportContext()720cdf0e10cSrcweir XMLTableFormulaImportContext::~XMLTableFormulaImportContext()
721cdf0e10cSrcweir {
722cdf0e10cSrcweir }
723cdf0e10cSrcweir
ProcessAttribute(sal_uInt16 nAttrToken,const OUString & sAttrValue)724cdf0e10cSrcweir void XMLTableFormulaImportContext::ProcessAttribute(
725cdf0e10cSrcweir sal_uInt16 nAttrToken,
726cdf0e10cSrcweir const OUString& sAttrValue )
727cdf0e10cSrcweir {
728cdf0e10cSrcweir switch (nAttrToken)
729cdf0e10cSrcweir {
730cdf0e10cSrcweir case XML_TOK_TEXTFIELD_FORMULA:
731cdf0e10cSrcweir aValueHelper.ProcessAttribute( nAttrToken, sAttrValue );
732cdf0e10cSrcweir bValid = sal_True; // we need a formula!
733cdf0e10cSrcweir break;
734cdf0e10cSrcweir
735cdf0e10cSrcweir case XML_TOK_TEXTFIELD_DATA_STYLE_NAME:
736cdf0e10cSrcweir aValueHelper.ProcessAttribute( nAttrToken, sAttrValue );
737cdf0e10cSrcweir break;
738cdf0e10cSrcweir case XML_TOK_TEXTFIELD_DISPLAY:
739cdf0e10cSrcweir if ( sAttrValue.equalsAsciiL(
740cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("formula")) )
741cdf0e10cSrcweir bIsShowFormula = sal_True;
742cdf0e10cSrcweir break;
743cdf0e10cSrcweir default:
744cdf0e10cSrcweir // unknown attribute -> ignore
745cdf0e10cSrcweir break;
746cdf0e10cSrcweir }
747cdf0e10cSrcweir }
748cdf0e10cSrcweir
PrepareField(const Reference<XPropertySet> & xPropertySet)749cdf0e10cSrcweir void XMLTableFormulaImportContext::PrepareField(
750cdf0e10cSrcweir const Reference<XPropertySet> & xPropertySet)
751cdf0e10cSrcweir {
752cdf0e10cSrcweir // set format and formula
753cdf0e10cSrcweir aValueHelper.PrepareField( xPropertySet );
754cdf0e10cSrcweir
755cdf0e10cSrcweir Any aAny;
756cdf0e10cSrcweir
757cdf0e10cSrcweir // set 'show formula' and presentation
758cdf0e10cSrcweir aAny.setValue( &bIsShowFormula, ::getBooleanCppuType() );
759cdf0e10cSrcweir xPropertySet->setPropertyValue( sPropertyIsShowFormula, aAny );
760cdf0e10cSrcweir
761cdf0e10cSrcweir aAny <<= GetContent();
762cdf0e10cSrcweir xPropertySet->setPropertyValue( sPropertyCurrentPresentation, aAny );
763cdf0e10cSrcweir }
764cdf0e10cSrcweir
765cdf0e10cSrcweir
766cdf0e10cSrcweir
767cdf0e10cSrcweir //
768cdf0e10cSrcweir // variable declarations
769cdf0e10cSrcweir //
770cdf0e10cSrcweir // Should be adapted to XMLVarField-/XMLSetVarFieldImportContext scheme!
771cdf0e10cSrcweir //
772cdf0e10cSrcweir
773cdf0e10cSrcweir
774cdf0e10cSrcweir
775cdf0e10cSrcweir //
776cdf0e10cSrcweir // declaration containter import (<variable/user-field/sequence-decls>)
777cdf0e10cSrcweir //
778cdf0e10cSrcweir
779cdf0e10cSrcweir TYPEINIT1( XMLVariableDeclsImportContext, SvXMLImportContext );
780cdf0e10cSrcweir
XMLVariableDeclsImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & rLocalName,enum VarType eVarType)781cdf0e10cSrcweir XMLVariableDeclsImportContext::XMLVariableDeclsImportContext(
782cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
783cdf0e10cSrcweir const OUString& rLocalName, enum VarType eVarType) :
784cdf0e10cSrcweir SvXMLImportContext(rImport, nPrfx, rLocalName),
785cdf0e10cSrcweir eVarDeclsContextType(eVarType),
786cdf0e10cSrcweir rImportHelper(rHlp)
787cdf0e10cSrcweir {
788cdf0e10cSrcweir }
789cdf0e10cSrcweir
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<xml::sax::XAttributeList> & xAttrList)790cdf0e10cSrcweir SvXMLImportContext* XMLVariableDeclsImportContext::CreateChildContext(
791cdf0e10cSrcweir sal_uInt16 nPrefix, const OUString& rLocalName,
792cdf0e10cSrcweir const Reference<xml::sax::XAttributeList> & xAttrList )
793cdf0e10cSrcweir {
794cdf0e10cSrcweir enum XMLTokenEnum eElementName;
795cdf0e10cSrcweir SvXMLImportContext* pImportContext = NULL;
796cdf0e10cSrcweir
797cdf0e10cSrcweir if( XML_NAMESPACE_TEXT == nPrefix )
798cdf0e10cSrcweir {
799cdf0e10cSrcweir switch (eVarDeclsContextType)
800cdf0e10cSrcweir {
801cdf0e10cSrcweir case VarTypeSequence:
802cdf0e10cSrcweir eElementName = XML_SEQUENCE_DECL;
803cdf0e10cSrcweir break;
804cdf0e10cSrcweir case VarTypeSimple:
805cdf0e10cSrcweir eElementName = XML_VARIABLE_DECL;
806cdf0e10cSrcweir break;
807cdf0e10cSrcweir case VarTypeUserField:
808cdf0e10cSrcweir eElementName = XML_USER_FIELD_DECL;
809cdf0e10cSrcweir break;
810cdf0e10cSrcweir default:
811cdf0e10cSrcweir DBG_ERROR("unknown field type!");
812cdf0e10cSrcweir eElementName = XML_SEQUENCE_DECL;
813cdf0e10cSrcweir break;
814cdf0e10cSrcweir }
815cdf0e10cSrcweir
816cdf0e10cSrcweir if( IsXMLToken( rLocalName, eElementName ) )
817cdf0e10cSrcweir {
818cdf0e10cSrcweir pImportContext = new XMLVariableDeclImportContext(
819cdf0e10cSrcweir GetImport(), rImportHelper, nPrefix, rLocalName, xAttrList,
820cdf0e10cSrcweir eVarDeclsContextType);
821cdf0e10cSrcweir }
822cdf0e10cSrcweir }
823cdf0e10cSrcweir
824cdf0e10cSrcweir // if no context was created, use default context
825cdf0e10cSrcweir if (NULL == pImportContext) {
826cdf0e10cSrcweir pImportContext = SvXMLImportContext::CreateChildContext(nPrefix,
827cdf0e10cSrcweir rLocalName,
828cdf0e10cSrcweir xAttrList);
829cdf0e10cSrcweir }
830cdf0e10cSrcweir
831cdf0e10cSrcweir return pImportContext;
832cdf0e10cSrcweir }
833cdf0e10cSrcweir
834cdf0e10cSrcweir
835cdf0e10cSrcweir
836cdf0e10cSrcweir //
837cdf0e10cSrcweir // declaration import (<variable/user-field/sequence-decl> elements)
838cdf0e10cSrcweir //
839cdf0e10cSrcweir
840cdf0e10cSrcweir TYPEINIT1( XMLVariableDeclImportContext, SvXMLImportContext );
841cdf0e10cSrcweir
XMLVariableDeclImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & rLocalName,const Reference<xml::sax::XAttributeList> & xAttrList,enum VarType eVarType)842cdf0e10cSrcweir XMLVariableDeclImportContext::XMLVariableDeclImportContext(
843cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp,
844cdf0e10cSrcweir sal_uInt16 nPrfx, const OUString& rLocalName,
845cdf0e10cSrcweir const Reference<xml::sax::XAttributeList> & xAttrList,
846cdf0e10cSrcweir enum VarType eVarType) :
847cdf0e10cSrcweir SvXMLImportContext(rImport, nPrfx, rLocalName),
848cdf0e10cSrcweir // bug?? which properties for userfield/userfieldmaster
849cdf0e10cSrcweir sPropertyName(RTL_CONSTASCII_USTRINGPARAM(sAPI_name)),
850cdf0e10cSrcweir sPropertySubType(RTL_CONSTASCII_USTRINGPARAM(sAPI_sub_type)),
851cdf0e10cSrcweir sPropertyNumberingLevel(RTL_CONSTASCII_USTRINGPARAM(sAPI_chapter_numbering_level)),
852cdf0e10cSrcweir sPropertyNumberingSeparator(RTL_CONSTASCII_USTRINGPARAM(sAPI_numbering_separator)),
853cdf0e10cSrcweir sPropertyIsExpression(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_expression)),
854cdf0e10cSrcweir aValueHelper(rImport, rHlp, sal_True, sal_False, sal_True, sal_False),
855cdf0e10cSrcweir nNumLevel(-1), cSeparationChar('.')
856cdf0e10cSrcweir {
857cdf0e10cSrcweir if ( (XML_NAMESPACE_TEXT == nPrfx) &&
858cdf0e10cSrcweir ( ( IsXMLToken( rLocalName, XML_SEQUENCE_DECL )) ||
859cdf0e10cSrcweir ( IsXMLToken( rLocalName, XML_VARIABLE_DECL)) ||
860cdf0e10cSrcweir ( IsXMLToken( rLocalName, XML_USER_FIELD_DECL)) )) {
861cdf0e10cSrcweir
862cdf0e10cSrcweir // TODO: check validity (need name!)
863cdf0e10cSrcweir
864cdf0e10cSrcweir // parse attributes
865cdf0e10cSrcweir sal_Int16 nLength = xAttrList->getLength();
866cdf0e10cSrcweir for(sal_Int16 i=0; i<nLength; i++) {
867cdf0e10cSrcweir
868cdf0e10cSrcweir OUString sLocalName;
869cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
870cdf0e10cSrcweir GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
871cdf0e10cSrcweir
872cdf0e10cSrcweir sal_uInt16 nToken = rHlp.
873cdf0e10cSrcweir GetTextFieldAttrTokenMap().Get(nPrefix, sLocalName);
874cdf0e10cSrcweir
875cdf0e10cSrcweir switch (nToken)
876cdf0e10cSrcweir {
877cdf0e10cSrcweir case XML_TOK_TEXTFIELD_NAME:
878cdf0e10cSrcweir sName = xAttrList->getValueByIndex(i);
879cdf0e10cSrcweir break;
880cdf0e10cSrcweir case XML_TOK_TEXTFIELD_NUMBERING_LEVEL:
881cdf0e10cSrcweir {
882cdf0e10cSrcweir sal_Int32 nLevel;
883cdf0e10cSrcweir sal_Bool bRet = SvXMLUnitConverter::convertNumber(
884cdf0e10cSrcweir nLevel, xAttrList->getValueByIndex(i), 0,
885cdf0e10cSrcweir GetImport().GetTextImport()->GetChapterNumbering()->
886cdf0e10cSrcweir getCount());
887cdf0e10cSrcweir if (bRet)
888cdf0e10cSrcweir {
889cdf0e10cSrcweir nNumLevel = static_cast< sal_Int8 >( nLevel-1 ); // API numbers -1..9
890cdf0e10cSrcweir }
891cdf0e10cSrcweir break;
892cdf0e10cSrcweir }
893cdf0e10cSrcweir case XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR:
894cdf0e10cSrcweir cSeparationChar =
895cdf0e10cSrcweir (sal_Char)xAttrList->getValueByIndex(i).toChar();
896cdf0e10cSrcweir break;
897cdf0e10cSrcweir
898cdf0e10cSrcweir default:
899cdf0e10cSrcweir // delegate to value helper
900cdf0e10cSrcweir aValueHelper.ProcessAttribute(nToken,
901cdf0e10cSrcweir xAttrList->getValueByIndex(i));
902cdf0e10cSrcweir break;
903cdf0e10cSrcweir }
904cdf0e10cSrcweir }
905cdf0e10cSrcweir
906cdf0e10cSrcweir Reference<XPropertySet> xFieldMaster;
907cdf0e10cSrcweir if (FindFieldMaster(xFieldMaster, GetImport(), rHlp,
908cdf0e10cSrcweir sName, eVarType))
909cdf0e10cSrcweir {
910cdf0e10cSrcweir // now we have a field master: process attributes!
911cdf0e10cSrcweir Any aAny;
912cdf0e10cSrcweir
913cdf0e10cSrcweir switch (eVarType)
914cdf0e10cSrcweir {
915cdf0e10cSrcweir case VarTypeSequence:
916cdf0e10cSrcweir aAny <<= nNumLevel;
917cdf0e10cSrcweir xFieldMaster->setPropertyValue(sPropertyNumberingLevel, aAny);
918cdf0e10cSrcweir
919cdf0e10cSrcweir if (nNumLevel >= 0)
920cdf0e10cSrcweir {
921cdf0e10cSrcweir OUString sStr(&cSeparationChar, 1);
922cdf0e10cSrcweir aAny <<= sStr;
923cdf0e10cSrcweir xFieldMaster->setPropertyValue(
924cdf0e10cSrcweir sPropertyNumberingSeparator, aAny);
925cdf0e10cSrcweir }
926cdf0e10cSrcweir break;
927cdf0e10cSrcweir case VarTypeSimple:
928cdf0e10cSrcweir {
929cdf0e10cSrcweir // set string or non-string SubType (#93192#)
930cdf0e10cSrcweir // The SubType was already set in the FindFieldMaster
931cdf0e10cSrcweir // method, but it needs to be adjusted if it's a string.
932cdf0e10cSrcweir aAny <<= aValueHelper.IsStringValue()
933cdf0e10cSrcweir ? SetVariableType::STRING : SetVariableType::VAR;
934cdf0e10cSrcweir xFieldMaster->setPropertyValue(sPropertySubType, aAny);
935cdf0e10cSrcweir }
936cdf0e10cSrcweir break;
937cdf0e10cSrcweir case VarTypeUserField:
938cdf0e10cSrcweir {
939cdf0e10cSrcweir sal_Bool bTmp = !aValueHelper.IsStringValue();
940cdf0e10cSrcweir aAny.setValue(&bTmp, ::getBooleanCppuType());
941cdf0e10cSrcweir xFieldMaster->setPropertyValue(sPropertyIsExpression, aAny);
942cdf0e10cSrcweir aValueHelper.PrepareField(xFieldMaster);
943cdf0e10cSrcweir break;
944cdf0e10cSrcweir }
945cdf0e10cSrcweir default:
946cdf0e10cSrcweir DBG_ERROR("unkown varfield type");
947cdf0e10cSrcweir } // switch
948cdf0e10cSrcweir } // else: no field master found/constructed
949cdf0e10cSrcweir } // else: no sequence-decl
950cdf0e10cSrcweir }
951cdf0e10cSrcweir
952cdf0e10cSrcweir
953cdf0e10cSrcweir
FindFieldMaster(Reference<XPropertySet> & xMaster,SvXMLImport & rImport,XMLTextImportHelper & rImportHelper,const OUString & sVarName,enum VarType eVarType)954cdf0e10cSrcweir sal_Bool XMLVariableDeclImportContext::FindFieldMaster(
955cdf0e10cSrcweir Reference<XPropertySet> & xMaster, SvXMLImport& rImport,
956cdf0e10cSrcweir XMLTextImportHelper& rImportHelper,
957cdf0e10cSrcweir const OUString& sVarName, enum VarType eVarType)
958cdf0e10cSrcweir {
959cdf0e10cSrcweir static sal_Int32 nCollisionCount = 0;
960cdf0e10cSrcweir
961cdf0e10cSrcweir // rename field
962cdf0e10cSrcweir // currently: no family in use! Use 0.
963cdf0e10cSrcweir OUString sName = rImportHelper.GetRenameMap().Get(
964cdf0e10cSrcweir sal::static_int_cast< sal_uInt16 >(eVarType), sVarName);
965cdf0e10cSrcweir
966cdf0e10cSrcweir // get text fields supplier and field masters
967cdf0e10cSrcweir Reference<XTextFieldsSupplier> xTextFieldsSupp(rImport.GetModel(),
968cdf0e10cSrcweir UNO_QUERY);
969cdf0e10cSrcweir Reference<container::XNameAccess> xFieldMasterNameAccess(
970cdf0e10cSrcweir xTextFieldsSupp->getTextFieldMasters(), UNO_QUERY);
971cdf0e10cSrcweir
972cdf0e10cSrcweir OUStringBuffer sBuffer;
973cdf0e10cSrcweir sBuffer.appendAscii(sAPI_fieldmaster_prefix);
974cdf0e10cSrcweir sBuffer.appendAscii(sAPI_set_expression);
975cdf0e10cSrcweir sBuffer.appendAscii(".");
976cdf0e10cSrcweir sBuffer.append(sName);
977cdf0e10cSrcweir OUString sVarServiceName = sBuffer.makeStringAndClear();
978cdf0e10cSrcweir
979cdf0e10cSrcweir sBuffer.appendAscii(sAPI_fieldmaster_prefix);
980cdf0e10cSrcweir sBuffer.appendAscii(sAPI_user);
981cdf0e10cSrcweir sBuffer.appendAscii(".");
982cdf0e10cSrcweir sBuffer.append(sName);
983cdf0e10cSrcweir OUString sUserServiceName = sBuffer.makeStringAndClear();
984cdf0e10cSrcweir
985cdf0e10cSrcweir if (xFieldMasterNameAccess->hasByName(sVarServiceName)) {
986cdf0e10cSrcweir // variable field master already in document
987cdf0e10cSrcweir
988cdf0e10cSrcweir Any aAny = xFieldMasterNameAccess->getByName(sVarServiceName);
989cdf0e10cSrcweir aAny >>= xMaster;
990cdf0e10cSrcweir
991cdf0e10cSrcweir aAny = xMaster->getPropertyValue(
992cdf0e10cSrcweir // sPropertySubType
993cdf0e10cSrcweir OUString::createFromAscii(sAPI_sub_type)
994cdf0e10cSrcweir );
995cdf0e10cSrcweir sal_Int16 nType = 0;
996cdf0e10cSrcweir aAny >>= nType;
997cdf0e10cSrcweir
998cdf0e10cSrcweir enum VarType eFMVarType =
999cdf0e10cSrcweir (SetVariableType::SEQUENCE == nType) ?
1000cdf0e10cSrcweir VarTypeSequence : VarTypeSimple;
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir if (eFMVarType != eVarType)
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir OUString sNew;
1005cdf0e10cSrcweir
1006cdf0e10cSrcweir // FIXME! cant find if name is taken already!!!!
1007cdf0e10cSrcweir
1008cdf0e10cSrcweir nCollisionCount++;
1009cdf0e10cSrcweir OUStringBuffer aBuf;
1010cdf0e10cSrcweir aBuf.append(sName);
1011cdf0e10cSrcweir aBuf.appendAscii("_renamed_");
1012cdf0e10cSrcweir aBuf.append(nCollisionCount);
1013cdf0e10cSrcweir sNew = aBuf.makeStringAndClear();
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir rImportHelper.GetRenameMap().Add(
1016cdf0e10cSrcweir sal::static_int_cast< sal_uInt16 >(eVarType), sName, sNew);
1017cdf0e10cSrcweir
1018cdf0e10cSrcweir // call FindFieldMaster recursively to create new master
1019cdf0e10cSrcweir return FindFieldMaster(xMaster, rImport, rImportHelper,
1020cdf0e10cSrcweir sNew, eVarType);
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir } else if (xFieldMasterNameAccess->hasByName(sUserServiceName)) {
1023cdf0e10cSrcweir // user field: get field master
1024cdf0e10cSrcweir Any aAny = xFieldMasterNameAccess->getByName(sUserServiceName);
1025cdf0e10cSrcweir aAny >>= xMaster;
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir if (VarTypeUserField != eVarType) {
1028cdf0e10cSrcweir // find new name that is not taken
1029cdf0e10cSrcweir OUString sNew;
1030cdf0e10cSrcweir
1031cdf0e10cSrcweir // FIXME! cant find if name is taken already!!!!
1032cdf0e10cSrcweir
1033cdf0e10cSrcweir nCollisionCount++;
1034cdf0e10cSrcweir OUStringBuffer aBuf;
1035cdf0e10cSrcweir aBuf.append(sName);
1036cdf0e10cSrcweir aBuf.appendAscii("_renamed_");
1037cdf0e10cSrcweir aBuf.append(nCollisionCount);
1038cdf0e10cSrcweir sNew = aBuf.makeStringAndClear();
1039cdf0e10cSrcweir
1040cdf0e10cSrcweir rImportHelper.GetRenameMap().Add(
1041cdf0e10cSrcweir sal::static_int_cast< sal_uInt16 >(eVarType), sName, sNew);
1042cdf0e10cSrcweir
1043cdf0e10cSrcweir // call FindFieldMaster recursively to create new master
1044cdf0e10cSrcweir return FindFieldMaster(xMaster, rImport, rImportHelper,
1045cdf0e10cSrcweir sNew, eVarType);
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir } else {
1048cdf0e10cSrcweir // field name not used: create field master
1049cdf0e10cSrcweir
1050cdf0e10cSrcweir // import -> model is MultiServiceFactory -> createInstance
1051cdf0e10cSrcweir Reference<lang::XMultiServiceFactory>
1052cdf0e10cSrcweir xFactory(rImport.GetModel(),UNO_QUERY);
1053cdf0e10cSrcweir if( xFactory.is() ) {
1054cdf0e10cSrcweir
1055cdf0e10cSrcweir OUStringBuffer sService;
1056cdf0e10cSrcweir sService.appendAscii(sAPI_fieldmaster_prefix);
1057cdf0e10cSrcweir sService.appendAscii((eVarType==VarTypeUserField) ?
1058cdf0e10cSrcweir sAPI_user : sAPI_set_expression);
1059cdf0e10cSrcweir Reference<XInterface> xIfc =
1060cdf0e10cSrcweir xFactory->createInstance( sService.makeStringAndClear() );
1061cdf0e10cSrcweir if (xIfc.is()) {
1062cdf0e10cSrcweir Reference<XPropertySet> xTmp( xIfc, UNO_QUERY );
1063cdf0e10cSrcweir xMaster = xTmp;
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir // set name
1066cdf0e10cSrcweir Any aAny;
1067cdf0e10cSrcweir aAny <<= sName;
1068cdf0e10cSrcweir xMaster->setPropertyValue(
1069cdf0e10cSrcweir // sPropertyName
1070cdf0e10cSrcweir OUString::createFromAscii(sAPI_name)
1071cdf0e10cSrcweir , aAny);
1072cdf0e10cSrcweir
1073cdf0e10cSrcweir if (eVarType != VarTypeUserField) {
1074cdf0e10cSrcweir // set subtype for setexp field
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir aAny <<= ((eVarType == VarTypeSimple) ?
1077cdf0e10cSrcweir SetVariableType::VAR :
1078cdf0e10cSrcweir SetVariableType::SEQUENCE);
1079cdf0e10cSrcweir xMaster->setPropertyValue(
1080cdf0e10cSrcweir // sPropertySubType
1081cdf0e10cSrcweir OUString::createFromAscii(sAPI_sub_type)
1082cdf0e10cSrcweir , aAny);
1083cdf0e10cSrcweir } // else : user field: no subtype
1084cdf0e10cSrcweir
1085cdf0e10cSrcweir } else {
1086cdf0e10cSrcweir return sal_False;
1087cdf0e10cSrcweir }
1088cdf0e10cSrcweir } else {
1089cdf0e10cSrcweir return sal_False;
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir }
1092cdf0e10cSrcweir
1093cdf0e10cSrcweir DBG_ASSERT(xMaster.is(), "no field master found!?!");
1094cdf0e10cSrcweir return sal_True;
1095cdf0e10cSrcweir }
1096cdf0e10cSrcweir
1097cdf0e10cSrcweir
1098cdf0e10cSrcweir //
1099cdf0e10cSrcweir // Database Display field import
1100cdf0e10cSrcweir //
1101cdf0e10cSrcweir
1102cdf0e10cSrcweir
1103cdf0e10cSrcweir TYPEINIT1( XMLDatabaseDisplayImportContext, XMLDatabaseFieldImportContext );
1104cdf0e10cSrcweir
XMLDatabaseDisplayImportContext(SvXMLImport & rImport,XMLTextImportHelper & rHlp,sal_uInt16 nPrfx,const OUString & rLocalName)1105cdf0e10cSrcweir XMLDatabaseDisplayImportContext::XMLDatabaseDisplayImportContext(
1106cdf0e10cSrcweir SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
1107cdf0e10cSrcweir const OUString& rLocalName) :
1108cdf0e10cSrcweir XMLDatabaseFieldImportContext(rImport, rHlp, sAPI_database,
1109cdf0e10cSrcweir nPrfx, rLocalName, false),
1110cdf0e10cSrcweir sPropertyColumnName(RTL_CONSTASCII_USTRINGPARAM(sAPI_data_column_name)),
1111cdf0e10cSrcweir sPropertyDatabaseFormat(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_data_base_format)),
1112cdf0e10cSrcweir sPropertyCurrentPresentation(RTL_CONSTASCII_USTRINGPARAM(sAPI_current_presentation)),
1113cdf0e10cSrcweir sPropertyIsVisible(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_visible)),
1114cdf0e10cSrcweir aValueHelper(rImport, rHlp, sal_False, sal_True, sal_False, sal_False),
1115cdf0e10cSrcweir bColumnOK(sal_False),
1116cdf0e10cSrcweir bDisplay( sal_True ),
1117cdf0e10cSrcweir bDisplayOK( sal_False )
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir }
1120cdf0e10cSrcweir
ProcessAttribute(sal_uInt16 nAttrToken,const OUString & sAttrValue)1121cdf0e10cSrcweir void XMLDatabaseDisplayImportContext::ProcessAttribute(
1122cdf0e10cSrcweir sal_uInt16 nAttrToken, const OUString& sAttrValue )
1123cdf0e10cSrcweir {
1124cdf0e10cSrcweir switch (nAttrToken)
1125cdf0e10cSrcweir {
1126cdf0e10cSrcweir case XML_TOK_TEXTFIELD_COLUMN_NAME:
1127cdf0e10cSrcweir sColumnName = sAttrValue;
1128cdf0e10cSrcweir bColumnOK = sal_True;
1129cdf0e10cSrcweir break;
1130cdf0e10cSrcweir case XML_TOK_TEXTFIELD_DISPLAY:
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir sal_Bool bNone = IsXMLToken( sAttrValue, XML_NONE );
1133cdf0e10cSrcweir sal_Bool bValue = IsXMLToken( sAttrValue, XML_VALUE );
1134cdf0e10cSrcweir bDisplay = bValue;
1135cdf0e10cSrcweir bDisplayOK = bNone || bValue;
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir break;
1138cdf0e10cSrcweir case XML_TOK_TEXTFIELD_DATABASE_NAME:
1139cdf0e10cSrcweir case XML_TOK_TEXTFIELD_TABLE_NAME:
1140cdf0e10cSrcweir case XML_TOK_TEXTFIELD_TABLE_TYPE:
1141cdf0e10cSrcweir // handled by super class
1142cdf0e10cSrcweir XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken,
1143cdf0e10cSrcweir sAttrValue);
1144cdf0e10cSrcweir break;
1145cdf0e10cSrcweir default:
1146cdf0e10cSrcweir // remainder handled by value helper
1147cdf0e10cSrcweir aValueHelper.ProcessAttribute(nAttrToken, sAttrValue);
1148cdf0e10cSrcweir break;
1149cdf0e10cSrcweir }
1150cdf0e10cSrcweir
1151cdf0e10cSrcweir bValid = bTableOK && bDatabaseOK && bColumnOK;
1152cdf0e10cSrcweir }
1153cdf0e10cSrcweir
EndElement()1154cdf0e10cSrcweir void XMLDatabaseDisplayImportContext::EndElement()
1155cdf0e10cSrcweir {
1156cdf0e10cSrcweir // we have an EndElement of our own, because database fields need
1157cdf0e10cSrcweir // to be attached to a field master before they can be inserted into
1158cdf0e10cSrcweir // the document. Database stuff (database, table, column) all goes
1159cdf0e10cSrcweir // to the field master, value & style go to the field.
1160cdf0e10cSrcweir
1161cdf0e10cSrcweir if (bValid)
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir
1164cdf0e10cSrcweir // so here goes: we start with the master
1165cdf0e10cSrcweir Reference<XPropertySet> xMaster;
1166cdf0e10cSrcweir
1167cdf0e10cSrcweir // create and prepare field master first
1168cdf0e10cSrcweir if (CreateField(xMaster,
1169cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM(
1170cdf0e10cSrcweir sAPI_fieldmaster_database))))
1171cdf0e10cSrcweir {
1172cdf0e10cSrcweir Any aAny;
1173cdf0e10cSrcweir aAny <<= sColumnName;
1174cdf0e10cSrcweir xMaster->setPropertyValue(sPropertyColumnName, aAny);
1175cdf0e10cSrcweir
1176cdf0e10cSrcweir // fieldmaster takes database, table and column name
1177cdf0e10cSrcweir XMLDatabaseFieldImportContext::PrepareField(xMaster);
1178cdf0e10cSrcweir
1179cdf0e10cSrcweir // create field
1180cdf0e10cSrcweir Reference<XPropertySet> xField;
1181cdf0e10cSrcweir if (CreateField(xField,
1182cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM(
1183cdf0e10cSrcweir sAPI_database))))
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir // attach field master
1186cdf0e10cSrcweir Reference<XDependentTextField> xDepField(xField, UNO_QUERY);
1187cdf0e10cSrcweir if (xDepField.is())
1188cdf0e10cSrcweir {
1189cdf0e10cSrcweir // attach field to field master
1190cdf0e10cSrcweir xDepField->attachTextFieldMaster(xMaster);
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir // attach field to document
1193cdf0e10cSrcweir Reference<XTextContent> xTextContent(xField, UNO_QUERY);
1194cdf0e10cSrcweir if (xTextContent.is())
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir // insert, set field properties and exit!
1197cdf0e10cSrcweir GetImportHelper().InsertTextContent(xTextContent);
1198cdf0e10cSrcweir
1199cdf0e10cSrcweir // prepare field: format from database?
1200cdf0e10cSrcweir sal_Bool bTmp = !aValueHelper.IsFormatOK();
1201cdf0e10cSrcweir aAny.setValue( &bTmp, ::getBooleanCppuType() );
1202cdf0e10cSrcweir xField->setPropertyValue(sPropertyDatabaseFormat,aAny);
1203cdf0e10cSrcweir
1204cdf0e10cSrcweir // value, value-type and format done by value helper
1205cdf0e10cSrcweir aValueHelper.PrepareField(xField);
1206cdf0e10cSrcweir
1207cdf0e10cSrcweir // visibility
1208cdf0e10cSrcweir if( bDisplayOK )
1209cdf0e10cSrcweir {
1210cdf0e10cSrcweir aAny.setValue( &bDisplay, ::getBooleanCppuType() );
1211cdf0e10cSrcweir xField->setPropertyValue(sPropertyIsVisible, aAny);
1212cdf0e10cSrcweir }
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir // set presentation
1215cdf0e10cSrcweir aAny <<= GetContent();
1216cdf0e10cSrcweir xField->setPropertyValue(sPropertyCurrentPresentation,
1217cdf0e10cSrcweir aAny);
1218cdf0e10cSrcweir
1219cdf0e10cSrcweir // success!
1220cdf0e10cSrcweir return;
1221cdf0e10cSrcweir }
1222cdf0e10cSrcweir }
1223cdf0e10cSrcweir }
1224cdf0e10cSrcweir }
1225cdf0e10cSrcweir }
1226cdf0e10cSrcweir
1227cdf0e10cSrcweir // above: exit on success; so for all error cases we end up here!
1228cdf0e10cSrcweir // write element content
1229cdf0e10cSrcweir GetImportHelper().InsertString(GetContent());
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir
1233cdf0e10cSrcweir //
1234cdf0e10cSrcweir // value import helper
1235cdf0e10cSrcweir //
1236cdf0e10cSrcweir
1237cdf0e10cSrcweir enum ValueType
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir XML_VALUE_TYPE_STRING,
1240cdf0e10cSrcweir XML_VALUE_TYPE_FLOAT,
1241cdf0e10cSrcweir XML_VALUE_TYPE_CURRENCY,
1242cdf0e10cSrcweir XML_VALUE_TYPE_PERCENTAGE,
1243cdf0e10cSrcweir XML_VALUE_TYPE_DATE,
1244cdf0e10cSrcweir XML_VALUE_TYPE_TIME,
1245cdf0e10cSrcweir XML_VALUE_TYPE_BOOLEAN
1246cdf0e10cSrcweir };
1247cdf0e10cSrcweir
1248cdf0e10cSrcweir static SvXMLEnumMapEntry __READONLY_DATA aValueTypeMap[] =
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir { XML_FLOAT, XML_VALUE_TYPE_FLOAT },
1251cdf0e10cSrcweir { XML_CURRENCY, XML_VALUE_TYPE_CURRENCY },
1252cdf0e10cSrcweir { XML_PERCENTAGE, XML_VALUE_TYPE_PERCENTAGE },
1253cdf0e10cSrcweir { XML_DATE, XML_VALUE_TYPE_DATE },
1254cdf0e10cSrcweir { XML_TIME, XML_VALUE_TYPE_TIME },
1255cdf0e10cSrcweir { XML_BOOLEAN, XML_VALUE_TYPE_BOOLEAN },
1256cdf0e10cSrcweir { XML_STRING, XML_VALUE_TYPE_STRING },
1257cdf0e10cSrcweir { XML_TOKEN_INVALID, 0 }
1258cdf0e10cSrcweir };
1259cdf0e10cSrcweir
XMLValueImportHelper(SvXMLImport & rImprt,XMLTextImportHelper & rHlp,sal_Bool bType,sal_Bool bStyle,sal_Bool bValue,sal_Bool bFormula)1260cdf0e10cSrcweir XMLValueImportHelper::XMLValueImportHelper(
1261cdf0e10cSrcweir SvXMLImport& rImprt,
1262cdf0e10cSrcweir XMLTextImportHelper& rHlp,
1263cdf0e10cSrcweir sal_Bool bType, sal_Bool bStyle, sal_Bool bValue, sal_Bool bFormula) :
1264cdf0e10cSrcweir sPropertyContent(RTL_CONSTASCII_USTRINGPARAM(sAPI_content)),
1265cdf0e10cSrcweir sPropertyValue(RTL_CONSTASCII_USTRINGPARAM(sAPI_value)),
1266cdf0e10cSrcweir sPropertyNumberFormat(RTL_CONSTASCII_USTRINGPARAM(sAPI_number_format)),
1267cdf0e10cSrcweir sPropertyIsFixedLanguage(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_fixed_language)),
1268cdf0e10cSrcweir
1269cdf0e10cSrcweir rImport(rImprt),
1270cdf0e10cSrcweir rHelper(rHlp),
1271cdf0e10cSrcweir
1272cdf0e10cSrcweir fValue(0.0),
1273cdf0e10cSrcweir nFormatKey(0),
1274cdf0e10cSrcweir bIsDefaultLanguage(sal_True),
1275cdf0e10cSrcweir
1276cdf0e10cSrcweir bStringType(sal_False),
1277cdf0e10cSrcweir bFormatOK(sal_False),
1278cdf0e10cSrcweir bTypeOK(sal_False),
1279cdf0e10cSrcweir bStringValueOK(sal_False),
1280cdf0e10cSrcweir bFloatValueOK(sal_False),
1281cdf0e10cSrcweir bFormulaOK(sal_False),
1282cdf0e10cSrcweir
1283cdf0e10cSrcweir bSetType(bType),
1284cdf0e10cSrcweir bSetValue(bValue),
1285cdf0e10cSrcweir bSetStyle(bStyle),
1286cdf0e10cSrcweir bSetFormula(bFormula),
1287cdf0e10cSrcweir
1288cdf0e10cSrcweir bStringDefault(sal_True),
1289cdf0e10cSrcweir bFormulaDefault(sal_True)
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir }
1292cdf0e10cSrcweir
~XMLValueImportHelper()1293cdf0e10cSrcweir XMLValueImportHelper::~XMLValueImportHelper()
1294cdf0e10cSrcweir {
1295cdf0e10cSrcweir }
1296cdf0e10cSrcweir
ProcessAttribute(sal_uInt16 nAttrToken,const OUString & sAttrValue)1297cdf0e10cSrcweir void XMLValueImportHelper::ProcessAttribute(
1298cdf0e10cSrcweir sal_uInt16 nAttrToken, const OUString& sAttrValue )
1299cdf0e10cSrcweir {
1300cdf0e10cSrcweir switch (nAttrToken)
1301cdf0e10cSrcweir {
1302cdf0e10cSrcweir case XML_TOK_TEXTFIELD_VALUE_TYPE:
1303cdf0e10cSrcweir {
1304cdf0e10cSrcweir // convert enum
1305cdf0e10cSrcweir sal_uInt16 nTmp = 0;
1306cdf0e10cSrcweir sal_Bool bRet = SvXMLUnitConverter::convertEnum(
1307cdf0e10cSrcweir nTmp, sAttrValue, aValueTypeMap);
1308cdf0e10cSrcweir
1309cdf0e10cSrcweir if (bRet) {
1310cdf0e10cSrcweir ValueType eValueType = (ValueType)nTmp;
1311cdf0e10cSrcweir
1312cdf0e10cSrcweir bTypeOK = sal_True;
1313cdf0e10cSrcweir
1314cdf0e10cSrcweir switch (eValueType)
1315cdf0e10cSrcweir {
1316cdf0e10cSrcweir case XML_VALUE_TYPE_STRING:
1317cdf0e10cSrcweir bStringType = sal_True;
1318cdf0e10cSrcweir break;
1319cdf0e10cSrcweir case XML_VALUE_TYPE_FLOAT:
1320cdf0e10cSrcweir case XML_VALUE_TYPE_CURRENCY:
1321cdf0e10cSrcweir case XML_VALUE_TYPE_PERCENTAGE:
1322cdf0e10cSrcweir case XML_VALUE_TYPE_DATE:
1323cdf0e10cSrcweir case XML_VALUE_TYPE_TIME:
1324cdf0e10cSrcweir case XML_VALUE_TYPE_BOOLEAN:
1325cdf0e10cSrcweir bStringType = sal_False;
1326cdf0e10cSrcweir break;
1327cdf0e10cSrcweir
1328cdf0e10cSrcweir default:
1329cdf0e10cSrcweir DBG_ERROR("unknown value type");
1330cdf0e10cSrcweir bTypeOK = sal_False;
1331cdf0e10cSrcweir }
1332cdf0e10cSrcweir }
1333cdf0e10cSrcweir break;
1334cdf0e10cSrcweir }
1335cdf0e10cSrcweir
1336cdf0e10cSrcweir case XML_TOK_TEXTFIELD_VALUE:
1337cdf0e10cSrcweir {
1338cdf0e10cSrcweir double fTmp;
1339cdf0e10cSrcweir sal_Bool bRet = SvXMLUnitConverter::convertDouble(fTmp,sAttrValue);
1340cdf0e10cSrcweir if (bRet) {
1341cdf0e10cSrcweir bFloatValueOK = sal_True;
1342cdf0e10cSrcweir fValue = fTmp;
1343cdf0e10cSrcweir }
1344cdf0e10cSrcweir break;
1345cdf0e10cSrcweir }
1346cdf0e10cSrcweir
1347cdf0e10cSrcweir case XML_TOK_TEXTFIELD_TIME_VALUE:
1348cdf0e10cSrcweir {
1349cdf0e10cSrcweir double fTmp;
1350cdf0e10cSrcweir sal_Bool bRet = SvXMLUnitConverter::convertTime(fTmp,sAttrValue);
1351cdf0e10cSrcweir if (bRet) {
1352cdf0e10cSrcweir bFloatValueOK = sal_True;
1353cdf0e10cSrcweir fValue = fTmp;
1354cdf0e10cSrcweir }
1355cdf0e10cSrcweir break;
1356cdf0e10cSrcweir }
1357cdf0e10cSrcweir
1358cdf0e10cSrcweir case XML_TOK_TEXTFIELD_DATE_VALUE:
1359cdf0e10cSrcweir {
1360cdf0e10cSrcweir double fTmp;
1361cdf0e10cSrcweir sal_Bool bRet = rImport.GetMM100UnitConverter().
1362cdf0e10cSrcweir convertDateTime(fTmp,sAttrValue);
1363cdf0e10cSrcweir if (bRet) {
1364cdf0e10cSrcweir bFloatValueOK = sal_True;
1365cdf0e10cSrcweir fValue = fTmp;
1366cdf0e10cSrcweir }
1367cdf0e10cSrcweir break;
1368cdf0e10cSrcweir }
1369cdf0e10cSrcweir
1370cdf0e10cSrcweir case XML_TOK_TEXTFIELD_BOOL_VALUE:
1371cdf0e10cSrcweir {
1372cdf0e10cSrcweir sal_Bool bTmp;
1373cdf0e10cSrcweir sal_Bool bRet = SvXMLUnitConverter::convertBool(bTmp,sAttrValue);
1374cdf0e10cSrcweir if (bRet) {
1375cdf0e10cSrcweir bFloatValueOK = sal_True;
1376cdf0e10cSrcweir fValue = (bTmp ? 1.0 : 0.0);
1377cdf0e10cSrcweir }
1378cdf0e10cSrcweir else
1379cdf0e10cSrcweir {
1380cdf0e10cSrcweir double fTmp;
1381cdf0e10cSrcweir bRet = SvXMLUnitConverter::convertDouble(fTmp,sAttrValue);
1382cdf0e10cSrcweir if (bRet) {
1383cdf0e10cSrcweir bFloatValueOK = sal_True;
1384cdf0e10cSrcweir fValue = fTmp;
1385cdf0e10cSrcweir }
1386cdf0e10cSrcweir }
1387cdf0e10cSrcweir break;
1388cdf0e10cSrcweir }
1389cdf0e10cSrcweir
1390cdf0e10cSrcweir case XML_TOK_TEXTFIELD_STRING_VALUE:
1391cdf0e10cSrcweir sValue = sAttrValue;
1392cdf0e10cSrcweir bStringValueOK = sal_True;
1393cdf0e10cSrcweir break;
1394cdf0e10cSrcweir
1395cdf0e10cSrcweir case XML_TOK_TEXTFIELD_FORMULA:
1396cdf0e10cSrcweir {
1397cdf0e10cSrcweir OUString sTmp;
1398cdf0e10cSrcweir sal_uInt16 nPrefix = rImport.GetNamespaceMap().
1399cdf0e10cSrcweir _GetKeyByAttrName( sAttrValue, &sTmp, sal_False );
1400cdf0e10cSrcweir if( XML_NAMESPACE_OOOW == nPrefix )
1401cdf0e10cSrcweir {
1402cdf0e10cSrcweir sFormula = sTmp;
1403cdf0e10cSrcweir bFormulaOK = sal_True;
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir else
1406cdf0e10cSrcweir sFormula = sAttrValue;
1407cdf0e10cSrcweir }
1408cdf0e10cSrcweir break;
1409cdf0e10cSrcweir
1410cdf0e10cSrcweir case XML_TOK_TEXTFIELD_DATA_STYLE_NAME:
1411cdf0e10cSrcweir {
1412cdf0e10cSrcweir sal_Int32 nKey = rHelper.GetDataStyleKey(
1413cdf0e10cSrcweir sAttrValue, &bIsDefaultLanguage);
1414cdf0e10cSrcweir if (-1 != nKey)
1415cdf0e10cSrcweir {
1416cdf0e10cSrcweir nFormatKey = nKey;
1417cdf0e10cSrcweir bFormatOK = sal_True;
1418cdf0e10cSrcweir }
1419cdf0e10cSrcweir break;
1420cdf0e10cSrcweir }
1421cdf0e10cSrcweir } // switch
1422cdf0e10cSrcweir }
1423cdf0e10cSrcweir
PrepareField(const Reference<XPropertySet> & xPropertySet)1424cdf0e10cSrcweir void XMLValueImportHelper::PrepareField(
1425cdf0e10cSrcweir const Reference<XPropertySet> & xPropertySet)
1426cdf0e10cSrcweir {
1427cdf0e10cSrcweir Any aAny;
1428cdf0e10cSrcweir
1429cdf0e10cSrcweir if (bSetType)
1430cdf0e10cSrcweir {
1431cdf0e10cSrcweir // ??? how to set type?
1432cdf0e10cSrcweir }
1433cdf0e10cSrcweir
1434cdf0e10cSrcweir if (bSetFormula)
1435cdf0e10cSrcweir {
1436cdf0e10cSrcweir aAny <<= (!bFormulaOK && bFormulaDefault) ? sDefault : sFormula;
1437cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyContent, aAny);
1438cdf0e10cSrcweir }
1439cdf0e10cSrcweir
1440cdf0e10cSrcweir // format/style
1441cdf0e10cSrcweir if (bSetStyle && bFormatOK)
1442cdf0e10cSrcweir {
1443cdf0e10cSrcweir aAny <<= nFormatKey;
1444cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyNumberFormat, aAny);
1445cdf0e10cSrcweir
1446cdf0e10cSrcweir if( xPropertySet->getPropertySetInfo()->
1447cdf0e10cSrcweir hasPropertyByName( sPropertyIsFixedLanguage ) )
1448cdf0e10cSrcweir {
1449cdf0e10cSrcweir sal_Bool bIsFixedLanguage = ! bIsDefaultLanguage;
1450cdf0e10cSrcweir aAny.setValue( &bIsFixedLanguage, ::getBooleanCppuType() );
1451cdf0e10cSrcweir xPropertySet->setPropertyValue( sPropertyIsFixedLanguage, aAny );
1452cdf0e10cSrcweir }
1453cdf0e10cSrcweir }
1454cdf0e10cSrcweir
1455cdf0e10cSrcweir // value: string or float
1456cdf0e10cSrcweir if (bSetValue)
1457cdf0e10cSrcweir {
1458cdf0e10cSrcweir if (bStringType)
1459cdf0e10cSrcweir {
1460cdf0e10cSrcweir aAny <<= (!bStringValueOK && bStringDefault) ? sDefault : sValue;
1461cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyContent, aAny);
1462cdf0e10cSrcweir }
1463cdf0e10cSrcweir else
1464cdf0e10cSrcweir {
1465cdf0e10cSrcweir aAny <<= fValue;
1466cdf0e10cSrcweir xPropertySet->setPropertyValue(sPropertyValue, aAny);
1467cdf0e10cSrcweir }
1468cdf0e10cSrcweir }
1469cdf0e10cSrcweir }
1470cdf0e10cSrcweir
1471