Bump for 3.6-28
[LibreOffice.git] / xmloff / source / text / txtvfldi.cxx
blobc9c8219d214f6193ef2107380b3252512f956dce
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 /** @#file
32 * export of all variable related text fields (and database display field)
34 #include "txtvfldi.hxx"
35 #include <xmloff/xmltoken.hxx>
36 #include <xmloff/txtimp.hxx>
37 #include <xmloff/xmlnumi.hxx>
38 #include "xmloff/xmlnmspe.hxx"
39 #include <xmloff/nmspmap.hxx>
40 #include "xmloff/i18nmap.hxx"
41 #include <xmloff/xmlimp.hxx>
42 #include <xmloff/xmluconv.hxx>
43 #include <xmloff/xmlement.hxx>
44 #include <com/sun/star/text/SetVariableType.hpp>
45 #include <com/sun/star/text/XTextField.hpp>
46 #include <com/sun/star/text/XDependentTextField.hpp>
47 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
48 #include <com/sun/star/beans/XPropertySet.hpp>
49 #include <com/sun/star/beans/XPropertySetInfo.hpp>
50 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 #include <com/sun/star/xml/sax/XAttributeList.hpp>
53 #include <sax/tools/converter.hxx>
55 #include <rtl/ustring.hxx>
57 #include <tools/debug.hxx>
60 // service names
61 static const sal_Char sAPI_textfield_prefix[] = "com.sun.star.text.TextField.";
62 static const sal_Char sAPI_fieldmaster_prefix[] = "com.sun.star.text.FieldMaster.";
63 static const sal_Char sAPI_input[] = "Input";
64 static const sal_Char sAPI_input_user[] = "InputUser";
65 static const sal_Char sAPI_get_expression[] = "GetExpression";
66 static const sal_Char sAPI_set_expression[] = "SetExpression";
67 static const sal_Char sAPI_user[] = "User";
68 static const sal_Char sAPI_table_formula[] = "TableFormula";
69 static const sal_Char sAPI_database[] = "com.sun.star.text.TextField.Database";
70 static const sal_Char sAPI_fieldmaster_database[] = "com.sun.star.text.FieldMaster.Database";
72 // property names
73 static const sal_Char sAPI_hint[] = "Hint";
74 static const sal_Char sAPI_help[] = "Help";
75 static const sal_Char sAPI_tooltip[] = "Tooltip";
76 static const sal_Char sAPI_content[] = "Content";
77 static const sal_Char sAPI_sub_type[] = "SubType";
78 static const sal_Char sAPI_is_expression[] = "IsExpression";
79 static const sal_Char sAPI_is_input[] = "Input";
80 static const sal_Char sAPI_is_show_formula[] = "IsShowFormula";
81 static const sal_Char sAPI_numbering_type[] = "NumberingType";
82 static const sal_Char sAPI_number_format[] = "NumberFormat";
83 static const sal_Char sAPI_name[] = "Name";
84 static const sal_Char sAPI_numbering_separator[] = "NumberingSeparator";
85 static const sal_Char sAPI_chapter_numbering_level[]= "ChapterNumberingLevel";
86 static const sal_Char sAPI_value[] = "Value";
87 static const sal_Char sAPI_is_visible[] = "IsVisible";
88 static const sal_Char sAPI_variable_subtype[] = "VariableSubtype";
89 static const sal_Char sAPI_data_column_name[] = "DataColumnName";
90 static const sal_Char sAPI_is_data_base_format[] = "DataBaseFormat";
91 static const sal_Char sAPI_current_presentation[] = "CurrentPresentation";
92 static const sal_Char sAPI_sequence_value[] = "SequenceValue";
93 static const sal_Char sAPI_is_fixed_language[] = "IsFixedLanguage";
96 using ::rtl::OUString;
97 using ::rtl::OUStringBuffer;
99 using namespace ::com::sun::star;
100 using namespace ::com::sun::star::uno;
101 using namespace ::com::sun::star::beans;
102 using namespace ::com::sun::star::text;
103 using namespace ::com::sun::star::style;
104 using namespace ::xmloff::token;
109 // XMLVarFieldImportContext: superclass for all variable related fields
112 TYPEINIT1( XMLVarFieldImportContext, XMLTextFieldImportContext );
114 XMLVarFieldImportContext::XMLVarFieldImportContext(
115 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
116 const sal_Char* pServiceName, sal_uInt16 nPrfx,
117 const OUString& rLocalName,
118 sal_Bool bName, sal_Bool bFormula, sal_Bool bFormulaDefault,
119 sal_Bool bDescription, sal_Bool bHelp, sal_Bool bHint, sal_Bool bVisible,
120 sal_Bool bIsDisplayFormula,
121 sal_Bool bType, sal_Bool bStyle, sal_Bool bValue,
122 sal_Bool bPresentation) :
123 XMLTextFieldImportContext(rImport, rHlp, pServiceName, nPrfx, rLocalName),
124 sPropertyContent(sAPI_content),
125 sPropertyHint(sAPI_hint),
126 sPropertyHelp(sAPI_help),
127 sPropertyTooltip(sAPI_tooltip),
128 sPropertyIsVisible(sAPI_is_visible),
129 sPropertyIsDisplayFormula(sAPI_is_show_formula),
130 sPropertyCurrentPresentation(sAPI_current_presentation),
131 aValueHelper(rImport, rHlp, bType, bStyle, bValue, sal_False),
132 bDisplayFormula(sal_False),
133 bDisplayNone(sal_False),
134 bNameOK(sal_False),
135 bFormulaOK(sal_False),
136 bDescriptionOK(sal_False),
137 bHelpOK(sal_False),
138 bHintOK(sal_False),
139 bDisplayOK(sal_False),
140 bSetName(bName),
141 bSetFormula(bFormula),
142 bSetFormulaDefault(bFormulaDefault),
143 bSetDescription(bDescription),
144 bSetHelp(bHelp),
145 bSetHint(bHint),
146 bSetVisible(bVisible),
147 bSetDisplayFormula(bIsDisplayFormula),
148 bSetPresentation(bPresentation)
152 void XMLVarFieldImportContext::ProcessAttribute(
153 sal_uInt16 nAttrToken,
154 const OUString& sAttrValue )
156 switch (nAttrToken)
158 case XML_TOK_TEXTFIELD_NAME:
159 sName = sAttrValue;
160 bNameOK = sal_True;
161 bValid = sal_True; // we assume: field with name is valid!
162 break;
163 case XML_TOK_TEXTFIELD_DESCRIPTION:
164 sDescription = sAttrValue;
165 bDescriptionOK = sal_True;
166 break;
167 case XML_TOK_TEXTFIELD_HELP:
168 sHelp = sAttrValue;
169 bHelpOK = true;
170 break;
171 case XML_TOK_TEXTFIELD_HINT:
172 sHint = sAttrValue;
173 bHintOK = true;
174 break;
175 case XML_TOK_TEXTFIELD_FORMULA:
177 OUString sTmp;
178 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
179 _GetKeyByAttrName( sAttrValue, &sTmp, sal_False );
180 if( XML_NAMESPACE_OOOW == nPrefix )
182 sFormula = sTmp;
183 bFormulaOK = sal_True;
185 else
186 sFormula = sAttrValue;
188 break;
189 case XML_TOK_TEXTFIELD_DISPLAY:
190 if (IsXMLToken(sAttrValue, XML_FORMULA))
192 bDisplayFormula = sal_True;
193 bDisplayNone = sal_False;
194 bDisplayOK = sal_True;
196 else if (IsXMLToken(sAttrValue, XML_VALUE))
198 bDisplayFormula = sal_False;
199 bDisplayNone = sal_False;
200 bDisplayOK = sal_True;
202 else if (IsXMLToken(sAttrValue, XML_NONE))
204 bDisplayFormula = sal_False;
205 bDisplayNone = sal_True;
206 bDisplayOK = sal_True;
207 } // else: no change
208 DBG_ASSERT(!(bDisplayFormula && bDisplayNone),
209 "illegal display values");
210 break;
211 default:
212 // delegate all others to value helper
213 aValueHelper.ProcessAttribute(nAttrToken, sAttrValue);
214 break;
218 void XMLVarFieldImportContext::PrepareField(
219 const Reference<XPropertySet> & xPropertySet)
221 // bSetName: not implemented
223 if (bSetFormula)
225 if (!bFormulaOK && bSetFormulaDefault)
227 sFormula = GetContent();
228 bFormulaOK = sal_True;
231 if (bFormulaOK)
233 Any aAny;
234 aAny <<= sFormula;
235 xPropertySet->setPropertyValue(sPropertyContent, aAny);
239 if (bSetDescription && bDescriptionOK)
241 Any aAny;
242 aAny <<= sDescription;
243 xPropertySet->setPropertyValue(sPropertyHint, aAny);
246 if (bSetHelp && bHelpOK)
248 Any aAny;
249 aAny <<= sHelp;
250 xPropertySet->setPropertyValue(sPropertyHelp, aAny);
253 if (bSetHint && bHintOK)
255 Any aAny;
256 aAny <<= sHint;
257 xPropertySet->setPropertyValue(sPropertyTooltip, aAny);
260 if (bSetVisible && bDisplayOK)
262 Any aAny;
263 sal_Bool bTmp = ! (bDisplayNone && bDisplayOK);
264 aAny.setValue( &bTmp, ::getBooleanCppuType());
265 xPropertySet->setPropertyValue(sPropertyIsVisible, aAny);
268 // workaround for #no-bug#: display formula by default
269 if (xPropertySet->getPropertySetInfo()->
270 hasPropertyByName(sPropertyIsDisplayFormula) &&
271 !bSetDisplayFormula)
273 bDisplayFormula = sal_False;
274 bSetDisplayFormula = sal_True;
278 if (bSetDisplayFormula)
280 Any aAny;
281 sal_Bool bTmp = bDisplayFormula && bDisplayOK;
282 aAny.setValue( &bTmp, ::getBooleanCppuType());
283 xPropertySet->setPropertyValue(sPropertyIsDisplayFormula, aAny);
286 // delegate to value helper
287 aValueHelper.SetDefault(GetContent());
288 aValueHelper.PrepareField(xPropertySet);
290 // finally, set the curren presentation
291 if (bSetPresentation)
293 Any aAny;
294 aAny <<= GetContent();
295 xPropertySet->setPropertyValue(sPropertyCurrentPresentation, aAny);
304 // variable set fields
307 TYPEINIT1( XMLSetVarFieldImportContext, XMLVarFieldImportContext );
309 XMLSetVarFieldImportContext::XMLSetVarFieldImportContext(
310 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
311 const sal_Char* pServiceName, sal_uInt16 nPrfx,
312 const OUString& rLocalName, VarType eVarType,
313 sal_Bool bName, sal_Bool bFormula, sal_Bool bFormulaDefault,
314 sal_Bool bDescription, sal_Bool bHelp, sal_Bool bHint, sal_Bool bVisible, sal_Bool bIsDisplayFormula,
315 sal_Bool bType, sal_Bool bStyle, sal_Bool bValue, sal_Bool bPresentation) :
316 XMLVarFieldImportContext(rImport, rHlp, pServiceName,
317 nPrfx, rLocalName,
318 bName, bFormula, bFormulaDefault,
319 bDescription, bHelp, bHint, bVisible, bIsDisplayFormula,
320 bType, bStyle, bValue, bPresentation),
321 eFieldType(eVarType)
325 void XMLSetVarFieldImportContext::EndElement()
327 // should we call PrepareField on the field, or rather on it's master?
328 // currently: call on field (just like superclass)
329 // possible alternatives: call on master
330 // call field or master depending on variable
331 // PrepareMaster() in addition to PrepareField()
333 DBG_ASSERT(!GetServiceName().isEmpty(), "no service name for element!");
335 if (bValid)
337 DBG_ASSERT(!GetName().isEmpty(), "variable name needed!");
339 // find field master
340 Reference<XPropertySet> xMaster;
341 if (FindFieldMaster(xMaster))
343 // create field/Service
344 Reference<XPropertySet> xPropSet;
345 if (CreateField(xPropSet, OUString(sAPI_textfield_prefix) + GetServiceName()))
347 Reference<XDependentTextField> xDepTextField(xPropSet, UNO_QUERY);
348 if (xDepTextField.is())
350 // attach field to field master
351 xDepTextField->attachTextFieldMaster(xMaster);
353 // attach field to document
354 Reference<XTextContent> xTextContent(xPropSet, UNO_QUERY);
355 if (xTextContent.is())
357 try {
358 // insert, set field properties and exit!
359 GetImportHelper().InsertTextContent(xTextContent);
360 PrepareField(xPropSet);
361 } catch (lang::IllegalArgumentException & /*e*/)
363 // ignore e: #i54023#
365 return;
372 // above: exit on success; so for all error cases we end up here!
373 // write element content
374 GetImportHelper().InsertString(GetContent());
377 sal_Bool XMLSetVarFieldImportContext::FindFieldMaster(
378 Reference<XPropertySet> & xMaster)
380 // currently: delegate to XMLVariableDeclImportContext;
381 // shoud eventually go here
382 return XMLVariableDeclImportContext::FindFieldMaster(xMaster,
383 GetImport(),
384 GetImportHelper(),
385 GetName(),
386 eFieldType);
392 // sequence field
395 TYPEINIT1( XMLSequenceFieldImportContext, XMLSetVarFieldImportContext );
397 XMLSequenceFieldImportContext::XMLSequenceFieldImportContext(
398 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
399 sal_uInt16 nPrfx, const OUString& rLocalName) :
400 XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
401 nPrfx, rLocalName, VarTypeSequence,
402 // name, formula
403 sal_True, sal_True, sal_True,
404 sal_False, sal_False, sal_False, sal_False,
405 sal_False,
406 sal_False, sal_False, sal_False, sal_True),
408 sPropertyNumberFormat(sAPI_number_format),
409 sPropertySequenceValue(sAPI_sequence_value),
410 sNumFormat(OUString::valueOf(sal_Unicode('1'))),
411 sNumFormatSync(GetXMLToken(XML_FALSE)),
412 bRefNameOK(sal_False)
416 void XMLSequenceFieldImportContext::ProcessAttribute(
417 sal_uInt16 nAttrToken, const OUString& sAttrValue )
419 switch (nAttrToken)
421 case XML_TOK_TEXTFIELD_NUM_FORMAT:
422 sNumFormat = sAttrValue;
423 break;
424 case XML_TOK_TEXTFIELD_NUM_LETTER_SYNC:
425 sNumFormatSync = sAttrValue;
426 break;
427 case XML_TOK_TEXTFIELD_REF_NAME:
428 sRefName = sAttrValue;
429 bRefNameOK = sal_True;
430 break;
431 default:
432 // delegate to super class (name, formula)
433 XMLSetVarFieldImportContext::ProcessAttribute(nAttrToken,
434 sAttrValue);
435 break;
436 } // switch
439 void XMLSequenceFieldImportContext::PrepareField(
440 const Reference<XPropertySet> & xPropertySet)
442 // delegate to super class (formula)
443 XMLSetVarFieldImportContext::PrepareField(xPropertySet);
445 // set format
446 sal_Int16 nNumType = NumberingType::ARABIC;
447 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType, sNumFormat, sNumFormatSync );
448 Any aAny;
449 aAny <<= nNumType;
450 xPropertySet->setPropertyValue(sPropertyNumberFormat, aAny);
452 // handle reference name
453 if (bRefNameOK)
455 aAny = xPropertySet->getPropertyValue(sPropertySequenceValue);
456 sal_Int16 nValue = 0;
457 aAny >>= nValue;
458 GetImportHelper().InsertSequenceID(sRefName, GetName(), nValue);
465 // variable set field
468 TYPEINIT1( XMLVariableSetFieldImportContext, XMLSetVarFieldImportContext );
470 XMLVariableSetFieldImportContext::XMLVariableSetFieldImportContext(
471 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
472 sal_uInt16 nPrfx, const OUString& rLocalName) :
473 XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
474 nPrfx, rLocalName, VarTypeSimple,
475 // name, formula, value&type, style,
476 // display none
477 sal_True, sal_True, sal_True,
478 sal_False, sal_False, sal_False,
479 sal_True, sal_False,
480 sal_True, sal_True, sal_True,
481 sal_True),
482 sPropertySubType(sAPI_sub_type)
486 void XMLVariableSetFieldImportContext::PrepareField(
487 const Reference<XPropertySet> & xPropertySet)
489 // set type
490 Any aAny;
491 aAny <<= (IsStringValue()? SetVariableType::STRING : SetVariableType::VAR);
492 xPropertySet->setPropertyValue(sPropertySubType, aAny);
494 // the remainder is handled by super class
495 XMLSetVarFieldImportContext::PrepareField(xPropertySet);
501 // variable input field
504 TYPEINIT1( XMLVariableInputFieldImportContext, XMLSetVarFieldImportContext );
506 XMLVariableInputFieldImportContext::XMLVariableInputFieldImportContext(
507 SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
508 const OUString& rLocalName) :
509 XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
510 nPrfx, rLocalName, VarTypeSimple,
511 // name, description, display none/formula,
512 // value&type, style, formula
513 sal_True, sal_True, sal_True,
514 sal_True, sal_True, sal_True,
515 sal_True, sal_False,
516 sal_True, sal_True, sal_True,
517 sal_True),
518 sPropertySubType(sAPI_sub_type),
519 sPropertyIsInput(sAPI_is_input)
523 void XMLVariableInputFieldImportContext::PrepareField(
524 const Reference<XPropertySet> & xPropertySet)
526 // set type (input field)
527 Any aAny;
528 sal_Bool bTrue = sal_True;
529 aAny.setValue( &bTrue, ::getBooleanCppuType() );
530 xPropertySet->setPropertyValue(sPropertyIsInput, aAny);
532 // set type
533 aAny <<= (IsStringValue()? SetVariableType::STRING : SetVariableType::VAR);
534 xPropertySet->setPropertyValue(sPropertySubType, aAny);
536 // the remainder is handled by super class
537 XMLSetVarFieldImportContext::PrepareField(xPropertySet);
543 // user field
546 TYPEINIT1( XMLUserFieldImportContext, XMLSetVarFieldImportContext );
548 XMLUserFieldImportContext::XMLUserFieldImportContext(
549 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
550 sal_uInt16 nPrfx, const OUString& rLocalName) :
551 XMLSetVarFieldImportContext(rImport, rHlp, sAPI_user, nPrfx,
552 rLocalName, VarTypeUserField,
553 // name, display none/formula, style
554 sal_True, sal_False, sal_False,
555 sal_False, sal_False, sal_False, sal_True,
556 sal_True,
557 sal_False, sal_True, sal_False,
558 sal_False)
565 // user input field
568 TYPEINIT1( XMLUserFieldInputImportContext, XMLVarFieldImportContext );
570 // bug: doesn't work (SO API lacking)
571 XMLUserFieldInputImportContext::XMLUserFieldInputImportContext(
572 SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
573 const OUString& rLocalName) :
574 XMLVarFieldImportContext(rImport, rHlp, sAPI_input_user,
575 nPrfx, rLocalName,
576 // name, description, style
577 sal_True, sal_False, sal_False,
578 sal_True, sal_False, sal_False,
579 sal_False, sal_False,
580 sal_False /*???*/, sal_True, sal_False,
581 sal_False)
585 void XMLUserFieldInputImportContext::PrepareField(
586 const Reference<XPropertySet> & xPropertySet)
588 Any aAny;
589 aAny <<= GetName();
590 xPropertySet->setPropertyValue(sPropertyContent, aAny);
592 // delegate to super class
593 XMLVarFieldImportContext::PrepareField(xPropertySet);
598 // variable get field
601 TYPEINIT1( XMLVariableGetFieldImportContext, XMLVarFieldImportContext );
603 XMLVariableGetFieldImportContext::XMLVariableGetFieldImportContext(
604 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
605 sal_uInt16 nPrfx, const OUString& rLocalName) :
606 XMLVarFieldImportContext(rImport, rHlp, sAPI_get_expression,
607 nPrfx, rLocalName,
608 // name, style, display formula
609 sal_True, sal_False, sal_False,
610 sal_False, sal_False, sal_False,
611 sal_False, sal_True,
612 sal_True, sal_True, sal_False,
613 sal_True),
614 sPropertySubType(sAPI_sub_type)
618 void XMLVariableGetFieldImportContext::PrepareField(
619 const Reference<XPropertySet> & xPropertySet)
621 // set name
622 Any aAny;
623 aAny <<= GetName();
624 xPropertySet->setPropertyValue(sPropertyContent, aAny);
626 // the remainder is handled by super class
627 XMLVarFieldImportContext::PrepareField(xPropertySet);
633 // expression field
636 TYPEINIT1( XMLExpressionFieldImportContext, XMLVarFieldImportContext );
638 XMLExpressionFieldImportContext::XMLExpressionFieldImportContext(
639 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
640 sal_uInt16 nPrfx, const OUString& rLocalName) :
641 XMLVarFieldImportContext(rImport, rHlp, sAPI_get_expression,
642 nPrfx, rLocalName,
643 // formula, type, style, display formula
644 sal_False, sal_True, sal_True,
645 sal_False, sal_False, sal_False,
646 sal_False, sal_True,
647 sal_True, sal_True, sal_False,
648 sal_True),
649 sPropertySubType(sAPI_sub_type)
651 bValid = sal_True; // always valid
655 void XMLExpressionFieldImportContext::PrepareField(
656 const Reference<XPropertySet> & xPropertySet)
658 sal_Int16 nSubType = SetVariableType::FORMULA;
659 Any aAny;
660 aAny <<= nSubType;
661 xPropertySet->setPropertyValue(sPropertySubType, aAny);
663 // delegate to super class
664 XMLVarFieldImportContext::PrepareField(xPropertySet);
670 // text input field
673 TYPEINIT1( XMLTextInputFieldImportContext, XMLVarFieldImportContext );
675 XMLTextInputFieldImportContext::XMLTextInputFieldImportContext(
676 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
677 sal_uInt16 nPrfx, const OUString& sLocalName) :
678 XMLVarFieldImportContext(rImport, rHlp, sAPI_input,
679 nPrfx, sLocalName,
680 // description
681 sal_False, sal_False, sal_False,
682 sal_True, sal_True, sal_True,
683 sal_False, sal_False,
684 sal_False, sal_False, sal_False,
685 sal_False),
686 sPropertyContent(sAPI_content)
688 bValid = sal_True; // always valid
691 void XMLTextInputFieldImportContext::PrepareField(
692 const Reference<XPropertySet> & xPropertySet)
694 XMLVarFieldImportContext::PrepareField(xPropertySet);
696 Any aAny;
697 aAny <<= GetContent();
698 xPropertySet->setPropertyValue(sPropertyContent, aAny);
703 // table formula field
706 TYPEINIT1( XMLTableFormulaImportContext, XMLTextFieldImportContext );
708 XMLTableFormulaImportContext::XMLTableFormulaImportContext(
709 SvXMLImport& rImport,
710 XMLTextImportHelper& rHlp,
711 sal_uInt16 nPrfx,
712 const OUString& rLocalName) :
713 XMLTextFieldImportContext(rImport, rHlp, sAPI_table_formula,
714 nPrfx, rLocalName),
715 sPropertyIsShowFormula("IsShowFormula"),
716 sPropertyCurrentPresentation(
717 "CurrentPresentation"),
718 aValueHelper(rImport, rHlp, sal_False, sal_True, sal_False, sal_True),
719 sFormula(),
720 bIsShowFormula(sal_False)
724 XMLTableFormulaImportContext::~XMLTableFormulaImportContext()
728 void XMLTableFormulaImportContext::ProcessAttribute(
729 sal_uInt16 nAttrToken,
730 const OUString& sAttrValue )
732 switch (nAttrToken)
734 case XML_TOK_TEXTFIELD_FORMULA:
735 aValueHelper.ProcessAttribute( nAttrToken, sAttrValue );
736 bValid = sal_True; // we need a formula!
737 break;
739 case XML_TOK_TEXTFIELD_DATA_STYLE_NAME:
740 aValueHelper.ProcessAttribute( nAttrToken, sAttrValue );
741 break;
742 case XML_TOK_TEXTFIELD_DISPLAY:
743 if ( sAttrValue == "formula" )
744 bIsShowFormula = sal_True;
745 break;
746 default:
747 // unknown attribute -> ignore
748 break;
752 void XMLTableFormulaImportContext::PrepareField(
753 const Reference<XPropertySet> & xPropertySet)
755 // set format and formula
756 aValueHelper.PrepareField( xPropertySet );
758 Any aAny;
760 // set 'show formula' and presentation
761 aAny.setValue( &bIsShowFormula, ::getBooleanCppuType() );
762 xPropertySet->setPropertyValue( sPropertyIsShowFormula, aAny );
764 aAny <<= GetContent();
765 xPropertySet->setPropertyValue( sPropertyCurrentPresentation, aAny );
771 // variable declarations
773 // Should be adapted to XMLVarField-/XMLSetVarFieldImportContext scheme!
779 // declaration containter import (<variable/user-field/sequence-decls>)
782 TYPEINIT1( XMLVariableDeclsImportContext, SvXMLImportContext );
784 XMLVariableDeclsImportContext::XMLVariableDeclsImportContext(
785 SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
786 const OUString& rLocalName, enum VarType eVarType) :
787 SvXMLImportContext(rImport, nPrfx, rLocalName),
788 eVarDeclsContextType(eVarType),
789 rImportHelper(rHlp)
793 SvXMLImportContext* XMLVariableDeclsImportContext::CreateChildContext(
794 sal_uInt16 nPrefix, const OUString& rLocalName,
795 const Reference<xml::sax::XAttributeList> & xAttrList )
797 enum XMLTokenEnum eElementName;
798 SvXMLImportContext* pImportContext = NULL;
800 if( XML_NAMESPACE_TEXT == nPrefix )
802 switch (eVarDeclsContextType)
804 case VarTypeSequence:
805 eElementName = XML_SEQUENCE_DECL;
806 break;
807 case VarTypeSimple:
808 eElementName = XML_VARIABLE_DECL;
809 break;
810 case VarTypeUserField:
811 eElementName = XML_USER_FIELD_DECL;
812 break;
813 default:
814 OSL_FAIL("unknown field type!");
815 eElementName = XML_SEQUENCE_DECL;
816 break;
819 if( IsXMLToken( rLocalName, eElementName ) )
821 pImportContext = new XMLVariableDeclImportContext(
822 GetImport(), rImportHelper, nPrefix, rLocalName, xAttrList,
823 eVarDeclsContextType);
827 // if no context was created, use default context
828 if (NULL == pImportContext) {
829 pImportContext = SvXMLImportContext::CreateChildContext(nPrefix,
830 rLocalName,
831 xAttrList);
834 return pImportContext;
840 // declaration import (<variable/user-field/sequence-decl> elements)
843 TYPEINIT1( XMLVariableDeclImportContext, SvXMLImportContext );
845 XMLVariableDeclImportContext::XMLVariableDeclImportContext(
846 SvXMLImport& rImport, XMLTextImportHelper& rHlp,
847 sal_uInt16 nPrfx, const OUString& rLocalName,
848 const Reference<xml::sax::XAttributeList> & xAttrList,
849 enum VarType eVarType) :
850 SvXMLImportContext(rImport, nPrfx, rLocalName),
851 // bug?? which properties for userfield/userfieldmaster
852 sPropertyName(sAPI_name),
853 sPropertySubType(sAPI_sub_type),
854 sPropertyNumberingLevel(sAPI_chapter_numbering_level),
855 sPropertyNumberingSeparator(sAPI_numbering_separator),
856 sPropertyIsExpression(sAPI_is_expression),
857 aValueHelper(rImport, rHlp, sal_True, sal_False, sal_True, sal_False),
858 nNumLevel(-1), cSeparationChar('.')
860 if ( (XML_NAMESPACE_TEXT == nPrfx) &&
861 ( ( IsXMLToken( rLocalName, XML_SEQUENCE_DECL )) ||
862 ( IsXMLToken( rLocalName, XML_VARIABLE_DECL)) ||
863 ( IsXMLToken( rLocalName, XML_USER_FIELD_DECL)) )) {
865 // TODO: check validity (need name!)
867 // parse attributes
868 sal_Int16 nLength = xAttrList->getLength();
869 for(sal_Int16 i=0; i<nLength; i++) {
871 OUString sLocalName;
872 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
873 GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
875 sal_uInt16 nToken = rHlp.
876 GetTextFieldAttrTokenMap().Get(nPrefix, sLocalName);
878 switch (nToken)
880 case XML_TOK_TEXTFIELD_NAME:
881 sName = xAttrList->getValueByIndex(i);
882 break;
883 case XML_TOK_TEXTFIELD_NUMBERING_LEVEL:
885 sal_Int32 nLevel;
886 bool const bRet = ::sax::Converter::convertNumber(
887 nLevel, xAttrList->getValueByIndex(i), 0,
888 GetImport().GetTextImport()->GetChapterNumbering()->
889 getCount());
890 if (bRet)
892 nNumLevel = static_cast< sal_Int8 >( nLevel-1 ); // API numbers -1..9
894 break;
896 case XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR:
897 cSeparationChar =
898 (sal_Char)xAttrList->getValueByIndex(i).toChar();
899 break;
901 default:
902 // delegate to value helper
903 aValueHelper.ProcessAttribute(nToken,
904 xAttrList->getValueByIndex(i));
905 break;
909 Reference<XPropertySet> xFieldMaster;
910 if (FindFieldMaster(xFieldMaster, GetImport(), rHlp,
911 sName, eVarType))
913 // now we have a field master: process attributes!
914 Any aAny;
916 switch (eVarType)
918 case VarTypeSequence:
919 aAny <<= nNumLevel;
920 xFieldMaster->setPropertyValue(sPropertyNumberingLevel, aAny);
922 if (nNumLevel >= 0)
924 OUString sStr(&cSeparationChar, 1);
925 aAny <<= sStr;
926 xFieldMaster->setPropertyValue(
927 sPropertyNumberingSeparator, aAny);
929 break;
930 case VarTypeSimple:
932 // set string or non-string SubType (#93192#)
933 // The SubType was already set in the FindFieldMaster
934 // method, but it needs to be adjusted if it's a string.
935 aAny <<= aValueHelper.IsStringValue()
936 ? SetVariableType::STRING : SetVariableType::VAR;
937 xFieldMaster->setPropertyValue(sPropertySubType, aAny);
939 break;
940 case VarTypeUserField:
942 sal_Bool bTmp = !aValueHelper.IsStringValue();
943 aAny.setValue(&bTmp, ::getBooleanCppuType());
944 xFieldMaster->setPropertyValue(sPropertyIsExpression, aAny);
945 aValueHelper.PrepareField(xFieldMaster);
946 break;
948 default:
949 OSL_FAIL("unkown varfield type");
950 } // switch
951 } // else: no field master found/constructed
952 } // else: no sequence-decl
957 sal_Bool XMLVariableDeclImportContext::FindFieldMaster(
958 Reference<XPropertySet> & xMaster, SvXMLImport& rImport,
959 XMLTextImportHelper& rImportHelper,
960 const OUString& sVarName, enum VarType eVarType)
962 static sal_Int32 nCollisionCount = 0;
964 // rename field
965 // currently: no family in use! Use 0.
966 OUString sName = rImportHelper.GetRenameMap().Get(
967 sal::static_int_cast< sal_uInt16 >(eVarType), sVarName);
969 // get text fields supplier and field masters
970 Reference<XTextFieldsSupplier> xTextFieldsSupp(rImport.GetModel(),
971 UNO_QUERY);
972 Reference<container::XNameAccess> xFieldMasterNameAccess(
973 xTextFieldsSupp->getTextFieldMasters(), UNO_QUERY);
975 OUStringBuffer sBuffer;
976 sBuffer.appendAscii(sAPI_fieldmaster_prefix);
977 sBuffer.appendAscii(sAPI_set_expression);
978 sBuffer.appendAscii(".");
979 sBuffer.append(sName);
980 OUString sVarServiceName = sBuffer.makeStringAndClear();
982 sBuffer.appendAscii(sAPI_fieldmaster_prefix);
983 sBuffer.appendAscii(sAPI_user);
984 sBuffer.appendAscii(".");
985 sBuffer.append(sName);
986 OUString sUserServiceName = sBuffer.makeStringAndClear();
988 if (xFieldMasterNameAccess->hasByName(sVarServiceName)) {
989 // variable field master already in document
991 Any aAny = xFieldMasterNameAccess->getByName(sVarServiceName);
992 aAny >>= xMaster;
994 aAny = xMaster->getPropertyValue(
995 // sPropertySubType
996 OUString(sAPI_sub_type)
998 sal_Int16 nType = 0;
999 aAny >>= nType;
1001 enum VarType eFMVarType =
1002 (SetVariableType::SEQUENCE == nType) ?
1003 VarTypeSequence : VarTypeSimple;
1005 if (eFMVarType != eVarType)
1007 OUString sNew;
1009 // FIXME! cant find if name is taken already!!!!
1011 nCollisionCount++;
1012 OUStringBuffer aBuf;
1013 aBuf.append(sName);
1014 aBuf.appendAscii("_renamed_");
1015 aBuf.append(nCollisionCount);
1016 sNew = aBuf.makeStringAndClear();
1018 rImportHelper.GetRenameMap().Add(
1019 sal::static_int_cast< sal_uInt16 >(eVarType), sName, sNew);
1021 // call FindFieldMaster recursively to create new master
1022 return FindFieldMaster(xMaster, rImport, rImportHelper,
1023 sNew, eVarType);
1025 } else if (xFieldMasterNameAccess->hasByName(sUserServiceName)) {
1026 // user field: get field master
1027 Any aAny = xFieldMasterNameAccess->getByName(sUserServiceName);
1028 aAny >>= xMaster;
1030 if (VarTypeUserField != eVarType) {
1031 // find new name that is not taken
1032 OUString sNew;
1034 // FIXME! cant find if name is taken already!!!!
1036 nCollisionCount++;
1037 OUStringBuffer aBuf;
1038 aBuf.append(sName);
1039 aBuf.appendAscii("_renamed_");
1040 aBuf.append(nCollisionCount);
1041 sNew = aBuf.makeStringAndClear();
1043 rImportHelper.GetRenameMap().Add(
1044 sal::static_int_cast< sal_uInt16 >(eVarType), sName, sNew);
1046 // call FindFieldMaster recursively to create new master
1047 return FindFieldMaster(xMaster, rImport, rImportHelper,
1048 sNew, eVarType);
1050 } else {
1051 // field name not used: create field master
1053 // import -> model is MultiServiceFactory -> createInstance
1054 Reference<lang::XMultiServiceFactory>
1055 xFactory(rImport.GetModel(),UNO_QUERY);
1056 if( xFactory.is() ) {
1058 OUStringBuffer sService;
1059 sService.appendAscii(sAPI_fieldmaster_prefix);
1060 sService.appendAscii((eVarType==VarTypeUserField) ?
1061 sAPI_user : sAPI_set_expression);
1062 Reference<XInterface> xIfc =
1063 xFactory->createInstance( sService.makeStringAndClear() );
1064 if (xIfc.is()) {
1065 Reference<XPropertySet> xTmp( xIfc, UNO_QUERY );
1066 xMaster = xTmp;
1068 // set name
1069 Any aAny;
1070 aAny <<= sName;
1071 xMaster->setPropertyValue(
1072 // sPropertyName
1073 OUString(sAPI_name)
1074 , aAny);
1076 if (eVarType != VarTypeUserField) {
1077 // set subtype for setexp field
1079 aAny <<= ((eVarType == VarTypeSimple) ?
1080 SetVariableType::VAR :
1081 SetVariableType::SEQUENCE);
1082 xMaster->setPropertyValue(
1083 // sPropertySubType
1084 OUString(sAPI_sub_type)
1085 , aAny);
1086 } // else : user field: no subtype
1088 } else {
1089 return sal_False;
1091 } else {
1092 return sal_False;
1096 DBG_ASSERT(xMaster.is(), "no field master found!?!");
1097 return sal_True;
1102 // Database Display field import
1106 TYPEINIT1( XMLDatabaseDisplayImportContext, XMLDatabaseFieldImportContext );
1108 XMLDatabaseDisplayImportContext::XMLDatabaseDisplayImportContext(
1109 SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_uInt16 nPrfx,
1110 const OUString& rLocalName) :
1111 XMLDatabaseFieldImportContext(rImport, rHlp, sAPI_database,
1112 nPrfx, rLocalName, false),
1113 sPropertyColumnName(sAPI_data_column_name),
1114 sPropertyDatabaseFormat(sAPI_is_data_base_format),
1115 sPropertyCurrentPresentation(sAPI_current_presentation),
1116 sPropertyIsVisible(sAPI_is_visible),
1117 aValueHelper(rImport, rHlp, sal_False, sal_True, sal_False, sal_False),
1118 bColumnOK(sal_False),
1119 bDisplay( sal_True ),
1120 bDisplayOK( sal_False )
1124 void XMLDatabaseDisplayImportContext::ProcessAttribute(
1125 sal_uInt16 nAttrToken, const OUString& sAttrValue )
1127 switch (nAttrToken)
1129 case XML_TOK_TEXTFIELD_COLUMN_NAME:
1130 sColumnName = sAttrValue;
1131 bColumnOK = sal_True;
1132 break;
1133 case XML_TOK_TEXTFIELD_DISPLAY:
1135 sal_Bool bNone = IsXMLToken( sAttrValue, XML_NONE );
1136 sal_Bool bValue = IsXMLToken( sAttrValue, XML_VALUE );
1137 bDisplay = bValue;
1138 bDisplayOK = bNone || bValue;
1140 break;
1141 case XML_TOK_TEXTFIELD_DATABASE_NAME:
1142 case XML_TOK_TEXTFIELD_TABLE_NAME:
1143 case XML_TOK_TEXTFIELD_TABLE_TYPE:
1144 // handled by super class
1145 XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken,
1146 sAttrValue);
1147 break;
1148 default:
1149 // remainder handled by value helper
1150 aValueHelper.ProcessAttribute(nAttrToken, sAttrValue);
1151 break;
1154 bValid = bTableOK && bDatabaseOK && bColumnOK;
1157 void XMLDatabaseDisplayImportContext::EndElement()
1159 // we have an EndElement of our own, because database fields need
1160 // to be attached to a field master before they can be inserted into
1161 // the document. Database stuff (database, table, column) all goes
1162 // to the field master, value & style go to the field.
1164 if (bValid)
1167 // so here goes: we start with the master
1168 Reference<XPropertySet> xMaster;
1170 // create and prepare field master first
1171 if (CreateField(xMaster,
1172 OUString(
1173 sAPI_fieldmaster_database)))
1175 Any aAny;
1176 aAny <<= sColumnName;
1177 xMaster->setPropertyValue(sPropertyColumnName, aAny);
1179 // fieldmaster takes database, table and column name
1180 XMLDatabaseFieldImportContext::PrepareField(xMaster);
1182 // create field
1183 Reference<XPropertySet> xField;
1184 if (CreateField(xField,
1185 OUString(
1186 sAPI_database)))
1188 // attach field master
1189 Reference<XDependentTextField> xDepField(xField, UNO_QUERY);
1190 if (xDepField.is())
1192 // attach field to field master
1193 xDepField->attachTextFieldMaster(xMaster);
1195 // attach field to document
1196 Reference<XTextContent> xTextContent(xField, UNO_QUERY);
1197 if (xTextContent.is())
1199 // insert, set field properties and exit!
1200 GetImportHelper().InsertTextContent(xTextContent);
1202 // prepare field: format from database?
1203 sal_Bool bTmp = !aValueHelper.IsFormatOK();
1204 aAny.setValue( &bTmp, ::getBooleanCppuType() );
1205 xField->setPropertyValue(sPropertyDatabaseFormat,aAny);
1207 // value, value-type and format done by value helper
1208 aValueHelper.PrepareField(xField);
1210 // visibility
1211 if( bDisplayOK )
1213 aAny.setValue( &bDisplay, ::getBooleanCppuType() );
1214 xField->setPropertyValue(sPropertyIsVisible, aAny);
1217 // set presentation
1218 aAny <<= GetContent();
1219 xField->setPropertyValue(sPropertyCurrentPresentation,
1220 aAny);
1222 // success!
1223 return;
1230 // above: exit on success; so for all error cases we end up here!
1231 // write element content
1232 GetImportHelper().InsertString(GetContent());
1237 // value import helper
1240 enum ValueType
1242 XML_VALUE_TYPE_STRING,
1243 XML_VALUE_TYPE_FLOAT,
1244 XML_VALUE_TYPE_CURRENCY,
1245 XML_VALUE_TYPE_PERCENTAGE,
1246 XML_VALUE_TYPE_DATE,
1247 XML_VALUE_TYPE_TIME,
1248 XML_VALUE_TYPE_BOOLEAN
1251 static SvXMLEnumMapEntry const aValueTypeMap[] =
1253 { XML_FLOAT, XML_VALUE_TYPE_FLOAT },
1254 { XML_CURRENCY, XML_VALUE_TYPE_CURRENCY },
1255 { XML_PERCENTAGE, XML_VALUE_TYPE_PERCENTAGE },
1256 { XML_DATE, XML_VALUE_TYPE_DATE },
1257 { XML_TIME, XML_VALUE_TYPE_TIME },
1258 { XML_BOOLEAN, XML_VALUE_TYPE_BOOLEAN },
1259 { XML_STRING, XML_VALUE_TYPE_STRING },
1260 { XML_TOKEN_INVALID, 0 }
1263 XMLValueImportHelper::XMLValueImportHelper(
1264 SvXMLImport& rImprt,
1265 XMLTextImportHelper& rHlp,
1266 sal_Bool bType, sal_Bool bStyle, sal_Bool bValue, sal_Bool bFormula) :
1267 sPropertyContent(sAPI_content),
1268 sPropertyValue(sAPI_value),
1269 sPropertyNumberFormat(sAPI_number_format),
1270 sPropertyIsFixedLanguage(sAPI_is_fixed_language),
1272 rImport(rImprt),
1273 rHelper(rHlp),
1275 fValue(0.0),
1276 nFormatKey(0),
1277 bIsDefaultLanguage(sal_True),
1279 bStringType(sal_False),
1280 bFormatOK(sal_False),
1281 bTypeOK(sal_False),
1282 bStringValueOK(sal_False),
1283 bFloatValueOK(sal_False),
1284 bFormulaOK(sal_False),
1286 bSetType(bType),
1287 bSetValue(bValue),
1288 bSetStyle(bStyle),
1289 bSetFormula(bFormula),
1291 bStringDefault(sal_True),
1292 bFormulaDefault(sal_True)
1296 XMLValueImportHelper::~XMLValueImportHelper()
1300 void XMLValueImportHelper::ProcessAttribute(
1301 sal_uInt16 nAttrToken, const OUString& sAttrValue )
1303 switch (nAttrToken)
1305 case XML_TOK_TEXTFIELD_VALUE_TYPE:
1307 // convert enum
1308 sal_uInt16 nTmp = 0;
1309 sal_Bool bRet = SvXMLUnitConverter::convertEnum(
1310 nTmp, sAttrValue, aValueTypeMap);
1312 if (bRet) {
1313 ValueType eValueType = (ValueType)nTmp;
1315 bTypeOK = sal_True;
1317 switch (eValueType)
1319 case XML_VALUE_TYPE_STRING:
1320 bStringType = sal_True;
1321 break;
1322 case XML_VALUE_TYPE_FLOAT:
1323 case XML_VALUE_TYPE_CURRENCY:
1324 case XML_VALUE_TYPE_PERCENTAGE:
1325 case XML_VALUE_TYPE_DATE:
1326 case XML_VALUE_TYPE_TIME:
1327 case XML_VALUE_TYPE_BOOLEAN:
1328 bStringType = sal_False;
1329 break;
1331 default:
1332 OSL_FAIL("unknown value type");
1333 bTypeOK = sal_False;
1336 break;
1339 case XML_TOK_TEXTFIELD_VALUE:
1341 double fTmp;
1342 bool const bRet = ::sax::Converter::convertDouble(fTmp,sAttrValue);
1343 if (bRet) {
1344 bFloatValueOK = sal_True;
1345 fValue = fTmp;
1347 break;
1350 case XML_TOK_TEXTFIELD_TIME_VALUE:
1352 double fTmp;
1353 bool const bRet =
1354 ::sax::Converter::convertDuration(fTmp, sAttrValue);
1355 if (bRet) {
1356 bFloatValueOK = sal_True;
1357 fValue = fTmp;
1359 break;
1362 case XML_TOK_TEXTFIELD_DATE_VALUE:
1364 double fTmp;
1365 sal_Bool bRet = rImport.GetMM100UnitConverter().
1366 convertDateTime(fTmp,sAttrValue);
1367 if (bRet) {
1368 bFloatValueOK = sal_True;
1369 fValue = fTmp;
1371 break;
1374 case XML_TOK_TEXTFIELD_BOOL_VALUE:
1376 bool bTmp(false);
1377 bool bRet = ::sax::Converter::convertBool(bTmp, sAttrValue);
1378 if (bRet) {
1379 bFloatValueOK = sal_True;
1380 fValue = (bTmp ? 1.0 : 0.0);
1382 else
1384 double fTmp;
1385 bRet = ::sax::Converter::convertDouble(fTmp, sAttrValue);
1386 if (bRet) {
1387 bFloatValueOK = sal_True;
1388 fValue = fTmp;
1391 break;
1394 case XML_TOK_TEXTFIELD_STRING_VALUE:
1395 sValue = sAttrValue;
1396 bStringValueOK = sal_True;
1397 break;
1399 case XML_TOK_TEXTFIELD_FORMULA:
1401 OUString sTmp;
1402 sal_uInt16 nPrefix = rImport.GetNamespaceMap().
1403 _GetKeyByAttrName( sAttrValue, &sTmp, sal_False );
1404 if( XML_NAMESPACE_OOOW == nPrefix )
1406 sFormula = sTmp;
1407 bFormulaOK = sal_True;
1409 else
1410 sFormula = sAttrValue;
1412 break;
1414 case XML_TOK_TEXTFIELD_DATA_STYLE_NAME:
1416 sal_Int32 nKey = rHelper.GetDataStyleKey(
1417 sAttrValue, &bIsDefaultLanguage);
1418 if (-1 != nKey)
1420 nFormatKey = nKey;
1421 bFormatOK = sal_True;
1423 break;
1425 } // switch
1428 void XMLValueImportHelper::PrepareField(
1429 const Reference<XPropertySet> & xPropertySet)
1431 Any aAny;
1433 if (bSetType)
1435 // ??? how to set type?
1438 if (bSetFormula)
1440 aAny <<= (!bFormulaOK && bFormulaDefault) ? sDefault : sFormula;
1441 xPropertySet->setPropertyValue(sPropertyContent, aAny);
1444 // format/style
1445 if (bSetStyle && bFormatOK)
1447 aAny <<= nFormatKey;
1448 xPropertySet->setPropertyValue(sPropertyNumberFormat, aAny);
1450 if( xPropertySet->getPropertySetInfo()->
1451 hasPropertyByName( sPropertyIsFixedLanguage ) )
1453 sal_Bool bIsFixedLanguage = ! bIsDefaultLanguage;
1454 aAny.setValue( &bIsFixedLanguage, ::getBooleanCppuType() );
1455 xPropertySet->setPropertyValue( sPropertyIsFixedLanguage, aAny );
1459 // value: string or float
1460 if (bSetValue)
1462 if (bStringType)
1464 aAny <<= (!bStringValueOK && bStringDefault) ? sDefault : sValue;
1465 xPropertySet->setPropertyValue(sPropertyContent, aAny);
1467 else
1469 aAny <<= fValue;
1470 xPropertySet->setPropertyValue(sPropertyValue, aAny);
1475 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */