Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/style/xmlnumi.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
#include <com/sun/star/beans/PropertyValue.hpp>
21
#include <com/sun/star/beans/XPropertySet.hpp>
22
#include <com/sun/star/awt/Size.hpp>
23
#include <com/sun/star/frame/XModel.hpp>
24
#include <com/sun/star/graphic/XGraphic.hpp>
25
#include <com/sun/star/awt/FontDescriptor.hpp>
26
#include <com/sun/star/text/HoriOrientation.hpp>
27
#include <com/sun/star/text/VertOrientation.hpp>
28
#include <com/sun/star/text/PositionAndSpaceMode.hpp>
29
#include <com/sun/star/text/LabelFollow.hpp>
30
#include <com/sun/star/container/XNameContainer.hpp>
31
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
32
#include <com/sun/star/style/XStyle.hpp>
33
#include <com/sun/star/io/XOutputStream.hpp>
34
#include <com/sun/star/awt/XBitmap.hpp>
35
#include <com/sun/star/style/NumberingType.hpp>
36
#include <com/sun/star/container/XIndexReplace.hpp>
37
38
#include <o3tl/any.hxx>
39
#include <o3tl/temporary.hxx>
40
#include <sal/log.hxx>
41
#include <comphelper/diagnose_ex.hxx>
42
#include <comphelper/sequence.hxx>
43
#include <comphelper/propertyvalue.hxx>
44
45
#include <tools/fontenum.hxx>
46
#include <tools/color.hxx>
47
48
#include <sax/tools/converter.hxx>
49
50
#include <vcl/vclenum.hxx>
51
52
#include <xmloff/xmlnamespace.hxx>
53
#include <xmloff/xmlimp.hxx>
54
#include <xmloff/XMLBase64ImportContext.hxx>
55
#include <xmloff/xmltoken.hxx>
56
57
#include <xmloff/xmluconv.hxx>
58
#include "fonthdl.hxx"
59
#include <xmloff/XMLFontStylesContext.hxx>
60
#include <xmloff/families.hxx>
61
#include <xmloff/maptype.hxx>
62
63
#include <xmloff/xmlnumi.hxx>
64
#include <algorithm>
65
#include <optional>
66
67
using namespace ::com::sun::star;
68
using namespace ::com::sun::star::uno;
69
using namespace ::com::sun::star::style;
70
using namespace ::com::sun::star::text;
71
using namespace ::com::sun::star::beans;
72
using namespace ::com::sun::star::container;
73
using namespace ::com::sun::star::lang;
74
using namespace ::com::sun::star::frame;
75
using namespace ::xmloff::token;
76
using namespace ::com::sun::star::io;
77
78
class SvxXMLListLevelStyleContext_Impl;
79
80
namespace {
81
82
class SvxXMLListLevelStyleAttrContext_Impl : public SvXMLImportContext
83
{
84
    SvxXMLListLevelStyleContext_Impl&   rListLevel;
85
86
public:
87
88
    SvxXMLListLevelStyleAttrContext_Impl(
89
            SvXMLImport& rImport, sal_Int32 nElement,
90
            const Reference< xml::sax::XFastAttributeList >& xAttrList,
91
            SvxXMLListLevelStyleContext_Impl& rLLevel   );
92
93
    virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
94
        sal_Int32 nElement,
95
        const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
96
};
97
98
class SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl : public SvXMLImportContext
99
{
100
public:
101
102
    SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
103
            SvXMLImport& rImport, sal_Int32 nElement,
104
            const Reference< xml::sax::XFastAttributeList >& xAttrList,
105
            SvxXMLListLevelStyleContext_Impl& rLLevel   );
106
};
107
108
}
109
110
class SvxXMLListLevelStyleContext_Impl : public SvXMLImportContext
111
{
112
    friend SvxXMLListLevelStyleAttrContext_Impl;
113
114
    OUString            sPrefix;
115
    OUString            sSuffix;
116
    std::optional<OUString> sListFormat;    // It is optional to distinguish empty format string
117
                                            // from not existing format string in old docs
118
    OUString            sTextStyleName;
119
    OUString            sNumFormat;
120
    OUString            sNumLetterSync;
121
    OUString            sBulletFontName;
122
    OUString            sBulletFontStyleName;
123
    OUString            sImageURL;
124
125
    Reference < XOutputStream > xBase64Stream;
126
127
    sal_Int32           nLevel;
128
    sal_Int32           nSpaceBefore;
129
    sal_Int32           nMinLabelWidth;
130
    sal_Int32           nMinLabelDist;
131
    sal_Int32           nImageWidth;
132
    sal_Int32           nImageHeight;
133
    sal_Int16           nNumStartValue;
134
    sal_Int16           nNumDisplayLevels;
135
136
    sal_Int16           eAdjust;
137
    sal_Int16           eBulletFontFamily;
138
    sal_Int16           eBulletFontPitch;
139
    rtl_TextEncoding    eBulletFontEncoding;
140
    sal_Int16           eImageVertOrient;
141
142
    sal_UCS4            cBullet;
143
144
    sal_Int16           nRelSize;
145
    Color               m_nColor;
146
147
    sal_Int16           ePosAndSpaceMode;
148
    sal_Int16           eLabelFollowedBy;
149
    sal_Int32           nListtabStopPosition;
150
    sal_Int32           nFirstLineIndent;
151
    sal_Int32           nIndentAt;
152
153
    bool            bBullet : 1;
154
    bool            bImage : 1;
155
    bool            bNum : 1;
156
    bool            bHasColor : 1;
157
158
    bool            m_bIsLegal = false;
159
160
5.27k
    void SetRelSize( sal_Int16 nRel ) { nRelSize = nRel; }
161
    void SetColor( Color nColor )
162
6.19k
        { m_nColor = nColor; bHasColor = true; }
163
5.64k
    void SetSpaceBefore( sal_Int32 nSet ) { nSpaceBefore = nSet; }
164
2.48k
    void SetMinLabelWidth( sal_Int32 nSet ) { nMinLabelWidth = nSet; }
165
1.90k
    void SetMinLabelDist( sal_Int32 nSet ) { nMinLabelDist = nSet; }
166
1.42k
    void SetAdjust( sal_Int16 eSet ) { eAdjust = eSet; }
167
168
4.25k
    void SetBulletFontName( const OUString& rSet ) { sBulletFontName = rSet; }
169
    void SetBulletFontStyleName( const OUString& rSet )
170
24
         { sBulletFontStyleName = rSet; }
171
25
    void SetBulletFontFamily( sal_Int16 eSet ) { eBulletFontFamily = eSet; }
172
25
    void SetBulletFontPitch( sal_Int16 eSet ) { eBulletFontPitch = eSet; }
173
    void SetBulletFontEncoding( rtl_TextEncoding eSet )
174
1.25k
         { eBulletFontEncoding = eSet; }
175
176
0
    void SetImageWidth( sal_Int32 nSet ) { nImageWidth = nSet; }
177
0
    void SetImageHeight( sal_Int32 nSet ) { nImageHeight = nSet; }
178
    void SetImageVertOrient( sal_Int16 eSet )
179
34.2k
         { eImageVertOrient = eSet; }
180
181
public:
182
183
    SvxXMLListLevelStyleContext_Impl(
184
            SvXMLImport& rImport, sal_Int32 nElement,
185
            const Reference< xml::sax::XFastAttributeList > & xAttrList );
186
187
    virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
188
        sal_Int32 nElement,
189
        const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
190
191
13.0k
    sal_Int32 GetLevel() const { return nLevel; }
192
    Sequence<beans::PropertyValue> GetProperties();
193
194
    void SetPosAndSpaceMode( sal_Int16 eValue )
195
16.6k
    {
196
16.6k
        ePosAndSpaceMode = eValue;
197
16.6k
    }
198
    void SetLabelFollowedBy( sal_Int16 eValue )
199
16.5k
    {
200
16.5k
        eLabelFollowedBy = eValue;
201
16.5k
    }
202
    void SetListtabStopPosition( sal_Int32 nValue )
203
16.0k
    {
204
16.0k
        nListtabStopPosition = nValue;
205
16.0k
    }
206
    void SetFirstLineIndent( sal_Int32 nValue )
207
14.4k
    {
208
14.4k
        nFirstLineIndent = nValue;
209
14.4k
    }
210
    void SetIndentAt( sal_Int32 nValue )
211
14.5k
    {
212
14.5k
        nIndentAt = nValue;
213
14.5k
    }
214
};
215
216
constexpr OUStringLiteral gsStarBats( u"StarBats"  );
217
constexpr OUStringLiteral gsStarMath( u"StarMath"  );
218
219
SvxXMLListLevelStyleContext_Impl::SvxXMLListLevelStyleContext_Impl(
220
        SvXMLImport& rImport, sal_Int32 nElement,
221
        const Reference< xml::sax::XFastAttributeList > & xAttrList )
