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/zforlist.hxx>
51#include <vcl/outdev.hxx>
52#include <tools/fract.hxx>
54#include <osl/diagnose.h>
55
56#include <attrib.hxx>
57#include <patattr.hxx>
58#include <docpool.hxx>
59#include <stlsheet.hxx>
60#include <stlpool.hxx>
61#include <document.hxx>
62#include <globstr.hrc>
63#include <scresid.hxx>
64#include <validat.hxx>
65#include <scmod.hxx>
66#include <fillinfo.hxx>
67#include <boost/functional/hash.hpp>
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 if( *mxHashCode != 0 )
174 {
175 for( auto it = begin; it != end; ++it)
176 {
177 const ScPatternAttr* other = static_cast<const ScPatternAttr*>(*it);
178 if( !other->mxHashCode )
179 other->CalcHashCode();
180 if (*mxHashCode == *other->mxHashCode
181 && EqualPatternSets( GetItemSet(), other->GetItemSet())
182 && StrCmp( GetStyleName(), other->GetStyleName()))
183 {
184 return it;
185 }
186 }
187 }
188 return end;
189}
190
192{
193 SvxCellOrientation eOrient = SvxCellOrientation::Standard;
194
195 if( GetItem( ATTR_STACKED, rItemSet, pCondSet ).GetValue() )
196 {
197 eOrient = SvxCellOrientation::Stacked;
198 }
199 else
200 {
201 Degree100 nAngle = GetItem( ATTR_ROTATE_VALUE, rItemSet, pCondSet ).GetValue();
202 if( nAngle == 9000_deg100 )
203 eOrient = SvxCellOrientation::BottomUp;
204 else if( nAngle == 27000_deg100 )
205 eOrient = SvxCellOrientation::TopBottom;
206 }
207
208 return eOrient;
209}
210
212{
213 return GetCellOrientation( GetItemSet(), pCondSet );
214}
215
216namespace {
217
218void getFontIDsByScriptType(SvtScriptType nScript,
224{
225 if ( nScript == SvtScriptType::ASIAN )
226 {
227 nFontId = ATTR_CJK_FONT;
228 nHeightId = ATTR_CJK_FONT_HEIGHT;
229 nWeightId = ATTR_CJK_FONT_WEIGHT;
230 nPostureId = ATTR_CJK_FONT_POSTURE;
231 nLangId = ATTR_CJK_FONT_LANGUAGE;
232 }
233 else if ( nScript == SvtScriptType::COMPLEX )
234 {
235 nFontId = ATTR_CTL_FONT;
236 nHeightId = ATTR_CTL_FONT_HEIGHT;
237 nWeightId = ATTR_CTL_FONT_WEIGHT;
238 nPostureId = ATTR_CTL_FONT_POSTURE;
239 nLangId = ATTR_CTL_FONT_LANGUAGE;
240 }
241 else
242 {
243 nFontId = ATTR_FONT;
244 nHeightId = ATTR_FONT_HEIGHT;
245 nWeightId = ATTR_FONT_WEIGHT;
246 nPostureId = ATTR_FONT_POSTURE;
247 nLangId = ATTR_FONT_LANGUAGE;
248 }
249}
250
251}
252
254 vcl::Font& rFont, const SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode,
255 const OutputDevice* pOutDev, const Fraction* pScale,
256 const SfxItemSet* pCondSet, SvtScriptType nScript,
257 const Color* pBackConfigColor, const Color* pTextConfigColor )
258{
259 // Read items
260
261 const SvxFontItem* pFontAttr;
262 sal_uInt32 nFontHeight;
263 FontWeight eWeight;
264 FontItalic eItalic;
265 FontLineStyle eUnder;
266 FontLineStyle eOver;
267 bool bWordLine;
268 FontStrikeout eStrike;
269 bool bOutline;
270 bool bShadow;
271 FontEmphasisMark eEmphasis;
272 FontRelief eRelief;
273 Color aColor;
274 LanguageType eLang;
275
276 TypedWhichId<SvxFontItem> nFontId(0);
278 TypedWhichId<SvxWeightItem> nWeightId(0);
279 TypedWhichId<SvxPostureItem> nPostureId(0);
281 getFontIDsByScriptType(nScript, nFontId, nHeightId, nWeightId, nPostureId, nLangId);
282
283 if ( pCondSet )
284 {
285 pFontAttr = pCondSet->GetItemIfSet( nFontId );
286 if ( !pFontAttr )
287 pFontAttr = &rItemSet.Get( nFontId );
288
289 const SvxFontHeightItem* pFontHeightItem = pCondSet->GetItemIfSet( nHeightId );
290 if ( !pFontHeightItem )
291 pFontHeightItem = &rItemSet.Get( nHeightId );
292 nFontHeight = pFontHeightItem->GetHeight();
293
294 const SvxWeightItem* pFontHWeightItem = pCondSet->GetItemIfSet( nWeightId );
295 if ( !pFontHWeightItem )
296 pFontHWeightItem = &rItemSet.Get( nWeightId );
297 eWeight = pFontHWeightItem->GetValue();
298
299 const SvxPostureItem* pPostureItem = pCondSet->GetItemIfSet( nPostureId );
300 if ( !pPostureItem )
301 pPostureItem = &rItemSet.Get( nPostureId );
302 eItalic = pPostureItem->GetValue();
303
304 const SvxUnderlineItem* pUnderlineItem = pCondSet->GetItemIfSet( ATTR_FONT_UNDERLINE );
305 if ( !pUnderlineItem )
306 pUnderlineItem = &rItemSet.Get( ATTR_FONT_UNDERLINE );
307 eUnder = pUnderlineItem->GetValue();
308
309 const SvxOverlineItem* pOverlineItem = pCondSet->GetItemIfSet( ATTR_FONT_OVERLINE );
310 if ( !pOverlineItem )
311 pOverlineItem = &rItemSet.Get( ATTR_FONT_OVERLINE );
312 eOver = pOverlineItem->GetValue();
313
314 const SvxWordLineModeItem* pWordlineItem = pCondSet->GetItemIfSet( ATTR_FONT_WORDLINE );
315 if ( !pWordlineItem )
316 pWordlineItem = &rItemSet.Get( ATTR_FONT_WORDLINE );
317 bWordLine = pWordlineItem->GetValue();
318
319 const SvxCrossedOutItem* pCrossedOutItem = pCondSet->GetItemIfSet( ATTR_FONT_CROSSEDOUT );
320 if ( !pCrossedOutItem )
321 pCrossedOutItem = &rItemSet.Get( ATTR_FONT_CROSSEDOUT );
322 eStrike = pCrossedOutItem->GetValue();
323
324 const SvxContourItem* pContourItem = pCondSet->GetItemIfSet( ATTR_FONT_CONTOUR );
325 if ( !pContourItem )
326 pContourItem = &rItemSet.Get( ATTR_FONT_CONTOUR );
327 bOutline = pContourItem->GetValue();
328
329 const SvxShadowedItem* pShadowedItem = pCondSet->GetItemIfSet( ATTR_FONT_SHADOWED );
330 if ( !pShadowedItem )
331 pShadowedItem = &rItemSet.Get( ATTR_FONT_SHADOWED );
332 bShadow = pShadowedItem->GetValue();
333
334 const SvxEmphasisMarkItem* pEmphasisMarkItem = pCondSet->GetItemIfSet( ATTR_FONT_EMPHASISMARK );
335 if ( !pEmphasisMarkItem )
336 pEmphasisMarkItem = &rItemSet.Get( ATTR_FONT_EMPHASISMARK );
337 eEmphasis = pEmphasisMarkItem->GetEmphasisMark();
338
339 const SvxCharReliefItem* pCharReliefItem = pCondSet->GetItemIfSet( ATTR_FONT_RELIEF );
340 if ( !pCharReliefItem )
341 pCharReliefItem = &rItemSet.Get( ATTR_FONT_RELIEF );
342 eRelief = pCharReliefItem->GetValue();
343
344 const SvxColorItem* pColorItem = pCondSet->GetItemIfSet( ATTR_FONT_COLOR );
345 if ( !pColorItem )
346 pColorItem = &rItemSet.Get( ATTR_FONT_COLOR );
347 aColor = pColorItem->GetValue();
348
349 const SvxLanguageItem* pLanguageItem = pCondSet->GetItemIfSet( nLangId );
350 if ( !pLanguageItem )
351 pLanguageItem = &rItemSet.Get( nLangId );
352 eLang = pLanguageItem->GetLanguage();
353 }
354 else // Everything from rItemSet
355 {
356 pFontAttr = &rItemSet.Get( nFontId );
357 nFontHeight = rItemSet.Get( nHeightId ).GetHeight();
358 eWeight = rItemSet.Get( nWeightId ).GetValue();
359 eItalic = rItemSet.Get( nPostureId ).GetValue();
360 eUnder = rItemSet.Get( ATTR_FONT_UNDERLINE ).GetValue();
361 eOver = rItemSet.Get( ATTR_FONT_OVERLINE ).GetValue();
362 bWordLine = rItemSet.Get( ATTR_FONT_WORDLINE ).GetValue();
363 eStrike = rItemSet.Get( ATTR_FONT_CROSSEDOUT ).GetValue();
364 bOutline = rItemSet.Get( ATTR_FONT_CONTOUR ).GetValue();
365 bShadow = rItemSet.Get( ATTR_FONT_SHADOWED ).GetValue();
366 eEmphasis = rItemSet.Get( ATTR_FONT_EMPHASISMARK ).GetEmphasisMark();
367 eRelief = rItemSet.Get( ATTR_FONT_RELIEF ).GetValue();
368 aColor = rItemSet.Get( ATTR_FONT_COLOR ).GetValue();
369 // for graphite language features
370 eLang = rItemSet.Get( nLangId ).GetLanguage();
371 }
372 OSL_ENSURE(pFontAttr,"Oops?");
373
374 // Evaluate
375
376 // FontItem:
377
378 if (rFont.GetFamilyName() != pFontAttr->GetFamilyName())
379 rFont.SetFamilyName( pFontAttr->GetFamilyName() );
380 if (rFont.GetStyleName() != pFontAttr->GetStyleName())
381 rFont.SetStyleName( pFontAttr->GetStyleName() );
382
383 rFont.SetFamily( pFontAttr->GetFamily() );
384 rFont.SetCharSet( pFontAttr->GetCharSet() );
385 rFont.SetPitch( pFontAttr->GetPitch() );
386
387 rFont.SetLanguage(eLang);
388
389 // Size
390
391 if ( pOutDev != nullptr )
392 {
393 Size aEffSize;
394 Fraction aFraction( 1,1 );
395 if (pScale)
396 aFraction = *pScale;
397 Size aSize( 0, static_cast<tools::Long>(nFontHeight) );
398 MapMode aDestMode = pOutDev->GetMapMode();
399 MapMode aSrcMode( MapUnit::MapTwip, Point(), aFraction, aFraction );
400 if (aDestMode.GetMapUnit() == MapUnit::MapPixel && pOutDev->GetDPIX() > 0)
401 aEffSize = pOutDev->LogicToPixel( aSize, aSrcMode );
402 else
403 {
404 Fraction aFractOne(1,1);
405 aDestMode.SetScaleX( aFractOne );
406 aDestMode.SetScaleY( aFractOne );
407 aEffSize = OutputDevice::LogicToLogic( aSize, aSrcMode, aDestMode );
408 }
409 rFont.SetFontSize( aEffSize );
410 }
411 else /* if pOutDev != NULL */
412 {
413 rFont.SetFontSize( Size( 0, static_cast<tools::Long>(nFontHeight) ) );
414 }
415
416 // determine effective font color
417
418 if ( ( aColor == COL_AUTO && eAutoMode != SC_AUTOCOL_RAW ) ||
419 eAutoMode == SC_AUTOCOL_IGNOREFONT || eAutoMode == SC_AUTOCOL_IGNOREALL )
420 {
421 if ( eAutoMode == SC_AUTOCOL_BLACK )
422 aColor = COL_BLACK;
423 else
424 {
425 // get background color from conditional or own set
426 Color aBackColor;
427 if ( pCondSet )
428 {
429 const SvxBrushItem* pItem = pCondSet->GetItemIfSet( ATTR_BACKGROUND );
430 if ( !pItem )
431 pItem = &rItemSet.Get( ATTR_BACKGROUND );
432 aBackColor = pItem->GetColor();
433 }
434 else
435 aBackColor = rItemSet.Get( ATTR_BACKGROUND ).GetColor();
436
437 // if background color attribute is transparent, use window color for brightness comparisons
438 if ( aBackColor == COL_TRANSPARENT ||
439 eAutoMode == SC_AUTOCOL_IGNOREBACK || eAutoMode == SC_AUTOCOL_IGNOREALL )
440 {
442 {
443 if ( eAutoMode == SC_AUTOCOL_PRINT )
444 aBackColor = COL_WHITE;
445 else if ( pBackConfigColor )
446 {
447 // pBackConfigColor can be used to avoid repeated lookup of the configured color
448 aBackColor = *pBackConfigColor;
449 }
450 else
451 aBackColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
452 }
453 else
454 {
455 // Get document color from current view instead
456 SfxViewShell* pSfxViewShell = SfxViewShell::Current();
457 ScTabViewShell* pViewShell = dynamic_cast<ScTabViewShell*>(pSfxViewShell);
458 if (pViewShell)
459 {
460 const ScViewData& pViewData = pViewShell->GetViewData();
461 const ScViewOptions& aViewOptions = pViewData.GetOptions();
462 aBackColor = aViewOptions.GetDocColor();
463 }
464 }
465 }
466
467 // get system text color for comparison
468 Color aSysTextColor;
469 if ( eAutoMode == SC_AUTOCOL_PRINT )
470 aSysTextColor = COL_BLACK;
471 else if ( pTextConfigColor )
472 {
473 // pTextConfigColor can be used to avoid repeated lookup of the configured color
474 aSysTextColor = *pTextConfigColor;
475 }
476 else
477 aSysTextColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor;
478
479 // select the resulting color
480 if ( aBackColor.IsDark() && aSysTextColor.IsDark() )
481 {
482 // use white instead of dark on dark
483 aColor = COL_WHITE;
484 }
485 else if ( aBackColor.IsBright() && aSysTextColor.IsBright() )
486 {
487 // use black instead of bright on bright
488 aColor = COL_BLACK;
489 }
490 else
491 {
492 // use aSysTextColor (black for SC_AUTOCOL_PRINT, from style settings otherwise)
493 aColor = aSysTextColor;
494 }
495 }
496 }
497
498 // set font effects
499 rFont.SetWeight( eWeight );
500 rFont.SetItalic( eItalic );
501 rFont.SetUnderline( eUnder );
502 rFont.SetOverline( eOver );
503 rFont.SetWordLineMode( bWordLine );
504 rFont.SetStrikeout( eStrike );
505 rFont.SetOutline( bOutline );
506 rFont.SetShadow( bShadow );
507 rFont.SetEmphasisMark( eEmphasis );
508 rFont.SetRelief( eRelief );
509 rFont.SetColor( aColor );
510 rFont.SetTransparent( true );
511}
512
514 vcl::Font& rFont, ScAutoFontColorMode eAutoMode,
515 const OutputDevice* pOutDev, const Fraction* pScale,
516 const SfxItemSet* pCondSet, SvtScriptType nScript,
517 const Color* pBackConfigColor, const Color* pTextConfigColor ) const
518{
519 GetFont( rFont, GetItemSet(), eAutoMode, pOutDev, pScale, pCondSet, nScript, pBackConfigColor, pTextConfigColor );
520}
521
523{
524 TypedWhichId<SvxFontItem> nFontId(0);
526 TypedWhichId<SvxWeightItem> nWeightId(0);
527 TypedWhichId<SvxPostureItem> nPostureId(0);
529 getFontIDsByScriptType(nScript, nFontId, nHeightId, nWeightId, nPostureId, nLangId);
530
531 ScDxfFont aReturn;
532
533 if ( const SvxFontItem* pItem = rItemSet.GetItemIfSet( nFontId ) )
534 {
535 aReturn.pFontAttr = pItem;
536 }
537
538 if ( const SvxFontHeightItem* pItem = rItemSet.GetItemIfSet( nHeightId ) )
539 {
540 aReturn.nFontHeight = pItem->GetHeight();
541 }
542
543 if ( const SvxWeightItem* pItem = rItemSet.GetItemIfSet( nWeightId ) )
544 {
545 aReturn.eWeight = pItem->GetValue();
546 }
547
548 if ( const SvxPostureItem* pItem = rItemSet.GetItemIfSet( nPostureId ) )
549 {
550 aReturn.eItalic = pItem->GetValue();
551 }
552
553 if ( const SvxUnderlineItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_UNDERLINE ) )
554 {
555 pItem = &rItemSet.Get( ATTR_FONT_UNDERLINE );
556 aReturn.eUnder = pItem->GetValue();
557 }
558
559 if ( const SvxOverlineItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_OVERLINE ) )
560 {
561 aReturn.eOver = pItem->GetValue();
562 }
563
564 if ( const SvxWordLineModeItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_WORDLINE ) )
565 {
566 aReturn.bWordLine = pItem->GetValue();
567 }
568
569 if ( const SvxCrossedOutItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_CROSSEDOUT ) )
570 {
571 pItem = &rItemSet.Get( ATTR_FONT_CROSSEDOUT );
572 aReturn.eStrike = pItem->GetValue();
573 }
574
575 if ( const SvxContourItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_CONTOUR ) )
576 {
577 aReturn.bOutline = pItem->GetValue();
578 }
579
580 if ( const SvxShadowedItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_SHADOWED ) )
581 {
582 pItem = &rItemSet.Get( ATTR_FONT_SHADOWED );
583 aReturn.bShadow = pItem->GetValue();
584 }
585
586 if ( const SvxEmphasisMarkItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_EMPHASISMARK ) )
587 {
588 aReturn.eEmphasis = pItem->GetEmphasisMark();
589 }
590
591 if ( const SvxCharReliefItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_RELIEF ) )
592 {
593 aReturn.eRelief = pItem->GetValue();
594 }
595
596 if ( const SvxColorItem* pItem = rItemSet.GetItemIfSet( ATTR_FONT_COLOR ) )
597 {
598 aReturn.aColor = pItem->GetValue();
599 }
600
601 if ( const SvxLanguageItem* pItem = rItemSet.GetItemIfSet( nLangId ) )
602 {
603 aReturn.eLang = pItem->GetLanguage();
604 }
605
606 return aReturn;
607}
608
609template <class T>
610static void lcl_populate( std::unique_ptr<T>& rxItem, TypedWhichId<T> nWhich, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet )
611{
612 const T* pItem = pCondSet->GetItemIfSet( nWhich );
613 if ( !pItem )
614 pItem = &rSrcSet.Get( nWhich );
615 rxItem.reset(pItem->Clone());
616}
617
618void ScPatternAttr::FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet )
619{
620 // Read Items
621
622 std::unique_ptr<SvxColorItem> aColorItem(std::make_unique<SvxColorItem>(EE_CHAR_COLOR)); // use item as-is
623 std::unique_ptr<SvxFontItem> aFontItem(std::make_unique<SvxFontItem>(EE_CHAR_FONTINFO)); // use item as-is
624 std::unique_ptr<SvxFontItem> aCjkFontItem(std::make_unique<SvxFontItem>(EE_CHAR_FONTINFO_CJK)); // use item as-is
625 std::unique_ptr<SvxFontItem> aCtlFontItem(std::make_unique<SvxFontItem>(EE_CHAR_FONTINFO_CTL)); // use item as-is
626 tools::Long nTHeight, nCjkTHeight, nCtlTHeight; // Twips
627 FontWeight eWeight, eCjkWeight, eCtlWeight;
628 std::unique_ptr<SvxUnderlineItem> aUnderlineItem(std::make_unique<SvxUnderlineItem>(LINESTYLE_NONE, EE_CHAR_UNDERLINE));
629 std::unique_ptr<SvxOverlineItem> aOverlineItem(std::make_unique<SvxOverlineItem>(LINESTYLE_NONE, EE_CHAR_OVERLINE));
630 bool bWordLine;
631 FontStrikeout eStrike;
632 FontItalic eItalic, eCjkItalic, eCtlItalic;
633 bool bOutline;
634 bool bShadow;
635 bool bForbidden;
636 FontEmphasisMark eEmphasis;
637 FontRelief eRelief;
638 LanguageType eLang, eCjkLang, eCtlLang;
639 bool bHyphenate;
640 SvxFrameDirection eDirection;
641
642 //TODO: additional parameter to control if language is needed?
643
644 if ( pCondSet )
645 {
646 lcl_populate(aColorItem, ATTR_FONT_COLOR, rSrcSet, pCondSet);
647 lcl_populate(aFontItem, ATTR_FONT, rSrcSet, pCondSet);
648 lcl_populate(aCjkFontItem, ATTR_CJK_FONT, rSrcSet, pCondSet);
649 lcl_populate(aCtlFontItem, ATTR_CTL_FONT, rSrcSet, pCondSet);
650
651 const SvxFontHeightItem* pFontHeightItem = pCondSet->GetItemIfSet( ATTR_FONT_HEIGHT );
652 if (!pFontHeightItem)
653 pFontHeightItem = &rSrcSet.Get( ATTR_FONT_HEIGHT );
654 nTHeight = pFontHeightItem->GetHeight();
655 pFontHeightItem = pCondSet->GetItemIfSet( ATTR_CJK_FONT_HEIGHT );
656 if ( !pFontHeightItem )
657 pFontHeightItem = &rSrcSet.Get( ATTR_CJK_FONT_HEIGHT );
658 nCjkTHeight = pFontHeightItem->GetHeight();
659 pFontHeightItem = pCondSet->GetItemIfSet( ATTR_CTL_FONT_HEIGHT );
660 if ( !pFontHeightItem )
661 pFontHeightItem = &rSrcSet.Get( ATTR_CTL_FONT_HEIGHT );
662 nCtlTHeight = pFontHeightItem->GetHeight();
663
664 const SvxWeightItem* pWeightItem = pCondSet->GetItemIfSet( ATTR_FONT_WEIGHT );
665 if ( !pWeightItem )
666 pWeightItem = &rSrcSet.Get( ATTR_FONT_WEIGHT );
667 eWeight = pWeightItem->GetValue();
668 pWeightItem = pCondSet->GetItemIfSet( ATTR_CJK_FONT_WEIGHT );
669 if ( !pWeightItem )
670 pWeightItem = &rSrcSet.Get( ATTR_CJK_FONT_WEIGHT );
671 eCjkWeight = pWeightItem->GetValue();
672 pWeightItem = pCondSet->GetItemIfSet( ATTR_CTL_FONT_WEIGHT );
673 if ( !pWeightItem )
674 pWeightItem = &rSrcSet.Get( ATTR_CTL_FONT_WEIGHT );
675 eCtlWeight = pWeightItem->GetValue();
676
677 const SvxPostureItem* pPostureItem = pCondSet->GetItemIfSet( ATTR_FONT_POSTURE );
678 if ( !pPostureItem )
679 pPostureItem = &rSrcSet.Get( ATTR_FONT_POSTURE );
680 eItalic = pPostureItem->GetValue();
681 pPostureItem = pCondSet->GetItemIfSet( ATTR_CJK_FONT_POSTURE );
682 if ( !pPostureItem )
683 pPostureItem = &rSrcSet.Get( ATTR_CJK_FONT_POSTURE );
684 eCjkItalic = pPostureItem->GetValue();
685 pPostureItem = pCondSet->GetItemIfSet( ATTR_CTL_FONT_POSTURE );
686 if ( !pPostureItem )
687 pPostureItem = &rSrcSet.Get( ATTR_CTL_FONT_POSTURE );
688 eCtlItalic = pPostureItem->GetValue();
689
690 lcl_populate(aUnderlineItem, ATTR_FONT_UNDERLINE, rSrcSet, pCondSet);
691 lcl_populate(aOverlineItem, ATTR_FONT_OVERLINE, rSrcSet, pCondSet);
692
693 const SvxWordLineModeItem* pWordLineModeItem = pCondSet->GetItemIfSet( ATTR_FONT_WORDLINE );
694 if ( !pWordLineModeItem )
695 pWordLineModeItem = &rSrcSet.Get( ATTR_FONT_WORDLINE );
696 bWordLine = pWordLineModeItem->GetValue();
697
698 const SvxCrossedOutItem* pCrossedOutItem = pCondSet->GetItemIfSet( ATTR_FONT_CROSSEDOUT );
699 if ( !pCrossedOutItem )
700 pCrossedOutItem = &rSrcSet.Get( ATTR_FONT_CROSSEDOUT );
701 eStrike = pCrossedOutItem->GetValue();
702
703 const SvxContourItem* pContourItem = pCondSet->GetItemIfSet( ATTR_FONT_CONTOUR );
704 if ( !pContourItem )
705 pContourItem = &rSrcSet.Get( ATTR_FONT_CONTOUR );
706 bOutline = pContourItem->GetValue();
707
708 const SvxShadowedItem* pShadowedItem = pCondSet->GetItemIfSet( ATTR_FONT_SHADOWED );
709 if ( !pShadowedItem )
710 pShadowedItem = &rSrcSet.Get( ATTR_FONT_SHADOWED );
711 bShadow = pShadowedItem->GetValue();
712
713 const SvxForbiddenRuleItem* pForbiddenRuleItem = pCondSet->GetItemIfSet( ATTR_FORBIDDEN_RULES );
714 if ( !pForbiddenRuleItem )
715 pForbiddenRuleItem = &rSrcSet.Get( ATTR_FORBIDDEN_RULES );
716 bForbidden = pForbiddenRuleItem->GetValue();
717
718 const SvxEmphasisMarkItem* pEmphasisMarkItem = pCondSet->GetItemIfSet( ATTR_FONT_EMPHASISMARK );
719 if ( !pEmphasisMarkItem )
720 pEmphasisMarkItem = &rSrcSet.Get( ATTR_FONT_EMPHASISMARK );
721 eEmphasis = pEmphasisMarkItem->GetEmphasisMark();
722 const SvxCharReliefItem* pCharReliefItem = pCondSet->GetItemIfSet( ATTR_FONT_RELIEF );
723 if ( !pCharReliefItem )
724 pCharReliefItem = &rSrcSet.Get( ATTR_FONT_RELIEF );
725 eRelief = pCharReliefItem->GetValue();
726
727 const SvxLanguageItem* pLanguageItem = pCondSet->GetItemIfSet( ATTR_FONT_LANGUAGE );
728 if ( !pLanguageItem )
729 pLanguageItem = &rSrcSet.Get( ATTR_FONT_LANGUAGE );
730 eLang = pLanguageItem->GetLanguage();
731 pLanguageItem = pCondSet->GetItemIfSet( ATTR_CJK_FONT_LANGUAGE );
732 if ( !pLanguageItem )
733 pLanguageItem = &rSrcSet.Get( ATTR_CJK_FONT_LANGUAGE );
734 eCjkLang = pLanguageItem->GetLanguage();
735 pLanguageItem = pCondSet->GetItemIfSet( ATTR_CTL_FONT_LANGUAGE );
736 if ( !pLanguageItem )
737 pLanguageItem = &rSrcSet.Get( ATTR_CTL_FONT_LANGUAGE );
738 eCtlLang = pLanguageItem->GetLanguage();
739
740 const ScHyphenateCell* pHyphenateCell = pCondSet->GetItemIfSet( ATTR_HYPHENATE );
741 if ( !pHyphenateCell )
742 pHyphenateCell = &rSrcSet.Get( ATTR_HYPHENATE );
743 bHyphenate = pHyphenateCell->GetValue();
744
745 const SvxFrameDirectionItem* pFrameDirectionItem = pCondSet->GetItemIfSet( ATTR_WRITINGDIR );
746 if ( !pFrameDirectionItem )
747 pFrameDirectionItem = &rSrcSet.Get( ATTR_WRITINGDIR );
748 eDirection = pFrameDirectionItem->GetValue();
749 }
750 else // Everything directly from Pattern
751 {
752 aColorItem.reset(rSrcSet.Get(ATTR_FONT_COLOR).Clone());
753 aFontItem.reset(rSrcSet.Get(ATTR_FONT).Clone());
754 aCjkFontItem.reset(rSrcSet.Get(ATTR_CJK_FONT).Clone());
755 aCtlFontItem.reset(rSrcSet.Get(ATTR_CTL_FONT).Clone());
756 nTHeight = rSrcSet.Get( ATTR_FONT_HEIGHT ).GetHeight();
757 nCjkTHeight = rSrcSet.Get( ATTR_CJK_FONT_HEIGHT ).GetHeight();
758 nCtlTHeight = rSrcSet.Get( ATTR_CTL_FONT_HEIGHT ).GetHeight();
759 eWeight = rSrcSet.Get( ATTR_FONT_WEIGHT ).GetValue();
760 eCjkWeight = rSrcSet.Get( ATTR_CJK_FONT_WEIGHT ).GetValue();
761 eCtlWeight = rSrcSet.Get( ATTR_CTL_FONT_WEIGHT ).GetValue();
762 eItalic = rSrcSet.Get( ATTR_FONT_POSTURE ).GetValue();
763 eCjkItalic = rSrcSet.Get( ATTR_CJK_FONT_POSTURE ).GetValue();
764 eCtlItalic = rSrcSet.Get( ATTR_CTL_FONT_POSTURE ).GetValue();
765 aUnderlineItem.reset(rSrcSet.Get(ATTR_FONT_UNDERLINE).Clone());
766 aOverlineItem.reset(rSrcSet.Get(ATTR_FONT_OVERLINE).Clone());
767 bWordLine = rSrcSet.Get( ATTR_FONT_WORDLINE ).GetValue();
768 eStrike = rSrcSet.Get( ATTR_FONT_CROSSEDOUT ).GetValue();
769 bOutline = rSrcSet.Get( ATTR_FONT_CONTOUR ).GetValue();
770 bShadow = rSrcSet.Get( ATTR_FONT_SHADOWED ).GetValue();
771 bForbidden = rSrcSet.Get( ATTR_FORBIDDEN_RULES ).GetValue();
772 eEmphasis = rSrcSet.Get( ATTR_FONT_EMPHASISMARK ).GetEmphasisMark();
773 eRelief = rSrcSet.Get( ATTR_FONT_RELIEF ).GetValue();
774 eLang = rSrcSet.Get( ATTR_FONT_LANGUAGE ).GetLanguage();
775 eCjkLang = rSrcSet.Get( ATTR_CJK_FONT_LANGUAGE ).GetLanguage();
776 eCtlLang = rSrcSet.Get( ATTR_CTL_FONT_LANGUAGE ).GetLanguage();
777 bHyphenate = rSrcSet.Get( ATTR_HYPHENATE ).GetValue();
778 eDirection = rSrcSet.Get( ATTR_WRITINGDIR ).GetValue();
779 }
780
781 // Expect to be compatible to LogicToLogic, ie. 2540/1440 = 127/72, and round
782
783 tools::Long nHeight = convertTwipToMm100(nTHeight);
784 tools::Long nCjkHeight = convertTwipToMm100(nCjkTHeight);
785 tools::Long nCtlHeight = convertTwipToMm100(nCtlTHeight);
786
787 // put items into EditEngine ItemSet
788
789 if ( aColorItem->GetValue() == COL_AUTO )
790 {
791 // When cell attributes are converted to EditEngine paragraph attributes,
792 // don't create a hard item for automatic color, because that would be converted
793 // to black when the item's Store method is used in CreateTransferable/WriteBin.
794 // COL_AUTO is the EditEngine's pool default, so ClearItem will result in automatic
795 // color, too, without having to store the item.
796 rEditSet.ClearItem( EE_CHAR_COLOR );
797 }
798 else
799 {
800 // tdf#125054 adapt WhichID
801 rEditSet.Put( std::move(aColorItem), EE_CHAR_COLOR );
802 }
803
804 // tdf#125054 adapt WhichID
805 rEditSet.Put( std::move(aFontItem), EE_CHAR_FONTINFO );
806 rEditSet.Put( std::move(aCjkFontItem), EE_CHAR_FONTINFO_CJK );
807 rEditSet.Put( std::move(aCtlFontItem), EE_CHAR_FONTINFO_CTL );
808
809 rEditSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
810 rEditSet.Put( SvxFontHeightItem( nCjkHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
811 rEditSet.Put( SvxFontHeightItem( nCtlHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
812 rEditSet.Put( SvxWeightItem ( eWeight, EE_CHAR_WEIGHT ) );
813 rEditSet.Put( SvxWeightItem ( eCjkWeight, EE_CHAR_WEIGHT_CJK ) );
814 rEditSet.Put( SvxWeightItem ( eCtlWeight, EE_CHAR_WEIGHT_CTL ) );
815
816 // tdf#125054 adapt WhichID
817 rEditSet.Put( std::move(aUnderlineItem), EE_CHAR_UNDERLINE );
818 rEditSet.Put( std::move(aOverlineItem), EE_CHAR_OVERLINE );
819
820 rEditSet.Put( SvxWordLineModeItem( bWordLine, EE_CHAR_WLM ) );
821 rEditSet.Put( SvxCrossedOutItem( eStrike, EE_CHAR_STRIKEOUT ) );
822 rEditSet.Put( SvxPostureItem ( eItalic, EE_CHAR_ITALIC ) );
823 rEditSet.Put( SvxPostureItem ( eCjkItalic, EE_CHAR_ITALIC_CJK ) );
824 rEditSet.Put( SvxPostureItem ( eCtlItalic, EE_CHAR_ITALIC_CTL ) );
825 rEditSet.Put( SvxContourItem ( bOutline, EE_CHAR_OUTLINE ) );
826 rEditSet.Put( SvxShadowedItem ( bShadow, EE_CHAR_SHADOW ) );
827 rEditSet.Put( SvxForbiddenRuleItem(bForbidden, EE_PARA_FORBIDDENRULES) );
828 rEditSet.Put( SvxEmphasisMarkItem( eEmphasis, EE_CHAR_EMPHASISMARK ) );
829 rEditSet.Put( SvxCharReliefItem( eRelief, EE_CHAR_RELIEF ) );
830 rEditSet.Put( SvxLanguageItem ( eLang, EE_CHAR_LANGUAGE ) );
831 rEditSet.Put( SvxLanguageItem ( eCjkLang, EE_CHAR_LANGUAGE_CJK ) );
832 rEditSet.Put( SvxLanguageItem ( eCtlLang, EE_CHAR_LANGUAGE_CTL ) );
833 rEditSet.Put( SfxBoolItem ( EE_PARA_HYPHENATE, bHyphenate ) );
834 rEditSet.Put( SvxFrameDirectionItem( eDirection, EE_PARA_WRITINGDIR ) );
835
836 // Script spacing is always off.
837 // The cell attribute isn't used here as long as there is no UI to set it
838 // (don't evaluate attributes that can't be changed).
839 // If a locale-dependent default is needed, it has to go into the cell
840 // style, like the fonts.
841 rEditSet.Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
842}
843
844void ScPatternAttr::FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet ) const
845{
846 if( pEditSet )
847 FillToEditItemSet( *pEditSet, GetItemSet(), pCondSet );
848}
849
851{
852 if (const SvxColorItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_COLOR))
853 rDestSet.Put( *pItem, ATTR_FONT_COLOR );
854
855 if (const SvxFontItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTINFO))
856 rDestSet.Put( *pItem, ATTR_FONT );
857 if (const SvxFontItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTINFO_CJK))
858 rDestSet.Put( *pItem, ATTR_CJK_FONT );
859 if (const SvxFontItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTINFO_CTL))
860 rDestSet.Put( *pItem, ATTR_CTL_FONT );
861
862 if (const SvxFontHeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTHEIGHT))
863 rDestSet.Put( SvxFontHeightItem(o3tl::toTwips(pItem->GetHeight(), o3tl::Length::mm100),
864 100, ATTR_FONT_HEIGHT ) );
865 if (const SvxFontHeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTHEIGHT_CJK))
866 rDestSet.Put( SvxFontHeightItem(o3tl::toTwips(pItem->GetHeight(), o3tl::Length::mm100),
867 100, ATTR_CJK_FONT_HEIGHT ) );
868 if (const SvxFontHeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTHEIGHT_CTL))
869 rDestSet.Put( SvxFontHeightItem(o3tl::toTwips(pItem->GetHeight(), o3tl::Length::mm100),
870 100, ATTR_CTL_FONT_HEIGHT ) );
871
872 if (const SvxWeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_WEIGHT))
873 rDestSet.Put( SvxWeightItem( pItem->GetValue(),
875 if (const SvxWeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_WEIGHT_CJK))
876 rDestSet.Put( SvxWeightItem( pItem->GetValue(),
878 if (const SvxWeightItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_WEIGHT_CTL))
879 rDestSet.Put( SvxWeightItem( pItem->GetValue(),
881
882 // SvxTextLineItem contains enum and color
883 if (const SvxUnderlineItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_UNDERLINE))
884 rDestSet.Put( *pItem, ATTR_FONT_UNDERLINE );
885 if (const SvxOverlineItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_OVERLINE))
886 rDestSet.Put( *pItem, ATTR_FONT_OVERLINE );
887 if (const SvxWordLineModeItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_WLM))
888 rDestSet.Put( SvxWordLineModeItem( pItem->GetValue(),
890
891 if (const SvxCrossedOutItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_STRIKEOUT))
892 rDestSet.Put( SvxCrossedOutItem( pItem->GetValue(),
894
895 if (const SvxPostureItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_ITALIC))
896 rDestSet.Put( SvxPostureItem( pItem->GetValue(),
898 if (const SvxPostureItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_ITALIC_CJK))
899 rDestSet.Put( SvxPostureItem( pItem->GetValue(),
901 if (const SvxPostureItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_ITALIC_CTL))
902 rDestSet.Put( SvxPostureItem( pItem->GetValue(),
904
905 if (const SvxContourItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_OUTLINE))
906 rDestSet.Put( SvxContourItem( pItem->GetValue(),
908 if (const SvxShadowedItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_SHADOW))
909 rDestSet.Put( SvxShadowedItem( pItem->GetValue(),
911 if (const SvxEmphasisMarkItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_EMPHASISMARK))
912 rDestSet.Put( SvxEmphasisMarkItem( pItem->GetEmphasisMark(),
914 if (const SvxCharReliefItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_RELIEF))
915 rDestSet.Put( SvxCharReliefItem( pItem->GetValue(),
917
918 if (const SvxLanguageItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_LANGUAGE))
919 rDestSet.Put( SvxLanguageItem(pItem->GetValue(), ATTR_FONT_LANGUAGE) );
920 if (const SvxLanguageItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_LANGUAGE_CJK))
921 rDestSet.Put( SvxLanguageItem(pItem->GetValue(), ATTR_CJK_FONT_LANGUAGE) );
922 if (const SvxLanguageItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_LANGUAGE_CTL))
923 rDestSet.Put( SvxLanguageItem(pItem->GetValue(), ATTR_CTL_FONT_LANGUAGE) );
924
925 const SvxAdjustItem* pAdjustItem = rEditSet.GetItemIfSet(EE_PARA_JUST);
926
927 if (!pAdjustItem)
928 return;
929
931 switch ( pAdjustItem->GetAdjust() )
932 {
933 case SvxAdjust::Left:
934 // EditEngine Default is always set in the GetAttribs() ItemSet !
935 // whether left or right, is decided in text / number
936 eVal = SvxCellHorJustify::Standard;
937 break;
938 case SvxAdjust::Right:
939 eVal = SvxCellHorJustify::Right;
940 break;
941 case SvxAdjust::Block:
942 eVal = SvxCellHorJustify::Block;
943 break;
944 case SvxAdjust::Center:
945 eVal = SvxCellHorJustify::Center;
946 break;
947 case SvxAdjust::BlockLine:
948 eVal = SvxCellHorJustify::Block;
949 break;
950 case SvxAdjust::End:
951 eVal = SvxCellHorJustify::Right;
952 break;
953 default:
954 eVal = SvxCellHorJustify::Standard;
955 }
956 if ( eVal != SvxCellHorJustify::Standard )
957 rDestSet.Put( SvxHorJustifyItem( eVal, ATTR_HOR_JUSTIFY) );
958}
959
961{
962 if( !pEditSet )
963 return;
964 GetFromEditItemSet( GetItemSet(), *pEditSet );
965 mxHashCode.reset();
966}
967
969{
970 // already there in GetFromEditItemSet, but not in FillEditItemSet
971 // Default horizontal alignment is always implemented as left
972
973 const SfxItemSet& rMySet = GetItemSet();
974
975 SvxCellHorJustify eHorJust = rMySet.Get(ATTR_HOR_JUSTIFY).GetValue();
976
977 SvxAdjust eSvxAdjust;
978 switch (eHorJust)
979 {
980 case SvxCellHorJustify::Right: eSvxAdjust = SvxAdjust::Right; break;
981 case SvxCellHorJustify::Center: eSvxAdjust = SvxAdjust::Center; break;
982 case SvxCellHorJustify::Block: eSvxAdjust = SvxAdjust::Block; break;
983 default: eSvxAdjust = SvxAdjust::Left; break;
984 }
985 pEditSet->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) );
986}
987
989{
990 SfxItemSet& rThisSet = GetItemSet();
991 const SfxItemSet& rOldSet = pOldAttrs->GetItemSet();
992
993 const SfxPoolItem* pThisItem;
994 const SfxPoolItem* pOldItem;
995
996 for ( sal_uInt16 nSubWhich=ATTR_PATTERN_START; nSubWhich<=ATTR_PATTERN_END; nSubWhich++ )
997 {
998 // only items that are set are interesting
999 if ( rThisSet.GetItemState( nSubWhich, false, &pThisItem ) == SfxItemState::SET )
1000 {
1001 SfxItemState eOldState = rOldSet.GetItemState( nSubWhich, true, &pOldItem );
1002 if ( eOldState == SfxItemState::SET )
1003 {
1004 // item is set in OldAttrs (or its parent) -> compare pointers
1005 if ( pThisItem == pOldItem )
1006 {
1007 rThisSet.ClearItem( nSubWhich );
1008 mxHashCode.reset();
1009 }
1010 }
1011 else if ( eOldState != SfxItemState::DONTCARE )
1012 {
1013 // not set in OldAttrs -> compare item value to default item
1014 if ( *pThisItem == rThisSet.GetPool()->GetDefaultItem( nSubWhich ) )
1015 {
1016 rThisSet.ClearItem( nSubWhich );
1017 mxHashCode.reset();
1018 }
1019 }
1020 }
1021 }
1022}
1023
1024bool ScPatternAttr::HasItemsSet( const sal_uInt16* pWhich ) const
1025{
1026 const SfxItemSet& rSet = GetItemSet();
1027 for (sal_uInt16 i=0; pWhich[i]; i++)
1028 if ( rSet.GetItemState( pWhich[i], false ) == SfxItemState::SET )
1029 return true;
1030 return false;
1031}
1032
1033void ScPatternAttr::ClearItems( const sal_uInt16* pWhich )
1034{
1036 for (sal_uInt16 i=0; pWhich[i]; i++)
1037 rSet.ClearItem(pWhich[i]);
1038 mxHashCode.reset();
1039}
1040
1042 (
1043 SfxStyleSheetBase* pSrcStyle,
1044 SfxStyleSheetBasePool* pSrcPool,
1045 SfxStyleSheetBasePool* pDestPool,
1046 const SvNumberFormatterIndexTable* pFormatExchangeList
1047 )
1048{
1049 if ( !pSrcStyle || !pDestPool || !pSrcPool )
1050 {
1051 OSL_FAIL( "CopyStyleToPool: Invalid Arguments :-/" );
1052 return nullptr;
1053 }
1054
1055 const OUString aStrSrcStyle = pSrcStyle->GetName();
1056 const SfxStyleFamily eFamily = pSrcStyle->GetFamily();
1057 SfxStyleSheetBase* pDestStyle = pDestPool->Find( aStrSrcStyle, eFamily );
1058
1059 if ( !pDestStyle )
1060 {
1061 const OUString aStrParent = pSrcStyle->GetParent();
1062 const SfxItemSet& rSrcSet = pSrcStyle->GetItemSet();
1063
1064 pDestStyle = &pDestPool->Make( aStrSrcStyle, eFamily, SfxStyleSearchBits::UserDefined );
1065 SfxItemSet& rDestSet = pDestStyle->GetItemSet();
1066 rDestSet.Put( rSrcSet );
1067
1068 // number format exchange list has to be handled here, too
1069 // (only called for cell styles)
1070
1071 const SfxUInt32Item* pSrcItem;
1072 if ( pFormatExchangeList &&
1073 (pSrcItem = rSrcSet.GetItemIfSet( ATTR_VALUE_FORMAT, false )) )
1074 {
1075 sal_uLong nOldFormat = pSrcItem->GetValue();
1076 SvNumberFormatterIndexTable::const_iterator it = pFormatExchangeList->find(nOldFormat);
1077 if (it != pFormatExchangeList->end())
1078 {
1079 sal_uInt32 nNewFormat = it->second;
1080 rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
1081 }
1082 }
1083
1084 // if necessary create derivative Styles, if not available:
1085
1086 if ( ScResId(STR_STYLENAME_STANDARD) != aStrParent &&
1087 aStrSrcStyle != aStrParent &&
1088 !pDestPool->Find( aStrParent, eFamily ) )
1089 {
1090 lcl_CopyStyleToPool( pSrcPool->Find( aStrParent, eFamily ),
1091 pSrcPool, pDestPool, pFormatExchangeList );
1092 }
1093
1094 pDestStyle->SetParent( aStrParent );
1095 }
1096
1097 return pDestStyle;
1098}
1099
1101{
1102 const SfxItemSet* pSrcSet = &GetItemSet();
1103
1104 ScPatternAttr aDestPattern( pDestDoc->GetPool() );
1105 SfxItemSet* pDestSet = &aDestPattern.GetItemSet();
1106
1107 // Copy cell pattern style to other document:
1108
1109 if ( pDestDoc != pSrcDoc )
1110 {
1111 OSL_ENSURE( pStyle, "Missing Pattern-Style! :-/" );
1112
1113 // if pattern in DestDoc is available, use this, otherwise copy
1114 // parent style to style or create if necessary and attach DestDoc
1115
1117 pSrcDoc->GetStyleSheetPool(),
1118 pDestDoc->GetStyleSheetPool(),
1119 pDestDoc->GetFormatExchangeList() );
1120
1121 aDestPattern.SetStyleSheet( static_cast<ScStyleSheet*>(pStyleCpy) );
1122 }
1123
1124 for ( sal_uInt16 nAttrId = ATTR_PATTERN_START; nAttrId <= ATTR_PATTERN_END; nAttrId++ )
1125 {
1126 const SfxPoolItem* pSrcItem;
1127 SfxItemState eItemState = pSrcSet->GetItemState( nAttrId, false, &pSrcItem );
1128 if (eItemState==SfxItemState::SET)
1129 {
1130 std::unique_ptr<SfxPoolItem> pNewItem;
1131
1132 if ( nAttrId == ATTR_VALIDDATA )
1133 {
1134 // Copy validity to the new document
1135
1136 sal_uInt32 nNewIndex = 0;
1137 ScValidationDataList* pSrcList = pSrcDoc->GetValidationList();
1138 if ( pSrcList )
1139 {
1140 sal_uInt32 nOldIndex = static_cast<const SfxUInt32Item*>(pSrcItem)->GetValue();
1141 const ScValidationData* pOldData = pSrcList->GetData( nOldIndex );
1142 if ( pOldData )
1143 nNewIndex = pDestDoc->AddValidationEntry( *pOldData );
1144 }
1145 pNewItem.reset(new SfxUInt32Item( ATTR_VALIDDATA, nNewIndex ));
1146 }
1147 else if ( nAttrId == ATTR_VALUE_FORMAT && pDestDoc->GetFormatExchangeList() )
1148 {
1149 // Number format to Exchange List
1150
1151 sal_uLong nOldFormat = static_cast<const SfxUInt32Item*>(pSrcItem)->GetValue();
1152 SvNumberFormatterIndexTable::const_iterator it = pDestDoc->GetFormatExchangeList()->find(nOldFormat);
1153 if (it != pDestDoc->GetFormatExchangeList()->end())
1154 {
1155 sal_uInt32 nNewFormat = it->second;
1156 pNewItem.reset(new SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ));
1157 }
1158 }
1159
1160 if ( pNewItem )
1161 {
1162 pDestSet->Put(std::move(pNewItem));
1163 }
1164 else
1165 pDestSet->Put(*pSrcItem);
1166 }
1167 }
1168
1169 ScPatternAttr* pPatternAttr = const_cast<ScPatternAttr*>( &pDestDoc->GetPool()->Put(aDestPattern) );
1170 return pPatternAttr;
1171}
1172
1174{
1175 const SfxItemSet& rSet = GetItemSet();
1176
1177 if ( const SvxBrushItem* pItem = rSet.GetItemIfSet( ATTR_BACKGROUND ) )
1178 if ( pItem->GetColor() != COL_TRANSPARENT )
1179 return true;
1180
1181 if ( const SvxBoxItem* pBoxItem = rSet.GetItemIfSet( ATTR_BORDER ) )
1182 {
1183 if ( pBoxItem->GetTop() || pBoxItem->GetBottom() ||
1184 pBoxItem->GetLeft() || pBoxItem->GetRight() )
1185 return true;
1186 }
1187
1188 if ( const SvxLineItem* pItem = rSet.GetItemIfSet( ATTR_BORDER_TLBR ) )
1189 if( pItem->GetLine() )
1190 return true;
1191
1192 if ( const SvxLineItem* pItem = rSet.GetItemIfSet( ATTR_BORDER_BLTR ) )
1193 if( pItem->GetLine() )
1194 return true;
1195
1196 if ( const SvxShadowItem* pItem = rSet.GetItemIfSet( ATTR_SHADOW ) )
1197 if ( pItem->GetLocation() != SvxShadowLocation::NONE )
1198 return true;
1199
1200 return false;
1201}
1202
1203static bool OneEqual( const SfxItemSet& rSet1, const SfxItemSet& rSet2, sal_uInt16 nId )
1204{
1205 const SfxPoolItem* pItem1 = &rSet1.Get(nId);
1206 const SfxPoolItem* pItem2 = &rSet2.Get(nId);
1207 return ( pItem1 == pItem2 || *pItem1 == *pItem2 );
1208}
1209
1211{
1212 const SfxItemSet& rThisSet = GetItemSet();
1213 const SfxItemSet& rOtherSet = rOther.GetItemSet();
1214
1215 return OneEqual( rThisSet, rOtherSet, ATTR_BACKGROUND ) &&
1216 OneEqual( rThisSet, rOtherSet, ATTR_BORDER ) &&
1217 OneEqual( rThisSet, rOtherSet, ATTR_BORDER_TLBR ) &&
1218 OneEqual( rThisSet, rOtherSet, ATTR_BORDER_BLTR ) &&
1219 OneEqual( rThisSet, rOtherSet, ATTR_SHADOW );
1220
1221 //TODO: also here only check really visible values !!!
1222}
1223
1224const OUString* ScPatternAttr::GetStyleName() const
1225{
1226 return pName ? &*pName : ( pStyle ? &pStyle->GetName() : nullptr );
1227}
1228
1229void ScPatternAttr::SetStyleSheet( ScStyleSheet* pNewStyle, bool bClearDirectFormat )
1230{
1231 if (pNewStyle)
1232 {
1233 SfxItemSet& rPatternSet = GetItemSet();
1234 const SfxItemSet& rStyleSet = pNewStyle->GetItemSet();
1235
1236 if (bClearDirectFormat)
1237 {
1238 for (sal_uInt16 i=ATTR_PATTERN_START; i<=ATTR_PATTERN_END; i++)
1239 {
1240 if (rStyleSet.GetItemState(i) == SfxItemState::SET)
1241 rPatternSet.ClearItem(i);
1242 }
1243 }
1244 rPatternSet.SetParent(&pNewStyle->GetItemSet());
1245 pStyle = pNewStyle;
1246 pName.reset();
1247 }
1248 else
1249 {
1250 OSL_FAIL( "ScPatternAttr::SetStyleSheet( NULL ) :-|" );
1251 GetItemSet().SetParent(nullptr);
1252 pStyle = nullptr;
1253 }
1254 mxHashCode.reset();
1255}
1256
1258{
1259 if (pName)
1260 {
1261 pStyle = static_cast<ScStyleSheet*>(rDoc.GetStyleSheetPool()->Find(*pName, SfxStyleFamily::Para));
1262
1263 // use Standard if Style is not found,
1264 // to avoid empty display in Toolbox-Controller
1265 // Assumes that "Standard" is always the 1st entry!
1266 if (!pStyle)
1267 {
1268 std::unique_ptr<SfxStyleSheetIterator> pIter = rDoc.GetStyleSheetPool()->CreateIterator(SfxStyleFamily::Para);
1269 pStyle = dynamic_cast< ScStyleSheet* >(pIter->First());
1270 }
1271
1272 if (pStyle)
1273 {
1275 pName.reset();
1276 }
1277 }
1278 else
1279 pStyle = nullptr;
1280 mxHashCode.reset();
1281}
1282
1284{
1285 // Style was deleted, remember name:
1286
1287 if ( pStyle )
1288 {
1289 pName = pStyle->GetName();
1290 pStyle = nullptr;
1291 GetItemSet().SetParent( nullptr );
1292 mxHashCode.reset();
1293 }
1294}
1295
1297{
1298 if( const SvxFontItem* pItem = GetItemSet().GetItemIfSet( ATTR_FONT ) )
1299 return pItem->GetCharSet() == RTL_TEXTENCODING_SYMBOL;
1300 else
1301 return false;
1302}
1303
1304namespace {
1305
1306sal_uInt32 getNumberFormatKey(const SfxItemSet& rSet)
1307{
1308 return rSet.Get(ATTR_VALUE_FORMAT).GetValue();
1309}
1310
1311LanguageType getLanguageType(const SfxItemSet& rSet)
1312{
1313 return rSet.Get(ATTR_LANGUAGE_FORMAT).GetLanguage();
1314}
1315
1316}
1317
1319{
1320 sal_uInt32 nFormat = getNumberFormatKey(GetItemSet());
1321 LanguageType eLang = getLanguageType(GetItemSet());
1322 if ( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && eLang == LANGUAGE_SYSTEM )
1323 ; // it remains as it is
1324 else if ( pFormatter )
1325 nFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nFormat, eLang );
1326 return nFormat;
1327}
1328
1329// the same if conditional formatting is in play:
1330
1332 const SfxItemSet* pCondSet ) const
1333{
1334 assert(pFormatter);
1335 if (!pCondSet)
1336 return GetNumberFormat(pFormatter);
1337
1338 // Conditional format takes precedence over style and even hard format.
1339
1340 sal_uInt32 nFormat;
1341 LanguageType eLang;
1342 if (pCondSet->GetItemState(ATTR_VALUE_FORMAT) == SfxItemState::SET )
1343 {
1344 nFormat = getNumberFormatKey(*pCondSet);
1345 if (pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT) == SfxItemState::SET)
1346 eLang = getLanguageType(*pCondSet);
1347 else
1348 eLang = getLanguageType(GetItemSet());
1349 }
1350 else
1351 {
1352 nFormat = getNumberFormatKey(GetItemSet());
1353 eLang = getLanguageType(GetItemSet());
1354 }
1355
1356 return pFormatter->GetFormatForLanguageIfBuiltIn(nFormat, eLang);
1357}
1358
1359const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
1360{
1361 const SfxPoolItem* pCondItem;
1362 if ( pCondSet && pCondSet->GetItemState( nWhich, true, &pCondItem ) == SfxItemState::SET )
1363 return *pCondItem;
1364 return rItemSet.Get(nWhich);
1365}
1366
1367const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nSubWhich, const SfxItemSet* pCondSet ) const
1368{
1369 return GetItem( nSubWhich, GetItemSet(), pCondSet );
1370}
1371
1372// GetRotateVal is tested before ATTR_ORIENTATION
1373
1375{
1376 Degree100 nAttrRotate(0);
1377 if ( GetCellOrientation() == SvxCellOrientation::Standard )
1378 {
1379 bool bRepeat = ( GetItem(ATTR_HOR_JUSTIFY, pCondSet).
1380 GetValue() == SvxCellHorJustify::Repeat );
1381 // ignore orientation/rotation if "repeat" is active
1382 if ( !bRepeat )
1383 nAttrRotate = GetItem( ATTR_ROTATE_VALUE, pCondSet ).GetValue();
1384 }
1385 return nAttrRotate;
1386}
1387
1389{
1391
1392 Degree100 nAttrRotate = GetRotateVal( pCondSet );
1393 if ( nAttrRotate )
1394 {
1395 SvxRotateMode eRotMode = GetItem(ATTR_ROTATE_MODE, pCondSet).GetValue();
1396
1397 if ( eRotMode == SVX_ROTATE_MODE_STANDARD || nAttrRotate == 18000_deg100 )
1398 nRet = ScRotateDir::Standard;
1399 else if ( eRotMode == SVX_ROTATE_MODE_CENTER )
1400 nRet = ScRotateDir::Center;
1401 else if ( eRotMode == SVX_ROTATE_MODE_TOP || eRotMode == SVX_ROTATE_MODE_BOTTOM )
1402 {
1403 Degree100 nRot180 = nAttrRotate % 18000_deg100; // 1/100 degrees
1404 if ( nRot180 == 9000_deg100 )
1405 nRet = ScRotateDir::Center;
1406 else if ( ( eRotMode == SVX_ROTATE_MODE_TOP && nRot180 < 9000_deg100 ) ||
1407 ( eRotMode == SVX_ROTATE_MODE_BOTTOM && nRot180 > 9000_deg100 ) )
1408 nRet = ScRotateDir::Left;
1409 else
1410 nRet = ScRotateDir::Right;
1411 }
1412 }
1413
1414 return nRet;
1415}
1416
1417void ScPatternAttr::SetKey(sal_uInt64 nKey)
1418{
1419 mnKey = nKey;
1420}
1421
1422sal_uInt64 ScPatternAttr::GetKey() const
1423{
1424 return mnKey;
1425}
1426
1428{
1429 auto const & rSet = GetItemSet();
1430 if( rSet.TotalCount() != compareSize ) // see EqualPatternSets()
1431 {
1432 mxHashCode = 0; // invalid
1433 return;
1434 }
1435 mxHashCode = 1; // Set up seed so that an empty pattern does not have an (invalid) hash of 0.
1436 boost::hash_range(*mxHashCode, rSet.GetItems_Impl(), rSet.GetItems_Impl() + compareSize);
1437}
1438
1439/* 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:6165
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6170
SC_DLLPUBLIC sal_uLong AddValidationEntry(const ScValidationData &rNew)
Definition: documen4.cxx:725
const ScValidationDataList * GetValidationList() const
Definition: document.hxx:1878
SvNumberFormatterIndexTable * GetFormatExchangeList() const
Definition: document.hxx:923
sal_uInt64 mnKey
Definition: patattr.hxx:58
bool IsSymbolFont() const
If font is an old symbol font StarBats/StarMath with text encoding RTL_TEXTENC_SYMBOL.
Definition: patattr.cxx:1296
void UpdateStyleSheet(const ScDocument &rDoc)
Definition: patattr.cxx:1257
void StyleToName()
Definition: patattr.cxx:1283
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< size_t > mxHashCode
Definition: patattr.hxx:56
ScStyleSheet * pStyle
Definition: patattr.hxx:57
void ClearItems(const sal_uInt16 *pWhich)
Definition: patattr.cxx:1033
ScPatternAttr * PutInPool(ScDocument *pDestDoc, ScDocument *pSrcDoc) const
Definition: patattr.cxx:1100
void CalcHashCode() const
Definition: patattr.cxx:1427
std::optional< OUString > pName
Definition: patattr.hxx:55
bool IsVisible() const
Definition: patattr.cxx:1173
Degree100 GetRotateVal(const SfxItemSet *pCondSet) const
Definition: patattr.cxx:1374
static std::optional< bool > FastEqualPatternSets(const SfxItemSet &rSet1, const SfxItemSet &rSet2)
Definition: patattr.cxx:124
bool IsVisibleEqual(const ScPatternAttr &rOther) const
Definition: patattr.cxx:1210
const OUString * GetStyleName() const
Definition: patattr.cxx:1224
void SetStyleSheet(ScStyleSheet *pNewStyle, bool bClearDirectFormat=true)
Definition: patattr.cxx:1229
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
Definition: patattr.cxx:1318
ScPatternAttr(SfxItemSet &&pItemSet, const OUString &rStyleName)
Definition: patattr.cxx:71
void DeleteUnchanged(const ScPatternAttr *pOldAttrs)
Definition: patattr.cxx:988
sal_uInt64 GetKey() const
Definition: patattr.cxx:1422
ScRotateDir GetRotateDir(const SfxItemSet *pCondSet) const
Definition: patattr.cxx:1388
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:618
static ScDxfFont GetDxfFont(const SfxItemSet &rSet, SvtScriptType nScript)
Definition: patattr.cxx:522
void SetKey(sal_uInt64 nKey)
Definition: patattr.cxx:1417
static void GetFont(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)
Static helper function to fill a font object from the passed item set.
Definition: patattr.cxx:253
bool HasItemsSet(const sal_uInt16 *pWhich) const
Definition: patattr.cxx:1024
SfxItemSet & GetItemSet()
Definition: patattr.hxx:155
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:72
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:844
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:850
static SvxCellOrientation GetCellOrientation(const SfxItemSet &rItemSet, const SfxItemSet *pCondSet)
Definition: patattr.cxx:191
virtual ScPatternAttr * Clone(SfxItemPool *pPool=nullptr) const override
Definition: patattr.cxx:101
void FillEditParaItems(SfxItemSet *pSet) const
Definition: patattr.cxx:968
virtual SC_DLLPUBLIC SfxItemSet & GetItemSet() override
Definition: stlsheet.cxx:133
ScViewData & GetViewData()
Definition: tabview.hxx:343
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 SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) const
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits nMask=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_uInt32 GetFormatForLanguageIfBuiltIn(sal_uInt32 nFormat, LanguageType eLnge=LANGUAGE_DONTKNOW)
SvxAdjust GetAdjust() const
const Color & GetColor() const
const Color & GetValue() 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
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
#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
sal_Int16 nId
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:1042
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:610
static bool EqualPatternSets(const SfxItemSet &rSet1, const SfxItemSet &rSet2)
Definition: patattr.cxx:144
static bool OneEqual(const SfxItemSet &rSet1, const SfxItemSet &rSet2, sal_uInt16 nId)
Definition: patattr.cxx:1203
ScAutoFontColorMode
how to treat COL_AUTO in GetFont:
Definition: patattr.hxx:43
@ SC_AUTOCOL_BLACK
always use black
Definition: patattr.hxx:45
@ SC_AUTOCOL_IGNOREBACK
like DISPLAY, but ignore stored background color (use configured color)
Definition: patattr.hxx:49
@ SC_AUTOCOL_RAW
COL_AUTO is returned.
Definition: patattr.hxx:44
@ SC_AUTOCOL_IGNOREFONT
like DISPLAY, but ignore stored font color (assume COL_AUTO)
Definition: patattr.hxx:48
@ SC_AUTOCOL_PRINT
black or white, depending on background
Definition: patattr.hxx:46
@ SC_AUTOCOL_IGNOREALL
like DISPLAY, but ignore stored font and background colors
Definition: patattr.hxx:50
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:249
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