LibreOffice Module sw (master)  1
fldbas.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 <fldbas.hxx>
21 
22 #include <float.h>
23 
24 #include <libxml/xmlwriter.h>
25 
26 #include <rtl/math.hxx>
27 #include <svl/zforlist.hxx>
28 #include <svl/zformat.hxx>
29 #include <o3tl/enumarray.hxx>
30 #include <osl/diagnose.h>
31 #include <unofldmid.h>
32 #include <doc.hxx>
33 #include <fmtfld.hxx>
34 #include <docufld.hxx>
35 #include <expfld.hxx>
36 #include <shellres.hxx>
37 #include <calc.hxx>
38 #include <strings.hrc>
39 #include <docary.hxx>
40 #include <authfld.hxx>
41 #include <calbck.hxx>
42 #include <viewsh.hxx>
43 
44 using namespace ::com::sun::star;
45 using namespace nsSwDocInfoSubType;
46 
48  const SvNumberFormatter& rFormatter )
49 {
50  if( nLng == LANGUAGE_NONE ) // Bug #60010
51  nLng = LANGUAGE_SYSTEM;
52  else if( nLng == ::GetAppLanguage() )
53  switch( rFormatter.GetIndexTableOffset( nFormat ))
54  {
55  case NF_NUMBER_SYSTEM:
59  nLng = LANGUAGE_SYSTEM;
60  break;
61  default: break;
62  }
63  return nLng;
64 }
65 
66 // Globals
67 
69 std::vector<OUString>* SwFieldType::s_pFieldNames = nullptr;
70 
71 namespace
72 {
73 
75  /* SwFieldIds::Database */ SwFieldTypesEnum::Database,
76  /* SwFieldIds::User */ SwFieldTypesEnum::User,
77  /* SwFieldIds::Filename */ SwFieldTypesEnum::Filename,
78  /* SwFieldIds::DatabaseName */ SwFieldTypesEnum::DatabaseName,
79  /* SwFieldIds::Date */ SwFieldTypesEnum::Date,
80  /* SwFieldIds::Time */ SwFieldTypesEnum::Time,
81  /* SwFieldIds::PageNumber */ SwFieldTypesEnum::PageNumber, // dynamic
82  /* SwFieldIds::Author */ SwFieldTypesEnum::Author,
83  /* SwFieldIds::Chapter */ SwFieldTypesEnum::Chapter,
84  /* SwFieldIds::DocStat */ SwFieldTypesEnum::DocumentStatistics,
85  /* SwFieldIds::GetExp */ SwFieldTypesEnum::Get, // dynamic
86  /* SwFieldIds::SetExp */ SwFieldTypesEnum::Set, // dynamic
87  /* SwFieldIds::GetRef */ SwFieldTypesEnum::GetRef,
88  /* SwFieldIds::HiddenText */ SwFieldTypesEnum::HiddenText,
89  /* SwFieldIds::Postit */ SwFieldTypesEnum::Postit,
90  /* SwFieldIds::FixDate */ SwFieldTypesEnum::FixedDate,
91  /* SwFieldIds::FixTime */ SwFieldTypesEnum::FixedTime,
92  /* SwFieldIds::Reg */ SwFieldTypesEnum::Begin, // old (no change since 2000)
93  /* SwFieldIds::VarReg */ SwFieldTypesEnum::Begin, // old (no change since 2000)
94  /* SwFieldIds::SetRef */ SwFieldTypesEnum::SetRef,
95  /* SwFieldIds::Input */ SwFieldTypesEnum::Input,
96  /* SwFieldIds::Macro */ SwFieldTypesEnum::Macro,
97  /* SwFieldIds::Dde */ SwFieldTypesEnum::DDE,
98  /* SwFieldIds::Table */ SwFieldTypesEnum::Formel,
99  /* SwFieldIds::HiddenPara */ SwFieldTypesEnum::HiddenParagraph,
100  /* SwFieldIds::DocInfo */ SwFieldTypesEnum::DocumentInfo,
101  /* SwFieldIds::TemplateName */ SwFieldTypesEnum::TemplateName,
102  /* SwFieldIds::DbNextSet */ SwFieldTypesEnum::DatabaseNextSet,
103  /* SwFieldIds::DbNumSet */ SwFieldTypesEnum::DatabaseNumberSet,
104  /* SwFieldIds::DbSetNumber */ SwFieldTypesEnum::DatabaseSetNumber,
105  /* SwFieldIds::ExtUser */ SwFieldTypesEnum::ExtendedUser,
106  /* SwFieldIds::RefPageSet */ SwFieldTypesEnum::SetRefPage,
107  /* SwFieldIds::RefPageGet */ SwFieldTypesEnum::GetRefPage,
108  /* SwFieldIds::Internet */ SwFieldTypesEnum::Internet,
109  /* SwFieldIds::JumpEdit */ SwFieldTypesEnum::JumpEdit,
110  /* SwFieldIds::Script */ SwFieldTypesEnum::Script,
111  /* SwFieldIds::DateTime */ SwFieldTypesEnum::Begin, // dynamic
112  /* SwFieldIds::TableOfAuthorities*/ SwFieldTypesEnum::Authority,
113  /* SwFieldIds::CombinedChars */ SwFieldTypesEnum::CombinedChars,
114  /* SwFieldIds::Dropdown */ SwFieldTypesEnum::Dropdown,
115  /* SwFieldIds::ParagraphSignature */ SwFieldTypesEnum::ParagraphSignature
116  };
117 
118 }
119 
121 {
122  if (!s_pFieldNames)
123  GetFieldName_();
124 
125  return (*SwFieldType::s_pFieldNames)[static_cast<int>(nTypeId)];
126 }
127 
128 // each field references a field type that is unique for each document
130  : SwModify()
131  , m_nWhich(nWhichId)
132 {
133 }
134 
135 OUString SwFieldType::GetName() const
136 {
137  return OUString();
138 }
139 
140 void SwFieldType::QueryValue( uno::Any&, sal_uInt16 ) const
141 {
142 }
143 void SwFieldType::PutValue( const uno::Any& , sal_uInt16 )
144 {
145 }
146 
148 {
150  if (!aIter.First())
151  return;
152  xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldType"));
153  for (const SwFormatField* pFormatField = aIter.First(); pFormatField;
154  pFormatField = aIter.Next())
155  pFormatField->dumpAsXml(pWriter);
156  xmlTextWriterEndElement(pWriter);
157 }
158 
160 {
161  xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldTypes"));
162  sal_uInt16 nCount = size();
163  for (sal_uInt16 nType = 0; nType < nCount; ++nType)
164  (*this)[nType]->dumpAsXml(pWriter);
165  xmlTextWriterEndElement(pWriter);
166 }
167 
168 // Base class for all fields.
169 // A field (multiple can exist) references a field type (can exists only once)
171  SwFieldType* pType,
172  sal_uInt32 nFormat,
174  bool bUseFieldValueCache)
175  : m_Cache()
176  , m_bUseFieldValueCache( bUseFieldValueCache )
177  , m_nLang( nLang )
178  , m_bIsAutomaticLanguage( true )
179  , m_nFormat( nFormat )
180  , m_pType( pType )
181 {
182  assert(m_pType);
183 }
184 
186 {
187 }
188 
189 // instead of indirectly via the type
190 
191 #ifdef DBG_UTIL
193 {
194  assert(m_pType);
195  return m_pType->Which();
196 }
197 #endif
198 
200 {
201 
202  SwFieldTypesEnum nRet;
203  switch (m_pType->Which())
204  {
206  if (GetSubType() & FIXEDFLD)
208  else
210  break;
211  case SwFieldIds::GetExp:
213  break;
214 
216  nRet = static_cast<SwFieldTypesEnum>(GetSubType());
217  break;
218 
219  case SwFieldIds::SetExp:
222  else if( static_cast<const SwSetExpField*>(this)->GetInputFlag() )
224  else
225  nRet = SwFieldTypesEnum::Set;
226  break;
227 
229  {
230  auto nSubType = GetSubType();
231  if( PG_NEXT == nSubType )
233  else if( PG_PREV == nSubType )
235  else
237  }
238  break;
239 
240  default:
241  nRet = aTypeTab[ m_pType->Which() ];
242  }
243  return nRet;
244 }
245 
247 OUString SwField::GetFieldName() const
248 {
249  SwFieldTypesEnum nTypeId = GetTypeId();
250  if (SwFieldIds::DateTime == GetTyp()->Which())
251  {
252  nTypeId =
254  }
255  OUString sRet = SwFieldType::GetTypeStr( nTypeId );
256  if (IsFixed())
257  {
258  sRet += " " + SwViewShell::GetShellRes()->aFixedStr;
259  }
260  return sRet;
261 }
262 
263 OUString SwField::GetPar1() const
264 {
265  return OUString();
266 }
267 
268 OUString SwField::GetPar2() const
269 {
270  return OUString();
271 }
272 
273 OUString SwField::GetFormula() const
274 {
275  return GetPar2();
276 }
277 
278 void SwField::SetPar1(const OUString& )
279 {}
280 
281 void SwField::SetPar2(const OUString& )
282 {}
283 
284 sal_uInt16 SwField::GetSubType() const
285 {
286  return 0;
287 }
288 
289 void SwField::SetSubType(sal_uInt16 )
290 {
291 }
292 
293 bool SwField::QueryValue( uno::Any& rVal, sal_uInt16 nWhichId ) const
294 {
295  switch( nWhichId )
296  {
297  case FIELD_PROP_BOOL4:
298  rVal <<= !m_bIsAutomaticLanguage;
299  break;
300  default:
301  assert(false);
302  }
303  return true;
304 }
305 
306 bool SwField::PutValue( const uno::Any& rVal, sal_uInt16 nWhichId )
307 {
308  switch( nWhichId )
309  {
310  case FIELD_PROP_BOOL4:
311  {
312  bool bFixed = false;
313  if(rVal >>= bFixed)
314  m_bIsAutomaticLanguage = !bFixed;
315  }
316  break;
317  default:
318  assert(false);
319  }
320  return true;
321 }
322 
331 {
332  assert(pNewType && pNewType->Which() == m_pType->Which());
333 
334  SwFieldType* pOld = m_pType;
335  m_pType = pNewType;
336  return pOld;
337 }
338 
341 {
342  bool bRet = false;
343  switch (m_pType->Which())
344  {
347  case SwFieldIds::GetRef:
348  case SwFieldIds::Macro:
349  case SwFieldIds::Input:
350  case SwFieldIds::Dropdown :
351  bRet = true;
352  break;
353 
354  case SwFieldIds::SetExp:
355  bRet = static_cast<const SwSetExpField*>(this)->GetInputFlag();
356  break;
357  default: break;
358  }
359  return bRet;
360 }
361 
363 {
364  m_nLang = nLang;
365 }
366 
367 void SwField::ChangeFormat(sal_uInt32 const nFormat)
368 {
369  m_nFormat = nFormat;
370 }
371 
372 bool SwField::IsFixed() const
373 {
374  bool bRet = false;
375  switch (m_pType->Which())
376  {
377  case SwFieldIds::FixDate:
378  case SwFieldIds::FixTime:
379  bRet = true;
380  break;
381 
383  bRet = 0 != (GetSubType() & FIXEDFLD);
384  break;
385 
386  case SwFieldIds::ExtUser:
387  case SwFieldIds::Author:
388  bRet = 0 != (GetFormat() & AF_FIXED);
389  break;
390 
392  bRet = 0 != (GetFormat() & FF_FIXED);
393  break;
394 
395  case SwFieldIds::DocInfo:
396  bRet = 0 != (GetSubType() & DI_SUB_FIXED);
397  break;
398  default: break;
399  }
400  return bRet;
401 }
402 
403 OUString
404 SwField::ExpandField(bool const bCached, SwRootFrame const*const pLayout) const
405 {
406  if ( m_bUseFieldValueCache )
407  {
408  if (!bCached) // #i85766# do not expand fields in clipboard documents
409  {
411  {
412  const SwAuthorityField* pAuthorityField = static_cast<const SwAuthorityField*>(this);
413  m_Cache = pAuthorityField->ConditionalExpandAuthIdentifier(pLayout);
414  }
415  else
416  m_Cache = ExpandImpl(pLayout);
417  }
418  return m_Cache;
419  }
420 
421  return ExpandImpl(pLayout);
422 }
423 
424 std::unique_ptr<SwField> SwField::CopyField() const
425 {
426  std::unique_ptr<SwField> pNew = Copy();
427  // #i85766# cache expansion of source (for clipboard)
428  // use this->cache, not this->Expand(): only text formatting calls Expand()
429  pNew->m_Cache = m_Cache;
430  pNew->m_bUseFieldValueCache = m_bUseFieldValueCache;
431 
432  return pNew;
433 }
434 
436 OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang)
437 {
438  if(SVX_NUM_PAGEDESC == nFormat)
439  return OUString::number( nNum );
440  SvxNumberType aNumber;
441 
442  OSL_ENSURE(nFormat != SVX_NUM_NUMBER_NONE, "wrong number format" );
443 
444  aNumber.SetNumberingType(nFormat);
445 
446  if (nLang == LANGUAGE_NONE)
447  return aNumber.GetNumStr(nNum);
448  else
449  return aNumber.GetNumStr(nNum, LanguageTag::convertToLocale(nLang));
450 }
451 
453  : SwFieldType(nWhichId)
454  , m_pDoc(pDoc)
455  , m_bUseFormat(true)
456 {
457 }
458 
460  : SwFieldType(rTyp.Which())
461  , m_pDoc(rTyp.GetDoc())
462  , m_bUseFormat(rTyp.UseFormat())
463 {
464 }
465 
467 OUString SwValueFieldType::ExpandValue( const double& rVal,
468  sal_uInt32 nFormat, LanguageType nLng) const
469 {
470  if (rVal >= DBL_MAX) // error string for calculator
472 
473  OUString sExpand;
475  Color* pCol = nullptr;
476 
477  // Bug #60010
478  LanguageType nFormatLng = ::lcl_GetLanguageOfFormat( nLng, nFormat, *pFormatter );
479 
480  if( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && LANGUAGE_SYSTEM != nFormatLng )
481  {
482  SvNumFormatType nType = SvNumFormatType::DEFINED;
483  sal_Int32 nDummy;
484 
485  const SvNumberformat* pEntry = pFormatter->GetEntry(nFormat);
486 
487  if (pEntry && nLng != pEntry->GetLanguage())
488  {
489  sal_uInt32 nNewFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nFormat,
490  nFormatLng);
491 
492  if (nNewFormat == nFormat)
493  {
494  // probably user-defined format
495  OUString sFormat(pEntry->GetFormatstring());
496 
497  pFormatter->PutandConvertEntry(sFormat, nDummy, nType, nFormat,
498  pEntry->GetLanguage(), nFormatLng, false);
499  }
500  else
501  nFormat = nNewFormat;
502  }
503  OSL_ENSURE(pEntry, "unknown number format!");
504  }
505 
506  if( pFormatter->IsTextFormat( nFormat ) )
507  {
508  pFormatter->GetOutputString(DoubleToString(rVal, nFormatLng), nFormat,
509  sExpand, &pCol);
510  }
511  else
512  {
513  pFormatter->GetOutputString(rVal, nFormat, sExpand, &pCol);
514  }
515  return sExpand;
516 }
517 
518 OUString SwValueFieldType::DoubleToString(const double &rVal,
519  sal_uInt32 nFormat) const
520 {
522  const SvNumberformat* pEntry = pFormatter->GetEntry(nFormat);
523 
524  if (!pEntry)
525  return OUString();
526 
527  return DoubleToString(rVal, pEntry->GetLanguage());
528 }
529 
530 OUString SwValueFieldType::DoubleToString( const double &rVal,
531  LanguageType nLng ) const
532 {
534 
535  // Bug #60010
536  if( nLng == LANGUAGE_NONE )
537  nLng = LANGUAGE_SYSTEM;
538 
539  pFormatter->ChangeIntl( nLng ); // get separator in the correct language
540  return ::rtl::math::doubleToUString( rVal, rtl_math_StringFormat_F, 12,
541  pFormatter->GetNumDecimalSep()[0], true );
542 }
543 
544 SwValueField::SwValueField( SwValueFieldType* pFieldType, sal_uInt32 nFormat,
545  LanguageType nLng, const double fVal )
546  : SwField(pFieldType, nFormat, nLng)
547  , m_fValue(fVal)
548 {
549 }
550 
552  : SwField(rField)
553  , m_fValue(rField.GetValue())
554 {
555 }
556 
558 {
559 }
560 
569 {
570  SwDoc* pNewDoc = static_cast<SwValueFieldType *>(pNewType)->GetDoc();
571  SwDoc* pDoc = GetDoc();
572 
573  if( pNewDoc && pDoc && pDoc != pNewDoc)
574  {
575  SvNumberFormatter* pFormatter = pNewDoc->GetNumberFormatter();
576 
577  if( pFormatter && pFormatter->HasMergeFormatTable() &&
578  static_cast<SwValueFieldType *>(GetTyp())->UseFormat() )
579  SetFormat(pFormatter->GetMergeFormatIndex( GetFormat() ));
580  }
581 
582  return SwField::ChgTyp(pNewType);
583 }
584 
586 sal_uInt32 SwValueField::GetSystemFormat(SvNumberFormatter* pFormatter, sal_uInt32 nFormat)
587 {
588  const SvNumberformat* pEntry = pFormatter->GetEntry(nFormat);
590 
591  if (pEntry && nLng != pEntry->GetLanguage())
592  {
593  sal_uInt32 nNewFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nFormat,
594  nLng);
595 
596  if (nNewFormat == nFormat)
597  {
598  // probably user-defined format
599  SvNumFormatType nType = SvNumFormatType::DEFINED;
600  sal_Int32 nDummy;
601 
602  OUString sFormat(pEntry->GetFormatstring());
603 
604  sal_uInt32 nTempFormat = nFormat;
605  pFormatter->PutandConvertEntry(sFormat, nDummy, nType,
606  nTempFormat, pEntry->GetLanguage(), nLng, true);
607  nFormat = nTempFormat;
608  }
609  else
610  nFormat = nNewFormat;
611  }
612 
613  return nFormat;
614 }
615 
617 {
618  xmlTextWriterStartElement(pWriter, BAD_CAST("SwValueField"));
619  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_fValue"), BAD_CAST(OString::number(m_fValue).getStr()));
620  SwField::dumpAsXml(pWriter);
621  xmlTextWriterEndElement(pWriter);
622 }
623 
626 {
627  if( IsAutomaticLanguage() &&
628  static_cast<SwValueFieldType *>(GetTyp())->UseFormat() &&
630  {
631  // Bug #60010
632  SvNumberFormatter* pFormatter = GetDoc()->GetNumberFormatter();
633  LanguageType nFormatLng = ::lcl_GetLanguageOfFormat( nLng, GetFormat(),
634  *pFormatter );
635 
637  LANGUAGE_SYSTEM != nFormatLng ) &&
639  {
640  const SvNumberformat* pEntry = pFormatter->GetEntry(GetFormat());
641 
642  if( pEntry && nFormatLng != pEntry->GetLanguage() )
643  {
644  sal_uInt32 nNewFormat = pFormatter->GetFormatForLanguageIfBuiltIn(
645  GetFormat(), nFormatLng );
646 
647  if( nNewFormat == GetFormat() )
648  {
649  // probably user-defined format
650  SvNumFormatType nType = SvNumFormatType::DEFINED;
651  sal_Int32 nDummy;
652  OUString sFormat( pEntry->GetFormatstring() );
653  pFormatter->PutandConvertEntry( sFormat, nDummy, nType,
654  nNewFormat,
655  pEntry->GetLanguage(),
656  nFormatLng, false);
657  }
658  SetFormat( nNewFormat );
659  }
660  OSL_ENSURE(pEntry, "unknown number format!");
661  }
662  }
663 
664  SwField::SetLanguage(nLng);
665 }
666 
668 {
669  return m_fValue;
670 }
671 
672 void SwValueField::SetValue( const double& rVal )
673 {
674  m_fValue = rVal;
675 }
676 
677 SwFormulaField::SwFormulaField( SwValueFieldType* pFieldType, sal_uInt32 nFormat, const double fVal)
678  : SwValueField(pFieldType, nFormat, LANGUAGE_SYSTEM, fVal)
679 {
680 }
681 
683  : SwValueField(static_cast<SwValueFieldType *>(rField.GetTyp()), rField.GetFormat(),
684  rField.GetLanguage(), rField.GetValue())
685 {
686 }
687 
689 {
690  return m_sFormula;
691 }
692 
693 void SwFormulaField::SetFormula(const OUString& rStr)
694 {
695  m_sFormula = rStr;
696 
697  sal_uLong nFormat(GetFormat());
698 
699  if( nFormat && SAL_MAX_UINT32 != nFormat )
700  {
701  sal_Int32 nPos = 0;
702  double fTmpValue;
703  if( SwCalc::Str2Double( rStr, nPos, fTmpValue, GetDoc() ) )
704  SwValueField::SetValue( fTmpValue );
705  }
706 }
707 
708 void SwFormulaField::SetExpandedFormula( const OUString& rStr )
709 {
710  sal_uInt32 nFormat(GetFormat());
711 
712  if (nFormat && nFormat != SAL_MAX_UINT32 && static_cast<SwValueFieldType *>(GetTyp())->UseFormat())
713  {
714  double fTmpValue;
715 
716  if (GetDoc()->IsNumberFormat(rStr, nFormat, fTmpValue))
717  {
718  SwValueField::SetValue(fTmpValue);
719 
720  m_sFormula = static_cast<SwValueFieldType *>(GetTyp())->DoubleToString(fTmpValue, nFormat);
721  return;
722  }
723  }
724  m_sFormula = rStr;
725 }
726 
728 {
729  sal_uInt32 nFormat(GetFormat());
730 
731  if (nFormat && nFormat != SAL_MAX_UINT32 && static_cast<SwValueFieldType *>(GetTyp())->UseFormat())
732  {
733  OUString sFormattedValue;
734  Color* pCol = nullptr;
735 
736  SvNumberFormatter* pFormatter = GetDoc()->GetNumberFormatter();
737 
738  if (pFormatter->IsTextFormat(nFormat))
739  {
740  OUString sTempIn(static_cast<SwValueFieldType *>(GetTyp())->DoubleToString(GetValue(), nFormat));
741  pFormatter->GetOutputString(sTempIn, nFormat, sFormattedValue, &pCol);
742  }
743  else
744  {
745  pFormatter->GetOutputString(GetValue(), nFormat, sFormattedValue, &pCol);
746  }
747  return sFormattedValue;
748  }
749  else
750  return GetFormula();
751 }
752 
753 OUString SwField::GetDescription() const
754 {
755  return SwResId(STR_FIELD);
756 }
757 
759 {
760  switch (Which())
761  {
763  case SwFieldIds::Macro:
764  case SwFieldIds::GetRef:
765  case SwFieldIds::Input:
766  case SwFieldIds::SetExp:
768  return true;
769  default: break;
770  }
771  return false;
772 }
773 
775 {
776  xmlTextWriterStartElement(pWriter, BAD_CAST("SwField"));
777  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("symbol"), "%s", BAD_CAST(typeid(*this).name()));
778  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
779  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nFormat"), BAD_CAST(OString::number(m_nFormat).getStr()));
780  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nLang"), BAD_CAST(OString::number(m_nLang.get()).getStr()));
781 
782  xmlTextWriterEndElement(pWriter);
783 }
784 
785 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetNumStr(sal_Int32 nNo) const
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:234
SwValueField(SwValueFieldType *pFieldType, sal_uInt32 nFormat, LanguageType nLang=LANGUAGE_SYSTEM, const double fVal=0.0)
Definition: fldbas.cxx:544
sal_uInt32 GetFormatForLanguageIfBuiltIn(sal_uInt32 nFormat, LanguageType eLnge=LANGUAGE_DONTKNOW)
virtual ~SwField()
Definition: fldbas.cxx:185
#define LANGUAGE_NONE
OUString ConditionalExpandAuthIdentifier(SwRootFrame const *pLayout) const
For internal use only, in general continue using ExpandField() instead.
Definition: authfld.cxx:482
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: fldbas.cxx:774
const OUString & GetNumDecimalSep() const
OUString m_Cache
Cached expansion (for clipboard).
Definition: fldbas.hxx:283
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2493
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:388
static LanguageType lcl_GetLanguageOfFormat(LanguageType nLng, sal_uLong nFormat, const SvNumberFormatter &rFormatter)
Definition: fldbas.cxx:47
std::string GetValue
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1401
LanguageType getLanguageType(bool bResolveSystem=true) const
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, Color **ppColor, bool bUseStarFormat=false)
SVX_NUM_NUMBER_NONE
sal_uIntPtr sal_uLong
bool IsFixed() const
Definition: fldbas.cxx:372
Base class of all fields.
Definition: fldbas.hxx:280
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:402
virtual SwFieldType * ChgTyp(SwFieldType *) override
Set a new type.
Definition: fldbas.cxx:568
Definition: doc.hxx:185
TElementType * Next()
Definition: calbck.hxx:373
std::unique_ptr< SwField > CopyField() const
Definition: fldbas.cxx:424
#define FIELD_PROP_BOOL4
Definition: unofldmid.h:41
SwValueFieldType(SwDoc *pDocPtr, SwFieldIds nWhichId)
Definition: fldbas.cxx:452
NfIndexTableOffset GetIndexTableOffset(sal_uInt32 nFormat) const
LanguageType m_nLang
control the usage of the cached field value
Definition: fldbas.hxx:285
bool m_bIsAutomaticLanguage
Definition: fldbas.hxx:286
SwDoc * GetDoc() const
Definition: fldbas.hxx:444
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
const OUString & GetFormatstring() const
SwFieldType * m_pType
this can be either SvxNumType or SwChapterFormat depending on the subtype
Definition: fldbas.hxx:288
OUString GetExpandedFormula() const
Definition: fldbas.cxx:727
SvxNumType
static LanguageType nLang
Definition: srtdlg.cxx:60
#define SAL_MAX_UINT32
virtual OUString GetPar1() const
Definition: fldbas.cxx:263
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const =0
static bool Str2Double(const OUString &rStr, sal_Int32 &rPos, double &rVal)
Definition: calc.cxx:1335
invariant for SwAuthorityField is that it is always registered at its SwAuthorityFieldType via AddFie...
Definition: authfld.hxx:147
virtual void SetPar2(const OUString &rStr)
Definition: fldbas.cxx:281
static std::vector< OUString > * s_pFieldNames
field names
Definition: fldbas.hxx:241
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId)
Definition: fldbas.cxx:306
SwFieldType(SwFieldIds nWhichId)
Single argument ctors shall be explicit.
Definition: fldbas.cxx:129
virtual void SetLanguage(LanguageType nLng) override
set language of the format
Definition: fldbas.cxx:625
OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang)
expand numbering
Definition: fldbas.cxx:436
void SetExpandedFormula(const OUString &rStr)
Definition: fldbas.cxx:708
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const
Definition: fldbas.cxx:293
bool HasClickHdl() const
Does the field possess an action on its ClickHandler? (e.g. INetFields, ...).
Definition: fldbas.cxx:340
virtual OUString GetDescription() const
Definition: fldbas.cxx:753
void SetFormula(const OUString &rStr)
Definition: fldbas.cxx:693
virtual SwFieldType * ChgTyp(SwFieldType *)
Set new type (used for copying among documents).
Definition: fldbas.cxx:330
struct _xmlTextWriter * xmlTextWriterPtr
SwField(SwFieldType *pTyp, sal_uInt32 nFormat=0, LanguageType nLang=LANGUAGE_SYSTEM, bool m_bUseFieldValueCache=true)
Definition: fldbas.cxx:170
virtual void SetPar1(const OUString &rStr)
Definition: fldbas.cxx:278
static OUString GetTypeStr(SwFieldTypesEnum nTypeId)
Definition: fldbas.cxx:120
UNDERLYING_TYPE get() const
virtual std::unique_ptr< SwField > Copy() const =0
bool m_bUseFieldValueCache
Definition: fldbas.hxx:284
bool PutandConvertEntry(OUString &rString, sal_Int32 &nCheckPos, SvNumFormatType &nType, sal_uInt32 &nKey, LanguageType eLnge, LanguageType eNewLnge, bool bConvertDateOrder)
const SwExtendedSubType SUB_CMD
Show command.
Definition: fldbas.hxx:205
virtual ~SwValueField() override
Definition: fldbas.cxx:557
#define LANGUAGE_SYSTEM
bool IsTextFormat(sal_uInt32 nFIndex) const
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: fldbas.cxx:147
SwFormulaField(SwValueFieldType *pFieldType, sal_uInt32 nFormat, const double fVal)
Definition: fldbas.cxx:677
TElementType * First()
Definition: calbck.hxx:342
QPRO_FUNC_TYPE const nType
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:87
SwFieldIds
Definition: fldbas.hxx:38
sal_uInt32 m_nFormat
Definition: fldbas.hxx:287
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: fldbas.cxx:159
void SetFormat(sal_uInt32 const nSet)
Definition: fldbas.hxx:294
virtual OUString GetFormula() const override
Definition: fldbas.cxx:688
SvNumFormatType
size
OUString m_sFormula
Definition: fldbas.hxx:462
OUString SwResId(const char *pId)
Definition: swmodule.cxx:190
bool HasMergeFormatTable() const
#define SV_COUNTRY_LANGUAGE_OFFSET
virtual OUString GetPar2() const
Definition: fldbas.cxx:268
bool IsAutomaticLanguage() const
Definition: fldbas.hxx:370
virtual sal_uInt16 GetSubType() const
Definition: fldbas.cxx:284
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const
Definition: fldbas.cxx:140
SwFieldType * GetTyp() const
Definition: fldbas.hxx:383
NF_NUMBER_SYSTEM
Fields containing values that have to be formatted via number formatter.
Definition: fldbas.hxx:399
SwFieldTypesEnum GetTypeId() const
Definition: fldbas.cxx:199
SVX_NUM_PAGEDESC
OUString ExpandField(bool bCached, SwRootFrame const *pLayout) const
expand the field.
Definition: fldbas.cxx:404
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:198
SwFieldIds Which() const
ResId.
Definition: fldbas.cxx:192
virtual void SetLanguage(LanguageType nLng)
Definition: fldbas.cxx:362
void ChangeIntl(LanguageType eLnge)
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
return value formatted as string
Definition: fldbas.cxx:467
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:135
NF_DATE_SYSTEM_LONG
sal_uInt32 GetMergeFormatIndex(sal_uInt32 nOldFmt) const
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: fldbas.cxx:616
double m_fValue
Definition: fldbas.hxx:432
LanguageType GetAppLanguage()
Definition: init.cxx:729
NF_DATE_SYSTEM_SHORT
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich)
Definition: fldbas.cxx:143
virtual OUString GetFieldName() const
get name or content
Definition: fldbas.cxx:247
const SwGetSetExpType GSE_FORMULA
Formula.
Definition: fldbas.hxx:199
OUString const aFixedStr
Definition: shellres.hxx:47
void ChangeFormat(sal_uInt32 n)
Definition: fldbas.cxx:367
static sal_uInt32 GetSystemFormat(SvNumberFormatter *pFormatter, sal_uInt32 nFormat)
get format in office language
Definition: fldbas.cxx:586
NF_DATETIME_SYSTEM_SHORT_HHMM
const LanguageTag & GetLanguageTag() const
virtual void SetValue(const double &rVal)
Definition: fldbas.cxx:672
const SwDocInfoSubType DI_SUB_FIXED
Definition: docufld.hxx:81
OUString DoubleToString(const double &rVal, LanguageType eLng) const
Definition: fldbas.cxx:530
void SetNumberingType(SvxNumType nSet)
virtual void SetSubType(sal_uInt16)
Definition: fldbas.cxx:289
virtual OUString GetFormula() const
Definition: fldbas.cxx:273
sal_Int32 nPos
SwDoc * m_pDoc
Definition: fldbas.hxx:402
OUString const aCalc_Error
Definition: shellres.hxx:40
SwFieldIds Which() const
Definition: fldbas.hxx:266
bool IsClickable() const
Is this field clickable?
Definition: fldbas.cxx:758
virtual double GetValue() const
Definition: fldbas.cxx:667
LanguageType GetLanguage() const
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)