222
223
26.4k
:   SvXMLImportContext( rImport )
224
26.4k
,   sNumFormat( u"1"_ustr )
225
26.4k
,   nLevel( -1 )
226
26.4k
,   nSpaceBefore( 0 )
227
26.4k
,   nMinLabelWidth( 0 )
228
26.4k
,   nMinLabelDist( 0 )
229
26.4k
,   nImageWidth( 0 )
230
26.4k
,   nImageHeight( 0 )
231
26.4k
,   nNumStartValue( 1 )
232
26.4k
,   nNumDisplayLevels( 1 )
233
26.4k
,   eAdjust( HoriOrientation::LEFT )
234
26.4k
,   eBulletFontFamily( FAMILY_DONTKNOW )
235
26.4k
,   eBulletFontPitch( PITCH_DONTKNOW )
236
26.4k
,   eBulletFontEncoding( RTL_TEXTENCODING_DONTKNOW )
237
26.4k
,   eImageVertOrient(0)
238
26.4k
,   cBullet( 0 )
239
26.4k
,   nRelSize(0)
240
26.4k
,   m_nColor(0)
241
26.4k
,   ePosAndSpaceMode( PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION )
242
26.4k
,   eLabelFollowedBy( LabelFollow::LISTTAB )
243
26.4k
,   nListtabStopPosition( 0 )
244
26.4k
,   nFirstLineIndent( 0 )
245
26.4k
,   nIndentAt( 0 )
246
26.4k
,   bBullet( false )
247
26.4k
,   bImage( false )
248
26.4k
,   bNum( false )
249
26.4k
,   bHasColor( false )
250
26.4k
{
251
26.4k
    switch (nElement & TOKEN_MASK)
252
26.4k
    {
253
12.7k
        case XML_LIST_LEVEL_STYLE_NUMBER:
254
21.0k
        case XML_OUTLINE_LEVEL_STYLE:
255
21.0k
            bNum = true;
256
21.0k
            break;
257
5.43k
        case XML_LIST_LEVEL_STYLE_BULLET:
258
5.43k
            bBullet = true;
259
5.43k
            break;
260
0
        case XML_LIST_LEVEL_STYLE_IMAGE:
261
0
            bImage = true;
262
0
            break;
263
26.4k
    }
264
265
26.4k
    for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
266
71.9k
    {
267
71.9k
        switch( aIter.getToken() )
268
71.9k
        {
269
26.1k
        case XML_ELEMENT(TEXT, XML_LEVEL):
270
26.1k
            nLevel = aIter.toInt32();
271
26.1k
            if( nLevel >= 1 )
272
26.0k
                nLevel--;
273
69
            else
274
69
                nLevel = 0;
275
26.1k
            break;
276
9.29k
        case XML_ELEMENT(TEXT, XML_STYLE_NAME):
277
9.29k
            sTextStyleName = aIter.toString();
278
9.29k
            break;
279
5.37k
        case XML_ELEMENT(TEXT, XML_BULLET_CHAR):
280
5.37k
            if (!aIter.isEmpty())
281
5.37k
            {
282
5.37k
                cBullet = aIter.toString().iterateCodePoints(&o3tl::temporary(sal_Int32(0)));
283
5.37k
            }
284
5.37k
            break;
285
0
        case XML_ELEMENT(XLINK, XML_HREF):
286
0
            if( bImage )
287
0
                sImageURL = aIter.toString();
288
0
            break;
289
0
        case XML_ELEMENT(XLINK, XML_TYPE):
290
0
        case XML_ELEMENT(XLINK, XML_SHOW):
291
0
        case XML_ELEMENT(XLINK, XML_ACTUATE):
292
            // This properties will be ignored
293
0
            break;
294
19.8k
        case XML_ELEMENT(STYLE, XML_NUM_FORMAT):
295
19.8k
            if( bNum )
296
19.8k
                sNumFormat = aIter.toString();
297
19.8k
            break;
298
0
        case XML_ELEMENT(STYLE, XML_NUM_PREFIX):
299
0
            sPrefix = aIter.toString();
300
0
            break;
301
9.33k
        case XML_ELEMENT(STYLE, XML_NUM_SUFFIX):
302
9.33k
            sSuffix = aIter.toString();
303
9.33k
            break;
304
0
        case XML_ELEMENT(STYLE, XML_NUM_LIST_FORMAT):
305
0
        case XML_ELEMENT(LO_EXT, XML_NUM_LIST_FORMAT):
306
0
            sListFormat = std::make_optional(aIter.toString());
307
0
            break;
308
0
        case XML_ELEMENT(LO_EXT, XML_IS_LEGAL):
309
0
            m_bIsLegal = aIter.toBoolean();
310
0
            break;
311
0
        case XML_ELEMENT(STYLE, XML_NUM_LETTER_SYNC):
312
0
            if( bNum )
313
0
                sNumLetterSync = aIter.toString();
314
0
            break;
315
3
        case XML_ELEMENT(TEXT, XML_START_VALUE):
316
3
            if( bNum )
317
3
            {
318
3
                sal_Int32 nTmp = aIter.toInt32();
319
3
                nNumStartValue =
320
3
                    (nTmp < 0) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX
321
3
                                                        : static_cast<sal_Int16>(nTmp) );
322
3
            }
323
3
            break;
324
1.87k
        case XML_ELEMENT(TEXT, XML_DISPLAY_LEVELS):
325
1.87k
            if( bNum )
326
1.87k
            {
327
1.87k
                sal_Int32 nTmp = aIter.toInt32();
328
1.87k
                nNumDisplayLevels =
329
1.87k
                    (nTmp < 1) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX
330
1.86k
                                                        : static_cast<sal_Int16>(nTmp) );
331
1.87k
            }
332
1.87k
            break;
333
53
        default:
334
53
            XMLOFF_WARN_UNKNOWN("xmloff", aIter);
335
71.9k
        }
336
71.9k
    }
337
26.4k
}
338
339
css::uno::Reference< css::xml::sax::XFastContextHandler > SvxXMLListLevelStyleContext_Impl::createFastChildContext(
340
        sal_Int32 nElement,
341
        const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
342
34.5k
{
343
34.5k
    if( nElement == XML_ELEMENT(STYLE, XML_LIST_LEVEL_PROPERTIES) ||
344
9.43k
        nElement == XML_ELEMENT(STYLE, XML_TEXT_PROPERTIES) )
345
34.2k
    {
346
34.2k
        return new SvxXMLListLevelStyleAttrContext_Impl( GetImport(),
347
34.2k
                                                         nElement,
348
34.2k
                                                         xAttrList,
349
34.2k
                                                         *this );
350
34.2k
    }
351
312
    else if( nElement == XML_ELEMENT(OFFICE, XML_BINARY_DATA) )
352
0
    {
353
0
        if( bImage && sImageURL.isEmpty() && !xBase64Stream.is() )
354
0
        {
355
0
            xBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
356
0
            if( xBase64Stream.is() )
357
0
                return new XMLBase64ImportContext( GetImport(), xBase64Stream );
358
0
        }
359
0
    }
360
312
    XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
361
312
    return nullptr;
362
312
}
363
364
Sequence<beans::PropertyValue> SvxXMLListLevelStyleContext_Impl::GetProperties()
365
12.9k
{
366
12.9k
    if (!bBullet && !bImage && !bNum)
367
0
    {
368
0
        return Sequence<beans::PropertyValue>();
369
0
    }
370
371
12.9k
    sal_Int16 eType = NumberingType::NUMBER_NONE;
372
12.9k
    std::vector<beans::PropertyValue> aProperties;
373
374
12.9k
    if( bBullet )
375
3.21k
    {
376
3.21k
        eType = NumberingType::CHAR_SPECIAL;
377
3.21k
    }
378
12.9k
    if( bImage )
379
0
    {
380
0
        eType = NumberingType::BITMAP;
381
0
    }
382
12.9k
    if( bNum )
383
9.76k
    {
384
9.76k
        eType = NumberingType::ARABIC;
385
9.76k
        GetImport().GetMM100UnitConverter().convertNumFormat(
386
9.76k
                eType, sNumFormat, sNumLetterSync, true );
387
9.76k
    }
388
389
12.9k
    if (bBullet && !sSuffix.isEmpty())
390
0
    {
391
0
        sal_uInt16 const nVersion(GetImport().getGeneratorVersion());
392
0
        sal_Int32 nUPD;
393
0
        sal_Int32 nBuildId;
394
0
        if (GetImport().getBuildIds(nUPD, nBuildId)
395
0
            && (   (SvXMLImport::OOo_1x == nVersion)
396
0
                || (SvXMLImport::OOo_2x == nVersion)
397
0
                || (310 == nUPD) || (320 == nUPD) || (330 == nUPD)
398
0
                || ((300 == nUPD) && (nBuildId <= 9573))))
399
0
        {
400
            // #i93908# OOo < 3.4 wrote a bogus suffix for bullet chars
401
0
            sSuffix.clear(); // clear it
402
0
        }
403
0
    }
404
405
12.9k
    if (!sListFormat.has_value())
406
12.9k
    {
407
        // This is older document: it has no list format, but can probably contain prefix and/or suffix
408
        // Generate list format string, based on this
409
12.9k
        sListFormat = std::make_optional(sPrefix);
410
411
        // Can't display more levels than exist
412
12.9k
        sal_Int32 nDisplayLevels = std::min<sal_Int32>(nNumDisplayLevels, nLevel + 1);
413
27.9k
        for (int i = 1; i <= nDisplayLevels; i++)
414
15.0k
        {
415
15.0k
            *sListFormat += "%";
416
15.0k
            *sListFormat += OUString::number(nLevel - nDisplayLevels + i + 1);
417
15.0k
            *sListFormat += "%";
418
15.0k
            if (i != nDisplayLevels)
419
2.10k
                *sListFormat += ".";     // Default separator for older ODT
420
15.0k
        }
421
422
12.9k
        *sListFormat += sSuffix;
423
12.9k
    }
424
425
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"NumberingType"_ustr, eType));
426
427
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"Prefix"_ustr, sPrefix));
428
429
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"Suffix"_ustr, sSuffix));
430
431
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"Adjust"_ustr, eAdjust));
432
433
12.9k
    sal_Int32 nLeftMargin = nSpaceBefore + nMinLabelWidth;
434
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"LeftMargin"_ustr, nLeftMargin));
435
436
12.9k
    sal_Int32 nFirstLineOffset = -nMinLabelWidth;
437
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"FirstLineOffset"_ustr, nFirstLineOffset));
438
439
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"SymbolTextDistance"_ustr, static_cast<sal_Int16>(nMinLabelDist)));
440
441
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"PositionAndSpaceMode"_ustr, ePosAndSpaceMode));
442
443
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"LabelFollowedBy"_ustr, eLabelFollowedBy));
444
445
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"ListtabStopPosition"_ustr, nListtabStopPosition));
446
447
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"FirstLineIndent"_ustr, nFirstLineIndent));
448
449
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"IndentAt"_ustr, nIndentAt));
450
451
12.9k
    OUString sDisplayTextStyleName = GetImport().GetStyleDisplayName(XmlStyleFamily::TEXT_TEXT, sTextStyleName);
452
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"CharStyleName"_ustr, sDisplayTextStyleName));
453
454
12.9k
    if( bBullet )
455
3.21k
    {
456
3.21k
        awt::FontDescriptor aFDesc;
457
3.21k
        aFDesc.Name = sBulletFontName;
458
3.21k
        if( !sBulletFontName.isEmpty() )
459
2.49k
        {
460
2.49k
            aFDesc.StyleName = sBulletFontStyleName;
461
2.49k
            aFDesc.Family = eBulletFontFamily;
462
2.49k
            aFDesc.Pitch = eBulletFontPitch;
463
2.49k
            aFDesc.CharSet = eBulletFontEncoding;
464
2.49k
            aFDesc.Weight = WEIGHT_DONTKNOW;
465
2.49k
            bool bStarSymbol = false;
466
2.49k
            if( aFDesc.Name.equalsIgnoreAsciiCase( gsStarBats ) )
467
0
            {
468
0
                cBullet = GetImport().ConvStarBatsCharToStarSymbol( cBullet );
469
0
                bStarSymbol = true;
470
0
            }
471
2.49k
            else if( aFDesc.Name.equalsIgnoreAsciiCase( gsStarMath ) )
472
0
            {
473
0
                cBullet = GetImport().ConvStarMathCharToStarSymbol( cBullet );
474
0
                bStarSymbol = true;
475
0
            }
476
2.49k
            if( bStarSymbol )
477
0
                aFDesc.Name = "StarSymbol" ;
478
2.49k
        }
479
480
        // Must append 'cBullet' even if it is zero
481
        // if 'bBullet' is true and 'cBullet' is zero - BulletChar property must be 0.
482
3.21k
        aProperties.push_back(comphelper::makePropertyValue(u"BulletChar"_ustr, OUString(&cBullet, 1)));
483
3.21k
        aProperties.push_back(comphelper::makePropertyValue(u"BulletFont"_ustr, aFDesc));
484
3.21k
    }
485
486
12.9k
    if( bImage )
487
0
    {
488
0
        uno::Reference<graphic::XGraphic> xGraphic;
489
0
        if (!sImageURL.isEmpty())
490
0
        {
491
0
            xGraphic = GetImport().loadGraphicByURL(sImageURL);
492
0
        }
493
0
        else if( xBase64Stream.is() )
494
0
        {
495
0
            xGraphic = GetImport().loadGraphicFromBase64(xBase64Stream);
496
0
        }
497
498
0
        uno::Reference<awt::XBitmap> xBitmap;
499
0
        if (xGraphic.is())
500
0
            xBitmap.set(xGraphic, uno::UNO_QUERY);
501
502
0
        if (xBitmap.is())
503
0
        {
504
0
            aProperties.push_back(comphelper::makePropertyValue(u"GraphicBitmap"_ustr, xBitmap));
505
0
        }
506
507
0
        awt::Size aSize(nImageWidth, nImageHeight);
508
0
        aProperties.push_back(comphelper::makePropertyValue(u"GraphicSize"_ustr, aSize));
509
0
        aProperties.push_back(comphelper::makePropertyValue(u"VertOrient"_ustr, eImageVertOrient));
510
0
    }
511
512
12.9k
    if( bNum )
513
9.71k
    {
514
9.71k
        aProperties.push_back(comphelper::makePropertyValue(u"StartWith"_ustr, nNumStartValue));
515
9.71k
        aProperties.push_back(comphelper::makePropertyValue(u"ParentNumbering"_ustr, nNumDisplayLevels));
516
9.71k
    }
517
518
12.9k
    if( ( bNum || bBullet ) && nRelSize )
519
1.23k
    {
520
1.23k
        aProperties.push_back(comphelper::makePropertyValue(u"BulletRelSize"_ustr, nRelSize));
521
1.23k
    }
522
523
12.9k
    if( !bImage && bHasColor )
524
1.83k
    {
525
1.83k
        aProperties.push_back(comphelper::makePropertyValue(u"BulletColor"_ustr, m_nColor));
526
1.83k
    }
527
528
12.9k
    aProperties.push_back(comphelper::makePropertyValue(u"ListFormat"_ustr, *sListFormat));
529
530
12.9k
    if (m_bIsLegal)
531
0
        aProperties.push_back(comphelper::makePropertyValue(u"IsLegal"_ustr, true));
532
533
12.9k
    return comphelper::containerToSequence(aProperties);
534
12.9k
}
535
536
SvxXMLListLevelStyleAttrContext_Impl::SvxXMLListLevelStyleAttrContext_Impl(
537
        SvXMLImport& rImport, sal_Int32 /*nElement*/,
538
        const Reference< xml::sax::XFastAttributeList > & xAttrList,
539
        SvxXMLListLevelStyleContext_Impl& rLLevel ) :
540
34.2k
    SvXMLImportContext( rImport ),
541
34.2k
    rListLevel( rLLevel )
542
34.2k
{
543
34.2k
    SvXMLUnitConverter& rUnitConv = GetImport().GetMM100UnitConverter();
544
545
34.2k
    OUString sFontName, sFontFamily, sFontStyleName, sFontFamilyGeneric,
546
34.2k
             sFontPitch, sFontCharset;
547
34.2k
    OUString sVerticalPos, sVerticalRel;
548
549
34.2k
    for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
550
45.6k
    {
551
45.6k
        sal_Int32 nVal;
552
45.6k
        switch( aIter.getToken() )
553
45.6k
        {
554
5.65k
        case XML_ELEMENT(TEXT, XML_SPACE_BEFORE):
555
5.65k
            if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), SHRT_MIN, SHRT_MAX))
556
5.64k
                rListLevel.SetSpaceBefore( nVal );
557
5.65k
            break;
558
2.48k
        case XML_ELEMENT(TEXT, XML_MIN_LABEL_WIDTH):
559
2.48k
            if (rUnitConv.convertMeasureToCore( nVal, aIter.toView(), 0, SHRT_MAX ))
560
2.48k
                rListLevel.SetMinLabelWidth( nVal );
561
2.48k
            break;
562
1.91k
        case XML_ELEMENT(TEXT, XML_MIN_LABEL_DISTANCE):
563
1.91k
            if (rUnitConv.convertMeasureToCore( nVal, aIter.toView(), 0, USHRT_MAX ))
564
1.90k
                rListLevel.SetMinLabelDist( nVal );
565
1.91k
            break;
566
0
        case XML_ELEMENT(FO, XML_TEXT_ALIGN):
567
1.42k
        case XML_ELEMENT(FO_COMPAT, XML_TEXT_ALIGN):
568
1.42k
            if( !aIter.isEmpty() )
569
1.42k
            {
570
1.42k
                sal_Int16 eAdjust = HoriOrientation::LEFT;
571
1.42k
                if( IsXMLToken( aIter, XML_CENTER ) )
572
0
                    eAdjust = HoriOrientation::CENTER;
573
1.42k
                else if( IsXMLToken( aIter, XML_END ) )
574
1.42k
                    eAdjust = HoriOrientation::RIGHT;
575
1.42k
                rListLevel.SetAdjust( eAdjust );
576
1.42k
            }
577
1.42k
            break;
578
41
        case XML_ELEMENT(STYLE, XML_FONT_NAME):
579
41
            sFontName = aIter.toString();
580
41
            break;
581
0
        case XML_ELEMENT(FO, XML_FONT_FAMILY):
582
4.23k
        case XML_ELEMENT(FO_COMPAT, XML_FONT_FAMILY):
583
4.23k
            sFontFamily = aIter.toString();
584
4.23k
            break;
585
1
        case XML_ELEMENT(STYLE, XML_FONT_FAMILY_GENERIC):
586
1
            sFontFamilyGeneric = aIter.toString();
587
1
            break;
588
0
        case XML_ELEMENT(STYLE, XML_FONT_STYLE_NAME):
589
0
            sFontStyleName = aIter.toString();
590
0
            break;
591
1
        case XML_ELEMENT(STYLE, XML_FONT_PITCH):
592
1
            sFontPitch = aIter.toString();
593
1
            break;
594
1.48k
        case XML_ELEMENT(STYLE, XML_FONT_CHARSET):
595
1.48k
            sFontCharset = aIter.toString();
596
1.48k
            break;
597
1
        case XML_ELEMENT(STYLE, XML_VERTICAL_POS):
598
1
            sVerticalPos = aIter.toString();
599
1
            break;
600
1
        case XML_ELEMENT(STYLE, XML_VERTICAL_REL):
601
1
            sVerticalRel = aIter.toString();
602
1
            break;
603
0
        case XML_ELEMENT(FO, XML_WIDTH):
604
0
        case XML_ELEMENT(FO_COMPAT, XML_WIDTH):
605
0
            if (rUnitConv.convertMeasureToCore(nVal, aIter.toView()))
606
0
                rListLevel.SetImageWidth( nVal );
607
0
            break;
608
0
        case XML_ELEMENT(FO, XML_HEIGHT):
609
0
        case XML_ELEMENT(FO_COMPAT, XML_HEIGHT):
610
0
            if (rUnitConv.convertMeasureToCore(nVal, aIter.toView()))
611
0
                rListLevel.SetImageHeight( nVal );
612
0
            break;
613
0
        case XML_ELEMENT(FO, XML_COLOR):
614
3.65k
        case XML_ELEMENT(FO_COMPAT, XML_COLOR):
615
3.65k
            {
616
3.65k
                Color nColor;
617
3.65k
                if (::sax::Converter::convertColor( nColor, aIter.toView() ))
618
3.62k
                    rListLevel.SetColor( nColor );
619
3.65k
            }
620
3.65k
            break;
621
2.57k
        case XML_ELEMENT(STYLE, XML_USE_WINDOW_FONT_COLOR):
622
2.57k
            {
623
2.57k
                if( IsXMLToken( aIter, XML_TRUE ) )
624
2.57k
                    rListLevel.SetColor(COL_AUTO);
625
2.57k
            }
626
2.57k
            break;
627
0
        case XML_ELEMENT(FO, XML_FONT_SIZE):
628
5.32k
        case XML_ELEMENT(FO_COMPAT, XML_FONT_SIZE):
629
5.32k
            if (::sax::Converter::convertPercent( nVal, aIter.toView() ))
630
5.27k
                rListLevel.SetRelSize( static_cast<sal_Int16>(nVal) );
631
5.32k
            break;
632
16.6k
        case XML_ELEMENT(TEXT, XML_LIST_LEVEL_POSITION_AND_SPACE_MODE):
633
16.6k
            {
634
16.6k
                sal_Int16 ePosAndSpaceMode = PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION;
635
16.6k
                if( IsXMLToken( aIter, XML_LABEL_ALIGNMENT ) )
636
16.4k
                    ePosAndSpaceMode = PositionAndSpaceMode::LABEL_ALIGNMENT;
637
16.6k
                rListLevel.SetPosAndSpaceMode( ePosAndSpaceMode );
638
16.6k
            }
639
16.6k
            break;
640
234
        default:
641
234
            XMLOFF_WARN_UNKNOWN("xmloff", aIter);
642
45.6k
        }
643
45.6k
    }
644
645
34.2k
    if( !sFontName.isEmpty() )
646
41
    {
647
41
        const XMLFontStylesContext *pFontDecls =
648
41
            GetImport().GetFontDecls();
649
41
        if( pFontDecls )
650
40
        {
651
40
            ::std::vector < XMLPropertyState > aProps;
652
40
            if( pFontDecls->FillProperties( sFontName, aProps, 0, 1, 2, 3, 4 ) )
653
24
            {
654
24
                OUString sTmp;
655
24
                sal_Int16 nTmp = 0;
656
24
                for( const auto& rProp : aProps )
657
120
                {
658
120
                    switch( rProp.mnIndex )
659
120
                    {
660
24
                    case 0:
661
24
                        rProp.maValue >>= sTmp;
662
24
                        rListLevel.SetBulletFontName( sTmp);
663
24
                        break;
664
24
                    case 1:
665
24
                        rProp.maValue >>= sTmp;
666
24
                        rListLevel.SetBulletFontStyleName( sTmp );
667
24
                        break;
668
24
                    case 2:
669
24
                        rProp.maValue >>= nTmp;
670
24
                        rListLevel.SetBulletFontFamily( nTmp );
671
24
                        break;
672
24
                    case 3:
673
24
                        rProp.maValue >>= nTmp;
674
24
                        rListLevel.SetBulletFontPitch( nTmp );
675
24
                        break;
676
24
                    case 4:
677
24
                        rProp.maValue >>= nTmp;
678
24
                        rListLevel.SetBulletFontEncoding( nTmp );
679
24
                        break;
680
120
                    }
681
120
                }
682
24
            }
683
40
        }
684
41
    }
685
34.2k
    if( !sFontFamily.isEmpty() )
686
4.23k
    {
687
4.23k
        Any aAny;
688
689
4.23k
        XMLFontFamilyNamePropHdl aFamilyNameHdl;
690
4.23k
        if( aFamilyNameHdl.importXML( sFontFamily, aAny, rUnitConv ) )
691
4.23k
        {
692
4.23k
            OUString sTmp;
693
4.23k
            aAny >>= sTmp;
694
4.23k
            rListLevel.SetBulletFontName( sTmp);
695
4.23k
        }
696
697
4.23k
        XMLFontFamilyPropHdl aFamilyHdl;
698
4.23k
        if( !sFontFamilyGeneric.isEmpty() &&
699
1
            aFamilyHdl.importXML( sFontFamilyGeneric, aAny, rUnitConv  ) )
700
1
        {
701
1
            sal_Int16 nTmp = 0;
702
1
            aAny >>= nTmp;
703
1
            rListLevel.SetBulletFontFamily( nTmp );
704
1
        }
705
706
4.23k
        if( !sFontStyleName.isEmpty() )
707
0
            rListLevel.SetBulletFontStyleName( sFontStyleName );
708
709
4.23k
        XMLFontPitchPropHdl aPitchHdl;
710
4.23k
        if( !sFontPitch.isEmpty() &&
711
1
            aPitchHdl.importXML( sFontPitch, aAny, rUnitConv  ) )
712
1
        {
713
1
            sal_Int16 nTmp = 0;
714
1
            aAny >>= nTmp;
715
1
            rListLevel.SetBulletFontPitch( nTmp );
716
1
        }
717
718
4.23k
        XMLFontEncodingPropHdl aEncHdl;
719
4.23k
        if( !sFontCharset.isEmpty() &&
720
1.23k
            aEncHdl.importXML( sFontCharset, aAny, rUnitConv  ) )
721
1.23k
        {
722
1.23k
            sal_Int16 nTmp = 0;
723
1.23k
            aAny >>= nTmp;
724
1.23k
            rListLevel.SetBulletFontEncoding( nTmp );
725
1.23k
        }
726
4.23k
    }
727
728
34.2k
    sal_Int16 eVertOrient = VertOrientation::LINE_CENTER;
729
34.2k
    if( !sVerticalPos.isEmpty() )
730
1
    {
731
1
        if( IsXMLToken( sVerticalPos, XML_TOP ) )
732
0
            eVertOrient = VertOrientation::LINE_TOP;
733
1
        else if( IsXMLToken( sVerticalPos, XML_BOTTOM ) )
734
0
            eVertOrient = VertOrientation::LINE_BOTTOM;
735
1
    }
736
34.2k
    if( !sVerticalRel.isEmpty() )
737
1
    {
738
1
        if( IsXMLToken( sVerticalRel, XML_BASELINE ) )
739
0
        {
740
            // TOP and BOTTOM are exchanged for a baseline relation
741
0
            switch( eVertOrient  )
742
0
            {
743
0
            case VertOrientation::LINE_TOP:
744
0
                eVertOrient = VertOrientation::BOTTOM;
745
0
                break;
746
0
            case VertOrientation::LINE_CENTER:
747
0
                eVertOrient = VertOrientation::CENTER;
748
0
                break;
749
0
            case VertOrientation::LINE_BOTTOM:
750
0
                eVertOrient = VertOrientation::TOP;
751
0
                break;
752
0
            }
753
0
        }
754
1
        else if( IsXMLToken( sVerticalRel, XML_CHAR ) )
755
0
        {
756
0
            switch( eVertOrient  )
757
0
            {
758
0
            case VertOrientation::LINE_TOP:
759
0
                eVertOrient = VertOrientation::CHAR_TOP;
760
0
                break;
761
0
            case VertOrientation::LINE_CENTER:
762
0
                eVertOrient = VertOrientation::CHAR_CENTER;
763
0
                break;
764
0
            case VertOrientation::LINE_BOTTOM:
765
0
                eVertOrient = VertOrientation::CHAR_BOTTOM;
766
0
                break;
767
0
            }
768
0
        }
769
1
    }
770
34.2k
    rListLevel.SetImageVertOrient( eVertOrient );
771
34.2k
}
772
773
css::uno::Reference< css::xml::sax::XFastContextHandler > SvxXMLListLevelStyleAttrContext_Impl::createFastChildContext(
774
        sal_Int32 nElement,
775
        const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
776
16.6k
{
777
16.6k
    if ( nElement == XML_ELEMENT(STYLE, XML_LIST_LEVEL_LABEL_ALIGNMENT) )
778
16.5k
    {
779
16.5k
        return new SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl( GetImport(),
780
16.5k
                                                             nElement,
781
16.5k
                                                             xAttrList,
782
16.5k
                                                             rListLevel );
783
16.5k
    }
784
96
    XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
785
96
    return nullptr;
786
96
}
787
788
789
SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
790
        SvXMLImport& rImport, sal_Int32 /*nElement*/,
791
        const Reference< xml::sax::XFastAttributeList > & xAttrList,
792
        SvxXMLListLevelStyleContext_Impl& rLLevel ) :
793
16.5k
    SvXMLImportContext( rImport )
794
16.5k
{
795
16.5k
    SvXMLUnitConverter& rUnitConv = GetImport().GetMM100UnitConverter();
796
797
16.5k
    sal_Int16 eLabelFollowedBy = LabelFollow::LISTTAB;
798
16.5k
    for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
799
61.8k
    {
800
61.8k
        sal_Int32 nVal;
801
61.8k
        switch( aIter.getToken() )
802
61.8k
        {
803
16.4k
        case XML_ELEMENT(TEXT, XML_LABEL_FOLLOWED_BY):
804
16.4k
        case XML_ELEMENT(LO_EXT, XML_LABEL_FOLLOWED_BY):
805
16.4k
            {
806
16.4k
                if( eLabelFollowedBy == LabelFollow::NEWLINE)
807
                    //NewLine from LO_EXT has precedence over other values of the Non LO_EXT namespace
808
0
                    break;
809
16.4k
                if( IsXMLToken( aIter, XML_SPACE ) )
810
0
                    eLabelFollowedBy = LabelFollow::SPACE;
811
16.4k
                else if( IsXMLToken( aIter, XML_NOTHING ) )
812
0
                    eLabelFollowedBy = LabelFollow::NOTHING;
813
16.4k
                else if( IsXMLToken( aIter, XML_NEWLINE ) )
814
2
                    eLabelFollowedBy = LabelFollow::NEWLINE;
815
16.4k
            }
816
0
            break;
817
16.1k
        case XML_ELEMENT(TEXT, XML_LIST_TAB_STOP_POSITION):
818
16.1k
            if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), 0, SHRT_MAX))
819
16.0k
                rLLevel.SetListtabStopPosition( nVal );
820
16.1k
            break;
821
0
        case XML_ELEMENT(FO, XML_TEXT_INDENT):
822
14.5k
        case XML_ELEMENT(FO_COMPAT, XML_TEXT_INDENT):
823
14.5k
            if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), SHRT_MIN, SHRT_MAX))
824
14.4k
                rLLevel.SetFirstLineIndent( nVal );
825
14.5k
            break;
826
0
        case XML_ELEMENT(FO, XML_MARGIN_LEFT):
827
14.6k
        case XML_ELEMENT(FO_COMPAT, XML_MARGIN_LEFT):
828
14.6k
            if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), SHRT_MIN, SHRT_MAX))
829
14.5k
                rLLevel.SetIndentAt( nVal );
830
14.6k
            break;
831
134
        default:
832
134
            XMLOFF_WARN_UNKNOWN("xmloff", aIter);
833
61.8k
        }
834
61.8k
    }
835
16.5k
    rLLevel.SetLabelFollowedBy( eLabelFollowedBy );
836
16.5k
}
837
838
void SvxXMLListStyleContext::SetAttribute( sal_Int32 nElement,
839
                                           const OUString& rValue )
840
3.90k
{
841
3.90k
    if( nElement == XML_ELEMENT(TEXT, XML_CONSECUTIVE_NUMBERING) )
842
0
    {
843
0
        m_bConsecutive = IsXMLToken( rValue, XML_TRUE );
844
0
    }
845
3.90k
    else
846
3.90k
    {
847
3.90k
        SvXMLStyleContext::SetAttribute( nElement, rValue );
848
3.90k
    }
849
3.90k
}
850
851
constexpr OUString sIsPhysical( u"IsPhysical"_ustr  );
852
constexpr OUString sNumberingRules( u"NumberingRules"_ustr  );
853
constexpr OUString sIsContinuousNumbering( u"IsContinuousNumbering"_ustr  );
854
855
SvxXMLListStyleContext::SvxXMLListStyleContext( SvXMLImport& rImport,
856
        bool bOutl )
857
3.31k
:   SvXMLStyleContext( rImport, bOutl ? XmlStyleFamily::TEXT_OUTLINE : XmlStyleFamily::TEXT_LIST )
858
3.31k
,   m_bConsecutive( false )
859
3.31k
,   m_bOutline( bOutl )
860
3.31k
{
861
3.31k
}
862
863
3.31k
SvxXMLListStyleContext::~SvxXMLListStyleContext() {}
864
865
css::uno::Reference< css::xml::sax::XFastContextHandler > SvxXMLListStyleContext::createFastChildContext(
866
        sal_Int32 nElement,
867
        const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
868
26.8k
{
869
26.8k
    if( m_bOutline
870
26.8k
        ? nElement == XML_ELEMENT(TEXT, XML_OUTLINE_LEVEL_STYLE)
871
26.8k
        : ( nElement == XML_ELEMENT(TEXT, XML_LIST_LEVEL_STYLE_NUMBER) ||
872
5.55k
            nElement == XML_ELEMENT(TEXT, XML_LIST_LEVEL_STYLE_BULLET) ||
873
124
            nElement == XML_ELEMENT(TEXT, XML_LIST_LEVEL_STYLE_IMAGE )    ) )
874
26.4k
    {
875
26.4k
        rtl::Reference<SvxXMLListLevelStyleContext_Impl> xLevelStyle{
876
26.4k
            new SvxXMLListLevelStyleContext_Impl( GetImport(), nElement, xAttrList )};
877
26.4k
        if( !m_pLevelStyles )
878
3.30k
            m_pLevelStyles = std::make_unique<SvxXMLListStyle_Impl>();
879
26.4k
        m_pLevelStyles->push_back( xLevelStyle );
880
881
26.4k
        return xLevelStyle;
882
26.4k
    }
883
374
    XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
884
374
    return nullptr;
885
374
}
886
887
void SvxXMLListStyleContext::FillUnoNumRule(
888
        const Reference<container::XIndexReplace> & rNumRule) const
889
1.62k
{
890
1.62k
    try
891
1.62k
    {
892
1.62k
        if( m_pLevelStyles && rNumRule.is() )
893
1.62k
        {
894
1.62k
            sal_Int32 l_nLevels = rNumRule->getCount();
895
1.62k
            for (const auto& pLevelStyle : *m_pLevelStyles)
896
13.0k
            {
897
13.0k
                sal_Int32 nLevel = pLevelStyle->GetLevel();
898
13.0k
                if( nLevel >= 0 && nLevel < l_nLevels )
899
12.9k
                {
900
12.9k
                    Sequence<beans::PropertyValue> aProps =
901
12.9k
                        pLevelStyle->GetProperties();
902
12.9k
                    rNumRule->replaceByIndex( nLevel, Any(aProps) );
903
12.9k
                }
904
13.0k
            }
905
1.62k
        }
906
907
1.62k
        Reference < XPropertySet > xPropSet( rNumRule, UNO_QUERY );
908
1.62k
        Reference< XPropertySetInfo > xPropSetInfo;
909
1.62k
        if (xPropSet.is())
910
1.38k
            xPropSetInfo = xPropSet->getPropertySetInfo();
911
1.62k
        if( xPropSetInfo.is() &&
912
1.38k
            xPropSetInfo->hasPropertyByName( sIsContinuousNumbering ) )
913
1.38k
        {
914
1.38k
            xPropSet->setPropertyValue( sIsContinuousNumbering, Any(m_bConsecutive) );
915
1.38k
        }
916
1.62k
    }
917
1.62k
    catch (const Exception&)
918
1.62k
    {
919
50
        TOOLS_WARN_EXCEPTION("xmloff.style", "" );
920
50
    }
921
1.62k
}
922
923
void SvxXMLListStyleContext::CreateAndInsertLate( bool bOverwrite )
924
1.57k
{
925
1.57k
    if( m_bOutline )
926
791
    {
927
791
        if( bOverwrite )
928
791
        {
929
791
            const Reference< XIndexReplace >& rNumRule =
930
791
                GetImport().GetTextImport()->GetChapterNumbering();
931
            // We don't set xNumberingRules here, to avoid using them
932
            // as numbering rules.
933
791
            if( rNumRule.is() )
934
752
                FillUnoNumRule(rNumRule);
935
791
        }
936
791
    }
937
780
    else
938
780
    {
939
780
        Reference < XStyle > xStyle;
940
780
        const OUString& rName = GetDisplayName();
941
780
        if( rName.isEmpty() )
942
85
        {
943
85
            SetValid( false );
944
85
            return;
945
85
        }
946
947
695
        const Reference < XNameContainer >& rNumStyles =
948
695
                GetImport().GetTextImport()->GetNumberingStyles();
949
695
        if( !rNumStyles.is() )
950
9
        {
951
9
            SetValid( false );
952
9
            return;
953
9
        }
954
955
686
        bool bNew = false;
956
686
        if( rNumStyles->hasByName( rName ) )
957
157
        {
958
157
            Any aAny = rNumStyles->getByName( rName );
959
157
            aAny >>= xStyle;
960
157
        }
961
529
        else
962
529
        {
963
529
            Reference< XMultiServiceFactory > xFactory( GetImport().GetModel(),
964
529
                                                        UNO_QUERY );
965
529
            SAL_WARN_IF( !xFactory.is(), "xmloff", "no factory" );
966
529
            if( !xFactory.is() )
967
0
                return;
968
969
529
            Reference < XInterface > xIfc = xFactory->createInstance(u"com.sun.star.style.NumberingStyle"_ustr);
970
529
            if( !xIfc.is() )
971
0
                return;
972
529
            xStyle.set(xIfc, UNO_QUERY);
973
529
            if( !xStyle.is() )
974
0
                return;
975
976
529
            rNumStyles->insertByName( rName, Any(xStyle) );
977
529
            bNew = true;
978
529
        }
979
980
686
        Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
981
686
        Reference< XPropertySetInfo > xPropSetInfo =
982
686
            xPropSet->getPropertySetInfo();
983
686
        if( !bNew && xPropSetInfo->hasPropertyByName( sIsPhysical ) )
984
157
        {
985
157
            Any aAny = xPropSet->getPropertyValue( sIsPhysical );
986
157
            bNew = !*o3tl::doAccess<bool>(aAny);
987
157
        }
988
989
686
        if ( xPropSetInfo->hasPropertyByName( u"Hidden"_ustr ) )
990
686
            xPropSet->setPropertyValue( u"Hidden"_ustr, uno::Any( IsHidden( ) ) );
991
992
686
        if( rName != GetName() )
993
679
            GetImport().AddStyleDisplayName( XmlStyleFamily::TEXT_LIST,
994
679
                                             GetName(), rName );
995
996
686
        Any aAny = xPropSet->getPropertyValue( sNumberingRules );
997
686
        aAny >>= m_xNumRules;
998
686
        if( bOverwrite || bNew )
999
686
        {
1000
686
            FillUnoNumRule(m_xNumRules);
1001
686
            xPropSet->setPropertyValue( sNumberingRules, Any(m_xNumRules) );
1002
686
        }
1003
0
        else
1004
0
        {
1005
0
            SetValid( false );
1006
0
        }
1007
1008
686
        SetNew( bNew );
1009
686
    }
1010
1.57k
}
1011
1012
void SvxXMLListStyleContext::CreateAndInsertAuto() const
1013
0
{
1014
0
    SAL_WARN_IF( m_bOutline, "xmloff", "Outlines cannot be inserted here" );
1015
0
    SAL_WARN_IF( m_xNumRules.is(), "xmloff", "Numbering Rule is existing already" );
1016
1017
0
    const OUString& rName = GetName();
1018
0
    if( m_bOutline || m_xNumRules.is() || rName.isEmpty() )
1019
0
    {
1020
0
        const_cast<SvxXMLListStyleContext *>(this)->SetValid( false );
1021
0
        return;
1022
0
    }
1023
1024
0
    const_cast<SvxXMLListStyleContext *>(this)->m_xNumRules = CreateNumRule(
1025
0
        GetImport().GetModel() );
1026
1027
0
    FillUnoNumRule(m_xNumRules);
1028
0
}
1029
1030
Reference < XIndexReplace > SvxXMLListStyleContext::CreateNumRule(
1031
                                const Reference < XModel > & rModel )
1032
136k
{
1033
136k
    Reference<XIndexReplace> xNumRule;
1034
1035
136k
    Reference< XMultiServiceFactory > xFactory( rModel, UNO_QUERY );
1036
136k
    SAL_WARN_IF( !xFactory.is(), "xmloff", "no factory" );
1037
136k
    if( !xFactory.is() )
1038
0
        return xNumRule;
1039
1040
136k
    Reference < XInterface > xIfc = xFactory->createInstance(u"com.sun.star.text.NumberingRules"_ustr);
1041
136k
    if( !xIfc.is() )
1042
0
        return xNumRule;
1043
1044
136k
    xNumRule.set( xIfc, UNO_QUERY );
1045
136k
    SAL_WARN_IF( !xNumRule.is(), "xmloff", "go no numbering rule" );
1046
1047
136k
    return xNumRule;
1048
136k
}
1049
1050
void SvxXMLListStyleContext::SetDefaultStyle(
1051
        const Reference < XIndexReplace > & rNumRule,
1052
        sal_Int16 nLevel,
1053
        bool bOrdered )
1054
136k
{
1055
136k
    Sequence<beans::PropertyValue> aPropSeq( bOrdered ? 1 : 4  );
1056
136k
    beans::PropertyValue *pProps = aPropSeq.getArray();
1057
1058
136k
    pProps->Name = "NumberingType";
1059
136k
    (pProps++)->Value <<= static_cast<sal_Int16>(bOrdered ? NumberingType::ARABIC
1060
136k
                                                 : NumberingType::CHAR_SPECIAL );
1061
136k
    if( !bOrdered )
1062
136k
    {
1063
        // TODO: Bullet-Font
1064
136k
        awt::FontDescriptor aFDesc;
1065
136k
        aFDesc.Name =
1066
#ifdef _WIN32
1067
                        "StarBats"
1068
#else
1069
136k
                        "starbats"
1070
136k
#endif
1071
136k
                                        ;
1072
136k
        aFDesc.Family = FAMILY_DONTKNOW ;
1073
136k
        aFDesc.Pitch = PITCH_DONTKNOW ;
1074
136k
        aFDesc.CharSet = RTL_TEXTENCODING_SYMBOL ;
1075
136k
        aFDesc.Weight = WEIGHT_DONTKNOW;
1076
136k
        pProps->Name = "BulletFont";
1077
136k
        (pProps++)->Value <<= aFDesc;
1078
1079
136k
        pProps->Name = "BulletChar";
1080
136k
        (pProps++)->Value <<= OUString(sal_Unicode(0xF000 + 149));
1081
136k
        pProps->Name = "CharStyleName";
1082
136k
        (pProps++)->Value <<= u"Numbering Symbols"_ustr;
1083
136k
    }
1084
1085
136k
    rNumRule->replaceByIndex( nLevel, Any(aPropSeq) );
1086
136k
}
1087
1088
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */