Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/text/txtvfldi.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
21
/** @#file
22
 *
23
 *  export of all variable related text fields (and database display field)
24
 */
25
#include <txtvfldi.hxx>
26
#include <xmloff/xmltoken.hxx>
27
#include <xmloff/txtimp.hxx>
28
#include <xmloff/xmlnamespace.hxx>
29
#include <xmloff/namespacemap.hxx>
30
#include <xmloff/i18nmap.hxx>
31
#include <xmloff/xmlimp.hxx>
32
#include <xmloff/xmluconv.hxx>
33
#include <xmloff/xmlement.hxx>
34
#include <com/sun/star/frame/XModel.hpp>
35
#include <com/sun/star/text/SetVariableType.hpp>
36
#include <com/sun/star/text/XDependentTextField.hpp>
37
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
38
#include <com/sun/star/beans/XPropertySet.hpp>
39
#include <com/sun/star/beans/XPropertySetInfo.hpp>
40
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
41
#include <com/sun/star/style/NumberingType.hpp>
42
#include <com/sun/star/container/XIndexReplace.hpp>
43
44
#include <sax/tools/converter.hxx>
45
46
#include <rtl/ustring.hxx>
47
#include <osl/diagnose.h>
48
#include <sal/log.hxx>
49
50
#include <tools/debug.hxx>
51
#include <comphelper/diagnose_ex.hxx>
52
53
54
// service names
55
constexpr char16_t sAPI_fieldmaster_prefix[] = u"com.sun.star.text.FieldMaster.";
56
constexpr OUString sAPI_get_expression = u"GetExpression"_ustr;
57
constexpr OUString sAPI_set_expression = u"SetExpression"_ustr;
58
constexpr OUString sAPI_user      = u"User"_ustr;
59
constexpr OUString sAPI_database  = u"com.sun.star.text.TextField.Database"_ustr;
60
61
// property names
62
constexpr OUString sAPI_content   = u"Content"_ustr;
63
constexpr OUString sAPI_sub_type  = u"SubType"_ustr;
64
constexpr OUString sAPI_number_format = u"NumberFormat"_ustr;
65
constexpr OUString sAPI_is_visible = u"IsVisible"_ustr;
66
constexpr OUString sAPI_current_presentation = u"CurrentPresentation"_ustr;
67
68
69
using namespace ::com::sun::star;
70
using namespace ::com::sun::star::uno;
71
using namespace ::com::sun::star::beans;
72
using namespace ::com::sun::star::text;
73
using namespace ::com::sun::star::style;
74
using namespace ::xmloff::token;
75
76
77
// XMLVarFieldImportContext: superclass for all variable related fields
78
79
80
XMLVarFieldImportContext::XMLVarFieldImportContext(
81
    SvXMLImport& rImport, XMLTextImportHelper& rHlp,
82
    const OUString& pServiceName,
83
    bool bFormula, bool bFormulaDefault,
84
    bool bDescription, bool bHelp, bool bHint, bool bVisible,
85
    bool bIsDisplayFormula,
86
    bool bType, bool bStyle, bool bValue,
87
    bool bPresentation) :
88
556
        XMLTextFieldImportContext(rImport, rHlp, pServiceName),
89
556
        aValueHelper(rImport, rHlp, bType, bStyle, bValue, false),
90
556
        bDisplayFormula(false),
91
556
        bDisplayNone(false),
92
556
        bFormulaOK(false),
93
556
        bDescriptionOK(false),
94
556
        bHelpOK(false),
95
556
        bHintOK(false),
96
556
        bDisplayOK(false),
97
556
        bSetFormula(bFormula),
98
556
        bSetFormulaDefault(bFormulaDefault),
99
556
        bSetDescription(bDescription),
100
556
        bSetHelp(bHelp),
101
556
        bSetHint(bHint),
102
556
        bSetVisible(bVisible),
103
556
        bSetDisplayFormula(bIsDisplayFormula),
104
556
        bSetPresentation(bPresentation)
105
556
{
106
556
}
107
108
void XMLVarFieldImportContext::ProcessAttribute(
109
    sal_Int32 nAttrToken,
110
    std::string_view sAttrValue )
111
1.08k
{
112
1.08k
    switch (nAttrToken)
113
1.08k
    {
114
537
        case XML_ELEMENT(TEXT, XML_NAME):
115
537
            sName = OUString::fromUtf8(sAttrValue);
116
537
            bValid = true;      // we assume: field with name is valid!
117
537
            break;
118
0
        case XML_ELEMENT(TEXT, XML_DESCRIPTION):
119
0
            sDescription = OUString::fromUtf8(sAttrValue);
120
0
            bDescriptionOK = true;
121
0
            break;
122
0
        case XML_ELEMENT(TEXT, XML_HELP):
123
0
            sHelp = OUString::fromUtf8(sAttrValue);
124
0
            bHelpOK = true;
125
0
            break;
126
0
        case XML_ELEMENT(TEXT, XML_HINT):
127
0
            sHint = OUString::fromUtf8(sAttrValue);
128
0
            bHintOK = true;
129
0
            break;
130
547
        case XML_ELEMENT(TEXT, XML_FORMULA):
131
547
            {
132
547
                OUString sTmp;
133
547
                sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
134
547
                        GetKeyByAttrValueQName(OUString::fromUtf8(sAttrValue), &sTmp);
135
547
                if( XML_NAMESPACE_OOOW == nPrefix )
136
455
                {
137
455
                    sFormula = sTmp;
138
455
                    bFormulaOK = true;
139
455
                }
140
92
                else
141
92
                    sFormula = OUString::fromUtf8(sAttrValue);
142
547
            }
143
547
            break;
144
0
        case XML_ELEMENT(TEXT, XML_DISPLAY):
145
0
            if (IsXMLToken(sAttrValue, XML_FORMULA))
146
0
            {
147
0
                bDisplayFormula = true;
148
0
                bDisplayNone = false;
149
0
                bDisplayOK = true;
150
0
            }
151
0
            else if (IsXMLToken(sAttrValue, XML_VALUE))
152
0
            {
153
0
                bDisplayFormula = false;
154
0
                bDisplayNone = false;
155
0
                bDisplayOK = true;
156
0
            }
157
0
            else if (IsXMLToken(sAttrValue, XML_NONE))
158
0
            {
159
0
                bDisplayFormula = false;
160
0
                bDisplayNone = true;
161
0
                bDisplayOK = true;
162
0
            } // else: no change
163
0
            DBG_ASSERT(!(bDisplayFormula && bDisplayNone),
164
0
                       "illegal display values");
165
0
            break;
166
0
        default:
167
            // delegate all others to value helper
168
0
            aValueHelper.ProcessAttribute(nAttrToken, sAttrValue);
169
0
            break;
170
1.08k
    }
171
1.08k
}
172
173
void XMLVarFieldImportContext::PrepareField(
174
    const Reference<XPropertySet> & xPropertySet)
