Coverage Report

Created: 2026-07-10 11:04

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.42k
#define XML_LINE_LEFT 0
34
5.99k
#define XML_LINE_RIGHT 1
35
4.61k
#define XML_LINE_TOP 2
36
4.20k
#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
3.13k
    SvXMLImportPropertyMapper( rMapper, rImp ),
46
3.13k
    rImport( rImp )
47
3.13k
{
48
3.13k
}
49
50
PageMasterImportPropertyMapper::~PageMasterImportPropertyMapper()
51
3.13k
{
52
3.13k
}
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
17.2k
{
90
17.2k
    SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex);
91
17.2k
    XMLPropertyState* pAllPaddingProperty = nullptr;
92
17.2k
    XMLPropertyState* pPadding[4] = { nullptr, nullptr, nullptr, nullptr };
93
17.2k
    XMLPropertyState* pNewPadding[4] = { nullptr, nullptr, nullptr, nullptr };
94
17.2k
    XMLPropertyState* pAllBorderProperty = nullptr;
95
17.2k
    XMLPropertyState* pBorders[4] = { nullptr, nullptr, nullptr, nullptr };
96
17.2k
    XMLPropertyState* pNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
97
17.2k
    XMLPropertyState* pAllBorderWidthProperty = nullptr;
98
17.2k
    XMLPropertyState* pBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
99
17.2k
    XMLPropertyState* pAllHeaderPaddingProperty = nullptr;
100
17.2k
    XMLPropertyState* pHeaderPadding[4] = { nullptr, nullptr, nullptr, nullptr };
101
17.2k
    XMLPropertyState* pHeaderNewPadding[4] = { nullptr, nullptr, nullptr, nullptr };
102
17.2k
    XMLPropertyState* pAllHeaderBorderProperty = nullptr;
103
17.2k
    XMLPropertyState* pHeaderBorders[4] = { nullptr, nullptr, nullptr, nullptr };
104
17.2k
    XMLPropertyState* pHeaderNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
105
17.2k
    XMLPropertyState* pAllHeaderBorderWidthProperty = nullptr;
106
17.2k
    XMLPropertyState* pHeaderBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
107
17.2k
    XMLPropertyState* pAllFooterPaddingProperty = nullptr;
108
17.2k
    XMLPropertyState* pFooterPadding[4] = { nullptr, nullptr, nullptr, nullptr };
109
17.2k
    XMLPropertyState* pFooterNewPadding[4] = { nullptr, nullptr, nullptr, nullptr };
110
17.2k
    XMLPropertyState* pAllFooterBorderProperty = nullptr;
111
17.2k
    XMLPropertyState* pFooterBorders[4] = { nullptr, nullptr, nullptr, nullptr };
112
17.2k
    XMLPropertyState* pFooterNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
113
17.2k
    XMLPropertyState* pAllFooterBorderWidthProperty = nullptr;
114
17.2k
    XMLPropertyState* pFooterBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
115
17.2k
    XMLPropertyState* pHeaderHeight = nullptr;
116
17.2k
    XMLPropertyState* pHeaderMinHeight = nullptr;
117
17.2k
    std::optional<XMLPropertyState> xHeaderDynamic;
118
17.2k
    XMLPropertyState* pFooterHeight = nullptr;
119
17.2k
    XMLPropertyState* pFooterMinHeight = nullptr;
120
17.2k
    std::optional<XMLPropertyState> xFooterDynamic;
121
17.2k
    XMLPropertyState* pAllMarginProperty = nullptr;
122
17.2k
    XMLPropertyState* pMargins[4] = { nullptr, nullptr, nullptr, nullptr };
123
17.2k
    std::optional<XMLPropertyState> pNewMargins[4];
124
17.2k
    XMLPropertyState* pAllHeaderMarginProperty = nullptr;
125
17.2k
    XMLPropertyState* pHeaderMargins[4] = { nullptr, nullptr, nullptr, nullptr };
126
17.2k
    std::optional<XMLPropertyState> pNewHeaderMargins[4];
127
17.2k
    XMLPropertyState* pAllFooterMarginProperty = nullptr;
128
17.2k
    XMLPropertyState* pFooterMargins[4] = { nullptr, nullptr, nullptr, nullptr };
129
17.2k
    std::optional<XMLPropertyState> pNewFooterMargins[4];
130
17.2k
    XMLPropertyState* pMarginGutter = nullptr;
131
17.2k
    XMLPropertyState* pRtlGutter = nullptr;
132
133
17.2k
    for (auto& rProp : rProperties)
134
1.91M
    {
135
1.91M
        XMLPropertyState *property = &rProp;
136
1.91M
        sal_Int16 nContextID = getPropertySetMapper()->GetEntryContextId(property->mnIndex);
137
1.91M
        if (property->mnIndex >= nStartIndex && property->mnIndex < nEndIndex)
138
1.83M
        {
139
1.83M
            switch (nContextID)
140
1.83M
            {
141
2
                case CTF_PM_PADDINGALL                  : pAllPaddingProperty = property; break;
142
1
                case CTF_PM_PADDINGLEFT                 : pPadding[XML_LINE_LEFT] = property; break;
143
1
                case CTF_PM_PADDINGRIGHT                : pPadding[XML_LINE_RIGHT] = property; break;
144
1
                case CTF_PM_PADDINGTOP                  : pPadding[XML_LINE_TOP] = property; break;
145
3
                case CTF_PM_PADDINGBOTTOM               : pPadding[XML_LINE_BOTTOM] = property; break;
146
1
                case CTF_PM_BORDERALL                   : pAllBorderProperty = property; break;
147
0
                case CTF_PM_BORDERLEFT                  : pBorders[XML_LINE_LEFT] = property; break;
148
0
                case CTF_PM_BORDERRIGHT                 : pBorders[XML_LINE_RIGHT] = property; break;
149
2
                case CTF_PM_BORDERTOP                   : pBorders[XML_LINE_TOP] = property; break;
150
2
                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
0
                case CTF_PM_BORDERWIDTHBOTTOM           : pBorderWidths[XML_LINE_BOTTOM] = property; break;
156
378
                case CTF_PM_HEADERPADDINGALL            : pAllHeaderPaddingProperty = property; break;
157
2
                case CTF_PM_HEADERPADDINGLEFT           : pHeaderPadding[XML_LINE_LEFT] = property; break;
158
1
                case CTF_PM_HEADERPADDINGRIGHT          : pHeaderPadding[XML_LINE_RIGHT] = property; break;
159
1
                case CTF_PM_HEADERPADDINGTOP            : pHeaderPadding[XML_LINE_TOP] = property; break;
160
1
                case CTF_PM_HEADERPADDINGBOTTOM         : pHeaderPadding[XML_LINE_BOTTOM] = property; break;
161
280
                case CTF_PM_HEADERBORDERALL             : pAllHeaderBorderProperty = property; break;
162
0
                case CTF_PM_HEADERBORDERLEFT            : pHeaderBorders[XML_LINE_LEFT] = property; break;
163
2
                case CTF_PM_HEADERBORDERRIGHT           : pHeaderBorders[XML_LINE_RIGHT] = property; break;
164
2
                case CTF_PM_HEADERBORDERTOP             : pHeaderBorders[XML_LINE_TOP] = property; break;
165
2
                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
238
                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
361
                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
399
                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
34
                case CTF_PM_HEADERHEIGHT                : pHeaderHeight = property; break;
187
1.39k
                case CTF_PM_HEADERMINHEIGHT             : pHeaderMinHeight = property; break;
188
0
                case CTF_PM_FOOTERHEIGHT                : pFooterHeight = property; break;
189
1.26k
                case CTF_PM_FOOTERMINHEIGHT             : pFooterMinHeight = property; break;
190
49
                case CTF_PM_MARGINALL   :
191
49
                      pAllMarginProperty = property; break;
192
2.94k
                case CTF_PM_MARGINTOP   :
193
2.94k
                      pMargins[XML_LINE_TOP] = property; break;
194
2.78k
                case CTF_PM_MARGINBOTTOM:
195
2.78k
                      pMargins[XML_LINE_BOTTOM] = property; break;
196
2.63k
                case CTF_PM_MARGINLEFT  :
197
2.63k
                      pMargins[XML_LINE_LEFT] = property; break;
198
3.26k
                case CTF_PM_MARGINRIGHT :
199
3.26k
                      pMargins[XML_LINE_RIGHT] = property; break;
200
0
                case CTF_PM_MARGINGUTTER:
201
0
                    pMarginGutter = property;
202
0
                    break;
203
828k
                case CTF_PM_RTLGUTTER:
204
828k
                    pRtlGutter = property;
205
828k
                    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.40k
                case CTF_PM_HEADERMARGINBOTTOM:
211
1.40k
                      pHeaderMargins[XML_LINE_BOTTOM] = property; break;
212
1.45k
                case CTF_PM_HEADERMARGINLEFT  :
213
1.45k
                      pHeaderMargins[XML_LINE_LEFT] = property; break;
214
1.47k
                case CTF_PM_HEADERMARGINRIGHT :
215
1.47k
                      pHeaderMargins[XML_LINE_RIGHT] = property; break;
216
0
                case CTF_PM_FOOTERMARGINALL   :
217
0
                      pAllFooterMarginProperty = property; break;
218
1.26k
                case CTF_PM_FOOTERMARGINTOP   :
219
1.26k
                      pFooterMargins[XML_LINE_TOP] = property; break;
220
0
                case CTF_PM_FOOTERMARGINBOTTOM:
221
0
                      pFooterMargins[XML_LINE_BOTTOM] = property; break;
222
1.34k
                case CTF_PM_FOOTERMARGINLEFT  :
223
1.34k
                      pFooterMargins[XML_LINE_LEFT] = property; break;
224
1.25k
                case CTF_PM_FOOTERMARGINRIGHT :
225
1.25k
                      pFooterMargins[XML_LINE_RIGHT] = property; break;
226
1.83M
            }
227
1.83M
        }
228
1.91M
    }
229
230
86.1k
    for (sal_uInt16 i = 0; i < 4; i++)
231
68.8k
    {
232
68.8k
        if (pAllMarginProperty && !pMargins[i])
233
9
        {
234
9
            pNewMargins[i].emplace(
235
9
                pAllMarginProperty->mnIndex + 1 + i,
236
9
                pAllMarginProperty->maValue);
237
9
        }
238
68.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
68.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
68.8k
        if (pAllPaddingProperty && !pPadding[i])
251
8
            pNewPadding[i] = new XMLPropertyState(pAllPaddingProperty->mnIndex + 1 + i, pAllPaddingProperty->maValue);
252
68.8k
        if (pAllBorderProperty && !pBorders[i])
253
4
        {
254
4
            pNewBorders[i] = new XMLPropertyState(pAllBorderProperty->mnIndex + 1 + i, pAllBorderProperty->maValue);
255
4
            pBorders[i] = pNewBorders[i];
256
4
        }
257
68.8k
        if( !pBorderWidths[i] )
258
68.8k
            pBorderWidths[i] = pAllBorderWidthProperty;
259
0
        else
260
0
            pBorderWidths[i]->mnIndex = -1;
261
68.8k
        if( pBorders[i] )
262
8
        {
263
8
            table::BorderLine2 aBorderLine;
264
8
            pBorders[i]->maValue >>= aBorderLine;
265
8
            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
8
        }
276
68.8k
        if (pAllHeaderPaddingProperty && !pHeaderPadding[i])
277
1.50k
            pHeaderNewPadding[i] = new XMLPropertyState(pAllHeaderPaddingProperty->mnIndex + 1 + i, pAllHeaderPaddingProperty->maValue);
278
68.8k
        if (pAllHeaderBorderProperty && !pHeaderBorders[i])
279
1.12k
            pHeaderNewBorders[i] = new XMLPropertyState(pAllHeaderBorderProperty->mnIndex + 1 + i, pAllHeaderBorderProperty->maValue);
280
68.8k
        if( !pHeaderBorderWidths[i] )
281
68.8k
            pHeaderBorderWidths[i] = pAllHeaderBorderWidthProperty;
282
0
        else
283
0
            pHeaderBorderWidths[i]->mnIndex = -1;
284
68.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
68.8k
        if (pAllFooterPaddingProperty && !pFooterPadding[i])
300
948
            pFooterNewPadding[i] = new XMLPropertyState(pAllFooterPaddingProperty->mnIndex + 1 + i, pAllFooterPaddingProperty->maValue);
301
68.8k
        if (pAllFooterBorderProperty && !pFooterBorders[i])
302
1.44k
            pFooterNewBorders[i] = new XMLPropertyState(pAllFooterBorderProperty->mnIndex + 1 + i, pAllFooterBorderProperty->maValue);
303
68.8k
        if( !pFooterBorderWidths[i] )
304
68.8k
            pFooterBorderWidths[i] = pAllFooterBorderWidthProperty;
305
0
        else
306
0
            pFooterBorderWidths[i]->mnIndex = -1;
307
68.8k
        if( pFooterBorders[i] )
308
402
        {
309
402
            table::BorderLine2 aBorderLine;
310
402
            pFooterBorders[i]->maValue >>= aBorderLine;
311
402
            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
402
        }
322
68.8k
    }
323
324
17.2k
    if (pHeaderHeight)
325
34
    {
326
34
        xHeaderDynamic.emplace(pHeaderHeight->mnIndex + 2, Any(false));
327
34
    }
328
17.2k
    if (pHeaderMinHeight)
329
1.39k
    {
330
1.39k
        xHeaderDynamic.emplace(pHeaderMinHeight->mnIndex + 1, Any(true));
331
1.39k
    }
332
17.2k
    if (pFooterHeight)
333
0
    {
334
0
        xFooterDynamic.emplace(pFooterHeight->mnIndex + 2, Any(false));
335
0
    }
336
17.2k
    if (pFooterMinHeight)
337
1.25k
    {
338
1.25k
        xFooterDynamic.emplace(pFooterMinHeight->mnIndex + 1, Any(true));
339
1.25k
    }
340
341
    // fdo#38056: nerf the various AllFoo properties so they do not override
342
    // the individual Foo properties later on
343
17.2k
    if (pAllPaddingProperty)
344
2
    {
345
2
        pAllPaddingProperty->mnIndex = -1;
346
2
    }
347
17.2k
    if (pAllBorderProperty)
348
1
    {
349
1
        pAllBorderProperty->mnIndex = -1;
350
1
    }
351
17.2k
    if (pAllBorderWidthProperty)
352
0
    {
353
0
        pAllBorderWidthProperty->mnIndex = -1;
354
0
    }
355
17.2k
    if (pAllHeaderPaddingProperty)
356
378
    {
357
378
        pAllHeaderPaddingProperty->mnIndex = -1;
358
378
    }
359
17.2k
    if (pAllHeaderBorderProperty)
360
280
    {
361
280
        pAllHeaderBorderProperty->mnIndex = -1;
362
280
    }
363
17.2k
    if (pAllHeaderBorderWidthProperty)
364
0
    {
365
0
        pAllHeaderBorderWidthProperty->mnIndex = -1;
366
0
    }
367
17.2k
    if (pAllFooterPaddingProperty)
368
238
    {
369
238
        pAllFooterPaddingProperty->mnIndex = -1;
370
238
    }
371
17.2k
    if (pAllFooterBorderProperty)
372
361
    {
373
361
        pAllFooterBorderProperty->mnIndex = -1;
374
361
    }
375
17.2k
    if (pAllFooterBorderWidthProperty)
376
0
    {
377
0
        pAllFooterBorderWidthProperty->mnIndex = -1;
378
0
    }
379
17.2k
    if (pAllMarginProperty)
380
49
    {
381
49
        pAllMarginProperty->mnIndex = -1;
382
49
    }
383
17.2k
    if (pAllHeaderMarginProperty)
384
0
    {
385
0
        pAllHeaderMarginProperty->mnIndex = -1;
386
0
    }
387
17.2k
    if (pAllFooterMarginProperty)
388
0
    {
389
0
        pAllFooterMarginProperty->mnIndex = -1;
390
0
    }
391
392
17.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
86.1k
    for (sal_uInt16 i = 0; i < 4; i++)
461
68.8k
    {
462
68.8k
        if (pNewMargins[i])
463
9
        {
464
9
            rProperties.push_back(*pNewMargins[i]);
465
9
        }
466
68.8k
        if (pNewHeaderMargins[i])
467
0
        {
468
0
            rProperties.push_back(*pNewHeaderMargins[i]);
469
0
        }
470
68.8k
        if (pNewFooterMargins[i])
471
0
        {
472
0
            rProperties.push_back(*pNewFooterMargins[i]);
473
0
        }
474
68.8k
        if (pNewPadding[i])
475
8
        {
476
8
            rProperties.push_back(*pNewPadding[i]);
477
8
            delete pNewPadding[i];
478
8
        }
479
68.8k
        if (pNewBorders[i])
480
4
        {
481
4
            rProperties.push_back(*pNewBorders[i]);
482
4
            delete pNewBorders[i];
483
4
        }
484
68.8k
        if (pHeaderNewPadding[i])
485
1.50k
        {
486
1.50k
            rProperties.push_back(*pHeaderNewPadding[i]);
487
1.50k
            delete pHeaderNewPadding[i];
488
1.50k
        }
489
68.8k
        if (pHeaderNewBorders[i])
490
1.12k
        {
491
1.12k
            rProperties.push_back(*pHeaderNewBorders[i]);
492
1.12k
            delete pHeaderNewBorders[i];
493
1.12k
        }
494
68.8k
        if (pFooterNewPadding[i])
495
948
        {
496
948
            rProperties.push_back(*pFooterNewPadding[i]);
497
948
            delete pFooterNewPadding[i];
498
948
        }
499
68.8k
        if (pFooterNewBorders[i])
500
1.44k
        {
501
1.44k
            rProperties.push_back(*pFooterNewBorders[i]);
502
1.44k
            delete pFooterNewBorders[i];
503
1.44k
        }
504
68.8k
    }
505
    // CAUTION - do not use XMLPropertyState* pointers (like pMargins,
506
    // pMarginGutter) after this.
507
508
17.2k
    if(xHeaderDynamic)
509
1.42k
    {
510
1.42k
        rProperties.push_back(*xHeaderDynamic);
511
1.42k
        xHeaderDynamic.reset();
512
1.42k
    }
513
17.2k
    if(xFooterDynamic)
514
1.25k
    {
515
1.25k
        rProperties.push_back(*xFooterDynamic);
516
1.25k
        xFooterDynamic.reset();
517
1.25k
    }
518
519
17.2k
}
520
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */