diff options
author | Eike Rathke <erack@redhat.com> | 2023-04-01 17:19:12 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2023-04-02 11:29:05 +0200 |
commit | 8c8457526a11fd03ed63a86ecdeeb270d5551049 (patch) | |
tree | abf6f048ac41810b31a7129cf22d2eb98c811e03 /sw | |
parent | ba6d84b854e1abd3e913423dbcfaf192f7ade7f2 (diff) |
Related: tdf#154218 Actually use the top format selected
Choosing a format of Additional Formats replaces the listbox
content with the format's category so the assumption that Text
would be the first entry does not hold. For such format still Text
was assumed and the input used as literal string, which defeated
the actual value formatting capabilities and a possible formula
interpretation for SwUserFieldType.
Change-Id: I199575469672a9f8bada2d2edde5036766977501
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149910
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/fldui/fldvar.cxx | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx index e0db9b458294..bf2456ee8c41 100644 --- a/sw/source/ui/fldui/fldvar.cxx +++ b/sw/source/ui/fldui/fldvar.cxx @@ -1006,8 +1006,15 @@ IMPL_LINK(SwFieldVarPage, TBClickHdl, weld::Button&, rBox, void) { if (nNumFormatPos != -1) { - sal_uInt32 nNumberFormat = nNumFormatPos == 0 ? 0 : m_xNumFormatLB->GetFormat(); - if (nNumberFormat) + // The first listbox entry is Text and second is + // Formula and both are SAL_MAX_UINT32 :-/ but only if + // not another yet unlisted of Additional Formats was + // selected that may claim the top position :-/ + sal_uInt32 nNumberFormat = m_xNumFormatLB->GetFormat(); + const bool bText = (nNumFormatPos == 0 && nNumberFormat == SAL_MAX_UINT32); + if (bText) + nNumberFormat = 0; + if (nNumberFormat && nNumberFormat != SAL_MAX_UINT32) { // Switch language to office-language because Kalkulator expects // String in office format and it should be fed into dialog like // that @@ -1015,7 +1022,7 @@ IMPL_LINK(SwFieldVarPage, TBClickHdl, weld::Button&, rBox, void) } static_cast<SwUserFieldType*>(pType)->SetContent(m_xValueED->get_text(), nNumberFormat); static_cast<SwUserFieldType*>(pType)->SetType( - nNumFormatPos == 0 ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR ); + bText ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR ); } } else @@ -1049,8 +1056,16 @@ IMPL_LINK(SwFieldVarPage, TBClickHdl, weld::Button&, rBox, void) if (nNumFormatPos != -1) { - aType.SetType(nNumFormatPos == 0 ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR); - aType.SetContent( sValue, nNumFormatPos == 0 ? 0 : m_xNumFormatLB->GetFormat() ); + // The first listbox entry is Text and second is + // Formula and both are SAL_MAX_UINT32 :-/ but only if + // not another yet unlisted of Additional Formats was + // selected that may claim the top position :-/ + sal_uInt32 nNumberFormat = m_xNumFormatLB->GetFormat(); + const bool bText = (nNumFormatPos == 0 && nNumberFormat == SAL_MAX_UINT32); + if (bText) + nNumberFormat = 0; + aType.SetType(bText ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR); + aType.SetContent( sValue, nNumberFormat ); m_xSelectionLB->append_text(sName); m_xSelectionLB->select_text(sName); GetFieldMgr().InsertFieldType( aType ); // Userfld new |