24 #include <libxml/xmlwriter.h>
26 #include <rtl/math.hxx>
30 #include <osl/diagnose.h>
38 #include <strings.hrc>
131 :
sw::BroadcastingModify()
161 std::vector<SwFormatField*> vFields;
165 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwFieldType"));
166 for(
const auto pFormatField: vFields)
167 pFormatField->dumpAsXml(pWriter);
168 xmlTextWriterEndElement(pWriter);
190 bool bHasHiddenInformationNotes =
false;
192 return bHasHiddenInformationNotes;
212 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwFieldTypes"));
215 (*
this)[
nType]->dumpAsXml(pWriter);
216 xmlTextWriterEndElement(pWriter);
225 bool bUseFieldValueCache)
230 , m_bUseFieldValueCache( bUseFieldValueCache )
231 , m_bIsAutomaticLanguage( true )
273 else if( static_cast<const SwSetExpField*>(
this)->GetInputFlag() )
406 bRet =
static_cast<const SwSetExpField*
>(
this)->GetInputFlag();
477 std::unique_ptr<SwField> pNew =
Copy();
490 return OUString::number( nNum );
512 , m_pDoc(rTyp.GetDoc())
513 , m_bUseFormat(rTyp.UseFormat())
526 const Color* pCol =
nullptr;
539 if (nNewFormat == nFormat)
550 nFormat = nNewFormat;
552 OSL_ENSURE(pEntry,
"unknown number format!");
568 sal_uInt32 nFormat)
const
589 return ::rtl::math::doubleToUString( rVal, rtl_math_StringFormat_F, 12,
595 :
SwField(pFieldType, nFormat, nLng)
622 if( pNewDoc && pDoc && pDoc != pNewDoc)
645 if (nNewFormat == nFormat)
653 sal_uInt32 nTempFormat = nFormat;
656 nFormat = nTempFormat;
659 nFormat = nNewFormat;
667 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwValueField"));
668 xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"m_fValue"), BAD_CAST(OString::number(
m_fValue).getStr()));
670 xmlTextWriterEndElement(pWriter);
677 static_cast<SwValueFieldType *>(
GetTyp())->UseFormat() &&
691 if( pEntry && nFormatLng != pEntry->
GetLanguage() )
709 OSL_ENSURE(pEntry,
"unknown number format!");
761 if (nFormat && nFormat !=
SAL_MAX_UINT32 && static_cast<SwValueFieldType *>(
GetTyp())->UseFormat())
765 if (
GetDoc()->IsNumberFormat(rStr, nFormat, fTmpValue))
780 if (nFormat && nFormat !=
SAL_MAX_UINT32 && static_cast<SwValueFieldType *>(
GetTyp())->UseFormat())
782 OUString sFormattedValue;
783 const Color* pCol =
nullptr;
789 OUString sTempIn(static_cast<SwValueFieldType *>(
GetTyp())->DoubleToString(
GetValue(), nFormat));
796 return sFormattedValue;
825 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwField"));
826 xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"symbol"),
"%s", BAD_CAST(
typeid(*this).name()));
827 xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
828 xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"m_nFormat"), BAD_CAST(OString::number(
m_nFormat).getStr()));
829 xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"m_nLang"), BAD_CAST(OString::number(
m_nLang.
get()).getStr()));
831 xmlTextWriterEndElement(pWriter);
OUString GetNumStr(sal_Int32 nNo) const
Instances of SwFields and those derived from it occur 0 to n times.
SwValueField(SwValueFieldType *pFieldType, sal_uInt32 nFormat, LanguageType nLang=LANGUAGE_SYSTEM, const double fVal=0.0)
OUString ConditionalExpandAuthIdentifier(SwRootFrame const *pLayout) const
For internal use only, in general continue using ExpandField() instead.
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
OUString m_Cache
Cached expansion (for clipboard).
sal_uInt16 const m_nFormat
static ShellResource * GetShellRes()
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
static LanguageType lcl_GetLanguageOfFormat(LanguageType nLng, sal_uLong nFormat, const SvNumberFormatter &rFormatter)
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
void CollectPostIts(std::vector< SwFormatField * > &rvFormatFields, IDocumentRedlineAccess const &rIDRA, bool HideRedlines)
LanguageType getLanguageType(bool bResolveSystem=true) const
Base class of all fields.
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
virtual SwFieldType * ChgTyp(SwFieldType *) override
Set a new type.
std::unique_ptr< SwField > CopyField() const
SwValueFieldType(SwDoc *pDocPtr, SwFieldIds nWhichId)
SwFormatField * FindFormatForField(const SwField *) const
LanguageType m_nLang
this can be either SvxNumType or SwChapterFormat depending on the subtype
Dialog to specify the properties of date form field.
bool m_bIsAutomaticLanguage
control the usage of the cached field value
The root element of a Writer document layout.
static LanguageType nLang
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
void UpdateFields() const
bool HasHiddenInformationNotes() const
virtual OUString GetPar1() const
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const =0
static bool Str2Double(const OUString &rStr, sal_Int32 &rPos, double &rVal)
invariant for SwAuthorityField is that it is always registered at its SwAuthorityFieldType via AddFie...
virtual void SetPar2(const OUString &rStr)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
static std::vector< OUString > * s_pFieldNames
field names
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhichId)
SwFieldType(SwFieldIds nWhichId)
Single argument ctors shall be explicit.
virtual void SetLanguage(LanguageType nLng) override
set language of the format
OUString FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, LanguageType nLang)
expand numbering
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const
bool HasClickHdl() const
Does the field possess an action on its ClickHandler? (e.g. INetFields, ...).
virtual OUString GetDescription() const
virtual SwFieldType * ChgTyp(SwFieldType *)
Set new type (used for copying among documents).
struct _xmlTextWriter * xmlTextWriterPtr
SwField(SwFieldType *pTyp, sal_uInt32 nFormat=0, LanguageType nLang=LANGUAGE_SYSTEM, bool m_bUseFieldValueCache=true)
virtual void SetPar1(const OUString &rStr)
static OUString GetTypeStr(SwFieldTypesEnum nTypeId)
UNDERLYING_TYPE get() const
virtual std::unique_ptr< SwField > Copy() const =0
bool m_bUseFieldValueCache
const SwExtendedSubType SUB_CMD
Show command.
virtual ~SwValueField() override
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
SwFieldTypesEnum
List of FieldTypes at UI.
void dumpAsXml(xmlTextWriterPtr pWriter) const
void SetFormat(sal_uInt32 const nSet)
void GatherNodeIndex(std::vector< sal_uLong > &rvNodeIndex)
OUString SwResId(const char *pId)
#define SV_COUNTRY_LANGUAGE_OFFSET
virtual OUString GetPar2() const
bool IsAutomaticLanguage() const
virtual sal_uInt16 GetSubType() const
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const
SwFieldType * GetTyp() const
Fields containing values that have to be formatted via number formatter.
SwFieldTypesEnum GetTypeId() const
OUString ExpandField(bool bCached, SwRootFrame const *pLayout) const
expand the field.
const SwGetSetExpType GSE_SEQ
Sequence.
SwFormatField * FindFormatForPostItId(sal_uInt32 nPostItId) const
SwFieldIds Which() const
ResId.
virtual void SetLanguage(LanguageType nLng)
void GatherRefFields(std::vector< SwGetRefField * > &rvRFields, const sal_uInt16 nTyp)
OUString ExpandValue(const double &rVal, sal_uInt32 nFormat, LanguageType nLng) const
return value formatted as string
virtual OUString GetName() const
Only in derived classes.
void dumpAsXml(xmlTextWriterPtr pWriter) const override
LanguageType GetAppLanguage()
constexpr TypedWhichId< SwMsgPoolItem > RES_HIDDENPARA_PRINT(176)
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich)
virtual OUString GetFieldName() const
get name or content
const SwGetSetExpType GSE_FORMULA
Formula.
virtual void CallSwClientNotify(const SfxHint &rHint) const override
void ChangeFormat(sal_uInt32 n)
static sal_uInt32 GetSystemFormat(SvNumberFormatter *pFormatter, sal_uInt32 nFormat)
get format in office language
NF_DATETIME_SYSTEM_SHORT_HHMM
const LanguageTag & GetLanguageTag() const
virtual void SetValue(const double &rVal)
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
const SwDocInfoSubType DI_SUB_FIXED
OUString DoubleToString(const double &rVal, LanguageType eLng) const
void SetNumberingType(SvxNumType nSet)
virtual void SetSubType(sal_uInt16)
virtual OUString GetFormula() const
bool IsClickable() const
Is this field clickable?
virtual double GetValue() const
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)