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