LibreOffice Module sc (master) 1
patattr.cxx
Go to the documentation of this file.
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 <utility>
22#include <scitems.hxx>
24#include <editeng/boxitem.hxx>
25#include <editeng/lineitem.hxx>
26#include <editeng/brushitem.hxx>
29#include <svtools/colorcfg.hxx>
30#include <editeng/colritem.hxx>
32#include <editeng/eeitem.hxx>
34#include <editeng/fhgtitem.hxx>
35#include <editeng/fontitem.hxx>
38#include <editeng/langitem.hxx>
39#include <editeng/postitem.hxx>
40#include <svx/rotmodit.hxx>
42#include <editeng/shaditem.hxx>
43#include <editeng/shdditem.hxx>
44#include <editeng/udlnitem.hxx>
45#include <editeng/wghtitem.hxx>
46#include <editeng/wrlmitem.hxx>
48#include <svl/intitem.hxx>
49#include <svl/numformat.hxx>
50#include <svl/whiter.hxx>
51#include <svl/zforlist.hxx>
52#include <vcl/outdev.hxx>
53#include <tools/fract.hxx>
55#include <osl/diagnose.h>
56
57#include <attrib.hxx>
58#include <patattr.hxx>
59#include <docpool.hxx>
60#include <stlsheet.hxx>
61#include <stlpool.hxx>
62#include <document.hxx>
63#include <globstr.hrc>
64#include <scresid.hxx>
65#include <validat.hxx>
66#include <scmod.hxx>
67#include <fillinfo.hxx>
68#include <comphelper/lok.hxx>
69#include <tabvwsh.hxx>
70
71ScPatternAttr::ScPatternAttr( SfxItemSet&& pItemSet, const OUString& rStyleName )
72 : SfxSetItem ( ATTR_PATTERN, std::move(pItemSet) ),
73 pName ( rStyleName ),
74 pStyle ( nullptr ),
75 mnKey(0)
76{
77}
78
80 : SfxSetItem ( ATTR_PATTERN, std::move(pItemSet) ),
81 pStyle ( nullptr ),
82 mnKey(0)
83{
84}
85
88 pStyle ( nullptr ),
89 mnKey(0)
90{
91}
92
94 : SfxSetItem ( rPatternAttr ),
95 pName ( rPatternAttr.pName ),
96 pStyle ( rPatternAttr.pStyle ),
97 mnKey(rPatternAttr.mnKey)
98{
99}
100
102{
103 ScPatternAttr* pPattern = new ScPatternAttr( GetItemSet().CloneAsValue(true, pPool) );
104
105 pPattern->pStyle = pStyle;
106 pPattern->pName = pName;
107
108 return pPattern;
109}
110
111static bool StrCmp( const OUString* pStr1, const OUString* pStr2 )
112{
113 if (pStr1 == pStr2)
114 return true;
115 if (pStr1 && !pStr2)
116 return false;
117 if (!pStr1 && pStr2)
118 return false;
119 return *pStr1 == *pStr2;
120}
121
123
124std::optional<bool> ScPatternAttr::FastEqualPatternSets( const SfxItemSet& rSet1, const SfxItemSet& rSet2 )
125{
126 // #i62090# The SfxItemSet in the SfxSetItem base class always has the same ranges
127 // (single range from ATTR_PATTERN_START to ATTR_PATTERN_END), and the items are pooled,
128 // so it's enough to compare just the pointers (Count just because it's even faster).
129
130 if ( rSet1.Count() != rSet2.Count() )
131 return { false };
132
133 // Actually test_tdf133629 from UITest_calc_tests9 somehow manages to have
134 // a different range (and I don't understand enough why), so better be safe and compare fully.
135 if( rSet1.TotalCount() != compareSize || rSet2.TotalCount() != compareSize )
136 return std::nullopt;
137
138 SfxPoolItem const ** pItems1 = rSet1.GetItems_Impl(); // inline method of SfxItemSet
139 SfxPoolItem const ** pItems2 = rSet2.GetItems_Impl();
140
141 return { memcmp( pItems1, pItems2, compareSize * sizeof(pItems1[0]) ) == 0 };
142}
143
144static bool EqualPatternSets( const SfxItemSet& rSet1, const SfxItemSet& rSet2 )
145{
146 std::optional<bool> equal = ScPatternAttr::FastEqualPatternSets( rSet1, rSet2 );
147 if(equal.has_value())
148 return *equal;
149 return rSet1 == rSet2;
150}
151
152bool ScPatternAttr::operator==( const SfxPoolItem& rCmp ) const
153{
154 // #i62090# Use quick comparison between ScPatternAttr's ItemSets
155
156 if (!SfxPoolItem::operator==(rCmp) )
157 return false;
158 if (!mxHashCode)
159 CalcHashCode();
160 auto const & rOther = static_cast<const ScPatternAttr&>(rCmp);
161 if (!rOther.mxHashCode)
162 rOther.CalcHashCode();
163 if (*mxHashCode != *rOther.mxHashCode)
164 return false;
165 return EqualPatternSets( GetItemSet(), rOther.GetItemSet() ) &&
166 StrCmp( GetStyleName(), rOther.GetStyleName() );
167}
168
170{
171 if( !mxHashCode )
172 CalcHashCode();
173 for( auto it = begin; it != end; ++it)
174 {
175 const ScPatternAttr* other = static_cast<const ScPatternAttr*>(*it);
176 if( !other->mxHashCode )
177 other->CalcHashCode();
178 if (*mxHashCode == *other->mxHashCode
179 && EqualPatternSets( GetItemSet(), other->GetItemSet())
180 && StrCmp( GetStyleName(), other->GetStyleName()))
181 {
182 return it;
183 }
184 }
185 return end;
186}
187
189{
190 SvxCellOrientation eOrient = SvxCellOrientation::Standard;
191
192 if( GetItem( ATTR_STACKED, rItemSet, pCondSet ).GetValue() )
193 {
194 eOrient = SvxCellOrientation::Stacked;
195 }
196 else
197 {
198 Degree100 nAngle = GetItem( ATTR_ROTATE_VALUE, rItemSet, pCondSet ).GetValue();
199 if( nAngle == 9000_deg100 )
200 eOrient = SvxCellOrientation::BottomUp;
201 else if( nAngle == 27000_deg100 )
202 eOrient = SvxCellOrientation::TopBottom;
203 }
204
205 return eOrient;
206}
207
209{
210 return GetCellOrientation( GetItemSet(), pCondSet );
211}
212
213namespace {
214
215void getFontIDsByScriptType(SvtScriptType nScript,
221{
222 if ( nScript == SvtScriptType::ASIAN )
223 {
224 nFontId = ATTR_CJK_FONT;
225 nHeightId = ATTR_CJK_FONT_HEIGHT;
226 nWeightId = ATTR_CJK_FONT_WEIGHT;
227 nPostureId = ATTR_CJK_FONT_POSTURE;
228 nLangId = ATTR_CJK_FONT_LANGUAGE;
229 }
230 else if ( nScript == SvtScriptType::COMPLEX )
231 {
232 nFontId = ATTR_CTL_FONT;
233 nHeightId = ATTR_CTL_FONT_HEIGHT;
234 nWeightId = ATTR_CTL_FONT_WEIGHT;
235 nPostureId = ATTR_CTL_FONT_POSTURE;
236 nLangId = ATTR_CTL_FONT_LANGUAGE;
237 }
238 else
239 {
240 nFontId = ATTR_FONT;
241 nHeightId = ATTR_FONT_HEIGHT;
242 nWeightId = ATTR_FONT_WEIGHT;
243 nPostureId = ATTR_FONT_POSTURE;
244 nLangId = ATTR_FONT_LANGUAGE;
245 }
246}
247
248}
249
251 vcl::Font& rFont, const SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode,
252 const OutputDevice* pOutDev, const Fraction* pScale,
253 const SfxItemSet* pCondSet, SvtScriptType nScript,
254 const Color* pBackConfigColor, const Color* pTextConfigColor)
255{
256 model::ComplexColor aComplexColor;
257
258 // determine effective font color
259 ScPatternAttr::fillFontOnly(rFont, rItemSet, pOutDev, pScale, pCondSet, nScript);
260 ScPatternAttr::fillColor(aComplexColor, rItemSet, eAutoMode, pCondSet, pBackConfigColor, pTextConfigColor);
261
262 // set font effects
263 rFont.SetColor(aComplexColor.getFinalColor());
264}
265
267 vcl::Font& rFont, const SfxItemSet& rItemSet,
268 const OutputDevice* pOutDev, const Fraction* pScale,
269 const SfxItemSet* pCondSet, SvtScriptType nScript)
270{
271 // Read items
272
273 const SvxFontItem* pFontAttr;
274 sal_uInt32 nFontHeight;
275 FontWeight eWeight;
276 FontItalic eItalic;
277 FontLineStyle eUnder;
278 FontLineStyle eOver;
279 bool bWordLine;
280 FontStrikeout eStrike;
281 bool bOutline;
282 bool bShadow;
283 FontEmphasisMark eEmphasis;
284 FontRelief eRelief;
285 LanguageType eLang;
286
287 TypedWhichId<SvxFontItem> nFontId(0);
289 TypedWhichId<SvxWeightItem> nWeightId(0);
290 TypedWhichId<SvxPostureItem> nPostureId(0);
292 getFontIDsByScriptType(nScript, nFontId, nHeightId, nWeightId, nPostureId, nLangId);
293
294 if (pCondSet)
295 {
296 pFontAttr = pCondSet->GetItemIfSet( nFontId );
297 if ( !pFontAttr )
298 pFontAttr = &rItemSet.Get( nFontId );
299
300 const SvxFontHeightItem* pFontHeightItem = pCondSet->GetItemIfSet( nHeightId );
301 if ( !pFontHeightItem )
302 pFontHeightItem = &rItemSet.Get( nHeightId );
303 nFontHeight = pFontHeightItem->GetHeight();
304
305 const SvxWeightItem* pFontHWeightItem = pCondSet->GetItemIfSet( nWeightId );
306 if ( !pFontHWeightItem )
307 pFontHWeightItem = &rItemSet.Get( nWeightId );
308 eWeight = pFontHWeightItem->GetValue();
309
310 const SvxPostureItem* pPostureItem = pCondSet->GetItemIfSet( nPostureId );
311 if ( !pPostureItem )
312 pPostureItem = &rItemSet.Get( nPostureId );
313 eItalic = pPostureItem->GetValue();
314
315 const SvxUnderlineItem* pUnderlineItem = pCondSet->GetItemIfSet( ATTR_FONT_UNDERLINE );
316 if ( !pUnderlineItem )
317 pUnderlineItem = &rItemSet.Get( ATTR_FONT_UNDERLINE );
318 eUnder = pUnderlineItem->GetValue();
319
320 const SvxOverlineItem* pOverlineItem = pCondSet->GetItemIfSet( ATTR_FONT_OVERLINE );
321 if ( !pOverlineItem )
322 pOverlineItem = &rItemSet.Get( ATTR_FONT_OVERLINE );
323 eOver = pOverlineItem->GetValue();
324
325 const SvxWordLineModeItem* pWordlineItem = pCondSet->GetItemIfSet( ATTR_FONT_WORDLINE );
326 if ( !pWordlineItem )
327 pWordlineItem = &rItemSet.Get( ATTR_FONT_WORDLINE );
328 bWordLine = pWordlineItem->GetValue();
329
330 const SvxCrossedOutItem* pCrossedOutItem = pCondSet->GetItemIfSet( ATTR_FONT_CROSSEDOUT );
331 if ( !pCrossedOutItem )
332 pCrossedOutItem = &rItemSet.Get( ATTR_FONT_CROSSEDOUT );
333 eStrike = pCrossedOutItem->GetValue();
334
335 const SvxContourItem* pContourItem = pCondSet->GetItemIfSet( ATTR_FONT_CONTOUR );
336 if ( !pContourItem )
337 pContourItem = &rItemSet.Get( ATTR_FONT_CONTOUR );
338 bOutline = pContourItem->GetValue();
339
340 const SvxShadowedItem* pShadowedItem = pCondSet->GetItemIfSet( ATTR_FONT_SHADOWED );
341 if ( !pShadowedItem )
342 pShadowedItem = &rItemSet.Get( ATTR_FONT_SHADOWED );
343 bShadow = pShadowedItem->GetValue();
344
345 const SvxEmphasisMarkItem* pEmphasisMarkItem = pCondSet->GetItemIfSet( ATTR_FONT_EMPHASISMARK );
346 if ( !pEmphasisMarkItem )
347 pEmphasisMarkItem = &rItemSet.Get( ATTR_FONT_EMPHASISMARK );
348 eEmphasis = pEmphasisMarkItem->GetEmphasisMark();
349
350 const SvxCharReliefItem* pCharReliefItem = pCondSet->GetItemIfSet( ATTR_FONT_RELIEF );
351 if ( !pCharReliefItem )
352 pCharReliefItem = &rItemSet.Get( ATTR_FONT_RELIEF );
353 eRelief = pCharReliefItem->GetValue();
354
355 const SvxLanguageItem* pLanguageItem = pCondSet->GetItemIfSet( nLangId );
356 if ( !pLanguageItem )
357 pLanguageItem = &rItemSet.Get( nLangId );
358 eLang = pLanguageItem->GetLanguage();
359 }
360 else // Everything from rItemSet
361 {
362 pFontAttr = &rItemSet.Get( nFontId );
363 nFontHeight = rItemSet.Get( nHeightId ).GetHeight();
364 eWeight = rItemSet.Get( nWeightId ).GetValue();
365 eItalic = rItemSet.Get( nPostureId ).GetValue();
366 eUnder = rItemSet.Get( ATTR_FONT_UNDERLINE ).GetValue();
367 eOver = rItemSet.Get( ATTR_FONT_OVERLINE ).GetValue();
368 bWordLine = rItemSet.Get( ATTR_FONT_WORDLINE ).GetValue();
369 eStrike = rItemSet.Get( ATTR_FONT_CROSSEDOUT ).GetValue();
370 bOutline = rItemSet.Get( ATTR_FONT_CONTOUR ).GetValue();
371 bShadow = rItemSet.Get( ATTR_FONT_SHADOWED ).GetValue();
372 eEmphasis = rItemSet.Get( ATTR_FONT_EMPHASISMARK ).GetEmphasisMark();
373 eRelief = rItemSet.Get( ATTR_FONT_RELIEF ).GetValue();
374 // for graphite language features
375 eLang = rItemSet.Get( nLangId ).GetLanguage();
376 }
377 OSL_ENSURE(pFontAttr,"Oops?");
378
379 // Evaluate
380
381 // FontItem:
382
383 if (rFont.GetFamilyName() != pFontAttr->GetFamilyName())
384 rFont.SetFamilyName( pFontAttr->GetFamilyName() );
385 if (rFont.GetStyleName() != pFontAttr->GetStyleName())
386 rFont.SetStyleName( pFontAttr->GetStyleName() );
387
388 rFont.SetFamily( pFontAttr->GetFamily() );
389 rFont.SetCharSet( pFontAttr->GetCharSet() );
390 rFont.SetPitch( pFontAttr->GetPitch() );
391
392 rFont.SetLanguage(eLang);
393
394 // Size
395
396 if ( pOutDev != nullptr )
397 {
398 Size aEffSize;
399 Fraction aFraction( 1,1 );
400 if (pScale)
401 aFraction = *pScale;
402 Size aSize( 0, static_cast<tools::Long>(nFontHeight) );
403 MapMode aDestMode = pOutDev->GetMapMode();
404 MapMode aSrcMode( MapUnit::MapTwip, Point(), aFraction, aFraction );
405 if (aDestMode.GetMapUnit() == MapUnit::MapPixel && pOutDev->GetDPIX() > 0)
406 aEffSize = pOutDev->LogicToPixel( aSize, aSrcMode );
407 else
408 {
409 Fraction aFractOne(1,1);
410 aDestMode.SetScaleX( aFractOne );
411 aDestMode.SetScaleY( aFractOne );
412 aEffSize = OutputDevice::LogicToLogic( aSize, aSrcMode, aDestMode );
413 }
414 rFont.SetFontSize( aEffSize );
415 }
416 else /* if pOutDev != NULL */
417 {
418 rFont.SetFontSize( Size( 0, static_cast<tools::Long>(nFontHeight) ) );
419 }
420
421 // set font effects
422 rFont.SetWeight( eWeight );
423 rFont.SetItalic( eItalic );
424 rFont.SetUnderline( eUnder );
425 rFont.SetOverline( eOver );
426 rFont.SetWordLineMode( bWordLine );
427 rFont.SetStrikeout( eStrike );
428 rFont.SetOutline( bOutline );
429 rFont.SetShadow( bShadow );
430 rFont.SetEmphasisMark( eEmphasis );
431 rFont.SetRelief( eRelief );
432 rFont.SetTransparent( true );
433}
434
435void ScPatternAttr::fillColor(model::ComplexColor& rComplexColor, const SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode, const SfxItemSet* pCondSet, const Color* pBackConfigColor, const Color* pTextConfigColor)
436{
437 model::ComplexColor aComplexColor;
438
439 Color aColor;
440
441 SvxColorItem const* pColorItem = nullptr;
442
443 if (pCondSet)
444 pColorItem = pCondSet->GetItemIfSet(ATTR_FONT_COLOR);
445
446 if (!pColorItem)
447 pColorItem = &rItemSet.Get(ATTR_FONT_COLOR);
448
449 if (pColorItem)
450 {
451 aComplexColor = pColorItem->getComplexColor();
452 aColor = pColorItem->GetValue();
453 }
454
455 if (aComplexColor.getType() == model::ColorType::Unused)
456 {
457 aComplexColor.setColor(aColor);
458 }
459
460 if ((aColor == COL_AUTO && eAutoMode != ScAutoFontColorMode::Raw)
461 || eAutoMode == ScAutoFontColorMode::IgnoreFont
462 || eAutoMode == ScAutoFontColorMode::IgnoreAll)
463 {
464 // get background color from conditional or own set
465 Color aBackColor;
466 if ( pCondSet )
467 {
468 const SvxBrushItem* pItem = pCondSet->GetItemIfSet(ATTR_BACKGROUND);
469 if (!pItem)
470 pItem = &rItemSet.Get(ATTR_BACKGROUND);
471 aBackColor = pItem->GetColor();
472 }
473 else
474 {
475 aBackColor = rItemSet.Get(ATTR_BACKGROUND).GetColor();
476 }
477
478 // if background color attribute is transparent, use window color for brightness comparisons
479 if (aBackColor == COL_TRANSPARENT
480 || eAutoMode == ScAutoFontColorMode::IgnoreBack
481 || eAutoMode == ScAutoFontColorMode::IgnoreAll)
482 {
484 {
485 if ( eAutoMode == ScAutoFontColorMode::Print )
486 aBackColor = COL_WHITE;
487 else if ( pBackConfigColor )
488 {
489 // pBackConfigColor can be used to avoid repeated lookup of the configured color
490 aBackColor = *pBackConfigColor;
491 }
492 else
493 aBackColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
494 }
495 else
496 {
497 // Get document color from current view instead
498 SfxViewShell* pSfxViewShell = SfxViewShell::Current();
499 ScTabViewShell* pViewShell = dynamic_cast<ScTabViewShell*>(pSfxViewShell);
500 if (pViewShell)
501 {
502 const ScViewData& pViewData = pViewShell->GetViewData();
503 const ScViewOptions& aViewOptions = pViewData.GetOptions();
504 aBackColor = aViewOptions.GetDocColor();
505 }
506 }
507 }
508
509 // get system text color for comparison
510 Color aSysTextColor;
511 if (eAutoMode == ScAutoFontColorMode::Print)
512 {
513 aSysTextColor = COL_BLACK;
514 }
515 else if (pTextConfigColor)
516 {
517 // pTextConfigColor can be used to avoid repeated lookup of the configured color
518 aSysTextColor = *pTextConfigColor;
519 }
520 else
521 {
522 aSysTextColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor;
523 }
524
525 // select the resulting color
526 if ( aBackColor.IsDark() && aSysTextColor.IsDark() )
527 {
528 // use white instead of dark on dark
529 aColor = COL_WHITE;
530 }
531 else if ( aBackColor.IsBright() && aSysTextColor.IsBright() )
532 {
533 // use black instead of bright on bright
534 aColor = COL_BLACK;
535 }
536 else
537 {
538 // use aSysTextColor (black for ScAutoFontColorMode::Print, from style settings otherwise)
539 aColor = aSysTextColor;
540 }
541 }
542 aComplexColor.setFinalColor(aColor);
543 rComplexColor = aComplexColor;
544}
545
547{
548 TypedWhichId<SvxFontItem> nFontId(0);
550 TypedWhichId<SvxWeightItem> nWeightId(0);
551 TypedWhichId<SvxPostureItem> nPostureId(0);
553 getFontIDsByScriptType(nScript, nFontId, nHeightId, nWeightId, nPostureId, nLangId);
554
555 ScDxfFont aReturn;
556
557 if ( const SvxFontItem* pItem = rItemSet.GetItemIfSet( nFontId ) )
558 {
559 aReturn.pFontAttr = pItem;
560 }
561
562 if ( const SvxFontHeightItem* pItem = rItemSet.GetItemIfSet( nHeightId ) )
563 {
564 aReturn.nFontHeight = pItem->GetHeight();
565 }
566
567 if ( const SvxWeightItem* pItem = rItemSet.GetItemIfSet( nWeightId ) )
568 {
569 aReturn.eWeight = pItem->GetValue();
570 }
571
572 if ( const SvxPostureItem* pItem = rItemSet.GetItemIfSet( nPostureId ) )
573 {
574 aReturn.eItalic = pItem->GetValue();
575 }
576
577 if ( const SvxUnderlineItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_UNDERLINE ) )
578 {
579 pItem = &rItemSet.Get( ATTR_FONT_UNDERLINE );
580 aReturn.eUnder = pItem->GetValue();
581 }
582
583 if ( const SvxOverlineItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_OVERLINE ) )
584 {
585 aReturn.eOver = pItem->GetValue();
586 }
587
588 if ( const SvxWordLineModeItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_WORDLINE ) )
589 {
590 aReturn.bWordLine = pItem->GetValue();
591 }
592
593 if ( const SvxCrossedOutItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_CROSSEDOUT ) )
594 {
595 pItem = &rItemSet.Get( ATTR_FONT_CROSSEDOUT );
596 aReturn.eStrike = pItem->GetValue();
597 }
598
599 if ( const SvxContourItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_CONTOUR ) )
600 {
601 aReturn.bOutline = pItem->GetValue();
602 }
603
604 if ( const SvxShadowedItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_SHADOWED ) )
605 {
606 pItem = &rItemSet.Get( ATTR_FONT_SHADOWED );
607 aReturn.bShadow = pItem->GetValue();
608 }
609
610 if ( const SvxEmphasisMarkItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_EMPHASISMARK ) )
611 {
612 aReturn.eEmphasis = pItem->GetEmphasisMark();
613 }
614
615 if ( const SvxCharReliefItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_RELIEF ) )
616 {
617 aReturn.eRelief = pItem->GetValue();
618 }
619
620 if ( const SvxColorItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_COLOR ) )
621 {
622 aReturn.aColor = pItem->GetValue();
623 }
624
625 if ( const SvxLanguageItem* pItem = rItemSet.GetItemIfSet( nLangId ) )
626 {
627 aReturn.eLang = pItem->GetLanguage();
628 }
629
630 return aReturn;
631}
632
633template <class T>
634static void lcl_populate( std::unique_ptr<T>& rxItem, TypedWhichId<T> nWhich, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet )
635{
636 const T* pItem = pCondSet->GetItemIfSet( nWhich );
637 if ( !pItem )
638 pItem = &rSrcSet.Get( nWhich );
639 rxItem.reset(pItem->Clone());
640}
641
642void ScPatternAttr::FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet )
643{
644 // Read Items
645
646 std::unique_ptr<SvxColorItem> aColorItem(std::make_unique<SvxColorItem>(EE_CHAR_COLOR)); // use item as-is
647 std::unique_ptr<SvxFontItem> aFontItem(std::make_unique<SvxFontItem>(EE_CHAR_FONTINFO)); // use item as-is
648 std::unique_ptr<SvxFontItem> aCjkFontItem(std::make_unique<SvxFontItem>(EE_CHAR_FONTINFO_CJK)); // use item as-is
649 std::unique_ptr<SvxFontItem> aCtlFontItem(std::make_unique<SvxFontItem>(EE_CHAR_FONTINFO_CTL)); // use item as-is
650 tools::Long nTHeight, nCjkTHeight, nCtlTHeight; // Twips
651 FontWeight eWeight, eCjkWeight, eCtlWeight;
652 std::unique_ptr<SvxUnderlineItem> aUnderlineItem(std::make_unique<SvxUnderlineItem>(LINESTYLE_NONE, EE_CHAR_UNDERLINE));
653 std::unique_ptr<SvxOverlineItem> aOverlineItem(std::make_unique<SvxOverlineItem>(LINESTYLE_NONE, EE_CHAR_OVERLINE));
654 bool bWordLine;
655 FontStrikeout eStrike;
656 FontItalic eItalic, eCjkItalic, eCtlItalic;
657 bool bOutline;
658 bool bShadow;
659 bool bForbidden;
660 FontEmphasisMark eEmphasis;
661 FontRelief eRelief;
662 LanguageType eLang, eCjkLang, eCtlLang;
663 bool bHyphenate;
664 SvxFrameDirection eDirection;
665
666 //TODO: additional parameter to control if language is needed?
667
668 if ( pCondSet )
669 {
670 lcl_populate(aColorItem, ATTR_FONT_COLOR, rSrcSet, pCondSet);
671 lcl_populate(aFontItem, ATTR_FONT, rSrcSet, pCondSet);
672 lcl_populate(aCjkFontItem, ATTR_CJK_FONT, rSrcSet, pCondSet);
673 lcl_populate(aCtlFontItem, ATTR_CTL_FONT, rSrcSet, pCondSet);
674
675 const SvxFontHeightItem* pFontHeightItem = pCondSet->GetItemIfSet( ATTR_FONT_HEIGHT );
676 if (!pFontHeightItem)
677 pFontHeightItem = &rSrcSet.Get( ATTR_FONT_HEIGHT );
678 nTHeight = pFontHeightItem->GetHeight();
679 pFontHeightItem = pCondSet->GetItemIfSet( ATTR_CJK_FONT_HEIGHT );
680 if ( !pFontHeightItem )
681 pFontHeightItem = &rSrcSet.Get( ATTR_CJK_FONT_HEIGHT );
682 nCjkTHeight = pFontHeightItem->GetHeight();
683 pFontHeightItem = pCondSet->GetItemIfSet( ATTR_CTL_FONT_HEIGHT );
684 if ( !pFontHeightItem )
685 pFontHeightItem = &rSrcSet.Get( ATTR_CTL_FONT_HEIGHT );
686 nCtlTHeight = pFontHeightItem->GetHeight();
687
688 const SvxWeightItem* pWeightItem = pCondSet->GetItemIfSet( ATTR_FONT_WEIGHT );
689 if ( !pWeightItem )
690 pWeightItem = &rSrcSet.Get( ATTR_FONT_WEIGHT );
691 eWeight = pWeightItem->GetValue();
692 pWeightItem = pCondSet->GetItemIfSet( ATTR_CJK_FONT_WEIGHT );
693 if ( !pWeightItem )
694 pWeightItem = &rSrcSet.Get( ATTR_CJK_FONT_WEIGHT );
695 eCjkWeight = pWeightItem->GetValue();
696 pWeightItem = pCondSet->GetItemIfSet( ATTR_CTL_FONT_WEIGHT );
697 if ( !pWeightItem )
698 pWeightItem = &rSrcSet.Get( ATTR_CTL_FONT_WEIGHT );
699 eCtlWeight = pWeightItem->GetValue();
700
701 const SvxPostureItem* pPostureItem = pCondSet->GetItemIfSet( ATTR_FONT_POSTURE );
702 if ( !pPostureItem )
703 pPostureItem = &rSrcSet.Get( ATTR_FONT_POSTURE );
704 eItalic = pPostureItem->GetValue();
705 pPostureItem = pCondSet->GetItemIfSet( ATTR_CJK_FONT_POSTURE );
706 if ( !pPostureItem )
707 pPostureItem = &rSrcSet.Get( ATTR_CJK_FONT_POSTURE );
708 eCjkItalic = pPostureItem->GetValue();
709 pPostureItem = pCondSet->GetItemIfSet( ATTR_CTL_FONT_POSTURE );
710 if ( !pPostureItem )
711 pPostureItem = &rSrcSet.Get( ATTR_CTL_FONT_POSTURE );
712 eCtlItalic = pPostureItem->GetValue();
713
714 lcl_populate(aUnderlineItem, ATTR_FONT_UNDERLINE, rSrcSet, pCondSet);
715 lcl_populate(aOverlineItem, ATTR_FONT_OVERLINE, rSrcSet, pCondSet);
716
717 const SvxWordLineModeItem* pWordLineModeItem = pCondSet->GetItemIfSet( ATTR_FONT_WORDLINE );
718 if ( !pWordLineModeItem )
719 pWordLineModeItem = &rSrcSet.Get( ATTR_FONT_WORDLINE );
720 bWordLine = pWordLineModeItem->GetValue();
721
722 const SvxCrossedOutItem* pCrossedOutItem = pCondSet->GetItemIfSet( ATTR_FONT_CROSSEDOUT );
723 if ( !pCrossedOutItem )
724 pCrossedOutItem = &rSrcSet.Get( ATTR_FONT_CROSSEDOUT );
725 eStrike = pCrossedOutItem->GetValue();
726
727 const SvxContourItem* pContourItem = pCondSet->GetItemIfSet( ATTR_FONT_CONTOUR );
728 if ( !pContourItem )
729 pContourItem = &rSrcSet.Get( ATTR_FONT_CONTOUR );
730 bOutline = pContourItem->GetValue();
731
732 const SvxShadowedItem* pShadowedItem = pCondSet->GetItemIfSet( ATTR_FONT_SHADOWED );
733 if ( !pShadowedItem )
734 pShadowedItem = &rSrcSet.Get( ATTR_FONT_SHADOWED );
735 bShadow = pShadowedItem->GetValue();
736
737 const SvxForbiddenRuleItem* pForbiddenRuleItem = pCondSet->GetItemIfSet( ATTR_FORBIDDEN_RULES );
738 if ( !pForbiddenRuleItem )
739 pForbiddenRuleItem = &rSrcSet.Get( ATTR_FORBIDDEN_RULES );
740 bForbidden = pForbiddenRuleItem->GetValue();
741
742 const SvxEmphasisMarkItem* pEmphasisMarkItem = pCondSet->GetItemIfSet( ATTR_FONT_EMPHASISMARK );
743 if ( !pEmphasisMarkItem )
744 pEmphasisMarkItem = &rSrcSet.Get( ATTR_FONT_EMPHASISMARK );
745 eEmphasis = pEmphasisMarkItem->GetEmphasisMark();
746 const SvxCharReliefItem* pCharReliefItem = pCondSet->GetItemIfSet( ATTR_FONT_RELIEF );
747 if ( !pCharReliefItem )
748 pCharReliefItem = &rSrcSet.Get( ATTR_FONT_RELIEF );
749 eRelief = pCharReliefItem->GetValue();
750
751 const SvxLanguageItem* pLanguageItem = pCondSet->GetItemIfSet( ATTR_FONT_LANGUAGE );
752 if ( !pLanguageItem )
753 pLanguageItem = &rSrcSet.Get( ATTR_FONT_LANGUAGE );
754 eLang = pLanguageItem->GetLanguage();
755 pLanguageItem = pCondSet->GetItemIfSet( ATTR_CJK_FONT_LANGUAGE );
756 if ( !pLanguageItem )
757 pLanguageItem = &rSrcSet.Get( ATTR_CJK_FONT_LANGUAGE );
758 eCjkLang = pLanguageItem->GetLanguage();
759 pLanguageItem = pCondSet->GetItemIfSet( ATTR_CTL_FONT_LANGUAGE );
760 if ( !pLanguageItem )
761 pLanguageItem = &rSrcSet.Get( ATTR_CTL_FONT_LANGUAGE );
762 eCtlLang = pLanguageItem->GetLanguage();
763
764 const ScHyphenateCell* pHyphenateCell = pCondSet->GetItemIfSet( ATTR_HYPHENATE );
765 if ( !pHyphenateCell )
766 pHyphenateCell = &rSrcSet.Get( ATTR_HYPHENATE );
767 bHyphenate = pHyphenateCell->GetValue();
768
769 const SvxFrameDirectionItem* pFrameDirectionItem = pCondSet->GetItemIfSet( ATTR_WRITINGDIR );
770 if ( !pFrameDirectionItem )
771 pFrameDirectionItem = &rSrcSet.Get( ATTR_WRITINGDIR );
772 eDirection = pFrameDirectionItem->GetValue();
773 }
774 else // Everything directly from Pattern
775 {
776 aColorItem.reset(rSrcSet.Get(ATTR_FONT_COLOR).Clone());
777 aFontItem.reset(rSrcSet.Get(ATTR_FONT).Clone());
778 aCjkFontItem.reset(rSrcSet.Get(ATTR_CJK_FONT).Clone());
779 aCtlFontItem.reset(rSrcSet.Get(ATTR_CTL_FONT).Clone());
780 nTHeight = rSrcSet.Get( ATTR_FONT_HEIGHT ).GetHeight();
781 nCjkTHeight = rSrcSet.Get( ATTR_CJK_FONT_HEIGHT ).GetHeight();
782 nCtlTHeight = rSrcSet.Get( ATTR_CTL_FONT_HEIGHT ).GetHeight();
783 eWeight = rSrcSet.Get( ATTR_FONT_WEIGHT ).GetValue();
784 eCjkWeight = rSrcSet.Get( ATTR_CJK_FONT_WEIGHT ).GetValue();
785 eCtlWeight = rSrcSet.Get( ATTR_CTL_FONT_WEIGHT ).GetValue();
786 eItalic = rSrcSet.Get( ATTR_FONT_POSTURE ).GetValue();
787 eCjkItalic = rSrcSet.Get( ATTR_CJK_FONT_POSTURE ).GetValue();
788 eCtlItalic = rSrcSet.Get( ATTR_CTL_FONT_POSTURE ).GetValue();
789 aUnderlineItem.reset(rSrcSet.Get(ATTR_FONT_UNDERLINE).Clone());
790 aOverlineItem.reset(rSrcSet.Get(ATTR_FONT_OVERLINE).Clone());
791 bWordLine = rSrcSet.Get( ATTR_FONT_WORDLINE ).GetValue();
792 eStrike = rSrcSet.Get( ATTR_FONT_CROSSEDOUT ).GetValue();
793 bOutline = rSrcSet.Get( ATTR_FONT_CONTOUR ).GetValue();
794 bShadow = rSrcSet.Get( ATTR_FONT_SHADOWED ).GetValue();
795 bForbidden = rSrcSet.Get( ATTR_FORBIDDEN_RULES ).GetValue();
796 eEmphasis = rSrcSet.Get( ATTR_FONT_EMPHASISMARK ).GetEmphasisMark();
797 eRelief = rSrcSet.Get( ATTR_FONT_RELIEF ).GetValue();
798 eLang = rSrcSet.Get( ATTR_FONT_LANGUAGE ).GetLanguage();
799 eCjkLang = rSrcSet.Get( ATTR_CJK_FONT_LANGUAGE ).GetLanguage();
800 eCtlLang = rSrcSet.Get( ATTR_CTL_FONT_LANGUAGE ).GetLanguage();
801 bHyphenate = rSrcSet.Get( ATTR_HYPHENATE ).GetValue();
802 eDirection = rSrcSet.Get( ATTR_WRITINGDIR ).GetValue();
803 }
804
805 // Expect to be compatible to LogicToLogic, ie. 2540/1440 = 127/72, and round
806
807 tools::Long nHeight = convertTwipToMm100(nTHeight);
808 tools::Long nCjkHeight = convertTwipToMm100(nCjkTHeight);
809 tools::Long nCtlHeight = convertTwipToMm100(nCtlTHeight);
810
811 // put items into EditEngine ItemSet
812
813 if ( aColorItem->GetValue() == COL_AUTO )
814 {
815 // When cell attributes are converted to EditEngine paragraph attributes,
816 // don't create a hard item for automatic color, because that would be converted
817 // to black when the item's Store method is used in CreateTransferable/WriteBin.
818 // COL_AUTO is the EditEngine's pool default, so ClearItem will result in automatic
819 // color, too, without having to store the item.
820 rEditSet.ClearItem( EE_CHAR_COLOR );
821 }
822 else
823 {
824 // tdf#125054 adapt WhichID
825 rEditSet.Put( std::move(aColorItem), EE_CHAR_COLOR );
826 }
827
828 // tdf#125054 adapt WhichID
829 rEditSet.Put( std::move(aFontItem), EE_CHAR_FONTINFO );
830 rEditSet.Put( std::move(aCjkFontItem), EE_CHAR_FONTINFO_CJK );
831 rEditSet.Put( std::move(aCtlFontItem), EE_CHAR_FONTINFO_CTL );
832
833 rEditSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
834 rEditSet.Put( SvxFontHeightItem( nCjkHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
835 rEditSet.Put( SvxFontHeightItem( nCtlHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
836 rEditSet.Put( SvxWeightItem ( eWeight, EE_CHAR_WEIGHT ) );
837 rEditSet.Put( SvxWeightItem ( eCjkWeight, EE_CHAR_WEIGHT_CJK ) );
838 rEditSet.Put( SvxWeightItem ( eCtlWeight, EE_CHAR_WEIGHT_CTL ) );
839
840 // tdf#125054 adapt WhichID
841 rEditSet.Put( std::move(aUnderlineItem), EE_CHAR_UNDERLINE );
842 rEditSet.Put( std::move(aOverlineItem), EE_CHAR_OVERLINE );
843
844 rEditSet.Put( SvxWordLineModeItem( bWordLine, EE_CHAR_WLM ) );
845 rEditSet.Put( SvxCrossedOutItem( eStrike, EE_CHAR_STRIKEOUT ) );
846 rEditSet.Put( SvxPostureItem ( eItalic, EE_CHAR_ITALIC ) );
847 rEditSet.Put( SvxPostureItem ( eCjkItalic, EE_CHAR_ITALIC_CJK ) );
848 rEditSet.Put( SvxPostureItem ( eCtlItalic, EE_CHAR_ITALIC_CTL ) );
849 rEditSet.Put( SvxContourItem ( bOutline, EE_CHAR_OUTLINE ) );
850 rEditSet.Put( SvxShadowedItem ( bShadow, EE_CHAR_SHADOW ) );
851 rEditSet.Put( SvxForbiddenRuleItem(bForbidden, EE_PARA_FORBIDDENRULES) );
852 rEditSet.Put( SvxEmphasisMarkItem( eEmphasis, EE_CHAR_EMPHASISMARK ) );
853 rEditSet.Put( SvxCharReliefItem( eRelief, EE_CHAR_RELIEF ) );
854 rEditSet.Put( SvxLanguageItem ( eLang, EE_CHAR_LANGUAGE ) );
855 rEditSet.Put( SvxLanguageItem ( eCjkLang, EE_CHAR_LANGUAGE_CJK ) );
856 rEditSet.Put( SvxLanguageItem ( eCtlLang, EE_CHAR_LANGUAGE_CTL ) );
857 rEditSet.Put( SfxBoolItem ( EE_PARA_HYPHENATE, bHyphenate ) );
858 rEditSet.Put( SvxFrameDirectionItem( eDirection, EE_PARA_WRITINGDIR ) );
859
860 // Script spacing is always off.
861 // The cell attribute isn't used here as long as there is no UI to set it
862 // (don't evaluate attributes that can't be changed).
863 // If a locale-dependent default is needed, it has to go into the cell
864 // style, like the fonts.
865 rEditSet.Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
866}
867
868void ScPatternAttr::FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet ) const
869{
870 if( pEditSet )
871 FillToEditItemSet( *pEditSet, GetItemSet(), pCondSet );
872}
873
875{
876 if (const SvxColorItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_COLOR))
877 rDestSet.Put( *pItem, ATTR_FONT_COLOR );
878
879 if (const SvxFontItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTINFO))
880 rDestSet.Put( *pItem, ATTR_FONT );
881 if (const SvxFontItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTINFO_CJK))
882 rDestSet.Put( *pItem, ATTR_CJK_FONT );
883 if (const SvxFontItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTINFO_CTL))
884 rDestSet.Put( *pItem, ATTR_CTL_FONT );
885
886 if (const SvxFontHeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTHEIGHT))
887 rDestSet.Put( SvxFontHeightItem(o3tl::toTwips(pItem->GetHeight(), o3tl::Length::mm100),
888 100, ATTR_FONT_HEIGHT ) );
889 if (const SvxFontHeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTHEIGHT_CJK))
890 rDestSet.Put( SvxFontHeightItem(o3tl::toTwips(pItem->GetHeight(), o3tl::Length::mm100),
891 100, ATTR_CJK_FONT_HEIGHT ) );
892 if (const SvxFontHeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTHEIGHT_CTL))
893 rDestSet.Put( SvxFontHeightItem(o3tl::toTwips(pItem->GetHeight(), o3tl::Length::mm100),
894 100, ATTR_CTL_FONT_HEIGHT ) );
895
896 if (const SvxWeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_WEIGHT))
897 rDestSet.Put( SvxWeightItem( pItem->GetValue(),
899 if (const SvxWeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_WEIGHT_CJK))
900 rDestSet.Put( SvxWeightItem( pItem->GetValue(),
902 if (const SvxWeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_WEIGHT_CTL))
903 rDestSet.Put( SvxWeightItem( pItem->GetValue(),
905
906 // SvxTextLineItem contains enum and color
907 if (const SvxUnderlineItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_UNDERLINE))
908 rDestSet.Put( *pItem, ATTR_FONT_UNDERLINE );
909 if (const SvxOverlineItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_OVERLINE))
910 rDestSet.Put( *pItem, ATTR_FONT_OVERLINE );
911 if (const SvxWordLineModeItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_WLM))
912 rDestSet.Put( SvxWordLineModeItem( pItem->GetValue(),
914
915 if (const SvxCrossedOutItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_STRIKEOUT))
916 rDestSet.Put( SvxCrossedOutItem( pItem->GetValue(),
918
919 if (const SvxPostureItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_ITALIC))
920 rDestSet.Put( SvxPostureItem( pItem->GetValue(),
922 if (const SvxPostureItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_ITALIC_CJK))
923 rDestSet.Put( SvxPostureItem( pItem->GetValue(),
925 if (const SvxPostureItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_ITALIC_CTL))
926 rDestSet.Put( SvxPostureItem( pItem->GetValue(),
928
929 if (const SvxContourItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_OUTLINE))
930 rDestSet.Put( SvxContourItem( pItem->GetValue(),
932 if (const SvxShadowedItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_SHADOW))
933 rDestSet.Put( SvxShadowedItem( pItem->GetValue(),
935 if (const SvxEmphasisMarkItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_EMPHASISMARK))
936 rDestSet.Put( SvxEmphasisMarkItem( pItem->GetEmphasisMark(),
938 if (const SvxCharReliefItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_RELIEF))
939 rDestSet.Put( SvxCharReliefItem( pItem->GetValue(),
941
942 if (const SvxLanguageItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_LANGUAGE))
943 rDestSet.Put( SvxLanguageItem(pItem->GetValue(), ATTR_FONT_LANGUAGE) );
944 if (const SvxLanguageItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_LANGUAGE_CJK))
945 rDestSet.Put( SvxLanguageItem(pItem->GetValue(), ATTR_CJK_FONT_LANGUAGE) );
946 if (const SvxLanguageItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_LANGUAGE_CTL))
947 rDestSet.Put( SvxLanguageItem(pItem->GetValue(), ATTR_CTL_FONT_LANGUAGE) );
948
949 const SvxAdjustItem* pAdjustItem = rEditSet.GetItemIfSet(EE_PARA_JUST);
950
951 if (!pAdjustItem)
952 return;
953
955 switch ( pAdjustItem->GetAdjust() )
956 {
957 case SvxAdjust::Left:
958 // EditEngine Default is always set in the GetAttribs() ItemSet !
959 // whether left or right, is decided in text / number
960 eVal = SvxCellHorJustify::Standard;
961 break;
962 case SvxAdjust::Right:
963 eVal = SvxCellHorJustify::Right;
964 break;
965 case SvxAdjust::Block:
966 eVal = SvxCellHorJustify::Block;
967 break;
968 case SvxAdjust::Center:
969 eVal = SvxCellHorJustify::Center;
970 break;
971 case SvxAdjust::BlockLine:
972 eVal = SvxCellHorJustify::Block;
973 break;
974 case SvxAdjust::End:
975 eVal = SvxCellHorJustify::Right;
976 break;
977 default:
978 eVal = SvxCellHorJustify::Standard;
979 }
980 if ( eVal != SvxCellHorJustify::Standard )
981 rDestSet.Put( SvxHorJustifyItem( eVal, ATTR_HOR_JUSTIFY) );
982}
983
985{
986 if( !pEditSet )
987 return;
988 GetFromEditItemSet( GetItemSet(), *pEditSet );
989 mxHashCode.reset();
990 mxVisible.reset();
991}
992
994{
995 // already there in GetFromEditItemSet, but not in FillEditItemSet
996 // Default horizontal alignment is always implemented as left
997
998 const SfxItemSet& rMySet = GetItemSet();
999
1000 SvxCellHorJustify eHorJust = rMySet.Get(ATTR_HOR_JUSTIFY).GetValue();
1001
1002 SvxAdjust eSvxAdjust;
1003 switch (eHorJust)
1004 {
1005 case SvxCellHorJustify::Right: eSvxAdjust = SvxAdjust::Right; break;
1006 case SvxCellHorJustify::Center: eSvxAdjust = SvxAdjust::Center; break;
1007 case SvxCellHorJustify::Block: eSvxAdjust = SvxAdjust::Block; break;
1008 default: eSvxAdjust = SvxAdjust::Left; break;
1009 }
1010 pEditSet->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) );
1011}
1012
1014{
1015 SfxItemSet& rThisSet = GetItemSet();
1016 const SfxItemSet& rOldSet = pOldAttrs->GetItemSet();
1017
1018 const SfxPoolItem* pThisItem;
1019 const SfxPoolItem* pOldItem;
1020
1021 for ( sal_uInt16 nSubWhich=ATTR_PATTERN_START; nSubWhich<=ATTR_PATTERN_END; nSubWhich++ )
1022 {
1023 // only items that are set are interesting
1024 if ( rThisSet.GetItemState( nSubWhich, false, &pThisItem ) == SfxItemState::SET )
1025 {
1026 SfxItemState eOldState = rOldSet.GetItemState( nSubWhich, true, &pOldItem );
1027 if ( eOldState == SfxItemState::SET )
1028 {
1029 // item is set in OldAttrs (or its parent) -> compare pointers
1030 if ( pThisItem == pOldItem )
1031 {
1032 rThisSet.ClearItem( nSubWhich );
1033 mxHashCode.reset();
1034 mxVisible.reset();
1035 }
1036 }
1037 else if ( eOldState != SfxItemState::DONTCARE )
1038 {
1039 // not set in OldAttrs -> compare item value to default item
1040 if ( *pThisItem == rThisSet.GetPool()->GetDefaultItem( nSubWhich ) )
1041 {
1042 rThisSet.ClearItem( nSubWhich );
1043 mxHashCode.reset();
1044 mxVisible.reset();
1045 }
1046 }
1047 }
1048 }
1049}
1050
1051bool ScPatternAttr::HasItemsSet( const sal_uInt16* pWhich ) const
1052{
1053 const SfxItemSet& rSet = GetItemSet();
1054 for (sal_uInt16 i=0; pWhich[i]; i++)
1055 if ( rSet.GetItemState( pWhich[i], false ) == SfxItemState::SET )
1056 return true;
1057 return false;
1058}
1059
1060void ScPatternAttr::ClearItems( const sal_uInt16* pWhich )
1061{
1063 for (sal_uInt16 i=0; pWhich[i]; i++)
1064 rSet.ClearItem(pWhich[i]);
1065 mxHashCode.reset();
1066 mxVisible.reset();
1067}
1068
1070 (
1071 SfxStyleSheetBase* pSrcStyle,
1072 SfxStyleSheetBasePool* pSrcPool,
1073 SfxStyleSheetBasePool* pDestPool,
1074 const SvNumberFormatterIndexTable* pFormatExchangeList
1075 )
1076{
1077 if ( !pSrcStyle || !pDestPool || !pSrcPool )
1078 {
1079 OSL_FAIL( "CopyStyleToPool: Invalid Arguments :-/" );
1080 return nullptr;
1081 }
1082
1083 const OUString aStrSrcStyle = pSrcStyle->GetName();
1084 const SfxStyleFamily eFamily = pSrcStyle->GetFamily();
1085 SfxStyleSheetBase* pDestStyle = pDestPool->Find( aStrSrcStyle, eFamily );
1086
1087 if ( !pDestStyle )
1088 {
1089 const OUString aStrParent = pSrcStyle->GetParent();
1090 const SfxItemSet& rSrcSet = pSrcStyle->GetItemSet();
1091
1092 pDestStyle = &pDestPool->Make( aStrSrcStyle, eFamily, SfxStyleSearchBits::UserDefined );
1093 SfxItemSet& rDestSet = pDestStyle->GetItemSet();
1094 rDestSet.Put( rSrcSet );
1095
1096 // number format exchange list has to be handled here, too
1097 // (only called for cell styles)
1098
1099 const SfxUInt32Item* pSrcItem;
1100 if ( pFormatExchangeList &&
1101 (pSrcItem = rSrcSet.GetItemIfSet( ATTR_VALUE_FORMAT, false )) )
1102 {
1103 sal_uLong nOldFormat = pSrcItem->GetValue();
1104 SvNumberFormatterIndexTable::const_iterator it = pFormatExchangeList->find(nOldFormat);
1105 if (it != pFormatExchangeList->end())
1106 {
1107 sal_uInt32 nNewFormat = it->second;
1108 rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
1109 }
1110 }
1111
1112 // if necessary create derivative Styles, if not available:
1113
1114 if ( ScResId(STR_STYLENAME_STANDARD) != aStrParent &&
1115 aStrSrcStyle != aStrParent &&
1116 !pDestPool->Find( aStrParent, eFamily ) )
1117 {
1118 lcl_CopyStyleToPool( pSrcPool->Find( aStrParent, eFamily ),
1119 pSrcPool, pDestPool, pFormatExchangeList );
1120 }
1121
1122 pDestStyle->SetParent( aStrParent );
1123 }
1124
1125 return pDestStyle;
1126}
1127
1129{
1130 const SfxItemSet* pSrcSet = &GetItemSet();
1131
1132 ScPatternAttr aDestPattern( pDestDoc->GetPool() );
1133 SfxItemSet* pDestSet = &aDestPattern.GetItemSet();
1134
1135 // Copy cell pattern style to other document:
1136
1137 if ( pDestDoc != pSrcDoc )
1138 {
1139 OSL_ENSURE( pStyle, "Missing Pattern-Style! :-/" );
1140
1141 // if pattern in DestDoc is available, use this, otherwise copy
1142 // parent style to style or create if necessary and attach DestDoc
1143
1145 pSrcDoc->GetStyleSheetPool(),
1146 pDestDoc->GetStyleSheetPool(),
1147 pDestDoc->GetFormatExchangeList() );
1148
1149 aDestPattern.SetStyleSheet( static_cast<ScStyleSheet*>(pStyleCpy) );
1150 }
1151
1152 for ( sal_uInt16 nAttrId = ATTR_PATTERN_START; nAttrId <= ATTR_PATTERN_END; nAttrId++ )
1153 {
1154 const SfxPoolItem* pSrcItem;
1155 SfxItemState eItemState = pSrcSet->GetItemState( nAttrId, false, &pSrcItem );
1156 if (eItemState==SfxItemState::SET)
1157 {
1158 std::unique_ptr<SfxPoolItem> pNewItem;
1159
1160 if ( nAttrId == ATTR_VALIDDATA )
1161 {
1162 // Copy validity to the new document
1163
1164 sal_uInt32 nNewIndex = 0;
1165 ScValidationDataList* pSrcList = pSrcDoc->GetValidationList();
1166 if ( pSrcList )
1167 {
1168 sal_uInt32 nOldIndex = static_cast<const SfxUInt32Item*>(pSrcItem)->GetValue();
1169 const ScValidationData* pOldData = pSrcList->GetData( nOldIndex );
1170 if ( pOldData )
1171 nNewIndex = pDestDoc->AddValidationEntry( *pOldData );
1172 }
1173 pNewItem.reset(new SfxUInt32Item( ATTR_VALIDDATA, nNewIndex ));
1174 }
1175 else if ( nAttrId == ATTR_VALUE_FORMAT && pDestDoc->GetFormatExchangeList() )
1176 {
1177 // Number format to Exchange List
1178
1179 sal_uLong nOldFormat = static_cast<const SfxUInt32Item*>(pSrcItem)->GetValue();
1180 SvNumberFormatterIndexTable::const_iterator it = pDestDoc->GetFormatExchangeList()->find(nOldFormat);
1181 if (it != pDestDoc->GetFormatExchangeList()->end())
1182 {
1183 sal_uInt32 nNewFormat = it->second;
1184 pNewItem.reset(new SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ));
1185 }
1186 }
1187
1188 if ( pNewItem )
1189 {
1190 pDestSet->Put(std::move(pNewItem));
1191 }
1192 else
1193 pDestSet->Put(*pSrcItem);
1194 }
1195 }
1196
1197 ScPatternAttr* pPatternAttr = const_cast<ScPatternAttr*>( &pDestDoc->GetPool()->Put(aDestPattern) );
1198 return pPatternAttr;
1199}
1200
1202{
1203 if (!mxVisible)
1205 return *mxVisible;
1206}
1207
1209{
1210 const SfxItemSet& rSet = GetItemSet();
1211
1212 if ( const SvxBrushItem* pItem = rSet.GetItemIfSet( ATTR_BACKGROUND ) )
1213 if ( pItem->GetColor() != COL_TRANSPARENT )
1214 return true;
1215
1216 if ( const SvxBoxItem* pBoxItem = rSet.GetItemIfSet( ATTR_BORDER ) )
1217 {
1218 if ( pBoxItem->GetTop() || pBoxItem->GetBottom() ||
1219 pBoxItem->GetLeft() || pBoxItem->GetRight() )
1220 return true;
1221 }
1222
1223 if ( const SvxLineItem* pItem = rSet.GetItemIfSet( ATTR_BORDER_TLBR ) )
1224 if( pItem->GetLine() )
1225 return true;
1226
1227 if ( const SvxLineItem* pItem = rSet.GetItemIfSet( ATTR_BORDER_BLTR ) )
1228 if( pItem->GetLine() )
1229 return true;
1230
1231 if ( const SvxShadowItem* pItem = rSet.GetItemIfSet( ATTR_SHADOW ) )
1232 if ( pItem->GetLocation() != SvxShadowLocation::NONE )
1233 return true;
1234
1235 return false;
1236}
1237
1239{
1240 // This method is hot, so we do an optimised comparison here, by
1241 // walking the two itemsets in parallel, avoiding doing repeated searches.
1242 auto IsInterestingWhich = [](sal_uInt16 n)
1243 {
1245 || n == ATTR_BORDER || n == ATTR_SHADOW;
1246 };
1247 SfxWhichIter aIter1(GetItemSet());
1248 SfxWhichIter aIter2(rOther.GetItemSet());
1249 sal_uInt16 nWhich1 = aIter1.FirstWhich();
1250 sal_uInt16 nWhich2 = aIter2.FirstWhich();
1251 for (;;)
1252 {
1253 while (nWhich1 != nWhich2)
1254 {
1255 SfxWhichIter* pIterToIncrement;
1256 sal_uInt16* pSmallerWhich;
1257 if (nWhich1 == 0 || nWhich1 > nWhich2)
1258 {
1259 pSmallerWhich = &nWhich2;
1260 pIterToIncrement = &aIter2;
1261 }
1262 else
1263 {
1264 pSmallerWhich = &nWhich1;
1265 pIterToIncrement = &aIter1;
1266 }
1267
1268 if (IsInterestingWhich(*pSmallerWhich))
1269 {
1270 // the iter with larger which has already passed this point, and has no interesting
1271 // item available in the other - so indeed these are unequal
1272 return false;
1273 }
1274
1275 *pSmallerWhich = pIterToIncrement->NextWhich();
1276 }
1277
1278 // Here nWhich1 == nWhich2
1279
1280 if (!nWhich1 /* && !nWhich2*/)
1281 return true;
1282
1283 if (IsInterestingWhich(nWhich1))
1284 {
1285 const SfxPoolItem* pItem1 = nullptr;
1286 const SfxPoolItem* pItem2 = nullptr;
1287 SfxItemState state1 = aIter1.GetItemState(true, &pItem1);
1288 SfxItemState state2 = aIter2.GetItemState(true, &pItem2);
1289 if (state1 != state2
1290 && (state1 < SfxItemState::DEFAULT || state2 < SfxItemState::DEFAULT))
1291 return false;
1292 if (pItem1 != pItem2)
1293 return false;
1294 }
1295 nWhich1 = aIter1.NextWhich();
1296 nWhich2 = aIter2.NextWhich();
1297 }
1298 //TODO: also here only check really visible values !!!
1299}
1300
1301const OUString* ScPatternAttr::GetStyleName() const
1302{
1303 return pName ? &*pName : ( pStyle ? &pStyle->GetName() : nullptr );
1304}
1305
1306void ScPatternAttr::SetStyleSheet( ScStyleSheet* pNewStyle, bool bClearDirectFormat )
1307{
1308 if (pNewStyle)
1309 {
1310 SfxItemSet& rPatternSet = GetItemSet();
1311 const SfxItemSet& rStyleSet = pNewStyle->GetItemSet();
1312
1313 if (bClearDirectFormat)
1314 {
1315 for (sal_uInt16 i=ATTR_PATTERN_START; i<=ATTR_PATTERN_END; i++)
1316 {
1317 if (rStyleSet.GetItemState(i) == SfxItemState::SET)
1318 rPatternSet.ClearItem(i);
1319 }
1320 }
1321 rPatternSet.SetParent(&pNewStyle->GetItemSet());
1322 pStyle = pNewStyle;
1323 pName.reset();
1324 }
1325 else
1326 {
1327 OSL_FAIL( "ScPatternAttr::SetStyleSheet( NULL ) :-|" );
1328 GetItemSet().SetParent(nullptr);
1329 pStyle = nullptr;
1330 }
1331 mxHashCode.reset();
1332 mxVisible.reset();
1333}
1334
1336{
1337 if (pName)
1338 {
1339 pStyle = static_cast<ScStyleSheet*>(rDoc.GetStyleSheetPool()->Find(*pName, SfxStyleFamily::Para));
1340
1341 // use Standard if Style is not found,
1342 // to avoid empty display in Toolbox-Controller
1343 // Assumes that "Standard" is always the 1st entry!
1344 if (!pStyle)
1345 {
1346 std::unique_ptr<SfxStyleSheetIterator> pIter = rDoc.GetStyleSheetPool()->CreateIterator(SfxStyleFamily::Para);
1347 pStyle = dynamic_cast< ScStyleSheet* >(pIter->First());
1348 }
1349
1350 if (pStyle)
1351 {
1353 pName.reset();
1354 }
1355 }
1356 else
1357 pStyle = nullptr;
1358 mxHashCode.reset();
1359 mxVisible.reset();
1360}
1361
1363{
1364 // Style was deleted, remember name:
1365
1366 if ( pStyle )
1367 {
1368 pName = pStyle->GetName();
1369 pStyle = nullptr;
1370 GetItemSet().SetParent( nullptr );
1371 mxHashCode.reset();
1372 mxVisible.reset();
1373 }
1374}
1375
1377{
1378 if( const SvxFontItem* pItem = GetItemSet().GetItemIfSet( ATTR_FONT ) )
1379 return pItem->GetCharSet() == RTL_TEXTENCODING_SYMBOL;
1380 else
1381 return false;
1382}
1383
1384namespace {
1385
1386sal_uInt32 getNumberFormatKey(const SfxItemSet& rSet)
1387{
1388 return rSet.Get(ATTR_VALUE_FORMAT).GetValue();
1389}
1390
1391LanguageType getLanguageType(const SfxItemSet& rSet)
1392{
1393 return rSet.Get(ATTR_LANGUAGE_FORMAT).GetLanguage();
1394}
1395
1396}
1397
1399{
1400 sal_uInt32 nFormat = getNumberFormatKey(GetItemSet());
1401 LanguageType eLang = getLanguageType(GetItemSet());
1402 if ( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && eLang == LANGUAGE_SYSTEM )
1403 ; // it remains as it is
1404 else if ( pFormatter )
1405 nFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nFormat, eLang );
1406 return nFormat;
1407}
1408
1409// the same if conditional formatting is in play:
1410
1412 const SfxItemSet* pCondSet ) const
1413{
1414 assert(pFormatter);
1415 if (!pCondSet)
1416 return GetNumberFormat(pFormatter);
1417
1418 // Conditional format takes precedence over style and even hard format.
1419
1420 sal_uInt32 nFormat;
1421 LanguageType eLang;
1422 if (pCondSet->GetItemState(ATTR_VALUE_FORMAT) == SfxItemState::SET )
1423 {
1424 nFormat = getNumberFormatKey(*pCondSet);
1425 if (pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT) == SfxItemState::SET)
1426 eLang = getLanguageType(*pCondSet);
1427 else
1428 eLang = getLanguageType(GetItemSet());
1429 }
1430 else
1431 {
1432 nFormat = getNumberFormatKey(GetItemSet());
1433 eLang = getLanguageType(GetItemSet());
1434 }
1435
1436 return pFormatter->GetFormatForLanguageIfBuiltIn(nFormat, eLang);
1437}
1438
1439const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
1440{
1441 const SfxPoolItem* pCondItem;
1442 if ( pCondSet && pCondSet->GetItemState( nWhich, true, &pCondItem ) == SfxItemState::SET )
1443 return *pCondItem;
1444 return rItemSet.Get(nWhich);
1445}
1446
1447const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nSubWhich, const SfxItemSet* pCondSet ) const
1448{
1449 return GetItem( nSubWhich, GetItemSet(), pCondSet );
1450}
1451
1452// GetRotateVal is tested before ATTR_ORIENTATION
1453
1455{
1456 Degree100 nAttrRotate(0);
1457 if ( GetCellOrientation() == SvxCellOrientation::Standard )
1458 {
1459 bool bRepeat = ( GetItem(ATTR_HOR_JUSTIFY, pCondSet).
1460 GetValue() == SvxCellHorJustify::Repeat );
1461 // ignore orientation/rotation if "repeat" is active
1462 if ( !bRepeat )
1463 nAttrRotate = GetItem( ATTR_ROTATE_VALUE, pCondSet ).GetValue();
1464 }
1465 return nAttrRotate;
1466}
1467
1469{
1471
1472 Degree100 nAttrRotate = GetRotateVal( pCondSet );
1473 if ( nAttrRotate )
1474 {
1475 SvxRotateMode eRotMode = GetItem(ATTR_ROTATE_MODE, pCondSet).GetValue();
1476
1477 if ( eRotMode == SVX_ROTATE_MODE_STANDARD || nAttrRotate == 18000_deg100 )
1478 nRet = ScRotateDir::Standard;
1479 else if ( eRotMode == SVX_ROTATE_MODE_CENTER )
1480 nRet = ScRotateDir::Center;
1481 else if ( eRotMode == SVX_ROTATE_MODE_TOP || eRotMode == SVX_ROTATE_MODE_BOTTOM )
1482 {
1483 Degree100 nRot180 = nAttrRotate % 18000_deg100; // 1/100 degrees
1484 if ( nRot180 == 9000_deg100 )
1485 nRet = ScRotateDir::Center;
1486 else if ( ( eRotMode == SVX_ROTATE_MODE_TOP && nRot180 < 9000_deg100 ) ||
1487 ( eRotMode == SVX_ROTATE_MODE_BOTTOM && nRot180 > 9000_deg100 ) )
1488 nRet = ScRotateDir::Left;
1489 else
1490 nRet = ScRotateDir::Right;
1491 }
1492 }
1493
1494 return nRet;
1495}
1496
1497void ScPatternAttr::SetKey(sal_uInt64 nKey)
1498{
1499 mnKey = nKey;
1500}
1501
1502sal_uInt64 ScPatternAttr::GetKey() const
1503{
1504 return mnKey;
1505}
1506
1508{
1509 auto const & rSet = GetItemSet();
1510 // This is an unrolled hash function so the compiler/CPU can execute it in parallel,
1511 // because we hit this hard when loading documents with lots of styles.
1512 sal_uInt32 h1 = 0;
1513 sal_uInt32 h2 = 0;
1514 sal_uInt32 h3 = 0;
1515 sal_uInt32 h4 = 0;
1516 for (auto it = rSet.GetItems_Impl(), end = rSet.GetItems_Impl() + (compareSize / 4 * 4); it != end; )
1517 {
1518 h1 = 31 * h1 + reinterpret_cast<size_t>(*it);
1519 ++it;
1520 h2 = 31 * h2 + reinterpret_cast<size_t>(*it);
1521 ++it;
1522 h3 = 31 * h3 + reinterpret_cast<size_t>(*it);
1523 ++it;
1524 h4 = 31 * h4 + reinterpret_cast<size_t>(*it);
1525 ++it;
1526 }
1527 mxHashCode = h1 + h2 + h3 + h4;
1528}
1529
1530/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr auto convertTwipToMm100(N n)
const char * pName
sal_uInt32 GetValue() const
bool IsBright() const
bool IsDark() const
void SetScaleY(const Fraction &rScaleY)
MapUnit GetMapUnit() const
void SetScaleX(const Fraction &rScaleX)
SAL_DLLPRIVATE sal_Int32 GetDPIX() const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const MapMode & GetMapMode() const
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6050
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6055
SC_DLLPUBLIC sal_uLong AddValidationEntry(const ScValidationData &rNew)
Definition: documen4.cxx:719
const ScValidationDataList * GetValidationList() const
Definition: document.hxx:1879
SvNumberFormatterIndexTable * GetFormatExchangeList() const
Definition: document.hxx:923
sal_uInt64 mnKey
Definition: patattr.hxx:59
bool IsSymbolFont() const
If font is an old symbol font StarBats/StarMath with text encoding RTL_TEXTENC_SYMBOL.
Definition: patattr.cxx:1376
void UpdateStyleSheet(const ScDocument &rDoc)
Definition: patattr.cxx:1335
void StyleToName()
Definition: patattr.cxx:1362
virtual lookup_iterator Lookup(lookup_iterator begin, lookup_iterator end) const override
Definition: patattr.cxx:169
virtual bool operator==(const SfxPoolItem &rCmp) const override
Definition: patattr.cxx:152
std::optional< sal_uInt32 > mxHashCode
Definition: patattr.hxx:56
ScStyleSheet * pStyle
Definition: patattr.hxx:58
static void fillFont(vcl::Font &rFont, const SfxItemSet &rItemSet, ScAutoFontColorMode eAutoMode, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE, const Color *pBackConfigColor=nullptr, const Color *pTextConfigColor=nullptr)
Definition: patattr.cxx:250
void ClearItems(const sal_uInt16 *pWhich)
Definition: patattr.cxx:1060
ScPatternAttr * PutInPool(ScDocument *pDestDoc, ScDocument *pSrcDoc) const
Definition: patattr.cxx:1128
void CalcHashCode() const
Definition: patattr.cxx:1507
std::optional< OUString > pName
Definition: patattr.hxx:55
bool IsVisible() const
Definition: patattr.cxx:1201
Degree100 GetRotateVal(const SfxItemSet *pCondSet) const
Definition: patattr.cxx:1454
bool CalcVisible() const
Definition: patattr.cxx:1208
static std::optional< bool > FastEqualPatternSets(const SfxItemSet &rSet1, const SfxItemSet &rSet2)
Definition: patattr.cxx:124
bool IsVisibleEqual(const ScPatternAttr &rOther) const
Definition: patattr.cxx:1238
const OUString * GetStyleName() const
Definition: patattr.cxx:1301
void SetStyleSheet(ScStyleSheet *pNewStyle, bool bClearDirectFormat=true)
Definition: patattr.cxx:1306
static void fillColor(model::ComplexColor &rComplexColor, const SfxItemSet &rItemSet, ScAutoFontColorMode eAutoMode, const SfxItemSet *pCondSet=nullptr, const Color *pBackConfigColor=nullptr, const Color *pTextConfigColor=nullptr)
Definition: patattr.cxx:435
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
Definition: patattr.cxx:1398
ScPatternAttr(SfxItemSet &&pItemSet, const OUString &rStyleName)
Definition: patattr.cxx:71
void DeleteUnchanged(const ScPatternAttr *pOldAttrs)
Definition: patattr.cxx:1013
sal_uInt64 GetKey() const
Definition: patattr.cxx:1502
ScRotateDir GetRotateDir(const SfxItemSet *pCondSet) const
Definition: patattr.cxx:1468
static void FillToEditItemSet(SfxItemSet &rEditSet, const SfxItemSet &rSrcSet, const SfxItemSet *pCondSet=nullptr)
Converts all Calc items contained in rSrcSet to edit engine items and puts them into rEditSet.
Definition: patattr.cxx:642
static ScDxfFont GetDxfFont(const SfxItemSet &rSet, SvtScriptType nScript)
Definition: patattr.cxx:546
void SetKey(sal_uInt64 nKey)
Definition: patattr.cxx:1497
bool HasItemsSet(const sal_uInt16 *pWhich) const
Definition: patattr.cxx:1051
SfxItemSet & GetItemSet()
Definition: patattr.hxx:192
static void fillFontOnly(vcl::Font &rFont, const SfxItemSet &rItemSet, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE)
Static helper function to fill a font object from the passed item set.
Definition: patattr.cxx:266
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:73
void FillEditItemSet(SfxItemSet *pEditSet, const SfxItemSet *pCondSet=nullptr) const
Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSe...
Definition: patattr.cxx:868
static void GetFromEditItemSet(SfxItemSet &rDestSet, const SfxItemSet &rEditSet)
Converts all edit engine items contained in rEditSet to Calc items and puts them into rDestSet.
Definition: patattr.cxx:874
static SvxCellOrientation GetCellOrientation(const SfxItemSet &rItemSet, const SfxItemSet *pCondSet)
Definition: patattr.cxx:188
std::optional< bool > mxVisible
Definition: patattr.hxx:57
virtual ScPatternAttr * Clone(SfxItemPool *pPool=nullptr) const override
Definition: patattr.cxx:101
void FillEditParaItems(SfxItemSet *pSet) const
Definition: patattr.cxx:993
virtual SC_DLLPUBLIC SfxItemSet & GetItemSet() override
Definition: stlsheet.cxx:133
ScViewData & GetViewData()
Definition: tabview.hxx:344
ScValidationData * GetData(sal_uInt32 nKey)
Definition: validat.cxx:1122
const ScViewOptions & GetOptions() const
Definition: viewdata.hxx:554
const Color & GetDocColor() const
Definition: viewopti.hxx:101
bool GetValue() const
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
SfxItemPool * GetPool() const
void SetParent(const SfxItemSet *pNew)
sal_uInt16 Count() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxPoolItem const ** GetItems_Impl() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
sal_uInt16 TotalCount() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
std::vector< SfxPoolItem * >::const_iterator lookup_iterator
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual const OUString & GetParent() const
const OUString & GetName() const
SfxStyleFamily GetFamily() const
virtual bool SetParent(const OUString &)
virtual SfxItemSet & GetItemSet()
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
sal_uInt16 FirstWhich()
SfxItemState GetItemState(bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
sal_uInt16 NextWhich()
sal_uInt32 GetFormatForLanguageIfBuiltIn(sal_uInt32 nFormat, LanguageType eLnge=LANGUAGE_DONTKNOW)
SvxAdjust GetAdjust() const
const Color & GetColor() const
const Color & GetValue() const
model::ComplexColor const & getComplexColor() const
FontEmphasisMark GetEmphasisMark() const
sal_uInt32 GetHeight() const
FontFamily GetFamily() const
FontPitch GetPitch() const
const OUString & GetStyleName() const
rtl_TextEncoding GetCharSet() const
const OUString & GetFamilyName() const
LanguageType GetLanguage() const
ColorType getType() const
void setColor(Color const &rColor)
void setFinalColor(Color const &rColor)
Color const & getFinalColor() const
void SetFontSize(const Size &)
void SetOutline(bool bOutline)
void SetStyleName(const OUString &rStyleName)
void SetWordLineMode(bool bWordLine)
void SetPitch(FontPitch ePitch)
void SetTransparent(bool bTransparent)
void SetColor(const Color &)
const OUString & GetStyleName() const
void SetItalic(FontItalic)
void SetWeight(FontWeight)
const OUString & GetFamilyName() const
void SetFamily(FontFamily)
void SetUnderline(FontLineStyle)
void SetCharSet(rtl_TextEncoding)
void SetOverline(FontLineStyle)
void SetFamilyName(const OUString &rFamilyName)
void SetLanguage(LanguageType)
void SetShadow(bool bShadow)
void SetRelief(FontRelief)
void SetEmphasisMark(FontEmphasisMark)
void SetStrikeout(FontStrikeout)
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr TypedWhichId< SvxContourItem > EE_CHAR_OUTLINE(EE_CHAR_START+8)
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE(EE_PARA_START+6)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SvxShadowedItem > EE_CHAR_SHADOW(EE_CHAR_START+9)
constexpr TypedWhichId< SvxOverlineItem > EE_CHAR_OVERLINE(EE_CHAR_START+29)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CTL(EE_CHAR_START+16)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CTL(EE_CHAR_START+22)
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
constexpr TypedWhichId< SvxForbiddenRuleItem > EE_PARA_FORBIDDENRULES(EE_PARA_START+3)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
constexpr TypedWhichId< SvxEmphasisMarkItem > EE_CHAR_EMPHASISMARK(EE_CHAR_START+25)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CJK(EE_CHAR_START+21)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
constexpr TypedWhichId< SvxFrameDirectionItem > EE_PARA_WRITINGDIR(EE_PARA_START+0)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CJK(EE_CHAR_START+23)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CTL(EE_CHAR_START+24)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
constexpr TypedWhichId< SvxScriptSpaceItem > EE_PARA_ASIANCJKSPACING(EE_PARA_START+4)
constexpr TypedWhichId< SvxWordLineModeItem > EE_CHAR_WLM(EE_CHAR_START+13)
constexpr TypedWhichId< SvxCharReliefItem > EE_CHAR_RELIEF(EE_CHAR_START+26)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
ScRotateDir
Definition: fillinfo.hxx:40
FontRelief
FontLineStyle
LINESTYLE_NONE
FontStrikeout
FontItalic
FontEmphasisMark
SvxFrameDirection
sal_Int64 n
#define LANGUAGE_SYSTEM
SvtScriptType
bool equal(T const &rfValA, T const &rfValB)
int i
constexpr auto toTwips(N number, Length from)
enumrange< T >::Iterator begin(enumrange< T >)
end
FontWeight
long Long
const char GetValue[]
constexpr size_t compareSize
Definition: patattr.cxx:122
static SfxStyleSheetBase * lcl_CopyStyleToPool(SfxStyleSheetBase *pSrcStyle, SfxStyleSheetBasePool *pSrcPool, SfxStyleSheetBasePool *pDestPool, const SvNumberFormatterIndexTable *pFormatExchangeList)
Definition: patattr.cxx:1070
static bool StrCmp(const OUString *pStr1, const OUString *pStr2)
Definition: patattr.cxx:111
static void lcl_populate(std::unique_ptr< T > &rxItem, TypedWhichId< T > nWhich, const SfxItemSet &rSrcSet, const SfxItemSet *pCondSet)
Definition: patattr.cxx:634
static bool EqualPatternSets(const SfxItemSet &rSet1, const SfxItemSet &rSet2)
Definition: patattr.cxx:144
ScAutoFontColorMode
how to treat COL_AUTO in GetFont:
Definition: patattr.hxx:44
@ Print
black or white, depending on background
@ IgnoreAll
like DISPLAY, but ignore stored font and background colors
@ Raw
COL_AUTO is returned.
@ IgnoreBack
like DISPLAY, but ignore stored background color (use configured color)
@ IgnoreFont
like DISPLAY, but ignore stored font color (assume COL_AUTO)
SfxItemState
SvxRotateMode
SVX_ROTATE_MODE_BOTTOM
SVX_ROTATE_MODE_STANDARD
SVX_ROTATE_MODE_CENTER
SVX_ROTATE_MODE_TOP
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
constexpr TypedWhichId< SvxFontItem > ATTR_CJK_FONT(111)
constexpr TypedWhichId< ScPatternAttr > ATTR_PATTERN(156)
constexpr TypedWhichId< SvxForbiddenRuleItem > ATTR_FORBIDDEN_RULES(128)
constexpr TypedWhichId< SvxPostureItem > ATTR_CTL_FONT_POSTURE(119)
constexpr TypedWhichId< SvxFontItem > ATTR_CTL_FONT(116)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CJK_FONT_HEIGHT(112)
constexpr TypedWhichId< SvxPostureItem > ATTR_FONT_POSTURE(103)
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxWeightItem > ATTR_CJK_FONT_WEIGHT(113)
constexpr TypedWhichId< SvxEmphasisMarkItem > ATTR_FONT_EMPHASISMARK(121)
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_TLBR(141)
constexpr TypedWhichId< SvxShadowedItem > ATTR_FONT_SHADOWED(108)
constexpr TypedWhichId< SvxWordLineModeItem > ATTR_FONT_WORDLINE(123)
constexpr TypedWhichId< SvxContourItem > ATTR_FONT_CONTOUR(107)
constexpr TypedWhichId< SvxLanguageItem > ATTR_CTL_FONT_LANGUAGE(120)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
constexpr TypedWhichId< SvxOverlineItem > ATTR_FONT_OVERLINE(105)
constexpr TypedWhichId< SvxShadowItem > ATTR_SHADOW(152)
constexpr TypedWhichId< SvxLanguageItem > ATTR_LANGUAGE_FORMAT(147)
constexpr TypedWhichId< ScRotateValueItem > ATTR_ROTATE_VALUE(135)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
constexpr sal_uInt16 ATTR_PATTERN_START(100)
constexpr TypedWhichId< SvxRotateModeItem > ATTR_ROTATE_MODE(136)
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
constexpr TypedWhichId< SvxCharReliefItem > ATTR_FONT_RELIEF(124)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
constexpr TypedWhichId< SvxFrameDirectionItem > ATTR_WRITINGDIR(138)
constexpr TypedWhichId< SvxCrossedOutItem > ATTR_FONT_CROSSEDOUT(106)
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_BLTR(142)
constexpr TypedWhichId< ScVerticalStackCell > ATTR_STACKED(134)
constexpr TypedWhichId< ScHyphenateCell > ATTR_HYPHENATE(125)
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
constexpr TypedWhichId< SvxLanguageItem > ATTR_FONT_LANGUAGE(110)
constexpr sal_uInt16 ATTR_PATTERN_END(155)
constexpr TypedWhichId< SvxWeightItem > ATTR_CTL_FONT_WEIGHT(118)
constexpr TypedWhichId< SvxPostureItem > ATTR_CJK_FONT_POSTURE(114)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALIDDATA(153)
constexpr TypedWhichId< SvxLanguageItem > ATTR_CJK_FONT_LANGUAGE(115)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CTL_FONT_HEIGHT(117)
constexpr TypedWhichId< SvxUnderlineItem > ATTR_FONT_UNDERLINE(104)
#define SC_MOD()
Definition: scmod.hxx:247
static SfxItemSet & rSet
sal_uIntPtr sal_uLong
std::optional< bool > bShadow
Definition: fonthelper.hxx:32
std::optional< const SvxFontItem * > pFontAttr
Definition: fonthelper.hxx:23
std::optional< bool > bOutline
Definition: fonthelper.hxx:31
std::optional< bool > bWordLine
Definition: fonthelper.hxx:29
std::optional< FontLineStyle > eUnder
Definition: fonthelper.hxx:27
std::optional< FontItalic > eItalic
Definition: fonthelper.hxx:26
std::optional< FontLineStyle > eOver
Definition: fonthelper.hxx:28
std::optional< FontRelief > eRelief
Definition: fonthelper.hxx:34
std::optional< LanguageType > eLang
Definition: fonthelper.hxx:36
std::optional< FontStrikeout > eStrike
Definition: fonthelper.hxx:30
std::optional< FontEmphasisMark > eEmphasis
Definition: fonthelper.hxx:33
std::optional< sal_uInt32 > nFontHeight
Definition: fonthelper.hxx:24
std::optional< FontWeight > eWeight
Definition: fonthelper.hxx:25
std::optional< Color > aColor
Definition: fonthelper.hxx:35
SfxStyleFamily
SvxCellHorJustify
SvxCellOrientation
SvxAdjust
std::unordered_map< sal_uInt16, sal_uInt32 > SvNumberFormatterIndexTable
#define SV_COUNTRY_LANGUAGE_OFFSET