175
499
{
176
    // bSetName: not implemented
177
178
499
    if (bSetFormula)
179
499
    {
180
499
        if (!bFormulaOK && bSetFormulaDefault)
181
86
        {
182
86
            sFormula = GetContent();
183
86
            bFormulaOK = true;
184
86
        }
185
186
499
        if (bFormulaOK)
187
499
        {
188
499
            xPropertySet->setPropertyValue(sAPI_content, Any(sFormula));
189
499
        }
190
499
    }
191
192
499
    if (bSetDescription && bDescriptionOK)
193
0
    {
194
0
        xPropertySet->setPropertyValue(u"Hint"_ustr, Any(sDescription));
195
0
    }
196
197
499
    if (bSetHelp && bHelpOK)
198
0
    {
199
0
        xPropertySet->setPropertyValue(u"Help"_ustr, Any(sHelp));
200
0
    }
201
202
499
    if (bSetHint && bHintOK)
203
0
    {
204
0
        xPropertySet->setPropertyValue(u"Tooltip"_ustr, Any(sHint));
205
0
    }
206
207
499
    if (bSetVisible && bDisplayOK)
208
0
    {
209
0
        bool bTmp = !bDisplayNone;
210
0
        xPropertySet->setPropertyValue(sAPI_is_visible, Any(bTmp));
211
0
    }
212
213
    // workaround for #no-bug#: display formula by default
214
499
    if (xPropertySet->getPropertySetInfo()->
215
499
                hasPropertyByName(u"IsShowFormula"_ustr) &&
216
499
        !bSetDisplayFormula)
217
499
    {
218
499
        bDisplayFormula = false;
219
499
        bSetDisplayFormula = true;
220
499
    }
221
222
223
499
    if (bSetDisplayFormula)
224
499
    {
225
499
        bool bTmp = bDisplayFormula && bDisplayOK;
226
499
        xPropertySet->setPropertyValue(u"IsShowFormula"_ustr, Any(bTmp));
227
499
    }
228
229
    // delegate to value helper
230
499
    aValueHelper.SetDefault(GetContent());
231
499
    aValueHelper.PrepareField(xPropertySet);
232
233
    // finally, set the current presentation
234
499
    if (bSetPresentation)
235
499
    {
236
499
        Any aAny;
237
499
        aAny <<= GetContent();
238
499
        xPropertySet->setPropertyValue(sAPI_current_presentation, aAny);
239
499
    }
240
499
}
241
242
243
// variable set fields
244
245
246
XMLSetVarFieldImportContext::XMLSetVarFieldImportContext(
247
    SvXMLImport& rImport, XMLTextImportHelper& rHlp,
248
    const OUString& pServiceName, VarType eVarType,
249
    bool bFormula, bool bFormulaDefault,
250
    bool bDescription, bool bHelp, bool bHint, bool bVisible, bool bIsDisplayFormula,
251
    bool bType, bool bStyle, bool bValue, bool bPresentation) :
252
553
        XMLVarFieldImportContext(rImport, rHlp, pServiceName,
253
553
                                 bFormula, bFormulaDefault,
254
553
                                 bDescription, bHelp, bHint, bVisible, bIsDisplayFormula,
255
553
                                 bType, bStyle, bValue, bPresentation),
256
553
        eFieldType(eVarType)
257
553
{
258
553
}
259
260
void XMLSetVarFieldImportContext::endFastElement(sal_Int32 )
261
541
{
262
    // should we call PrepareField on the field, or rather on it's master?
263
    // currently: call on field (just like superclass)
264
    // possible alternatives: call on master
265
    //                        call field or master depending on variable
266
    //                        PrepareMaster() in addition to PrepareField()
267
268
541
    DBG_ASSERT(!GetServiceName().isEmpty(), "no service name for element!");
269
270
541
    if (bValid)
271
526
    {
272
526
        DBG_ASSERT(!GetName().isEmpty(), "variable name needed!");
273
274
        // find field master
275
526
        Reference<XPropertySet> xMaster;
276
526
        if (FindFieldMaster(xMaster))
277
526
        {
278
            // create field/Service
279
526
            Reference<XPropertySet> xPropSet;
280
526
            if (CreateField(xPropSet, "com.sun.star.text.TextField." + GetServiceName()))
281
526
            {
282
526
                Reference<XDependentTextField> xDepTextField(xPropSet, UNO_QUERY);
283
526
                if (xDepTextField.is())
284
526
                {
285
                    // attach field to field master
286
526
                    xDepTextField->attachTextFieldMaster(xMaster);
287
288
                    // attach field to document
289
526
                    Reference<XTextContent> xTextContent(xPropSet, UNO_QUERY);
290
526
                    if (xTextContent.is())
291
526
                    {
292
526
                        try {
293
                        // insert, set field properties and exit!
294
526
                        GetImportHelper().InsertTextContent(xTextContent);
295
526
                        PrepareField(xPropSet);
296
526
                        } catch (lang::IllegalArgumentException & /*e*/)
297
526
                        {
298
                            // ignore e: #i54023#
299
514
                        };
300
514
                        return;
301
526
                    }
302
526
                }
303
526
            }
304
526
        }
305
526
    }
306
307
    // above: exit on success; so for all error cases we end up here!
308
    // write element content
309
15
    GetImportHelper().InsertString(GetContent());
310
15
}
311
312
bool XMLSetVarFieldImportContext::FindFieldMaster(
313
    Reference<XPropertySet> & xMaster)
314
526
{
315
    // currently: delegate to XMLVariableDeclImportContext;
316
    // should eventually go here
317
526
    return XMLVariableDeclImportContext::FindFieldMaster(xMaster,
318
526
                                                         GetImport(),
319
526
                                                         GetImportHelper(),
320
526
                                                         GetName(),
321
526
                                                         eFieldType);
322
526
}
323
324
325
// sequence field
326
327
328
XMLSequenceFieldImportContext::XMLSequenceFieldImportContext(
329
    SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
330
553
        XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
331
553
                                    VarTypeSequence,
332
                                    // formula
333
553
                                    true, true,
334
553
                                    false, false, false, false,
335
553
                                    false,
336
553
                                    false, false, false, true),
337
338
553
        sNumFormat(OUString('1')),
339
553
        sNumFormatSync(GetXMLToken(XML_FALSE)),
340
553
        bRefNameOK(false)
341
553
{
342
553
}
343
344
void XMLSequenceFieldImportContext::ProcessAttribute(
345
    sal_Int32 nAttrToken, std::string_view sAttrValue )
346
1.51k
{
347
1.51k
    switch (nAttrToken)
348
1.51k
    {
349
428
        case XML_ELEMENT(STYLE, XML_NUM_FORMAT):
350
428
            sNumFormat = OUString::fromUtf8(sAttrValue);
351
428
            break;
352
0
        case XML_ELEMENT(STYLE, XML_NUM_LETTER_SYNC):
353
0
            sNumFormatSync = OUString::fromUtf8(sAttrValue);
354
0
            break;
355
0
        case XML_ELEMENT(TEXT, XML_REF_NAME):
356
0
            sRefName = OUString::fromUtf8(sAttrValue);
357
0
            bRefNameOK = true;
358
0
            break;
359
1.08k
        default:
360
            // delegate to super class (name, formula)
361
1.08k
            XMLSetVarFieldImportContext::ProcessAttribute(nAttrToken,
362
1.08k
                                                          sAttrValue);
363
1.08k
            break;
364
1.51k
    } // switch
365
1.51k
}
366
367
void XMLSequenceFieldImportContext::PrepareField(
368
    const Reference<XPropertySet> & xPropertySet)
369
499
{
370
    // delegate to super class (formula)
371
499
    XMLSetVarFieldImportContext::PrepareField(xPropertySet);
372
373
    // set format
374
499
    sal_Int16 nNumType = NumberingType::ARABIC;
375
499
    GetImport().GetMM100UnitConverter().convertNumFormat( nNumType, sNumFormat, sNumFormatSync );
376
499
    xPropertySet->setPropertyValue(sAPI_number_format, Any(nNumType));
377
378
    // handle reference name
379
499
    if (bRefNameOK)
380
0
    {
381
0
        Any aAny = xPropertySet->getPropertyValue(u"SequenceValue"_ustr);
382
0
        sal_Int16 nValue = 0;
383
0
        aAny >>= nValue;
384
0
        GetImportHelper().InsertSequenceID(sRefName, GetName(), nValue);
385
0
    }
386
499
}
387
388
389
// variable set field
390
391
392
XMLVariableSetFieldImportContext::XMLVariableSetFieldImportContext(
393
    SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
394
0
        XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
395
0
                                    VarTypeSimple,
396
                                    // formula, value&type, style,
397
                                    // display none
398
0
                                    true, true,
399
0
                                    false, false, false,
400
0
                                    true, false,
401
0
                                    true, true, true,
402
0
                                    true)
403
0
{
404
0
}
405
406
void XMLVariableSetFieldImportContext::PrepareField(
407
        const Reference<XPropertySet> & xPropertySet)
