LibreOffice Module sc (master)  1
docpool.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 <sal/config.h>
21 
22 #include <scitems.hxx>
23 
24 #include <comphelper/string.hxx>
25 #include <i18nutil/unicode.hxx>
26 #include <vcl/outdev.hxx>
27 #include <vcl/svapp.hxx>
28 #include <vcl/settings.hxx>
29 #include <svl/itemiter.hxx>
30 #include <svl/stritem.hxx>
31 #include <svx/algitem.hxx>
32 #include <editeng/boxitem.hxx>
33 #include <editeng/lineitem.hxx>
34 #include <editeng/brushitem.hxx>
36 #include <editeng/contouritem.hxx>
37 #include <editeng/colritem.hxx>
40 #include <editeng/fhgtitem.hxx>
41 #include <editeng/fontitem.hxx>
43 #include <editeng/frmdiritem.hxx>
44 #include <editeng/hngpnctitem.hxx>
45 #include <editeng/itemtype.hxx>
46 #include <editeng/editrids.hrc>
47 #include <editeng/eerdll.hxx>
48 #include <editeng/langitem.hxx>
49 #include <editeng/lrspitem.hxx>
50 #include <svx/pageitem.hxx>
51 #include <editeng/pbinitem.hxx>
52 #include <editeng/postitem.hxx>
53 #include <svx/rotmodit.hxx>
55 #include <editeng/shaditem.hxx>
56 #include <editeng/shdditem.hxx>
57 #include <editeng/sizeitem.hxx>
58 #include <editeng/udlnitem.hxx>
59 #include <editeng/ulspitem.hxx>
60 #include <editeng/wghtitem.hxx>
61 #include <editeng/wrlmitem.hxx>
62 #include <editeng/xmlcnitm.hxx>
63 #include <editeng/justifyitem.hxx>
64 
65 #include <docpool.hxx>
66 #include <global.hxx>
67 #include <attrib.hxx>
68 #include <patattr.hxx>
69 #include <globstr.hrc>
70 #include <scresid.hxx>
71 #include <scmod.hxx>
72 #include <sc.hrc>
73 
74 // ATTR_FONT_TWOLINES (not used) was changed to ATTR_USERDEF (not saved in binary format) in 641c
75 
76 namespace {
77 
78 SvxFontItem* getDefaultFontItem(LanguageType eLang, DefaultFontType nFontType, sal_uInt16 nItemId)
79 {
80  vcl::Font aDefFont = OutputDevice::GetDefaultFont( nFontType, eLang, GetDefaultFontFlags::OnlyOne );
81  SvxFontItem* pNewItem = new SvxFontItem( aDefFont.GetFamilyType(), aDefFont.GetFamilyName(), aDefFont.GetStyleName(),
82  aDefFont.GetPitch(), aDefFont.GetCharSet(), nItemId );
83 
84  return pNewItem;
85 }
86 
87 }
88 
90 {
91  { SID_ATTR_CHAR_FONT, true }, // ATTR_FONT
92  { SID_ATTR_CHAR_FONTHEIGHT, true }, // ATTR_FONT_HEIGHT
93  { SID_ATTR_CHAR_WEIGHT, true }, // ATTR_FONT_WEIGHT
94  { SID_ATTR_CHAR_POSTURE, true }, // ATTR_FONT_POSTURE
95  { SID_ATTR_CHAR_UNDERLINE, true }, // ATTR_FONT_UNDERLINE
96  { SID_ATTR_CHAR_OVERLINE, true }, // ATTR_FONT_OVERLINE
97  { SID_ATTR_CHAR_STRIKEOUT, true }, // ATTR_FONT_CROSSEDOUT
98  { SID_ATTR_CHAR_CONTOUR, true }, // ATTR_FONT_CONTOUR
99  { SID_ATTR_CHAR_SHADOWED, true }, // ATTR_FONT_SHADOWED
100  { SID_ATTR_CHAR_COLOR, true }, // ATTR_FONT_COLOR
101  { SID_ATTR_CHAR_LANGUAGE, true }, // ATTR_FONT_LANGUAGE
102  { SID_ATTR_CHAR_CJK_FONT, true }, // ATTR_CJK_FONT from 614
103  { SID_ATTR_CHAR_CJK_FONTHEIGHT, true }, // ATTR_CJK_FONT_HEIGHT from 614
104  { SID_ATTR_CHAR_CJK_WEIGHT, true }, // ATTR_CJK_FONT_WEIGHT from 614
105  { SID_ATTR_CHAR_CJK_POSTURE, true }, // ATTR_CJK_FONT_POSTURE from 614
106  { SID_ATTR_CHAR_CJK_LANGUAGE, true }, // ATTR_CJK_FONT_LANGUAGE from 614
107  { SID_ATTR_CHAR_CTL_FONT, true }, // ATTR_CTL_FONT from 614
108  { SID_ATTR_CHAR_CTL_FONTHEIGHT, true }, // ATTR_CTL_FONT_HEIGHT from 614
109  { SID_ATTR_CHAR_CTL_WEIGHT, true }, // ATTR_CTL_FONT_WEIGHT from 614
110  { SID_ATTR_CHAR_CTL_POSTURE, true }, // ATTR_CTL_FONT_POSTURE from 614
111  { SID_ATTR_CHAR_CTL_LANGUAGE, true }, // ATTR_CTL_FONT_LANGUAGE from 614
112  { SID_ATTR_CHAR_EMPHASISMARK, true }, // ATTR_FONT_EMPHASISMARK from 614
113  { 0, true }, // ATTR_USERDEF from 614 / 641c
114  { SID_ATTR_CHAR_WORDLINEMODE, true }, // ATTR_FONT_WORDLINE from 632b
115  { SID_ATTR_CHAR_RELIEF, true }, // ATTR_FONT_RELIEF from 632b
116  { SID_ATTR_ALIGN_HYPHENATION, true }, // ATTR_HYPHENATE from 632b
117  { 0, true }, // ATTR_SCRIPTSPACE from 614d
118  { 0, true }, // ATTR_HANGPUNCTUATION from 614d
119  { SID_ATTR_PARA_FORBIDDEN_RULES,true }, // ATTR_FORBIDDEN_RULES from 614d
120  { SID_ATTR_ALIGN_HOR_JUSTIFY, true }, // ATTR_HOR_JUSTIFY
121  { SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD, true }, // ATTR_HOR_JUSTIFY_METHOD
122  { SID_ATTR_ALIGN_INDENT, true }, // ATTR_INDENT from 350
123  { SID_ATTR_ALIGN_VER_JUSTIFY, true }, // ATTR_VER_JUSTIFY
124  { SID_ATTR_ALIGN_VER_JUSTIFY_METHOD, true }, // ATTR_VER_JUSTIFY_METHOD
125  { SID_ATTR_ALIGN_STACKED, true }, // ATTR_STACKED from 680/dr14 (replaces ATTR_ORIENTATION)
126  { SID_ATTR_ALIGN_DEGREES, true }, // ATTR_ROTATE_VALUE from 367
127  { SID_ATTR_ALIGN_LOCKPOS, true }, // ATTR_ROTATE_MODE from 367
128  { SID_ATTR_ALIGN_ASIANVERTICAL, true }, // ATTR_VERTICAL_ASIAN from 642
129  { SID_ATTR_FRAMEDIRECTION, true }, // ATTR_WRITINGDIR from 643
130  { SID_ATTR_ALIGN_LINEBREAK, true }, // ATTR_LINEBREAK
131  { SID_ATTR_ALIGN_SHRINKTOFIT, true }, // ATTR_SHRINKTOFIT from 680/dr14
132  { SID_ATTR_BORDER_DIAG_TLBR, true }, // ATTR_BORDER_TLBR from 680/dr14
133  { SID_ATTR_BORDER_DIAG_BLTR, true }, // ATTR_BORDER_BLTR from 680/dr14
134  { SID_ATTR_ALIGN_MARGIN, true }, // ATTR_MARGIN
135  { 0, true }, // ATTR_MERGE
136  { 0, true }, // ATTR_MERGE_FLAG
137  { SID_ATTR_NUMBERFORMAT_VALUE, true }, // ATTR_VALUE_FORMAT
138  { 0, true }, // ATTR_LANGUAGE_FORMAT from 329, is combined with SID_ATTR_NUMBERFORMAT_VALUE in the dialog
139  { SID_ATTR_BRUSH, true }, // ATTR_BACKGROUND
140  { SID_SCATTR_PROTECTION, true }, // ATTR_PROTECTION
141  { SID_ATTR_BORDER_OUTER, true }, // ATTR_BORDER
142  { SID_ATTR_BORDER_INNER, true }, // ATTR_BORDER_INNER
143  { SID_ATTR_BORDER_SHADOW, true }, // ATTR_SHADOW
144  { 0, true }, // ATTR_VALIDDATA
145  { 0, true }, // ATTR_CONDITIONAL
146  { 0, true }, // ATTR_HYPERLINK
147  { 0, true }, // ATTR_PATTERN
148  { SID_ATTR_LRSPACE, true }, // ATTR_LRSPACE
149  { SID_ATTR_ULSPACE, true }, // ATTR_ULSPACE
150  { SID_ATTR_PAGE, true }, // ATTR_PAGE
151  { SID_ATTR_PAGE_PAPERBIN, true }, // ATTR_PAGE_PAPERBIN
152  { SID_ATTR_PAGE_SIZE, true }, // ATTR_PAGE_SIZE
153  { SID_ATTR_PAGE_EXT1, true }, // ATTR_PAGE_HORCENTER
154  { SID_ATTR_PAGE_EXT2, true }, // ATTR_PAGE_VERCENTER
155  { SID_ATTR_PAGE_ON, true }, // ATTR_PAGE_ON
156  { SID_ATTR_PAGE_DYNAMIC, true }, // ATTR_PAGE_DYNAMIC
157  { SID_ATTR_PAGE_SHARED, true }, // ATTR_PAGE_SHARED
158  { SID_ATTR_PAGE_SHARED_FIRST, true }, // ATTR_PAGE_SHARED_FIRST
159  { 0, true }, // ATTR_PAGE_NOTES aka. SID_SCATTR_PAGE_NOTES
160  { 0, true }, // ATTR_PAGE_GRID aka. SID_SCATTR_PAGE_GRID
161  { 0, true }, // ATTR_PAGE_HEADERS aka. SID_SCATTR_PAGE_HEADERS
162  { 0, true }, // ATTR_PAGE_CHARTS aka. SID_SCATTR_PAGE_CHARTS
163  { 0, true }, // ATTR_PAGE_OBJECTS aka. SID_SCATTR_PAGE_OBJECTS
164  { 0, true }, // ATTR_PAGE_DRAWINGS aka. SID_SCATTR_PAGE_DRAWINGS
165  { 0, true }, // ATTR_PAGE_TOPDOWN aka. SID_SCATTR_PAGE_TOPDOWN
166  { 0, true }, // ATTR_PAGE_SCALE aka SID_SCATTR_PAGE_SCALE
167  { 0, true }, // ATTR_PAGE_SCALETOPAGES aka SID_SCATTR_PAGE_SCALETOPAGES
168  { 0, true }, // ATTR_PAGE_FIRSTPAGENO aka SID_SCATTR_PAGE_FIRSTPAGENO
169  { 0, true }, // ATTR_PAGE_HEADERLEFT aka SID_SCATTR_PAGE_HEADERLEFT
170  { 0, true }, // ATTR_PAGE_FOOTERLEFT aka SID_SCATTR_PAGE_FOOTERLEFT
171  { 0, true }, // ATTR_PAGE_HEADERRIGHT aka SID_SCATTR_PAGE_HEADERRIGHT
172  { 0, true }, // ATTR_PAGE_FOOTERRIGHT aka. SID_SCATTR_PAGE_FOOTERRIGHT
173  { 0, true }, // ATTR_PAGE_HEADERFIRST aka. SID_SCATTR_PAGE_HEADERFIRST
174  { 0, true }, // ATTR_PAGE_FOOTERFIRST aka. SID_SCATTR_PAGE_FOOTERFIRST`
175  { SID_ATTR_PAGE_HEADERSET, true }, // ATTR_PAGE_HEADERSET
176  { SID_ATTR_PAGE_FOOTERSET, true }, // ATTR_PAGE_FOOTERSET
177  { 0, true }, // ATTR_PAGE_FORMULAS aka. SID_SCATTR_PAGE_FORMULAS
178  { 0, true }, // ATTR_PAGE_NULLVALS aka. SID_SCATTR_PAGE_NULLVALS
179  { 0, true }, // ATTR_PAGE_SCALETO aka. SID_SCATTR_PAGE_SCALETO
180  { 0, true } // ATTR_HIDDEN
181 };
182 static_assert(
183  SAL_N_ELEMENTS(aItemInfos) == ATTR_ENDINDEX - ATTR_STARTINDEX + 1, "these must match");
184 
186 
187  : SfxItemPool ( "ScDocumentPool",
189  aItemInfos, nullptr ),
190  mvPoolDefaults(ATTR_ENDINDEX-ATTR_STARTINDEX+1),
191  mnCurrentMaxKey(0)
192 {
193 
194  LanguageType nDefLang, nCjkLang, nCtlLang;
195  bool bAutoSpell;
196  ScModule::GetSpellSettings( nDefLang, nCjkLang, nCtlLang, bAutoSpell );
197 
198  // latin font from GetDefaultFonts is not used, DEFAULTFONT_LATIN_SPREADSHEET instead
199  SvxFontItem* pStdFont = getDefaultFontItem(nDefLang, DefaultFontType::LATIN_SPREADSHEET, ATTR_FONT);
200  SvxFontItem* pCjkFont = getDefaultFontItem(nCjkLang, DefaultFontType::CJK_SPREADSHEET, ATTR_CJK_FONT);
201  SvxFontItem* pCtlFont = getDefaultFontItem(nCtlLang, DefaultFontType::CTL_SPREADSHEET, ATTR_CTL_FONT);
202 
203  SvxBoxInfoItem* pGlobalBorderInnerAttr = new SvxBoxInfoItem( ATTR_BORDER_INNER );
204  SfxItemSet aSetItemItemSet( *this,
210 
211  pGlobalBorderInnerAttr->SetLine(nullptr, SvxBoxInfoItemLine::HORI);
212  pGlobalBorderInnerAttr->SetLine(nullptr, SvxBoxInfoItemLine::VERT);
213  pGlobalBorderInnerAttr->SetTable(true);
214  pGlobalBorderInnerAttr->SetDist(true);
215  pGlobalBorderInnerAttr->SetMinDist(false);
216 
217  mvPoolDefaults[ ATTR_FONT - ATTR_STARTINDEX ] = pStdFont;
246  mvPoolDefaults[ ATTR_HOR_JUSTIFY - ATTR_STARTINDEX ] = new SvxHorJustifyItem( SvxCellHorJustify::Standard, ATTR_HOR_JUSTIFY);
249  mvPoolDefaults[ ATTR_VER_JUSTIFY - ATTR_STARTINDEX ] = new SvxVerJustifyItem( SvxCellVerJustify::Standard, ATTR_VER_JUSTIFY);
255  // The default for the ATTR_WRITINGDIR cell attribute must by SvxFrameDirection::Environment,
256  // so that value is returned when asking for a default cell's attributes.
257  // The value from the page style is set as DefaultHorizontalTextDirection for the EditEngine.
258  mvPoolDefaults[ ATTR_WRITINGDIR - ATTR_STARTINDEX ] = new SvxFrameDirectionItem( SvxFrameDirection::Environment, ATTR_WRITINGDIR );
271  mvPoolDefaults[ ATTR_BORDER_INNER - ATTR_STARTINDEX ] = pGlobalBorderInnerAttr;
276 
277  // GetRscString only works after ScGlobal::Init (indicated by the EmptyBrushItem)
278  // TODO: Write additional method ScGlobal::IsInit() or somesuch
279  // or detect whether this is the Secondary Pool for a MessagePool
281 
284  ScResId(STR_STYLENAME_STANDARD) );
285  else
288  STRING_STANDARD ); // FIXME: without name?
289 
323 
325 }
326 
328 {
329  Delete();
330 
331  for ( sal_uInt16 i=0; i < ATTR_ENDINDEX-ATTR_STARTINDEX+1; i++ )
332  {
334  delete mvPoolDefaults[i];
335  }
336 }
337 
338 const SfxPoolItem& ScDocumentPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nWhich, bool bPassingOwnership )
339 {
340  if ( rItem.Which() != ATTR_PATTERN ) // Only Pattern is special
341  return SfxItemPool::PutImpl( rItem, nWhich, bPassingOwnership );
342 
343  // Don't copy the default pattern of this Pool
344  if (&rItem == mvPoolDefaults[ ATTR_PATTERN - ATTR_STARTINDEX ])
345  return rItem;
346 
347  // Else Put must always happen, because it could be another Pool
348  const SfxPoolItem& rNew = SfxItemPool::PutImpl( rItem, nWhich, bPassingOwnership );
349  sal_uInt32 nRef = rNew.GetRefCount();
350  if (nRef == 1)
351  {
352  ++mnCurrentMaxKey;
353  const_cast<ScPatternAttr&>(static_cast<const ScPatternAttr&>(rNew)).SetKey(mnCurrentMaxKey);
354  }
355  return rNew;
356 }
357 
359 {
360  for (const SfxPoolItem* pItem : GetItemSurrogates( ATTR_PATTERN ))
361  {
362  ScPatternAttr* pPattern = const_cast<ScPatternAttr*>(dynamic_cast<const ScPatternAttr*>(pItem));
363  if ( pPattern && pPattern->GetStyleSheet() == pStyle )
364  pPattern->StyleToName();
365  }
366 }
367 
368 void ScDocumentPool::CellStyleCreated( std::u16string_view rName, const ScDocument& rDoc )
369 {
370  // If a style was created, don't keep any pattern with its name string in the pool,
371  // because it would compare equal to a pattern with a pointer to the new style.
372  // Calling StyleSheetChanged isn't enough because the pool may still contain items
373  // for undo or clipboard content.
374 
375  for (const SfxPoolItem* pItem : GetItemSurrogates( ATTR_PATTERN ))
376  {
377  auto pPattern = const_cast<ScPatternAttr*>(dynamic_cast<const ScPatternAttr*>(pItem));
378  if ( pPattern && pPattern->GetStyleSheet() == nullptr )
379  {
380  const OUString* pStyleName = pPattern->GetStyleName();
381  if ( pStyleName && *pStyleName == rName )
382  pPattern->UpdateStyleSheet(rDoc); // find and store style pointer
383  }
384  }
385 }
386 
388 {
389  return new SfxItemPool (*this, true);
390 }
391 
392 static bool lcl_HFPresentation
393 (
394  const SfxPoolItem& rItem,
395  MapUnit eCoreMetric,
396  MapUnit ePresentationMetric,
397  OUString& rText,
398  const IntlWrapper& rIntl
399 )
400 {
401  const SfxItemSet& rSet = static_cast<const SfxSetItem&>(rItem).GetItemSet();
402 
403  if ( const SfxBoolItem* pItem = rSet.GetItemIfSet(ATTR_PAGE_ON,false) )
404  {
405  if( !pItem->GetValue() )
406  return false;
407  }
408 
409  SfxItemIter aIter( rSet );
410 
411  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
412  {
413  sal_uInt16 nWhich = pItem->Which();
414 
415  OUString aText;
416 
417  switch( nWhich )
418  {
419  case ATTR_PAGE_ON:
420  case ATTR_PAGE_DYNAMIC:
421  case ATTR_PAGE_SHARED:
423  break;
424 
425  case ATTR_LRSPACE:
426  {
427  const SvxLRSpaceItem& rLRItem = static_cast<const SvxLRSpaceItem&>(*pItem);
428  sal_uInt16 nPropLeftMargin = rLRItem.GetPropLeft();
429  sal_uInt16 nPropRightMargin = rLRItem.GetPropRight();
430  sal_uInt16 nLeftMargin, nRightMargin;
431  tools::Long nTmp;
432  nTmp = rLRItem.GetLeft();
433  nLeftMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
434  nTmp = rLRItem.GetRight();
435  nRightMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
436 
437  aText = EditResId(RID_SVXITEMS_LRSPACE_LEFT);
438  if ( 100 != nPropLeftMargin )
439  {
440  aText += unicode::formatPercent(nPropLeftMargin,
441  Application::GetSettings().GetUILanguageTag());
442  }
443  else
444  {
445  aText += GetMetricText( static_cast<tools::Long>(nLeftMargin),
446  eCoreMetric, ePresentationMetric, &rIntl ) +
447  " " + EditResId(GetMetricId(ePresentationMetric));
448  }
449  aText += cpDelim +
450  // We don't have a nPropFirstLineOffset
451  EditResId(RID_SVXITEMS_LRSPACE_RIGHT);
452  if ( 100 != nPropRightMargin )
453  {
454  aText += unicode::formatPercent(nPropLeftMargin,
455  Application::GetSettings().GetUILanguageTag());
456  }
457  else
458  {
459  aText += GetMetricText( static_cast<tools::Long>(nRightMargin),
460  eCoreMetric, ePresentationMetric, &rIntl ) +
461  " " + EditResId(GetMetricId(ePresentationMetric));
462  }
463  }
464  break;
465 
466  default:
467  pItem->GetPresentation( SfxItemPresentation::Complete, eCoreMetric, ePresentationMetric, aText, rIntl );
468 
469  }
470 
471  if ( aText.getLength() )
472  {
473  rText += aText + " + ";
474  }
475  }
476 
477  rText = comphelper::string::stripEnd(rText, ' ');
478  rText = comphelper::string::stripEnd(rText, '+');
479  rText = comphelper::string::stripEnd(rText, ' ');
480  return true;
481 }
482 
484  const SfxPoolItem& rItem,
485  MapUnit ePresentationMetric,
486  OUString& rText,
487  const IntlWrapper& rIntl ) const
488 {
489  sal_uInt16 nW = rItem.Which();
490  OUString aStrYes ( ScResId(STR_YES) );
491  OUString aStrNo ( ScResId(STR_NO) );
492  OUString aStrSep(": ");
493 
494  bool ePresentationRet = true;
495  switch( nW )
496  {
497  case ATTR_PAGE_TOPDOWN:
498  rText = ScResId(STR_SCATTR_PAGE_PRINTDIR) + aStrSep;
499  rText += static_cast<const SfxBoolItem&>(rItem).GetValue() ?
500  ScResId(STR_SCATTR_PAGE_TOPDOWN) :
501  ScResId(STR_SCATTR_PAGE_LEFTRIGHT) ;
502  break;
503 
504  case ATTR_PAGE_HEADERS:
505  rText = ScResId(STR_SCATTR_PAGE_HEADERS) + aStrSep;
506  rText += static_cast<const SfxBoolItem&>(rItem).GetValue() ? aStrYes : aStrNo ;
507  break;
508 
509  case ATTR_PAGE_NULLVALS:
510  rText = ScResId(STR_SCATTR_PAGE_NULLVALS) + aStrSep;
511  rText += static_cast<const SfxBoolItem&>(rItem).GetValue() ? aStrYes : aStrNo ;
512  break;
513 
514  case ATTR_PAGE_FORMULAS:
515  rText = ScResId(STR_SCATTR_PAGE_FORMULAS) + aStrSep;
516  rText += static_cast<const SfxBoolItem&>(rItem).GetValue() ? aStrYes : aStrNo ;
517  break;
518 
519  case ATTR_PAGE_NOTES:
520  rText = ScResId(STR_SCATTR_PAGE_NOTES) + aStrSep;
521  rText += static_cast<const SfxBoolItem&>(rItem).GetValue() ? aStrYes : aStrNo ;
522  break;
523 
524  case ATTR_PAGE_GRID:
525  rText = ScResId(STR_SCATTR_PAGE_GRID) + aStrSep;
526  rText += static_cast<const SfxBoolItem&>(rItem).GetValue() ? aStrYes : aStrNo ;
527  break;
528 
530  {
531  sal_uInt16 nPagNo = static_cast<const SfxUInt16Item&>(rItem).GetValue();
532 
533  if( nPagNo )
534  {
535  rText = ScResId( STR_SCATTR_PAGE_SCALETOPAGES ) + aStrSep;
536  OUString aPages(ScResId(STR_SCATTR_PAGE_SCALE_PAGES, nPagNo));
537  aPages = aPages.replaceFirst( "%1", OUString::number( nPagNo ) );
538  rText += aPages;
539  }
540  else
541  {
542  ePresentationRet = false;
543  }
544  }
545  break;
546 
548  {
549  sal_uInt16 nPagNo = static_cast<const SfxUInt16Item&>(rItem).GetValue();
550 
551  if( nPagNo )
552  {
553  rText = ScResId(STR_SCATTR_PAGE_FIRSTPAGENO) + aStrSep;
554  rText += OUString::number( nPagNo );
555  }
556  else
557  {
558  ePresentationRet = false;
559  }
560  }
561  break;
562 
563  case ATTR_PAGE_SCALE:
564  {
565  sal_uInt16 nPercent = static_cast<const SfxUInt16Item &>(rItem).GetValue();
566 
567  if( nPercent )
568  {
569  rText = ScResId(STR_SCATTR_PAGE_SCALE) + aStrSep;
570  rText += unicode::formatPercent(nPercent,
571  Application::GetSettings().GetUILanguageTag());
572  }
573  else
574  {
575  ePresentationRet = false;
576  }
577  }
578  break;
579 
580  case ATTR_PAGE_HEADERSET:
581  {
582  OUString aBuffer;
583 
584  if( lcl_HFPresentation( rItem, GetMetric( nW ), ePresentationMetric, aBuffer, rIntl ) )
585  {
586  rText = ScResId(STR_HEADER) + " ( " + aBuffer + " ) ";
587  }
588  }
589  break;
590 
591  case ATTR_PAGE_FOOTERSET:
592  {
593  OUString aBuffer;
594 
595  if( lcl_HFPresentation( rItem, GetMetric( nW ), ePresentationMetric, aBuffer, rIntl ) )
596  {
597  rText = ScResId(STR_FOOTER) + " ( " + aBuffer + " ) ";
598  }
599  }
600  break;
601 
602  default:
603  ePresentationRet = rItem.GetPresentation( SfxItemPresentation::Complete, GetMetric( nW ), ePresentationMetric, rText, rIntl );
604  break;
605  }
606 
607  return ePresentationRet;
608 }
609 
610 MapUnit ScDocumentPool::GetMetric( sal_uInt16 nWhich ) const
611 {
612  // Own attributes in Twips, everything else in 1/100 mm
613  if ( nWhich >= ATTR_STARTINDEX && nWhich <= ATTR_ENDINDEX )
614  return MapUnit::MapTwip;
615  else
616  return MapUnit::Map100thMM;
617 }
618 
619 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OString stripEnd(const OString &rIn, char c)
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_FOOTERFIRST(183)
constexpr TypedWhichId< SvxWeightItem > ATTR_CTL_FONT_WEIGHT(118)
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
constexpr TypedWhichId< SvxEmphasisMarkItem > ATTR_FONT_EMPHASISMARK(121)
virtual bool GetPresentation(const SfxPoolItem &rItem, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntl) const override
Definition: docpool.cxx:483
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_DYNAMIC(165)
SfxItemPool(const SfxItemPool &rPool, bool bCloneStaticDefaults=false)
constexpr TypedWhichId< ScViewObjectModeItem > ATTR_PAGE_DRAWINGS(173)
constexpr TypedWhichId< SvxLanguageItem > ATTR_LANGUAGE_FORMAT(147)
constexpr TypedWhichId< SvxSizeItem > ATTR_PAGE_SIZE(161)
const OUString & GetFamilyName() const
constexpr TypedWhichId< ScPatternAttr > ATTR_PATTERN(156)
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
void CellStyleCreated(std::u16string_view rName, const ScDocument &rDoc)
Definition: docpool.cxx:368
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
static constexpr auto Items
constexpr TypedWhichId< SvxLanguageItem > ATTR_CJK_FONT_LANGUAGE(115)
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_GRID(169)
static void GetSpellSettings(LanguageType &rDefLang, LanguageType &rCjkLang, LanguageType &rCtlLang, bool &rAutoSpell)
Definition: scmod.cxx:2252
std::string GetValue
const OUString & GetStyleName() const
void StyleDeleted(const ScStyleSheet *pStyle)
Definition: docpool.cxx:358
constexpr TypedWhichId< SfxBoolItem > ATTR_VERTICAL_ASIAN(137)
sal_uInt32 GetRefCount() const
void SetMinDist(bool bNew)
constexpr TypedWhichId< ScViewObjectModeItem > ATTR_PAGE_CHARTS(171)
tools::Long const nLeftMargin
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_HEADERLEFT(178)
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALE(175)
constexpr TypedWhichId< SvxCrossedOutItem > ATTR_FONT_CROSSEDOUT(106)
long Long
tools::Long GetRight() const
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr TypedWhichId< SvxLanguageItem > ATTR_FONT_LANGUAGE(110)
void SetTable(bool bNew)
static const AllSettings & GetSettings()
constexpr::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr TypedWhichId< SvxRotateModeItem > ATTR_ROTATE_MODE(136)
void SetDefaults(std::vector< SfxPoolItem * > *pDefaults)
constexpr TypedWhichId< SvxBoxInfoItem > ATTR_BORDER_INNER(151)
constexpr OUStringLiteral STRING_STANDARD
Definition: global.hxx:59
constexpr TypedWhichId< SvxCharReliefItem > ATTR_FONT_RELIEF(124)
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
constexpr TypedWhichId< ScLineBreakCell > ATTR_LINEBREAK(139)
constexpr TypedWhichId< ScProtectionAttr > ATTR_PROTECTION(149)
constexpr sal_uInt16 ATTR_STARTINDEX(100)
void Delete()
virtual rtl::Reference< SfxItemPool > Clone() const override
Definition: docpool.cxx:387
constexpr TypedWhichId< ScViewObjectModeItem > ATTR_PAGE_OBJECTS(172)
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
FontFamily GetFamilyType()
constexpr TypedWhichId< SvxScriptSpaceItem > ATTR_SCRIPTSPACE(126)
constexpr TypedWhichId< ScIndentItem > ATTR_INDENT(131)
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_HEADERRIGHT(180)
constexpr TypedWhichId< ScRotateValueItem > ATTR_ROTATE_VALUE(135)
const SfxPoolItem * NextItem()
LINESTYLE_NONE
constexpr TypedWhichId< SvxShadowItem > ATTR_SHADOW(152)
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_TOPDOWN(174)
TranslateId GetMetricId(MapUnit eUnit)
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_VERCENTER(163)
constexpr TypedWhichId< SvxJustifyMethodItem > ATTR_HOR_JUSTIFY_METHOD(130)
constexpr TypedWhichId< ScShrinkToFitCell > ATTR_SHRINKTOFIT(140)
void StyleToName()
Definition: patattr.cxx:1266
sal_uInt64 mnCurrentMaxKey
Definition: docpool.hxx:32
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_SHARED_FIRST(167)
constexpr TypedWhichId< SvxPaperBinItem > ATTR_PAGE_PAPERBIN(160)
constexpr TypedWhichId< SvxUnderlineItem > ATTR_FONT_UNDERLINE(104)
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_HEADERFIRST(182)
#define SAL_N_ELEMENTS(arr)
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_TLBR(141)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALIDDATA(153)
sal_uInt16 GetPropRight() const
constexpr TypedWhichId< SvxPostureItem > ATTR_FONT_POSTURE(103)
constexpr TypedWhichId< SvxShadowedItem > ATTR_FONT_SHADOWED(108)
sal_Int32 nRef
FontPitch GetPitch()
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CJK_FONT_HEIGHT(112)
int i
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_HEADERSET(184)
virtual const SfxPoolItem & PutImpl(const SfxPoolItem &, sal_uInt16 nWhich=0, bool bPassingOwnership=false) override
Definition: docpool.cxx:338
virtual ~ScDocumentPool() override
Definition: docpool.cxx:327
constexpr TypedWhichId< SvxVerJustifyItem > ATTR_VER_JUSTIFY(132)
sal_uInt16 GetPropLeft() const
const ScStyleSheet * GetStyleSheet() const
Definition: patattr.hxx:128
tools::Long GetLeft() const
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxInfoItemLine nLine)
OUString GetMetricText(tools::Long nVal, MapUnit eSrcUnit, MapUnit eDestUnit, const IntlWrapper *pIntl)
WEIGHT_NORMAL
const SfxItemSet * GetItemSet(const SfxPoolItem &rAttr)
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_HORCENTER(162)
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_FORMULAS(186)
#define LANGUAGE_DONTKNOW
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
constexpr TypedWhichId< ScVerticalStackCell > ATTR_STACKED(134)
SVX_ROTATE_MODE_BOTTOM
ITALIC_NONE
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_NOTES(168)
static SC_DLLPUBLIC LanguageType eLnge
Definition: global.hxx:545
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_FIRSTPAGENO(177)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CTL_FONT_HEIGHT(117)
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_HEADERS(170)
constexpr TypedWhichId< SvxFontItem > ATTR_CTL_FONT(116)
constexpr TypedWhichId< SvxLRSpaceItem > ATTR_LRSPACE(157)
constexpr TypedWhichId< ScPageScaleToItem > ATTR_PAGE_SCALETO(188)
constexpr TypedWhichId< ScHyphenateCell > ATTR_HYPHENATE(125)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const override
Definition: docpool.cxx:610
constexpr TypedWhichId< SvxFontItem > ATTR_CJK_FONT(111)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
static SvxBrushItem * GetEmptyBrushItem()
Definition: global.hxx:591
constexpr TypedWhichId< SvxLanguageItem > ATTR_CTL_FONT_LANGUAGE(120)
constexpr TypedWhichId< SvxFrameDirectionItem > ATTR_WRITINGDIR(138)
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_FOOTERLEFT(179)
std::unique_ptr< char[]> aBuffer
constexpr sal_uInt16 ATTR_ENDINDEX(ATTR_HIDDEN)
static OUString formatPercent(double dNumber, const LanguageTag &rLangTag)
constexpr TypedWhichId< SvxJustifyMethodItem > ATTR_VER_JUSTIFY_METHOD(133)
constexpr TypedWhichId< SvxPostureItem > ATTR_CTL_FONT_POSTURE(119)
virtual bool GetPresentation(SfxItemPresentation ePresentation, MapUnit eCoreMetric, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntlWrapper) const
Contains the "scale to width/height" attribute in page styles.
Definition: attrib.hxx:224
constexpr TypedWhichId< SvxOverlineItem > ATTR_FONT_OVERLINE(105)
std::vector< SfxPoolItem * > mvPoolDefaults
Definition: docpool.hxx:31
static void ClearRefCount(SfxPoolItem &rItem)
virtual const SfxPoolItem & PutImpl(const SfxPoolItem &, sal_uInt16 nWhich=0, bool bPassingOwnership=false)
void SetKey(sal_uInt64 nKey)
Definition: patattr.cxx:1400
constexpr TypedWhichId< SvXMLAttrContainerItem > ATTR_USERDEF(122)
constexpr TypedWhichId< SvxPostureItem > ATTR_CJK_FONT_POSTURE(114)
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
SfxItemInfo const aItemInfos[]
Definition: docpool.cxx:89
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
constexpr TypedWhichId< SvxULSpaceItem > ATTR_ULSPACE(158)
constexpr TypedWhichId< ScCondFormatItem > ATTR_CONDITIONAL(154)
constexpr TypedWhichId< SvxPageItem > ATTR_PAGE(159)
tools::Long const nRightMargin
DefaultFontType
constexpr TypedWhichId< SfxStringItem > ATTR_HYPERLINK(155)
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALETOPAGES(176)
constexpr OUStringLiteral cpDelim
MapUnit
constexpr TypedWhichId< ScPageHFItem > ATTR_PAGE_FOOTERRIGHT(181)
constexpr TypedWhichId< SvxWordLineModeItem > ATTR_FONT_WORDLINE(123)
STRIKEOUT_NONE
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_ON(164)
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_NULLVALS(187)
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_FOOTERSET(185)
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxWeightItem > ATTR_CJK_FONT_WEIGHT(113)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
static bool lcl_HFPresentation(const SfxPoolItem &rItem, MapUnit eCoreMetric, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntl)
Definition: docpool.cxx:393
constexpr TypedWhichId< SvxHangingPunctuationItem > ATTR_HANGPUNCTUATION(127)
constexpr TypedWhichId< SfxBoolItem > ATTR_HIDDEN(189)
constexpr TypedWhichId< SvxLineItem > ATTR_BORDER_BLTR(142)
constexpr TypedWhichId< SvxContourItem > ATTR_FONT_CONTOUR(107)
const OUString * GetStyleName() const
Definition: patattr.cxx:1207
sal_uInt16 Which() const
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_SHARED(166)
rtl_TextEncoding GetCharSet() const
const SfxPoolItem * GetCurItem() const
constexpr TypedWhichId< SvxMarginItem > ATTR_MARGIN(143)
void SetDist(bool bNew)
OUString EditResId(TranslateId aId)
constexpr TypedWhichId< SvxForbiddenRuleItem > ATTR_FORBIDDEN_RULES(128)