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