408
0
{
409
    // set type
410
0
    Any aAny;
411
0
    aAny <<= (IsStringValue()? SetVariableType::STRING : SetVariableType::VAR);
412
0
    xPropertySet->setPropertyValue(sAPI_sub_type, aAny);
413
414
    // the remainder is handled by super class
415
0
    XMLSetVarFieldImportContext::PrepareField(xPropertySet);
416
0
}
417
418
419
// variable input field
420
421
422
XMLVariableInputFieldImportContext::XMLVariableInputFieldImportContext(
423
    SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
424
0
        XMLSetVarFieldImportContext(rImport, rHlp, sAPI_set_expression,
425
0
                                    VarTypeSimple,
426
                                    // description, display none/formula,
427
                                    // value&type, style, formula
428
0
                                    true, true,
429
0
                                    true, true, true,
430
0
                                    true, false,
431
0
                                    true, true, true,
432
0
                                    true)
433
0
{
434
0
}
435
436
void XMLVariableInputFieldImportContext::PrepareField(
437
        const Reference<XPropertySet> & xPropertySet)
438
0
{
439
    // set type (input field)
440
0
    Any aAny;
441
0
    xPropertySet->setPropertyValue(u"Input"_ustr, Any(true));
442
443
    // set type
444
0
    aAny <<= (IsStringValue()? SetVariableType::STRING : SetVariableType::VAR);
445
0
    xPropertySet->setPropertyValue(sAPI_sub_type, aAny);
446
447
    // the remainder is handled by super class
448
0
    XMLSetVarFieldImportContext::PrepareField(xPropertySet);
449
0
}
450
451
452
// user field
453
454
455
XMLUserFieldImportContext::XMLUserFieldImportContext(
456
    SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
457
0
        XMLSetVarFieldImportContext(rImport, rHlp, sAPI_user,
458
0
                                    VarTypeUserField,
459
                                    // display none/formula, style
460
0
                                    false, false,
461
0
                                    false, false, false, true,
462
0
                                    true,
463
0
                                    false, true, false,
464
0
                                    false)
465
0
{
466
0
}
467
468
469
// user input field
470
471
472
// bug: doesn't work (SO API lacking)
473
XMLUserFieldInputImportContext::XMLUserFieldInputImportContext(
474
    SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
475
0
        XMLVarFieldImportContext(rImport, rHlp, u"InputUser"_ustr,
476
                                 // description, style
477
0
                                 false, false,
478
0
                                 true, false, false,
479
0
                                 false, false,
480
0
                                 false /*???*/, true, false,
481
0
                                 false)
482
0
{
483
0
}
484
485
void XMLUserFieldInputImportContext::PrepareField(
486
    const Reference<XPropertySet> & xPropertySet)
487
0
{
488
0
    xPropertySet->setPropertyValue(sAPI_content, Any(GetName()));
489
490
    // delegate to super class
491
0
    XMLVarFieldImportContext::PrepareField(xPropertySet);
492
0
}
493
494
495
// variable get field
496
497
498
XMLVariableGetFieldImportContext::XMLVariableGetFieldImportContext(
499
    SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
500
0
        XMLVarFieldImportContext(rImport, rHlp, sAPI_get_expression,
501
                                 // style, display formula
502
0
                                 false, false,
503
0
                                 false, false, false,
504
0
                                 false, true,
505
0
                                 true, true, false,
506
0
                                 true)
507
0
{
508
0
}
509
510
void XMLVariableGetFieldImportContext::PrepareField(
511
        const Reference<XPropertySet> & xPropertySet)
512
0
{
513
    // set name
514
0
    xPropertySet->setPropertyValue(sAPI_content, Any(GetName()));
515
516
    // the remainder is handled by super class
517
0
    XMLVarFieldImportContext::PrepareField(xPropertySet);
518
0
}
519
520
521
// expression field
522
523
524
XMLExpressionFieldImportContext::XMLExpressionFieldImportContext(
525
    SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
526
1
        XMLVarFieldImportContext(rImport, rHlp, sAPI_get_expression,
527
                                 // formula, type, style, display formula
528
1
                                 true, true,
529
1
                                 false, false, false,
530
1
                                 false, true,
531
1
                                 true, true, false,
532
1
                                 true)
533
1
{
534
1
    bValid = true;  // always valid
535
1
}
536
537
538
void XMLExpressionFieldImportContext::PrepareField(
539
    const Reference<XPropertySet> & xPropertySet)
540
0
{
541
0
    xPropertySet->setPropertyValue(sAPI_sub_type, Any(sal_Int16(SetVariableType::FORMULA)));
542
543
    // delegate to super class
544
0
    XMLVarFieldImportContext::PrepareField(xPropertySet);
545
0
}
546
547
548
// text input field
549
550
551
XMLTextInputFieldImportContext::XMLTextInputFieldImportContext(
552
    SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
553
2
        XMLVarFieldImportContext(rImport, rHlp, u"Input"_ustr,
554
                                 // description
555
2
                                 false, false,
556
2
                                 true, true, true,
557
2
                                 false, false,
558
2
                                 false, false, false,
559
2
                                 false)
560
2
{
561
2
    bValid = true;  // always valid
562
2
}
563
564
void XMLTextInputFieldImportContext::PrepareField(
565
    const Reference<XPropertySet> & xPropertySet)
566
0
{
567
0
    XMLVarFieldImportContext::PrepareField(xPropertySet);
568
569
0
    xPropertySet->setPropertyValue(sAPI_content, Any(GetContent()));
570
0
}
571
572
573
// table formula field
574
575
576
XMLTableFormulaImportContext::XMLTableFormulaImportContext(
577
    SvXMLImport& rImport,
578
    XMLTextImportHelper& rHlp) :
579
10
        XMLTextFieldImportContext(rImport, rHlp, u"TableFormula"_ustr),
580
10
        aValueHelper(rImport, rHlp, false, true, false, true),
581
10
        bIsShowFormula(false)
582
10
{
583
10
}
584
585
void XMLTableFormulaImportContext::ProcessAttribute(
586
    sal_Int32 nAttrToken,
587
    std::string_view sAttrValue )
588
0
{
589
0
    switch (nAttrToken)
590
0
    {
591
0
        case XML_ELEMENT(TEXT, XML_FORMULA):
592
0
            aValueHelper.ProcessAttribute( nAttrToken, sAttrValue );
593
0
            bValid = true;  // we need a formula!
594
0
            break;
595
596
0
        case XML_ELEMENT(STYLE, XML_DATA_STYLE_NAME):
597
0
            aValueHelper.ProcessAttribute( nAttrToken, sAttrValue );
598
0
            break;
599
0
        case XML_ELEMENT(TEXT, XML_DISPLAY):
600
0
            if ( sAttrValue == "formula" )
601
0
                 bIsShowFormula = true;
602
0
            break;
603
0
        default:
604
            // unknown attribute -> ignore
605
0
            XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
606
0
            break;
607
0
    }
608
0
}
609
610
void XMLTableFormulaImportContext::PrepareField(
611
    const Reference<XPropertySet> & xPropertySet)
612
0
{
613
    // set format and formula
614
0
    aValueHelper.PrepareField( xPropertySet );
615
616
0
    Any aAny;
617
618
    // set 'show formula' and presentation
619
0
    xPropertySet->setPropertyValue( u"IsShowFormula"_ustr, Any(bIsShowFormula) );
620
621
0
    aAny <<= GetContent();
622
0
    xPropertySet->setPropertyValue( u"CurrentPresentation"_ustr, aAny );
623
0
}
624
625
626
// variable declarations
627
628
// Should be adapted to XMLVarField-/XMLSetVarFieldImportContext scheme!
629
630
631
// declaration container import (<variable/user-field/sequence-decls>)
632
633
634
XMLVariableDeclsImportContext::XMLVariableDeclsImportContext(
635
    SvXMLImport& rImport, XMLTextImportHelper& rHlp, enum VarType eVarType) :
636
1.12k
        SvXMLImportContext(rImport),
637
1.12k
        eVarDeclsContextType(eVarType),
638
1.12k
        rImportHelper(rHlp)
639
1.12k
{
640
1.12k
}
641
642
css::uno::Reference< css::xml::sax::XFastContextHandler > XMLVariableDeclsImportContext::createFastChildContext(
643
        sal_Int32 nElement,
644
        const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
645
10.4k
{
646
10.4k
    if( IsTokenInNamespace(nElement, XML_NAMESPACE_TEXT) )
647
10.2k
    {
648
10.2k
        enum XMLTokenEnum eElementName;
649
10.2k
        switch (eVarDeclsContextType)
650
10.2k
        {
651
10.2k
            case VarTypeSequence:
652
10.2k
                eElementName = XML_SEQUENCE_DECL;
653
10.2k
                break;
654
0
            case VarTypeSimple:
655
0
                eElementName = XML_VARIABLE_DECL;
656
0
                break;
657
0
            case VarTypeUserField:
658
0
                eElementName = XML_USER_FIELD_DECL;
659
0
                break;
660
0
            default:
661
0
                OSL_FAIL("unknown field type!");
662
0
                eElementName = XML_SEQUENCE_DECL;
663
0
                break;
664
10.2k
        }
665
666
10.2k
        if( nElement == XML_ELEMENT(TEXT, eElementName) )
667
10.1k
        {
668
10.1k
            return new XMLVariableDeclImportContext(
669
10.1k
                GetImport(), rImportHelper, nElement, xAttrList,
670
10.1k
                eVarDeclsContextType);
671
10.1k
        }
672
10.2k
    }
673
674
    // if no context was created, use default context
675
300
    return nullptr;
676
10.4k
}
677
678
679
// declaration import (<variable/user-field/sequence-decl> elements)
680
681
682
XMLVariableDeclImportContext::XMLVariableDeclImportContext(
683
    SvXMLImport& rImport, XMLTextImportHelper& rHlp,
684
    sal_Int32 nElement,
685
    const Reference<xml::sax::XFastAttributeList> & xAttrList,
686
    enum VarType eVarType) :
687
10.1k
        SvXMLImportContext(rImport)
688
10.1k
{
689
    // bug?? which properties for userfield/userfieldmaster
690
10.1k
    XMLValueImportHelper aValueHelper(rImport, rHlp, true, false, true, false);
691
10.1k
    sal_Unicode cSeparationChar('.');
692
693
10.1k
    sal_Int8 nNumLevel(-1);
694
10.1k
    OUString sName;
695
696
10.1k
    if (nElement != XML_ELEMENT(TEXT, XML_SEQUENCE_DECL) &&
697
0
        nElement != XML_ELEMENT(TEXT, XML_VARIABLE_DECL) &&
698
0
        nElement != XML_ELEMENT(TEXT, XML_USER_FIELD_DECL) )
699
0
        return;
700
701
    // TODO: check validity (need name!)
702
703
    // parse attributes
704
10.1k
    for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
705
11.4k
    {
706
11.4k
        switch (aIter.getToken())
707
11.4k
        {
708
7.61k
            case XML_ELEMENT(TEXT, XML_NAME):
709
7.61k
                sName = aIter.toString();
710
7.61k
                break;
711
3.80k
            case XML_ELEMENT(TEXT, XML_DISPLAY_OUTLINE_LEVEL):
712
3.80k
            {
713
3.80k
                sal_Int32 nLevel;
714
3.80k
                bool const bRet = ::sax::Converter::convertNumber(
715
3.80k
                    nLevel, aIter.toView(), 0,
716
3.80k
                    GetImport().GetTextImport()->GetChapterNumbering()->
717
3.80k
                                                               getCount());
718
3.80k
                if (bRet)
719
3.79k
                {
720
3.79k
                    nNumLevel = static_cast< sal_Int8 >( nLevel-1 ); // API numbers -1..9
721
3.79k
                }
722
3.80k
                break;
723
0
            }
724
0
            case XML_ELEMENT(TEXT, XML_SEPARATION_CHARACTER):
725
0
                cSeparationChar =
726
0
                    static_cast<char>(aIter.toString().toChar());
727
0
                break;
728
729
12
            default:
730
                // delegate to value helper
731
12
                aValueHelper.ProcessAttribute(aIter.getToken(), aIter.toView());
732
12
                break;
733
11.4k
        }
734
11.4k
    }
735
736
10.1k
    Reference<XPropertySet> xFieldMaster;
737
10.1k
    if (!FindFieldMaster(xFieldMaster, GetImport(), rHlp,
738
10.1k
                        sName, eVarType))
739
0
        return;
740
741
    // now we have a field master: process attributes!
742
10.1k
    Any aAny;
743
744
10.1k
    switch (eVarType)
745
10.1k
    {
746
10.1k
    case VarTypeSequence:
747
10.1k
        xFieldMaster->setPropertyValue(u"ChapterNumberingLevel"_ustr, Any(nNumLevel));
748
749
10.1k
        if (nNumLevel >= 0)
750
283
        {
751
283
            OUString sStr(&cSeparationChar, 1);
752
283
            xFieldMaster->setPropertyValue(
753
283
                u"NumberingSeparator"_ustr, Any(sStr));
754
283
        }
755
10.1k
        break;
756
0
    case VarTypeSimple:
757
0
        {
758
            // set string or non-string SubType (#93192#)
759
            // The SubType was already set in the FindFieldMaster
760
            // method, but it needs to be adjusted if it's a string.
761
0
            aAny <<= aValueHelper.IsStringValue()
762
0
                ? SetVariableType::STRING : SetVariableType::VAR;
763
0
            xFieldMaster->setPropertyValue(sAPI_sub_type, aAny);
764
0
        }
765
0
        break;
766
0
    case VarTypeUserField:
767
0
    {
768
0
        bool bTmp = !aValueHelper.IsStringValue();
769
0
        xFieldMaster->setPropertyValue(u"IsExpression"_ustr, Any(bTmp));
770
0
        aValueHelper.PrepareField(xFieldMaster);
771
0
        break;
772
0
    }
773
0
    default:
774
0
        OSL_FAIL("unknown varfield type");
775
10.1k
    } // switch
776
10.1k
}
777
778
779
bool XMLVariableDeclImportContext::FindFieldMaster(
780
    Reference<XPropertySet> & xMaster, SvXMLImport& rImport,
781
    XMLTextImportHelper& rImportHelper,
782
    const OUString& sVarName, enum VarType eVarType)
783
10.6k
{
784
10.6k
    static sal_Int32 nCollisionCount = 0;
785
786
    // rename field
787
    // currently: no family in use! Use 0.
788
10.6k
    OUString sName = rImportHelper.GetRenameMap().Get(
789
10.6k
        sal::static_int_cast< sal_uInt16 >(eVarType), sVarName);
790
791
    // get text fields supplier and field masters
792
10.6k
    Reference<XTextFieldsSupplier> xTextFieldsSupp(rImport.GetModel(),
793
10.6k
                                                   UNO_QUERY);
794
10.6k
    Reference<container::XNameAccess> xFieldMasterNameAccess =
795
10.6k
        xTextFieldsSupp->getTextFieldMasters();
796
797
10.6k
    OUString sVarServiceName =
798
10.6k
        OUString::Concat(sAPI_fieldmaster_prefix) +
799
10.6k
        sAPI_set_expression +
800
10.6k
        "." +
801
10.6k
        sName;
802
803
10.6k
    OUString sUserServiceName =
804
10.6k
        OUString::Concat(sAPI_fieldmaster_prefix) +
805
10.6k
        sAPI_user +
806
10.6k
        "." +
807
10.6k
        sName;
808
809
10.6k
    if (xFieldMasterNameAccess->hasByName(sVarServiceName)) {
810
        // variable field master already in document
811
812
9.60k
        Any aAny = xFieldMasterNameAccess->getByName(sVarServiceName);
813
9.60k
        aAny >>= xMaster;
814
815
9.60k
        aAny = xMaster->getPropertyValue(sAPI_sub_type);
816
9.60k
        sal_Int16 nType = 0;
817
9.60k
        aAny >>= nType;
818
819
9.60k
        enum VarType eFMVarType =
820
9.60k
            (SetVariableType::SEQUENCE == nType) ?
821
9.60k
                VarTypeSequence : VarTypeSimple;
822
823
9.60k
        if (eFMVarType != eVarType)
824
0
        {
825
0
            ++nCollisionCount;
826
0
            OUString sNew(sName + "_renamed_" + OUString::number(nCollisionCount));
827
828
            // FIXME! can't find if name is taken already!!!!
829
830
0
            rImportHelper.GetRenameMap().Add(
831
0
                sal::static_int_cast< sal_uInt16 >(eVarType), sName, sNew);
832
833
            // call FindFieldMaster recursively to create new master
834
0
            return FindFieldMaster(xMaster, rImport, rImportHelper,
835
0
                                   sNew, eVarType);
836
0
        }
837
9.60k
    } else if (xFieldMasterNameAccess->hasByName(sUserServiceName)) {
838
        // user field: get field master
839
0
        Any aAny = xFieldMasterNameAccess->getByName(sUserServiceName);
840
0
        aAny >>= xMaster;
841
842
0
        if (VarTypeUserField != eVarType) {
843
0
            ++nCollisionCount;
844
            // find new name that is not taken
845
0
            OUString sNew(sName + "_renamed_" + OUString::number(nCollisionCount));
846
847
            // FIXME! can't find if name is taken already!!!!
848
849
0
            rImportHelper.GetRenameMap().Add(
850
0
                sal::static_int_cast< sal_uInt16 >(eVarType), sName, sNew);
851
852
            // call FindFieldMaster recursively to create new master
853
0
            return FindFieldMaster(xMaster, rImport, rImportHelper,
854
0
                                   sNew, eVarType);
855
0
        }
856
1.05k
    } else {
857
        // field name not used: create field master
858
859
        // import -> model is MultiServiceFactory -> createInstance
860
1.05k
        Reference<lang::XMultiServiceFactory>
861
1.05k
            xFactory(rImport.GetModel(),UNO_QUERY);
862
1.05k
        if( xFactory.is() ) {
863
864
1.05k
            OUString sService = sAPI_fieldmaster_prefix
865
1.05k
                + ((eVarType==VarTypeUserField) ?
866
1.05k
                                 sAPI_user : sAPI_set_expression);
867
1.05k
            Reference<XInterface> xIfc =
868
1.05k
                xFactory->createInstance( sService );
869
1.05k
            if (xIfc.is()) {
870
1.05k
                xMaster.set(xIfc, UNO_QUERY);
871
872
                // set name
873
1.05k
                xMaster->setPropertyValue(u"Name"_ustr, Any(sName));
874
875
1.05k
                if (eVarType != VarTypeUserField) {
876
                    // set subtype for setexp field
877
1.05k
                    Any aAny;
878
1.05k
                    aAny <<= ((eVarType == VarTypeSimple) ?
879
0
                              SetVariableType::VAR :
880
1.05k
                              SetVariableType::SEQUENCE);
881
1.05k
                    xMaster->setPropertyValue(sAPI_sub_type, aAny);
882
1.05k
                } // else : user field: no subtype
883
884
1.05k
            } else {
885
0
                return false;
886
0
            }
887
1.05k
        } else {
888
0
            return false;
889
0
        }
890
1.05k
    }
891
892
10.6k
    DBG_ASSERT(xMaster.is(), "no field master found!?!");
893
10.6k
    return true;
894
10.6k
}
895
896
897
// Database Display field import
898
899
900
XMLDatabaseDisplayImportContext::XMLDatabaseDisplayImportContext(
901
    SvXMLImport& rImport, XMLTextImportHelper& rHlp) :
902
251
        XMLDatabaseFieldImportContext(rImport, rHlp, sAPI_database, false),
903
251
        aValueHelper(rImport, rHlp, false, true, false, false),
904
251
        bColumnOK(false),
905
251
        bDisplay( true ),
906
251
        bDisplayOK( false )
907
251
{
908
251
}
909
910
void XMLDatabaseDisplayImportContext::ProcessAttribute(
911
    sal_Int32 nAttrToken, std::string_view sAttrValue )
912
973
{
913
973
    switch (nAttrToken)
914
973
    {
915
241
        case XML_ELEMENT(TEXT, XML_COLUMN_NAME):
916
241
            sColumnName = OUString::fromUtf8(sAttrValue);
917
241
            bColumnOK = true;
918
241
            break;
919
0
        case XML_ELEMENT(TEXT, XML_DISPLAY):
920
0
            {
921
0
                bool bNone = IsXMLToken( sAttrValue, XML_NONE );
922
0
                bool bValue = IsXMLToken( sAttrValue, XML_VALUE );
923
0
                bDisplay = bValue;
924
0
                bDisplayOK = bNone || bValue;
925
0
            }
926
0
            break;
927
245
        case XML_ELEMENT(TEXT, XML_DATABASE_NAME):
928
490
        case XML_ELEMENT(TEXT, XML_TABLE_NAME):
929
732
        case XML_ELEMENT(TEXT, XML_TABLE_TYPE):
930
            // handled by super class
931
732
            XMLDatabaseFieldImportContext::ProcessAttribute(nAttrToken,
932
732
                                                            sAttrValue);
933
732
            break;
934
0
        default:
935
            // remainder handled by value helper
936
0
            aValueHelper.ProcessAttribute(nAttrToken, sAttrValue);
937
0
            break;
938
973
    }
939
940
973
    bValid = m_bTableOK && m_bDatabaseOK && bColumnOK;
941
973
}
942
943
void XMLDatabaseDisplayImportContext::endFastElement(sal_Int32 )
944
248
{
945
    // we have an EndElement of our own, because database fields need
946
    // to be attached to a field master before they can be inserted into
947
    // the document. Database stuff (database, table, column) all goes
948
    // to the field master, value & style go to the field.
949
950
248
    if (bValid)
951
226
    {
952
953
        // so here goes: we start with the master
954
226
        Reference<XPropertySet> xMaster;
955
956
        // create and prepare field master first
957
226
        if (CreateField(xMaster,
958
226
                        u"com.sun.star.text.FieldMaster.Database"_ustr))
959
226
        {
960
226
            Any aAny;
961
226
            xMaster->setPropertyValue(u"DataColumnName"_ustr, Any(sColumnName));
962
963
            // fieldmaster takes database, table and column name
964
226
            XMLDatabaseFieldImportContext::PrepareField(xMaster);
965
966
            // create field
967
226
            Reference<XPropertySet> xField;
968
226
            if (CreateField(xField,
969
226
                            sAPI_database))
970
226
            {
971
                // attach field master
972
226
                Reference<XDependentTextField> xDepField(xField, UNO_QUERY);
973
226
                if (xDepField.is())
974
226
                {
975
                    // attach field to field master
976
226
                    xDepField->attachTextFieldMaster(xMaster);
977
978
                    // attach field to document
979
226
                    Reference<XTextContent> xTextContent(xField, UNO_QUERY);
980
226
                    if (xTextContent.is())
981
226
                    {
982
                        // insert, set field properties and exit!
983
226
                        try
984
226
                        {
985
226
                            GetImportHelper().InsertTextContent(xTextContent);
986
987
                            // prepare field: format from database?
988
226
                            bool bTmp = !aValueHelper.IsFormatOK();
989
226
                            xField->setPropertyValue(u"DataBaseFormat"_ustr, Any(bTmp));
990
991
                            // value, value-type and format done by value helper
992
226
                            aValueHelper.PrepareField(xField);
993
994
                            // visibility
995
226
                            if( bDisplayOK )
996
0
                            {
997
0
                                xField->setPropertyValue(sAPI_is_visible, Any(bDisplay));
998
0
                            }
999
1000
                            // set presentation
1001
226
                            aAny <<= GetContent();
1002
226
                            xField->setPropertyValue(sAPI_current_presentation, aAny);
1003
1004
                            // success!
1005
226
                            return;
1006
226
                        }
1007
226
                        catch (const lang::IllegalArgumentException&)
1008
226
                        {
1009
3
                            TOOLS_WARN_EXCEPTION("xmloff.text", "Failed to insert text content");
1010
3
                        }
1011
226
                    }
1012
226
                }
1013
226
            }
1014
226
        }
1015
226
    }
1016
1017
    // above: exit on success; so for all error cases we end up here!
1018
    // write element content
1019
25
    GetImportHelper().InsertString(GetContent());
1020
25
}
1021
1022
1023
// value import helper
1024
1025
namespace {
1026
1027
enum ValueType
1028
{
1029
    XML_VALUE_TYPE_STRING,
1030
    XML_VALUE_TYPE_FLOAT,
1031
    XML_VALUE_TYPE_CURRENCY,
1032
    XML_VALUE_TYPE_PERCENTAGE,
1033
    XML_VALUE_TYPE_DATE,
1034
    XML_VALUE_TYPE_TIME,
1035
    XML_VALUE_TYPE_BOOLEAN
1036
};
1037
1038
}
1039
1040
SvXMLEnumMapEntry<ValueType> const aValueTypeMap[] =
1041
{
1042
    { XML_FLOAT,        XML_VALUE_TYPE_FLOAT },
1043
    { XML_CURRENCY,     XML_VALUE_TYPE_CURRENCY },
1044
    { XML_PERCENTAGE,   XML_VALUE_TYPE_PERCENTAGE },
1045
    { XML_DATE,         XML_VALUE_TYPE_DATE },
1046
    { XML_TIME,         XML_VALUE_TYPE_TIME },
1047
    { XML_BOOLEAN,      XML_VALUE_TYPE_BOOLEAN },
1048
    { XML_STRING,       XML_VALUE_TYPE_STRING },
1049
    { XML_TOKEN_INVALID, ValueType(0) }
1050
};
1051
1052
XMLValueImportHelper::XMLValueImportHelper(
1053
    SvXMLImport& rImprt,
1054
    XMLTextImportHelper& rHlp,
1055
    bool bType, bool bStyle, bool bValue, bool bFormula) :
1056
1057
10.9k
        rImport(rImprt),
1058
10.9k
        rHelper(rHlp),
1059
1060
10.9k
        fValue(0.0),
1061
10.9k
        nFormatKey(0),
1062
10.9k
        bIsDefaultLanguage(true),
1063
1064
10.9k
        bStringType(false),
1065
10.9k
        bFormatOK(false),
1066
10.9k
        bStringValueOK(false),
1067
10.9k
        bFormulaOK(false),
1068
1069
10.9k
        bSetType(bType),
1070
10.9k
        bSetValue(bValue),
1071
10.9k
        bSetStyle(bStyle),
1072
10.9k
        bSetFormula(bFormula)
1073
10.9k
{
1074
10.9k
}
1075
1076
void XMLValueImportHelper::ProcessAttribute(
1077
    sal_Int32 nAttrToken, std::string_view sAttrValue )
1078
12
{
1079
12
    switch (nAttrToken)
1080
12
    {
1081
0
        case XML_ELEMENT(TEXT, XML_VALUE_TYPE): // #i32362#: src680m48++ saves text:value-type
1082
0
        case XML_ELEMENT(OFFICE, XML_VALUE_TYPE):
1083
0
        {
1084
            // convert enum
1085
0
            ValueType eValueType = XML_VALUE_TYPE_STRING;
1086
0
            bool bRet = SvXMLUnitConverter::convertEnum(
1087
0
                eValueType, sAttrValue, aValueTypeMap);
1088
1089
0
            if (bRet) {
1090
0
                switch (eValueType)
1091
0
                {
1092
0
                    case XML_VALUE_TYPE_STRING:
1093
0
                        bStringType = true;
1094
0
                        break;
1095
0
                    case XML_VALUE_TYPE_FLOAT:
1096
0
                    case XML_VALUE_TYPE_CURRENCY:
1097
0
                    case XML_VALUE_TYPE_PERCENTAGE:
1098
0
                    case XML_VALUE_TYPE_DATE:
1099
0
                    case XML_VALUE_TYPE_TIME:
1100
0
                    case XML_VALUE_TYPE_BOOLEAN:
1101
0
                        bStringType = false;
1102
0
                        break;
1103
1104
0
                    default:
1105
0
                        OSL_FAIL("unknown value type");
1106
0
                }
1107
0
            }
1108
0
            break;
1109
0
        }
1110
1111
0
        case XML_ELEMENT(TEXT, XML_VALUE):
1112
0
        case XML_ELEMENT(OFFICE, XML_VALUE):
1113
0
        {
1114
0
            double fTmp;
1115
0
            bool const bRet = ::sax::Converter::convertDouble(fTmp,sAttrValue);
1116
0
            if (bRet) {
1117
0
                fValue = fTmp;
1118
0
            }
1119
0
            break;
1120
0
        }
1121
1122
0
        case XML_ELEMENT(TEXT, XML_TIME_VALUE):
1123
0
        case XML_ELEMENT(OFFICE, XML_TIME_VALUE):
1124
0
        {
1125
0
            double fTmp;
1126
0
            bool const bRet =
1127
0
                ::sax::Converter::convertDuration(fTmp, sAttrValue);
1128
0
            if (bRet) {
1129
0
                fValue = fTmp;
1130
0
            }
1131
0
            break;
1132
0
        }
1133
1134
0
        case XML_ELEMENT(TEXT, XML_DATE_VALUE):
1135
0
        case XML_ELEMENT(OFFICE, XML_DATE_VALUE):
1136
0
        {
1137
0
            double fTmp;
1138
0
            bool bRet = rImport.GetMM100UnitConverter().
1139
0
                convertDateTime(fTmp,sAttrValue);
1140
0
            if (bRet) {
1141
0
                fValue = fTmp;
1142
0
            }
1143
0
            break;
1144
0
        }
1145
1146
0
        case XML_ELEMENT(OFFICE, XML_BOOLEAN_VALUE):
1147
0
        {
1148
0
            bool bTmp(false);
1149
0
            bool bRet = ::sax::Converter::convertBool(bTmp, sAttrValue);
1150
0
            if (bRet) {
1151
0
                fValue = (bTmp ? 1.0 : 0.0);
1152
0
            }
1153
0
            else
1154
0
            {
1155
0
                double fTmp;
1156
0
                bRet = ::sax::Converter::convertDouble(fTmp, sAttrValue);
1157
0
                if (bRet) {
1158
0
                    fValue = fTmp;
1159
0
                }
1160
0
            }
1161
0
            break;
1162
0
        }
1163
1164
0
        case XML_ELEMENT(TEXT, XML_STRING_VALUE):
1165
0
        case XML_ELEMENT(OFFICE, XML_STRING_VALUE):
1166
0
            sValue = OUString::fromUtf8(sAttrValue);
1167
0
            bStringValueOK = true;
1168
0
            break;
1169
1170
0
        case  XML_ELEMENT(TEXT, XML_FORMULA):
1171
0
            {
1172
0
                OUString sTmp;
1173
0
                sal_uInt16 nPrefix = rImport.GetNamespaceMap().
1174
0
                        GetKeyByAttrValueQName(OUString::fromUtf8(sAttrValue), &sTmp);
1175
0
                if( XML_NAMESPACE_OOOW == nPrefix )
1176
0
                {
1177
0
                    sFormula = sTmp;
1178
0
                    bFormulaOK = true;
1179
0
                }
1180
0
                else
1181
0
                    sFormula = OUString::fromUtf8(sAttrValue);
1182
0
            }
1183
0
            break;
1184
1185
0
        case XML_ELEMENT(STYLE, XML_DATA_STYLE_NAME):
1186
0
        {
1187
0
            sal_Int32 nKey = rHelper.GetDataStyleKey(
1188
0
                                          OUString::fromUtf8(sAttrValue), &bIsDefaultLanguage);
1189
0
            if (-1 != nKey)
1190
0
            {
1191
0
                nFormatKey = nKey;
1192
0
                bFormatOK = true;
1193
0
            }
1194
0
            break;
1195
0
        }
1196
12
        default:
1197
12
            XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttrToken, sAttrValue);
1198
12
    } // switch
1199
12
}
1200
1201
void XMLValueImportHelper::PrepareField(
1202
    const Reference<XPropertySet> & xPropertySet)
1203
722
{
1204
722
    Any aAny;
1205
1206
722
    if (bSetType)
1207
0
    {
1208
        // ??? how to set type?
1209
0
    }
1210
1211
722
    if (bSetFormula)
1212
0
    {
1213
0
        aAny <<= !bFormulaOK ? sDefault : sFormula;
1214
0
        xPropertySet->setPropertyValue(sAPI_content, aAny);
1215
0
    }
1216
1217
    // format/style
1218
722
    if (bSetStyle && bFormatOK)
1219
0
    {
1220
0
        xPropertySet->setPropertyValue(sAPI_number_format, Any(nFormatKey));
1221
1222
0
        if( xPropertySet->getPropertySetInfo()->
1223
0
                hasPropertyByName( u"IsFixedLanguage"_ustr ) )
1224
0
        {
1225
0
            bool bIsFixedLanguage = ! bIsDefaultLanguage;
1226
0
            xPropertySet->setPropertyValue( u"IsFixedLanguage"_ustr, Any(bIsFixedLanguage) );
1227
0
        }
1228
0
    }
1229
1230
    // value: string or float
1231
722
    if (bSetValue)
1232
0
    {
1233
0
        if (bStringType)
1234
0
        {
1235
0
            aAny <<= !bStringValueOK ? sDefault : sValue;
1236
0
            xPropertySet->setPropertyValue(sAPI_content, aAny);
1237
0
        }
1238
0
        else
1239
0
        {
1240
0
            xPropertySet->setPropertyValue(u"Value"_ustr, Any(fValue));
1241
0
        }
1242
0
    }
1243
722
}
1244
1245
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */