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