Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/style/PageMasterImportPropMapper.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
#include "PageMasterImportPropMapper.hxx"
22
#include <PageMasterStyleMap.hxx>
23
#include <xmloff/maptype.hxx>
24
#include <com/sun/star/table/BorderLine2.hpp>
25
#include <com/sun/star/container/XNameContainer.hpp>
26
#include <com/sun/star/lang/XServiceInfo.hpp>
27
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
28
#include <com/sun/star/frame/XModel.hpp>
29
#include <com/sun/star/beans/XPropertySet.hpp>
30
#include <xmloff/xmlimp.hxx>
31
#include <xmloff/xmlprmap.hxx>
32
33
5.04k
#define XML_LINE_LEFT 0
34
5.90k
#define XML_LINE_RIGHT 1
35
4.11k
#define XML_LINE_TOP 2
36
3.87k
#define XML_LINE_BOTTOM 3
37
38
using namespace ::com::sun::star;
39
using namespace ::com::sun::star::uno;
40
using namespace ::com::sun::star::container;
41
42
PageMasterImportPropertyMapper::PageMasterImportPropertyMapper(
43
        const rtl::Reference< XMLPropertySetMapper >& rMapper,
44
        SvXMLImport& rImp ) :
45
2.99k
    SvXMLImportPropertyMapper( rMapper, rImp ),
46
2.99k
    rImport( rImp )
47
2.99k
{
48
2.99k
}
49
50
PageMasterImportPropertyMapper::~PageMasterImportPropertyMapper()
51
2.99k
{
52
2.99k
}
53
54
bool PageMasterImportPropertyMapper::handleSpecialItem(
55
        XMLPropertyState& rProperty,
56
        std::vector< XMLPropertyState >& rProperties,
57
        const OUString& rValue,
58
        const SvXMLUnitConverter& rUnitConverter,
59
        const SvXMLNamespaceMap& rNamespaceMap ) const
60
0
{
61
0
    bool bRet = false;
62
0
    sal_Int16 nContextID =
63
0
            getPropertySetMapper()->GetEntryContextId(rProperty.mnIndex);
64
65
0
    if( CTF_PM_REGISTER_STYLE==nContextID )
66
0
    {
67
0
        OUString sDisplayName( rImport.GetStyleDisplayName(
68
0
                    XmlStyleFamily::TEXT_PARAGRAPH, rValue ) );
69
0
        Reference < XNameContainer > xParaStyles =
70
0
            rImport.GetTextImport()->GetParaStyles();
71
0
        if( xParaStyles.is() && xParaStyles->hasByName( sDisplayName ) )
72
0
        {
73
0
            rProperty.maValue <<= sDisplayName;
74
0
            bRet = true;
75
0
        }
76
0
    }
77
0
    else
78
0
    {
79
0
        bRet = SvXMLImportPropertyMapper::handleSpecialItem(
80
0
                    rProperty, rProperties, rValue,
81
0
                    rUnitConverter, rNamespaceMap );
82
0
    }
83
84
0
    return bRet;
85
0
}
86
87
88
void PageMasterImportPropertyMapper::finished(std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const
89
18.2k
{
90
18.2k
    SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex);
91
18.2k
    XMLPropertyState* pAllPaddingProperty = nullptr;
92
18.2k
    XMLPropertyState* pPadding[4] = { nullptr, nullptr, nullptr, nullptr };
93
18.2k
    XMLPropertyState* pNewPadding[4] = { nullptr, nullptr, nullptr, nullptr };
94
18.2k
    XMLPropertyState* pAllBorderProperty = nullptr;
95
18.2k
    XMLPropertyState* pBorders[4] = { nullptr, nullptr, nullptr, nullptr };
96
18.2k
    XMLPropertyState* pNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
97
18.2k
    XMLPropertyState* pAllBorderWidthProperty = nullptr;
98
18.2k
    XMLPropertyState* pBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
99
18.2k
    XMLPropertyState* pAllHeaderPaddingProperty = nullptr;
100
18.2k
    XMLPropertyState* pHeaderPadding[4] = { nullptr, nullptr, nullptr, nullptr };
101
18.2k
    XMLPropertyState* pHeaderNewPadding[4] = { nullptr, nullptr, nullptr, nullptr };
102
18.2k
    XMLPropertyState* pAllHeaderBorderProperty = nullptr;
103
18.2k
    XMLPropertyState* pHeaderBorders[4] = { nullptr, nullptr, nullptr, nullptr };
104
18.2k
    XMLPropertyState* pHeaderNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
105
18.2k
    XMLPropertyState* pAllHeaderBorderWidthProperty = nullptr;
106
18.2k
    XMLPropertyState* pHeaderBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
107
18.2k
    XMLPropertyState* pAllFooterPaddingProperty = nullptr;
108
18.2k
    XMLPropertyState* pFooterPadding[4] = { nullptr, nullptr, nullptr, nullptr };
109
18.2k
    XMLPropertyState* pFooterNewPadding[4] = { nullptr, nullptr, nullptr, nullptr };
110
18.2k
    XMLPropertyState* pAllFooterBorderProperty = nullptr;
111
18.2k
    XMLPropertyState* pFooterBorders[4] = { nullptr, nullptr, nullptr, nullptr };
112
18.2k
    XMLPropertyState* pFooterNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
113
18.2k
    XMLPropertyState* pAllFooterBorderWidthProperty = nullptr;
114
18.2k
    XMLPropertyState* pFooterBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
115
18.2k
    XMLPropertyState* pHeaderHeight = nullptr;
116
18.2k
    XMLPropertyState* pHeaderMinHeight = nullptr;
117
18.2k
    std::optional<XMLPropertyState> xHeaderDynamic;
118
18.2k
    XMLPropertyState* pFooterHeight = nullptr;
119
18.2k
    XMLPropertyState* pFooterMinHeight = nullptr;
120
18.2k
    std::optional<XMLPropertyState> xFooterDynamic;
121
18.2k
    XMLPropertyState* pAllMarginProperty = nullptr;
122
18.2k
    XMLPropertyState* pMargins[4] = { nullptr, nullptr, nullptr, nullptr };
123
18.2k
    std::optional<XMLPropertyState> pNewMargins[4];
124
18.2k
    XMLPropertyState* pAllHeaderMarginProperty = nullptr;
125
18.2k
    XMLPropertyState* pHeaderMargins[4] = { nullptr, nullptr, nullptr, nullptr };
126
18.2k
    std::optional<XMLPropertyState> pNewHeaderMargins[4];
127
18.2k
    XMLPropertyState* pAllFooterMarginProperty = nullptr;
128
18.2k
    XMLPropertyState* pFooterMargins[4] = { nullptr, nullptr, nullptr, nullptr };
129
18.2k
    std::optional<XMLPropertyState> pNewFooterMargins[4];
130
18.2k
    XMLPropertyState* pMarginGutter = nullptr;
131
18.2k
    XMLPropertyState* pRtlGutter = nullptr;
132
133
18.2k
    for (auto& rProp : rProperties)
134
1.52M
    {
135
1.52M
        XMLPropertyState *property = &rProp;
136
1.52M
        sal_Int16 nContextID = getPropertySetMapper()->GetEntryContextId(property->mnIndex);
137
1.52M
        if (property->mnIndex >= nStartIndex && property->mnIndex < nEndIndex)
138
1.44M
        {
139
1.44M
            switch (nContextID)
140
1.44M
            {
141
5
                case CTF_PM_PADDINGALL                  : pAllPaddingProperty = property; break;
142
0
                case CTF_PM_PADDINGLEFT                 : pPadding[XML_LINE_LEFT] = property; break;
143
0
                case CTF_PM_PADDINGRIGHT                : pPadding[XML_LINE_RIGHT] = property; break;
144
0
                case CTF_PM_PADDINGTOP                  : pPadding[XML_LINE_TOP] = property; break;
145
0
                case CTF_PM_PADDINGBOTTOM               : pPadding[XML_LINE_BOTTOM] = property; break;
146
2
                case CTF_PM_BORDERALL                   : pAllBorderProperty = property; break;
147
0
                case CTF_PM_BORDERLEFT                  : pBorders[XML_LINE_LEFT] = property; break;
148
2
                case CTF_PM_BORDERRIGHT                 : pBorders[XML_LINE_RIGHT] = property; break;
149
1
                case CTF_PM_BORDERTOP                   : pBorders[XML_LINE_TOP] = property; break;
150
1
                case CTF_PM_BORDERBOTTOM                : pBorders[XML_LINE_BOTTOM] = property; break;
151
0
                case CTF_PM_BORDERWIDTHALL              : pAllBorderWidthProperty = property; break;
152
0
                case CTF_PM_BORDERWIDTHLEFT             : pBorderWidths[XML_LINE_LEFT] = property; break;
153
0
                case CTF_PM_BORDERWIDTHRIGHT            : pBorderWidths[XML_LINE_RIGHT] = property; break;
154
0
                case CTF_PM_BORDERWIDTHTOP              : pBorderWidths[XML_LINE_TOP] = property; break;
155
3
                case CTF_PM_BORDERWIDTHBOTTOM           : pBorderWidths[XML_LINE_BOTTOM] = property; break;
156
571
                case CTF_PM_HEADERPADDINGALL            : pAllHeaderPaddingProperty = property; break;
157
3
                case CTF_PM_HEADERPADDINGLEFT           : pHeaderPadding[XML_LINE_LEFT] = property; break;
158
2
                case CTF_PM_HEADERPADDINGRIGHT          : pHeaderPadding[XML_LINE_RIGHT] = property; break;
159
2
                case CTF_PM_HEADERPADDINGTOP            : pHeaderPadding[XML_LINE_TOP] = property; break;
160
2
                case CTF_PM_HEADERPADDINGBOTTOM         : pHeaderPadding[XML_LINE_BOTTOM] = property; break;
161
433
                case CTF_PM_HEADERBORDERALL             : pAllHeaderBorderProperty = property; break;
162
1
                case CTF_PM_HEADERBORDERLEFT            : pHeaderBorders[XML_LINE_LEFT] = property; break;
163
3
                case CTF_PM_HEADERBORDERRIGHT           : pHeaderBorders[XML_LINE_RIGHT] = property; break;
164
1
                case CTF_PM_HEADERBORDERTOP             : pHeaderBorders[XML_LINE_TOP] = property; break;
165
1
                case CTF_PM_HEADERBORDERBOTTOM          : pHeaderBorders[XML_LINE_BOTTOM] = property; break;
166
0
                case CTF_PM_HEADERBORDERWIDTHALL        : pAllHeaderBorderWidthProperty = property; break;
167
0
                case CTF_PM_HEADERBORDERWIDTHLEFT       : pHeaderBorderWidths[XML_LINE_LEFT] = property; break;
168
0
                case CTF_PM_HEADERBORDERWIDTHRIGHT      : pHeaderBorderWidths[XML_LINE_RIGHT] = property; break;
169
0
                case CTF_PM_HEADERBORDERWIDTHTOP        : pHeaderBorderWidths[XML_LINE_TOP] = property; break;
170
0
                case CTF_PM_HEADERBORDERWIDTHBOTTOM     : pHeaderBorderWidths[XML_LINE_BOTTOM] = property; break;
171
475
                case CTF_PM_FOOTERPADDINGALL            : pAllFooterPaddingProperty = property; break;
172
2
                case CTF_PM_FOOTERPADDINGLEFT           : pFooterPadding[XML_LINE_LEFT] = property; break;
173
1
                case CTF_PM_FOOTERPADDINGRIGHT          : pFooterPadding[XML_LINE_RIGHT] = property; break;
174
1
                case CTF_PM_FOOTERPADDINGTOP            : pFooterPadding[XML_LINE_TOP] = property; break;
175
1
                case CTF_PM_FOOTERPADDINGBOTTOM         : pFooterPadding[XML_LINE_BOTTOM] = property; break;
176
532
                case CTF_PM_FOOTERBORDERALL             : pAllFooterBorderProperty = property; break;
177
1
                case CTF_PM_FOOTERBORDERLEFT            : pFooterBorders[XML_LINE_LEFT] = property; break;
178
1
                case CTF_PM_FOOTERBORDERRIGHT           : pFooterBorders[XML_LINE_RIGHT] = property; break;
179
194
                case CTF_PM_FOOTERBORDERTOP             : pFooterBorders[XML_LINE_TOP] = property; break;
180
1
                case CTF_PM_FOOTERBORDERBOTTOM          : pFooterBorders[XML_LINE_BOTTOM] = property; break;
181
0
                case CTF_PM_FOOTERBORDERWIDTHALL        : pAllFooterBorderWidthProperty = property; break;
182
0
                case CTF_PM_FOOTERBORDERWIDTHLEFT       : pFooterBorderWidths[XML_LINE_LEFT] = property; break;
183
0
                case CTF_PM_FOOTERBORDERWIDTHRIGHT      : pFooterBorderWidths[XML_LINE_RIGHT] = property; break;
184
0
                case CTF_PM_FOOTERBORDERWIDTHTOP        : pFooterBorderWidths[XML_LINE_TOP] = property; break;
185
0
                case CTF_PM_FOOTERBORDERWIDTHBOTTOM     : pFooterBorderWidths[XML_LINE_BOTTOM] = property; break;
186
24
                case CTF_PM_HEADERHEIGHT                : pHeaderHeight = property; break;
187
1.53k
                case CTF_PM_HEADERMINHEIGHT             : pHeaderMinHeight = property; break;
188
0
                case CTF_PM_FOOTERHEIGHT                : pFooterHeight = property; break;
189
1.35k
                case CTF_PM_FOOTERMINHEIGHT             : pFooterMinHeight = property; break;
190
41
                case CTF_PM_MARGINALL   :
191
41
                      pAllMarginProperty = property; break;
192
2.55k
                case CTF_PM_MARGINTOP   :
193
2.55k
                      pMargins[XML_LINE_TOP] = property; break;
194
2.37k
                case CTF_PM_MARGINBOTTOM:
195
2.37k
                      pMargins[XML_LINE_BOTTOM] = property; break;
196
2.02k
                case CTF_PM_MARGINLEFT  :
197
2.02k
                      pMargins[XML_LINE_LEFT] = property; break;
198
2.99k
                case CTF_PM_MARGINRIGHT :
199
2.99k
                      pMargins[XML_LINE_RIGHT] = property; break;
200
0
                case CTF_PM_MARGINGUTTER:
201
0
                    pMarginGutter = property;
202
0
                    break;
203
635k
                case CTF_PM_RTLGUTTER:
204
635k
                    pRtlGutter = property;
205
635k
                    break;
206
0
                case CTF_PM_HEADERMARGINALL   :
207
0
                      pAllHeaderMarginProperty = property; break;
208
0
                case CTF_PM_HEADERMARGINTOP   :
209
0
                      pHeaderMargins[XML_LINE_TOP] = property; break;
210
1.48k
                case CTF_PM_HEADERMARGINBOTTOM:
211
1.48k
                      pHeaderMargins[XML_LINE_BOTTOM] = property; break;
212
1.50k
                case CTF_PM_HEADERMARGINLEFT  :
213
1.50k
                      pHeaderMargins[XML_LINE_LEFT] = property; break;
214
1.53k
                case CTF_PM_HEADERMARGINRIGHT :
215
1.53k
                      pHeaderMargins[XML_LINE_RIGHT] = property; break;
216
0
                case CTF_PM_FOOTERMARGINALL   :
217
0
                      pAllFooterMarginProperty = property; break;
218
1.35k
                case CTF_PM_FOOTERMARGINTOP   :
219
1.35k
                      pFooterMargins[XML_LINE_TOP] = property; break;
220
0
                case CTF_PM_FOOTERMARGINBOTTOM:
221
0
                      pFooterMargins[XML_LINE_BOTTOM] = property; break;
222
1.49k
                case CTF_PM_FOOTERMARGINLEFT  :
223
1.49k
                      pFooterMargins[XML_LINE_LEFT] = property; break;
224
1.37k
                case CTF_PM_FOOTERMARGINRIGHT :
225
1.37k
                      pFooterMargins[XML_LINE_RIGHT] = property; break;
226
1.44M
            }
227
1.44M
        }
228
1.52M
    }
229
230
91.0k
    for (sal_uInt16 i = 0; i < 4; i++)
231
72.8k
    {
232
72.8k
        if (pAllMarginProperty && !pMargins[i])
233
5
        {
234
5
            pNewMargins[i].emplace(
235
5
                pAllMarginProperty->mnIndex + 1 + i,
236
5
                pAllMarginProperty->maValue);
237
5
        }
238
72.8k
        if (pAllHeaderMarginProperty && !pHeaderMargins[i])
239
0
        {
240
0
            pNewHeaderMargins[i].emplace(
241
0
                pAllHeaderMarginProperty->mnIndex + 1 + i,
242
0
                pAllHeaderMarginProperty->maValue);
243
0
        }
244
72.8k
        if (pAllFooterMarginProperty && !pFooterMargins[i])
245
0
        {
246
0
            pNewFooterMargins[i].emplace(
247
0
                pAllFooterMarginProperty->mnIndex + 1 + i,
248
0
                pAllFooterMarginProperty->maValue);
249
0
        }
250
72.8k
        if (pAllPaddingProperty && !pPadding[i])
251
20
            pNewPadding[i] = new XMLPropertyState(pAllPaddingProperty->mnIndex + 1 + i, pAllPaddingProperty->maValue);
252
72.8k
        if (pAllBorderProperty && !pBorders[i])
253
8
        {
254
8
            pNewBorders[i] = new XMLPropertyState(pAllBorderProperty->mnIndex + 1 + i, pAllBorderProperty->maValue);
255
8
            pBorders[i] = pNewBorders[i];
256
8
        }
257
72.8k
        if( !pBorderWidths[i] )
258
72.8k
            pBorderWidths[i] = pAllBorderWidthProperty;
259
3
        else
260
3
            pBorderWidths[i]->mnIndex = -1;
261
72.8k
        if( pBorders[i] )
262
12
        {
263
12
            table::BorderLine2 aBorderLine;
264
12
            pBorders[i]->maValue >>= aBorderLine;
265
12
            if( pBorderWidths[i] )
266
0
            {
267
0
                table::BorderLine2 aBorderLineWidth;
268
0
                pBorderWidths[i]->maValue >>= aBorderLineWidth;
269
0
                aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
270
0
                aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
271
0
                aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
272
0
                aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
273
0
                pBorders[i]->maValue <<= aBorderLine;
274
0
            }
275
12
        }
276
72.8k
        if (pAllHeaderPaddingProperty && !pHeaderPadding[i])
277
2.27k
            pHeaderNewPadding[i] = new XMLPropertyState(pAllHeaderPaddingProperty->mnIndex + 1 + i, pAllHeaderPaddingProperty->maValue);
278
72.8k
        if (pAllHeaderBorderProperty && !pHeaderBorders[i])
279
1.73k
            pHeaderNewBorders[i] = new XMLPropertyState(pAllHeaderBorderProperty->mnIndex + 1 + i, pAllHeaderBorderProperty->maValue);
280
72.8k
        if( !pHeaderBorderWidths[i] )
281
72.8k
            pHeaderBorderWidths[i] = pAllHeaderBorderWidthProperty;
282
0
        else
283
0
            pHeaderBorderWidths[i]->mnIndex = -1;
284
72.8k
        if( pHeaderBorders[i] )
285
6
        {
286
6
            table::BorderLine2 aBorderLine;
287
6
            pHeaderBorders[i]->maValue >>= aBorderLine;
288
6
            if( pHeaderBorderWidths[i] )
289
0
            {
290
0
                table::BorderLine2 aBorderLineWidth;
291
0
                pHeaderBorderWidths[i]->maValue >>= aBorderLineWidth;
292
0
                aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
293
0
                aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
294
0
                aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
295
0
                aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
296
0
                pHeaderBorders[i]->maValue <<= aBorderLine;
297
0
            }
298
6
        }
299
72.8k
        if (pAllFooterPaddingProperty && !pFooterPadding[i])
300
1.89k
            pFooterNewPadding[i] = new XMLPropertyState(pAllFooterPaddingProperty->mnIndex + 1 + i, pAllFooterPaddingProperty->maValue);
301
72.8k
        if (pAllFooterBorderProperty && !pFooterBorders[i])
302
2.12k
            pFooterNewBorders[i] = new XMLPropertyState(pAllFooterBorderProperty->mnIndex + 1 + i, pAllFooterBorderProperty->maValue);
303
72.8k
        if( !pFooterBorderWidths[i] )
304
72.8k
            pFooterBorderWidths[i] = pAllFooterBorderWidthProperty;
305
0
        else
306
0
            pFooterBorderWidths[i]->mnIndex = -1;
307
72.8k
        if( pFooterBorders[i] )
308
197
        {
309
197
            table::BorderLine2 aBorderLine;
310
197
            pFooterBorders[i]->maValue >>= aBorderLine;
311
197
            if( pFooterBorderWidths[i] )
312
0
            {
313
0
                table::BorderLine2 aBorderLineWidth;
314
0
                pFooterBorderWidths[i]->maValue >>= aBorderLineWidth;
315
0
                aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
316
0
                aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
317
0
                aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
318
0
                aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
319
0
                pFooterBorders[i]->maValue <<= aBorderLine;
320
0
            }
321
197
        }
322
72.8k
    }
323
324
18.2k
    if (pHeaderHeight)
325
24
    {
326
24
        xHeaderDynamic.emplace(pHeaderHeight->mnIndex + 2, Any(false));
327
24
    }
328
18.2k
    if (pHeaderMinHeight)
329
1.52k
    {
330
1.52k
        xHeaderDynamic.emplace(pHeaderMinHeight->mnIndex + 1, Any(true));
331
1.52k
    }
332
18.2k
    if (pFooterHeight)
333
0
    {
334
0
        xFooterDynamic.emplace(pFooterHeight->mnIndex + 2, Any(false));
335
0
    }
336
18.2k
    if (pFooterMinHeight)
337
1.34k
    {
338
1.34k
        xFooterDynamic.emplace(pFooterMinHeight->mnIndex + 1, Any(true));
339
1.34k
    }
340
341
    // fdo#38056: nerf the various AllFoo properties so they do not override
342
    // the individual Foo properties later on
343
18.2k
    if (pAllPaddingProperty)
344
5
    {
345
5
        pAllPaddingProperty->mnIndex = -1;
346
5
    }
347
18.2k
    if (pAllBorderProperty)
348
2
    {
349
2
        pAllBorderProperty->mnIndex = -1;
350
2
    }
351
18.2k
    if (pAllBorderWidthProperty)
352
0
    {
353
0
        pAllBorderWidthProperty->mnIndex = -1;
354
0
    }
355
18.2k
    if (pAllHeaderPaddingProperty)
356
571
    {
357
571
        pAllHeaderPaddingProperty->mnIndex = -1;
358
571
    }
359
18.2k
    if (pAllHeaderBorderProperty)
360
433
    {
361
433
        pAllHeaderBorderProperty->mnIndex = -1;
362
433
    }
363
18.2k
    if (pAllHeaderBorderWidthProperty)
364
0
    {
365
0
        pAllHeaderBorderWidthProperty->mnIndex = -1;
366
0
    }
367
18.2k
    if (pAllFooterPaddingProperty)
368
475
    {
369
475
        pAllFooterPaddingProperty->mnIndex = -1;
370
475
    }
371
18.2k
    if (pAllFooterBorderProperty)
372
532
    {
373
532
        pAllFooterBorderProperty->mnIndex = -1;
374
532
    }
375
18.2k
    if (pAllFooterBorderWidthProperty)
376
0
    {
377
0
        pAllFooterBorderWidthProperty->mnIndex = -1;
378
0
    }
379
18.2k
    if (pAllMarginProperty)
380
41
    {
381
41
        pAllMarginProperty->mnIndex = -1;
382
41
    }
383
18.2k
    if (pAllHeaderMarginProperty)
384
0
    {
385
0
        pAllHeaderMarginProperty->mnIndex = -1;
386
0
    }
387
18.2k
    if (pAllFooterMarginProperty)
388
0
    {
389
0
        pAllFooterMarginProperty->mnIndex = -1;
390
0
    }
391
392
18.2k
    if (pMarginGutter)
393
0
    {
394
0
        sal_Int32 nGutterMargin{};
395
0
        pMarginGutter->maValue >>= nGutterMargin;
396
397
0
        bool bGutterAtTop{};
398
0
        uno::Reference<lang::XServiceInfo> xSI(GetImport().GetModel(), uno::UNO_QUERY);
399
0
        if (xSI.is() && xSI->supportsService(u"com.sun.star.text.TextDocument"_ustr))
400
0
        {
401
0
            uno::Reference<lang::XMultiServiceFactory> xFac(GetImport().GetModel(), uno::UNO_QUERY);
402
0
            if (xFac.is())
403
0
            {
404
0
                uno::Reference<beans::XPropertySet> xProps(
405
0
                    xFac->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY);
406
0
                if (xProps.is())
407
0
                {
408
0
                    xProps->getPropertyValue(u"GutterAtTop"_ustr) >>= bGutterAtTop;
409
0
                }
410
0
            }
411
0
        }
412
0
        if (bGutterAtTop)
413
0
        {
414
0
            if (nGutterMargin && pMargins[XML_LINE_TOP])
415
0
            {
416
                // Decrease top margin to not include gutter.
417
0
                sal_Int32 nTopMargin{};
418
0
                pMargins[XML_LINE_TOP]->maValue >>= nTopMargin;
419
0
                nTopMargin -= nGutterMargin;
420
0
                pMargins[XML_LINE_TOP]->maValue <<= nTopMargin;
421
0
            }
422
0
        }
423
0
        else
424
0
        {
425
0
            bool bRtlGutter{};
426
0
            if (nGutterMargin && pRtlGutter)
427
0
            {
428
0
                pRtlGutter->maValue >>= bRtlGutter;
429
0
            }
430
0
            if (bRtlGutter)
431
0
            {
432
0
                if (nGutterMargin && pMargins[XML_LINE_RIGHT])
433
0
                {
434
                    // Decrease right margin to not include gutter.
435
0
                    sal_Int32 nRightMargin{};
436
0
                    pMargins[XML_LINE_RIGHT]->maValue >>= nRightMargin;
437
0
                    nRightMargin -= nGutterMargin;
438
0
                    pMargins[XML_LINE_RIGHT]->maValue <<= nRightMargin;
439
0
                }
440
0
            }
441
0
            else
442
0
            {
443
0
                if (nGutterMargin && pMargins[XML_LINE_LEFT])
444
0
                {
445
                    // Decrease left margin to not include gutter.
446
0
                    sal_Int32 nLeftMargin{};
447
0
                    pMargins[XML_LINE_LEFT]->maValue >>= nLeftMargin;
448
0
                    nLeftMargin -= nGutterMargin;
449
0
                    pMargins[XML_LINE_LEFT]->maValue <<= nLeftMargin;
450
0
                }
451
0
            }
452
0
        }
453
0
    }
454
455
    // CAUTION!
456
    // The following code adds into the rProperties vector, so all the
457
    // XMLPropertyState* pointers that are pointing to the rProperties
458
    // elements could potentially be deallocated, so don't use them after
459
    // this!
460
91.0k
    for (sal_uInt16 i = 0; i < 4; i++)
461
72.8k
    {
462
72.8k
        if (pNewMargins[i])
463
5
        {
464
5
            rProperties.push_back(*pNewMargins[i]);
465
5
        }
466
72.8k
        if (pNewHeaderMargins[i])
467
0
        {
468
0
            rProperties.push_back(*pNewHeaderMargins[i]);
469
0
        }
470
72.8k
        if (pNewFooterMargins[i])
471
0
        {
472
0
            rProperties.push_back(*pNewFooterMargins[i]);
473
0
        }
474
72.8k
        if (pNewPadding[i])
475
20
        {
476
20
            rProperties.push_back(*pNewPadding[i]);
477
20
            delete pNewPadding[i];
478
20
        }
479
72.8k
        if (pNewBorders[i])
480
8
        {
481
8
            rProperties.push_back(*pNewBorders[i]);
482
8
            delete pNewBorders[i];
483
8
        }
484
72.8k
        if (pHeaderNewPadding[i])
485
2.27k
        {
486
2.27k
            rProperties.push_back(*pHeaderNewPadding[i]);
487
2.27k
            delete pHeaderNewPadding[i];
488
2.27k
        }
489
72.8k
        if (pHeaderNewBorders[i])
490
1.73k
        {
491
1.73k
            rProperties.push_back(*pHeaderNewBorders[i]);
492
1.73k
            delete pHeaderNewBorders[i];
493
1.73k
        }
494
72.8k
        if (pFooterNewPadding[i])
495
1.89k
        {
496
1.89k
            rProperties.push_back(*pFooterNewPadding[i]);
497
1.89k
            delete pFooterNewPadding[i];
498
1.89k
        }
499
72.8k
        if (pFooterNewBorders[i])
500
2.12k
        {
501
2.12k
            rProperties.push_back(*pFooterNewBorders[i]);
502
2.12k
            delete pFooterNewBorders[i];
503
2.12k
        }
504
72.8k
    }
505
    // CAUTION - do not use XMLPropertyState* pointers (like pMargins,
506
    // pMarginGutter) after this.
507
508
18.2k
    if(xHeaderDynamic)
509
1.54k
    {
510
1.54k
        rProperties.push_back(*xHeaderDynamic);
511
1.54k
        xHeaderDynamic.reset();
512
1.54k
    }
513
18.2k
    if(xFooterDynamic)
514
1.34k
    {
515
1.34k
        rProperties.push_back(*xFooterDynamic);
516
1.34k
        xFooterDynamic.reset();
517
1.34k
    }
518
519
18.2k
}
520
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */