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