/src/libreoffice/editeng/source/items/frmitems.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http: // mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http: // www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #include <memory> |
21 | | #include <com/sun/star/uno/Any.hxx> |
22 | | #include <com/sun/star/drawing/LineStyle.hpp> |
23 | | #include <com/sun/star/script/Converter.hpp> |
24 | | #include <com/sun/star/table/ShadowLocation.hpp> |
25 | | #include <com/sun/star/table/ShadowFormat.hpp> |
26 | | #include <com/sun/star/table/BorderLine2.hpp> |
27 | | #include <com/sun/star/table/BorderLineStyle.hpp> |
28 | | #include <com/sun/star/style/BreakType.hpp> |
29 | | #include <com/sun/star/style/GraphicLocation.hpp> |
30 | | #include <com/sun/star/awt/Size.hpp> |
31 | | #include <com/sun/star/beans/Pair.hpp> |
32 | | #include <com/sun/star/text/WritingMode2.hpp> |
33 | | #include <com/sun/star/frame/status/UpperLowerMarginScale.hpp> |
34 | | #include <com/sun/star/frame/status/LeftRightMarginScale.hpp> |
35 | | #include <com/sun/star/graphic/XGraphic.hpp> |
36 | | #include <com/sun/star/util/XComplexColor.hpp> |
37 | | |
38 | | #include <osl/diagnose.h> |
39 | | #include <i18nutil/unicode.hxx> |
40 | | #include <unotools/ucbstreamhelper.hxx> |
41 | | #include <comphelper/processfactory.hxx> |
42 | | #include <utility> |
43 | | #include <vcl/GraphicObject.hxx> |
44 | | #include <tools/stream.hxx> |
45 | | #include <tools/urlobj.hxx> |
46 | | #include <tools/bigint.hxx> |
47 | | #include <svl/memberid.h> |
48 | | #include <rtl/math.hxx> |
49 | | #include <rtl/ustring.hxx> |
50 | | #include <tools/debug.hxx> |
51 | | #include <tools/mapunit.hxx> |
52 | | #include <tools/UnitConversion.hxx> |
53 | | #include <tools/XmlWriter.hxx> |
54 | | #include <vcl/graphicfilter.hxx> |
55 | | #include <vcl/settings.hxx> |
56 | | #include <vcl/svapp.hxx> |
57 | | #include <editeng/editrids.hrc> |
58 | | #include <editeng/pbinitem.hxx> |
59 | | #include <editeng/sizeitem.hxx> |
60 | | #include <editeng/lrspitem.hxx> |
61 | | #include <editeng/ulspitem.hxx> |
62 | | #include <editeng/prntitem.hxx> |
63 | | #include <editeng/opaqitem.hxx> |
64 | | #include <editeng/protitem.hxx> |
65 | | #include <editeng/shaditem.hxx> |
66 | | #include <editeng/borderline.hxx> |
67 | | #include <editeng/boxitem.hxx> |
68 | | #include <editeng/formatbreakitem.hxx> |
69 | | #include <editeng/keepitem.hxx> |
70 | | #include <editeng/lineitem.hxx> |
71 | | #include <editeng/brushitem.hxx> |
72 | | #include <editeng/frmdiritem.hxx> |
73 | | #include <editeng/itemtype.hxx> |
74 | | #include <editeng/eerdll.hxx> |
75 | | #include <editeng/memberids.h> |
76 | | #include <libxml/xmlwriter.h> |
77 | | #include <o3tl/enumrange.hxx> |
78 | | #include <o3tl/safeint.hxx> |
79 | | #include <sal/log.hxx> |
80 | | #include <sax/tools/converter.hxx> |
81 | | #include <vcl/GraphicLoader.hxx> |
82 | | #include <unotools/securityoptions.hxx> |
83 | | #include <docmodel/uno/UnoComplexColor.hxx> |
84 | | |
85 | | #include <boost/property_tree/ptree.hpp> |
86 | | |
87 | | using namespace ::editeng; |
88 | | using namespace ::com::sun::star; |
89 | | using namespace ::com::sun::star::drawing; |
90 | | using namespace ::com::sun::star::table::BorderLineStyle; |
91 | | |
92 | | |
93 | 0 | SfxPoolItem* SvxPaperBinItem::CreateDefault() { return new SvxPaperBinItem(0);} |
94 | 0 | SfxPoolItem* SvxSizeItem::CreateDefault() { return new SvxSizeItem(0);} |
95 | 0 | SfxPoolItem* SvxLRSpaceItem::CreateDefault() { return new SvxLRSpaceItem(0);} |
96 | 0 | SfxPoolItem* SvxULSpaceItem::CreateDefault() { return new SvxULSpaceItem(0);} |
97 | 0 | SfxPoolItem* SvxProtectItem::CreateDefault() { return new SvxProtectItem(0);} |
98 | 0 | SfxPoolItem* SvxBrushItem::CreateDefault() { return new SvxBrushItem(0);} |
99 | 0 | SfxPoolItem* SvxShadowItem::CreateDefault() { return new SvxShadowItem(0);} |
100 | 0 | SfxPoolItem* SvxBoxItem::CreateDefault() { return new SvxBoxItem(0);} |
101 | 0 | SfxPoolItem* SvxBoxInfoItem::CreateDefault() { return new SvxBoxInfoItem(0);} |
102 | 0 | SfxPoolItem* SvxFormatBreakItem::CreateDefault() { return new SvxFormatBreakItem(SvxBreak::NONE, 0);} |
103 | 0 | SfxPoolItem* SvxFormatKeepItem::CreateDefault() { return new SvxFormatKeepItem(false, 0);} |
104 | 0 | SfxPoolItem* SvxLineItem::CreateDefault() { return new SvxLineItem(0);} |
105 | | |
106 | | SvxPaperBinItem* SvxPaperBinItem::Clone( SfxItemPool* ) const |
107 | 0 | { |
108 | 0 | return new SvxPaperBinItem( *this ); |
109 | 0 | } |
110 | | |
111 | | bool SvxPaperBinItem::GetPresentation |
112 | | ( |
113 | | SfxItemPresentation ePres, |
114 | | MapUnit /*eCoreUnit*/, |
115 | | MapUnit /*ePresUnit*/, |
116 | | OUString& rText, const IntlWrapper& |
117 | | ) const |
118 | 0 | { |
119 | 0 | switch ( ePres ) |
120 | 0 | { |
121 | 0 | case SfxItemPresentation::Nameless: |
122 | 0 | rText = OUString::number( GetValue() ); |
123 | 0 | return true; |
124 | | |
125 | 0 | case SfxItemPresentation::Complete: |
126 | 0 | { |
127 | 0 | sal_uInt8 nValue = GetValue(); |
128 | |
|
129 | 0 | if ( PAPERBIN_PRINTER_SETTINGS == nValue ) |
130 | 0 | rText = EditResId(RID_SVXSTR_PAPERBIN_SETTINGS); |
131 | 0 | else |
132 | 0 | { |
133 | 0 | rText = EditResId(RID_SVXSTR_PAPERBIN) + " " + OUString::number( nValue ); |
134 | 0 | } |
135 | 0 | return true; |
136 | 0 | } |
137 | | //no break necessary |
138 | 0 | default: ; //prevent warning |
139 | 0 | } |
140 | | |
141 | 0 | return false; |
142 | 0 | } |
143 | | |
144 | | |
145 | | SvxSizeItem::SvxSizeItem( const sal_uInt16 nId, const Size& rSize ) : |
146 | | |
147 | 2.13M | SfxPoolItem( nId ), |
148 | | |
149 | 2.13M | m_aSize( rSize ) |
150 | 2.13M | { |
151 | 2.13M | } |
152 | | |
153 | | |
154 | | bool SvxSizeItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
155 | 128 | { |
156 | 128 | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
157 | 128 | nMemberId &= ~CONVERT_TWIPS; |
158 | | |
159 | 128 | awt::Size aTmp(m_aSize.Width(), m_aSize.Height()); |
160 | 128 | if( bConvert ) |
161 | 128 | { |
162 | 128 | aTmp.Height = convertTwipToMm100(aTmp.Height); |
163 | 128 | aTmp.Width = convertTwipToMm100(aTmp.Width); |
164 | 128 | } |
165 | | |
166 | 128 | switch( nMemberId ) |
167 | 128 | { |
168 | 35 | case MID_SIZE_SIZE: rVal <<= aTmp; break; |
169 | 35 | case MID_SIZE_WIDTH: rVal <<= aTmp.Width; break; |
170 | 58 | case MID_SIZE_HEIGHT: rVal <<= aTmp.Height; break; |
171 | 0 | default: OSL_FAIL("Wrong MemberId!"); return false; |
172 | 128 | } |
173 | | |
174 | 128 | return true; |
175 | 128 | } |
176 | | |
177 | | |
178 | | bool SvxSizeItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
179 | 35.4k | { |
180 | 35.4k | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
181 | 35.4k | nMemberId &= ~CONVERT_TWIPS; |
182 | | |
183 | 35.4k | switch( nMemberId ) |
184 | 35.4k | { |
185 | 3.10k | case MID_SIZE_SIZE: |
186 | 3.10k | { |
187 | 3.10k | awt::Size aTmp; |
188 | 3.10k | if( rVal >>= aTmp ) |
189 | 3.10k | { |
190 | 3.10k | if(bConvert) |
191 | 3.10k | { |
192 | 3.10k | aTmp.Height = o3tl::toTwips(aTmp.Height, o3tl::Length::mm100); |
193 | 3.10k | aTmp.Width = o3tl::toTwips(aTmp.Width, o3tl::Length::mm100); |
194 | 3.10k | } |
195 | 3.10k | m_aSize = Size( aTmp.Width, aTmp.Height ); |
196 | 3.10k | } |
197 | 0 | else |
198 | 0 | { |
199 | 0 | return false; |
200 | 0 | } |
201 | 3.10k | } |
202 | 3.10k | break; |
203 | 5.84k | case MID_SIZE_WIDTH: |
204 | 5.84k | { |
205 | 5.84k | sal_Int32 nVal = 0; |
206 | 5.84k | if(!(rVal >>= nVal )) |
207 | 0 | return false; |
208 | | |
209 | 5.84k | m_aSize.setWidth( bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal ); |
210 | 5.84k | } |
211 | 0 | break; |
212 | 26.5k | case MID_SIZE_HEIGHT: |
213 | 26.5k | { |
214 | 26.5k | sal_Int32 nVal = 0; |
215 | 26.5k | if(!(rVal >>= nVal)) |
216 | 0 | return true; |
217 | | |
218 | 26.5k | m_aSize.setHeight( bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal ); |
219 | 26.5k | } |
220 | 0 | break; |
221 | 0 | default: OSL_FAIL("Wrong MemberId!"); |
222 | 0 | return false; |
223 | 35.4k | } |
224 | 35.4k | return true; |
225 | 35.4k | } |
226 | | |
227 | | |
228 | | SvxSizeItem::SvxSizeItem( const sal_uInt16 nId ) : |
229 | | |
230 | 11 | SfxPoolItem( nId ) |
231 | 11 | { |
232 | 11 | } |
233 | | |
234 | | |
235 | | bool SvxSizeItem::operator==( const SfxPoolItem& rAttr ) const |
236 | 2.76M | { |
237 | 2.76M | assert(SfxPoolItem::operator==(rAttr)); |
238 | | |
239 | 2.76M | return ( m_aSize == static_cast<const SvxSizeItem&>( rAttr ).GetSize() ); |
240 | 2.76M | } |
241 | | |
242 | | SvxSizeItem* SvxSizeItem::Clone( SfxItemPool* ) const |
243 | 1.60M | { |
244 | 1.60M | return new SvxSizeItem( *this ); |
245 | 1.60M | } |
246 | | |
247 | | bool SvxSizeItem::GetPresentation |
248 | | ( |
249 | | SfxItemPresentation ePres, |
250 | | MapUnit eCoreUnit, |
251 | | MapUnit ePresUnit, |
252 | | OUString& rText, const IntlWrapper& rIntl |
253 | | ) const |
254 | 0 | { |
255 | 0 | OUString cpDelimTmp(cpDelim); |
256 | 0 | switch ( ePres ) |
257 | 0 | { |
258 | 0 | case SfxItemPresentation::Nameless: |
259 | 0 | rText = GetMetricText( m_aSize.Width(), eCoreUnit, ePresUnit, &rIntl ) + |
260 | 0 | cpDelimTmp + |
261 | 0 | GetMetricText( m_aSize.Height(), eCoreUnit, ePresUnit, &rIntl ); |
262 | 0 | return true; |
263 | | |
264 | 0 | case SfxItemPresentation::Complete: |
265 | 0 | rText = EditResId(RID_SVXITEMS_SIZE_WIDTH) + |
266 | 0 | GetMetricText( m_aSize.Width(), eCoreUnit, ePresUnit, &rIntl ) + |
267 | 0 | " " + EditResId(GetMetricId(ePresUnit)) + |
268 | 0 | cpDelimTmp + |
269 | 0 | EditResId(RID_SVXITEMS_SIZE_HEIGHT) + |
270 | 0 | GetMetricText( m_aSize.Height(), eCoreUnit, ePresUnit, &rIntl ) + |
271 | 0 | " " + EditResId(GetMetricId(ePresUnit)); |
272 | 0 | return true; |
273 | | // no break necessary |
274 | 0 | default: ; // prevent warning |
275 | |
|
276 | 0 | } |
277 | 0 | return false; |
278 | 0 | } |
279 | | |
280 | | |
281 | | void SvxSizeItem::ScaleMetrics(double fScale) |
282 | 0 | { |
283 | 0 | m_aSize.setWidth( BigInt::Scale( m_aSize.Width(), fScale ) ); |
284 | 0 | m_aSize.setHeight( BigInt::Scale( m_aSize.Height(), fScale ) ); |
285 | 0 | } |
286 | | |
287 | | |
288 | | bool SvxSizeItem::HasMetrics() const |
289 | 0 | { |
290 | 0 | return true; |
291 | 0 | } |
292 | | |
293 | | double SvxIndentValue::ResolveDouble(const SvxFontUnitMetrics& rMetrics) const |
294 | 25.1M | { |
295 | 25.1M | if (m_nUnit == css::util::MeasureUnit::TWIP) |
296 | 25.1M | return m_dValue; |
297 | | |
298 | 0 | SAL_WARN_IF(!rMetrics.m_bInitialized, "editeng", "font-relative indentation lost"); |
299 | | |
300 | 0 | switch (m_nUnit) |
301 | 0 | { |
302 | 0 | case css::util::MeasureUnit::FONT_EM: |
303 | 0 | return m_dValue * rMetrics.m_dEmTwips; |
304 | | |
305 | 0 | case css::util::MeasureUnit::FONT_CJK_ADVANCE: |
306 | 0 | return m_dValue * rMetrics.m_dIcTwips; |
307 | | |
308 | 0 | default: |
309 | 0 | SAL_WARN("editeng", "unhandled type conversion"); |
310 | 0 | return 0.0; |
311 | 0 | } |
312 | 0 | } |
313 | | |
314 | | sal_Int32 SvxIndentValue::Resolve(const SvxFontUnitMetrics& rMetrics) const |
315 | 25.1M | { |
316 | 25.1M | return static_cast<sal_Int32>(std::llround(ResolveDouble(rMetrics))); |
317 | 25.1M | } |
318 | | |
319 | | sal_Int32 SvxIndentValue::ResolveFixedPart() const |
320 | 880k | { |
321 | 880k | if (m_nUnit == css::util::MeasureUnit::TWIP) |
322 | 880k | return Resolve({}); |
323 | | |
324 | 0 | return 0; |
325 | 880k | } |
326 | | |
327 | | sal_Int32 SvxIndentValue::ResolveVariablePart(const SvxFontUnitMetrics& rMetrics) const |
328 | 1.25M | { |
329 | 1.25M | if (m_nUnit == css::util::MeasureUnit::TWIP) |
330 | 1.25M | return 0; |
331 | | |
332 | 0 | return Resolve(rMetrics); |
333 | 1.25M | } |
334 | | |
335 | | void SvxIndentValue::ScaleMetrics(double fScale) |
336 | 0 | { |
337 | 0 | m_dValue = m_dValue * fScale; |
338 | 0 | } |
339 | | |
340 | | size_t SvxIndentValue::hashCode() const |
341 | 972k | { |
342 | 972k | std::size_t seed(0); |
343 | 972k | o3tl::hash_combine(seed, m_dValue); |
344 | 972k | o3tl::hash_combine(seed, m_nUnit); |
345 | 972k | return seed; |
346 | 972k | } |
347 | | |
348 | | namespace |
349 | | { |
350 | | |
351 | | boost::property_tree::ptree lcl_IndentValueToJson(const char* aName, SvxIndentValue stValue) |
352 | 0 | { |
353 | 0 | boost::property_tree::ptree aState; |
354 | |
|
355 | 0 | switch (stValue.m_nUnit) |
356 | 0 | { |
357 | 0 | case css::util::MeasureUnit::TWIP: |
358 | 0 | { |
359 | 0 | OUString sValue |
360 | 0 | = GetMetricText(stValue.m_dValue, MapUnit::MapTwip, MapUnit::MapInch, nullptr); |
361 | 0 | aState.put(aName, sValue); |
362 | 0 | aState.put("unit", "inch"); |
363 | 0 | } |
364 | 0 | break; |
365 | | |
366 | 0 | case css::util::MeasureUnit::FONT_EM: |
367 | 0 | aState.put(aName, stValue.m_dValue); |
368 | 0 | aState.put("unit", "em"); |
369 | 0 | break; |
370 | | |
371 | 0 | case css::util::MeasureUnit::FONT_CJK_ADVANCE: |
372 | 0 | aState.put(aName, stValue.m_dValue); |
373 | 0 | aState.put("unit", "ic"); |
374 | 0 | break; |
375 | | |
376 | 0 | default: |
377 | 0 | SAL_WARN("editeng", "unhandled type conversion"); |
378 | 0 | break; |
379 | 0 | } |
380 | | |
381 | 0 | return aState; |
382 | 0 | } |
383 | | |
384 | | bool lcl_FillAbsoluteMeasureAny(const SvxIndentValue& rIndent, uno::Any& rVal, bool bConvert) |
385 | 1.17k | { |
386 | 1.17k | if (rIndent.m_nUnit == css::util::MeasureUnit::TWIP) |
387 | 1.17k | { |
388 | 1.17k | auto nConvOffset = (bConvert ? convertTwipToMm100(rIndent.m_dValue) : rIndent.m_dValue); |
389 | 1.17k | rVal <<= static_cast<sal_Int32>(std::llround(nConvOffset)); |
390 | 1.17k | return true; |
391 | 1.17k | } |
392 | | |
393 | 0 | return false; |
394 | 1.17k | } |
395 | | |
396 | | bool lcl_FillRelativeMeasureAny(const SvxIndentValue& rIndent, uno::Any& rVal) |
397 | 278 | { |
398 | 278 | if (rIndent.m_nUnit != css::util::MeasureUnit::TWIP) |
399 | 0 | { |
400 | 0 | rVal <<= css::beans::Pair<double, sal_Int16>{ rIndent.m_dValue, rIndent.m_nUnit }; |
401 | 0 | return true; |
402 | 0 | } |
403 | | |
404 | 278 | return false; |
405 | 278 | } |
406 | | |
407 | | } |
408 | | |
409 | | SvxLRSpaceItem::SvxLRSpaceItem(const sal_uInt16 nId) |
410 | 890k | : SfxPoolItem(nId) |
411 | 890k | , m_nGutterMargin(0) |
412 | 890k | , m_nRightGutterMargin(0), |
413 | 890k | nPropFirstLineOffset( 100 ), |
414 | 890k | nPropLeftMargin( 100 ), |
415 | 890k | nPropRightMargin( 100 ), |
416 | 890k | bAutoFirst ( false ), |
417 | 890k | bExplicitZeroMarginValRight(false), |
418 | 890k | bExplicitZeroMarginValLeft(false) |
419 | 890k | { |
420 | 890k | } |
421 | | |
422 | | SvxLRSpaceItem::SvxLRSpaceItem(SvxIndentValue stLeft, SvxIndentValue stRight, |
423 | | SvxIndentValue stOffset, const sal_uInt16 nId) |
424 | 474k | : SfxPoolItem(nId) |
425 | 474k | , m_nGutterMargin(0) |
426 | 474k | , m_nRightGutterMargin(0) |
427 | 474k | , nPropFirstLineOffset(100) |
428 | 474k | , nPropLeftMargin(100) |
429 | 474k | , nPropRightMargin(100) |
430 | 474k | , bAutoFirst(false) |
431 | 474k | , bExplicitZeroMarginValRight(false) |
432 | 474k | , bExplicitZeroMarginValLeft(false) |
433 | 474k | { |
434 | 474k | SetLeft(stLeft); |
435 | 474k | SetRight(stRight); |
436 | 474k | SetTextFirstLineOffset(stOffset); |
437 | 474k | } |
438 | | |
439 | | |
440 | | bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
441 | 1.94k | { |
442 | 1.94k | bool bRet = true; |
443 | 1.94k | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
444 | 1.94k | nMemberId &= ~CONVERT_TWIPS; |
445 | 1.94k | switch( nMemberId ) |
446 | 1.94k | { |
447 | | // now all signed |
448 | 0 | case 0: |
449 | 0 | { |
450 | 0 | css::frame::status::LeftRightMarginScale aLRSpace; |
451 | |
|
452 | 0 | auto nLeftTwips = ResolveLeft({}); |
453 | 0 | aLRSpace.Left |
454 | 0 | = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nLeftTwips) : nLeftTwips); |
455 | |
|
456 | 0 | auto nTextLeftTwips = ResolveTextLeft({}); |
457 | 0 | aLRSpace.TextLeft = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nTextLeftTwips) |
458 | 0 | : nTextLeftTwips); |
459 | |
|
460 | 0 | auto nRightTwips = ResolveRight({}); |
461 | 0 | aLRSpace.Right |
462 | 0 | = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nRightTwips) : nRightTwips); |
463 | |
|
464 | 0 | aLRSpace.ScaleLeft = static_cast<sal_Int16>(nPropLeftMargin); |
465 | 0 | aLRSpace.ScaleRight = static_cast<sal_Int16>(nPropRightMargin); |
466 | |
|
467 | 0 | auto nFirstLineOffsetTwips = ResolveTextFirstLineOffset({}); |
468 | 0 | aLRSpace.FirstLine = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nFirstLineOffsetTwips) : nFirstLineOffsetTwips); |
469 | |
|
470 | 0 | aLRSpace.ScaleFirstLine = static_cast<sal_Int16>(nPropFirstLineOffset); |
471 | 0 | aLRSpace.AutoFirstLine = IsAutoFirst(); |
472 | 0 | rVal <<= aLRSpace; |
473 | 0 | break; |
474 | 0 | } |
475 | 447 | case MID_L_MARGIN: |
476 | 447 | bRet = lcl_FillAbsoluteMeasureAny(GetLeft(), rVal, bConvert); |
477 | 447 | break; |
478 | | |
479 | 19 | case MID_TXT_LMARGIN: |
480 | 19 | bRet = lcl_FillAbsoluteMeasureAny(GetTextLeft(), rVal, bConvert); |
481 | 19 | break; |
482 | | |
483 | 19 | case MID_L_UNIT_MARGIN: |
484 | 19 | bRet = lcl_FillRelativeMeasureAny(GetTextLeft(), rVal); |
485 | 19 | break; |
486 | | |
487 | 466 | case MID_R_MARGIN: |
488 | 466 | bRet = lcl_FillAbsoluteMeasureAny(m_stRightMargin, rVal, bConvert); |
489 | 466 | break; |
490 | 19 | case MID_R_UNIT_MARGIN: |
491 | 19 | bRet = lcl_FillRelativeMeasureAny(m_stRightMargin, rVal); |
492 | 19 | break; |
493 | | |
494 | 0 | case MID_L_REL_MARGIN: |
495 | 0 | rVal <<= static_cast<sal_Int16>(nPropLeftMargin); |
496 | 0 | break; |
497 | 0 | case MID_R_REL_MARGIN: |
498 | 0 | rVal <<= static_cast<sal_Int16>(nPropRightMargin); |
499 | 0 | break; |
500 | | |
501 | 19 | case MID_FIRST_LINE_INDENT: |
502 | 19 | bRet = lcl_FillAbsoluteMeasureAny(m_stFirstLineOffset, rVal, bConvert); |
503 | 19 | break; |
504 | | |
505 | 0 | case MID_FIRST_LINE_REL_INDENT: |
506 | 0 | rVal <<= static_cast<sal_Int16>(nPropFirstLineOffset); |
507 | 0 | break; |
508 | | |
509 | 19 | case MID_FIRST_LINE_UNIT_INDENT: |
510 | 19 | bRet = lcl_FillRelativeMeasureAny(m_stFirstLineOffset, rVal); |
511 | 19 | break; |
512 | | |
513 | 0 | case MID_FIRST_AUTO: |
514 | 0 | rVal <<= IsAutoFirst(); |
515 | 0 | break; |
516 | | |
517 | 939 | case MID_GUTTER_MARGIN: |
518 | 939 | rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(m_nGutterMargin) |
519 | 939 | : m_nGutterMargin); |
520 | 939 | break; |
521 | | |
522 | 0 | default: |
523 | 0 | bRet = false; |
524 | | // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? |
525 | 0 | OSL_FAIL("unknown MemberId"); |
526 | 1.94k | } |
527 | 1.94k | return bRet; |
528 | 1.94k | } |
529 | | |
530 | | |
531 | | bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
532 | 457k | { |
533 | 457k | bool bConvert = 0 != (nMemberId&CONVERT_TWIPS); |
534 | 457k | nMemberId &= ~CONVERT_TWIPS; |
535 | 457k | sal_Int32 nVal = 0; |
536 | 457k | if (nMemberId != 0 && nMemberId != MID_FIRST_AUTO && nMemberId != MID_L_REL_MARGIN |
537 | 457k | && nMemberId != MID_R_REL_MARGIN && nMemberId != MID_FIRST_LINE_UNIT_INDENT |
538 | 457k | && nMemberId != MID_L_UNIT_MARGIN && nMemberId != MID_R_UNIT_MARGIN) |
539 | 457k | if (!(rVal >>= nVal)) |
540 | 0 | return false; |
541 | | |
542 | 457k | switch( nMemberId ) |
543 | 457k | { |
544 | 0 | case 0: |
545 | 0 | { |
546 | 0 | css::frame::status::LeftRightMarginScale aLRSpace; |
547 | 0 | if(!(rVal >>= aLRSpace)) |
548 | 0 | return false; |
549 | | |
550 | 0 | SetLeft(SvxIndentValue::twips( |
551 | 0 | bConvert ? o3tl::toTwips(aLRSpace.Left, o3tl::Length::mm100) : aLRSpace.Left)); |
552 | 0 | SetTextLeft(SvxIndentValue::twips( |
553 | 0 | bConvert ? o3tl::toTwips(aLRSpace.TextLeft, o3tl::Length::mm100) |
554 | 0 | : aLRSpace.TextLeft)); |
555 | 0 | SetRight(SvxIndentValue::twips( |
556 | 0 | bConvert ? o3tl::toTwips(aLRSpace.Right, o3tl::Length::mm100) : aLRSpace.Right)); |
557 | 0 | nPropLeftMargin = aLRSpace.ScaleLeft; |
558 | 0 | nPropRightMargin = aLRSpace.ScaleRight; |
559 | 0 | SetTextFirstLineOffset(SvxIndentValue::twips( |
560 | 0 | bConvert ? o3tl::toTwips(aLRSpace.FirstLine, o3tl::Length::mm100) |
561 | 0 | : aLRSpace.FirstLine)); |
562 | 0 | SetPropTextFirstLineOffset ( aLRSpace.ScaleFirstLine ); |
563 | 0 | SetAutoFirst( aLRSpace.AutoFirstLine ); |
564 | 0 | break; |
565 | 0 | } |
566 | 21.6k | case MID_L_MARGIN: |
567 | 21.6k | SetLeft( |
568 | 21.6k | SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); |
569 | 21.6k | break; |
570 | | |
571 | 201k | case MID_TXT_LMARGIN: |
572 | 201k | SetTextLeft( |
573 | 201k | SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); |
574 | 201k | break; |
575 | | |
576 | 0 | case MID_L_UNIT_MARGIN: |
577 | 0 | { |
578 | 0 | css::beans::Pair<double, sal_Int16> stVal; |
579 | 0 | if (!(rVal >>= stVal)) |
580 | 0 | { |
581 | 0 | return false; |
582 | 0 | } |
583 | | |
584 | 0 | SetTextLeft(SvxIndentValue{ stVal.First, stVal.Second }); |
585 | 0 | break; |
586 | 0 | } |
587 | | |
588 | 28.1k | case MID_R_MARGIN: |
589 | 28.1k | SetRight( |
590 | 28.1k | SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); |
591 | 28.1k | break; |
592 | | |
593 | 0 | case MID_R_UNIT_MARGIN: |
594 | 0 | { |
595 | 0 | css::beans::Pair<double, sal_Int16> stVal; |
596 | 0 | if (!(rVal >>= stVal)) |
597 | 0 | { |
598 | 0 | return false; |
599 | 0 | } |
600 | | |
601 | 0 | SetRight(SvxIndentValue{ stVal.First, stVal.Second }); |
602 | 0 | break; |
603 | 0 | } |
604 | | |
605 | 0 | case MID_L_REL_MARGIN: |
606 | 0 | case MID_R_REL_MARGIN: |
607 | 0 | { |
608 | 0 | sal_Int32 nRel = 0; |
609 | 0 | if((rVal >>= nRel) && nRel >= 0 && nRel < SAL_MAX_UINT16) |
610 | 0 | { |
611 | 0 | if(MID_L_REL_MARGIN== nMemberId) |
612 | 0 | nPropLeftMargin = static_cast<sal_uInt16>(nRel); |
613 | 0 | else |
614 | 0 | nPropRightMargin = static_cast<sal_uInt16>(nRel); |
615 | 0 | } |
616 | 0 | else |
617 | 0 | return false; |
618 | 0 | } |
619 | 0 | break; |
620 | 201k | case MID_FIRST_LINE_INDENT: |
621 | 201k | SetTextFirstLineOffset( |
622 | 201k | SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); |
623 | 201k | break; |
624 | | |
625 | 0 | case MID_FIRST_LINE_REL_INDENT: |
626 | 0 | SetPropTextFirstLineOffset ( nVal ); |
627 | 0 | break; |
628 | | |
629 | 0 | case MID_FIRST_LINE_UNIT_INDENT: |
630 | 0 | { |
631 | 0 | css::beans::Pair<double, sal_Int16> stVal; |
632 | 0 | if (!(rVal >>= stVal)) |
633 | 0 | { |
634 | 0 | return false; |
635 | 0 | } |
636 | | |
637 | 0 | SetTextFirstLineOffset(SvxIndentValue{ stVal.First, stVal.Second }); |
638 | 0 | break; |
639 | 0 | } |
640 | | |
641 | 0 | case MID_FIRST_AUTO: |
642 | 0 | SetAutoFirst( Any2Bool(rVal) ); |
643 | 0 | break; |
644 | | |
645 | 4.08k | case MID_GUTTER_MARGIN: |
646 | 4.08k | SetGutterMargin(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); |
647 | 4.08k | break; |
648 | | |
649 | 0 | default: |
650 | 0 | OSL_FAIL("unknown MemberId"); |
651 | 0 | return false; |
652 | 457k | } |
653 | 457k | return true; |
654 | 457k | } |
655 | | |
656 | | void SvxLeftMarginItem::SetLeft(const tools::Long nL, const sal_uInt16 nProp) |
657 | 0 | { |
658 | 0 | m_nLeftMargin = (nL * nProp) / 100; |
659 | 0 | m_nPropLeftMargin = nProp; |
660 | 0 | } |
661 | | |
662 | | void SvxLRSpaceItem::SetLeft(SvxIndentValue stL, const sal_uInt16 nProp) |
663 | 806k | { |
664 | 806k | SAL_WARN_IF(m_stFirstLineOffset.m_dValue != 0.0, "editeng", |
665 | 806k | "probably call SetTextLeft instead? looks inconsistent otherwise"); |
666 | | |
667 | 806k | m_stLeftMargin = stL; |
668 | 806k | nPropLeftMargin = nProp; |
669 | | |
670 | 806k | if (nProp != 100) |
671 | 0 | { |
672 | 0 | m_stLeftMargin.m_dValue = (stL.m_dValue * static_cast<double>(nProp)) / 100.0; |
673 | 0 | } |
674 | 806k | } |
675 | | |
676 | 102k | const SvxIndentValue & SvxLRSpaceItem::GetLeft() const { return m_stLeftMargin; } |
677 | | |
678 | | sal_Int32 SvxLRSpaceItem::ResolveLeft(const SvxFontUnitMetrics& rMetrics) const |
679 | 446k | { |
680 | 446k | return m_stLeftMargin.Resolve(rMetrics); |
681 | 446k | } |
682 | | |
683 | | void SvxRightMarginItem::SetRight(SvxIndentValue stR, const sal_uInt16 nProp) |
684 | 287k | { |
685 | 287k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
686 | | |
687 | 287k | m_stRightMargin = stR; |
688 | 287k | m_nPropRightMargin = nProp; |
689 | | |
690 | 287k | if (nProp != 100) |
691 | 0 | { |
692 | 0 | m_stRightMargin.m_dValue = (stR.m_dValue * static_cast<double>(nProp)) / 100.0; |
693 | 0 | } |
694 | 287k | } |
695 | | |
696 | 363k | const SvxIndentValue & SvxRightMarginItem::GetRight() const { return m_stRightMargin; } |
697 | | |
698 | 7.14k | const SvxIndentValue & SvxLRSpaceItem::GetRight() const { return m_stRightMargin; } |
699 | | |
700 | | sal_Int32 SvxRightMarginItem::ResolveRight(const SvxFontUnitMetrics& rMetrics) const |
701 | 621k | { |
702 | 621k | return m_stRightMargin.Resolve(rMetrics); |
703 | 621k | } |
704 | | |
705 | | sal_Int32 SvxLRSpaceItem::ResolveRight(const SvxFontUnitMetrics& rMetrics) const |
706 | 6.61M | { |
707 | 6.61M | return m_stRightMargin.Resolve(rMetrics); |
708 | 6.61M | } |
709 | | |
710 | | sal_Int32 SvxRightMarginItem::ResolveRightFixedPart() const |
711 | 290k | { |
712 | 290k | return m_stRightMargin.ResolveFixedPart(); |
713 | 290k | } |
714 | | |
715 | | sal_Int32 SvxRightMarginItem::ResolveRightVariablePart(const SvxFontUnitMetrics& rMetrics) const |
716 | 419k | { |
717 | 419k | return m_stRightMargin.ResolveVariablePart(rMetrics); |
718 | 419k | } |
719 | | |
720 | 308 | sal_uInt16 SvxRightMarginItem::GetPropRight() const { return m_nPropRightMargin; } |
721 | | |
722 | | void SvxLRSpaceItem::SetRight(SvxIndentValue stR, const sal_uInt16 nProp) |
723 | 843k | { |
724 | 843k | if (0.0 == stR.m_dValue) |
725 | 270k | { |
726 | 270k | SetExplicitZeroMarginValRight(true); |
727 | 270k | } |
728 | | |
729 | 843k | m_stRightMargin = stR; |
730 | 843k | nPropRightMargin = nProp; |
731 | | |
732 | 843k | if (nProp != 100) |
733 | 0 | { |
734 | 0 | m_stRightMargin.m_dValue = (stR.m_dValue * static_cast<double>(nProp)) / 100.0; |
735 | 0 | } |
736 | 843k | } |
737 | | |
738 | | void SvxLRSpaceItem::SetTextFirstLineOffset(SvxIndentValue stValue, sal_uInt16 nProp) |
739 | 781k | { |
740 | | // note: left margin contains any negative first line offset - preserve it! |
741 | 781k | if (m_stFirstLineOffset.m_dValue < 0.0) |
742 | 510 | { |
743 | 510 | m_stLeftMargin |
744 | 510 | = SvxIndentValue::twips(m_stLeftMargin.Resolve({}) - ResolveTextFirstLineOffset({})); |
745 | 510 | } |
746 | | |
747 | 781k | m_stFirstLineOffset = stValue; |
748 | 781k | nPropFirstLineOffset = nProp; |
749 | | |
750 | 781k | if (nProp != 100) |
751 | 0 | { |
752 | 0 | m_stFirstLineOffset.m_dValue = (stValue.m_dValue * static_cast<double>(nProp)) / 100.0; |
753 | 0 | } |
754 | | |
755 | 781k | if (m_stFirstLineOffset.m_dValue < 0.0) |
756 | 52.1k | { |
757 | 52.1k | m_stLeftMargin |
758 | 52.1k | = SvxIndentValue::twips(m_stLeftMargin.Resolve({}) + ResolveTextFirstLineOffset({})); |
759 | 52.1k | } |
760 | 781k | } |
761 | | |
762 | | void SvxTextLeftMarginItem::SetTextLeft(SvxIndentValue stL, const sal_uInt16 nProp) |
763 | 899k | { |
764 | 899k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
765 | | |
766 | 899k | m_stTextLeftMargin = stL; |
767 | 899k | m_nPropLeftMargin = nProp; |
768 | | |
769 | 899k | if (nProp != 100) |
770 | 0 | { |
771 | 0 | m_stTextLeftMargin.m_dValue = (stL.m_dValue * static_cast<double>(nProp)) / 100.0; |
772 | 0 | } |
773 | 899k | } |
774 | | |
775 | | void SvxLRSpaceItem::SetTextLeft(SvxIndentValue stL, const sal_uInt16 nProp) |
776 | 353k | { |
777 | 353k | if (0.0 == stL.m_dValue) |
778 | 337k | { |
779 | 337k | SetExplicitZeroMarginValLeft(true); |
780 | 337k | } |
781 | | |
782 | 353k | m_stLeftMargin = stL; |
783 | 353k | nPropLeftMargin = nProp; |
784 | | |
785 | 353k | if (nProp != 100) |
786 | 0 | { |
787 | 0 | m_stLeftMargin.m_dValue = (stL.m_dValue * static_cast<double>(nProp)) / 100.0; |
788 | 0 | } |
789 | | |
790 | | // note: left margin contains any negative first line offset |
791 | 353k | if (0.0 > m_stFirstLineOffset.m_dValue) |
792 | 9.86k | { |
793 | 9.86k | m_stLeftMargin |
794 | 9.86k | = SvxIndentValue::twips(m_stLeftMargin.Resolve({}) + ResolveTextFirstLineOffset({})); |
795 | 9.86k | } |
796 | 353k | } |
797 | | |
798 | | const SvxIndentValue & SvxLRSpaceItem::GetTextFirstLineOffset() const |
799 | 0 | { |
800 | 0 | return m_stFirstLineOffset; |
801 | 0 | } |
802 | | |
803 | | sal_Int32 SvxLRSpaceItem::ResolveTextFirstLineOffset(const SvxFontUnitMetrics& rMetrics) const |
804 | 5.93M | { |
805 | 5.93M | return m_stFirstLineOffset.Resolve(rMetrics); |
806 | 5.93M | } |
807 | | |
808 | 771k | const SvxIndentValue & SvxTextLeftMarginItem::GetTextLeft() const { return m_stTextLeftMargin; } |
809 | | |
810 | | sal_Int32 SvxTextLeftMarginItem::ResolveTextLeft(const SvxFontUnitMetrics& rMetrics) const |
811 | 1.62M | { |
812 | 1.62M | return m_stTextLeftMargin.Resolve(rMetrics); |
813 | 1.62M | } |
814 | | |
815 | | sal_Int32 SvxTextLeftMarginItem::ResolveLeft(const SvxFirstLineIndentItem& rFirstLine, |
816 | | const SvxFontUnitMetrics& rMetrics) const |
817 | 453k | { |
818 | 453k | auto nLeft = m_stTextLeftMargin.Resolve(rMetrics); |
819 | | |
820 | | // add any negative first line offset to text left margin to get left |
821 | 453k | auto nFirstLine = rFirstLine.GetTextFirstLineOffset().Resolve(rMetrics); |
822 | 453k | if (nFirstLine < 0) |
823 | 20.5k | { |
824 | 20.5k | nLeft += nFirstLine; |
825 | 20.5k | } |
826 | | |
827 | 453k | return nLeft; |
828 | 453k | } |
829 | | |
830 | | sal_Int32 |
831 | | SvxTextLeftMarginItem::ResolveLeftFixedPart(const SvxFirstLineIndentItem& rFirstLine) const |
832 | 295k | { |
833 | 295k | auto nLeft = m_stTextLeftMargin.ResolveFixedPart(); |
834 | | |
835 | | // add any negative first line offset to text left margin to get left |
836 | 295k | auto nFirstLine = rFirstLine.GetTextFirstLineOffset().ResolveFixedPart(); |
837 | 295k | if (nFirstLine < 0) |
838 | 5.28k | { |
839 | 5.28k | nLeft += nFirstLine; |
840 | 5.28k | } |
841 | | |
842 | 295k | return nLeft; |
843 | 295k | } |
844 | | |
845 | | sal_Int32 SvxTextLeftMarginItem::ResolveLeftVariablePart(const SvxFirstLineIndentItem& rFirstLine, |
846 | | const SvxFontUnitMetrics& rMetrics) const |
847 | 419k | { |
848 | 419k | auto nLeft = m_stTextLeftMargin.ResolveVariablePart(rMetrics); |
849 | | |
850 | | // add any negative first line offset to text left margin to get left |
851 | 419k | auto nFirstLine = rFirstLine.GetTextFirstLineOffset().ResolveVariablePart(rMetrics); |
852 | 419k | if (nFirstLine < 0) |
853 | 0 | { |
854 | 0 | nLeft += nFirstLine; |
855 | 0 | } |
856 | | |
857 | 419k | return nLeft; |
858 | 419k | } |
859 | | |
860 | 301k | sal_uInt16 SvxTextLeftMarginItem::GetPropLeft() const { return m_nPropLeftMargin; } |
861 | | |
862 | | SvxIndentValue SvxLRSpaceItem::GetTextLeft() const |
863 | 38 | { |
864 | | // remove any negative first line offset from left margin to get text-left |
865 | 38 | if (m_stFirstLineOffset.m_dValue < 0.0) |
866 | 0 | { |
867 | 0 | return SvxIndentValue::twips(m_stLeftMargin.Resolve({}) - ResolveTextFirstLineOffset({})); |
868 | 0 | } |
869 | | |
870 | 38 | return m_stLeftMargin; |
871 | 38 | } |
872 | | |
873 | | sal_Int32 SvxLRSpaceItem::ResolveTextLeft(const SvxFontUnitMetrics& rMetrics) const |
874 | 7.15M | { |
875 | | // remove any negative first line offset from left margin to get text-left |
876 | 7.15M | if (m_stFirstLineOffset.m_dValue < 0.0) |
877 | 76.2k | { |
878 | 76.2k | return m_stLeftMargin.Resolve(rMetrics) - ResolveTextFirstLineOffset(rMetrics); |
879 | 76.2k | } |
880 | | |
881 | 7.07M | return m_stLeftMargin.Resolve(rMetrics); |
882 | 7.15M | } |
883 | | |
884 | | SvxLeftMarginItem::SvxLeftMarginItem(const sal_uInt16 nId) |
885 | 9 | : SfxPoolItem(nId) |
886 | 9 | { |
887 | 9 | } |
888 | | |
889 | | SvxLeftMarginItem::SvxLeftMarginItem(const tools::Long nLeft, const sal_uInt16 nId) |
890 | 0 | : SfxPoolItem(nId) |
891 | 0 | , m_nLeftMargin(nLeft) |
892 | 0 | { |
893 | 0 | } |
894 | | |
895 | | bool SvxLeftMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const |
896 | 0 | { |
897 | 0 | bool bRet = true; |
898 | 0 | bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
899 | 0 | nMemberId &= ~CONVERT_TWIPS; |
900 | 0 | switch (nMemberId) |
901 | 0 | { |
902 | 0 | case MID_L_MARGIN: |
903 | 0 | rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(m_nLeftMargin) : m_nLeftMargin); |
904 | 0 | break; |
905 | 0 | case MID_L_REL_MARGIN: |
906 | 0 | rVal <<= static_cast<sal_Int16>(m_nPropLeftMargin); |
907 | 0 | break; |
908 | 0 | default: |
909 | 0 | assert(false); |
910 | 0 | bRet = false; |
911 | | // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? |
912 | 0 | OSL_FAIL("unknown MemberId"); |
913 | 0 | } |
914 | 0 | return bRet; |
915 | 0 | } |
916 | | |
917 | | bool SvxLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) |
918 | 0 | { |
919 | 0 | bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
920 | 0 | nMemberId &= ~CONVERT_TWIPS; |
921 | |
|
922 | 0 | switch (nMemberId) |
923 | 0 | { |
924 | 0 | case MID_L_MARGIN: |
925 | 0 | { |
926 | 0 | sal_Int32 nVal = 0; |
927 | 0 | if (!(rVal >>= nVal)) |
928 | 0 | { |
929 | 0 | return false; |
930 | 0 | } |
931 | 0 | SetLeft(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); |
932 | 0 | break; |
933 | 0 | } |
934 | 0 | case MID_L_REL_MARGIN: |
935 | 0 | { |
936 | 0 | sal_Int32 nRel = 0; |
937 | 0 | if ((rVal >>= nRel) && nRel >= 0 && nRel < SAL_MAX_UINT16) |
938 | 0 | { |
939 | 0 | m_nPropLeftMargin = static_cast<sal_uInt16>(nRel); |
940 | 0 | } |
941 | 0 | else |
942 | 0 | { |
943 | 0 | return false; |
944 | 0 | } |
945 | 0 | } |
946 | 0 | break; |
947 | 0 | default: |
948 | 0 | assert(false); |
949 | 0 | OSL_FAIL("unknown MemberId"); |
950 | 0 | return false; |
951 | 0 | } |
952 | 0 | return true; |
953 | 0 | } |
954 | | |
955 | | bool SvxLeftMarginItem::operator==(const SfxPoolItem& rAttr) const |
956 | 0 | { |
957 | 0 | assert(SfxPoolItem::operator==(rAttr)); |
958 | |
|
959 | 0 | const SvxLeftMarginItem& rOther = static_cast<const SvxLeftMarginItem&>(rAttr); |
960 | |
|
961 | 0 | return (m_nLeftMargin == rOther.GetLeft() |
962 | 0 | && m_nPropLeftMargin == rOther.GetPropLeft()); |
963 | 0 | } |
964 | | |
965 | | SvxLeftMarginItem* SvxLeftMarginItem::Clone(SfxItemPool *) const |
966 | 0 | { |
967 | 0 | return new SvxLeftMarginItem(*this); |
968 | 0 | } |
969 | | |
970 | | bool SvxLeftMarginItem::GetPresentation |
971 | | ( |
972 | | SfxItemPresentation ePres, |
973 | | MapUnit eCoreUnit, |
974 | | MapUnit ePresUnit, |
975 | | OUString& rText, const IntlWrapper& rIntl |
976 | | ) const |
977 | 0 | { |
978 | 0 | switch (ePres) |
979 | 0 | { |
980 | 0 | case SfxItemPresentation::Nameless: |
981 | 0 | { |
982 | 0 | if (100 != m_nPropLeftMargin) |
983 | 0 | { |
984 | 0 | rText = unicode::formatPercent(m_nPropLeftMargin, |
985 | 0 | Application::GetSettings().GetUILanguageTag()); |
986 | 0 | } |
987 | 0 | else |
988 | 0 | { |
989 | 0 | rText = GetMetricText(m_nLeftMargin, |
990 | 0 | eCoreUnit, ePresUnit, &rIntl); |
991 | 0 | } |
992 | 0 | return true; |
993 | 0 | } |
994 | 0 | case SfxItemPresentation::Complete: |
995 | 0 | { |
996 | 0 | rText = EditResId(RID_SVXITEMS_LRSPACE_LEFT); |
997 | 0 | if (100 != m_nPropLeftMargin) |
998 | 0 | { |
999 | 0 | rText += unicode::formatPercent(m_nPropLeftMargin, |
1000 | 0 | Application::GetSettings().GetUILanguageTag()); |
1001 | 0 | } |
1002 | 0 | else |
1003 | 0 | { |
1004 | 0 | rText += GetMetricText(m_nLeftMargin, eCoreUnit, ePresUnit, &rIntl) |
1005 | 0 | + " " + EditResId(GetMetricId(ePresUnit)); |
1006 | 0 | } |
1007 | 0 | return true; |
1008 | 0 | } |
1009 | 0 | default: ; // prevent warning |
1010 | 0 | } |
1011 | 0 | return false; |
1012 | 0 | } |
1013 | | |
1014 | | void SvxLeftMarginItem::ScaleMetrics(double fScale) |
1015 | 0 | { |
1016 | 0 | m_nLeftMargin = BigInt::Scale(m_nLeftMargin, fScale); |
1017 | 0 | } |
1018 | | |
1019 | | bool SvxLeftMarginItem::HasMetrics() const |
1020 | 0 | { |
1021 | 0 | return true; |
1022 | 0 | } |
1023 | | |
1024 | | void SvxLeftMarginItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
1025 | 0 | { |
1026 | 0 | tools::XmlWriter aWriter(pWriter); |
1027 | 0 | aWriter.startElement("SvxLeftMarginItem"); |
1028 | 0 | aWriter.attribute("whichId", Which()); |
1029 | 0 | aWriter.attribute("m_nLeftMargin", m_nLeftMargin); |
1030 | 0 | aWriter.attribute("m_nPropLeftMargin", m_nPropLeftMargin); |
1031 | 0 | aWriter.endElement(); |
1032 | 0 | } |
1033 | | |
1034 | | boost::property_tree::ptree SvxLeftMarginItem::dumpAsJSON() const |
1035 | 0 | { |
1036 | 0 | boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); |
1037 | |
|
1038 | 0 | boost::property_tree::ptree aState; |
1039 | |
|
1040 | 0 | MapUnit eTargetUnit = MapUnit::MapInch; |
1041 | |
|
1042 | 0 | OUString sLeft = GetMetricText(GetLeft(), |
1043 | 0 | MapUnit::MapTwip, eTargetUnit, nullptr); |
1044 | |
|
1045 | 0 | aState.put("left", sLeft); |
1046 | 0 | aState.put("unit", "inch"); |
1047 | |
|
1048 | 0 | aTree.push_back(std::make_pair("state", aState)); |
1049 | |
|
1050 | 0 | return aTree; |
1051 | 0 | } |
1052 | | |
1053 | | SvxTextLeftMarginItem::SvxTextLeftMarginItem(const sal_uInt16 nId) |
1054 | 183M | : SfxPoolItem(nId) |
1055 | 183M | { |
1056 | 183M | } |
1057 | | |
1058 | | SvxTextLeftMarginItem::SvxTextLeftMarginItem(SvxIndentValue stLeft, const sal_uInt16 nId) |
1059 | 160k | : SfxPoolItem(nId) |
1060 | 160k | { |
1061 | 160k | SetTextLeft(stLeft); |
1062 | 160k | } |
1063 | | |
1064 | | bool SvxTextLeftMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const |
1065 | 306 | { |
1066 | 306 | bool bRet = false; |
1067 | 306 | bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
1068 | 306 | nMemberId &= ~CONVERT_TWIPS; |
1069 | 306 | switch (nMemberId) |
1070 | 306 | { |
1071 | | // tdf#154282 - return both values for the hardcoded 0 in SfxDispatchController_Impl::StateChanged |
1072 | 0 | case 0: |
1073 | 0 | { |
1074 | 0 | css::frame::status::LeftRightMarginScale aLRSpace; |
1075 | |
|
1076 | 0 | auto nLeftTwips = m_stTextLeftMargin.Resolve({}); |
1077 | 0 | aLRSpace.TextLeft |
1078 | 0 | = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nLeftTwips) : nLeftTwips); |
1079 | 0 | aLRSpace.ScaleLeft = static_cast<sal_Int16>(m_nPropLeftMargin); |
1080 | 0 | rVal <<= aLRSpace; |
1081 | 0 | bRet = true; |
1082 | 0 | break; |
1083 | 0 | } |
1084 | 153 | case MID_TXT_LMARGIN : |
1085 | 153 | bRet = lcl_FillAbsoluteMeasureAny(m_stTextLeftMargin, rVal, bConvert); |
1086 | 153 | break; |
1087 | 0 | case MID_L_REL_MARGIN: |
1088 | 0 | rVal <<= static_cast<sal_Int16>(m_nPropLeftMargin); |
1089 | 0 | bRet = true; |
1090 | 0 | break; |
1091 | 153 | case MID_L_UNIT_MARGIN: |
1092 | 153 | bRet = lcl_FillRelativeMeasureAny(m_stTextLeftMargin, rVal); |
1093 | 153 | break; |
1094 | 0 | default: |
1095 | 0 | assert(false); |
1096 | 0 | bRet = false; |
1097 | | // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? |
1098 | 0 | OSL_FAIL("unknown MemberId"); |
1099 | 306 | } |
1100 | 306 | return bRet; |
1101 | 306 | } |
1102 | | |
1103 | | bool SvxTextLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) |
1104 | 18.8k | { |
1105 | 18.8k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1106 | 18.8k | bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
1107 | 18.8k | nMemberId &= ~CONVERT_TWIPS; |
1108 | | |
1109 | 18.8k | switch (nMemberId) |
1110 | 18.8k | { |
1111 | 18.6k | case MID_TXT_LMARGIN: |
1112 | 18.6k | { |
1113 | 18.6k | sal_Int32 nVal = 0; |
1114 | 18.6k | if (!(rVal >>= nVal)) |
1115 | 0 | { |
1116 | 0 | return false; |
1117 | 0 | } |
1118 | 18.6k | SetTextLeft( |
1119 | 18.6k | SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); |
1120 | 18.6k | break; |
1121 | 18.6k | } |
1122 | 1 | case MID_L_REL_MARGIN: |
1123 | 1 | { |
1124 | 1 | sal_Int32 nRel = 0; |
1125 | 1 | if ((rVal >>= nRel) && nRel >= 0 && nRel < SAL_MAX_UINT16) |
1126 | 1 | { |
1127 | 1 | m_nPropLeftMargin = static_cast<sal_uInt16>(nRel); |
1128 | 1 | } |
1129 | 0 | else |
1130 | 0 | { |
1131 | 0 | return false; |
1132 | 0 | } |
1133 | 1 | break; |
1134 | 1 | } |
1135 | 197 | case MID_L_UNIT_MARGIN: |
1136 | 197 | { |
1137 | 197 | css::beans::Pair<double, sal_Int16> stVal; |
1138 | 197 | if (!(rVal >>= stVal)) |
1139 | 153 | { |
1140 | 153 | return false; |
1141 | 153 | } |
1142 | | |
1143 | 44 | SetTextLeft(SvxIndentValue{ stVal.First, stVal.Second }); |
1144 | 44 | break; |
1145 | 197 | } |
1146 | 0 | default: |
1147 | 0 | assert(false); |
1148 | 0 | OSL_FAIL("unknown MemberId"); |
1149 | 0 | return false; |
1150 | 18.8k | } |
1151 | 18.6k | return true; |
1152 | 18.8k | } |
1153 | | |
1154 | | bool SvxTextLeftMarginItem::operator==(const SfxPoolItem& rAttr) const |
1155 | 196M | { |
1156 | 196M | assert(SfxPoolItem::operator==(rAttr)); |
1157 | | |
1158 | 196M | const SvxTextLeftMarginItem& rOther = static_cast<const SvxTextLeftMarginItem&>(rAttr); |
1159 | | |
1160 | 196M | return std::tie(m_stTextLeftMargin, m_nPropLeftMargin) |
1161 | 196M | == std::tie(rOther.m_stTextLeftMargin, rOther.m_nPropLeftMargin); |
1162 | 196M | } |
1163 | | |
1164 | | size_t SvxTextLeftMarginItem::hashCode() const |
1165 | 562k | { |
1166 | 562k | std::size_t seed(0); |
1167 | 562k | o3tl::hash_combine(seed, m_stTextLeftMargin.hashCode()); |
1168 | 562k | o3tl::hash_combine(seed, m_nPropLeftMargin); |
1169 | 562k | return seed; |
1170 | 562k | } |
1171 | | |
1172 | | |
1173 | | SvxTextLeftMarginItem* SvxTextLeftMarginItem::Clone(SfxItemPool *) const |
1174 | 1.28M | { |
1175 | 1.28M | return new SvxTextLeftMarginItem(*this); |
1176 | 1.28M | } |
1177 | | |
1178 | | bool SvxTextLeftMarginItem::GetPresentation |
1179 | | ( |
1180 | | SfxItemPresentation ePres, |
1181 | | MapUnit eCoreUnit, |
1182 | | MapUnit ePresUnit, |
1183 | | OUString& rText, const IntlWrapper& rIntl |
1184 | | ) const |
1185 | 0 | { |
1186 | 0 | switch (ePres) |
1187 | 0 | { |
1188 | 0 | case SfxItemPresentation::Nameless: |
1189 | 0 | { |
1190 | 0 | if (100 != m_nPropLeftMargin) |
1191 | 0 | { |
1192 | 0 | rText = unicode::formatPercent(m_nPropLeftMargin, |
1193 | 0 | Application::GetSettings().GetUILanguageTag()); |
1194 | 0 | } |
1195 | 0 | else if (m_stTextLeftMargin.m_nUnit != css::util::MeasureUnit::TWIP) |
1196 | 0 | { |
1197 | 0 | OUStringBuffer stBuf; |
1198 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stTextLeftMargin.m_dValue, |
1199 | 0 | m_stTextLeftMargin.m_nUnit); |
1200 | 0 | rText += stBuf.makeStringAndClear(); |
1201 | 0 | } |
1202 | 0 | else |
1203 | 0 | { |
1204 | 0 | rText = GetMetricText(m_stTextLeftMargin.m_dValue, eCoreUnit, ePresUnit, &rIntl); |
1205 | 0 | } |
1206 | 0 | return true; |
1207 | 0 | } |
1208 | 0 | case SfxItemPresentation::Complete: |
1209 | 0 | { |
1210 | 0 | rText = EditResId(RID_SVXITEMS_LRSPACE_LEFT); |
1211 | 0 | if (100 != m_nPropLeftMargin) |
1212 | 0 | { |
1213 | 0 | rText += unicode::formatPercent(m_nPropLeftMargin, |
1214 | 0 | Application::GetSettings().GetUILanguageTag()); |
1215 | 0 | } |
1216 | 0 | else if (m_stTextLeftMargin.m_nUnit != css::util::MeasureUnit::TWIP) |
1217 | 0 | { |
1218 | 0 | OUStringBuffer stBuf; |
1219 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stTextLeftMargin.m_dValue, |
1220 | 0 | m_stTextLeftMargin.m_nUnit); |
1221 | 0 | rText += stBuf.makeStringAndClear(); |
1222 | 0 | } |
1223 | 0 | else |
1224 | 0 | { |
1225 | 0 | rText += GetMetricText(m_stTextLeftMargin.m_dValue, eCoreUnit, ePresUnit, &rIntl) |
1226 | 0 | + " " + EditResId(GetMetricId(ePresUnit)); |
1227 | 0 | } |
1228 | 0 | return true; |
1229 | 0 | } |
1230 | 0 | default: ; // prevent warning |
1231 | 0 | } |
1232 | 0 | return false; |
1233 | 0 | } |
1234 | | |
1235 | | void SvxTextLeftMarginItem::ScaleMetrics(double fScale) |
1236 | 0 | { |
1237 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1238 | 0 | m_stTextLeftMargin.ScaleMetrics(fScale); |
1239 | 0 | } |
1240 | | |
1241 | | bool SvxTextLeftMarginItem::HasMetrics() const |
1242 | 0 | { |
1243 | 0 | return true; |
1244 | 0 | } |
1245 | | |
1246 | | void SvxTextLeftMarginItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
1247 | 0 | { |
1248 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxTextLeftMarginItem")); |
1249 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
1250 | 0 | (void)xmlTextWriterWriteAttribute( |
1251 | 0 | pWriter, BAD_CAST("m_dTextLeftMargin"), |
1252 | 0 | BAD_CAST(OString::number(m_stTextLeftMargin.m_dValue).getStr())); |
1253 | 0 | (void)xmlTextWriterWriteAttribute( |
1254 | 0 | pWriter, BAD_CAST("m_nUnit"), |
1255 | 0 | BAD_CAST(OString::number(m_stTextLeftMargin.m_nUnit).getStr())); |
1256 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nPropLeftMargin"), BAD_CAST(OString::number(m_nPropLeftMargin).getStr())); |
1257 | 0 | (void)xmlTextWriterEndElement(pWriter); |
1258 | 0 | } |
1259 | | |
1260 | | boost::property_tree::ptree SvxTextLeftMarginItem::dumpAsJSON() const |
1261 | 0 | { |
1262 | 0 | boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); |
1263 | |
|
1264 | 0 | auto aState = lcl_IndentValueToJson("left", m_stTextLeftMargin); |
1265 | 0 | aTree.push_back(std::make_pair("state", aState)); |
1266 | |
|
1267 | 0 | return aTree; |
1268 | 0 | } |
1269 | | |
1270 | | SvxFirstLineIndentItem::SvxFirstLineIndentItem(const sal_uInt16 nId) |
1271 | 183M | : SfxPoolItem(nId) |
1272 | 183M | { |
1273 | 183M | } |
1274 | | |
1275 | | SvxFirstLineIndentItem::SvxFirstLineIndentItem(SvxIndentValue stValue, const sal_uInt16 nId) |
1276 | 139k | : SvxFirstLineIndentItem(nId) |
1277 | 139k | { |
1278 | 139k | SetTextFirstLineOffset(stValue); |
1279 | 139k | } |
1280 | | |
1281 | 493k | bool SvxFirstLineIndentItem::IsAutoFirst() const { return m_bAutoFirst; } |
1282 | | |
1283 | | void SvxFirstLineIndentItem::SetAutoFirst(bool bNew) |
1284 | 301k | { |
1285 | 301k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1286 | 301k | m_bAutoFirst = bNew; |
1287 | 301k | } |
1288 | | |
1289 | | void SvxFirstLineIndentItem::SetPropTextFirstLineOffset(sal_uInt16 nProp) |
1290 | 0 | { |
1291 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1292 | 0 | m_nPropFirstLineOffset = nProp; |
1293 | 0 | } |
1294 | | |
1295 | | sal_uInt16 SvxFirstLineIndentItem::GetPropTextFirstLineOffset() const |
1296 | 300k | { |
1297 | 300k | return m_nPropFirstLineOffset; |
1298 | 300k | } |
1299 | | |
1300 | | void SvxFirstLineIndentItem::SetTextFirstLineOffset(SvxIndentValue stValue, sal_uInt16 nProp) |
1301 | 754k | { |
1302 | 754k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1303 | 754k | m_stFirstLineOffset = stValue; |
1304 | 754k | m_nPropFirstLineOffset = nProp; |
1305 | | |
1306 | 754k | if (nProp != 100) |
1307 | 0 | { |
1308 | 0 | m_stFirstLineOffset.m_dValue = (stValue.m_dValue * static_cast<double>(nProp)) / 100.0; |
1309 | 0 | } |
1310 | 754k | } |
1311 | | |
1312 | | const SvxIndentValue & SvxFirstLineIndentItem::GetTextFirstLineOffset() const |
1313 | 2.40M | { |
1314 | 2.40M | return m_stFirstLineOffset; |
1315 | 2.40M | } |
1316 | | |
1317 | | sal_Int32 |
1318 | | SvxFirstLineIndentItem::ResolveTextFirstLineOffset(const SvxFontUnitMetrics& rMetrics) const |
1319 | 860k | { |
1320 | 860k | return m_stFirstLineOffset.Resolve(rMetrics); |
1321 | 860k | } |
1322 | | |
1323 | | bool SvxFirstLineIndentItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const |
1324 | 180 | { |
1325 | 180 | bool bRet = false; |
1326 | 180 | bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
1327 | 180 | nMemberId &= ~CONVERT_TWIPS; |
1328 | 180 | switch (nMemberId) |
1329 | 180 | { |
1330 | 60 | case MID_FIRST_LINE_INDENT: |
1331 | 60 | bRet = lcl_FillAbsoluteMeasureAny(m_stFirstLineOffset, rVal, bConvert); |
1332 | 60 | break; |
1333 | | |
1334 | 0 | case MID_FIRST_LINE_REL_INDENT: |
1335 | 0 | rVal <<= static_cast<sal_Int16>(m_nPropFirstLineOffset); |
1336 | 0 | bRet = true; |
1337 | 0 | break; |
1338 | | |
1339 | 60 | case MID_FIRST_LINE_UNIT_INDENT: |
1340 | 60 | bRet = lcl_FillRelativeMeasureAny(m_stFirstLineOffset, rVal); |
1341 | 60 | break; |
1342 | | |
1343 | 60 | case MID_FIRST_AUTO: |
1344 | 60 | rVal <<= IsAutoFirst(); |
1345 | 60 | bRet = true; |
1346 | 60 | break; |
1347 | | |
1348 | 0 | default: |
1349 | 0 | assert(false); |
1350 | 0 | bRet = false; |
1351 | | // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? |
1352 | 0 | OSL_FAIL("unknown MemberId"); |
1353 | 180 | } |
1354 | 180 | return bRet; |
1355 | 180 | } |
1356 | | |
1357 | | bool SvxFirstLineIndentItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) |
1358 | 20.0k | { |
1359 | 20.0k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1360 | 20.0k | bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
1361 | 20.0k | nMemberId &= ~CONVERT_TWIPS; |
1362 | | |
1363 | 20.0k | switch (nMemberId) |
1364 | 20.0k | { |
1365 | 18.3k | case MID_FIRST_LINE_INDENT: |
1366 | 18.3k | { |
1367 | 18.3k | sal_Int32 nVal = 0; |
1368 | 18.3k | if (!(rVal >>= nVal)) |
1369 | 0 | { |
1370 | 0 | return false; |
1371 | 0 | } |
1372 | | |
1373 | 18.3k | m_stFirstLineOffset |
1374 | 18.3k | = SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); |
1375 | 18.3k | m_nPropFirstLineOffset = 100; |
1376 | 18.3k | break; |
1377 | 18.3k | } |
1378 | 0 | case MID_FIRST_LINE_REL_INDENT: |
1379 | 0 | { |
1380 | 0 | sal_Int32 nRel = 0; |
1381 | 0 | if ((rVal >>= nRel) && nRel >= 0 && nRel < SAL_MAX_UINT16) |
1382 | 0 | { |
1383 | 0 | SetPropTextFirstLineOffset(nRel); |
1384 | 0 | } |
1385 | 0 | else |
1386 | 0 | { |
1387 | 0 | return false; |
1388 | 0 | } |
1389 | 0 | break; |
1390 | 0 | } |
1391 | 60 | case MID_FIRST_LINE_UNIT_INDENT: |
1392 | 60 | { |
1393 | 60 | css::beans::Pair<double, sal_Int16> stVal; |
1394 | 60 | if (!(rVal >>= stVal)) |
1395 | 60 | { |
1396 | 60 | return false; |
1397 | 60 | } |
1398 | | |
1399 | 0 | SetTextFirstLineOffset(SvxIndentValue{ stVal.First, stVal.Second }); |
1400 | 0 | break; |
1401 | 60 | } |
1402 | 1.59k | case MID_FIRST_AUTO: |
1403 | 1.59k | SetAutoFirst(Any2Bool(rVal)); |
1404 | 1.59k | break; |
1405 | 0 | default: |
1406 | 0 | assert(false); |
1407 | 0 | OSL_FAIL("unknown MemberId"); |
1408 | 0 | return false; |
1409 | 20.0k | } |
1410 | 19.9k | return true; |
1411 | 20.0k | } |
1412 | | |
1413 | | bool SvxFirstLineIndentItem::operator==(const SfxPoolItem& rAttr) const |
1414 | 1.24M | { |
1415 | 1.24M | assert(SfxPoolItem::operator==(rAttr)); |
1416 | | |
1417 | 1.24M | const SvxFirstLineIndentItem& rOther = static_cast<const SvxFirstLineIndentItem&>(rAttr); |
1418 | | |
1419 | 1.24M | return std::tie(m_stFirstLineOffset, m_nPropFirstLineOffset, m_bAutoFirst) |
1420 | 1.24M | == std::tie(rOther.m_stFirstLineOffset, rOther.m_nPropFirstLineOffset, |
1421 | 1.24M | rOther.m_bAutoFirst); |
1422 | 1.24M | } |
1423 | | |
1424 | | size_t SvxFirstLineIndentItem::hashCode() const |
1425 | 158k | { |
1426 | 158k | std::size_t seed(0); |
1427 | 158k | o3tl::hash_combine(seed, m_stFirstLineOffset.hashCode()); |
1428 | 158k | o3tl::hash_combine(seed, m_nPropFirstLineOffset); |
1429 | 158k | o3tl::hash_combine(seed, m_bAutoFirst); |
1430 | 158k | return seed; |
1431 | 158k | } |
1432 | | |
1433 | | SvxFirstLineIndentItem* SvxFirstLineIndentItem::Clone(SfxItemPool *) const |
1434 | 1.05M | { |
1435 | 1.05M | return new SvxFirstLineIndentItem(*this); |
1436 | 1.05M | } |
1437 | | |
1438 | | bool SvxFirstLineIndentItem::GetPresentation |
1439 | | ( |
1440 | | SfxItemPresentation ePres, |
1441 | | MapUnit eCoreUnit, |
1442 | | MapUnit ePresUnit, |
1443 | | OUString& rText, const IntlWrapper& rIntl |
1444 | | ) const |
1445 | 0 | { |
1446 | 0 | switch (ePres) |
1447 | 0 | { |
1448 | 0 | case SfxItemPresentation::Nameless: |
1449 | 0 | { |
1450 | 0 | if (100 != m_nPropFirstLineOffset) |
1451 | 0 | { |
1452 | 0 | rText += unicode::formatPercent(m_nPropFirstLineOffset, |
1453 | 0 | Application::GetSettings().GetUILanguageTag()); |
1454 | 0 | } |
1455 | 0 | else if (m_stFirstLineOffset.m_nUnit != css::util::MeasureUnit::TWIP) |
1456 | 0 | { |
1457 | 0 | OUStringBuffer stBuf; |
1458 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stFirstLineOffset.m_dValue, |
1459 | 0 | m_stFirstLineOffset.m_nUnit); |
1460 | 0 | rText += stBuf.makeStringAndClear(); |
1461 | 0 | } |
1462 | 0 | else |
1463 | 0 | { |
1464 | 0 | rText += GetMetricText(m_stFirstLineOffset.m_dValue, eCoreUnit, ePresUnit, &rIntl); |
1465 | 0 | } |
1466 | 0 | return true; |
1467 | 0 | } |
1468 | 0 | case SfxItemPresentation::Complete: |
1469 | 0 | { |
1470 | 0 | rText += EditResId(RID_SVXITEMS_LRSPACE_FLINE); |
1471 | 0 | if (100 != m_nPropFirstLineOffset) |
1472 | 0 | { |
1473 | 0 | rText += unicode::formatPercent(m_nPropFirstLineOffset, |
1474 | 0 | Application::GetSettings().GetUILanguageTag()); |
1475 | 0 | } |
1476 | 0 | else if (m_stFirstLineOffset.m_nUnit != css::util::MeasureUnit::TWIP) |
1477 | 0 | { |
1478 | 0 | OUStringBuffer stBuf; |
1479 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stFirstLineOffset.m_dValue, |
1480 | 0 | m_stFirstLineOffset.m_nUnit); |
1481 | 0 | rText += stBuf.makeStringAndClear(); |
1482 | 0 | } |
1483 | 0 | else |
1484 | 0 | { |
1485 | 0 | rText += GetMetricText(m_stFirstLineOffset.m_dValue, eCoreUnit, ePresUnit, &rIntl) |
1486 | 0 | + " " + EditResId(GetMetricId(ePresUnit)); |
1487 | 0 | } |
1488 | 0 | return true; |
1489 | 0 | } |
1490 | 0 | default: ; // prevent warning |
1491 | 0 | } |
1492 | 0 | return false; |
1493 | 0 | } |
1494 | | |
1495 | | void SvxFirstLineIndentItem::ScaleMetrics(double fScale) |
1496 | 0 | { |
1497 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1498 | 0 | m_stFirstLineOffset.ScaleMetrics(fScale); |
1499 | 0 | } |
1500 | | |
1501 | | bool SvxFirstLineIndentItem::HasMetrics() const |
1502 | 0 | { |
1503 | 0 | return true; |
1504 | 0 | } |
1505 | | |
1506 | | void SvxFirstLineIndentItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
1507 | 0 | { |
1508 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxFirstLineIndentItem")); |
1509 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
1510 | 0 | (void)xmlTextWriterWriteAttribute( |
1511 | 0 | pWriter, BAD_CAST("m_dFirstLineOffset"), |
1512 | 0 | BAD_CAST(OString::number(m_stFirstLineOffset.m_dValue).getStr())); |
1513 | 0 | (void)xmlTextWriterWriteAttribute( |
1514 | 0 | pWriter, BAD_CAST("m_nUnit"), |
1515 | 0 | BAD_CAST(OString::number(m_stFirstLineOffset.m_nUnit).getStr())); |
1516 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nPropFirstLineOffset"), BAD_CAST(OString::number(m_nPropFirstLineOffset).getStr())); |
1517 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_bAutoFirst"), BAD_CAST(OString::number(int(m_bAutoFirst)).getStr())); |
1518 | 0 | (void)xmlTextWriterEndElement(pWriter); |
1519 | 0 | } |
1520 | | |
1521 | | boost::property_tree::ptree SvxFirstLineIndentItem::dumpAsJSON() const |
1522 | 0 | { |
1523 | 0 | boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); |
1524 | |
|
1525 | 0 | auto aState = lcl_IndentValueToJson("firstline", m_stFirstLineOffset); |
1526 | |
|
1527 | 0 | aTree.push_back(std::make_pair("state", aState)); |
1528 | |
|
1529 | 0 | return aTree; |
1530 | 0 | } |
1531 | | |
1532 | | SvxRightMarginItem::SvxRightMarginItem(const sal_uInt16 nId) |
1533 | 182M | : SfxPoolItem(nId) |
1534 | 182M | { |
1535 | 182M | } |
1536 | | |
1537 | | SvxRightMarginItem::SvxRightMarginItem(SvxIndentValue stRight, const sal_uInt16 nId) |
1538 | 146k | : SfxPoolItem(nId) |
1539 | 146k | { |
1540 | 146k | SetRight(stRight); |
1541 | 146k | } |
1542 | | |
1543 | | bool SvxRightMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const |
1544 | 16 | { |
1545 | 16 | bool bRet = false; |
1546 | 16 | bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
1547 | 16 | nMemberId &= ~CONVERT_TWIPS; |
1548 | 16 | switch (nMemberId) |
1549 | 16 | { |
1550 | | // tdf#154282 - return both values for the hardcoded 0 in SfxDispatchController_Impl::StateChanged |
1551 | 0 | case 0: |
1552 | 0 | { |
1553 | 0 | css::frame::status::LeftRightMarginScale aLRSpace; |
1554 | |
|
1555 | 0 | auto nRightTwips = ResolveRight({}); |
1556 | 0 | aLRSpace.Right |
1557 | 0 | = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nRightTwips) : nRightTwips); |
1558 | 0 | aLRSpace.ScaleRight = static_cast<sal_Int16>(m_nPropRightMargin); |
1559 | 0 | rVal <<= aLRSpace; |
1560 | 0 | bRet = true; |
1561 | 0 | break; |
1562 | 0 | } |
1563 | 8 | case MID_R_MARGIN: |
1564 | 8 | bRet = lcl_FillAbsoluteMeasureAny(m_stRightMargin, rVal, bConvert); |
1565 | 8 | break; |
1566 | 0 | case MID_R_REL_MARGIN: |
1567 | 0 | rVal <<= static_cast<sal_Int16>(m_nPropRightMargin); |
1568 | 0 | bRet = true; |
1569 | 0 | break; |
1570 | 8 | case MID_R_UNIT_MARGIN: |
1571 | 8 | bRet = lcl_FillRelativeMeasureAny(m_stRightMargin, rVal); |
1572 | 8 | break; |
1573 | 0 | default: |
1574 | 0 | assert(false); |
1575 | 0 | bRet = false; |
1576 | | // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? |
1577 | 0 | OSL_FAIL("unknown MemberId"); |
1578 | 16 | } |
1579 | 16 | return bRet; |
1580 | 16 | } |
1581 | | |
1582 | | bool SvxRightMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) |
1583 | 15.3k | { |
1584 | 15.3k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1585 | 15.3k | bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
1586 | 15.3k | nMemberId &= ~CONVERT_TWIPS; |
1587 | | |
1588 | 15.3k | switch (nMemberId) |
1589 | 15.3k | { |
1590 | 15.0k | case MID_R_MARGIN: |
1591 | 15.0k | { |
1592 | 15.0k | sal_Int32 nVal = 0; |
1593 | 15.0k | if (!(rVal >>= nVal)) |
1594 | 0 | { |
1595 | 0 | return false; |
1596 | 0 | } |
1597 | 15.0k | SetRight( |
1598 | 15.0k | SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); |
1599 | 15.0k | break; |
1600 | 15.0k | } |
1601 | 0 | case MID_R_REL_MARGIN: |
1602 | 0 | { |
1603 | 0 | sal_Int32 nRel = 0; |
1604 | 0 | if ((rVal >>= nRel) && nRel >= 0 && nRel < SAL_MAX_UINT16) |
1605 | 0 | { |
1606 | 0 | m_nPropRightMargin = static_cast<sal_uInt16>(nRel); |
1607 | 0 | } |
1608 | 0 | else |
1609 | 0 | { |
1610 | 0 | return false; |
1611 | 0 | } |
1612 | 0 | break; |
1613 | 0 | } |
1614 | 272 | case MID_R_UNIT_MARGIN: |
1615 | 272 | { |
1616 | 272 | css::beans::Pair<double, sal_Int16> stVal; |
1617 | 272 | if (!(rVal >>= stVal)) |
1618 | 8 | { |
1619 | 8 | return false; |
1620 | 8 | } |
1621 | | |
1622 | 264 | SetRight(SvxIndentValue{ stVal.First, stVal.Second }); |
1623 | 264 | break; |
1624 | 272 | } |
1625 | 0 | default: |
1626 | 0 | assert(false); |
1627 | 0 | OSL_FAIL("unknown MemberId"); |
1628 | 0 | return false; |
1629 | 15.3k | } |
1630 | 15.3k | return true; |
1631 | 15.3k | } |
1632 | | |
1633 | | bool SvxRightMarginItem::operator==(const SfxPoolItem& rAttr) const |
1634 | 2.49M | { |
1635 | 2.49M | assert(SfxPoolItem::operator==(rAttr)); |
1636 | | |
1637 | 2.49M | const SvxRightMarginItem& rOther = static_cast<const SvxRightMarginItem&>(rAttr); |
1638 | | |
1639 | 2.49M | return std::tie(m_stRightMargin, m_nPropRightMargin) |
1640 | 2.49M | == std::tie(rOther.m_stRightMargin, rOther.m_nPropRightMargin); |
1641 | 2.49M | } |
1642 | | |
1643 | | size_t SvxRightMarginItem::hashCode() const |
1644 | 251k | { |
1645 | 251k | std::size_t seed(0); |
1646 | 251k | o3tl::hash_combine(seed, m_stRightMargin.hashCode()); |
1647 | 251k | o3tl::hash_combine(seed, m_nPropRightMargin); |
1648 | 251k | return seed; |
1649 | 251k | } |
1650 | | |
1651 | | SvxRightMarginItem* SvxRightMarginItem::Clone(SfxItemPool *) const |
1652 | 1.21M | { |
1653 | 1.21M | return new SvxRightMarginItem(*this); |
1654 | 1.21M | } |
1655 | | |
1656 | | bool SvxRightMarginItem::GetPresentation |
1657 | | ( |
1658 | | SfxItemPresentation ePres, |
1659 | | MapUnit eCoreUnit, |
1660 | | MapUnit ePresUnit, |
1661 | | OUString& rText, const IntlWrapper& rIntl |
1662 | | ) const |
1663 | 0 | { |
1664 | 0 | switch (ePres) |
1665 | 0 | { |
1666 | 0 | case SfxItemPresentation::Nameless: |
1667 | 0 | { |
1668 | 0 | if (100 != m_nPropRightMargin) |
1669 | 0 | { |
1670 | 0 | rText += unicode::formatPercent(m_nPropRightMargin, |
1671 | 0 | Application::GetSettings().GetUILanguageTag()); |
1672 | 0 | } |
1673 | 0 | else if (m_stRightMargin.m_nUnit != css::util::MeasureUnit::TWIP) |
1674 | 0 | { |
1675 | 0 | OUStringBuffer stBuf; |
1676 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stRightMargin.m_dValue, |
1677 | 0 | m_stRightMargin.m_nUnit); |
1678 | 0 | rText += stBuf.makeStringAndClear(); |
1679 | 0 | } |
1680 | 0 | else |
1681 | 0 | { |
1682 | 0 | rText += GetMetricText(m_stRightMargin.m_dValue, eCoreUnit, ePresUnit, &rIntl); |
1683 | 0 | } |
1684 | 0 | return true; |
1685 | 0 | } |
1686 | 0 | case SfxItemPresentation::Complete: |
1687 | 0 | { |
1688 | 0 | rText += EditResId(RID_SVXITEMS_LRSPACE_RIGHT); |
1689 | 0 | if (100 != m_nPropRightMargin) |
1690 | 0 | { |
1691 | 0 | rText += unicode::formatPercent(m_nPropRightMargin, |
1692 | 0 | Application::GetSettings().GetUILanguageTag()); |
1693 | 0 | } |
1694 | 0 | else if (m_stRightMargin.m_nUnit != css::util::MeasureUnit::TWIP) |
1695 | 0 | { |
1696 | 0 | OUStringBuffer stBuf; |
1697 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stRightMargin.m_dValue, |
1698 | 0 | m_stRightMargin.m_nUnit); |
1699 | 0 | rText += stBuf.makeStringAndClear(); |
1700 | 0 | } |
1701 | 0 | else |
1702 | 0 | { |
1703 | 0 | rText += GetMetricText(m_stRightMargin.m_dValue, eCoreUnit, ePresUnit, &rIntl) + " " |
1704 | 0 | + EditResId(GetMetricId(ePresUnit)); |
1705 | 0 | } |
1706 | 0 | return true; |
1707 | 0 | } |
1708 | 0 | default: ; // prevent warning |
1709 | 0 | } |
1710 | 0 | return false; |
1711 | 0 | } |
1712 | | |
1713 | | void SvxRightMarginItem::ScaleMetrics(double fScale) |
1714 | 0 | { |
1715 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1716 | 0 | m_stRightMargin.ScaleMetrics(fScale); |
1717 | 0 | } |
1718 | | |
1719 | | bool SvxRightMarginItem::HasMetrics() const |
1720 | 0 | { |
1721 | 0 | return true; |
1722 | 0 | } |
1723 | | |
1724 | | void SvxRightMarginItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
1725 | 0 | { |
1726 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxRightMarginItem")); |
1727 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
1728 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_dRightMargin"), |
1729 | 0 | BAD_CAST(OString::number(m_stRightMargin.m_dValue).getStr())); |
1730 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nUnit"), |
1731 | 0 | BAD_CAST(OString::number(m_stRightMargin.m_nUnit).getStr())); |
1732 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nPropRightMargin"), BAD_CAST(OString::number(m_nPropRightMargin).getStr())); |
1733 | 0 | (void)xmlTextWriterEndElement(pWriter); |
1734 | 0 | } |
1735 | | |
1736 | | boost::property_tree::ptree SvxRightMarginItem::dumpAsJSON() const |
1737 | 0 | { |
1738 | 0 | boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); |
1739 | |
|
1740 | 0 | auto aState = lcl_IndentValueToJson("right", m_stRightMargin); |
1741 | 0 | aTree.push_back(std::make_pair("state", aState)); |
1742 | |
|
1743 | 0 | return aTree; |
1744 | 0 | } |
1745 | | |
1746 | | SvxGutterLeftMarginItem::SvxGutterLeftMarginItem(const sal_uInt16 nId) |
1747 | 9 | : SfxPoolItem(nId) |
1748 | 9 | { |
1749 | 9 | } |
1750 | | |
1751 | | bool SvxGutterLeftMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const |
1752 | 0 | { |
1753 | 0 | bool bRet = true; |
1754 | 0 | bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
1755 | 0 | nMemberId &= ~CONVERT_TWIPS; |
1756 | 0 | switch (nMemberId) |
1757 | 0 | { |
1758 | 0 | case MID_GUTTER_MARGIN: |
1759 | 0 | rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(m_nGutterMargin) |
1760 | 0 | : m_nGutterMargin); |
1761 | 0 | break; |
1762 | 0 | default: |
1763 | 0 | assert(false); |
1764 | 0 | bRet = false; |
1765 | | // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? |
1766 | 0 | OSL_FAIL("unknown MemberId"); |
1767 | 0 | } |
1768 | 0 | return bRet; |
1769 | 0 | } |
1770 | | |
1771 | | bool SvxGutterLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) |
1772 | 0 | { |
1773 | 0 | bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
1774 | 0 | nMemberId &= ~CONVERT_TWIPS; |
1775 | |
|
1776 | 0 | switch (nMemberId) |
1777 | 0 | { |
1778 | 0 | case MID_GUTTER_MARGIN: |
1779 | 0 | { |
1780 | 0 | sal_Int32 nVal = 0; |
1781 | 0 | if (!(rVal >>= nVal)) |
1782 | 0 | { |
1783 | 0 | return false; |
1784 | 0 | } |
1785 | 0 | SetGutterMargin(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); |
1786 | 0 | break; |
1787 | 0 | } |
1788 | 0 | default: |
1789 | 0 | assert(false); |
1790 | 0 | OSL_FAIL("unknown MemberId"); |
1791 | 0 | return false; |
1792 | 0 | } |
1793 | 0 | return true; |
1794 | 0 | } |
1795 | | |
1796 | | bool SvxGutterLeftMarginItem::operator==(const SfxPoolItem& rAttr) const |
1797 | 0 | { |
1798 | 0 | assert(SfxPoolItem::operator==(rAttr)); |
1799 | |
|
1800 | 0 | const SvxGutterLeftMarginItem& rOther = static_cast<const SvxGutterLeftMarginItem&>(rAttr); |
1801 | |
|
1802 | 0 | return (m_nGutterMargin == rOther.GetGutterMargin()); |
1803 | 0 | } |
1804 | | |
1805 | | SvxGutterLeftMarginItem* SvxGutterLeftMarginItem::Clone(SfxItemPool * ) const |
1806 | 0 | { |
1807 | 0 | return new SvxGutterLeftMarginItem(*this); |
1808 | 0 | } |
1809 | | |
1810 | | bool SvxGutterLeftMarginItem::GetPresentation |
1811 | | ( |
1812 | | SfxItemPresentation /*ePres*/, |
1813 | | MapUnit /*eCoreUnit*/, |
1814 | | MapUnit /*ePresUnit*/, |
1815 | | OUString& /*rText*/, const IntlWrapper& /*rIntl*/ |
1816 | | ) const |
1817 | 0 | { |
1818 | | // TODO? |
1819 | 0 | return false; |
1820 | 0 | } |
1821 | | |
1822 | | void SvxGutterLeftMarginItem::ScaleMetrics(double /*fScale*/) |
1823 | 0 | { |
1824 | | // TODO? |
1825 | 0 | } |
1826 | | |
1827 | | bool SvxGutterLeftMarginItem::HasMetrics() const |
1828 | 0 | { |
1829 | 0 | return true; |
1830 | 0 | } |
1831 | | |
1832 | | void SvxGutterLeftMarginItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
1833 | 0 | { |
1834 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxGutterLeftMarginItem")); |
1835 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
1836 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nGutterMargin"), |
1837 | 0 | BAD_CAST(OString::number(m_nGutterMargin).getStr())); |
1838 | 0 | (void)xmlTextWriterEndElement(pWriter); |
1839 | 0 | } |
1840 | | |
1841 | | boost::property_tree::ptree SvxGutterLeftMarginItem::dumpAsJSON() const |
1842 | 0 | { |
1843 | 0 | boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); |
1844 | |
|
1845 | 0 | boost::property_tree::ptree aState; |
1846 | | |
1847 | | // TODO? |
1848 | 0 | aState.put("unit", "inch"); |
1849 | |
|
1850 | 0 | aTree.push_back(std::make_pair("state", aState)); |
1851 | |
|
1852 | 0 | return aTree; |
1853 | 0 | } |
1854 | | |
1855 | | SvxGutterRightMarginItem::SvxGutterRightMarginItem(const sal_uInt16 nId) |
1856 | 9 | : SfxPoolItem(nId) |
1857 | 9 | { |
1858 | 9 | } |
1859 | | |
1860 | | bool SvxGutterRightMarginItem::QueryValue(uno::Any& /*rVal*/, sal_uInt8 nMemberId) const |
1861 | 0 | { |
1862 | 0 | bool bRet = true; |
1863 | | //bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
1864 | 0 | nMemberId &= ~CONVERT_TWIPS; |
1865 | 0 | #ifndef _MSC_VER |
1866 | 0 | switch (nMemberId) |
1867 | 0 | { |
1868 | | // TODO? |
1869 | 0 | default: |
1870 | 0 | assert(false); |
1871 | 0 | bRet = false; |
1872 | | // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? |
1873 | 0 | OSL_FAIL("unknown MemberId"); |
1874 | 0 | } |
1875 | | #else |
1876 | | (void) nMemberId; |
1877 | | #endif |
1878 | 0 | return bRet; |
1879 | 0 | } |
1880 | | |
1881 | | bool SvxGutterRightMarginItem::PutValue(const uno::Any& /*rVal*/, sal_uInt8 nMemberId) |
1882 | 0 | { |
1883 | | //bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
1884 | 0 | nMemberId &= ~CONVERT_TWIPS; |
1885 | |
|
1886 | 0 | #ifndef _MSC_VER |
1887 | 0 | switch (nMemberId) |
1888 | 0 | { |
1889 | | // TODO? |
1890 | 0 | default: |
1891 | 0 | assert(false); |
1892 | 0 | OSL_FAIL("unknown MemberId"); |
1893 | 0 | return false; |
1894 | 0 | } |
1895 | | #else |
1896 | | (void) nMemberId; |
1897 | | #endif |
1898 | 0 | return true; |
1899 | 0 | } |
1900 | | |
1901 | | |
1902 | | bool SvxGutterRightMarginItem::operator==(const SfxPoolItem& rAttr) const |
1903 | 0 | { |
1904 | 0 | assert(SfxPoolItem::operator==(rAttr)); |
1905 | |
|
1906 | 0 | const SvxGutterRightMarginItem& rOther = static_cast<const SvxGutterRightMarginItem&>(rAttr); |
1907 | |
|
1908 | 0 | return (m_nRightGutterMargin == rOther.GetRightGutterMargin()); |
1909 | 0 | } |
1910 | | |
1911 | | SvxGutterRightMarginItem* SvxGutterRightMarginItem::Clone(SfxItemPool *) const |
1912 | 0 | { |
1913 | 0 | return new SvxGutterRightMarginItem(*this); |
1914 | 0 | } |
1915 | | |
1916 | | bool SvxGutterRightMarginItem::GetPresentation |
1917 | | ( |
1918 | | SfxItemPresentation /*ePres*/, |
1919 | | MapUnit /*eCoreUnit*/, |
1920 | | MapUnit /*ePresUnit*/, |
1921 | | OUString& /*rText*/, const IntlWrapper& /*rIntl*/ |
1922 | | ) const |
1923 | 0 | { |
1924 | | // TODO? |
1925 | 0 | return false; |
1926 | 0 | } |
1927 | | |
1928 | | void SvxGutterRightMarginItem::ScaleMetrics(double /*fScale*/) |
1929 | 0 | { |
1930 | | // TODO? |
1931 | 0 | } |
1932 | | |
1933 | | bool SvxGutterRightMarginItem::HasMetrics() const |
1934 | 0 | { |
1935 | 0 | return true; |
1936 | 0 | } |
1937 | | |
1938 | | void SvxGutterRightMarginItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
1939 | 0 | { |
1940 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxGutterRightMarginItem")); |
1941 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
1942 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nRightGutterMargin"), |
1943 | 0 | BAD_CAST(OString::number(m_nRightGutterMargin).getStr())); |
1944 | 0 | (void)xmlTextWriterEndElement(pWriter); |
1945 | 0 | } |
1946 | | |
1947 | | boost::property_tree::ptree SvxGutterRightMarginItem::dumpAsJSON() const |
1948 | 0 | { |
1949 | 0 | boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); |
1950 | |
|
1951 | 0 | boost::property_tree::ptree aState; |
1952 | | |
1953 | | // TODO? |
1954 | 0 | aState.put("unit", "inch"); |
1955 | |
|
1956 | 0 | aTree.push_back(std::make_pair("state", aState)); |
1957 | |
|
1958 | 0 | return aTree; |
1959 | 0 | } |
1960 | | |
1961 | | |
1962 | | bool SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const |
1963 | 3.66M | { |
1964 | 3.66M | assert(SfxPoolItem::operator==(rAttr)); |
1965 | | |
1966 | 3.66M | const SvxLRSpaceItem& rOther = static_cast<const SvxLRSpaceItem&>(rAttr); |
1967 | | |
1968 | 3.66M | return std::tie(m_stFirstLineOffset, m_nGutterMargin, m_nRightGutterMargin, m_stLeftMargin, |
1969 | 3.66M | m_stRightMargin, nPropFirstLineOffset, nPropLeftMargin, nPropRightMargin, |
1970 | 3.66M | bAutoFirst, bExplicitZeroMarginValRight, bExplicitZeroMarginValLeft) |
1971 | 3.66M | == std::tie(rOther.m_stFirstLineOffset, rOther.m_nGutterMargin, |
1972 | 3.66M | rOther.m_nRightGutterMargin, rOther.m_stLeftMargin, rOther.m_stRightMargin, |
1973 | 3.66M | rOther.nPropFirstLineOffset, rOther.nPropLeftMargin, rOther.nPropRightMargin, |
1974 | 3.66M | rOther.bAutoFirst, rOther.bExplicitZeroMarginValRight, |
1975 | 3.66M | rOther.bExplicitZeroMarginValLeft); |
1976 | 3.66M | } |
1977 | | |
1978 | | SvxLRSpaceItem* SvxLRSpaceItem::Clone( SfxItemPool* ) const |
1979 | 1.35M | { |
1980 | 1.35M | return new SvxLRSpaceItem( *this ); |
1981 | 1.35M | } |
1982 | | |
1983 | | bool SvxLRSpaceItem::GetPresentation |
1984 | | ( |
1985 | | SfxItemPresentation ePres, |
1986 | | MapUnit eCoreUnit, |
1987 | | MapUnit ePresUnit, |
1988 | | OUString& rText, const IntlWrapper& rIntl |
1989 | | ) const |
1990 | 0 | { |
1991 | 0 | switch ( ePres ) |
1992 | 0 | { |
1993 | 0 | case SfxItemPresentation::Nameless: |
1994 | 0 | { |
1995 | 0 | if ( 100 != nPropLeftMargin ) |
1996 | 0 | { |
1997 | 0 | rText = unicode::formatPercent(nPropLeftMargin, |
1998 | 0 | Application::GetSettings().GetUILanguageTag()); |
1999 | 0 | } |
2000 | 0 | else if (m_stLeftMargin.m_nUnit != css::util::MeasureUnit::TWIP) |
2001 | 0 | { |
2002 | 0 | OUStringBuffer stBuf; |
2003 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stLeftMargin.m_dValue, |
2004 | 0 | m_stLeftMargin.m_nUnit); |
2005 | 0 | rText += stBuf.makeStringAndClear(); |
2006 | 0 | } |
2007 | 0 | else |
2008 | 0 | rText = GetMetricText(static_cast<tools::Long>(m_stLeftMargin.m_dValue), eCoreUnit, |
2009 | 0 | ePresUnit, &rIntl); |
2010 | 0 | rText += cpDelim; |
2011 | 0 | if ( 100 != nPropFirstLineOffset ) |
2012 | 0 | { |
2013 | 0 | rText += unicode::formatPercent(nPropFirstLineOffset, |
2014 | 0 | Application::GetSettings().GetUILanguageTag()); |
2015 | 0 | } |
2016 | 0 | else if (m_stFirstLineOffset.m_nUnit != css::util::MeasureUnit::TWIP) |
2017 | 0 | { |
2018 | 0 | OUStringBuffer stBuf; |
2019 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stFirstLineOffset.m_dValue, |
2020 | 0 | m_stFirstLineOffset.m_nUnit); |
2021 | 0 | rText += stBuf.makeStringAndClear(); |
2022 | 0 | } |
2023 | 0 | else |
2024 | 0 | rText += GetMetricText(static_cast<tools::Long>(m_stFirstLineOffset.m_dValue), |
2025 | 0 | eCoreUnit, ePresUnit, &rIntl); |
2026 | 0 | rText += cpDelim; |
2027 | 0 | if (100 != nPropRightMargin) |
2028 | 0 | { |
2029 | 0 | rText += unicode::formatPercent(nPropRightMargin, |
2030 | 0 | Application::GetSettings().GetUILanguageTag()); |
2031 | 0 | } |
2032 | 0 | else if (m_stRightMargin.m_nUnit != css::util::MeasureUnit::TWIP) |
2033 | 0 | { |
2034 | 0 | OUStringBuffer stBuf; |
2035 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stRightMargin.m_dValue, |
2036 | 0 | m_stRightMargin.m_nUnit); |
2037 | 0 | rText += stBuf.makeStringAndClear(); |
2038 | 0 | } |
2039 | 0 | else |
2040 | 0 | rText += GetMetricText(static_cast<tools::Long>(m_stRightMargin.m_dValue), |
2041 | 0 | eCoreUnit, ePresUnit, &rIntl); |
2042 | 0 | return true; |
2043 | 0 | } |
2044 | 0 | case SfxItemPresentation::Complete: |
2045 | 0 | { |
2046 | 0 | rText = EditResId(RID_SVXITEMS_LRSPACE_LEFT); |
2047 | 0 | if ( 100 != nPropLeftMargin ) |
2048 | 0 | rText += unicode::formatPercent(nPropLeftMargin, |
2049 | 0 | Application::GetSettings().GetUILanguageTag()); |
2050 | 0 | else if (m_stLeftMargin.m_nUnit != css::util::MeasureUnit::TWIP) |
2051 | 0 | { |
2052 | 0 | OUStringBuffer stBuf; |
2053 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stLeftMargin.m_dValue, |
2054 | 0 | m_stLeftMargin.m_nUnit); |
2055 | 0 | rText += stBuf.makeStringAndClear(); |
2056 | 0 | } |
2057 | 0 | else |
2058 | 0 | { |
2059 | 0 | rText += GetMetricText(static_cast<tools::Long>(m_stLeftMargin.m_dValue), eCoreUnit, |
2060 | 0 | ePresUnit, &rIntl) |
2061 | 0 | + " " + EditResId(GetMetricId(ePresUnit)); |
2062 | 0 | } |
2063 | 0 | rText += cpDelim; |
2064 | 0 | if (100 != nPropFirstLineOffset || m_stFirstLineOffset.m_dValue != 0.0) |
2065 | 0 | { |
2066 | 0 | rText += EditResId(RID_SVXITEMS_LRSPACE_FLINE); |
2067 | 0 | if ( 100 != nPropFirstLineOffset ) |
2068 | 0 | rText += unicode::formatPercent(nPropFirstLineOffset, |
2069 | 0 | Application::GetSettings().GetUILanguageTag()); |
2070 | 0 | else if (m_stFirstLineOffset.m_nUnit != css::util::MeasureUnit::TWIP) |
2071 | 0 | { |
2072 | 0 | OUStringBuffer stBuf; |
2073 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stFirstLineOffset.m_dValue, |
2074 | 0 | m_stFirstLineOffset.m_nUnit); |
2075 | 0 | rText += stBuf.makeStringAndClear(); |
2076 | 0 | } |
2077 | 0 | else |
2078 | 0 | { |
2079 | 0 | rText += GetMetricText(static_cast<tools::Long>(m_stFirstLineOffset.m_dValue), |
2080 | 0 | eCoreUnit, ePresUnit, &rIntl) |
2081 | 0 | + " " + EditResId(GetMetricId(ePresUnit)); |
2082 | 0 | } |
2083 | 0 | rText += cpDelim; |
2084 | 0 | } |
2085 | 0 | rText += EditResId(RID_SVXITEMS_LRSPACE_RIGHT); |
2086 | 0 | if (100 != nPropRightMargin) |
2087 | 0 | { |
2088 | 0 | rText += unicode::formatPercent(nPropRightMargin, |
2089 | 0 | Application::GetSettings().GetUILanguageTag()); |
2090 | 0 | } |
2091 | 0 | else if (m_stRightMargin.m_nUnit != css::util::MeasureUnit::TWIP) |
2092 | 0 | { |
2093 | 0 | OUStringBuffer stBuf; |
2094 | 0 | sax::Converter::convertMeasureUnit(stBuf, m_stRightMargin.m_dValue, |
2095 | 0 | m_stRightMargin.m_nUnit); |
2096 | 0 | rText += stBuf.makeStringAndClear(); |
2097 | 0 | } |
2098 | 0 | else |
2099 | 0 | { |
2100 | 0 | rText += GetMetricText(static_cast<tools::Long>(m_stRightMargin.m_dValue), |
2101 | 0 | eCoreUnit, ePresUnit, &rIntl) |
2102 | 0 | + " " + EditResId(GetMetricId(ePresUnit)); |
2103 | 0 | } |
2104 | 0 | return true; |
2105 | 0 | } |
2106 | 0 | default: ; // prevent warning |
2107 | 0 | } |
2108 | 0 | return false; |
2109 | 0 | } |
2110 | | |
2111 | | |
2112 | | void SvxLRSpaceItem::ScaleMetrics(double fScale) |
2113 | 0 | { |
2114 | 0 | m_stFirstLineOffset.ScaleMetrics(fScale); |
2115 | 0 | m_stLeftMargin.ScaleMetrics(fScale); |
2116 | 0 | m_stRightMargin.ScaleMetrics(fScale); |
2117 | 0 | } |
2118 | | |
2119 | | |
2120 | | bool SvxLRSpaceItem::HasMetrics() const |
2121 | 0 | { |
2122 | 0 | return true; |
2123 | 0 | } |
2124 | | |
2125 | | |
2126 | | void SvxLRSpaceItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
2127 | 0 | { |
2128 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxLRSpaceItem")); |
2129 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
2130 | 0 | (void)xmlTextWriterWriteAttribute( |
2131 | 0 | pWriter, BAD_CAST("m_dFirstLineOffset"), |
2132 | 0 | BAD_CAST(OString::number(m_stFirstLineOffset.m_dValue).getStr())); |
2133 | 0 | (void)xmlTextWriterWriteAttribute( |
2134 | 0 | pWriter, BAD_CAST("m_nFirstLineUnit"), |
2135 | 0 | BAD_CAST(OString::number(m_stFirstLineOffset.m_nUnit).getStr())); |
2136 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_dLeftMargin"), |
2137 | 0 | BAD_CAST(OString::number(m_stLeftMargin.m_dValue).getStr())); |
2138 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nLeftMarginUnit"), |
2139 | 0 | BAD_CAST(OString::number(m_stLeftMargin.m_nUnit).getStr())); |
2140 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_dRightMargin"), |
2141 | 0 | BAD_CAST(OString::number(m_stRightMargin.m_dValue).getStr())); |
2142 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nRightMarginUnit"), |
2143 | 0 | BAD_CAST(OString::number(m_stRightMargin.m_nUnit).getStr())); |
2144 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nGutterMargin"), |
2145 | 0 | BAD_CAST(OString::number(m_nGutterMargin).getStr())); |
2146 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nRightGutterMargin"), |
2147 | 0 | BAD_CAST(OString::number(m_nRightGutterMargin).getStr())); |
2148 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nPropFirstLineOffset"), BAD_CAST(OString::number(nPropFirstLineOffset).getStr())); |
2149 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nPropLeftMargin"), BAD_CAST(OString::number(nPropLeftMargin).getStr())); |
2150 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nPropRightMargin"), BAD_CAST(OString::number(nPropRightMargin).getStr())); |
2151 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("bAutoFirst"), BAD_CAST(OString::number(int(bAutoFirst)).getStr())); |
2152 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("bExplicitZeroMarginValRight"), BAD_CAST(OString::number(int(bExplicitZeroMarginValRight)).getStr())); |
2153 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("bExplicitZeroMarginValLeft"), BAD_CAST(OString::number(int(bExplicitZeroMarginValLeft)).getStr())); |
2154 | 0 | (void)xmlTextWriterEndElement(pWriter); |
2155 | 0 | } |
2156 | | |
2157 | | |
2158 | | boost::property_tree::ptree SvxLRSpaceItem::dumpAsJSON() const |
2159 | 0 | { |
2160 | 0 | boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); |
2161 | |
|
2162 | 0 | boost::property_tree::ptree aState; |
2163 | |
|
2164 | 0 | MapUnit eTargetUnit = MapUnit::MapInch; |
2165 | |
|
2166 | 0 | OUString sLeft = GetMetricText(ResolveLeft({}), MapUnit::MapTwip, eTargetUnit, nullptr); |
2167 | |
|
2168 | 0 | OUString sRight = GetMetricText(ResolveRight({}), MapUnit::MapTwip, eTargetUnit, nullptr); |
2169 | |
|
2170 | 0 | OUString sFirstline |
2171 | 0 | = GetMetricText(ResolveTextFirstLineOffset({}), MapUnit::MapTwip, eTargetUnit, nullptr); |
2172 | |
|
2173 | 0 | aState.put("left", sLeft); |
2174 | 0 | aState.put("right", sRight); |
2175 | 0 | aState.put("firstline", sFirstline); |
2176 | 0 | aState.put("unit", "inch"); |
2177 | |
|
2178 | 0 | aTree.push_back(std::make_pair("state", aState)); |
2179 | |
|
2180 | 0 | return aTree; |
2181 | 0 | } |
2182 | | |
2183 | | |
2184 | | SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nId ) |
2185 | 879k | : SfxPoolItem(nId) |
2186 | 879k | , nUpper(0) |
2187 | 879k | , nLower(0) |
2188 | 879k | , bContext(false) |
2189 | 879k | , nPropUpper(100) |
2190 | 879k | , nPropLower(100) |
2191 | 879k | { |
2192 | 879k | } |
2193 | | |
2194 | | |
2195 | | SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nUp, const sal_uInt16 nLow, |
2196 | | const sal_uInt16 nId ) |
2197 | 641k | : SfxPoolItem(nId) |
2198 | 641k | , nUpper(nUp) |
2199 | 641k | , nLower(nLow) |
2200 | 641k | , bContext(false) |
2201 | 641k | , nPropUpper(100) |
2202 | 641k | , nPropLower(100) |
2203 | 641k | { |
2204 | 641k | } |
2205 | | |
2206 | | |
2207 | | bool SvxULSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
2208 | 1.18k | { |
2209 | 1.18k | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
2210 | 1.18k | nMemberId &= ~CONVERT_TWIPS; |
2211 | 1.18k | switch( nMemberId ) |
2212 | 1.18k | { |
2213 | | // now all signed |
2214 | 0 | case 0: |
2215 | 0 | { |
2216 | 0 | css::frame::status::UpperLowerMarginScale aUpperLowerMarginScale; |
2217 | 0 | aUpperLowerMarginScale.Upper = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nUpper) : nUpper); |
2218 | 0 | aUpperLowerMarginScale.Lower = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nLower) : nPropUpper); |
2219 | 0 | aUpperLowerMarginScale.ScaleUpper = static_cast<sal_Int16>(nPropUpper); |
2220 | 0 | aUpperLowerMarginScale.ScaleLower = static_cast<sal_Int16>(nPropLower); |
2221 | 0 | rVal <<= aUpperLowerMarginScale; |
2222 | 0 | break; |
2223 | 0 | } |
2224 | 555 | case MID_UP_MARGIN: rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nUpper) : nUpper); break; |
2225 | 532 | case MID_LO_MARGIN: rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nLower) : nLower); break; |
2226 | 101 | case MID_CTX_MARGIN: rVal <<= bContext; break; |
2227 | 0 | case MID_UP_REL_MARGIN: rVal <<= static_cast<sal_Int16>(nPropUpper); break; |
2228 | 0 | case MID_LO_REL_MARGIN: rVal <<= static_cast<sal_Int16>(nPropLower); break; |
2229 | 1.18k | } |
2230 | 1.18k | return true; |
2231 | 1.18k | } |
2232 | | |
2233 | | |
2234 | | bool SvxULSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
2235 | 445k | { |
2236 | 445k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
2237 | 445k | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
2238 | 445k | nMemberId &= ~CONVERT_TWIPS; |
2239 | 445k | sal_Int32 nVal = 0; |
2240 | 445k | bool bVal = false; |
2241 | 445k | switch( nMemberId ) |
2242 | 445k | { |
2243 | 0 | case 0: |
2244 | 0 | { |
2245 | 0 | css::frame::status::UpperLowerMarginScale aUpperLowerMarginScale; |
2246 | 0 | if ( !(rVal >>= aUpperLowerMarginScale )) |
2247 | 0 | return false; |
2248 | 0 | { |
2249 | 0 | SetUpper(bConvert ? o3tl::toTwips(aUpperLowerMarginScale.Upper, o3tl::Length::mm100) : aUpperLowerMarginScale.Upper); |
2250 | 0 | SetLower(bConvert ? o3tl::toTwips(aUpperLowerMarginScale.Lower, o3tl::Length::mm100) : aUpperLowerMarginScale.Lower); |
2251 | 0 | if( aUpperLowerMarginScale.ScaleUpper > 1 ) |
2252 | 0 | nPropUpper = aUpperLowerMarginScale.ScaleUpper; |
2253 | 0 | if( aUpperLowerMarginScale.ScaleLower > 1 ) |
2254 | 0 | nPropUpper = aUpperLowerMarginScale.ScaleLower; |
2255 | 0 | } |
2256 | 0 | } |
2257 | 0 | break; |
2258 | 214k | case MID_UP_MARGIN : |
2259 | 214k | if(!(rVal >>= nVal)) |
2260 | 0 | return false; |
2261 | 214k | SetUpper(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); |
2262 | 214k | break; |
2263 | 220k | case MID_LO_MARGIN : |
2264 | 220k | if(!(rVal >>= nVal) || nVal < 0) |
2265 | 809 | return false; |
2266 | 219k | SetLower(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); |
2267 | 219k | break; |
2268 | 10.7k | case MID_CTX_MARGIN : |
2269 | 10.7k | if (!(rVal >>= bVal)) |
2270 | 0 | return false; |
2271 | 10.7k | SetContextValue(bVal); |
2272 | 10.7k | break; |
2273 | 0 | case MID_UP_REL_MARGIN: |
2274 | 6 | case MID_LO_REL_MARGIN: |
2275 | 6 | { |
2276 | 6 | sal_Int32 nRel = 0; |
2277 | 6 | if((rVal >>= nRel) && nRel > 1 ) |
2278 | 0 | { |
2279 | 0 | if(MID_UP_REL_MARGIN == nMemberId) |
2280 | 0 | nPropUpper = static_cast<sal_uInt16>(nRel); |
2281 | 0 | else |
2282 | 0 | nPropLower = static_cast<sal_uInt16>(nRel); |
2283 | 0 | } |
2284 | 6 | else |
2285 | 6 | return false; |
2286 | 6 | } |
2287 | 0 | break; |
2288 | | |
2289 | 0 | default: |
2290 | 0 | OSL_FAIL("unknown MemberId"); |
2291 | 0 | return false; |
2292 | 445k | } |
2293 | 444k | return true; |
2294 | 445k | } |
2295 | | |
2296 | | |
2297 | | bool SvxULSpaceItem::operator==( const SfxPoolItem& rAttr ) const |
2298 | 4.21M | { |
2299 | 4.21M | assert(SfxPoolItem::operator==(rAttr)); |
2300 | | |
2301 | 4.21M | const SvxULSpaceItem& rSpaceItem = static_cast<const SvxULSpaceItem&>( rAttr ); |
2302 | 4.21M | return ( nUpper == rSpaceItem.nUpper && |
2303 | 3.20M | nLower == rSpaceItem.nLower && |
2304 | 3.08M | bContext == rSpaceItem.bContext && |
2305 | 3.08M | nPropUpper == rSpaceItem.nPropUpper && |
2306 | 3.08M | nPropLower == rSpaceItem.nPropLower ); |
2307 | 4.21M | } |
2308 | | |
2309 | | size_t SvxULSpaceItem::hashCode() const |
2310 | 2.36M | { |
2311 | 2.36M | std::size_t seed(0); |
2312 | 2.36M | o3tl::hash_combine(seed, nUpper); |
2313 | 2.36M | o3tl::hash_combine(seed, nLower); |
2314 | 2.36M | o3tl::hash_combine(seed, bContext); |
2315 | 2.36M | o3tl::hash_combine(seed, nPropUpper); |
2316 | 2.36M | o3tl::hash_combine(seed, nPropLower); |
2317 | 2.36M | return seed; |
2318 | 2.36M | } |
2319 | | |
2320 | | SvxULSpaceItem* SvxULSpaceItem::Clone( SfxItemPool* ) const |
2321 | 2.03M | { |
2322 | 2.03M | return new SvxULSpaceItem( *this ); |
2323 | 2.03M | } |
2324 | | |
2325 | | bool SvxULSpaceItem::GetPresentation |
2326 | | ( |
2327 | | SfxItemPresentation ePres, |
2328 | | MapUnit eCoreUnit, |
2329 | | MapUnit ePresUnit, |
2330 | | OUString& rText, |
2331 | | const IntlWrapper& rIntl |
2332 | | ) const |
2333 | 0 | { |
2334 | 0 | switch ( ePres ) |
2335 | 0 | { |
2336 | 0 | case SfxItemPresentation::Nameless: |
2337 | 0 | { |
2338 | 0 | if ( 100 != nPropUpper ) |
2339 | 0 | { |
2340 | 0 | rText = unicode::formatPercent(nPropUpper, |
2341 | 0 | Application::GetSettings().GetUILanguageTag()); |
2342 | 0 | } |
2343 | 0 | else |
2344 | 0 | rText = GetMetricText( static_cast<tools::Long>(nUpper), eCoreUnit, ePresUnit, &rIntl ); |
2345 | 0 | rText += cpDelim; |
2346 | 0 | if ( 100 != nPropLower ) |
2347 | 0 | { |
2348 | 0 | rText += unicode::formatPercent(nPropLower, |
2349 | 0 | Application::GetSettings().GetUILanguageTag()); |
2350 | 0 | } |
2351 | 0 | else |
2352 | 0 | rText += GetMetricText( static_cast<tools::Long>(nLower), eCoreUnit, ePresUnit, &rIntl ); |
2353 | 0 | return true; |
2354 | 0 | } |
2355 | 0 | case SfxItemPresentation::Complete: |
2356 | 0 | { |
2357 | 0 | rText = EditResId(RID_SVXITEMS_ULSPACE_UPPER); |
2358 | 0 | if ( 100 != nPropUpper ) |
2359 | 0 | { |
2360 | 0 | rText += unicode::formatPercent(nPropUpper, |
2361 | 0 | Application::GetSettings().GetUILanguageTag()); |
2362 | 0 | } |
2363 | 0 | else |
2364 | 0 | { |
2365 | 0 | rText += GetMetricText( static_cast<tools::Long>(nUpper), eCoreUnit, ePresUnit, &rIntl ) + |
2366 | 0 | " " + EditResId(GetMetricId(ePresUnit)); |
2367 | 0 | } |
2368 | 0 | rText += cpDelim + EditResId(RID_SVXITEMS_ULSPACE_LOWER); |
2369 | 0 | if ( 100 != nPropLower ) |
2370 | 0 | { |
2371 | 0 | rText += unicode::formatPercent(nPropLower, |
2372 | 0 | Application::GetSettings().GetUILanguageTag()); |
2373 | 0 | } |
2374 | 0 | else |
2375 | 0 | { |
2376 | 0 | rText += GetMetricText( static_cast<tools::Long>(nLower), eCoreUnit, ePresUnit, &rIntl ) + |
2377 | 0 | " " + EditResId(GetMetricId(ePresUnit)); |
2378 | 0 | } |
2379 | 0 | return true; |
2380 | 0 | } |
2381 | 0 | default: ; // prevent warning |
2382 | 0 | } |
2383 | 0 | return false; |
2384 | 0 | } |
2385 | | |
2386 | | |
2387 | | void SvxULSpaceItem::ScaleMetrics(double fScale) |
2388 | 0 | { |
2389 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
2390 | 0 | nUpper = static_cast<sal_uInt16>(BigInt::Scale( nUpper, fScale )); |
2391 | 0 | nLower = static_cast<sal_uInt16>(BigInt::Scale( nLower, fScale )); |
2392 | 0 | } |
2393 | | |
2394 | | |
2395 | | bool SvxULSpaceItem::HasMetrics() const |
2396 | 0 | { |
2397 | 0 | return true; |
2398 | 0 | } |
2399 | | |
2400 | | |
2401 | | void SvxULSpaceItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
2402 | 0 | { |
2403 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxULSpaceItem")); |
2404 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
2405 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nUpper"), BAD_CAST(OString::number(nUpper).getStr())); |
2406 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nLower"), BAD_CAST(OString::number(nLower).getStr())); |
2407 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("bContext"), BAD_CAST(OString::boolean(bContext).getStr())); |
2408 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nPropUpper"), BAD_CAST(OString::number(nPropUpper).getStr())); |
2409 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nPropLower"), BAD_CAST(OString::number(nPropLower).getStr())); |
2410 | 0 | (void)xmlTextWriterEndElement(pWriter); |
2411 | 0 | } |
2412 | | |
2413 | | boost::property_tree::ptree SvxULSpaceItem::dumpAsJSON() const |
2414 | 0 | { |
2415 | 0 | boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); |
2416 | |
|
2417 | 0 | boost::property_tree::ptree aState; |
2418 | |
|
2419 | 0 | MapUnit eTargetUnit = MapUnit::MapInch; |
2420 | |
|
2421 | 0 | OUString sUpper = GetMetricText(GetUpper(), |
2422 | 0 | MapUnit::MapTwip, eTargetUnit, nullptr); |
2423 | |
|
2424 | 0 | OUString sLower = GetMetricText(GetLower(), |
2425 | 0 | MapUnit::MapTwip, eTargetUnit, nullptr); |
2426 | |
|
2427 | 0 | aState.put("upper", sUpper); |
2428 | 0 | aState.put("lower", sLower); |
2429 | 0 | aState.put("unit", "inch"); |
2430 | |
|
2431 | 0 | aTree.push_back(std::make_pair("state", aState)); |
2432 | |
|
2433 | 0 | return aTree; |
2434 | 0 | } |
2435 | | |
2436 | | SvxPrintItem* SvxPrintItem::Clone( SfxItemPool* ) const |
2437 | 483 | { |
2438 | 483 | return new SvxPrintItem( *this ); |
2439 | 483 | } |
2440 | | |
2441 | | bool SvxPrintItem::GetPresentation |
2442 | | ( |
2443 | | SfxItemPresentation /*ePres*/, |
2444 | | MapUnit /*eCoreUnit*/, |
2445 | | MapUnit /*ePresUnit*/, |
2446 | | OUString& rText, const IntlWrapper& |
2447 | | ) const |
2448 | 0 | { |
2449 | 0 | TranslateId pId = RID_SVXITEMS_PRINT_FALSE; |
2450 | |
|
2451 | 0 | if ( GetValue() ) |
2452 | 0 | pId = RID_SVXITEMS_PRINT_TRUE; |
2453 | 0 | rText = EditResId(pId); |
2454 | 0 | return true; |
2455 | 0 | } |
2456 | | |
2457 | | SvxOpaqueItem* SvxOpaqueItem::Clone( SfxItemPool* ) const |
2458 | 4.72k | { |
2459 | 4.72k | return new SvxOpaqueItem( *this ); |
2460 | 4.72k | } |
2461 | | |
2462 | | bool SvxOpaqueItem::GetPresentation |
2463 | | ( |
2464 | | SfxItemPresentation /*ePres*/, |
2465 | | MapUnit /*eCoreUnit*/, |
2466 | | MapUnit /*ePresUnit*/, |
2467 | | OUString& rText, const IntlWrapper& |
2468 | | ) const |
2469 | 0 | { |
2470 | 0 | TranslateId pId = RID_SVXITEMS_OPAQUE_FALSE; |
2471 | |
|
2472 | 0 | if ( GetValue() ) |
2473 | 0 | pId = RID_SVXITEMS_OPAQUE_TRUE; |
2474 | 0 | rText = EditResId(pId); |
2475 | 0 | return true; |
2476 | 0 | } |
2477 | | |
2478 | | |
2479 | | bool SvxProtectItem::operator==( const SfxPoolItem& rAttr ) const |
2480 | 51.1k | { |
2481 | 51.1k | assert(SfxPoolItem::operator==(rAttr)); |
2482 | | |
2483 | 51.1k | const SvxProtectItem& rItem = static_cast<const SvxProtectItem&>(rAttr); |
2484 | 51.1k | return ( bCntnt == rItem.bCntnt && |
2485 | 41.4k | bSize == rItem.bSize && |
2486 | 41.3k | bPos == rItem.bPos ); |
2487 | 51.1k | } |
2488 | | |
2489 | | |
2490 | | bool SvxProtectItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
2491 | 0 | { |
2492 | 0 | nMemberId &= ~CONVERT_TWIPS; |
2493 | 0 | bool bValue; |
2494 | 0 | switch(nMemberId) |
2495 | 0 | { |
2496 | 0 | case MID_PROTECT_CONTENT : bValue = bCntnt; break; |
2497 | 0 | case MID_PROTECT_SIZE : bValue = bSize; break; |
2498 | 0 | case MID_PROTECT_POSITION: bValue = bPos; break; |
2499 | 0 | default: |
2500 | 0 | OSL_FAIL("Wrong MemberId"); |
2501 | 0 | return false; |
2502 | 0 | } |
2503 | | |
2504 | 0 | rVal <<= bValue; |
2505 | 0 | return true; |
2506 | 0 | } |
2507 | | |
2508 | | |
2509 | | bool SvxProtectItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
2510 | 99 | { |
2511 | 99 | nMemberId &= ~CONVERT_TWIPS; |
2512 | 99 | bool bVal( Any2Bool(rVal) ); |
2513 | 99 | switch(nMemberId) |
2514 | 99 | { |
2515 | 33 | case MID_PROTECT_CONTENT : bCntnt = bVal; break; |
2516 | 33 | case MID_PROTECT_SIZE : bSize = bVal; break; |
2517 | 33 | case MID_PROTECT_POSITION: bPos = bVal; break; |
2518 | 0 | default: |
2519 | 0 | OSL_FAIL("Wrong MemberId"); |
2520 | 0 | return false; |
2521 | 99 | } |
2522 | 99 | return true; |
2523 | 99 | } |
2524 | | |
2525 | | SvxProtectItem* SvxProtectItem::Clone( SfxItemPool* ) const |
2526 | 13.9k | { |
2527 | 13.9k | return new SvxProtectItem( *this ); |
2528 | 13.9k | } |
2529 | | |
2530 | | bool SvxProtectItem::GetPresentation |
2531 | | ( |
2532 | | SfxItemPresentation /*ePres*/, |
2533 | | MapUnit /*eCoreUnit*/, |
2534 | | MapUnit /*ePresUnit*/, |
2535 | | OUString& rText, const IntlWrapper& |
2536 | | ) const |
2537 | 0 | { |
2538 | 0 | TranslateId pId = RID_SVXITEMS_PROT_CONTENT_FALSE; |
2539 | |
|
2540 | 0 | if ( bCntnt ) |
2541 | 0 | pId = RID_SVXITEMS_PROT_CONTENT_TRUE; |
2542 | 0 | rText = EditResId(pId) + cpDelim; |
2543 | 0 | pId = RID_SVXITEMS_PROT_SIZE_FALSE; |
2544 | |
|
2545 | 0 | if ( bSize ) |
2546 | 0 | pId = RID_SVXITEMS_PROT_SIZE_TRUE; |
2547 | 0 | rText += EditResId(pId) + cpDelim; |
2548 | 0 | pId = RID_SVXITEMS_PROT_POS_FALSE; |
2549 | |
|
2550 | 0 | if ( bPos ) |
2551 | 0 | pId = RID_SVXITEMS_PROT_POS_TRUE; |
2552 | 0 | rText += EditResId(pId); |
2553 | 0 | return true; |
2554 | 0 | } |
2555 | | |
2556 | | |
2557 | | void SvxProtectItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
2558 | 0 | { |
2559 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxProtectItem")); |
2560 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
2561 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("content"), BAD_CAST(OString::boolean(bCntnt).getStr())); |
2562 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("size"), BAD_CAST(OString::boolean(bSize).getStr())); |
2563 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("position"), BAD_CAST(OString::boolean(bPos).getStr())); |
2564 | 0 | (void)xmlTextWriterEndElement(pWriter); |
2565 | 0 | } |
2566 | | |
2567 | | |
2568 | | SvxShadowItem::SvxShadowItem( const sal_uInt16 nId, |
2569 | | const Color *pColor, const sal_uInt16 nW, |
2570 | | const SvxShadowLocation eLoc ) : |
2571 | 451k | SfxPoolItem( nId ), |
2572 | 451k | aShadowColor(COL_GRAY), |
2573 | 451k | nWidth ( nW ), |
2574 | 451k | eLocation ( eLoc ) |
2575 | 451k | { |
2576 | 451k | if ( pColor ) |
2577 | 316k | aShadowColor = *pColor; |
2578 | 451k | } |
2579 | | |
2580 | | |
2581 | | bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
2582 | 1.98k | { |
2583 | 1.98k | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
2584 | 1.98k | nMemberId &= ~CONVERT_TWIPS; |
2585 | | |
2586 | 1.98k | table::ShadowFormat aShadow; |
2587 | 1.98k | table::ShadowLocation eSet = table::ShadowLocation_NONE; |
2588 | 1.98k | switch( eLocation ) |
2589 | 1.98k | { |
2590 | 0 | case SvxShadowLocation::TopLeft : eSet = table::ShadowLocation_TOP_LEFT ; break; |
2591 | 0 | case SvxShadowLocation::TopRight : eSet = table::ShadowLocation_TOP_RIGHT ; break; |
2592 | 0 | case SvxShadowLocation::BottomLeft : eSet = table::ShadowLocation_BOTTOM_LEFT ; break; |
2593 | 0 | case SvxShadowLocation::BottomRight: eSet = table::ShadowLocation_BOTTOM_RIGHT; break; |
2594 | 1.98k | default: ; // prevent warning |
2595 | 1.98k | } |
2596 | 1.98k | aShadow.Location = eSet; |
2597 | 1.98k | aShadow.ShadowWidth = bConvert ? convertTwipToMm100(nWidth) : nWidth; |
2598 | 1.98k | aShadow.IsTransparent = aShadowColor.IsTransparent(); |
2599 | 1.98k | aShadow.Color = sal_Int32(aShadowColor); |
2600 | | |
2601 | 1.98k | sal_Int8 nTransparence = rtl::math::round((float(255 - aShadowColor.GetAlpha()) * 100) / 255); |
2602 | | |
2603 | 1.98k | switch ( nMemberId ) |
2604 | 1.98k | { |
2605 | 0 | case MID_LOCATION: rVal <<= aShadow.Location; break; |
2606 | 0 | case MID_WIDTH: rVal <<= aShadow.ShadowWidth; break; |
2607 | 0 | case MID_TRANSPARENT: rVal <<= aShadow.IsTransparent; break; |
2608 | 0 | case MID_BG_COLOR: rVal <<= aShadow.Color; break; |
2609 | 1.94k | case 0: rVal <<= aShadow; break; |
2610 | 35 | case MID_SHADOW_TRANSPARENCE: rVal <<= nTransparence; break; |
2611 | 0 | default: OSL_FAIL("Wrong MemberId!"); return false; |
2612 | 1.98k | } |
2613 | | |
2614 | 1.98k | return true; |
2615 | 1.98k | } |
2616 | | |
2617 | | bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
2618 | 1.88k | { |
2619 | 1.88k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
2620 | 1.88k | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
2621 | 1.88k | nMemberId &= ~CONVERT_TWIPS; |
2622 | | |
2623 | 1.88k | table::ShadowFormat aShadow; |
2624 | 1.88k | uno::Any aAny; |
2625 | 1.88k | bool bRet = QueryValue( aAny, bConvert ? CONVERT_TWIPS : 0 ) && ( aAny >>= aShadow ); |
2626 | 1.88k | switch ( nMemberId ) |
2627 | 1.88k | { |
2628 | 0 | case MID_LOCATION: |
2629 | 0 | { |
2630 | 0 | bRet = (rVal >>= aShadow.Location); |
2631 | 0 | if ( !bRet ) |
2632 | 0 | { |
2633 | 0 | sal_Int16 nVal = 0; |
2634 | 0 | bRet = (rVal >>= nVal); |
2635 | 0 | aShadow.Location = static_cast<table::ShadowLocation>(nVal); |
2636 | 0 | } |
2637 | |
|
2638 | 0 | break; |
2639 | 0 | } |
2640 | | |
2641 | 0 | case MID_WIDTH: rVal >>= aShadow.ShadowWidth; break; |
2642 | 0 | case MID_TRANSPARENT: rVal >>= aShadow.IsTransparent; break; |
2643 | 0 | case MID_BG_COLOR: rVal >>= aShadow.Color; break; |
2644 | 1.83k | case 0: rVal >>= aShadow; break; |
2645 | 51 | case MID_SHADOW_TRANSPARENCE: |
2646 | 51 | { |
2647 | 51 | sal_Int32 nTransparence = 0; |
2648 | 51 | if ((rVal >>= nTransparence) && !o3tl::checked_multiply<sal_Int32>(nTransparence, 255, nTransparence)) |
2649 | 51 | { |
2650 | 51 | Color aColor(ColorTransparency, aShadow.Color); |
2651 | 51 | aColor.SetAlpha(255 - rtl::math::round(float(nTransparence) / 100)); |
2652 | 51 | aShadow.Color = sal_Int32(aColor); |
2653 | 51 | } |
2654 | 51 | break; |
2655 | 0 | } |
2656 | 0 | default: OSL_FAIL("Wrong MemberId!"); return false; |
2657 | 1.88k | } |
2658 | | |
2659 | 1.88k | if ( bRet ) |
2660 | 1.88k | { |
2661 | 1.88k | switch( aShadow.Location ) |
2662 | 1.88k | { |
2663 | 1.88k | case table::ShadowLocation_NONE : eLocation = SvxShadowLocation::NONE; break; |
2664 | 0 | case table::ShadowLocation_TOP_LEFT : eLocation = SvxShadowLocation::TopLeft; break; |
2665 | 0 | case table::ShadowLocation_TOP_RIGHT : eLocation = SvxShadowLocation::TopRight; break; |
2666 | 0 | case table::ShadowLocation_BOTTOM_LEFT : eLocation = SvxShadowLocation::BottomLeft ; break; |
2667 | 4 | case table::ShadowLocation_BOTTOM_RIGHT: eLocation = SvxShadowLocation::BottomRight; break; |
2668 | 0 | default: ; // prevent warning |
2669 | 1.88k | } |
2670 | | |
2671 | 1.88k | nWidth = bConvert ? o3tl::toTwips(aShadow.ShadowWidth, o3tl::Length::mm100) : aShadow.ShadowWidth; |
2672 | 1.88k | Color aSet(ColorTransparency, aShadow.Color); |
2673 | 1.88k | aShadowColor = aSet; |
2674 | 1.88k | } |
2675 | | |
2676 | 1.88k | return bRet; |
2677 | 1.88k | } |
2678 | | |
2679 | | |
2680 | | bool SvxShadowItem::operator==( const SfxPoolItem& rAttr ) const |
2681 | 904k | { |
2682 | 904k | assert(SfxPoolItem::operator==(rAttr)); |
2683 | | |
2684 | 904k | const SvxShadowItem& rItem = static_cast<const SvxShadowItem&>(rAttr); |
2685 | 904k | return ( ( aShadowColor == rItem.aShadowColor ) && |
2686 | 902k | ( nWidth == rItem.GetWidth() ) && |
2687 | 902k | ( eLocation == rItem.GetLocation() ) ); |
2688 | 904k | } |
2689 | | |
2690 | | size_t SvxShadowItem::hashCode() const |
2691 | 776 | { |
2692 | 776 | std::size_t seed(0); |
2693 | 776 | o3tl::hash_combine(seed, sal_Int32(aShadowColor)); |
2694 | 776 | o3tl::hash_combine(seed, nWidth); |
2695 | 776 | o3tl::hash_combine(seed, static_cast<int>(eLocation)); |
2696 | 776 | return seed; |
2697 | 776 | } |
2698 | | |
2699 | | SvxShadowItem* SvxShadowItem::Clone( SfxItemPool* ) const |
2700 | 136k | { |
2701 | 136k | return new SvxShadowItem( *this ); |
2702 | 136k | } |
2703 | | |
2704 | | sal_uInt16 SvxShadowItem::CalcShadowSpace( SvxShadowItemSide nShadow ) const |
2705 | 118k | { |
2706 | 118k | sal_uInt16 nSpace = 0; |
2707 | | |
2708 | 118k | switch ( nShadow ) |
2709 | 118k | { |
2710 | 29.5k | case SvxShadowItemSide::TOP: |
2711 | 29.5k | if ( eLocation == SvxShadowLocation::TopLeft || |
2712 | 29.5k | eLocation == SvxShadowLocation::TopRight ) |
2713 | 0 | nSpace = nWidth; |
2714 | 29.5k | break; |
2715 | | |
2716 | 29.5k | case SvxShadowItemSide::BOTTOM: |
2717 | 29.5k | if ( eLocation == SvxShadowLocation::BottomLeft || |
2718 | 29.5k | eLocation == SvxShadowLocation::BottomRight ) |
2719 | 0 | nSpace = nWidth; |
2720 | 29.5k | break; |
2721 | | |
2722 | 29.4k | case SvxShadowItemSide::LEFT: |
2723 | 29.4k | if ( eLocation == SvxShadowLocation::TopLeft || |
2724 | 29.4k | eLocation == SvxShadowLocation::BottomLeft ) |
2725 | 0 | nSpace = nWidth; |
2726 | 29.4k | break; |
2727 | | |
2728 | 29.4k | case SvxShadowItemSide::RIGHT: |
2729 | 29.4k | if ( eLocation == SvxShadowLocation::TopRight || |
2730 | 29.4k | eLocation == SvxShadowLocation::BottomRight ) |
2731 | 0 | nSpace = nWidth; |
2732 | 29.4k | break; |
2733 | | |
2734 | 0 | default: |
2735 | 0 | OSL_FAIL( "wrong shadow" ); |
2736 | 118k | } |
2737 | 118k | return nSpace; |
2738 | 118k | } |
2739 | | |
2740 | | const TranslateId RID_SVXITEMS_SHADOW[] = |
2741 | | { |
2742 | | RID_SVXITEMS_SHADOW_NONE, |
2743 | | RID_SVXITEMS_SHADOW_TOPLEFT, |
2744 | | RID_SVXITEMS_SHADOW_TOPRIGHT, |
2745 | | RID_SVXITEMS_SHADOW_BOTTOMLEFT, |
2746 | | RID_SVXITEMS_SHADOW_BOTTOMRIGHT |
2747 | | }; |
2748 | | |
2749 | | bool SvxShadowItem::GetPresentation |
2750 | | ( |
2751 | | SfxItemPresentation ePres, |
2752 | | MapUnit eCoreUnit, |
2753 | | MapUnit ePresUnit, |
2754 | | OUString& rText, const IntlWrapper& rIntl |
2755 | | ) const |
2756 | 0 | { |
2757 | 0 | switch ( ePres ) |
2758 | 0 | { |
2759 | 0 | case SfxItemPresentation::Nameless: |
2760 | 0 | { |
2761 | 0 | rText = ::GetColorString( aShadowColor ) + cpDelim; |
2762 | 0 | TranslateId pId = RID_SVXITEMS_TRANSPARENT_FALSE; |
2763 | |
|
2764 | 0 | if ( aShadowColor.IsTransparent() ) |
2765 | 0 | pId = RID_SVXITEMS_TRANSPARENT_TRUE; |
2766 | 0 | rText += EditResId(pId) + |
2767 | 0 | cpDelim + |
2768 | 0 | GetMetricText( static_cast<tools::Long>(nWidth), eCoreUnit, ePresUnit, &rIntl ) + |
2769 | 0 | cpDelim + |
2770 | 0 | EditResId(RID_SVXITEMS_SHADOW[static_cast<int>(eLocation)]); |
2771 | 0 | return true; |
2772 | 0 | } |
2773 | 0 | case SfxItemPresentation::Complete: |
2774 | 0 | { |
2775 | 0 | rText = EditResId(RID_SVXITEMS_SHADOW_COMPLETE) + |
2776 | 0 | ::GetColorString( aShadowColor ) + |
2777 | 0 | cpDelim; |
2778 | |
|
2779 | 0 | TranslateId pId = RID_SVXITEMS_TRANSPARENT_FALSE; |
2780 | 0 | if ( aShadowColor.IsTransparent() ) |
2781 | 0 | pId = RID_SVXITEMS_TRANSPARENT_TRUE; |
2782 | 0 | rText += EditResId(pId) + |
2783 | 0 | cpDelim + |
2784 | 0 | GetMetricText( static_cast<tools::Long>(nWidth), eCoreUnit, ePresUnit, &rIntl ) + |
2785 | 0 | " " + EditResId(GetMetricId(ePresUnit)) + |
2786 | 0 | cpDelim + |
2787 | 0 | EditResId(RID_SVXITEMS_SHADOW[static_cast<int>(eLocation)]); |
2788 | 0 | return true; |
2789 | 0 | } |
2790 | 0 | default: ; // prevent warning |
2791 | 0 | } |
2792 | 0 | return false; |
2793 | 0 | } |
2794 | | |
2795 | | |
2796 | | void SvxShadowItem::ScaleMetrics(double fScale) |
2797 | 0 | { |
2798 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
2799 | 0 | nWidth = static_cast<sal_uInt16>(BigInt::Scale( nWidth, fScale )); |
2800 | 0 | } |
2801 | | |
2802 | | |
2803 | | bool SvxShadowItem::HasMetrics() const |
2804 | 0 | { |
2805 | 0 | return true; |
2806 | 0 | } |
2807 | | |
2808 | | |
2809 | | void SvxShadowItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
2810 | 0 | { |
2811 | 0 | tools::XmlWriter aWriter(pWriter); |
2812 | 0 | aWriter.startElement("SvxShadowItem"); |
2813 | 0 | aWriter.attribute("whichId", Which()); |
2814 | 0 | aWriter.attribute("aShadowColor", aShadowColor.AsRGBHexString()); |
2815 | 0 | aWriter.attribute("nWidth", nWidth); |
2816 | 0 | aWriter.attribute("eLocation", sal_Int32(eLocation)); |
2817 | 0 | aWriter.attribute("presentation", EditResId(RID_SVXITEMS_SHADOW[static_cast<int>(eLocation)])); |
2818 | 0 | aWriter.endElement(); |
2819 | 0 | } |
2820 | | |
2821 | | // class SvxBoxItem ------------------------------------------------------ |
2822 | | |
2823 | | SvxBoxItem::SvxBoxItem(const SvxBoxItem& rCopy) |
2824 | 1.83M | : SfxPoolItem (rCopy) |
2825 | 1.83M | , mpTopBorderLine(rCopy.mpTopBorderLine ? new SvxBorderLine(*rCopy.mpTopBorderLine) : nullptr) |
2826 | 1.83M | , mpBottomBorderLine(rCopy.mpBottomBorderLine ? new SvxBorderLine(*rCopy.mpBottomBorderLine) : nullptr) |
2827 | 1.83M | , mpLeftBorderLine(rCopy.mpLeftBorderLine ? new SvxBorderLine(*rCopy.mpLeftBorderLine) : nullptr) |
2828 | 1.83M | , mpRightBorderLine(rCopy.mpRightBorderLine ? new SvxBorderLine(*rCopy.mpRightBorderLine) : nullptr) |
2829 | 1.83M | , mnTopDistance(rCopy.mnTopDistance) |
2830 | 1.83M | , mnBottomDistance(rCopy.mnBottomDistance) |
2831 | 1.83M | , mnLeftDistance(rCopy.mnLeftDistance) |
2832 | 1.83M | , mnRightDistance(rCopy.mnRightDistance) |
2833 | 1.83M | , maTempComplexColors(rCopy.maTempComplexColors) |
2834 | 1.83M | , mbRemoveAdjCellBorder(rCopy.mbRemoveAdjCellBorder) |
2835 | 1.83M | { |
2836 | 1.83M | } |
2837 | | |
2838 | | |
2839 | | SvxBoxItem::SvxBoxItem(const sal_uInt16 nId) |
2840 | 1.63M | : SfxPoolItem(nId) |
2841 | 1.63M | { |
2842 | 1.63M | } |
2843 | | |
2844 | | |
2845 | | SvxBoxItem::~SvxBoxItem() |
2846 | 3.46M | { |
2847 | 3.46M | } |
2848 | | |
2849 | | void SvxBoxItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
2850 | 0 | { |
2851 | 0 | tools::XmlWriter aWriter(pWriter); |
2852 | 0 | aWriter.startElement("SvxBoxItem"); |
2853 | 0 | aWriter.attribute("top-dist", mnTopDistance); |
2854 | 0 | aWriter.attribute("bottom-dist", mnBottomDistance); |
2855 | 0 | aWriter.attribute("left-dist", mnLeftDistance); |
2856 | 0 | aWriter.attribute("right-dist", mnRightDistance); |
2857 | 0 | SfxPoolItem::dumpAsXml(pWriter); |
2858 | 0 | aWriter.endElement(); |
2859 | 0 | } |
2860 | | |
2861 | | boost::property_tree::ptree SvxBoxItem::dumpAsJSON() const |
2862 | 0 | { |
2863 | 0 | boost::property_tree::ptree aTree; |
2864 | |
|
2865 | 0 | boost::property_tree::ptree aState; |
2866 | 0 | aState.put("top", GetTop() && !GetTop()->isEmpty()); |
2867 | 0 | aState.put("bottom", GetBottom() && !GetBottom()->isEmpty()); |
2868 | 0 | aState.put("left", GetLeft() && !GetLeft()->isEmpty()); |
2869 | 0 | aState.put("right", GetRight() && !GetRight()->isEmpty()); |
2870 | |
|
2871 | 0 | aTree.push_back(std::make_pair("state", aState)); |
2872 | 0 | aTree.put("commandName", ".uno:BorderOuter"); |
2873 | |
|
2874 | 0 | return aTree; |
2875 | 0 | } |
2876 | | |
2877 | | |
2878 | | static bool CompareBorderLine(const std::unique_ptr<SvxBorderLine> & pBrd1, const SvxBorderLine* pBrd2) |
2879 | 51.9M | { |
2880 | 51.9M | if( pBrd1.get() == pBrd2 ) |
2881 | 15.4M | return true; |
2882 | 36.5M | if( pBrd1 == nullptr || pBrd2 == nullptr) |
2883 | 17.6M | return false; |
2884 | 18.8M | return *pBrd1 == *pBrd2; |
2885 | 36.5M | } |
2886 | | |
2887 | | |
2888 | | bool SvxBoxItem::operator==( const SfxPoolItem& rAttr ) const |
2889 | 35.5M | { |
2890 | 35.5M | assert(SfxPoolItem::operator==(rAttr)); |
2891 | | |
2892 | 35.5M | const SvxBoxItem& rBoxItem = static_cast<const SvxBoxItem&>(rAttr); |
2893 | 35.5M | return ( |
2894 | 35.5M | (mnTopDistance == rBoxItem.mnTopDistance) && |
2895 | 35.5M | (mnBottomDistance == rBoxItem.mnBottomDistance) && |
2896 | 35.5M | (mnLeftDistance == rBoxItem.mnLeftDistance) && |
2897 | 35.5M | (mnRightDistance == rBoxItem.mnRightDistance) && |
2898 | 35.5M | (mbRemoveAdjCellBorder == rBoxItem.mbRemoveAdjCellBorder ) && |
2899 | 35.5M | (maTempComplexColors == rBoxItem.maTempComplexColors) && |
2900 | 35.5M | CompareBorderLine(mpTopBorderLine, rBoxItem.GetTop()) && |
2901 | 7.50M | CompareBorderLine(mpBottomBorderLine, rBoxItem.GetBottom()) && |
2902 | 3.85M | CompareBorderLine(mpLeftBorderLine, rBoxItem.GetLeft()) && |
2903 | 3.20M | CompareBorderLine(mpRightBorderLine, rBoxItem.GetRight())); |
2904 | 35.5M | } |
2905 | | |
2906 | | size_t SvxBoxItem::hashCode() const |
2907 | 2.64M | { |
2908 | 2.64M | std::size_t seed(0); |
2909 | 2.64M | o3tl::hash_combine(seed, mnTopDistance); |
2910 | 2.64M | o3tl::hash_combine(seed, mnBottomDistance); |
2911 | 2.64M | o3tl::hash_combine(seed, mnLeftDistance); |
2912 | 2.64M | o3tl::hash_combine(seed, mnRightDistance); |
2913 | 2.64M | return seed; |
2914 | 2.64M | } |
2915 | | |
2916 | | table::BorderLine2 SvxBoxItem::SvxLineToLine(const SvxBorderLine* pLine, bool bConvert) |
2917 | 50.7k | { |
2918 | 50.7k | table::BorderLine2 aLine; |
2919 | 50.7k | if(pLine) |
2920 | 1.76k | { |
2921 | 1.76k | aLine.Color = sal_Int32(pLine->GetColor()); |
2922 | 1.76k | aLine.InnerLineWidth = sal_uInt16( bConvert ? convertTwipToMm100(pLine->GetInWidth() ): pLine->GetInWidth() ); |
2923 | 1.76k | aLine.OuterLineWidth = sal_uInt16( bConvert ? convertTwipToMm100(pLine->GetOutWidth()): pLine->GetOutWidth() ); |
2924 | 1.76k | aLine.LineDistance = sal_uInt16( bConvert ? convertTwipToMm100(pLine->GetDistance()): pLine->GetDistance() ); |
2925 | 1.76k | aLine.LineStyle = sal_Int16(pLine->GetBorderLineStyle()); |
2926 | 1.76k | aLine.LineWidth = sal_uInt32( bConvert ? convertTwipToMm100( pLine->GetWidth( ) ) : pLine->GetWidth( ) ); |
2927 | 1.76k | } |
2928 | 48.9k | else |
2929 | 48.9k | { |
2930 | 48.9k | aLine.Color = aLine.InnerLineWidth = aLine.OuterLineWidth = aLine.LineDistance = 0; |
2931 | 48.9k | aLine.LineStyle = table::BorderLineStyle::NONE; // 0 is SOLID! |
2932 | 48.9k | } |
2933 | 50.7k | return aLine; |
2934 | 50.7k | } |
2935 | | |
2936 | | bool SvxBoxItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
2937 | 112k | { |
2938 | 112k | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
2939 | 112k | table::BorderLine2 aRetLine; |
2940 | 112k | sal_Int16 nDist = 0; |
2941 | 112k | bool bDistMember = false; |
2942 | 112k | nMemberId &= ~CONVERT_TWIPS; |
2943 | 112k | switch(nMemberId) |
2944 | 112k | { |
2945 | 0 | case 0: |
2946 | 0 | { |
2947 | | // 4 Borders and 5 distances |
2948 | 0 | uno::Sequence< uno::Any > aSeq{ |
2949 | 0 | uno::Any(SvxBoxItem::SvxLineToLine(GetLeft(), bConvert)), |
2950 | 0 | uno::Any(SvxBoxItem::SvxLineToLine(GetRight(), bConvert)), |
2951 | 0 | uno::Any(SvxBoxItem::SvxLineToLine(GetBottom(), bConvert)), |
2952 | 0 | uno::Any(SvxBoxItem::SvxLineToLine(GetTop(), bConvert)), |
2953 | 0 | uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(GetSmallestDistance()) : GetSmallestDistance())), |
2954 | 0 | uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(mnTopDistance) : mnTopDistance)), |
2955 | 0 | uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(mnBottomDistance) : mnBottomDistance)), |
2956 | 0 | uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(mnLeftDistance) : mnLeftDistance)), |
2957 | 0 | uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(mnRightDistance) : mnRightDistance)) |
2958 | 0 | }; |
2959 | 0 | rVal <<= aSeq; |
2960 | 0 | return true; |
2961 | 0 | } |
2962 | 0 | case MID_LEFT_BORDER: |
2963 | 12.5k | case LEFT_BORDER: |
2964 | 12.5k | aRetLine = SvxBoxItem::SvxLineToLine(GetLeft(), bConvert); |
2965 | 12.5k | break; |
2966 | 0 | case MID_RIGHT_BORDER: |
2967 | 12.5k | case RIGHT_BORDER: |
2968 | 12.5k | aRetLine = SvxBoxItem::SvxLineToLine(GetRight(), bConvert); |
2969 | 12.5k | break; |
2970 | 0 | case MID_BOTTOM_BORDER: |
2971 | 13.1k | case BOTTOM_BORDER: |
2972 | 13.1k | aRetLine = SvxBoxItem::SvxLineToLine(GetBottom(), bConvert); |
2973 | 13.1k | break; |
2974 | 0 | case MID_TOP_BORDER: |
2975 | 12.5k | case TOP_BORDER: |
2976 | 12.5k | aRetLine = SvxBoxItem::SvxLineToLine(GetTop(), bConvert); |
2977 | 12.5k | break; |
2978 | 11.9k | case BORDER_DISTANCE: |
2979 | 11.9k | nDist = GetSmallestDistance(); |
2980 | 11.9k | bDistMember = true; |
2981 | 11.9k | break; |
2982 | 12.4k | case TOP_BORDER_DISTANCE: |
2983 | 12.4k | nDist = mnTopDistance; |
2984 | 12.4k | bDistMember = true; |
2985 | 12.4k | break; |
2986 | 12.4k | case BOTTOM_BORDER_DISTANCE: |
2987 | 12.4k | nDist = mnBottomDistance; |
2988 | 12.4k | bDistMember = true; |
2989 | 12.4k | break; |
2990 | 12.4k | case LEFT_BORDER_DISTANCE: |
2991 | 12.4k | nDist = mnLeftDistance; |
2992 | 12.4k | bDistMember = true; |
2993 | 12.4k | break; |
2994 | 12.4k | case RIGHT_BORDER_DISTANCE: |
2995 | 12.4k | nDist = mnRightDistance; |
2996 | 12.4k | bDistMember = true; |
2997 | 12.4k | break; |
2998 | 35 | case MID_BORDER_BOTTOM_COLOR: |
2999 | 35 | { |
3000 | 35 | if (mpBottomBorderLine) |
3001 | 0 | { |
3002 | 0 | rVal <<= model::color::createXComplexColor(mpBottomBorderLine->getComplexColor()); |
3003 | 0 | } |
3004 | 35 | else if (maTempComplexColors[size_t(SvxBoxItemLine::BOTTOM)].getType() != model::ColorType::Unused) |
3005 | 0 | { |
3006 | 0 | rVal <<= model::color::createXComplexColor(maTempComplexColors[size_t(SvxBoxItemLine::BOTTOM)]); |
3007 | 0 | } |
3008 | 35 | return true; |
3009 | 0 | } |
3010 | 35 | case MID_BORDER_LEFT_COLOR: |
3011 | 35 | { |
3012 | 35 | if (mpLeftBorderLine) |
3013 | 0 | { |
3014 | 0 | rVal <<= model::color::createXComplexColor(mpLeftBorderLine->getComplexColor()); |
3015 | 0 | } |
3016 | 35 | else if (maTempComplexColors[size_t(SvxBoxItemLine::LEFT)].getType() != model::ColorType::Unused) |
3017 | 0 | { |
3018 | 0 | rVal <<= model::color::createXComplexColor(maTempComplexColors[size_t(SvxBoxItemLine::LEFT)]); |
3019 | 0 | } |
3020 | 35 | return true; |
3021 | 0 | } |
3022 | 35 | case MID_BORDER_RIGHT_COLOR: |
3023 | 35 | { |
3024 | 35 | if (mpRightBorderLine) |
3025 | 0 | { |
3026 | 0 | rVal <<= model::color::createXComplexColor(mpRightBorderLine->getComplexColor()); |
3027 | 0 | } |
3028 | 35 | else if (maTempComplexColors[size_t(SvxBoxItemLine::RIGHT)].getType() != model::ColorType::Unused) |
3029 | 0 | { |
3030 | 0 | rVal <<= model::color::createXComplexColor(maTempComplexColors[size_t(SvxBoxItemLine::RIGHT)]); |
3031 | 0 | } |
3032 | 35 | return true; |
3033 | 0 | } |
3034 | 35 | case MID_BORDER_TOP_COLOR: |
3035 | 35 | { |
3036 | 35 | if (mpTopBorderLine) |
3037 | 0 | { |
3038 | 0 | rVal <<= model::color::createXComplexColor(mpTopBorderLine->getComplexColor()); |
3039 | 0 | } |
3040 | 35 | else if (maTempComplexColors[size_t(SvxBoxItemLine::TOP)].getType() != model::ColorType::Unused) |
3041 | 0 | { |
3042 | 0 | rVal <<= model::color::createXComplexColor(maTempComplexColors[size_t(SvxBoxItemLine::TOP)]); |
3043 | 0 | } |
3044 | 35 | return true; |
3045 | 0 | } |
3046 | 0 | case LINE_STYLE: |
3047 | 0 | case LINE_WIDTH: |
3048 | | // it doesn't make sense to return a value for these since it's |
3049 | | // probably ambiguous |
3050 | 0 | return true; |
3051 | 112k | } |
3052 | | |
3053 | 112k | if( bDistMember ) |
3054 | 61.7k | rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nDist) : nDist); |
3055 | 50.7k | else |
3056 | 50.7k | rVal <<= aRetLine; |
3057 | | |
3058 | 112k | return true; |
3059 | 112k | } |
3060 | | |
3061 | | namespace |
3062 | | { |
3063 | | |
3064 | | bool |
3065 | | lcl_lineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine, bool bConvert, bool bGuessWidth) |
3066 | 3.29M | { |
3067 | 3.29M | rSvxLine.SetColor( Color(ColorTransparency, rLine.Color)); |
3068 | 3.29M | if ( bGuessWidth ) |
3069 | 3.21M | { |
3070 | 3.21M | rSvxLine.GuessLinesWidths( rSvxLine.GetBorderLineStyle(), |
3071 | 3.21M | bConvert ? o3tl::toTwips(rLine.OuterLineWidth, o3tl::Length::mm100) : rLine.OuterLineWidth, |
3072 | 3.21M | bConvert ? o3tl::toTwips(rLine.InnerLineWidth, o3tl::Length::mm100) : rLine.InnerLineWidth, |
3073 | 3.21M | bConvert ? o3tl::toTwips(rLine.LineDistance, o3tl::Length::mm100) : rLine.LineDistance ); |
3074 | 3.21M | } |
3075 | | |
3076 | 3.29M | bool bRet = !rSvxLine.isEmpty(); |
3077 | 3.29M | return bRet; |
3078 | 3.29M | } |
3079 | | |
3080 | | } |
3081 | | |
3082 | | |
3083 | | bool SvxBoxItem::LineToSvxLine(const css::table::BorderLine& rLine, SvxBorderLine& rSvxLine, bool bConvert) |
3084 | 0 | { |
3085 | 0 | return lcl_lineToSvxLine(rLine, rSvxLine, bConvert, true); |
3086 | 0 | } |
3087 | | |
3088 | | bool |
3089 | | SvxBoxItem::LineToSvxLine(const css::table::BorderLine2& rLine, SvxBorderLine& rSvxLine, bool bConvert) |
3090 | 3.29M | { |
3091 | 3.29M | SvxBorderLineStyle const nStyle = |
3092 | 3.29M | (rLine.LineStyle < 0 || BORDER_LINE_STYLE_MAX < rLine.LineStyle) |
3093 | 3.29M | ? SvxBorderLineStyle::SOLID // default |
3094 | 3.29M | : static_cast<SvxBorderLineStyle>(rLine.LineStyle); |
3095 | | |
3096 | 3.29M | rSvxLine.SetBorderLineStyle( nStyle ); |
3097 | | |
3098 | 3.29M | bool bGuessWidth = true; |
3099 | 3.29M | if ( rLine.LineWidth ) |
3100 | 82.6k | { |
3101 | 82.6k | rSvxLine.SetWidth( bConvert? o3tl::toTwips(rLine.LineWidth, o3tl::Length::mm100) : rLine.LineWidth ); |
3102 | | // fdo#46112: double does not necessarily mean symmetric |
3103 | | // for backwards compatibility |
3104 | 82.6k | bGuessWidth = (SvxBorderLineStyle::DOUBLE == nStyle || SvxBorderLineStyle::DOUBLE_THIN == nStyle) && |
3105 | 1.82k | (rLine.InnerLineWidth > 0) && (rLine.OuterLineWidth > 0); |
3106 | 82.6k | } |
3107 | | |
3108 | 3.29M | return lcl_lineToSvxLine(rLine, rSvxLine, bConvert, bGuessWidth); |
3109 | 3.29M | } |
3110 | | |
3111 | | |
3112 | | namespace |
3113 | | { |
3114 | | |
3115 | | bool |
3116 | | lcl_extractBorderLine(const uno::Any& rAny, table::BorderLine2& rLine) |
3117 | 105k | { |
3118 | 105k | if (rAny >>= rLine) |
3119 | 105k | return true; |
3120 | | |
3121 | 0 | table::BorderLine aBorderLine; |
3122 | 0 | if (rAny >>= aBorderLine) |
3123 | 0 | { |
3124 | 0 | rLine.Color = aBorderLine.Color; |
3125 | 0 | rLine.InnerLineWidth = aBorderLine.InnerLineWidth; |
3126 | 0 | rLine.OuterLineWidth = aBorderLine.OuterLineWidth; |
3127 | 0 | rLine.LineDistance = aBorderLine.LineDistance; |
3128 | 0 | rLine.LineStyle = table::BorderLineStyle::SOLID; |
3129 | 0 | return true; |
3130 | 0 | } |
3131 | | |
3132 | 0 | return false; |
3133 | 0 | } |
3134 | | |
3135 | | template<typename Item, typename Line> |
3136 | | bool |
3137 | | lcl_setLine(const uno::Any& rAny, Item& rItem, Line nLine, const bool bConvert) |
3138 | 0 | { |
3139 | 0 | bool bDone = false; |
3140 | 0 | table::BorderLine2 aBorderLine; |
3141 | 0 | if (lcl_extractBorderLine(rAny, aBorderLine)) |
3142 | 0 | { |
3143 | 0 | SvxBorderLine aLine; |
3144 | 0 | bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert); |
3145 | 0 | rItem.SetLine( bSet ? &aLine : nullptr, nLine); |
3146 | 0 | bDone = true; |
3147 | 0 | } |
3148 | 0 | return bDone; |
3149 | 0 | } Unexecuted instantiation: frmitems.cxx:bool (anonymous namespace)::lcl_setLine<SvxBoxItem, SvxBoxItemLine>(com::sun::star::uno::Any const&, SvxBoxItem&, SvxBoxItemLine, bool) Unexecuted instantiation: frmitems.cxx:bool (anonymous namespace)::lcl_setLine<SvxBoxInfoItem, SvxBoxInfoItemLine>(com::sun::star::uno::Any const&, SvxBoxInfoItem&, SvxBoxInfoItemLine, bool) |
3150 | | |
3151 | | } |
3152 | | |
3153 | | bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
3154 | 254k | { |
3155 | 254k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
3156 | 254k | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
3157 | 254k | SvxBoxItemLine nLine = SvxBoxItemLine::TOP; |
3158 | 254k | bool bDistMember = false; |
3159 | 254k | nMemberId &= ~CONVERT_TWIPS; |
3160 | 254k | switch(nMemberId) |
3161 | 254k | { |
3162 | 0 | case 0: |
3163 | 0 | { |
3164 | 0 | uno::Sequence< uno::Any > aSeq; |
3165 | 0 | if (( rVal >>= aSeq ) && ( aSeq.getLength() == 9 )) |
3166 | 0 | { |
3167 | | // 4 Borders and 5 distances |
3168 | 0 | const SvxBoxItemLine aBorders[] = { SvxBoxItemLine::LEFT, SvxBoxItemLine::RIGHT, SvxBoxItemLine::BOTTOM, SvxBoxItemLine::TOP }; |
3169 | 0 | for (size_t n(0); n != std::size(aBorders); ++n) |
3170 | 0 | { |
3171 | 0 | if (!lcl_setLine(aSeq[n], *this, aBorders[n], bConvert)) |
3172 | 0 | return false; |
3173 | 0 | tryMigrateComplexColor(aBorders[n]); |
3174 | 0 | } |
3175 | | |
3176 | | // WTH are the borders and the distances saved in different order? |
3177 | 0 | SvxBoxItemLine const nLines[4] = { SvxBoxItemLine::TOP, SvxBoxItemLine::BOTTOM, SvxBoxItemLine::LEFT, SvxBoxItemLine::RIGHT }; |
3178 | 0 | for ( sal_Int32 n = 4; n < 9; n++ ) |
3179 | 0 | { |
3180 | 0 | sal_Int32 nDist = 0; |
3181 | 0 | if ( aSeq[n] >>= nDist ) |
3182 | 0 | { |
3183 | 0 | if( bConvert ) |
3184 | 0 | nDist = o3tl::toTwips(nDist, o3tl::Length::mm100); |
3185 | 0 | if ( n == 4 ) |
3186 | 0 | SetAllDistances(nDist); |
3187 | 0 | else |
3188 | 0 | SetDistance( nDist, nLines[n-5] ); |
3189 | 0 | } |
3190 | 0 | else |
3191 | 0 | return false; |
3192 | 0 | } |
3193 | | |
3194 | 0 | return true; |
3195 | 0 | } |
3196 | 0 | else |
3197 | 0 | return false; |
3198 | 0 | } |
3199 | 35.9k | case LEFT_BORDER_DISTANCE: |
3200 | 35.9k | bDistMember = true; |
3201 | 35.9k | [[fallthrough]]; |
3202 | 63.1k | case LEFT_BORDER: |
3203 | 63.1k | case MID_LEFT_BORDER: |
3204 | 63.1k | nLine = SvxBoxItemLine::LEFT; |
3205 | 63.1k | break; |
3206 | 35.5k | case RIGHT_BORDER_DISTANCE: |
3207 | 35.5k | bDistMember = true; |
3208 | 35.5k | [[fallthrough]]; |
3209 | 58.9k | case RIGHT_BORDER: |
3210 | 58.9k | case MID_RIGHT_BORDER: |
3211 | 58.9k | nLine = SvxBoxItemLine::RIGHT; |
3212 | 58.9k | break; |
3213 | 36.9k | case BOTTOM_BORDER_DISTANCE: |
3214 | 36.9k | bDistMember = true; |
3215 | 36.9k | [[fallthrough]]; |
3216 | 65.2k | case BOTTOM_BORDER: |
3217 | 65.2k | case MID_BOTTOM_BORDER: |
3218 | 65.2k | nLine = SvxBoxItemLine::BOTTOM; |
3219 | 65.2k | break; |
3220 | 37.4k | case TOP_BORDER_DISTANCE: |
3221 | 37.4k | bDistMember = true; |
3222 | 37.4k | [[fallthrough]]; |
3223 | 63.6k | case TOP_BORDER: |
3224 | 63.6k | case MID_TOP_BORDER: |
3225 | 63.6k | nLine = SvxBoxItemLine::TOP; |
3226 | 63.6k | break; |
3227 | 850 | case LINE_STYLE: |
3228 | 850 | { |
3229 | 850 | drawing::LineStyle eDrawingStyle; |
3230 | 850 | rVal >>= eDrawingStyle; |
3231 | 850 | SvxBorderLineStyle eBorderStyle = SvxBorderLineStyle::NONE; |
3232 | 850 | switch ( eDrawingStyle ) |
3233 | 850 | { |
3234 | 0 | default: |
3235 | 665 | case drawing::LineStyle_NONE: |
3236 | 665 | break; |
3237 | 185 | case drawing::LineStyle_SOLID: |
3238 | 185 | eBorderStyle = SvxBorderLineStyle::SOLID; |
3239 | 185 | break; |
3240 | 0 | case drawing::LineStyle_DASH: |
3241 | 0 | eBorderStyle = SvxBorderLineStyle::DASHED; |
3242 | 0 | break; |
3243 | 850 | } |
3244 | | |
3245 | | // Set the line style on all borders |
3246 | 850 | for( SvxBoxItemLine n : o3tl::enumrange<SvxBoxItemLine>() ) |
3247 | 3.40k | { |
3248 | 3.40k | editeng::SvxBorderLine* pLine = const_cast< editeng::SvxBorderLine* >( GetLine( n ) ); |
3249 | 3.40k | if( pLine ) |
3250 | 3.40k | pLine->SetBorderLineStyle( eBorderStyle ); |
3251 | 3.40k | } |
3252 | 850 | return true; |
3253 | 850 | } |
3254 | 0 | break; |
3255 | 0 | case LINE_WIDTH: |
3256 | 0 | { |
3257 | | // Set the line width on all borders |
3258 | 0 | tools::Long nWidth(0); |
3259 | 0 | rVal >>= nWidth; |
3260 | 0 | if( bConvert ) |
3261 | 0 | nWidth = o3tl::toTwips(nWidth, o3tl::Length::mm100); |
3262 | | |
3263 | | // Set the line Width on all borders |
3264 | 0 | for( SvxBoxItemLine n : o3tl::enumrange<SvxBoxItemLine>() ) |
3265 | 0 | { |
3266 | 0 | editeng::SvxBorderLine* pLine = const_cast< editeng::SvxBorderLine* >( GetLine( n ) ); |
3267 | 0 | if( pLine ) |
3268 | 0 | pLine->SetWidth( nWidth ); |
3269 | 0 | } |
3270 | 0 | } |
3271 | 0 | return true; |
3272 | 586 | case MID_BORDER_BOTTOM_COLOR: |
3273 | 586 | { |
3274 | 586 | if (mpBottomBorderLine) |
3275 | 331 | return mpBottomBorderLine->setComplexColorFromAny(rVal); |
3276 | 255 | else |
3277 | 255 | { |
3278 | 255 | css::uno::Reference<css::util::XComplexColor> xComplexColor; |
3279 | 255 | if (!(rVal >>= xComplexColor)) |
3280 | 35 | return false; |
3281 | | |
3282 | 220 | if (xComplexColor.is()) |
3283 | 220 | maTempComplexColors[size_t(SvxBoxItemLine::BOTTOM)] = model::color::getFromXComplexColor(xComplexColor); |
3284 | 220 | } |
3285 | 220 | return true; |
3286 | 586 | } |
3287 | 365 | case MID_BORDER_LEFT_COLOR: |
3288 | 365 | { |
3289 | 365 | if (mpLeftBorderLine) |
3290 | 198 | return mpLeftBorderLine->setComplexColorFromAny(rVal); |
3291 | 167 | else |
3292 | 167 | { |
3293 | 167 | css::uno::Reference<css::util::XComplexColor> xComplexColor; |
3294 | 167 | if (!(rVal >>= xComplexColor)) |
3295 | 35 | return false; |
3296 | | |
3297 | 132 | if (xComplexColor.is()) |
3298 | 132 | maTempComplexColors[size_t(SvxBoxItemLine::LEFT)] = model::color::getFromXComplexColor(xComplexColor); |
3299 | 132 | } |
3300 | 132 | return true; |
3301 | 365 | } |
3302 | 307 | case MID_BORDER_RIGHT_COLOR: |
3303 | 307 | { |
3304 | 307 | if (mpRightBorderLine) |
3305 | 138 | return mpRightBorderLine->setComplexColorFromAny(rVal); |
3306 | 169 | else |
3307 | 169 | { |
3308 | 169 | css::uno::Reference<css::util::XComplexColor> xComplexColor; |
3309 | 169 | if (!(rVal >>= xComplexColor)) |
3310 | 35 | return false; |
3311 | | |
3312 | 134 | if (xComplexColor.is()) |
3313 | 134 | maTempComplexColors[size_t(SvxBoxItemLine::RIGHT)] = model::color::getFromXComplexColor(xComplexColor); |
3314 | 134 | } |
3315 | 134 | return true; |
3316 | 307 | } |
3317 | 519 | case MID_BORDER_TOP_COLOR: |
3318 | 519 | { |
3319 | 519 | if (mpTopBorderLine) |
3320 | 265 | return mpTopBorderLine->setComplexColorFromAny(rVal); |
3321 | 254 | else |
3322 | 254 | { |
3323 | 254 | css::uno::Reference<css::util::XComplexColor> xComplexColor; |
3324 | 254 | if (!(rVal >>= xComplexColor)) |
3325 | 35 | return false; |
3326 | | |
3327 | 219 | if (xComplexColor.is()) |
3328 | 219 | maTempComplexColors[size_t(SvxBoxItemLine::TOP)] = model::color::getFromXComplexColor(xComplexColor); |
3329 | 219 | } |
3330 | 219 | return true; |
3331 | 519 | } |
3332 | 254k | } |
3333 | | |
3334 | 251k | if( bDistMember || nMemberId == BORDER_DISTANCE ) |
3335 | 146k | { |
3336 | 146k | sal_Int32 nDist = 0; |
3337 | 146k | if(!(rVal >>= nDist)) |
3338 | 0 | return false; |
3339 | | |
3340 | 146k | { |
3341 | 146k | if( bConvert ) |
3342 | 146k | nDist = o3tl::toTwips(nDist, o3tl::Length::mm100); |
3343 | 146k | if( nMemberId == BORDER_DISTANCE ) |
3344 | 480 | SetAllDistances(nDist); |
3345 | 145k | else |
3346 | 145k | SetDistance( nDist, nLine ); |
3347 | 146k | } |
3348 | 146k | } |
3349 | 105k | else |
3350 | 105k | { |
3351 | 105k | SvxBorderLine aLine; |
3352 | 105k | if( !rVal.hasValue() ) |
3353 | 0 | return false; |
3354 | | |
3355 | 105k | table::BorderLine2 aBorderLine; |
3356 | 105k | if( lcl_extractBorderLine(rVal, aBorderLine) ) |
3357 | 105k | { |
3358 | | // usual struct |
3359 | 105k | } |
3360 | 0 | else if (rVal.getValueTypeClass() == uno::TypeClass_SEQUENCE ) |
3361 | 0 | { |
3362 | | // serialization for basic macro recording |
3363 | 0 | uno::Reference < script::XTypeConverter > xConverter |
3364 | 0 | ( script::Converter::create(::comphelper::getProcessComponentContext()) ); |
3365 | 0 | uno::Sequence < uno::Any > aSeq; |
3366 | 0 | uno::Any aNew; |
3367 | 0 | try { aNew = xConverter->convertTo( rVal, cppu::UnoType<uno::Sequence < uno::Any >>::get() ); } |
3368 | 0 | catch (const uno::Exception&) {} |
3369 | |
|
3370 | 0 | aNew >>= aSeq; |
3371 | 0 | if (aSeq.getLength() >= 4 && aSeq.getLength() <= 6) |
3372 | 0 | { |
3373 | 0 | sal_Int32 nVal = 0; |
3374 | 0 | if ( aSeq[0] >>= nVal ) |
3375 | 0 | aBorderLine.Color = nVal; |
3376 | 0 | if ( aSeq[1] >>= nVal ) |
3377 | 0 | aBorderLine.InnerLineWidth = static_cast<sal_Int16>(nVal); |
3378 | 0 | if ( aSeq[2] >>= nVal ) |
3379 | 0 | aBorderLine.OuterLineWidth = static_cast<sal_Int16>(nVal); |
3380 | 0 | if ( aSeq[3] >>= nVal ) |
3381 | 0 | aBorderLine.LineDistance = static_cast<sal_Int16>(nVal); |
3382 | 0 | if (aSeq.getLength() >= 5) // fdo#40874 added fields |
3383 | 0 | { |
3384 | 0 | if (aSeq[4] >>= nVal) |
3385 | 0 | { |
3386 | 0 | aBorderLine.LineStyle = nVal; |
3387 | 0 | } |
3388 | 0 | if (aSeq.getLength() >= 6) |
3389 | 0 | { |
3390 | 0 | if (aSeq[5] >>= nVal) |
3391 | 0 | { |
3392 | 0 | aBorderLine.LineWidth = nVal; |
3393 | 0 | } |
3394 | 0 | } |
3395 | 0 | } |
3396 | 0 | } |
3397 | 0 | else |
3398 | 0 | return false; |
3399 | 0 | } |
3400 | 0 | else |
3401 | 0 | return false; |
3402 | | |
3403 | 105k | bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert); |
3404 | 105k | SetLine(bSet ? &aLine : nullptr, nLine); |
3405 | 105k | tryMigrateComplexColor(nLine); |
3406 | 105k | } |
3407 | | |
3408 | 251k | return true; |
3409 | 251k | } |
3410 | | |
3411 | | SvxBoxItem* SvxBoxItem::Clone( SfxItemPool* ) const |
3412 | 1.58M | { |
3413 | 1.58M | return new SvxBoxItem( *this ); |
3414 | 1.58M | } |
3415 | | |
3416 | | bool SvxBoxItem::GetPresentation |
3417 | | ( |
3418 | | SfxItemPresentation ePres, |
3419 | | MapUnit eCoreUnit, |
3420 | | MapUnit ePresUnit, |
3421 | | OUString& rText, const IntlWrapper& rIntl |
3422 | | ) const |
3423 | 0 | { |
3424 | 0 | OUString cpDelimTmp(cpDelim); |
3425 | 0 | switch ( ePres ) |
3426 | 0 | { |
3427 | 0 | case SfxItemPresentation::Nameless: |
3428 | 0 | { |
3429 | 0 | rText.clear(); |
3430 | |
|
3431 | 0 | if (mpTopBorderLine) |
3432 | 0 | { |
3433 | 0 | rText = mpTopBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; |
3434 | 0 | } |
3435 | 0 | if ( !(mpTopBorderLine && mpBottomBorderLine && mpLeftBorderLine && mpRightBorderLine && |
3436 | 0 | *mpTopBorderLine == *mpBottomBorderLine && |
3437 | 0 | *mpTopBorderLine == *mpLeftBorderLine && |
3438 | 0 | *mpTopBorderLine == *mpRightBorderLine)) |
3439 | 0 | { |
3440 | 0 | if (mpBottomBorderLine) |
3441 | 0 | { |
3442 | 0 | rText += mpBottomBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; |
3443 | 0 | } |
3444 | 0 | if (mpLeftBorderLine) |
3445 | 0 | { |
3446 | 0 | rText += mpLeftBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; |
3447 | 0 | } |
3448 | 0 | if (mpRightBorderLine) |
3449 | 0 | { |
3450 | 0 | rText += mpRightBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; |
3451 | 0 | } |
3452 | 0 | } |
3453 | 0 | rText += GetMetricText( static_cast<tools::Long>(mnTopDistance), eCoreUnit, ePresUnit, &rIntl ); |
3454 | 0 | if (mnTopDistance != mnBottomDistance || |
3455 | 0 | mnTopDistance != mnLeftDistance || |
3456 | 0 | mnTopDistance != mnRightDistance) |
3457 | 0 | { |
3458 | 0 | rText += cpDelimTmp + |
3459 | 0 | GetMetricText( tools::Long(mnBottomDistance), eCoreUnit, ePresUnit, &rIntl ) + |
3460 | 0 | cpDelimTmp + |
3461 | 0 | GetMetricText( tools::Long(mnLeftDistance), eCoreUnit, ePresUnit, &rIntl ) + |
3462 | 0 | cpDelimTmp + |
3463 | 0 | GetMetricText( tools::Long(mnRightDistance), eCoreUnit, ePresUnit, &rIntl ); |
3464 | 0 | } |
3465 | 0 | return true; |
3466 | 0 | } |
3467 | 0 | case SfxItemPresentation::Complete: |
3468 | 0 | { |
3469 | 0 | if (!(mpTopBorderLine || mpBottomBorderLine || mpLeftBorderLine || mpRightBorderLine)) |
3470 | 0 | { |
3471 | 0 | rText = EditResId(RID_SVXITEMS_BORDER_NONE) + cpDelimTmp; |
3472 | 0 | } |
3473 | 0 | else |
3474 | 0 | { |
3475 | 0 | rText = EditResId(RID_SVXITEMS_BORDER_COMPLETE); |
3476 | 0 | if (mpTopBorderLine && mpBottomBorderLine && mpLeftBorderLine && mpRightBorderLine && |
3477 | 0 | *mpTopBorderLine == *mpBottomBorderLine && |
3478 | 0 | *mpTopBorderLine == *mpLeftBorderLine && |
3479 | 0 | *mpTopBorderLine == *mpRightBorderLine) |
3480 | 0 | { |
3481 | 0 | rText += mpTopBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + cpDelimTmp; |
3482 | 0 | } |
3483 | 0 | else |
3484 | 0 | { |
3485 | 0 | if (mpTopBorderLine) |
3486 | 0 | { |
3487 | 0 | rText += EditResId(RID_SVXITEMS_BORDER_TOP) + |
3488 | 0 | mpTopBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + |
3489 | 0 | cpDelimTmp; |
3490 | 0 | } |
3491 | 0 | if (mpBottomBorderLine) |
3492 | 0 | { |
3493 | 0 | rText += EditResId(RID_SVXITEMS_BORDER_BOTTOM) + |
3494 | 0 | mpBottomBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + |
3495 | 0 | cpDelimTmp; |
3496 | 0 | } |
3497 | 0 | if (mpLeftBorderLine) |
3498 | 0 | { |
3499 | 0 | rText += EditResId(RID_SVXITEMS_BORDER_LEFT) + |
3500 | 0 | mpLeftBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + |
3501 | 0 | cpDelimTmp; |
3502 | 0 | } |
3503 | 0 | if (mpRightBorderLine) |
3504 | 0 | { |
3505 | 0 | rText += EditResId(RID_SVXITEMS_BORDER_RIGHT) + |
3506 | 0 | mpRightBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + |
3507 | 0 | cpDelimTmp; |
3508 | 0 | } |
3509 | 0 | } |
3510 | 0 | } |
3511 | |
|
3512 | 0 | rText += EditResId(RID_SVXITEMS_BORDER_DISTANCE); |
3513 | 0 | if (mnTopDistance == mnBottomDistance && |
3514 | 0 | mnTopDistance == mnLeftDistance && |
3515 | 0 | mnTopDistance == mnRightDistance) |
3516 | 0 | { |
3517 | 0 | rText += GetMetricText(tools::Long(mnTopDistance), eCoreUnit, ePresUnit, &rIntl ) + |
3518 | 0 | " " + EditResId(GetMetricId(ePresUnit)); |
3519 | 0 | } |
3520 | 0 | else |
3521 | 0 | { |
3522 | 0 | rText += EditResId(RID_SVXITEMS_BORDER_TOP) + |
3523 | 0 | GetMetricText(tools::Long(mnTopDistance), eCoreUnit, ePresUnit, &rIntl) + |
3524 | 0 | " " + EditResId(GetMetricId(ePresUnit)) + |
3525 | 0 | cpDelimTmp + |
3526 | 0 | EditResId(RID_SVXITEMS_BORDER_BOTTOM) + |
3527 | 0 | GetMetricText(tools::Long(mnBottomDistance), eCoreUnit, ePresUnit, &rIntl) + |
3528 | 0 | " " + EditResId(GetMetricId(ePresUnit)) + |
3529 | 0 | cpDelimTmp + |
3530 | 0 | EditResId(RID_SVXITEMS_BORDER_LEFT) + |
3531 | 0 | GetMetricText(tools::Long(mnLeftDistance), eCoreUnit, ePresUnit, &rIntl) + |
3532 | 0 | " " + EditResId(GetMetricId(ePresUnit)) + |
3533 | 0 | cpDelimTmp + |
3534 | 0 | EditResId(RID_SVXITEMS_BORDER_RIGHT) + |
3535 | 0 | GetMetricText(tools::Long(mnRightDistance), eCoreUnit, ePresUnit, &rIntl) + |
3536 | 0 | " " + EditResId(GetMetricId(ePresUnit)); |
3537 | 0 | } |
3538 | 0 | return true; |
3539 | 0 | } |
3540 | 0 | default: ; // prevent warning |
3541 | 0 | } |
3542 | 0 | return false; |
3543 | 0 | } |
3544 | | |
3545 | | |
3546 | | void SvxBoxItem::ScaleMetrics(double fScale) |
3547 | 0 | { |
3548 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
3549 | 0 | if (mpTopBorderLine) |
3550 | 0 | mpTopBorderLine->ScaleMetrics( fScale ); |
3551 | 0 | if (mpBottomBorderLine) |
3552 | 0 | mpBottomBorderLine->ScaleMetrics( fScale ); |
3553 | 0 | if (mpLeftBorderLine) |
3554 | 0 | mpLeftBorderLine->ScaleMetrics( fScale ); |
3555 | 0 | if (mpRightBorderLine) |
3556 | 0 | mpRightBorderLine->ScaleMetrics( fScale ); |
3557 | |
|
3558 | 0 | mnTopDistance = static_cast<sal_Int16>(BigInt::Scale(mnTopDistance, fScale)); |
3559 | 0 | mnBottomDistance = static_cast<sal_Int16>(BigInt::Scale(mnBottomDistance, fScale)); |
3560 | 0 | mnLeftDistance = static_cast<sal_Int16>(BigInt::Scale(mnLeftDistance, fScale)); |
3561 | 0 | mnRightDistance = static_cast<sal_Int16>(BigInt::Scale(mnRightDistance, fScale)); |
3562 | 0 | } |
3563 | | |
3564 | | |
3565 | | bool SvxBoxItem::HasMetrics() const |
3566 | 0 | { |
3567 | 0 | return true; |
3568 | 0 | } |
3569 | | |
3570 | | |
3571 | | const SvxBorderLine *SvxBoxItem::GetLine( SvxBoxItemLine nLine ) const |
3572 | 255k | { |
3573 | 255k | const SvxBorderLine *pRet = nullptr; |
3574 | | |
3575 | 255k | switch ( nLine ) |
3576 | 255k | { |
3577 | 58.9k | case SvxBoxItemLine::TOP: |
3578 | 58.9k | pRet = mpTopBorderLine.get(); |
3579 | 58.9k | break; |
3580 | 69.2k | case SvxBoxItemLine::BOTTOM: |
3581 | 69.2k | pRet = mpBottomBorderLine.get(); |
3582 | 69.2k | break; |
3583 | 59.8k | case SvxBoxItemLine::LEFT: |
3584 | 59.8k | pRet = mpLeftBorderLine.get(); |
3585 | 59.8k | break; |
3586 | 67.3k | case SvxBoxItemLine::RIGHT: |
3587 | 67.3k | pRet = mpRightBorderLine.get(); |
3588 | 67.3k | break; |
3589 | 0 | default: |
3590 | 0 | OSL_FAIL( "wrong line" ); |
3591 | 0 | break; |
3592 | 255k | } |
3593 | | |
3594 | 255k | return pRet; |
3595 | 255k | } |
3596 | | |
3597 | | |
3598 | | void SvxBoxItem::SetLine( const SvxBorderLine* pNew, SvxBoxItemLine nLine ) |
3599 | 3.02M | { |
3600 | 3.02M | ASSERT_CHANGE_REFCOUNTED_ITEM; |
3601 | 3.02M | std::unique_ptr<SvxBorderLine> pTmp( pNew ? new SvxBorderLine( *pNew ) : nullptr ); |
3602 | | |
3603 | 3.02M | switch ( nLine ) |
3604 | 3.02M | { |
3605 | 922k | case SvxBoxItemLine::TOP: |
3606 | 922k | mpTopBorderLine = std::move(pTmp); |
3607 | 922k | break; |
3608 | 802k | case SvxBoxItemLine::BOTTOM: |
3609 | 802k | mpBottomBorderLine = std::move(pTmp); |
3610 | 802k | break; |
3611 | 675k | case SvxBoxItemLine::LEFT: |
3612 | 675k | mpLeftBorderLine = std::move(pTmp); |
3613 | 675k | break; |
3614 | 630k | case SvxBoxItemLine::RIGHT: |
3615 | 630k | mpRightBorderLine = std::move(pTmp); |
3616 | 630k | break; |
3617 | 0 | default: |
3618 | 0 | OSL_FAIL( "wrong line" ); |
3619 | 3.02M | } |
3620 | 3.02M | } |
3621 | | |
3622 | | |
3623 | | sal_uInt16 SvxBoxItem::GetSmallestDistance() const |
3624 | 11.9k | { |
3625 | | // The smallest distance that is not 0 will be returned. |
3626 | 11.9k | sal_uInt16 nDist = mnTopDistance; |
3627 | 11.9k | if (mnBottomDistance && (!nDist || mnBottomDistance < nDist)) |
3628 | 209 | nDist = mnBottomDistance; |
3629 | 11.9k | if (mnLeftDistance && (!nDist || mnLeftDistance < nDist)) |
3630 | 209 | nDist = mnLeftDistance; |
3631 | 11.9k | if (mnRightDistance && (!nDist || mnRightDistance < nDist)) |
3632 | 209 | nDist = mnRightDistance; |
3633 | | |
3634 | 11.9k | return nDist; |
3635 | 11.9k | } |
3636 | | |
3637 | | |
3638 | | sal_Int16 SvxBoxItem::GetDistance( SvxBoxItemLine nLine, bool bAllowNegative ) const |
3639 | 882k | { |
3640 | 882k | sal_Int16 nDist = 0; |
3641 | 882k | switch ( nLine ) |
3642 | 882k | { |
3643 | 123k | case SvxBoxItemLine::TOP: |
3644 | 123k | nDist = mnTopDistance; |
3645 | 123k | break; |
3646 | 125k | case SvxBoxItemLine::BOTTOM: |
3647 | 125k | nDist = mnBottomDistance; |
3648 | 125k | break; |
3649 | 217k | case SvxBoxItemLine::LEFT: |
3650 | 217k | nDist = mnLeftDistance; |
3651 | 217k | break; |
3652 | 416k | case SvxBoxItemLine::RIGHT: |
3653 | 416k | nDist = mnRightDistance; |
3654 | 416k | break; |
3655 | 0 | default: |
3656 | 0 | OSL_FAIL( "wrong line" ); |
3657 | 882k | } |
3658 | | |
3659 | 882k | if (!bAllowNegative && nDist < 0) |
3660 | 0 | { |
3661 | 0 | nDist = 0; |
3662 | 0 | } |
3663 | 882k | return nDist; |
3664 | 882k | } |
3665 | | |
3666 | | |
3667 | | void SvxBoxItem::SetDistance( sal_Int16 nNew, SvxBoxItemLine nLine ) |
3668 | 1.09M | { |
3669 | 1.09M | ASSERT_CHANGE_REFCOUNTED_ITEM; |
3670 | 1.09M | switch ( nLine ) |
3671 | 1.09M | { |
3672 | 256k | case SvxBoxItemLine::TOP: |
3673 | 256k | mnTopDistance = nNew; |
3674 | 256k | break; |
3675 | 312k | case SvxBoxItemLine::BOTTOM: |
3676 | 312k | mnBottomDistance = nNew; |
3677 | 312k | break; |
3678 | 284k | case SvxBoxItemLine::LEFT: |
3679 | 284k | mnLeftDistance = nNew; |
3680 | 284k | break; |
3681 | 244k | case SvxBoxItemLine::RIGHT: |
3682 | 244k | mnRightDistance = nNew; |
3683 | 244k | break; |
3684 | 0 | default: |
3685 | 0 | OSL_FAIL( "wrong line" ); |
3686 | 1.09M | } |
3687 | 1.09M | } |
3688 | | |
3689 | | sal_uInt16 SvxBoxItem::CalcLineWidth( SvxBoxItemLine nLine ) const |
3690 | 392 | { |
3691 | 392 | SvxBorderLine* pTmp = nullptr; |
3692 | 392 | sal_uInt16 nWidth = 0; |
3693 | 392 | switch ( nLine ) |
3694 | 392 | { |
3695 | 98 | case SvxBoxItemLine::TOP: |
3696 | 98 | pTmp = mpTopBorderLine.get(); |
3697 | 98 | break; |
3698 | 98 | case SvxBoxItemLine::BOTTOM: |
3699 | 98 | pTmp = mpBottomBorderLine.get(); |
3700 | 98 | break; |
3701 | 98 | case SvxBoxItemLine::LEFT: |
3702 | 98 | pTmp = mpLeftBorderLine.get(); |
3703 | 98 | break; |
3704 | 98 | case SvxBoxItemLine::RIGHT: |
3705 | 98 | pTmp = mpRightBorderLine.get(); |
3706 | 98 | break; |
3707 | 0 | default: |
3708 | 0 | OSL_FAIL( "wrong line" ); |
3709 | 392 | } |
3710 | | |
3711 | 392 | if( pTmp ) |
3712 | 333 | nWidth = pTmp->GetScaledWidth(); |
3713 | | |
3714 | 392 | return nWidth; |
3715 | 392 | } |
3716 | | |
3717 | | sal_Int16 SvxBoxItem::CalcLineSpace( SvxBoxItemLine nLine, bool bEvenIfNoLine, bool bAllowNegative ) const |
3718 | 152k | { |
3719 | 152k | SvxBorderLine* pTmp = nullptr; |
3720 | 152k | sal_Int16 nDist = 0; |
3721 | 152k | switch ( nLine ) |
3722 | 152k | { |
3723 | 31.5k | case SvxBoxItemLine::TOP: |
3724 | 31.5k | pTmp = mpTopBorderLine.get(); |
3725 | 31.5k | nDist = mnTopDistance; |
3726 | 31.5k | break; |
3727 | 31.2k | case SvxBoxItemLine::BOTTOM: |
3728 | 31.2k | pTmp = mpBottomBorderLine.get(); |
3729 | 31.2k | nDist = mnBottomDistance; |
3730 | 31.2k | break; |
3731 | 32.2k | case SvxBoxItemLine::LEFT: |
3732 | 32.2k | pTmp = mpLeftBorderLine.get(); |
3733 | 32.2k | nDist = mnLeftDistance; |
3734 | 32.2k | break; |
3735 | 57.2k | case SvxBoxItemLine::RIGHT: |
3736 | 57.2k | pTmp = mpRightBorderLine.get(); |
3737 | 57.2k | nDist = mnRightDistance; |
3738 | 57.2k | break; |
3739 | 0 | default: |
3740 | 0 | OSL_FAIL( "wrong line" ); |
3741 | 152k | } |
3742 | | |
3743 | 152k | if( pTmp ) |
3744 | 14.7k | { |
3745 | 14.7k | nDist = nDist + pTmp->GetScaledWidth(); |
3746 | 14.7k | } |
3747 | 137k | else if( !bEvenIfNoLine ) |
3748 | 22.6k | nDist = 0; |
3749 | | |
3750 | 152k | if (!bAllowNegative && nDist < 0) |
3751 | 0 | { |
3752 | 0 | nDist = 0; |
3753 | 0 | } |
3754 | | |
3755 | 152k | return nDist; |
3756 | 152k | } |
3757 | | |
3758 | | void SvxBoxItem::tryMigrateComplexColor(SvxBoxItemLine eLine) |
3759 | 105k | { |
3760 | 105k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
3761 | 105k | if (!GetLine(eLine)) |
3762 | 22.2k | return; |
3763 | | |
3764 | 83.0k | auto nIndex = size_t(eLine); |
3765 | | |
3766 | 83.0k | if (maTempComplexColors[nIndex].getType() == model::ColorType::Unused) |
3767 | 83.0k | return; |
3768 | | |
3769 | 16 | switch (eLine) |
3770 | 16 | { |
3771 | 12 | case SvxBoxItemLine::TOP: |
3772 | 12 | mpTopBorderLine->setComplexColor(maTempComplexColors[nIndex]); |
3773 | 12 | break; |
3774 | 4 | case SvxBoxItemLine::BOTTOM: |
3775 | 4 | mpBottomBorderLine->setComplexColor(maTempComplexColors[nIndex]); |
3776 | 4 | break; |
3777 | 0 | case SvxBoxItemLine::LEFT: |
3778 | 0 | mpLeftBorderLine->setComplexColor(maTempComplexColors[nIndex]); |
3779 | 0 | break; |
3780 | 0 | case SvxBoxItemLine::RIGHT: |
3781 | 0 | mpRightBorderLine->setComplexColor(maTempComplexColors[nIndex]); |
3782 | 0 | break; |
3783 | 16 | } |
3784 | | |
3785 | 16 | maTempComplexColors[nIndex] = model::ComplexColor(); |
3786 | 16 | } |
3787 | | |
3788 | | bool SvxBoxItem::HasBorder( bool bTreatPaddingAsBorder ) const |
3789 | 0 | { |
3790 | 0 | return CalcLineSpace( SvxBoxItemLine::BOTTOM, bTreatPaddingAsBorder ) |
3791 | 0 | || CalcLineSpace( SvxBoxItemLine::RIGHT, bTreatPaddingAsBorder ) |
3792 | 0 | || CalcLineSpace( SvxBoxItemLine::TOP, bTreatPaddingAsBorder ) |
3793 | 0 | || CalcLineSpace( SvxBoxItemLine::LEFT, bTreatPaddingAsBorder ); |
3794 | 0 | } |
3795 | | |
3796 | | // class SvxBoxInfoItem -------------------------------------------------- |
3797 | | |
3798 | | SvxBoxInfoItem::SvxBoxInfoItem(const sal_uInt16 nId) |
3799 | 1.37M | : SfxPoolItem(nId) |
3800 | 1.37M | , mbDistance(false) |
3801 | 1.37M | , mbMinimumDistance(false) |
3802 | 1.37M | { |
3803 | 1.37M | ResetFlags(); |
3804 | 1.37M | } |
3805 | | |
3806 | | SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem& rCopy ) |
3807 | 3.01M | : SfxPoolItem(rCopy) |
3808 | 3.01M | , mpHorizontalLine(rCopy.mpHorizontalLine ? new SvxBorderLine(*rCopy.mpHorizontalLine) : nullptr) |
3809 | 3.01M | , mpVerticalLine(rCopy.mpVerticalLine ? new SvxBorderLine(*rCopy.mpVerticalLine) : nullptr) |
3810 | 3.01M | , mbEnableHorizontalLine(rCopy.mbEnableHorizontalLine) |
3811 | 3.01M | , mbEnableVerticalLine(rCopy.mbEnableVerticalLine) |
3812 | 3.01M | , mbDistance(rCopy.mbDistance) |
3813 | 3.01M | , mbMinimumDistance (rCopy.mbMinimumDistance) |
3814 | 3.01M | , mnValidFlags(rCopy.mnValidFlags) |
3815 | 3.01M | , mnDefaultMinimumDistance(rCopy.mnDefaultMinimumDistance) |
3816 | 3.01M | { |
3817 | 3.01M | } |
3818 | | |
3819 | | SvxBoxInfoItem::~SvxBoxInfoItem() |
3820 | 4.38M | { |
3821 | 4.38M | } |
3822 | | |
3823 | | |
3824 | | boost::property_tree::ptree SvxBoxInfoItem::dumpAsJSON() const |
3825 | 0 | { |
3826 | 0 | boost::property_tree::ptree aTree; |
3827 | |
|
3828 | 0 | boost::property_tree::ptree aState; |
3829 | 0 | aState.put("vertical", GetVert() && !GetVert()->isEmpty()); |
3830 | 0 | aState.put("horizontal", GetHori() && !GetHori()->isEmpty()); |
3831 | |
|
3832 | 0 | aTree.push_back(std::make_pair("state", aState)); |
3833 | 0 | aTree.put("commandName", ".uno:BorderInner"); |
3834 | |
|
3835 | 0 | return aTree; |
3836 | 0 | } |
3837 | | |
3838 | | |
3839 | | bool SvxBoxInfoItem::operator==( const SfxPoolItem& rAttr ) const |
3840 | 1.48M | { |
3841 | 1.48M | assert(SfxPoolItem::operator==(rAttr)); |
3842 | | |
3843 | 1.48M | const SvxBoxInfoItem& rBoxInfo = static_cast<const SvxBoxInfoItem&>(rAttr); |
3844 | | |
3845 | 1.48M | return (mbEnableHorizontalLine == rBoxInfo.mbEnableHorizontalLine |
3846 | 1.48M | && mbEnableVerticalLine == rBoxInfo.mbEnableVerticalLine |
3847 | 1.48M | && mbDistance == rBoxInfo.mbDistance |
3848 | 1.18M | && mbMinimumDistance == rBoxInfo.mbMinimumDistance |
3849 | 1.18M | && mnValidFlags == rBoxInfo.mnValidFlags |
3850 | 1.18M | && mnDefaultMinimumDistance == rBoxInfo.mnDefaultMinimumDistance |
3851 | 1.18M | && CompareBorderLine(mpHorizontalLine, rBoxInfo.GetHori()) |
3852 | 258k | && CompareBorderLine(mpVerticalLine, rBoxInfo.GetVert())); |
3853 | 1.48M | } |
3854 | | |
3855 | | |
3856 | | void SvxBoxInfoItem::SetLine( const SvxBorderLine* pNew, SvxBoxInfoItemLine nLine ) |
3857 | 198k | { |
3858 | 198k | std::unique_ptr<SvxBorderLine> pCopy(pNew ? new SvxBorderLine(*pNew) : nullptr); |
3859 | | |
3860 | 198k | if ( SvxBoxInfoItemLine::HORI == nLine ) |
3861 | 112k | { |
3862 | 112k | mpHorizontalLine = std::move(pCopy); |
3863 | 112k | } |
3864 | 85.3k | else if ( SvxBoxInfoItemLine::VERT == nLine ) |
3865 | 85.3k | { |
3866 | 85.3k | mpVerticalLine = std::move(pCopy); |
3867 | 85.3k | } |
3868 | 0 | else |
3869 | 0 | { |
3870 | 0 | OSL_FAIL( "wrong line" ); |
3871 | 0 | } |
3872 | 198k | } |
3873 | | |
3874 | | SvxBoxInfoItem* SvxBoxInfoItem::Clone( SfxItemPool* ) const |
3875 | 3.01M | { |
3876 | 3.01M | return new SvxBoxInfoItem( *this ); |
3877 | 3.01M | } |
3878 | | |
3879 | | bool SvxBoxInfoItem::GetPresentation |
3880 | | ( |
3881 | | SfxItemPresentation /*ePres*/, |
3882 | | MapUnit /*eCoreUnit*/, |
3883 | | MapUnit /*ePresUnit*/, |
3884 | | OUString& rText, const IntlWrapper& |
3885 | | ) const |
3886 | 0 | { |
3887 | 0 | rText.clear(); |
3888 | 0 | return false; |
3889 | 0 | } |
3890 | | |
3891 | | |
3892 | | void SvxBoxInfoItem::ScaleMetrics( double fScale ) |
3893 | 0 | { |
3894 | 0 | if (mpHorizontalLine) |
3895 | 0 | mpHorizontalLine->ScaleMetrics(fScale); |
3896 | 0 | if (mpVerticalLine) |
3897 | 0 | mpVerticalLine->ScaleMetrics(fScale); |
3898 | 0 | mnDefaultMinimumDistance = sal_uInt16(BigInt::Scale(mnDefaultMinimumDistance, fScale)); |
3899 | 0 | } |
3900 | | |
3901 | | |
3902 | | bool SvxBoxInfoItem::HasMetrics() const |
3903 | 0 | { |
3904 | 0 | return true; |
3905 | 0 | } |
3906 | | |
3907 | | |
3908 | | void SvxBoxInfoItem::ResetFlags() |
3909 | 1.37M | { |
3910 | 1.37M | mnValidFlags = static_cast<SvxBoxInfoItemValidFlags>(0x7F); // all valid except Disable |
3911 | 1.37M | } |
3912 | | |
3913 | | bool SvxBoxInfoItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
3914 | 0 | { |
3915 | 0 | bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); |
3916 | 0 | table::BorderLine2 aRetLine; |
3917 | 0 | sal_Int16 nVal=0; |
3918 | 0 | bool bIntMember = false; |
3919 | 0 | nMemberId &= ~CONVERT_TWIPS; |
3920 | 0 | switch(nMemberId) |
3921 | 0 | { |
3922 | 0 | case 0: |
3923 | 0 | { |
3924 | | // 2 BorderLines, flags, valid flags and distance |
3925 | 0 | if ( IsTable() ) |
3926 | 0 | nVal |= 0x01; |
3927 | 0 | if ( IsDist() ) |
3928 | 0 | nVal |= 0x02; |
3929 | 0 | if ( IsMinDist() ) |
3930 | 0 | nVal |= 0x04; |
3931 | 0 | css::uno::Sequence< css::uno::Any > aSeq{ |
3932 | 0 | uno::Any(SvxBoxItem::SvxLineToLine(mpHorizontalLine.get(), bConvert)), |
3933 | 0 | uno::Any(SvxBoxItem::SvxLineToLine(mpVerticalLine.get(), bConvert)), |
3934 | 0 | uno::Any(nVal), |
3935 | 0 | uno::Any(static_cast<sal_Int16>(mnValidFlags)), |
3936 | 0 | uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(GetDefDist()) : GetDefDist())) |
3937 | 0 | }; |
3938 | 0 | rVal <<= aSeq; |
3939 | 0 | return true; |
3940 | 0 | } |
3941 | | |
3942 | 0 | case MID_HORIZONTAL: |
3943 | 0 | aRetLine = SvxBoxItem::SvxLineToLine(mpHorizontalLine.get(), bConvert); |
3944 | 0 | break; |
3945 | 0 | case MID_VERTICAL: |
3946 | 0 | aRetLine = SvxBoxItem::SvxLineToLine(mpVerticalLine.get(), bConvert); |
3947 | 0 | break; |
3948 | 0 | case MID_FLAGS: |
3949 | 0 | bIntMember = true; |
3950 | 0 | if ( IsTable() ) |
3951 | 0 | nVal |= 0x01; |
3952 | 0 | if ( IsDist() ) |
3953 | 0 | nVal |= 0x02; |
3954 | 0 | if ( IsMinDist() ) |
3955 | 0 | nVal |= 0x04; |
3956 | 0 | rVal <<= nVal; |
3957 | 0 | break; |
3958 | 0 | case MID_VALIDFLAGS: |
3959 | 0 | bIntMember = true; |
3960 | 0 | rVal <<= static_cast<sal_Int16>(mnValidFlags); |
3961 | 0 | break; |
3962 | 0 | case MID_DISTANCE: |
3963 | 0 | bIntMember = true; |
3964 | 0 | rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(GetDefDist()) : GetDefDist()); |
3965 | 0 | break; |
3966 | 0 | default: OSL_FAIL("Wrong MemberId!"); return false; |
3967 | 0 | } |
3968 | | |
3969 | 0 | if( !bIntMember ) |
3970 | 0 | rVal <<= aRetLine; |
3971 | |
|
3972 | 0 | return true; |
3973 | 0 | } |
3974 | | |
3975 | | |
3976 | | bool SvxBoxInfoItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
3977 | 0 | { |
3978 | 0 | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
3979 | 0 | nMemberId &= ~CONVERT_TWIPS; |
3980 | 0 | bool bRet; |
3981 | 0 | switch(nMemberId) |
3982 | 0 | { |
3983 | 0 | case 0: |
3984 | 0 | { |
3985 | 0 | css::uno::Sequence< css::uno::Any > aSeq; |
3986 | 0 | if (( rVal >>= aSeq ) && ( aSeq.getLength() == 5 )) |
3987 | 0 | { |
3988 | | // 2 BorderLines, flags, valid flags and distance |
3989 | 0 | if (!lcl_setLine(aSeq[0], *this, SvxBoxInfoItemLine::HORI, bConvert)) |
3990 | 0 | return false; |
3991 | 0 | if (!lcl_setLine(aSeq[1], *this, SvxBoxInfoItemLine::VERT, bConvert)) |
3992 | 0 | return false; |
3993 | | |
3994 | 0 | sal_Int16 nFlags( 0 ); |
3995 | 0 | sal_Int32 nVal( 0 ); |
3996 | 0 | if ( aSeq[2] >>= nFlags ) |
3997 | 0 | { |
3998 | 0 | SetTable ( ( nFlags & 0x01 ) != 0 ); |
3999 | 0 | SetDist ( ( nFlags & 0x02 ) != 0 ); |
4000 | 0 | SetMinDist( ( nFlags & 0x04 ) != 0 ); |
4001 | 0 | } |
4002 | 0 | else |
4003 | 0 | return false; |
4004 | 0 | if ( aSeq[3] >>= nFlags ) |
4005 | 0 | mnValidFlags = static_cast<SvxBoxInfoItemValidFlags>(nFlags); |
4006 | 0 | else |
4007 | 0 | return false; |
4008 | 0 | if (( aSeq[4] >>= nVal ) && ( nVal >= 0 )) |
4009 | 0 | { |
4010 | 0 | if( bConvert ) |
4011 | 0 | nVal = o3tl::toTwips(nVal, o3tl::Length::mm100); |
4012 | 0 | SetDefDist( nVal ); |
4013 | 0 | } |
4014 | 0 | } |
4015 | 0 | return true; |
4016 | 0 | } |
4017 | | |
4018 | 0 | case MID_HORIZONTAL: |
4019 | 0 | case MID_VERTICAL: |
4020 | 0 | { |
4021 | 0 | if( !rVal.hasValue() ) |
4022 | 0 | return false; |
4023 | | |
4024 | 0 | table::BorderLine2 aBorderLine; |
4025 | 0 | if( lcl_extractBorderLine(rVal, aBorderLine) ) |
4026 | 0 | { |
4027 | | // usual struct |
4028 | 0 | } |
4029 | 0 | else if (rVal.getValueTypeClass() == uno::TypeClass_SEQUENCE ) |
4030 | 0 | { |
4031 | | // serialization for basic macro recording |
4032 | 0 | uno::Reference < script::XTypeConverter > xConverter( script::Converter::create(::comphelper::getProcessComponentContext()) ); |
4033 | 0 | uno::Any aNew; |
4034 | 0 | uno::Sequence < uno::Any > aSeq; |
4035 | 0 | try { aNew = xConverter->convertTo( rVal, cppu::UnoType<uno::Sequence < uno::Any >>::get() ); } |
4036 | 0 | catch (const uno::Exception&) {} |
4037 | |
|
4038 | 0 | if ((aNew >>= aSeq) && |
4039 | 0 | aSeq.getLength() >= 4 && aSeq.getLength() <= 6) |
4040 | 0 | { |
4041 | 0 | sal_Int32 nVal = 0; |
4042 | 0 | if ( aSeq[0] >>= nVal ) |
4043 | 0 | aBorderLine.Color = nVal; |
4044 | 0 | if ( aSeq[1] >>= nVal ) |
4045 | 0 | aBorderLine.InnerLineWidth = static_cast<sal_Int16>(nVal); |
4046 | 0 | if ( aSeq[2] >>= nVal ) |
4047 | 0 | aBorderLine.OuterLineWidth = static_cast<sal_Int16>(nVal); |
4048 | 0 | if ( aSeq[3] >>= nVal ) |
4049 | 0 | aBorderLine.LineDistance = static_cast<sal_Int16>(nVal); |
4050 | 0 | if (aSeq.getLength() >= 5) // fdo#40874 added fields |
4051 | 0 | { |
4052 | 0 | if (aSeq[4] >>= nVal) |
4053 | 0 | { |
4054 | 0 | aBorderLine.LineStyle = nVal; |
4055 | 0 | } |
4056 | 0 | if (aSeq.getLength() >= 6) |
4057 | 0 | { |
4058 | 0 | if (aSeq[5] >>= nVal) |
4059 | 0 | { |
4060 | 0 | aBorderLine.LineWidth = nVal; |
4061 | 0 | } |
4062 | 0 | } |
4063 | 0 | } |
4064 | 0 | } |
4065 | 0 | else |
4066 | 0 | return false; |
4067 | 0 | } |
4068 | 0 | else if (rVal.getValueType() == cppu::UnoType<css::uno::Sequence < sal_Int16 >>::get() ) |
4069 | 0 | { |
4070 | | // serialization for basic macro recording |
4071 | 0 | css::uno::Sequence < sal_Int16 > aSeq; |
4072 | 0 | rVal >>= aSeq; |
4073 | 0 | if (aSeq.getLength() >= 4 && aSeq.getLength() <= 6) |
4074 | 0 | { |
4075 | 0 | aBorderLine.Color = aSeq[0]; |
4076 | 0 | aBorderLine.InnerLineWidth = aSeq[1]; |
4077 | 0 | aBorderLine.OuterLineWidth = aSeq[2]; |
4078 | 0 | aBorderLine.LineDistance = aSeq[3]; |
4079 | 0 | if (aSeq.getLength() >= 5) // fdo#40874 added fields |
4080 | 0 | { |
4081 | 0 | aBorderLine.LineStyle = aSeq[4]; |
4082 | 0 | if (aSeq.getLength() >= 6) |
4083 | 0 | { |
4084 | 0 | aBorderLine.LineWidth = aSeq[5]; |
4085 | 0 | } |
4086 | 0 | } |
4087 | 0 | } |
4088 | 0 | else |
4089 | 0 | return false; |
4090 | 0 | } |
4091 | 0 | else |
4092 | 0 | return false; |
4093 | | |
4094 | 0 | SvxBorderLine aLine; |
4095 | 0 | bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert); |
4096 | 0 | if ( bSet ) |
4097 | 0 | SetLine( &aLine, nMemberId == MID_HORIZONTAL ? SvxBoxInfoItemLine::HORI : SvxBoxInfoItemLine::VERT ); |
4098 | 0 | break; |
4099 | 0 | } |
4100 | 0 | case MID_FLAGS: |
4101 | 0 | { |
4102 | 0 | sal_Int16 nFlags = sal_Int16(); |
4103 | 0 | bRet = (rVal >>= nFlags); |
4104 | 0 | if ( bRet ) |
4105 | 0 | { |
4106 | 0 | SetTable ( ( nFlags & 0x01 ) != 0 ); |
4107 | 0 | SetDist ( ( nFlags & 0x02 ) != 0 ); |
4108 | 0 | SetMinDist( ( nFlags & 0x04 ) != 0 ); |
4109 | 0 | } |
4110 | |
|
4111 | 0 | break; |
4112 | 0 | } |
4113 | 0 | case MID_VALIDFLAGS: |
4114 | 0 | { |
4115 | 0 | sal_Int16 nFlags = sal_Int16(); |
4116 | 0 | bRet = (rVal >>= nFlags); |
4117 | 0 | if ( bRet ) |
4118 | 0 | mnValidFlags = static_cast<SvxBoxInfoItemValidFlags>(nFlags); |
4119 | 0 | break; |
4120 | 0 | } |
4121 | 0 | case MID_DISTANCE: |
4122 | 0 | { |
4123 | 0 | sal_Int32 nVal = 0; |
4124 | 0 | bRet = (rVal >>= nVal); |
4125 | 0 | if ( bRet && nVal>=0 ) |
4126 | 0 | { |
4127 | 0 | if( bConvert ) |
4128 | 0 | nVal = o3tl::toTwips(nVal, o3tl::Length::mm100); |
4129 | 0 | SetDefDist( static_cast<sal_uInt16>(nVal) ); |
4130 | 0 | } |
4131 | 0 | break; |
4132 | 0 | } |
4133 | 0 | default: OSL_FAIL("Wrong MemberId!"); return false; |
4134 | 0 | } |
4135 | | |
4136 | 0 | return true; |
4137 | 0 | } |
4138 | | |
4139 | | |
4140 | | namespace editeng |
4141 | | { |
4142 | | |
4143 | | void BorderDistanceFromWord(bool bFromEdge, sal_Int32& nMargin, sal_Int32& nBorderDistance, |
4144 | | sal_Int32 nBorderWidth) |
4145 | 2.13k | { |
4146 | | // See https://wiki.openoffice.org/wiki/Writer/MSInteroperability/PageBorder |
4147 | | |
4148 | 2.13k | sal_Int32 nNewMargin = nMargin; |
4149 | 2.13k | sal_Int32 nNewBorderDistance = nBorderDistance; |
4150 | | |
4151 | 2.13k | if (bFromEdge) |
4152 | 916 | { |
4153 | 916 | nNewMargin = nBorderDistance; |
4154 | 916 | nNewBorderDistance = nMargin - nBorderDistance - nBorderWidth; |
4155 | 916 | } |
4156 | 1.22k | else |
4157 | 1.22k | { |
4158 | 1.22k | nNewMargin -= nBorderDistance + nBorderWidth; |
4159 | 1.22k | } |
4160 | | |
4161 | | // Ensure correct distance from page edge to text in cases not supported by us: |
4162 | | // when border is outside entire page area (!bFromEdge && BorderDistance > Margin), |
4163 | | // and when border is inside page body area (bFromEdge && BorderDistance > Margin) |
4164 | 2.13k | if (nNewMargin < 0) |
4165 | 46 | { |
4166 | 46 | nNewMargin = 0; |
4167 | 46 | nNewBorderDistance = std::max<sal_Int32>(nMargin - nBorderWidth, 0); |
4168 | 46 | } |
4169 | 2.09k | else if (nNewBorderDistance < 0) |
4170 | 354 | { |
4171 | 354 | nNewMargin = nMargin; |
4172 | 354 | } |
4173 | | |
4174 | 2.13k | nMargin = nNewMargin; |
4175 | 2.13k | nBorderDistance = nNewBorderDistance; |
4176 | 2.13k | } |
4177 | | |
4178 | | // Heuristics to decide if we need to use "from edge" offset of borders |
4179 | | // |
4180 | | // There are two cases when we can safely use "from text" or "from edge" offset without distorting |
4181 | | // border position (modulo rounding errors): |
4182 | | // 1. When distance of all borders from text is no greater than 31 pt, we use "from text" |
4183 | | // 2. Otherwise, if distance of all borders from edge is no greater than 31 pt, we use "from edge" |
4184 | | // In all other cases, the position of borders would be distorted on export, because Word doesn't |
4185 | | // support the offset of >31 pts (https://msdn.microsoft.com/en-us/library/ff533820), and we need |
4186 | | // to decide which type of offset would provide less wrong result (i.e., the result would look |
4187 | | // closer to original). Here, we just check sum of distances from text to borders, and if it is |
4188 | | // less than sum of distances from borders to edges. The alternative would be to compare total areas |
4189 | | // between text-and-borders and between borders-and-edges (taking into account different lengths of |
4190 | | // borders, and visual impact of that). |
4191 | | void BorderDistancesToWord(const SvxBoxItem& rBox, const WordPageMargins& rMargins, |
4192 | | WordBorderDistances& rDistances) |
4193 | 0 | { |
4194 | | // Use signed sal_Int32 that can hold sal_uInt16, to prevent overflow at subtraction below |
4195 | 0 | const sal_Int32 nT = rBox.GetDistance(SvxBoxItemLine::TOP, /*bAllowNegative=*/true); |
4196 | 0 | const sal_Int32 nL = rBox.GetDistance(SvxBoxItemLine::LEFT, /*bAllowNegative=*/true); |
4197 | 0 | const sal_Int32 nB = rBox.GetDistance(SvxBoxItemLine::BOTTOM, /*bAllowNegative=*/true); |
4198 | 0 | const sal_Int32 nR = rBox.GetDistance(SvxBoxItemLine::RIGHT, /*bAllowNegative=*/true); |
4199 | | |
4200 | | // Only take into account existing borders |
4201 | 0 | const SvxBorderLine* pLnT = rBox.GetLine(SvxBoxItemLine::TOP); |
4202 | 0 | const SvxBorderLine* pLnL = rBox.GetLine(SvxBoxItemLine::LEFT); |
4203 | 0 | const SvxBorderLine* pLnB = rBox.GetLine(SvxBoxItemLine::BOTTOM); |
4204 | 0 | const SvxBorderLine* pLnR = rBox.GetLine(SvxBoxItemLine::RIGHT); |
4205 | | |
4206 | | // We need to take border widths into account |
4207 | 0 | const tools::Long nWidthT = pLnT ? pLnT->GetScaledWidth() : 0; |
4208 | 0 | const tools::Long nWidthL = pLnL ? pLnL->GetScaledWidth() : 0; |
4209 | 0 | const tools::Long nWidthB = pLnB ? pLnB->GetScaledWidth() : 0; |
4210 | 0 | const tools::Long nWidthR = pLnR ? pLnR->GetScaledWidth() : 0; |
4211 | | |
4212 | | // Resulting distances from text to borders |
4213 | 0 | const sal_Int32 nT2BT = pLnT ? nT : 0; |
4214 | 0 | const sal_Int32 nT2BL = pLnL ? nL : 0; |
4215 | 0 | const sal_Int32 nT2BB = pLnB ? nB : 0; |
4216 | 0 | const sal_Int32 nT2BR = pLnR ? nR : 0; |
4217 | | |
4218 | | // Resulting distances from edge to borders |
4219 | 0 | const sal_Int32 nE2BT = pLnT ? std::max<sal_Int32>(rMargins.nTop - nT - nWidthT, 0) : 0; |
4220 | 0 | const sal_Int32 nE2BL = pLnL ? std::max<sal_Int32>(rMargins.nLeft - nL - nWidthL, 0) : 0; |
4221 | 0 | const sal_Int32 nE2BB = pLnB ? std::max<sal_Int32>(rMargins.nBottom - nB - nWidthB, 0) : 0; |
4222 | 0 | const sal_Int32 nE2BR = pLnR ? std::max<sal_Int32>(rMargins.nRight - nR - nWidthR, 0) : 0; |
4223 | |
|
4224 | 0 | const sal_Int32 n32pt = 32 * 20; |
4225 | | // 1. If all borders are in range of 31 pts from text |
4226 | 0 | if (nT2BT >= 0 && nT2BT < n32pt && nT2BL >= 0 && nT2BL < n32pt && nT2BB >= 0 && nT2BB < n32pt && nT2BR >= 0 && nT2BR < n32pt) |
4227 | 0 | { |
4228 | 0 | rDistances.bFromEdge = false; |
4229 | 0 | } |
4230 | 0 | else |
4231 | 0 | { |
4232 | | // 2. If all borders are in range of 31 pts from edge |
4233 | 0 | if (nE2BT < n32pt && nE2BL < n32pt && nE2BB < n32pt && nE2BR < n32pt) |
4234 | 0 | { |
4235 | 0 | rDistances.bFromEdge = true; |
4236 | 0 | } |
4237 | 0 | else |
4238 | 0 | { |
4239 | | // Let's try to guess which would be the best approximation |
4240 | 0 | rDistances.bFromEdge = |
4241 | 0 | (nT2BT + nT2BL + nT2BB + nT2BR) > (nE2BT + nE2BL + nE2BB + nE2BR); |
4242 | 0 | } |
4243 | 0 | } |
4244 | |
|
4245 | 0 | if (rDistances.bFromEdge) |
4246 | 0 | { |
4247 | 0 | rDistances.nTop = sal::static_int_cast<sal_uInt16>(nE2BT); |
4248 | 0 | rDistances.nLeft = sal::static_int_cast<sal_uInt16>(nE2BL); |
4249 | 0 | rDistances.nBottom = sal::static_int_cast<sal_uInt16>(nE2BB); |
4250 | 0 | rDistances.nRight = sal::static_int_cast<sal_uInt16>(nE2BR); |
4251 | 0 | } |
4252 | 0 | else |
4253 | 0 | { |
4254 | 0 | rDistances.nTop = sal::static_int_cast<sal_uInt16>(nT2BT); |
4255 | 0 | rDistances.nLeft = sal::static_int_cast<sal_uInt16>(nT2BL); |
4256 | 0 | rDistances.nBottom = sal::static_int_cast<sal_uInt16>(nT2BB); |
4257 | 0 | rDistances.nRight = sal::static_int_cast<sal_uInt16>(nT2BR); |
4258 | 0 | } |
4259 | 0 | } |
4260 | | |
4261 | | } |
4262 | | |
4263 | | // class SvxFormatBreakItem ------------------------------------------------- |
4264 | | |
4265 | | bool SvxFormatBreakItem::operator==( const SfxPoolItem& rAttr ) const |
4266 | 3.47M | { |
4267 | 3.47M | assert(SfxPoolItem::operator==(rAttr)); |
4268 | | |
4269 | 3.47M | return GetValue() == static_cast<const SvxFormatBreakItem&>( rAttr ).GetValue(); |
4270 | 3.47M | } |
4271 | | |
4272 | | |
4273 | | bool SvxFormatBreakItem::GetPresentation |
4274 | | ( |
4275 | | SfxItemPresentation /*ePres*/, |
4276 | | MapUnit /*eCoreUnit*/, |
4277 | | MapUnit /*ePresUnit*/, |
4278 | | OUString& rText, const IntlWrapper& |
4279 | | ) const |
4280 | 0 | { |
4281 | 0 | rText = GetValueTextByPos( GetEnumValue() ); |
4282 | 0 | return true; |
4283 | 0 | } |
4284 | | |
4285 | | OUString SvxFormatBreakItem::GetValueTextByPos( sal_uInt16 nPos ) |
4286 | 0 | { |
4287 | 0 | static const TranslateId RID_SVXITEMS_BREAK[] = |
4288 | 0 | { |
4289 | 0 | RID_SVXITEMS_BREAK_NONE, |
4290 | 0 | RID_SVXITEMS_BREAK_COLUMN_BEFORE, |
4291 | 0 | RID_SVXITEMS_BREAK_COLUMN_AFTER, |
4292 | 0 | RID_SVXITEMS_BREAK_COLUMN_BOTH, |
4293 | 0 | RID_SVXITEMS_BREAK_PAGE_BEFORE, |
4294 | 0 | RID_SVXITEMS_BREAK_PAGE_AFTER, |
4295 | 0 | RID_SVXITEMS_BREAK_PAGE_BOTH |
4296 | 0 | }; |
4297 | 0 | static_assert(std::size(RID_SVXITEMS_BREAK) == size_t(SvxBreak::End), "unexpected size"); |
4298 | 0 | assert(nPos < sal_uInt16(SvxBreak::End) && "enum overflow!"); |
4299 | 0 | return EditResId(RID_SVXITEMS_BREAK[nPos]); |
4300 | 0 | } |
4301 | | |
4302 | | bool SvxFormatBreakItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const |
4303 | 270 | { |
4304 | 270 | style::BreakType eBreak = style::BreakType_NONE; |
4305 | 270 | switch ( GetBreak() ) |
4306 | 270 | { |
4307 | 0 | case SvxBreak::ColumnBefore: eBreak = style::BreakType_COLUMN_BEFORE; break; |
4308 | 0 | case SvxBreak::ColumnAfter: eBreak = style::BreakType_COLUMN_AFTER ; break; |
4309 | 0 | case SvxBreak::ColumnBoth: eBreak = style::BreakType_COLUMN_BOTH ; break; |
4310 | 0 | case SvxBreak::PageBefore: eBreak = style::BreakType_PAGE_BEFORE ; break; |
4311 | 0 | case SvxBreak::PageAfter: eBreak = style::BreakType_PAGE_AFTER ; break; |
4312 | 0 | case SvxBreak::PageBoth: eBreak = style::BreakType_PAGE_BOTH ; break; |
4313 | 270 | default: ; // prevent warning |
4314 | 270 | } |
4315 | 270 | rVal <<= eBreak; |
4316 | 270 | return true; |
4317 | 270 | } |
4318 | | |
4319 | | bool SvxFormatBreakItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) |
4320 | 845 | { |
4321 | 845 | style::BreakType nBreak; |
4322 | | |
4323 | 845 | if(!(rVal >>= nBreak)) |
4324 | 0 | { |
4325 | 0 | sal_Int32 nValue = 0; |
4326 | 0 | if(!(rVal >>= nValue)) |
4327 | 0 | return false; |
4328 | | |
4329 | 0 | nBreak = static_cast<style::BreakType>(nValue); |
4330 | 0 | } |
4331 | | |
4332 | 845 | SvxBreak eBreak = SvxBreak::NONE; |
4333 | 845 | switch( nBreak ) |
4334 | 845 | { |
4335 | 58 | case style::BreakType_COLUMN_BEFORE: eBreak = SvxBreak::ColumnBefore; break; |
4336 | 0 | case style::BreakType_COLUMN_AFTER: eBreak = SvxBreak::ColumnAfter; break; |
4337 | 0 | case style::BreakType_COLUMN_BOTH: eBreak = SvxBreak::ColumnBoth; break; |
4338 | 773 | case style::BreakType_PAGE_BEFORE: eBreak = SvxBreak::PageBefore; break; |
4339 | 0 | case style::BreakType_PAGE_AFTER: eBreak = SvxBreak::PageAfter; break; |
4340 | 0 | case style::BreakType_PAGE_BOTH: eBreak = SvxBreak::PageBoth; break; |
4341 | 14 | default: ; // prevent warning |
4342 | 845 | } |
4343 | 845 | SetValue(eBreak); |
4344 | | |
4345 | 845 | return true; |
4346 | 845 | } |
4347 | | |
4348 | | SvxFormatBreakItem* SvxFormatBreakItem::Clone( SfxItemPool* ) const |
4349 | 527k | { |
4350 | 527k | return new SvxFormatBreakItem( *this ); |
4351 | 527k | } |
4352 | | |
4353 | | SvxFormatKeepItem* SvxFormatKeepItem::Clone( SfxItemPool* ) const |
4354 | 242k | { |
4355 | 242k | return new SvxFormatKeepItem( *this ); |
4356 | 242k | } |
4357 | | |
4358 | | bool SvxFormatKeepItem::GetPresentation |
4359 | | ( |
4360 | | SfxItemPresentation /*ePres*/, |
4361 | | MapUnit /*eCoreUnit*/, |
4362 | | MapUnit /*ePresUnit*/, |
4363 | | OUString& rText, const IntlWrapper& |
4364 | | ) const |
4365 | 0 | { |
4366 | 0 | TranslateId pId = RID_SVXITEMS_FMTKEEP_FALSE; |
4367 | |
|
4368 | 0 | if ( GetValue() ) |
4369 | 0 | pId = RID_SVXITEMS_FMTKEEP_TRUE; |
4370 | 0 | rText = EditResId(pId); |
4371 | 0 | return true; |
4372 | 0 | } |
4373 | | |
4374 | | void SvxFormatKeepItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
4375 | 0 | { |
4376 | 0 | tools::XmlWriter aWriter(pWriter); |
4377 | 0 | aWriter.startElement("SvxFormatKeepItem"); |
4378 | 0 | SfxBoolItem::dumpAsXml(pWriter); |
4379 | 0 | aWriter.endElement(); |
4380 | 0 | } |
4381 | | |
4382 | | SvxLineItem::SvxLineItem( const sal_uInt16 nId ) : |
4383 | 64.5k | SfxPoolItem ( nId ) |
4384 | 64.5k | { |
4385 | 64.5k | } |
4386 | | |
4387 | | |
4388 | | SvxLineItem::SvxLineItem( const SvxLineItem& rCpy ) : |
4389 | 57.5k | SfxPoolItem ( rCpy ), |
4390 | 57.5k | pLine(rCpy.pLine ? new SvxBorderLine( *rCpy.pLine ) : nullptr) |
4391 | 57.5k | { |
4392 | 57.5k | } |
4393 | | |
4394 | | |
4395 | | SvxLineItem::~SvxLineItem() |
4396 | 122k | { |
4397 | 122k | } |
4398 | | |
4399 | | |
4400 | | bool SvxLineItem::operator==( const SfxPoolItem& rAttr ) const |
4401 | 385k | { |
4402 | 385k | assert(SfxPoolItem::operator==(rAttr)); |
4403 | | |
4404 | 385k | return CompareBorderLine(pLine, static_cast<const SvxLineItem&>(rAttr).GetLine()); |
4405 | 385k | } |
4406 | | |
4407 | | SvxLineItem* SvxLineItem::Clone( SfxItemPool* ) const |
4408 | 57.5k | { |
4409 | 57.5k | return new SvxLineItem( *this ); |
4410 | 57.5k | } |
4411 | | |
4412 | | bool SvxLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemId ) const |
4413 | 0 | { |
4414 | 0 | bool bConvert = 0!=(nMemId&CONVERT_TWIPS); |
4415 | 0 | nMemId &= ~CONVERT_TWIPS; |
4416 | 0 | if ( nMemId == 0 ) |
4417 | 0 | { |
4418 | 0 | rVal <<= SvxBoxItem::SvxLineToLine(pLine.get(), bConvert); |
4419 | 0 | return true; |
4420 | 0 | } |
4421 | 0 | else if ( pLine ) |
4422 | 0 | { |
4423 | 0 | switch ( nMemId ) |
4424 | 0 | { |
4425 | 0 | case MID_FG_COLOR: rVal <<= pLine->GetColor(); break; |
4426 | 0 | case MID_OUTER_WIDTH: rVal <<= sal_Int32(pLine->GetOutWidth()); break; |
4427 | 0 | case MID_INNER_WIDTH: rVal <<= sal_Int32(pLine->GetInWidth( )); break; |
4428 | 0 | case MID_DISTANCE: rVal <<= sal_Int32(pLine->GetDistance()); break; |
4429 | 0 | default: |
4430 | 0 | OSL_FAIL( "Wrong MemberId" ); |
4431 | 0 | return false; |
4432 | 0 | } |
4433 | 0 | } |
4434 | | |
4435 | 0 | return true; |
4436 | 0 | } |
4437 | | |
4438 | | |
4439 | | bool SvxLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemId ) |
4440 | 0 | { |
4441 | 0 | bool bConvert = 0!=(nMemId&CONVERT_TWIPS); |
4442 | 0 | nMemId &= ~CONVERT_TWIPS; |
4443 | 0 | sal_Int32 nVal = 0; |
4444 | 0 | if ( nMemId == 0 ) |
4445 | 0 | { |
4446 | 0 | table::BorderLine2 aLine; |
4447 | 0 | if ( lcl_extractBorderLine(rVal, aLine) ) |
4448 | 0 | { |
4449 | 0 | if ( !pLine ) |
4450 | 0 | pLine.reset( new SvxBorderLine ); |
4451 | 0 | if( !SvxBoxItem::LineToSvxLine(aLine, *pLine, bConvert) ) |
4452 | 0 | pLine.reset(); |
4453 | 0 | return true; |
4454 | 0 | } |
4455 | 0 | return false; |
4456 | 0 | } |
4457 | 0 | else if ( rVal >>= nVal ) |
4458 | 0 | { |
4459 | 0 | if ( !pLine ) |
4460 | 0 | pLine.reset( new SvxBorderLine ); |
4461 | |
|
4462 | 0 | switch ( nMemId ) |
4463 | 0 | { |
4464 | 0 | case MID_FG_COLOR: pLine->SetColor( Color(ColorTransparency, nVal) ); break; |
4465 | 0 | case MID_LINE_STYLE: |
4466 | 0 | pLine->SetBorderLineStyle(static_cast<SvxBorderLineStyle>(nVal)); |
4467 | 0 | break; |
4468 | 0 | default: |
4469 | 0 | OSL_FAIL( "Wrong MemberId" ); |
4470 | 0 | return false; |
4471 | 0 | } |
4472 | | |
4473 | 0 | return true; |
4474 | 0 | } |
4475 | | |
4476 | 0 | return false; |
4477 | 0 | } |
4478 | | |
4479 | | |
4480 | | bool SvxLineItem::GetPresentation |
4481 | | ( |
4482 | | SfxItemPresentation ePres, |
4483 | | MapUnit eCoreUnit, |
4484 | | MapUnit ePresUnit, |
4485 | | OUString& rText, const IntlWrapper& rIntl |
4486 | | ) const |
4487 | 0 | { |
4488 | 0 | rText.clear(); |
4489 | |
|
4490 | 0 | if ( pLine ) |
4491 | 0 | rText = pLine->GetValueString( eCoreUnit, ePresUnit, &rIntl, |
4492 | 0 | (SfxItemPresentation::Complete == ePres) ); |
4493 | 0 | return true; |
4494 | 0 | } |
4495 | | |
4496 | | |
4497 | | void SvxLineItem::ScaleMetrics(double fScale) |
4498 | 0 | { |
4499 | 0 | if ( pLine ) pLine->ScaleMetrics( fScale ); |
4500 | 0 | } |
4501 | | |
4502 | | |
4503 | | bool SvxLineItem::HasMetrics() const |
4504 | 0 | { |
4505 | 0 | return true; |
4506 | 0 | } |
4507 | | |
4508 | | |
4509 | | void SvxLineItem::SetLine( const SvxBorderLine* pNew ) |
4510 | 39 | { |
4511 | 39 | pLine.reset( pNew ? new SvxBorderLine( *pNew ) : nullptr ); |
4512 | 39 | } |
4513 | | |
4514 | | ItemInstanceManager* SvxBrushItem::getItemInstanceManager() const |
4515 | 1.37M | { |
4516 | 1.37M | static DefaultItemInstanceManager aInstanceManager(ItemType()); |
4517 | 1.37M | return &aInstanceManager; |
4518 | 1.37M | } |
4519 | | |
4520 | | SvxBrushItem::SvxBrushItem(sal_uInt16 _nWhich) |
4521 | 1.04M | : SfxPoolItem(_nWhich ) |
4522 | 1.04M | { |
4523 | 1.04M | } |
4524 | | |
4525 | | SvxBrushItem::SvxBrushItem(const Color& rColor, sal_uInt16 _nWhich) |
4526 | 145k | : SfxPoolItem(_nWhich ) |
4527 | 145k | , maColor(rColor) |
4528 | 145k | { |
4529 | 145k | } |
4530 | | |
4531 | | SvxBrushItem::SvxBrushItem(Color const& rColor, model::ComplexColor const& rComplexColor, sal_uInt16 nWhich) |
4532 | 1.77k | : SfxPoolItem(nWhich) |
4533 | 1.77k | , maColor(rColor) |
4534 | 1.77k | , maComplexColor(rComplexColor) |
4535 | 1.77k | { |
4536 | 1.77k | } |
4537 | | |
4538 | | SvxBrushItem::SvxBrushItem(const Graphic& rGraphic, SvxGraphicPosition ePos, sal_uInt16 _nWhich) |
4539 | 1.48k | : SfxPoolItem(_nWhich) |
4540 | 1.48k | , mxGraphicObject(new GraphicObject(rGraphic)) |
4541 | 1.48k | , meGraphicPos((GPOS_NONE != ePos) ? ePos : GPOS_MM) |
4542 | 1.48k | { |
4543 | 1.48k | DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" ); |
4544 | 1.48k | } |
4545 | | |
4546 | | SvxBrushItem::SvxBrushItem(const GraphicObject& rGraphicObj, SvxGraphicPosition ePos, sal_uInt16 _nWhich) |
4547 | 0 | : SfxPoolItem(_nWhich) |
4548 | 0 | , mxGraphicObject(new GraphicObject(rGraphicObj)) |
4549 | 0 | , meGraphicPos((GPOS_NONE != ePos) ? ePos : GPOS_MM) |
4550 | 0 | { |
4551 | 0 | DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" ); |
4552 | 0 | } |
4553 | | |
4554 | | SvxBrushItem::SvxBrushItem(OUString aLink, OUString aFilter, |
4555 | | SvxGraphicPosition ePos, sal_uInt16 _nWhich) |
4556 | 54 | : SfxPoolItem(_nWhich) |
4557 | 54 | , maStrLink(std::move(aLink)) |
4558 | 54 | , maStrFilter(std::move(aFilter)) |
4559 | 54 | , meGraphicPos((GPOS_NONE != ePos) ? ePos : GPOS_MM) |
4560 | 54 | { |
4561 | 54 | DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" ); |
4562 | 54 | } |
4563 | | |
4564 | | SvxBrushItem::SvxBrushItem(const SvxBrushItem& rItem) |
4565 | 1.17M | : SfxPoolItem(rItem) |
4566 | 1.17M | , maColor(rItem.maColor) |
4567 | 1.17M | , maComplexColor(rItem.maComplexColor) |
4568 | 1.17M | , maFilterColor(rItem.maFilterColor) |
4569 | 1.17M | , mnShadingValue(rItem.mnShadingValue) |
4570 | 1.17M | , mxGraphicObject(rItem.mxGraphicObject ? new GraphicObject(*rItem.mxGraphicObject) : nullptr) |
4571 | 1.17M | , mnGraphicTransparency(rItem.mnGraphicTransparency) |
4572 | 1.17M | , maStrLink(rItem.maStrLink) |
4573 | 1.17M | , maStrFilter(rItem.maStrFilter) |
4574 | 1.17M | , meGraphicPos(rItem.meGraphicPos) |
4575 | 1.17M | , mbLoadAgain(rItem.mbLoadAgain) |
4576 | 1.17M | { |
4577 | 1.17M | } |
4578 | | |
4579 | | SvxBrushItem::SvxBrushItem(SvxBrushItem&& rItem) |
4580 | 0 | : SfxPoolItem(std::move(rItem)) |
4581 | 0 | , maColor(std::move(rItem.maColor)) |
4582 | 0 | , maComplexColor(std::move(rItem.maComplexColor)) |
4583 | 0 | , maFilterColor(std::move(rItem.maFilterColor)) |
4584 | 0 | , mnShadingValue(std::move(rItem.mnShadingValue)) |
4585 | 0 | , mxGraphicObject(std::move(rItem.mxGraphicObject)) |
4586 | 0 | , mnGraphicTransparency(std::move(rItem.mnGraphicTransparency)) |
4587 | 0 | , maStrLink(std::move(rItem.maStrLink)) |
4588 | 0 | , maStrFilter(std::move(rItem.maStrFilter)) |
4589 | 0 | , meGraphicPos(std::move(rItem.meGraphicPos)) |
4590 | 0 | , mbLoadAgain(std::move(rItem.mbLoadAgain)) |
4591 | 0 | { |
4592 | 0 | } |
4593 | | |
4594 | | SvxBrushItem::~SvxBrushItem() |
4595 | 2.36M | { |
4596 | 2.36M | } |
4597 | | |
4598 | | bool SvxBrushItem::isUsed() const |
4599 | 0 | { |
4600 | 0 | if (GPOS_NONE != GetGraphicPos()) |
4601 | 0 | { |
4602 | | // graphic used |
4603 | 0 | return true; |
4604 | 0 | } |
4605 | 0 | else if (!GetColor().IsFullyTransparent()) |
4606 | 0 | { |
4607 | | // color used |
4608 | 0 | return true; |
4609 | 0 | } |
4610 | | |
4611 | 0 | return false; |
4612 | 0 | } |
4613 | | |
4614 | | |
4615 | | static sal_Int8 lcl_PercentToTransparency(tools::Long nPercent) |
4616 | 645 | { |
4617 | | // 0xff must not be returned! |
4618 | 645 | return sal_Int8(nPercent ? (50 + 0xfe * nPercent) / 100 : 0); |
4619 | 645 | } |
4620 | | |
4621 | | |
4622 | | sal_Int8 SvxBrushItem::TransparencyToPercent(sal_Int32 nTrans) |
4623 | 717 | { |
4624 | 717 | return static_cast<sal_Int8>((nTrans * 100 + 127) / 254); |
4625 | 717 | } |
4626 | | |
4627 | | |
4628 | | bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
4629 | 14.0k | { |
4630 | 14.0k | nMemberId &= ~CONVERT_TWIPS; |
4631 | 14.0k | switch( nMemberId) |
4632 | 14.0k | { |
4633 | 13.0k | case MID_BACK_COLOR: |
4634 | 13.0k | rVal <<= maColor; |
4635 | 13.0k | break; |
4636 | 0 | case MID_BACK_COLOR_R_G_B: |
4637 | 0 | rVal <<= maColor.GetRGBColor(); |
4638 | 0 | break; |
4639 | 717 | case MID_BACK_COLOR_TRANSPARENCY: |
4640 | 717 | rVal <<= SvxBrushItem::TransparencyToPercent(255 - maColor.GetAlpha()); |
4641 | 717 | break; |
4642 | | |
4643 | 35 | case MID_BACKGROUND_COMPLEX_COLOR: |
4644 | 35 | { |
4645 | 35 | auto xComplexColor = model::color::createXComplexColor(maComplexColor); |
4646 | 35 | rVal <<= xComplexColor; |
4647 | 35 | break; |
4648 | 0 | } |
4649 | 0 | break; |
4650 | | |
4651 | 58 | case MID_GRAPHIC_POSITION: |
4652 | 58 | rVal <<= static_cast<style::GraphicLocation>(static_cast<sal_Int16>(meGraphicPos)); |
4653 | 58 | break; |
4654 | | |
4655 | 58 | case MID_GRAPHIC_TRANSPARENT: |
4656 | 58 | rVal <<= (maColor.GetAlpha() == 0 ); |
4657 | 58 | break; |
4658 | | |
4659 | 0 | case MID_GRAPHIC_URL: |
4660 | 58 | case MID_GRAPHIC: |
4661 | 58 | { |
4662 | 58 | uno::Reference<graphic::XGraphic> xGraphic; |
4663 | 58 | if (!maStrLink.isEmpty()) |
4664 | 0 | { |
4665 | 0 | Graphic aGraphic(vcl::graphic::loadFromURL(maStrLink)); |
4666 | 0 | xGraphic = aGraphic.GetXGraphic(); |
4667 | 0 | } |
4668 | 58 | else if (mxGraphicObject) |
4669 | 0 | { |
4670 | 0 | xGraphic = mxGraphicObject->GetGraphic().GetXGraphic(); |
4671 | 0 | } |
4672 | 58 | rVal <<= xGraphic; |
4673 | 58 | } |
4674 | 58 | break; |
4675 | | |
4676 | 58 | case MID_GRAPHIC_FILTER: |
4677 | 58 | { |
4678 | 58 | rVal <<= maStrFilter; |
4679 | 58 | } |
4680 | 58 | break; |
4681 | | |
4682 | 0 | case MID_GRAPHIC_TRANSPARENCY: |
4683 | 0 | rVal <<= mnGraphicTransparency; |
4684 | 0 | break; |
4685 | | |
4686 | 0 | case MID_SHADING_VALUE: |
4687 | 0 | { |
4688 | 0 | rVal <<= mnShadingValue; |
4689 | 0 | } |
4690 | 0 | break; |
4691 | 14.0k | } |
4692 | | |
4693 | 14.0k | return true; |
4694 | 14.0k | } |
4695 | | |
4696 | | |
4697 | | bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
4698 | 45.0k | { |
4699 | 45.0k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
4700 | 45.0k | nMemberId &= ~CONVERT_TWIPS; |
4701 | 45.0k | switch( nMemberId) |
4702 | 45.0k | { |
4703 | 31.2k | case MID_BACK_COLOR: |
4704 | 31.3k | case MID_BACK_COLOR_R_G_B: |
4705 | 31.3k | { |
4706 | 31.3k | Color aNewCol; |
4707 | 31.3k | if ( !( rVal >>= aNewCol ) ) |
4708 | 0 | return false; |
4709 | 31.3k | if(MID_BACK_COLOR_R_G_B == nMemberId) |
4710 | 11 | { |
4711 | 11 | aNewCol.SetAlpha(maColor.GetAlpha()); |
4712 | 11 | } |
4713 | 31.3k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
4714 | 31.3k | maColor = aNewCol; |
4715 | 31.3k | } |
4716 | 0 | break; |
4717 | 591 | case MID_BACK_COLOR_TRANSPARENCY: |
4718 | 591 | { |
4719 | 591 | sal_Int32 nTrans = 0; |
4720 | 591 | if ( !( rVal >>= nTrans ) || nTrans < 0 || nTrans > 100 ) |
4721 | 0 | return false; |
4722 | 591 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
4723 | 591 | maColor.SetAlpha(255 - lcl_PercentToTransparency(nTrans)); |
4724 | 591 | } |
4725 | 0 | break; |
4726 | | |
4727 | 35 | case MID_BACKGROUND_COMPLEX_COLOR: |
4728 | 35 | { |
4729 | 35 | css::uno::Reference<css::util::XComplexColor> xComplexColor; |
4730 | 35 | if (!(rVal >>= xComplexColor)) |
4731 | 0 | return false; |
4732 | | |
4733 | 35 | if (xComplexColor.is()) |
4734 | 35 | { |
4735 | 35 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
4736 | 35 | maComplexColor = model::color::getFromXComplexColor(xComplexColor); |
4737 | 35 | } |
4738 | 35 | } |
4739 | 0 | break; |
4740 | | |
4741 | 1.21k | case MID_GRAPHIC_POSITION: |
4742 | 1.21k | { |
4743 | 1.21k | style::GraphicLocation eLocation; |
4744 | 1.21k | if ( !( rVal>>=eLocation ) ) |
4745 | 0 | { |
4746 | 0 | sal_Int32 nValue = 0; |
4747 | 0 | if ( !( rVal >>= nValue ) ) |
4748 | 0 | return false; |
4749 | 0 | eLocation = static_cast<style::GraphicLocation>(nValue); |
4750 | 0 | } |
4751 | 1.21k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
4752 | 1.21k | SetGraphicPos( static_cast<SvxGraphicPosition>(static_cast<sal_uInt16>(eLocation)) ); |
4753 | 1.21k | } |
4754 | 0 | break; |
4755 | | |
4756 | 2.20k | case MID_GRAPHIC_TRANSPARENT: |
4757 | 2.20k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
4758 | 2.20k | maColor.SetAlpha( Any2Bool( rVal ) ? 0 : 255 ); |
4759 | 2.20k | break; |
4760 | | |
4761 | 0 | case MID_GRAPHIC_URL: |
4762 | 1.21k | case MID_GRAPHIC: |
4763 | 1.21k | { |
4764 | 1.21k | Graphic aGraphic; |
4765 | | |
4766 | 1.21k | if (OUString aURL; rVal >>= aURL) |
4767 | 0 | { |
4768 | 0 | aGraphic = vcl::graphic::loadFromURL(aURL); |
4769 | 0 | } |
4770 | 1.21k | else if (uno::Reference<graphic::XGraphic> xGraphic; rVal >>= xGraphic) |
4771 | 58 | { |
4772 | 58 | aGraphic = Graphic(xGraphic); |
4773 | 58 | } |
4774 | | |
4775 | 1.21k | if (!aGraphic.IsNone()) |
4776 | 0 | { |
4777 | 0 | maStrLink.clear(); |
4778 | |
|
4779 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
4780 | 0 | std::unique_ptr<GraphicObject> xOldGrfObj(std::move(mxGraphicObject)); |
4781 | 0 | mxGraphicObject.reset(new GraphicObject(std::move(aGraphic))); |
4782 | 0 | ApplyGraphicTransparency_Impl(); |
4783 | 0 | xOldGrfObj.reset(); |
4784 | |
|
4785 | 0 | if (meGraphicPos == GPOS_NONE) |
4786 | 0 | { |
4787 | 0 | meGraphicPos = GPOS_MM; |
4788 | 0 | } |
4789 | 0 | } |
4790 | 1.21k | else |
4791 | 1.21k | { |
4792 | 1.21k | meGraphicPos = GPOS_NONE; |
4793 | 1.21k | } |
4794 | 1.21k | } |
4795 | 1.21k | break; |
4796 | | |
4797 | 1.21k | case MID_GRAPHIC_FILTER: |
4798 | 1.21k | { |
4799 | 1.21k | if( rVal.getValueType() == ::cppu::UnoType<OUString>::get() ) |
4800 | 1.21k | { |
4801 | 1.21k | OUString sLink; |
4802 | 1.21k | rVal >>= sLink; |
4803 | 1.21k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
4804 | 1.21k | SetGraphicFilter( sLink ); |
4805 | 1.21k | } |
4806 | 1.21k | } |
4807 | 1.21k | break; |
4808 | 8 | case MID_GRAPHIC_TRANSPARENCY : |
4809 | 8 | { |
4810 | 8 | sal_Int32 nTmp = 0; |
4811 | 8 | rVal >>= nTmp; |
4812 | 8 | if(nTmp >= 0 && nTmp <= 100) |
4813 | 8 | { |
4814 | 8 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
4815 | 8 | mnGraphicTransparency = sal_Int8(nTmp); |
4816 | 8 | if (mxGraphicObject) |
4817 | 0 | ApplyGraphicTransparency_Impl(); |
4818 | 8 | } |
4819 | 8 | } |
4820 | 8 | break; |
4821 | | |
4822 | 7.25k | case MID_SHADING_VALUE: |
4823 | 7.25k | { |
4824 | 7.25k | sal_Int32 nVal = 0; |
4825 | 7.25k | if (!(rVal >>= nVal)) |
4826 | 0 | return false; |
4827 | | |
4828 | 7.25k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
4829 | 7.25k | mnShadingValue = nVal; |
4830 | 7.25k | } |
4831 | 0 | break; |
4832 | 45.0k | } |
4833 | | |
4834 | 45.0k | return true; |
4835 | 45.0k | } |
4836 | | |
4837 | | |
4838 | | bool SvxBrushItem::GetPresentation(SfxItemPresentation /*ePres*/, MapUnit /*eCoreUnit*/, MapUnit /*ePresUnit*/, |
4839 | | OUString& rText, const IntlWrapper&) const |
4840 | 0 | { |
4841 | 0 | if (GPOS_NONE == meGraphicPos) |
4842 | 0 | { |
4843 | 0 | rText = ::GetColorString(maColor) + cpDelim; |
4844 | 0 | TranslateId pId = RID_SVXITEMS_TRANSPARENT_FALSE; |
4845 | |
|
4846 | 0 | if (maColor.IsTransparent()) |
4847 | 0 | pId = RID_SVXITEMS_TRANSPARENT_TRUE; |
4848 | 0 | rText += EditResId(pId); |
4849 | 0 | } |
4850 | 0 | else |
4851 | 0 | { |
4852 | 0 | rText = EditResId(RID_SVXITEMS_GRAPHIC); |
4853 | 0 | } |
4854 | |
|
4855 | 0 | return true; |
4856 | 0 | } |
4857 | | |
4858 | | bool SvxBrushItem::operator==( const SfxPoolItem& rAttr ) const |
4859 | 14.2M | { |
4860 | 14.2M | assert(SfxPoolItem::operator==(rAttr)); |
4861 | | |
4862 | 14.2M | const SvxBrushItem& rCmp = static_cast<const SvxBrushItem&>(rAttr); |
4863 | 14.2M | bool bEqual = |
4864 | 14.2M | maColor == rCmp.maColor && |
4865 | 9.25M | maComplexColor == rCmp.maComplexColor && |
4866 | 994k | maFilterColor == rCmp.maFilterColor && |
4867 | 993k | meGraphicPos == rCmp.meGraphicPos && |
4868 | 993k | mnGraphicTransparency == rCmp.mnGraphicTransparency; |
4869 | | |
4870 | 14.2M | if ( bEqual ) |
4871 | 993k | { |
4872 | 993k | if ( GPOS_NONE != meGraphicPos ) |
4873 | 5.04k | { |
4874 | 5.04k | bEqual = maStrLink == rCmp.maStrLink; |
4875 | | |
4876 | 5.04k | if ( bEqual ) |
4877 | 4.68k | { |
4878 | 4.68k | bEqual = maStrFilter == rCmp.maStrFilter; |
4879 | 4.68k | } |
4880 | | |
4881 | 5.04k | if ( bEqual ) |
4882 | 4.68k | { |
4883 | 4.68k | if (!rCmp.mxGraphicObject) |
4884 | 2.06k | bEqual = !mxGraphicObject; |
4885 | 2.62k | else |
4886 | 2.62k | bEqual = mxGraphicObject && |
4887 | 2.62k | (*mxGraphicObject == *rCmp.mxGraphicObject); |
4888 | 4.68k | } |
4889 | 5.04k | } |
4890 | | |
4891 | 993k | if (bEqual) |
4892 | 992k | { |
4893 | 992k | bEqual = mnShadingValue == rCmp.mnShadingValue; |
4894 | 992k | } |
4895 | 993k | } |
4896 | | |
4897 | 14.2M | return bEqual; |
4898 | 14.2M | } |
4899 | | |
4900 | | size_t SvxBrushItem::hashCode() const |
4901 | 188k | { |
4902 | 188k | std::size_t seed(0); |
4903 | 188k | o3tl::hash_combine(seed, static_cast<sal_Int32>(maColor)); |
4904 | 188k | o3tl::hash_combine(seed, maComplexColor); |
4905 | 188k | o3tl::hash_combine(seed, static_cast<sal_Int32>(maFilterColor)); |
4906 | 188k | o3tl::hash_combine(seed, meGraphicPos); |
4907 | 188k | o3tl::hash_combine(seed, mnGraphicTransparency); |
4908 | 188k | if ( GPOS_NONE != meGraphicPos ) |
4909 | 0 | { |
4910 | 0 | o3tl::hash_combine(seed, maStrLink); |
4911 | 0 | o3tl::hash_combine(seed, maStrFilter); |
4912 | 0 | } |
4913 | 188k | o3tl::hash_combine(seed, mnShadingValue); |
4914 | 188k | return seed; |
4915 | 188k | } |
4916 | | |
4917 | | SvxBrushItem* SvxBrushItem::Clone( SfxItemPool* ) const |
4918 | 1.16M | { |
4919 | 1.16M | return new SvxBrushItem( *this ); |
4920 | 1.16M | } |
4921 | | |
4922 | | const GraphicObject* SvxBrushItem::GetGraphicObject(OUString const & referer) const |
4923 | 2.74k | { |
4924 | 2.74k | if (mbLoadAgain && !maStrLink.isEmpty() && !mxGraphicObject) |
4925 | | // when graphics already loaded, use as a cache |
4926 | 185 | { |
4927 | 185 | if (SvtSecurityOptions::isUntrustedReferer(referer)) { |
4928 | 0 | return nullptr; |
4929 | 0 | } |
4930 | | |
4931 | 185 | INetURLObject aGraphicURL( maStrLink ); |
4932 | 185 | if (aGraphicURL.IsExoticProtocol()) |
4933 | 0 | { |
4934 | 0 | SAL_WARN("editeng", "Ignore exotic protocol: " << maStrLink); |
4935 | 0 | return nullptr; |
4936 | 0 | } |
4937 | | |
4938 | | // tdf#94088 prepare graphic and state |
4939 | 185 | Graphic aGraphic; |
4940 | 185 | bool bGraphicLoaded = false; |
4941 | | |
4942 | | // try to create stream directly from given URL |
4943 | 185 | std::unique_ptr<SvStream> xStream(utl::UcbStreamHelper::CreateStream(maStrLink, StreamMode::STD_READ)); |
4944 | | // tdf#94088 if we have a stream, try to load it directly as graphic |
4945 | 185 | if (xStream && !xStream->GetError()) |
4946 | 0 | { |
4947 | 0 | if (ERRCODE_NONE == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, maStrLink, *xStream, |
4948 | 0 | GRFILTER_FORMAT_DONTKNOW, nullptr, GraphicFilterImportFlags::DontSetLogsizeForJpeg)) |
4949 | 0 | { |
4950 | 0 | bGraphicLoaded = true; |
4951 | 0 | } |
4952 | 0 | } |
4953 | | |
4954 | | // tdf#94088 if no succeeded, try if the string (which is not empty) contains |
4955 | | // a 'data:' scheme url and try to load that (embedded graphics) |
4956 | 185 | if(!bGraphicLoaded) |
4957 | 185 | { |
4958 | 185 | if( INetProtocol::Data == aGraphicURL.GetProtocol() ) |
4959 | 0 | { |
4960 | 0 | std::unique_ptr<SvMemoryStream> const xMemStream(aGraphicURL.getData()); |
4961 | 0 | if (xMemStream) |
4962 | 0 | { |
4963 | 0 | if (ERRCODE_NONE == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, u"", *xMemStream)) |
4964 | 0 | { |
4965 | 0 | bGraphicLoaded = true; |
4966 | | |
4967 | | // tdf#94088 delete the no longer needed data scheme URL which |
4968 | | // is potentially pretty // large, containing a base64 encoded copy of the graphic |
4969 | 0 | const_cast< SvxBrushItem* >(this)->maStrLink.clear(); |
4970 | 0 | } |
4971 | 0 | } |
4972 | 0 | } |
4973 | 185 | } |
4974 | | |
4975 | | // tdf#94088 when we got a graphic, set it |
4976 | 185 | if(bGraphicLoaded && GraphicType::NONE != aGraphic.GetType()) |
4977 | 0 | { |
4978 | 0 | mxGraphicObject.reset(new GraphicObject); |
4979 | 0 | mxGraphicObject->SetGraphic(aGraphic); |
4980 | 0 | const_cast < SvxBrushItem*> (this)->ApplyGraphicTransparency_Impl(); |
4981 | 0 | } |
4982 | 185 | else |
4983 | 185 | { |
4984 | 185 | mbLoadAgain = false; |
4985 | 185 | } |
4986 | 185 | } |
4987 | | |
4988 | 2.74k | return mxGraphicObject.get(); |
4989 | 2.74k | } |
4990 | | |
4991 | | void SvxBrushItem::setGraphicTransparency(sal_Int8 nNew) |
4992 | 0 | { |
4993 | 0 | if (nNew != mnGraphicTransparency) |
4994 | 0 | { |
4995 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
4996 | 0 | mnGraphicTransparency = nNew; |
4997 | 0 | ApplyGraphicTransparency_Impl(); |
4998 | 0 | } |
4999 | 0 | } |
5000 | | |
5001 | | const Graphic* SvxBrushItem::GetGraphic(OUString const & referer) const |
5002 | 2.74k | { |
5003 | 2.74k | const GraphicObject* pGrafObj = GetGraphicObject(referer); |
5004 | 2.74k | return( pGrafObj ? &( pGrafObj->GetGraphic() ) : nullptr ); |
5005 | 2.74k | } |
5006 | | |
5007 | | void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew ) |
5008 | 2.43k | { |
5009 | 2.43k | if (meGraphicPos == eNew) |
5010 | 1.22k | return; |
5011 | | |
5012 | 1.21k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
5013 | 1.21k | meGraphicPos = eNew; |
5014 | | |
5015 | 1.21k | if ( GPOS_NONE == meGraphicPos ) |
5016 | 0 | { |
5017 | 0 | mxGraphicObject.reset(); |
5018 | 0 | maStrLink.clear(); |
5019 | 0 | maStrFilter.clear(); |
5020 | 0 | } |
5021 | 1.21k | else |
5022 | 1.21k | { |
5023 | 1.21k | if (!mxGraphicObject && maStrLink.isEmpty()) |
5024 | 316 | { |
5025 | 316 | mxGraphicObject.reset(new GraphicObject); // Creating a dummy |
5026 | 316 | } |
5027 | 1.21k | } |
5028 | 1.21k | } |
5029 | | |
5030 | | void SvxBrushItem::SetGraphic( const Graphic& rNew ) |
5031 | 54 | { |
5032 | 54 | if ( maStrLink.isEmpty() ) |
5033 | 54 | { |
5034 | 54 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
5035 | 54 | if (mxGraphicObject) |
5036 | 0 | mxGraphicObject->SetGraphic(rNew); |
5037 | 54 | else |
5038 | 54 | mxGraphicObject.reset(new GraphicObject(rNew)); |
5039 | | |
5040 | 54 | ApplyGraphicTransparency_Impl(); |
5041 | | |
5042 | 54 | if ( GPOS_NONE == meGraphicPos ) |
5043 | 0 | meGraphicPos = GPOS_MM; // None would be brush, then Default: middle |
5044 | 54 | } |
5045 | 0 | else |
5046 | 0 | { |
5047 | 0 | OSL_FAIL( "SetGraphic() on linked graphic! :-/" ); |
5048 | 0 | } |
5049 | 54 | } |
5050 | | |
5051 | | void SvxBrushItem::SetGraphicObject( const GraphicObject& rNewObj ) |
5052 | 0 | { |
5053 | 0 | if ( maStrLink.isEmpty() ) |
5054 | 0 | { |
5055 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
5056 | 0 | if (mxGraphicObject) |
5057 | 0 | *mxGraphicObject = rNewObj; |
5058 | 0 | else |
5059 | 0 | mxGraphicObject.reset(new GraphicObject(rNewObj)); |
5060 | |
|
5061 | 0 | ApplyGraphicTransparency_Impl(); |
5062 | |
|
5063 | 0 | if ( GPOS_NONE == meGraphicPos ) |
5064 | 0 | meGraphicPos = GPOS_MM; // None would be brush, then Default: middle |
5065 | 0 | } |
5066 | 0 | else |
5067 | 0 | { |
5068 | 0 | OSL_FAIL( "SetGraphic() on linked graphic! :-/" ); |
5069 | 0 | } |
5070 | 0 | } |
5071 | | |
5072 | | void SvxBrushItem::SetGraphicLink( const OUString& rNew ) |
5073 | 1.21k | { |
5074 | 1.21k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
5075 | 1.21k | if ( rNew.isEmpty() ) |
5076 | 316 | maStrLink.clear(); |
5077 | 900 | else |
5078 | 900 | { |
5079 | 900 | maStrLink = rNew; |
5080 | 900 | mxGraphicObject.reset(); |
5081 | 900 | } |
5082 | 1.21k | } |
5083 | | |
5084 | | void SvxBrushItem::SetGraphicFilter( const OUString& rNew ) |
5085 | 1.21k | { |
5086 | 1.21k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
5087 | 1.21k | maStrFilter = rNew; |
5088 | 1.21k | } |
5089 | | |
5090 | | void SvxBrushItem::ApplyGraphicTransparency_Impl() |
5091 | 54 | { |
5092 | 54 | DBG_ASSERT(mxGraphicObject, "no GraphicObject available" ); |
5093 | 54 | if (mxGraphicObject) |
5094 | 54 | { |
5095 | 54 | GraphicAttr aAttr(mxGraphicObject->GetAttr()); |
5096 | 54 | aAttr.SetAlpha(255 - lcl_PercentToTransparency(mnGraphicTransparency)); |
5097 | 54 | mxGraphicObject->SetAttr(aAttr); |
5098 | 54 | } |
5099 | 54 | } |
5100 | | |
5101 | | void SvxBrushItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
5102 | 0 | { |
5103 | 0 | tools::XmlWriter aWriter(pWriter); |
5104 | 0 | aWriter.startElement("SvxBrushItem"); |
5105 | 0 | aWriter.attribute("whichId", Which()); |
5106 | 0 | aWriter.attribute("color", maColor.AsRGBHexString()); |
5107 | 0 | aWriter.attribute("filtercolor", maFilterColor.AsRGBHexString()); |
5108 | 0 | aWriter.attribute("shadingValue", mnShadingValue); |
5109 | 0 | aWriter.attribute("link", maStrLink); |
5110 | 0 | aWriter.attribute("filter", maStrFilter); |
5111 | 0 | aWriter.attribute("graphicPos", meGraphicPos); |
5112 | 0 | aWriter.attribute("loadAgain", mbLoadAgain); |
5113 | 0 | aWriter.endElement(); |
5114 | 0 | } |
5115 | | |
5116 | | ItemInstanceManager* SvxFrameDirectionItem::getItemInstanceManager() const |
5117 | 1.75M | { |
5118 | 1.75M | static DefaultItemInstanceManager aInstanceManager(ItemType()); |
5119 | 1.75M | return &aInstanceManager; |
5120 | 1.75M | } |
5121 | | |
5122 | | SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue , |
5123 | | sal_uInt16 _nWhich ) |
5124 | 1.63M | : SfxEnumItem<SvxFrameDirection>( _nWhich, nValue ) |
5125 | 1.63M | { |
5126 | 1.63M | } |
5127 | | |
5128 | | |
5129 | | SvxFrameDirectionItem::~SvxFrameDirectionItem() |
5130 | 2.27M | { |
5131 | 2.27M | } |
5132 | | |
5133 | | SvxFrameDirectionItem* SvxFrameDirectionItem::Clone( SfxItemPool * ) const |
5134 | 641k | { |
5135 | 641k | return new SvxFrameDirectionItem( *this ); |
5136 | 641k | } |
5137 | | |
5138 | | TranslateId getFrmDirResId(size_t nIndex) |
5139 | 0 | { |
5140 | 0 | TranslateId const RID_SVXITEMS_FRMDIR[] = |
5141 | 0 | { |
5142 | 0 | RID_SVXITEMS_FRMDIR_HORI_LEFT_TOP, |
5143 | 0 | RID_SVXITEMS_FRMDIR_HORI_RIGHT_TOP, |
5144 | 0 | RID_SVXITEMS_FRMDIR_VERT_TOP_RIGHT, |
5145 | 0 | RID_SVXITEMS_FRMDIR_VERT_TOP_LEFT, |
5146 | 0 | RID_SVXITEMS_FRMDIR_ENVIRONMENT, |
5147 | 0 | RID_SVXITEMS_FRMDIR_VERT_BOT_LEFT, |
5148 | 0 | RID_SVXITEMS_FRMDIR_VERT_TOP_RIGHT90 |
5149 | 0 | }; |
5150 | 0 | return RID_SVXITEMS_FRMDIR[nIndex]; |
5151 | 0 | } |
5152 | | |
5153 | | bool SvxFrameDirectionItem::GetPresentation( |
5154 | | SfxItemPresentation /*ePres*/, |
5155 | | MapUnit /*eCoreUnit*/, |
5156 | | MapUnit /*ePresUnit*/, |
5157 | | OUString& rText, const IntlWrapper&) const |
5158 | 0 | { |
5159 | 0 | rText = EditResId(getFrmDirResId(GetEnumValue())); |
5160 | 0 | return true; |
5161 | 0 | } |
5162 | | |
5163 | | bool SvxFrameDirectionItem::PutValue( const css::uno::Any& rVal, |
5164 | | sal_uInt8 ) |
5165 | 214k | { |
5166 | 214k | sal_Int16 nVal = sal_Int16(); |
5167 | 214k | bool bRet = ( rVal >>= nVal ); |
5168 | 214k | if( bRet ) |
5169 | 214k | { |
5170 | 214k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
5171 | | // translate WritingDirection2 constants into SvxFrameDirection |
5172 | 214k | switch( nVal ) |
5173 | 214k | { |
5174 | 206k | case text::WritingMode2::LR_TB: |
5175 | 206k | SetValue( SvxFrameDirection::Horizontal_LR_TB ); |
5176 | 206k | break; |
5177 | 2.06k | case text::WritingMode2::RL_TB: |
5178 | 2.06k | SetValue( SvxFrameDirection::Horizontal_RL_TB ); |
5179 | 2.06k | break; |
5180 | 1.34k | case text::WritingMode2::TB_RL: |
5181 | 1.34k | SetValue( SvxFrameDirection::Vertical_RL_TB ); |
5182 | 1.34k | break; |
5183 | 0 | case text::WritingMode2::TB_LR: |
5184 | 0 | SetValue( SvxFrameDirection::Vertical_LR_TB ); |
5185 | 0 | break; |
5186 | 297 | case text::WritingMode2::BT_LR: |
5187 | 297 | SetValue( SvxFrameDirection::Vertical_LR_BT ); |
5188 | 297 | break; |
5189 | 9 | case text::WritingMode2::TB_RL90: |
5190 | 9 | SetValue(SvxFrameDirection::Vertical_RL_TB90); |
5191 | 9 | break; |
5192 | 3.52k | case text::WritingMode2::PAGE: |
5193 | 3.52k | SetValue( SvxFrameDirection::Environment ); |
5194 | 3.52k | break; |
5195 | 0 | case text::WritingMode2::STACKED: |
5196 | 0 | SetValue(SvxFrameDirection::Stacked); |
5197 | 0 | break; |
5198 | 0 | default: |
5199 | 0 | bRet = false; |
5200 | 0 | break; |
5201 | 214k | } |
5202 | 214k | } |
5203 | | |
5204 | 214k | return bRet; |
5205 | 214k | } |
5206 | | |
5207 | | |
5208 | | bool SvxFrameDirectionItem::QueryValue( css::uno::Any& rVal, |
5209 | | sal_uInt8 ) const |
5210 | 72.0k | { |
5211 | | // translate SvxFrameDirection into WritingDirection2 |
5212 | 72.0k | sal_Int16 nVal; |
5213 | 72.0k | bool bRet = true; |
5214 | 72.0k | switch( GetValue() ) |
5215 | 72.0k | { |
5216 | 60.2k | case SvxFrameDirection::Horizontal_LR_TB: |
5217 | 60.2k | nVal = text::WritingMode2::LR_TB; |
5218 | 60.2k | break; |
5219 | 0 | case SvxFrameDirection::Horizontal_RL_TB: |
5220 | 0 | nVal = text::WritingMode2::RL_TB; |
5221 | 0 | break; |
5222 | 0 | case SvxFrameDirection::Vertical_RL_TB: |
5223 | 0 | nVal = text::WritingMode2::TB_RL; |
5224 | 0 | break; |
5225 | 0 | case SvxFrameDirection::Vertical_LR_TB: |
5226 | 0 | nVal = text::WritingMode2::TB_LR; |
5227 | 0 | break; |
5228 | 30 | case SvxFrameDirection::Vertical_LR_BT: |
5229 | 30 | nVal = text::WritingMode2::BT_LR; |
5230 | 30 | break; |
5231 | 9 | case SvxFrameDirection::Vertical_RL_TB90: |
5232 | 9 | nVal = text::WritingMode2::TB_RL90; |
5233 | 9 | break; |
5234 | 11.7k | case SvxFrameDirection::Environment: |
5235 | 11.7k | nVal = text::WritingMode2::PAGE; |
5236 | 11.7k | break; |
5237 | 0 | case SvxFrameDirection::Stacked: |
5238 | 0 | nVal = text::WritingMode2::STACKED; |
5239 | 0 | break; |
5240 | 0 | default: |
5241 | 0 | OSL_FAIL("Unknown SvxFrameDirection value!"); |
5242 | 0 | bRet = false; |
5243 | 0 | break; |
5244 | 72.0k | } |
5245 | | |
5246 | | // return value + error state |
5247 | 72.0k | if( bRet ) |
5248 | 72.0k | { |
5249 | 72.0k | rVal <<= nVal; |
5250 | 72.0k | } |
5251 | 72.0k | return bRet; |
5252 | 72.0k | } |
5253 | | |
5254 | | void SvxFrameDirectionItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
5255 | 0 | { |
5256 | 0 | tools::XmlWriter aWriter(pWriter); |
5257 | 0 | aWriter.startElement("SvxFrameDirectionItem"); |
5258 | 0 | aWriter.attribute("whichId", Which()); |
5259 | 0 | aWriter.attribute("m_nValue", sal_Int16(GetValue())); |
5260 | 0 | aWriter.endElement(); |
5261 | 0 | } |
5262 | | |
5263 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |