Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/text/txtimppr.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 <sal/config.h>
21
22
#include <o3tl/any.hxx>
23
#include <osl/thread.h>
24
#include <com/sun/star/awt/FontFamily.hpp>
25
#include <com/sun/star/awt/FontPitch.hpp>
26
#include <com/sun/star/drawing/FillStyle.hpp>
27
#include <com/sun/star/table/BorderLine2.hpp>
28
#include <com/sun/star/text/VertOrientation.hpp>
29
#include <com/sun/star/text/SizeType.hpp>
30
#include <xmloff/XMLFontStylesContext.hxx>
31
#include <xmloff/txtprmap.hxx>
32
#include <xmloff/xmlimp.hxx>
33
#include <xmloff/txtimppr.hxx>
34
#include <xmloff/maptype.hxx>
35
36
35.6k
#define XML_LINE_LEFT 0
37
34.4k
#define XML_LINE_RIGHT 1
38
44.0k
#define XML_LINE_TOP 2
39
47.6k
#define XML_LINE_BOTTOM 3
40
41
42
using namespace ::com::sun::star;
43
using namespace ::com::sun::star::uno;
44
using namespace ::com::sun::star::table;
45
using namespace ::com::sun::star::text;
46
47
bool XMLTextImportPropertyMapper::handleSpecialItem(
48
            XMLPropertyState& rProperty,
49
            ::std::vector< XMLPropertyState >& rProperties,
50
            const OUString& rValue,
51
            const SvXMLUnitConverter& rUnitConverter,
52
            const SvXMLNamespaceMap& rNamespaceMap ) const
53
61.4k
{
54
61.4k
    bool bRet = false;
55
61.4k
    sal_Int32 nIndex = rProperty.mnIndex;
56
61.4k
    switch( getPropertySetMapper()->GetEntryContextId( nIndex  ) )
57
61.4k
    {
58
35.8k
    case CTF_FONTNAME:
59
42.4k
    case CTF_FONTNAME_CJK:
60
54.0k
    case CTF_FONTNAME_CTL:
61
54.0k
        if( GetImport().GetFontDecls() != nullptr )
62
51.4k
        {
63
51.4k
            assert((
64
51.4k
                ( CTF_FONTFAMILYNAME ==
65
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
66
51.4k
                  CTF_FONTSTYLENAME ==
67
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
68
51.4k
                  CTF_FONTFAMILY ==
69
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
70
51.4k
                  CTF_FONTPITCH ==
71
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
72
51.4k
                  CTF_FONTCHARSET ==
73
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
74
51.4k
                ( CTF_FONTFAMILYNAME_CJK ==
75
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
76
51.4k
                  CTF_FONTSTYLENAME_CJK ==
77
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
78
51.4k
                  CTF_FONTFAMILY_CJK ==
79
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
80
51.4k
                  CTF_FONTPITCH_CJK ==
81
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
82
51.4k
                  CTF_FONTCHARSET_CJK ==
83
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
84
51.4k
                ( CTF_FONTFAMILYNAME_CTL ==
85
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
86
51.4k
                  CTF_FONTSTYLENAME_CTL ==
87
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
88
51.4k
                  CTF_FONTFAMILY_CTL ==
89
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
90
51.4k
                  CTF_FONTPITCH_CTL ==
91
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
92
51.4k
                  CTF_FONTCHARSET_CTL ==
93
51.4k
                    getPropertySetMapper()->GetEntryContextId(nIndex+5) )
94
51.4k
              ) && "illegal property map" );
95
96
51.4k
            GetImport().GetFontDecls()->FillProperties(
97
51.4k
                            rValue, rProperties,
98
51.4k
                            rProperty.mnIndex+1, rProperty.mnIndex+2,
99
51.4k
                            rProperty.mnIndex+3, rProperty.mnIndex+4,
100
51.4k
                            rProperty.mnIndex+5 );
101
51.4k
            bRet = false; // the property hasn't been filled
102
51.4k
        }
103
54.0k
        break;
104
105
    // If we want to do StarMath/StarSymbol font conversion, then we'll
106
    // want these special items to be treated just like regular ones...
107
    // For the Writer, we'll catch and convert them in _FillPropertySet;
108
    // the other apps probably don't care. For the other apps, we just
109
    // imitate the default non-special-item mechanism.
110
3.74k
    case CTF_FONTFAMILYNAME:
111
5.02k
    case CTF_FONTFAMILYNAME_CJK:
112
7.47k
    case CTF_FONTFAMILYNAME_CTL:
113
7.47k
        bRet = getPropertySetMapper()->importXML( rValue, rProperty,
114
7.47k
                                                  rUnitConverter );
115
7.47k
        break;
116
117
0
    case CTF_TEXT_DISPLAY:
118
0
        bRet = getPropertySetMapper()->importXML( rValue, rProperty,
119
0
                                                  rUnitConverter );
120
0
        if( SvXMLImport::OOo_2x == GetImport().getGeneratorVersion() )
121
0
        {
122
0
            bool bHidden = false;
123
0
            rProperty.maValue >>= bHidden;
124
0
            bHidden = !bHidden;
125
0
            rProperty.maValue <<= bHidden;
126
0
        }
127
0
    break;
128
3
    default:
129
3
        bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty,
130
3
                    rProperties, rValue, rUnitConverter, rNamespaceMap );
131
3
        break;
132
61.4k
    }
133
134
61.4k
    return bRet;
135
61.4k
}
136
137
XMLTextImportPropertyMapper::XMLTextImportPropertyMapper(
138
            const rtl::Reference< XMLPropertySetMapper >& rMapper,
139
            SvXMLImport& rImp ) :
140
163k
    SvXMLImportPropertyMapper( rMapper, rImp ),
141
163k
    m_nSizeTypeIndex( -2 ),
142
163k
    m_nWidthTypeIndex( -2 )
143
163k
{
144
163k
}
145
146
XMLTextImportPropertyMapper::~XMLTextImportPropertyMapper()
147
163k
{
148
163k
}
149
150
void XMLTextImportPropertyMapper::FontFinished(
151
    XMLPropertyState *pFontFamilyNameState,
152
    XMLPropertyState *pFontStyleNameState,
153
    XMLPropertyState *pFontFamilyState,
154
    XMLPropertyState *pFontPitchState,
155
    XMLPropertyState *pFontCharsetState )
156
45.1k
{
157
45.1k
    if( pFontFamilyNameState && pFontFamilyNameState->mnIndex != -1 )
158
44.3k
    {
159
44.3k
        OUString sName;
160
44.3k
        pFontFamilyNameState->maValue >>= sName;
161
44.3k
        if( sName.isEmpty() )
162
10.5k
            pFontFamilyNameState->mnIndex = -1;
163
44.3k
    }
164
45.1k
    if( !pFontFamilyNameState || pFontFamilyNameState->mnIndex == -1 )
165
11.3k
    {
166
11.3k
        if( pFontStyleNameState )
167
10.9k
            pFontStyleNameState->mnIndex = -1;
168
11.3k
        if( pFontFamilyState )
169
10.7k
            pFontFamilyState->mnIndex = -1;
170
11.3k
        if( pFontPitchState )
171
10.8k
            pFontPitchState->mnIndex = -1;
172
11.3k
        if( pFontCharsetState )
173
10.6k
            pFontCharsetState->mnIndex = -1;
174
11.3k
    }
175
45.1k
}
176
177
/** since the properties "CharFontFamilyName", "CharFontStyleName", "CharFontFamily",
178
    "CharFontPitch" and "CharFontSet" and their CJK and CTL counterparts are only
179
    usable as a union, we add defaults to all values that are not set as long as we
180
    have an "CharFontFamilyName"
181
182
    #99928# CL */
183
void XMLTextImportPropertyMapper::FontDefaultsCheck(
184
                                        XMLPropertyState const * pFontFamilyName,
185
                                        XMLPropertyState const * pFontStyleName,
186
                                        XMLPropertyState const * pFontFamily,
187
                                        XMLPropertyState const * pFontPitch,
188
                                        XMLPropertyState const * pFontCharSet,
189
                                        std::optional<XMLPropertyState>* ppNewFontStyleName,
190
                                        std::optional<XMLPropertyState>* ppNewFontFamily,
191
                                        std::optional<XMLPropertyState>* ppNewFontPitch,
192
                                        std::optional<XMLPropertyState>* ppNewFontCharSet ) const
193
460k
{
194
460k
    if( pFontFamilyName )
195
44.3k
    {
196
44.3k
        Any aAny;
197
198
44.3k
        if( !pFontStyleName )
199
3.78k
        {
200
3.78k
            aAny <<= OUString();
201
    #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
202
            sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
203
                                                pFontFamilyName->mnIndex + 1 );
204
            assert(nTmp == CTF_FONTSTYLENAME || nTmp == CTF_FONTSTYLENAME_CJK || nTmp == CTF_FONTSTYLENAME_CTL);
205
    #endif
206
3.78k
            ppNewFontStyleName->emplace( pFontFamilyName->mnIndex + 1, aAny );
207
3.78k
        }
208
209
44.3k
        if( !pFontFamily )
210
2.80k
        {
211
2.80k
            aAny <<= sal_Int16(css::awt::FontFamily::DONTKNOW);
212
213
    #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
214
            sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
215
                                                pFontFamilyName->mnIndex + 2 );
216
            assert(nTmp == CTF_FONTFAMILY || nTmp == CTF_FONTFAMILY_CJK || nTmp == CTF_FONTFAMILY_CTL);
217
    #endif
218
2.80k
            ppNewFontFamily->emplace( pFontFamilyName->mnIndex + 2, aAny );
219
2.80k
        }
220
221
44.3k
        if( !pFontPitch )
222
2.60k
        {
223
2.60k
            aAny <<= sal_Int16(css::awt::FontPitch::DONTKNOW);
224
    #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
225
            sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
226
                                                pFontFamilyName->mnIndex + 3 );
227
            assert(nTmp == CTF_FONTPITCH || nTmp == CTF_FONTPITCH_CJK || nTmp == CTF_FONTPITCH_CTL);
228
    #endif
229
2.60k
            ppNewFontPitch->emplace( pFontFamilyName->mnIndex + 3, aAny );
230
2.60k
        }
231
232
44.3k
        if( !pFontCharSet )
233
3.97k
        {
234
3.97k
            aAny <<= static_cast<sal_Int16>(osl_getThreadTextEncoding());
235
    #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
236
            sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
237
                                                pFontFamilyName->mnIndex + 4 );
238
            assert(nTmp == CTF_FONTCHARSET || nTmp == CTF_FONTCHARSET_CJK || nTmp == CTF_FONTCHARSET_CTL);
239
    #endif
240
3.97k
            ppNewFontCharSet->emplace( pFontFamilyName->mnIndex + 4, aAny );
241
3.97k
        }
242
44.3k
    }
243
244
460k
    (void) this; // avoid loplugin:staticmethods
245
460k
}
246
247
namespace {
248
//fdo#58730 The [UL|LR]Space class has a deficiency where "100%" also serves as
249
//a flag that the value is an absolute value so we can't truly handle an
250
//up/lower space property which wants to specify its 200% upper but 100% lower
251
//of its parent (try typing 100% vs 200% into the edit style dialog and revisit
252
//your style). So on xml load that ends up meaning 200%, 0 lower. This is a
253
//crock.
254
255
//On import clear 100% all-margins relative sizes.
256
bool
257
isNotDefaultRelSize(const XMLPropertyState* pRelState, const rtl::Reference<XMLPropertySetMapper>& rPrMap)
258
4
{
259
4
    if (rPrMap->GetEntryContextId(pRelState->mnIndex) == CTF_PARAMARGINALL_REL)
260
0
    {
261
0
        sal_Int32 nTemp = 0;
262
0
        pRelState->maValue >>= nTemp;
263
0
        return nTemp != 100;
264
0
    }
265
4
    return true;
266
4
}
267
268
/**
269
 * Separate compressed border attributes.
270
 * During export, border attributes are compressed if there are equal to all four side.
271
 * Since Writer hasn't the same compressed attributes, but has distinct ones for all
272
 * four side, we have to duplicate the compressed attribute during import.
273
**/
274
void lcl_SeparateBorder(
275
    sal_uInt16 nIndex, XMLPropertyState const * pAllBorderDistance,
276
    XMLPropertyState* pBorderDistances[4], XMLPropertyState* pNewBorderDistances[4],
277
    XMLPropertyState const * pAllBorder, XMLPropertyState* pBorders[4],
278
    XMLPropertyState* pNewBorders[4], XMLPropertyState* pAllBorderWidth,
279
    XMLPropertyState* pBorderWidths[4]
280
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
281
    , const rtl::Reference< XMLPropertySetMapper >& rMapper
282
#endif
283
)
284
1.22M
{
285
1.22M
    if( pAllBorderDistance && !pBorderDistances[nIndex] )
286
11.3k
    {
287
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
288
        sal_Int16 nTmp = rMapper->GetEntryContextId(
289
                                    pAllBorderDistance->mnIndex + nIndex + 1 );
290
        if (CTF_CHARALLBORDERDISTANCE ==
291
                rMapper->GetEntryContextId(pAllBorderDistance->mnIndex))
292
        {
293
            assert(nTmp >= CTF_CHARLEFTBORDERDISTANCE &&
294
                   nTmp <= CTF_CHARBOTTOMBORDERDISTANCE);
295
        }
296
        else
297
        {
298
            assert(nTmp >= CTF_LEFTBORDERDISTANCE &&
299
                   nTmp <= CTF_BOTTOMBORDERDISTANCE);
300
        }
301
#endif
302
11.3k
        pNewBorderDistances[nIndex] =
303
11.3k
            new XMLPropertyState( pAllBorderDistance->mnIndex + nIndex + 1,
304
11.3k
                                    pAllBorderDistance->maValue );
305
11.3k
        pBorderDistances[nIndex] = pNewBorderDistances[nIndex];
306
11.3k
    }
307
1.22M
    if( pAllBorder && !pBorders[nIndex] )
308
3.54k
    {
309
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
310
        sal_Int16 nTmp = rMapper->GetEntryContextId(
311
                                        pAllBorder->mnIndex + nIndex + 1 );
312
        if (CTF_CHARALLBORDER ==
313
                rMapper->GetEntryContextId(pAllBorder->mnIndex))
314
        {
315
            assert(nTmp >= CTF_CHARLEFTBORDER && nTmp <= CTF_CHARBOTTOMBORDER);
316
        }
317
        else
318
        {
319
            assert(nTmp >= CTF_LEFTBORDER && nTmp <= CTF_BOTTOMBORDER);
320
        }
321
#endif
322
3.54k
        pNewBorders[nIndex] = new XMLPropertyState( pAllBorder->mnIndex + nIndex + 1,
323
3.54k
                                                   pAllBorder->maValue );
324
3.54k
        pBorders[nIndex] = pNewBorders[nIndex];
325
3.54k
    }
326
1.22M
    if( !pBorderWidths[nIndex] )
327
1.22M
        pBorderWidths[nIndex] = pAllBorderWidth;
328
550
    else
329
550
        pBorderWidths[nIndex]->mnIndex = -1;
330
331
1.22M
    if( !(pBorders[nIndex] && pBorderWidths[nIndex]) )
332
1.22M
        return;
333
334
462
    table::BorderLine2 aBorderLine;
335
462
    pBorders[nIndex]->maValue >>= aBorderLine;
336
337
462
    table::BorderLine2 aBorderLineWidth;
338
462
    pBorderWidths[nIndex]->maValue >>= aBorderLineWidth;
339
340
462
    aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
341
462
    aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
342
462
    aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
343
462
    aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
344
345
462
    pBorders[nIndex]->maValue <<= aBorderLine;
346
462
}
347
348
}
349
350
void XMLTextImportPropertyMapper::finished(
351
            ::std::vector< XMLPropertyState >& rProperties,
352
            sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
353
153k
{
354
153k
    bool bHasAnyHeight = false;
355
153k
    bool bHasAnyMinHeight = false;
356
153k
    bool bHasAnyWidth = false;
357
153k
    bool bHasAnyMinWidth = false;
358
359
153k
    XMLPropertyState* pFontFamilyName = nullptr;
360
153k
    XMLPropertyState* pFontStyleName = nullptr;
361
153k
    XMLPropertyState* pFontFamily = nullptr;
362
153k
    XMLPropertyState* pFontPitch = nullptr;
363
153k
    XMLPropertyState* pFontCharSet = nullptr;
364
153k
    std::optional<XMLPropertyState> pNewFontStyleName;
365
153k
    std::optional<XMLPropertyState> pNewFontFamily;
366
153k
    std::optional<XMLPropertyState> pNewFontPitch;
367
153k
    std::optional<XMLPropertyState> pNewFontCharSet;
368
153k
    XMLPropertyState* pFontFamilyNameCJK = nullptr;
369
153k
    XMLPropertyState* pFontStyleNameCJK = nullptr;
370
153k
    XMLPropertyState* pFontFamilyCJK = nullptr;
371
153k
    XMLPropertyState* pFontPitchCJK = nullptr;
372
153k
    XMLPropertyState* pFontCharSetCJK = nullptr;
373
153k
    std::optional<XMLPropertyState> pNewFontStyleNameCJK;
374
153k
    std::optional<XMLPropertyState> pNewFontFamilyCJK;
375
153k
    std::optional<XMLPropertyState> pNewFontPitchCJK;
376
153k
    std::optional<XMLPropertyState> pNewFontCharSetCJK;
377
153k
    XMLPropertyState* pFontFamilyNameCTL = nullptr;
378
153k
    XMLPropertyState* pFontStyleNameCTL = nullptr;
379
153k
    XMLPropertyState* pFontFamilyCTL = nullptr;
380
153k
    XMLPropertyState* pFontPitchCTL = nullptr;
381
153k
    XMLPropertyState* pFontCharSetCTL = nullptr;
382
153k
    std::optional<XMLPropertyState> pNewFontStyleNameCTL;
383
153k
    std::optional<XMLPropertyState> pNewFontFamilyCTL;
384
153k
    std::optional<XMLPropertyState> pNewFontPitchCTL;
385
153k
    std::optional<XMLPropertyState> pNewFontCharSetCTL;
386
153k
    XMLPropertyState* pAllBorderDistance = nullptr;
387
153k
    XMLPropertyState* pBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
388
153k
    XMLPropertyState* pNewBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
389
153k
    XMLPropertyState* pAllBorder = nullptr;
390
153k
    XMLPropertyState* pBorders[4] = { nullptr, nullptr, nullptr, nullptr };
391
153k
    XMLPropertyState* pNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
392
153k
    XMLPropertyState* pAllBorderWidth = nullptr;
393
153k
    XMLPropertyState* pBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
394
153k
    XMLPropertyState* pCharAllBorderDistance = nullptr;
395
153k
    XMLPropertyState* pCharBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
396
153k
    XMLPropertyState* pCharNewBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
397
153k
    XMLPropertyState* pCharAllBorder = nullptr;
398
153k
    XMLPropertyState* pCharBorders[4] = { nullptr, nullptr, nullptr, nullptr };
399
153k
    XMLPropertyState* pCharNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
400
153k
    XMLPropertyState* pCharAllBorderWidth = nullptr;
401
153k
    XMLPropertyState* pCharBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
402
153k
    XMLPropertyState* pVertOrient = nullptr;
403
153k
    XMLPropertyState* pVertOrientRelAsChar = nullptr;
404
153k
    XMLPropertyState* pBackTransparency = nullptr; // transparency in %
405
153k
    XMLPropertyState* pBackTransparent = nullptr;  // transparency as boolean
406
153k
    XMLPropertyState* pAllParaMargin = nullptr;
407
153k
    XMLPropertyState* pParaMargins[4] = { nullptr, nullptr, nullptr, nullptr };
408
153k
    ::std::optional<XMLPropertyState> pNewParaMargins[4];
409
153k
    XMLPropertyState* pAllMargin = nullptr;
410
153k
    XMLPropertyState* pMargins[4] = { nullptr, nullptr, nullptr, nullptr };
411
153k
    ::std::optional<XMLPropertyState> pNewMargins[4];
412
153k
    XMLPropertyState* pFillStyle(nullptr);
413
153k
    XMLPropertyState* pFillColor(nullptr);
414
415
153k
    for( auto& rProperty : rProperties )
416
7.99M
    {
417
7.99M
        XMLPropertyState* property = &rProperty;
418
7.99M
        if( -1 == property->mnIndex )
419
2.38M
            continue;
420
421
5.61M
        switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ) )
422
5.61M
        {
423
358k
        case CTF_FONTFAMILYNAME:    pFontFamilyName = property; break;
424
353k
        case CTF_FONTSTYLENAME: pFontStyleName = property;  break;
425
353k
        case CTF_FONTFAMILY:    pFontFamily = property; break;
426
353k
        case CTF_FONTPITCH: pFontPitch = property;  break;
427
355k
        case CTF_FONTCHARSET:   pFontCharSet = property;    break;
428
429
6.25k
        case CTF_FONTFAMILYNAME_CJK:    pFontFamilyNameCJK = property;  break;
430
4.94k
        case CTF_FONTSTYLENAME_CJK: pFontStyleNameCJK = property;   break;
431
5.78k
        case CTF_FONTFAMILY_CJK:    pFontFamilyCJK = property;  break;
432
5.78k
        case CTF_FONTPITCH_CJK: pFontPitchCJK = property;   break;
433
4.94k
        case CTF_FONTCHARSET_CJK:   pFontCharSetCJK = property; break;
434
435
10.7k
        case CTF_FONTFAMILYNAME_CTL:    pFontFamilyNameCTL = property;  break;
436
8.27k
        case CTF_FONTSTYLENAME_CTL: pFontStyleNameCTL = property;   break;
437
9.43k
        case CTF_FONTFAMILY_CTL:    pFontFamilyCTL = property;  break;
438
9.62k
        case CTF_FONTPITCH_CTL: pFontPitchCTL = property;   break;
439
8.27k
        case CTF_FONTCHARSET_CTL:   pFontCharSetCTL = property; break;
440
441
2.78k
        case CTF_ALLBORDERDISTANCE:     pAllBorderDistance = property; break;
442
13.0k
        case CTF_LEFTBORDERDISTANCE:    pBorderDistances[XML_LINE_LEFT] = property; break;
443
12.7k
        case CTF_RIGHTBORDERDISTANCE:   pBorderDistances[XML_LINE_RIGHT] = property; break;
444
16.8k
        case CTF_TOPBORDERDISTANCE:     pBorderDistances[XML_LINE_TOP] = property; break;
445
14.7k
        case CTF_BOTTOMBORDERDISTANCE:  pBorderDistances[XML_LINE_BOTTOM] = property; break;
446
877
        case CTF_ALLBORDER:             pAllBorder = property; break;
447
5.92k
        case CTF_LEFTBORDER:            pBorders[XML_LINE_LEFT] = property; break;
448
4.46k
        case CTF_RIGHTBORDER:           pBorders[XML_LINE_RIGHT] = property; break;
449
2.53k
        case CTF_TOPBORDER:             pBorders[XML_LINE_TOP] = property; break;
450
2.32k
        case CTF_BOTTOMBORDER:          pBorders[XML_LINE_BOTTOM] = property; break;
451
0
        case CTF_ALLBORDERWIDTH:        pAllBorderWidth = property; break;
452
0
        case CTF_LEFTBORDERWIDTH:       pBorderWidths[XML_LINE_LEFT] = property; break;
453
0
        case CTF_RIGHTBORDERWIDTH:      pBorderWidths[XML_LINE_RIGHT] = property; break;
454
0
        case CTF_TOPBORDERWIDTH:        pBorderWidths[XML_LINE_TOP] = property; break;
455
543
        case CTF_BOTTOMBORDERWIDTH:     pBorderWidths[XML_LINE_BOTTOM] = property; break;
456
457
1.08k
        case CTF_CHARALLBORDERDISTANCE:     pCharAllBorderDistance = property; break;
458
1.49k
        case CTF_CHARLEFTBORDERDISTANCE:    pCharBorderDistances[XML_LINE_LEFT] = property; break;
459
1.49k
        case CTF_CHARRIGHTBORDERDISTANCE:   pCharBorderDistances[XML_LINE_RIGHT] = property; break;
460
1.49k
        case CTF_CHARTOPBORDERDISTANCE:     pCharBorderDistances[XML_LINE_TOP] = property; break;
461
1.50k
        case CTF_CHARBOTTOMBORDERDISTANCE:  pCharBorderDistances[XML_LINE_BOTTOM] = property; break;
462
9
        case CTF_CHARALLBORDER:             pCharAllBorder = property; break;
463
9.21k
        case CTF_CHARLEFTBORDER:            pCharBorders[XML_LINE_LEFT] = property; break;
464
9.31k
        case CTF_CHARRIGHTBORDER:           pCharBorders[XML_LINE_RIGHT] = property; break;
465
51
        case CTF_CHARTOPBORDER:             pCharBorders[XML_LINE_TOP] = property; break;
466
66
        case CTF_CHARBOTTOMBORDER:          pCharBorders[XML_LINE_BOTTOM] = property; break;
467
0
        case CTF_CHARALLBORDERWIDTH:        pCharAllBorderWidth = property; break;
468
0
        case CTF_CHARLEFTBORDERWIDTH:       pCharBorderWidths[XML_LINE_LEFT] = property; break;
469
0
        case CTF_CHARRIGHTBORDERWIDTH:      pCharBorderWidths[XML_LINE_RIGHT] = property; break;
470
0
        case CTF_CHARTOPBORDERWIDTH:        pCharBorderWidths[XML_LINE_TOP] = property; break;
471
7
        case CTF_CHARBOTTOMBORDERWIDTH:     pCharBorderWidths[XML_LINE_BOTTOM] = property; break;
472
473
2.15k
        case CTF_ANCHORTYPE:            break;
474
4.99k
        case CTF_VERTICALPOS:           pVertOrient = property; break;
475
2.09k
        case CTF_VERTICALREL_ASCHAR:    pVertOrientRelAsChar = property; break;
476
477
205
        case CTF_FRAMEHEIGHT_MIN_ABS:
478
205
        case CTF_FRAMEHEIGHT_MIN_REL:
479
//      case CTF_SYNCHEIGHT_MIN:
480
205
                                        bHasAnyMinHeight = true;
481
205
                                        [[fallthrough]];
482
244
        case CTF_FRAMEHEIGHT_ABS:
483
244
        case CTF_FRAMEHEIGHT_REL:
484
//      case CTF_SYNCHEIGHT:
485
244
                                        bHasAnyHeight = true; break;
486
0
        case CTF_FRAMEWIDTH_MIN_ABS:
487
0
        case CTF_FRAMEWIDTH_MIN_REL:
488
0
                                        bHasAnyMinWidth = true;
489
0
                                        [[fallthrough]];
490
178
        case CTF_FRAMEWIDTH_ABS:
491
179
        case CTF_FRAMEWIDTH_REL:
492
179
                                        bHasAnyWidth = true; break;
493
15
        case CTF_BACKGROUND_TRANSPARENCY: pBackTransparency = property; break;
494
20
        case CTF_BACKGROUND_TRANSPARENT:  pBackTransparent = property; break;
495
2.59k
        case CTF_FILLSTYLE:             pFillStyle = property; break;
496
6.77k
        case CTF_FILLCOLOR:             pFillColor = property; break;
497
1
        case CTF_PARAMARGINALL:
498
1
        case CTF_PARAMARGINALL_REL:
499
1
                pAllParaMargin = property; break;
500
5.24k
        case CTF_PARALEFTMARGIN:
501
5.24k
        case CTF_PARALEFTMARGIN_REL:
502
5.24k
                pParaMargins[XML_LINE_LEFT] = property; break;
503
5.72k
        case CTF_PARARIGHTMARGIN:
504
5.72k
        case CTF_PARARIGHTMARGIN_REL:
505
5.72k
                pParaMargins[XML_LINE_RIGHT] = property; break;
506
22.7k
        case CTF_PARATOPMARGIN:
507
22.7k
        case CTF_PARATOPMARGIN_REL:
508
22.7k
                pParaMargins[XML_LINE_TOP] = property; break;
509
28.0k
        case CTF_PARABOTTOMMARGIN:
510
28.0k
        case CTF_PARABOTTOMMARGIN_REL:
511
28.0k
                pParaMargins[XML_LINE_BOTTOM] = property; break;
512
0
        case CTF_MARGINALL:
513
0
                pAllMargin = property; break;
514
729
        case CTF_MARGINLEFT:
515
729
                pMargins[XML_LINE_LEFT] = property; break;
516
723
        case CTF_MARGINRIGHT:
517
723
                pMargins[XML_LINE_RIGHT] = property; break;
518
430
        case CTF_MARGINTOP:
519
430
                pMargins[XML_LINE_TOP] = property; break;
520
441
        case CTF_MARGINBOTTOM:
521
441
                pMargins[XML_LINE_BOTTOM] = property; break;
522
5.61M
        }
523
5.61M
    }
524
525
153k
    if( pFontFamilyName || pFontStyleName || pFontFamily ||
526
123k
        pFontPitch || pFontCharSet )
527
29.9k
        FontFinished( pFontFamilyName, pFontStyleName, pFontFamily,
528
29.9k
                      pFontPitch, pFontCharSet );
529
153k
    if( pFontFamilyNameCJK || pFontStyleNameCJK || pFontFamilyCJK ||
530
147k
        pFontPitchCJK || pFontCharSetCJK )
531
5.53k
        FontFinished( pFontFamilyNameCJK, pFontStyleNameCJK, pFontFamilyCJK,
532
5.53k
                      pFontPitchCJK, pFontCharSetCJK );
533
153k
    if( pFontFamilyNameCTL || pFontStyleNameCTL || pFontFamilyCTL ||
534
143k
        pFontPitchCTL || pFontCharSetCTL )
535
9.63k
        FontFinished( pFontFamilyNameCTL, pFontStyleNameCTL, pFontFamilyCTL,
536
9.63k
                      pFontPitchCTL, pFontCharSetCTL );
537
538
766k
    for (sal_uInt16 i = 0; i < 4; i++)
539
613k
    {
540
613k
        if (pAllParaMargin && !pParaMargins[i]
541
4
            && isNotDefaultRelSize(pAllParaMargin, getPropertySetMapper()))
542
4
        {
543
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
544
            sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
545
                                        pAllParaMargin->mnIndex + (2*i) + 2 );
546
            assert(nTmp >= CTF_PARALEFTMARGIN &&
547
                   nTmp <= CTF_PARABOTTOMMARGIN_REL);
548
#endif
549
4
            pNewParaMargins[i].emplace(
550
4
                pAllParaMargin->mnIndex + (2*i) + 2, pAllParaMargin->maValue);
551
4
        }
552
613k
        if (pAllMargin && !pMargins[i])
553
0
        {
554
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
555
            sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
556
                                        pAllMargin->mnIndex + i + 1 );
557
            assert(nTmp >= CTF_MARGINLEFT && nTmp <= CTF_MARGINBOTTOM);
558
#endif
559
0
            pNewMargins[i].emplace(
560
0
                pAllMargin->mnIndex + i + 1, pAllMargin->maValue);
561
0
        }
562
563
613k
        lcl_SeparateBorder(
564
613k
            i, pAllBorderDistance, pBorderDistances, pNewBorderDistances,
565
613k
            pAllBorder, pBorders, pNewBorders,
566
613k
            pAllBorderWidth, pBorderWidths
567
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
568
            , getPropertySetMapper()
569
#endif
570
613k
            );
571
572
613k
        lcl_SeparateBorder(
573
613k
            i, pCharAllBorderDistance, pCharBorderDistances,
574
613k
            pCharNewBorderDistances, pCharAllBorder, pCharBorders,
575
613k
            pCharNewBorders, pCharAllBorderWidth, pCharBorderWidths
576
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
577
            , getPropertySetMapper()
578
#endif
579
613k
            );
580
613k
    }
581
582
153k
    if (pAllParaMargin)
583
1
    {
584
1
        pAllParaMargin->mnIndex = -1;
585
1
    }
586
153k
    if (pAllMargin)
587
0
    {
588
0
        pAllMargin->mnIndex = -1;
589
0
    }
590
591
153k
    if( pAllBorderDistance )
592
2.76k
        pAllBorderDistance->mnIndex = -1;
593
594
153k
    if( pAllBorder )
595
877
        pAllBorder->mnIndex = -1;
596
597
153k
    if( pAllBorderWidth )
598
0
        pAllBorderWidth->mnIndex = -1;
599
600
153k
    if( pCharAllBorderDistance )
601
1.08k
        pCharAllBorderDistance->mnIndex = -1;
602
603
153k
    if( pCharAllBorder )
604
9
        pCharAllBorder->mnIndex = -1;
605
606
153k
    if( pCharAllBorderWidth )
607
0
        pCharAllBorderWidth->mnIndex = -1;
608
609
153k
    if( pVertOrient && pVertOrientRelAsChar )
610
2.06k
    {
611
2.06k
        sal_Int16 nVertOrient = 0;
612
2.06k
        pVertOrient->maValue >>= nVertOrient;
613
2.06k
        sal_Int16 nVertOrientRel = 0;
614
2.06k
        pVertOrientRelAsChar->maValue >>= nVertOrientRel;
615
2.06k
        switch( nVertOrient )
616
2.06k
        {
617
1.52k
        case VertOrientation::TOP:
618
1.52k
            nVertOrient = nVertOrientRel;
619
1.52k
            break;
620
484
        case VertOrientation::CENTER:
621
484
            switch( nVertOrientRel )
622
484
            {
623
484
            case VertOrientation::CHAR_TOP:
624
484
                nVertOrient = VertOrientation::CHAR_CENTER;
625
484
                break;
626
0
            case VertOrientation::LINE_TOP:
627
0
                nVertOrient = VertOrientation::LINE_CENTER;
628
0
                break;
629
484
            }
630
484
            break;
631
484
        case VertOrientation::BOTTOM:
632
50
            switch( nVertOrientRel )
633
50
            {
634
0
            case VertOrientation::CHAR_TOP:
635
0
                nVertOrient = VertOrientation::CHAR_BOTTOM;
636
0
                break;
637
50
            case VertOrientation::LINE_TOP:
638
50
                nVertOrient = VertOrientation::LINE_BOTTOM;
639
50
                break;
640
50
            }
641
50
            break;
642
2.06k
        }
643
2.06k
        pVertOrient->maValue <<= nVertOrient;
644
2.06k
        pVertOrientRelAsChar->mnIndex = -1;
645
2.06k
    }
646
647
153k
    FontDefaultsCheck( pFontFamilyName,
648
153k
                       pFontStyleName, pFontFamily, pFontPitch, pFontCharSet,
649
153k
                       &pNewFontStyleName, &pNewFontFamily, &pNewFontPitch, &pNewFontCharSet );
650
651
153k
    FontDefaultsCheck( pFontFamilyNameCJK,
652
153k
                       pFontStyleNameCJK, pFontFamilyCJK, pFontPitchCJK, pFontCharSetCJK,
653
153k
                       &pNewFontStyleNameCJK, &pNewFontFamilyCJK, &pNewFontPitchCJK, &pNewFontCharSetCJK );
654
655
153k
    FontDefaultsCheck( pFontFamilyNameCTL,
656
153k
                       pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL,
657
153k
                       &pNewFontStyleNameCTL, &pNewFontFamilyCTL, &pNewFontPitchCTL, &pNewFontCharSetCTL );
658
659
153k
    if (pFillStyle && !pFillColor && pBackTransparent
660
0
        && drawing::FillStyle_SOLID == pFillStyle->maValue.get<drawing::FillStyle>()
661
0
        && pBackTransparent->maValue.get<bool>())
662
0
    {
663
        // fo:background="transparent", draw:fill="solid" without draw:fill-color
664
        // prevent getSvxBrushItemFromSourceSet from adding bogus default color
665
0
        pFillStyle->mnIndex = -1;
666
0
    }
667
668
    // #i5775# don't overwrite %transparency with binary transparency
669
153k
    if( ( pBackTransparency != nullptr ) && ( pBackTransparent != nullptr ) )
670
13
    {
671
13
        if( ! *o3tl::doAccess<bool>(pBackTransparent->maValue) )
672
13
            pBackTransparent->mnIndex = -1;
673
13
    }
674
675
676
    // insert newly created properties. This invalidates all iterators!
677
    // Most of the pXXX variables in this method are iterators and will be
678
    // invalidated!!!
679
680
153k
    if( pNewFontStyleName )
681
1.97k
    {
682
1.97k
        rProperties.push_back( *pNewFontStyleName );
683
1.97k
        pNewFontStyleName.reset();
684
1.97k
    }
685
686
153k
    if( pNewFontFamily )
687
1.82k
    {
688
1.82k
        rProperties.push_back( *pNewFontFamily );
689
1.82k
        pNewFontFamily.reset();
690
1.82k
    }
691
692
153k
    if( pNewFontPitch )
693
1.79k
    {
694
1.79k
        rProperties.push_back( *pNewFontPitch );
695
1.79k
        pNewFontPitch.reset();
696
1.79k
    }
697
698
153k
    if( pNewFontCharSet )
699
2.16k
    {
700
2.16k
        rProperties.push_back( *pNewFontCharSet );
701
2.16k
        pNewFontCharSet.reset();
702
2.16k
    }
703
704
153k
    if( pNewFontStyleNameCJK )
705
585
    {
706
585
        rProperties.push_back( *pNewFontStyleNameCJK );
707
585
        pNewFontStyleNameCJK.reset();
708
585
    }
709
710
153k
    if( pNewFontFamilyCJK )
711
193
    {
712
193
        rProperties.push_back( *pNewFontFamilyCJK );
713
193
        pNewFontFamilyCJK.reset();
714
193
    }
715
716
153k
    if( pNewFontPitchCJK )
717
184
    {
718
184
        rProperties.push_back( *pNewFontPitchCJK );
719
184
        pNewFontPitchCJK.reset();
720
184
    }
721
722
153k
    if( pNewFontCharSetCJK )
723
585
    {
724
585
        rProperties.push_back( *pNewFontCharSetCJK );
725
585
        pNewFontCharSetCJK.reset();
726
585
    }
727
728
153k
    if( pNewFontStyleNameCTL)
729
1.22k
    {
730
1.22k
        rProperties.push_back( *pNewFontStyleNameCTL );
731
1.22k
        pNewFontStyleNameCTL.reset();
732
1.22k
    }
733
734
153k
    if( pNewFontFamilyCTL )
735
792
    {
736
792
        rProperties.push_back( *pNewFontFamilyCTL );
737
792
        pNewFontFamilyCTL.reset();
738
792
    }
739
740
153k
    if( pNewFontPitchCTL )
741
619
    {
742
619
        rProperties.push_back( *pNewFontPitchCTL );
743
619
        pNewFontPitchCTL.reset();
744
619
    }
745
746
153k
    if( pNewFontCharSetCTL )
747
1.22k
    {
748
1.22k
        rProperties.push_back( *pNewFontCharSetCTL );
749
1.22k
        pNewFontCharSetCTL.reset();
750
1.22k
    }
751
752
766k
    for (sal_uInt16 i=0; i<4; i++)
753
613k
    {
754
613k
        if (pNewParaMargins[i])
755
4
        {
756
4
            rProperties.push_back(*pNewParaMargins[i]);
757
4
        }
758
613k
        if (pNewMargins[i])
759
0
        {
760
0
            rProperties.push_back(*pNewMargins[i]);
761
0
        }
762
613k
        if( pNewBorderDistances[i] )
763
10.6k
        {
764
10.6k
            rProperties.push_back( *pNewBorderDistances[i] );
765
10.6k
            delete pNewBorderDistances[i];
766
10.6k
        }
767
613k
        if( pNewBorders[i] )
768
3.50k
        {
769
3.50k
            rProperties.push_back( *pNewBorders[i] );
770
3.50k
            delete pNewBorders[i];
771
3.50k
        }
772
613k
        if( pCharNewBorderDistances[i] )
773
632
        {
774
632
            rProperties.push_back( *pCharNewBorderDistances[i] );
775
632
            delete pCharNewBorderDistances[i];
776
632
        }
777
613k
        if( pCharNewBorders[i] )
778
36
        {
779
36
            rProperties.push_back( *pCharNewBorders[i] );
780
36
            delete pCharNewBorders[i];
781
36
        }
782
613k
    }
783
784
153k
    if( bHasAnyHeight )
785
244
    {
786
244
        if( m_nSizeTypeIndex == -2 )
787
217
        {
788
217
            const_cast < XMLTextImportPropertyMapper * > ( this )
789
217
                ->m_nSizeTypeIndex  = -1;
790
217
            sal_Int32 nPropCount = getPropertySetMapper()->GetEntryCount();
791
43.6k
            for( sal_Int32 j=0; j < nPropCount; j++ )
792
43.6k
            {
793
43.6k
                if( CTF_SIZETYPE == getPropertySetMapper()
794
43.6k
                        ->GetEntryContextId( j ) )
795
217
                {
796
217
                    const_cast < XMLTextImportPropertyMapper * > ( this )
797
217
                        ->m_nSizeTypeIndex = j;
798
217
                    break;
799
217
                }
800
43.6k
            }
801
217
        }
802
244
        if( m_nSizeTypeIndex != -1 )
803
244
        {
804
244
            XMLPropertyState aSizeTypeState( m_nSizeTypeIndex );
805
244
            aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinHeight
806
244
                                                        ? SizeType::MIN
807
244
                                                        : SizeType::FIX);
808
244
            rProperties.push_back( aSizeTypeState );
809
244
        }
810
244
    }
811
812
153k
    if( !bHasAnyWidth )
813
153k
        return;
814
815
179
    if( m_nWidthTypeIndex == -2 )
816
179
    {
817
179
        const_cast < XMLTextImportPropertyMapper * > ( this )
818
179
            ->m_nWidthTypeIndex  = -1;
819
179
        sal_Int32 nCount = getPropertySetMapper()->GetEntryCount();
820
35.0k
        for( sal_Int32 j=0; j < nCount; j++ )
821
35.0k
        {
822
35.0k
            if( CTF_FRAMEWIDTH_TYPE  == getPropertySetMapper()
823
35.0k
                    ->GetEntryContextId( j ) )
824
179
            {
825
179
                const_cast < XMLTextImportPropertyMapper * > ( this )
826
179
                    ->m_nWidthTypeIndex = j;
827
179
                break;
828
179
            }
829
35.0k
        }
830
179
    }
831
179
    if( m_nWidthTypeIndex != -1 )
832
179
    {
833
179
        XMLPropertyState aSizeTypeState( m_nWidthTypeIndex );
834
179
        aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinWidth
835
179
                                                    ? SizeType::MIN
836
179
                                                    : SizeType::FIX);
837
179
        rProperties.push_back( aSizeTypeState );
838
179
    }
839
840
    // DO NOT USE ITERATORS/POINTERS INTO THE rProperties-VECTOR AFTER
841
    // THIS LINE.  All iterators into the rProperties-vector, especially all
842
    // pXXX-type variables set in the first switch statement of this method,
843
    // may have been invalidated by the above push_back() calls!
844
179
}
845
846
847
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */