/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.99k | #define XML_LINE_LEFT 0 |
34 | 6.92k | #define XML_LINE_RIGHT 1 |
35 | 4.78k | #define XML_LINE_TOP 2 |
36 | 4.59k | #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.31k | SvXMLImportPropertyMapper( rMapper, rImp ), |
46 | 3.31k | rImport( rImp ) |
47 | 3.31k | { |
48 | 3.31k | } |
49 | | |
50 | | PageMasterImportPropertyMapper::~PageMasterImportPropertyMapper() |
51 | 3.31k | { |
52 | 3.31k | } |
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 | 23.4k | { |
90 | 23.4k | SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex); |
91 | 23.4k | XMLPropertyState* pAllPaddingProperty = nullptr; |
92 | 23.4k | XMLPropertyState* pPadding[4] = { nullptr, nullptr, nullptr, nullptr }; |
93 | 23.4k | XMLPropertyState* pNewPadding[4] = { nullptr, nullptr, nullptr, nullptr }; |
94 | 23.4k | XMLPropertyState* pAllBorderProperty = nullptr; |
95 | 23.4k | XMLPropertyState* pBorders[4] = { nullptr, nullptr, nullptr, nullptr }; |
96 | 23.4k | XMLPropertyState* pNewBorders[4] = { nullptr, nullptr, nullptr, nullptr }; |
97 | 23.4k | XMLPropertyState* pAllBorderWidthProperty = nullptr; |
98 | 23.4k | XMLPropertyState* pBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr }; |
99 | 23.4k | XMLPropertyState* pAllHeaderPaddingProperty = nullptr; |
100 | 23.4k | XMLPropertyState* pHeaderPadding[4] = { nullptr, nullptr, nullptr, nullptr }; |
101 | 23.4k | XMLPropertyState* pHeaderNewPadding[4] = { nullptr, nullptr, nullptr, nullptr }; |
102 | 23.4k | XMLPropertyState* pAllHeaderBorderProperty = nullptr; |
103 | 23.4k | XMLPropertyState* pHeaderBorders[4] = { nullptr, nullptr, nullptr, nullptr }; |
104 | 23.4k | XMLPropertyState* pHeaderNewBorders[4] = { nullptr, nullptr, nullptr, nullptr }; |
105 | 23.4k | XMLPropertyState* pAllHeaderBorderWidthProperty = nullptr; |
106 | 23.4k | XMLPropertyState* pHeaderBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr }; |
107 | 23.4k | XMLPropertyState* pAllFooterPaddingProperty = nullptr; |
108 | 23.4k | XMLPropertyState* pFooterPadding[4] = { nullptr, nullptr, nullptr, nullptr }; |
109 | 23.4k | XMLPropertyState* pFooterNewPadding[4] = { nullptr, nullptr, nullptr, nullptr }; |
110 | 23.4k | XMLPropertyState* pAllFooterBorderProperty = nullptr; |
111 | 23.4k | XMLPropertyState* pFooterBorders[4] = { nullptr, nullptr, nullptr, nullptr }; |
112 | 23.4k | XMLPropertyState* pFooterNewBorders[4] = { nullptr, nullptr, nullptr, nullptr }; |
113 | 23.4k | XMLPropertyState* pAllFooterBorderWidthProperty = nullptr; |
114 | 23.4k | XMLPropertyState* pFooterBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr }; |
115 | 23.4k | XMLPropertyState* pHeaderHeight = nullptr; |
116 | 23.4k | XMLPropertyState* pHeaderMinHeight = nullptr; |
117 | 23.4k | std::optional<XMLPropertyState> xHeaderDynamic; |
118 | 23.4k | XMLPropertyState* pFooterHeight = nullptr; |
119 | 23.4k | XMLPropertyState* pFooterMinHeight = nullptr; |
120 | 23.4k | std::optional<XMLPropertyState> xFooterDynamic; |
121 | 23.4k | XMLPropertyState* pAllMarginProperty = nullptr; |
122 | 23.4k | XMLPropertyState* pMargins[4] = { nullptr, nullptr, nullptr, nullptr }; |
123 | 23.4k | std::optional<XMLPropertyState> pNewMargins[4]; |
124 | 23.4k | XMLPropertyState* pAllHeaderMarginProperty = nullptr; |
125 | 23.4k | XMLPropertyState* pHeaderMargins[4] = { nullptr, nullptr, nullptr, nullptr }; |
126 | 23.4k | std::optional<XMLPropertyState> pNewHeaderMargins[4]; |
127 | 23.4k | XMLPropertyState* pAllFooterMarginProperty = nullptr; |
128 | 23.4k | XMLPropertyState* pFooterMargins[4] = { nullptr, nullptr, nullptr, nullptr }; |
129 | 23.4k | std::optional<XMLPropertyState> pNewFooterMargins[4]; |
130 | 23.4k | XMLPropertyState* pMarginGutter = nullptr; |
131 | 23.4k | XMLPropertyState* pRtlGutter = nullptr; |
132 | | |
133 | 23.4k | for (auto& rProp : rProperties) |
134 | 2.48M | { |
135 | 2.48M | XMLPropertyState *property = &rProp; |
136 | 2.48M | sal_Int16 nContextID = getPropertySetMapper()->GetEntryContextId(property->mnIndex); |
137 | 2.48M | if (property->mnIndex >= nStartIndex && property->mnIndex < nEndIndex) |
138 | 2.39M | { |
139 | 2.39M | switch (nContextID) |
140 | 2.39M | { |
141 | 1 | 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 | 0 | case CTF_PM_BORDERALL : pAllBorderProperty = property; break; |
147 | 6 | case CTF_PM_BORDERLEFT : pBorders[XML_LINE_LEFT] = property; break; |
148 | 1 | case CTF_PM_BORDERRIGHT : pBorders[XML_LINE_RIGHT] = property; break; |
149 | 4 | 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 | 0 | case CTF_PM_BORDERWIDTHBOTTOM : pBorderWidths[XML_LINE_BOTTOM] = property; break; |
156 | 694 | case CTF_PM_HEADERPADDINGALL : pAllHeaderPaddingProperty = property; break; |
157 | 5 | case CTF_PM_HEADERPADDINGLEFT : pHeaderPadding[XML_LINE_LEFT] = property; break; |
158 | 5 | case CTF_PM_HEADERPADDINGRIGHT : pHeaderPadding[XML_LINE_RIGHT] = property; break; |
159 | 5 | case CTF_PM_HEADERPADDINGTOP : pHeaderPadding[XML_LINE_TOP] = property; break; |
160 | 5 | case CTF_PM_HEADERPADDINGBOTTOM : pHeaderPadding[XML_LINE_BOTTOM] = property; break; |
161 | 580 | 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 | 2 | case CTF_PM_HEADERBORDERTOP : pHeaderBorders[XML_LINE_TOP] = property; break; |
165 | 3 | 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 | 554 | case CTF_PM_FOOTERPADDINGALL : pAllFooterPaddingProperty = property; break; |
172 | 8 | case CTF_PM_FOOTERPADDINGLEFT : pFooterPadding[XML_LINE_LEFT] = property; break; |
173 | 6 | case CTF_PM_FOOTERPADDINGRIGHT : pFooterPadding[XML_LINE_RIGHT] = property; break; |
174 | 6 | case CTF_PM_FOOTERPADDINGTOP : pFooterPadding[XML_LINE_TOP] = property; break; |
175 | 6 | case CTF_PM_FOOTERPADDINGBOTTOM : pFooterPadding[XML_LINE_BOTTOM] = property; break; |
176 | 636 | case CTF_PM_FOOTERBORDERALL : pAllFooterBorderProperty = property; break; |
177 | 6 | case CTF_PM_FOOTERBORDERLEFT : pFooterBorders[XML_LINE_LEFT] = property; break; |
178 | 6 | case CTF_PM_FOOTERBORDERRIGHT : pFooterBorders[XML_LINE_RIGHT] = property; break; |
179 | 156 | case CTF_PM_FOOTERBORDERTOP : pFooterBorders[XML_LINE_TOP] = property; break; |
180 | 6 | 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.71k | case CTF_PM_HEADERMINHEIGHT : pHeaderMinHeight = property; break; |
188 | 0 | case CTF_PM_FOOTERHEIGHT : pFooterHeight = property; break; |
189 | 1.57k | case CTF_PM_FOOTERMINHEIGHT : pFooterMinHeight = property; break; |
190 | 47 | case CTF_PM_MARGINALL : |
191 | 47 | pAllMarginProperty = property; break; |
192 | 3.02k | case CTF_PM_MARGINTOP : |
193 | 3.02k | pMargins[XML_LINE_TOP] = property; break; |
194 | 2.83k | case CTF_PM_MARGINBOTTOM: |
195 | 2.83k | pMargins[XML_LINE_BOTTOM] = property; break; |
196 | 2.46k | case CTF_PM_MARGINLEFT : |
197 | 2.46k | pMargins[XML_LINE_LEFT] = property; break; |
198 | 3.47k | case CTF_PM_MARGINRIGHT : |
199 | 3.47k | pMargins[XML_LINE_RIGHT] = property; break; |
200 | 0 | case CTF_PM_MARGINGUTTER: |
201 | 0 | pMarginGutter = property; |
202 | 0 | break; |
203 | 1.11M | case CTF_PM_RTLGUTTER: |
204 | 1.11M | pRtlGutter = property; |
205 | 1.11M | 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.73k | case CTF_PM_HEADERMARGINBOTTOM: |
211 | 1.73k | pHeaderMargins[XML_LINE_BOTTOM] = property; break; |
212 | 1.78k | case CTF_PM_HEADERMARGINLEFT : |
213 | 1.78k | pHeaderMargins[XML_LINE_LEFT] = property; break; |
214 | 1.79k | case CTF_PM_HEADERMARGINRIGHT : |
215 | 1.79k | pHeaderMargins[XML_LINE_RIGHT] = property; break; |
216 | 0 | case CTF_PM_FOOTERMARGINALL : |
217 | 0 | pAllFooterMarginProperty = property; break; |
218 | 1.58k | case CTF_PM_FOOTERMARGINTOP : |
219 | 1.58k | pFooterMargins[XML_LINE_TOP] = property; break; |
220 | 0 | case CTF_PM_FOOTERMARGINBOTTOM: |
221 | 0 | pFooterMargins[XML_LINE_BOTTOM] = property; break; |
222 | 1.71k | case CTF_PM_FOOTERMARGINLEFT : |
223 | 1.71k | pFooterMargins[XML_LINE_LEFT] = property; break; |
224 | 1.62k | case CTF_PM_FOOTERMARGINRIGHT : |
225 | 1.62k | pFooterMargins[XML_LINE_RIGHT] = property; break; |
226 | 2.39M | } |
227 | 2.39M | } |
228 | 2.48M | } |
229 | | |
230 | 117k | for (sal_uInt16 i = 0; i < 4; i++) |
231 | 93.7k | { |
232 | 93.7k | if (pAllMarginProperty && !pMargins[i]) |
233 | 7 | { |
234 | 7 | pNewMargins[i].emplace( |
235 | 7 | pAllMarginProperty->mnIndex + 1 + i, |
236 | 7 | pAllMarginProperty->maValue); |
237 | 7 | } |
238 | 93.7k | if (pAllHeaderMarginProperty && !pHeaderMargins[i]) |
239 | 0 | { |
240 | 0 | pNewHeaderMargins[i].emplace( |
241 | 0 | pAllHeaderMarginProperty->mnIndex + 1 + i, |
242 | 0 | pAllHeaderMarginProperty->maValue); |
243 | 0 | } |
244 | 93.7k | if (pAllFooterMarginProperty && !pFooterMargins[i]) |
245 | 0 | { |
246 | 0 | pNewFooterMargins[i].emplace( |
247 | 0 | pAllFooterMarginProperty->mnIndex + 1 + i, |
248 | 0 | pAllFooterMarginProperty->maValue); |
249 | 0 | } |
250 | 93.7k | if (pAllPaddingProperty && !pPadding[i]) |
251 | 4 | pNewPadding[i] = new XMLPropertyState(pAllPaddingProperty->mnIndex + 1 + i, pAllPaddingProperty->maValue); |
252 | 93.7k | if (pAllBorderProperty && !pBorders[i]) |
253 | 0 | { |
254 | 0 | pNewBorders[i] = new XMLPropertyState(pAllBorderProperty->mnIndex + 1 + i, pAllBorderProperty->maValue); |
255 | 0 | pBorders[i] = pNewBorders[i]; |
256 | 0 | } |
257 | 93.7k | if( !pBorderWidths[i] ) |
258 | 93.7k | pBorderWidths[i] = pAllBorderWidthProperty; |
259 | 0 | else |
260 | 0 | pBorderWidths[i]->mnIndex = -1; |
261 | 93.7k | 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 | 93.7k | if (pAllHeaderPaddingProperty && !pHeaderPadding[i]) |
277 | 2.75k | pHeaderNewPadding[i] = new XMLPropertyState(pAllHeaderPaddingProperty->mnIndex + 1 + i, pAllHeaderPaddingProperty->maValue); |
278 | 93.7k | if (pAllHeaderBorderProperty && !pHeaderBorders[i]) |
279 | 2.32k | pHeaderNewBorders[i] = new XMLPropertyState(pAllHeaderBorderProperty->mnIndex + 1 + i, pAllHeaderBorderProperty->maValue); |
280 | 93.7k | if( !pHeaderBorderWidths[i] ) |
281 | 93.7k | pHeaderBorderWidths[i] = pAllHeaderBorderWidthProperty; |
282 | 0 | else |
283 | 0 | pHeaderBorderWidths[i]->mnIndex = -1; |
284 | 93.7k | if( pHeaderBorders[i] ) |
285 | 9 | { |
286 | 9 | table::BorderLine2 aBorderLine; |
287 | 9 | pHeaderBorders[i]->maValue >>= aBorderLine; |
288 | 9 | 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 | 9 | } |
299 | 93.7k | if (pAllFooterPaddingProperty && !pFooterPadding[i]) |
300 | 2.19k | pFooterNewPadding[i] = new XMLPropertyState(pAllFooterPaddingProperty->mnIndex + 1 + i, pAllFooterPaddingProperty->maValue); |
301 | 93.7k | if (pAllFooterBorderProperty && !pFooterBorders[i]) |
302 | 2.52k | pFooterNewBorders[i] = new XMLPropertyState(pAllFooterBorderProperty->mnIndex + 1 + i, pAllFooterBorderProperty->maValue); |
303 | 93.7k | if( !pFooterBorderWidths[i] ) |
304 | 93.7k | pFooterBorderWidths[i] = pAllFooterBorderWidthProperty; |
305 | 0 | else |
306 | 0 | pFooterBorderWidths[i]->mnIndex = -1; |
307 | 93.7k | if( pFooterBorders[i] ) |
308 | 174 | { |
309 | 174 | table::BorderLine2 aBorderLine; |
310 | 174 | pFooterBorders[i]->maValue >>= aBorderLine; |
311 | 174 | 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 | 174 | } |
322 | 93.7k | } |
323 | | |
324 | 23.4k | if (pHeaderHeight) |
325 | 34 | { |
326 | 34 | xHeaderDynamic.emplace(pHeaderHeight->mnIndex + 2, Any(false)); |
327 | 34 | } |
328 | 23.4k | if (pHeaderMinHeight) |
329 | 1.70k | { |
330 | 1.70k | xHeaderDynamic.emplace(pHeaderMinHeight->mnIndex + 1, Any(true)); |
331 | 1.70k | } |
332 | 23.4k | if (pFooterHeight) |
333 | 0 | { |
334 | 0 | xFooterDynamic.emplace(pFooterHeight->mnIndex + 2, Any(false)); |
335 | 0 | } |
336 | 23.4k | if (pFooterMinHeight) |
337 | 1.57k | { |
338 | 1.57k | xFooterDynamic.emplace(pFooterMinHeight->mnIndex + 1, Any(true)); |
339 | 1.57k | } |
340 | | |
341 | | // fdo#38056: nerf the various AllFoo properties so they do not override |
342 | | // the individual Foo properties later on |
343 | 23.4k | if (pAllPaddingProperty) |
344 | 1 | { |
345 | 1 | pAllPaddingProperty->mnIndex = -1; |
346 | 1 | } |
347 | 23.4k | if (pAllBorderProperty) |
348 | 0 | { |
349 | 0 | pAllBorderProperty->mnIndex = -1; |
350 | 0 | } |
351 | 23.4k | if (pAllBorderWidthProperty) |
352 | 0 | { |
353 | 0 | pAllBorderWidthProperty->mnIndex = -1; |
354 | 0 | } |
355 | 23.4k | if (pAllHeaderPaddingProperty) |
356 | 694 | { |
357 | 694 | pAllHeaderPaddingProperty->mnIndex = -1; |
358 | 694 | } |
359 | 23.4k | if (pAllHeaderBorderProperty) |
360 | 580 | { |
361 | 580 | pAllHeaderBorderProperty->mnIndex = -1; |
362 | 580 | } |
363 | 23.4k | if (pAllHeaderBorderWidthProperty) |
364 | 0 | { |
365 | 0 | pAllHeaderBorderWidthProperty->mnIndex = -1; |
366 | 0 | } |
367 | 23.4k | if (pAllFooterPaddingProperty) |
368 | 554 | { |
369 | 554 | pAllFooterPaddingProperty->mnIndex = -1; |
370 | 554 | } |
371 | 23.4k | if (pAllFooterBorderProperty) |
372 | 636 | { |
373 | 636 | pAllFooterBorderProperty->mnIndex = -1; |
374 | 636 | } |
375 | 23.4k | if (pAllFooterBorderWidthProperty) |
376 | 0 | { |
377 | 0 | pAllFooterBorderWidthProperty->mnIndex = -1; |
378 | 0 | } |
379 | 23.4k | if (pAllMarginProperty) |
380 | 47 | { |
381 | 47 | pAllMarginProperty->mnIndex = -1; |
382 | 47 | } |
383 | 23.4k | if (pAllHeaderMarginProperty) |
384 | 0 | { |
385 | 0 | pAllHeaderMarginProperty->mnIndex = -1; |
386 | 0 | } |
387 | 23.4k | if (pAllFooterMarginProperty) |
388 | 0 | { |
389 | 0 | pAllFooterMarginProperty->mnIndex = -1; |
390 | 0 | } |
391 | | |
392 | 23.4k | 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 | 117k | for (sal_uInt16 i = 0; i < 4; i++) |
461 | 93.7k | { |
462 | 93.7k | if (pNewMargins[i]) |
463 | 7 | { |
464 | 7 | rProperties.push_back(*pNewMargins[i]); |
465 | 7 | } |
466 | 93.7k | if (pNewHeaderMargins[i]) |
467 | 0 | { |
468 | 0 | rProperties.push_back(*pNewHeaderMargins[i]); |
469 | 0 | } |
470 | 93.7k | if (pNewFooterMargins[i]) |
471 | 0 | { |
472 | 0 | rProperties.push_back(*pNewFooterMargins[i]); |
473 | 0 | } |
474 | 93.7k | if (pNewPadding[i]) |
475 | 4 | { |
476 | 4 | rProperties.push_back(*pNewPadding[i]); |
477 | 4 | delete pNewPadding[i]; |
478 | 4 | } |
479 | 93.7k | if (pNewBorders[i]) |
480 | 0 | { |
481 | 0 | rProperties.push_back(*pNewBorders[i]); |
482 | 0 | delete pNewBorders[i]; |
483 | 0 | } |
484 | 93.7k | if (pHeaderNewPadding[i]) |
485 | 2.75k | { |
486 | 2.75k | rProperties.push_back(*pHeaderNewPadding[i]); |
487 | 2.75k | delete pHeaderNewPadding[i]; |
488 | 2.75k | } |
489 | 93.7k | if (pHeaderNewBorders[i]) |
490 | 2.32k | { |
491 | 2.32k | rProperties.push_back(*pHeaderNewBorders[i]); |
492 | 2.32k | delete pHeaderNewBorders[i]; |
493 | 2.32k | } |
494 | 93.7k | if (pFooterNewPadding[i]) |
495 | 2.19k | { |
496 | 2.19k | rProperties.push_back(*pFooterNewPadding[i]); |
497 | 2.19k | delete pFooterNewPadding[i]; |
498 | 2.19k | } |
499 | 93.7k | if (pFooterNewBorders[i]) |
500 | 2.52k | { |
501 | 2.52k | rProperties.push_back(*pFooterNewBorders[i]); |
502 | 2.52k | delete pFooterNewBorders[i]; |
503 | 2.52k | } |
504 | 93.7k | } |
505 | | // CAUTION - do not use XMLPropertyState* pointers (like pMargins, |
506 | | // pMarginGutter) after this. |
507 | | |
508 | 23.4k | if(xHeaderDynamic) |
509 | 1.74k | { |
510 | 1.74k | rProperties.push_back(*xHeaderDynamic); |
511 | 1.74k | xHeaderDynamic.reset(); |
512 | 1.74k | } |
513 | 23.4k | if(xFooterDynamic) |
514 | 1.57k | { |
515 | 1.57k | rProperties.push_back(*xFooterDynamic); |
516 | 1.57k | xFooterDynamic.reset(); |
517 | 1.57k | } |
518 | | |
519 | 23.4k | } |
520 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |