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