sw/inc/chpfld.hxx | 4 + sw/inc/dbfld.hxx | 6 + sw/inc/docufld.hxx | 38 ++++++++- sw/inc/expfld.hxx | 5 - sw/inc/fldbas.hxx | 20 +---- sw/inc/reffld.hxx | 6 + sw/qa/extras/uiwriter/uiwriter.cxx | 6 - sw/qa/extras/uiwriter/uiwriter7.cxx | 60 +++++++-------- sw/source/core/access/accpara.cxx | 6 - sw/source/core/doc/DocumentFieldsManager.cxx | 14 ++- sw/source/core/fields/chpfld.cxx | 23 +++-- sw/source/core/fields/dbfld.cxx | 12 +-- sw/source/core/fields/docufld.cxx | 101 +++++++++++++------------- sw/source/core/fields/expfld.cxx | 12 +-- sw/source/core/fields/fldbas.cxx | 104 ++++++++++++++++++++++++--- sw/source/core/fields/flddat.cxx | 6 - sw/source/core/fields/flddropdown.cxx | 4 - sw/source/core/fields/reffld.cxx | 9 +- sw/source/core/text/txtfld.cxx | 10 +- sw/source/core/txtnode/atrfld.cxx | 2 sw/source/core/unocore/unofield.cxx | 6 - sw/source/filter/html/htmlfldw.cxx | 27 ++++--- sw/source/filter/ww8/ww8atr.cxx | 24 +++--- sw/source/filter/ww8/ww8par3.cxx | 2 sw/source/filter/ww8/ww8par5.cxx | 4 - sw/source/ui/fldui/flddb.cxx | 12 ++- sw/source/ui/fldui/flddinf.cxx | 4 - sw/source/ui/fldui/flddok.cxx | 14 +-- sw/source/ui/fldui/fldfunc.cxx | 4 - sw/source/ui/fldui/fldref.cxx | 2 sw/source/ui/fldui/fldvar.cxx | 8 +- sw/source/ui/fldui/javaedit.cxx | 2 sw/source/uibase/fldui/fldmgr.cxx | 16 ++-- sw/source/uibase/inc/fldmgr.hxx | 1 sw/source/uibase/shells/textfld.cxx | 2 sw/source/uibase/shells/textsh1.cxx | 3 sw/source/uibase/wrtsh/wrtsh2.cxx | 2 37 files changed, 363 insertions(+), 218 deletions(-)
New commits: commit 71362767a572193bb29d0535a13daf3d010f25c6 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Jul 4 22:45:55 2025 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jul 7 09:11:22 2025 +0200 move m_nFormat field in SwField down to subclasses because it is really different types depending which subclass it belongs to. Here I do not try to apply correct types to all of the fields that are created in the subclasses, only a couple of the obvious ones. Unfortunately, some of the code is just too awkward to fully re-structure, so I add some SwField::GetUntypedFormat() method to allow some code to get/set untyped format values. In the process, fix a large harmless bug in SwJavaEditDialog and SwScriptField where is was confusing the m_nFormat field with the m_bCodeUrl field. Change-Id: Ie055d907b50d07e38c131c14ae195b426b314700 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187431 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/inc/chpfld.hxx b/sw/inc/chpfld.hxx index 3b1768a4e37c..78076cd83cd4 100644 --- a/sw/inc/chpfld.hxx +++ b/sw/inc/chpfld.hxx @@ -61,6 +61,7 @@ class SW_DLLPUBLIC SwChapterField final : public SwField }; State m_State; State m_StateRLHidden; + sal_uInt32 m_nFormat; virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; @@ -68,6 +69,9 @@ class SW_DLLPUBLIC SwChapterField final : public SwField public: SwChapterField(SwChapterFieldType*, sal_uInt32 nFormat = 0); + sal_uInt32 GetFormat() const { return m_nFormat; } + void SetFormat(sal_uInt32 n) { m_nFormat = n; } + // #i53420# void ChangeExpansion( const SwFrame&, const SwContentNode*, diff --git a/sw/inc/dbfld.hxx b/sw/inc/dbfld.hxx index 984058a48572..42e96d29f9b4 100644 --- a/sw/inc/dbfld.hxx +++ b/sw/inc/dbfld.hxx @@ -122,6 +122,7 @@ class SW_DLLPUBLIC SwDBNameInfField : public SwField { SwDBData m_aDBData; sal_uInt16 m_nSubType; + sal_uInt32 m_nFormat; protected: const SwDBData& GetDBData() const {return m_aDBData;} @@ -130,6 +131,9 @@ protected: SwDBNameInfField(SwFieldType* pTyp, SwDBData aDBData, sal_uInt32 nFormat = 0); public: + sal_uInt32 GetFormat() const { return m_nFormat; } + void SetFormat(sal_uInt32 nFormat) { m_nFormat = nFormat; } + /// DBName const SwDBData& GetRealDBData() const { return m_aDBData; } SwDBData& GetRealDBData() { return m_aDBData; } @@ -245,7 +249,7 @@ public: class SwDBNameField final : public SwDBNameInfField { public: - SwDBNameField(SwDBNameFieldType*, const SwDBData& rDBData); + SwDBNameField(SwDBNameFieldType*, const SwDBData& rDBData, sal_uInt32 nFormat = 0); virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index 6502c5962ee0..c2189f0fdfaf 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -155,13 +155,17 @@ class SW_DLLPUBLIC SwPageNumberField final : public SwField // fdo#58074 store page number in SwField, not SwFieldType sal_uInt16 m_nPageNumber; sal_uInt16 m_nMaxPage; + SvxNumType m_nFormat; public: SwPageNumberField(SwPageNumberFieldType*, sal_uInt16 nSub, - sal_uInt32 nFormat, short nOff = 0, + SvxNumType nFormat, short nOff = 0, sal_uInt16 const nPageNumber = 0, sal_uInt16 const nMaxPage = 0); + SvxNumType GetFormat() const { return m_nFormat; } + void SetFormat(SvxNumType n) { m_nFormat = n; } + void ChangeExpansion(sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage); @@ -191,10 +195,14 @@ public: class SwAuthorField final : public SwField { OUString m_aContent; + sal_uInt32 m_nFormat; public: SwAuthorField(SwAuthorFieldType*, sal_uInt32 nFormat); + sal_uInt32 GetFormat() const { return m_nFormat; } + void SetFormat(sal_uInt32 n) { m_nFormat = n; } + virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; @@ -217,10 +225,14 @@ public: class SW_DLLPUBLIC SwFileNameField final : public SwField { OUString m_aContent; + sal_uInt32 m_nFormat; public: SwFileNameField(SwFileNameFieldType*, sal_uInt32 nFormat); + sal_uInt32 GetFormat() const { return m_nFormat; } + void SetFormat(sal_uInt32 n) { m_nFormat = n; } + virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; @@ -242,9 +254,12 @@ public: class SW_DLLPUBLIC SwTemplNameField final : public SwField { + sal_uInt32 m_nFormat; public: SwTemplNameField(SwTemplNameFieldType*, sal_uInt32 nFormat); + sal_uInt32 GetFormat() const { return m_nFormat; } + void SetFormat(sal_uInt32 n) { m_nFormat = n; } virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; @@ -271,10 +286,13 @@ class SW_DLLPUBLIC SwDocStatField final : public SwField { sal_uInt16 m_nSubType; sal_uInt16 m_nVirtPageCount; - + SvxNumType m_nFormat; public: SwDocStatField( SwDocStatFieldType*, - sal_uInt16 nSubType, sal_uInt32 nFormat, sal_uInt16 nVirtPageCount = 0); + sal_uInt16 nSubType, SvxNumType nFormat, sal_uInt16 nVirtPageCount = 0); + + SvxNumType GetFormat() const { return m_nFormat; } + void SetFormat(SvxNumType n) { m_nFormat = n; } void ChangeExpansion( const SwFrame* pFrame, sal_uInt16 nVirtPageCount); @@ -586,10 +604,14 @@ class SwExtUserField final : public SwField { OUString m_aContent; sal_uInt16 m_nType; + sal_uInt32 m_nFormat; public: SwExtUserField(SwExtUserFieldType*, sal_uInt16 nSub, sal_uInt32 nFormat); + sal_uInt32 GetFormat() const { return m_nFormat; } + void SetFormat(sal_uInt32 n) { m_nFormat = n; } + virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; @@ -662,9 +684,13 @@ class SwRefPageGetField final : public SwField { OUString m_sText; OUString m_sTextRLHidden; ///< hidden redlines + SvxNumType m_nFormat; public: - SwRefPageGetField( SwRefPageGetFieldType*, sal_uInt32 nFormat ); + SwRefPageGetField( SwRefPageGetFieldType*, SvxNumType nFormat ); + + SvxNumType GetFormat() const { return m_nFormat; } + void SetFormat(SvxNumType n) { m_nFormat = n; } virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; @@ -694,10 +720,14 @@ class SwJumpEditField final : public SwField { OUString m_sText; OUString m_sHelp; + sal_uInt32 m_nFormat; public: SwJumpEditField( SwJumpEditFieldType*, sal_uInt32 nFormat, OUString sText, OUString sHelp ); + sal_uInt32 GetFormat() const { return m_nFormat; } + void SetFormat(sal_uInt32 n) { m_nFormat = n; } + virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; diff --git a/sw/inc/expfld.hxx b/sw/inc/expfld.hxx index fc5ca2d29fc4..5560b176e93b 100644 --- a/sw/inc/expfld.hxx +++ b/sw/inc/expfld.hxx @@ -163,8 +163,8 @@ public: inline void SetType(sal_uInt16 nTyp); inline sal_uInt16 GetType() const; - void SetSeqFormat(sal_uLong nFormat); - sal_uLong GetSeqFormat() const; + void SetSeqFormat(sal_uInt32 nFormat); + sal_uInt32 GetSeqFormat() const; bool IsDeleted() const { return m_bDeleted; } void SetDeleted( bool b ) { m_bDeleted = b; } @@ -307,7 +307,6 @@ public: OUString aContent, OUString aPrompt, sal_uInt16 nSubType, - sal_uLong nFormat = 0, bool bIsFormField = true ); virtual ~SwInputField() override; diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index 0d682139cf82..857198b57579 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -298,7 +298,6 @@ class SW_DLLPUBLIC SwField private: mutable OUString m_Cache; ///< Cached expansion (for clipboard). SwFieldType* m_pType; - sal_uInt32 m_nFormat; /// this can be either SvxNumType or SwChapterFormat depending on the subtype LanguageType m_nLang; ///< Always change via SetLanguage! bool m_bUseFieldValueCache; /// control the usage of the cached field value bool m_bIsAutomaticLanguage; @@ -309,12 +308,7 @@ private: virtual std::unique_ptr<SwField> Copy() const = 0; protected: - void SetFormat(sal_uInt32 const nSet) { - m_nFormat = nSet; - } - SwField( SwFieldType* pTyp, - sal_uInt32 nFormat = 0, LanguageType nLang = LANGUAGE_SYSTEM, bool m_bUseFieldValueCache = true ); @@ -365,13 +359,11 @@ public: virtual void SetLanguage(LanguageType nLng); /// Query parameters for dialog and for BASIC. - inline sal_uInt32 GetFormat() const; virtual OUString GetPar1() const; virtual OUString GetPar2() const; virtual OUString GetFormula() const; - void ChangeFormat(sal_uInt32 n); virtual void SetPar1(const OUString& rStr); virtual void SetPar2(const OUString& rStr); @@ -395,6 +387,10 @@ public: virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; const OUString & GetTitle() const { return m_aTitle; } void SetTitle(const OUString& rTitle) { m_aTitle = rTitle; } + + /// Helpers for those places still passing untyped format ids around for SwField + sal_uInt32 GetUntypedFormat() const; + void SetUntypedFormat(sal_uInt32); }; inline SwFieldType* SwField::GetTyp() const @@ -402,11 +398,6 @@ inline SwFieldType* SwField::GetTyp() const return m_pType; } -inline sal_uInt32 SwField::GetFormat() const -{ - return m_nFormat; -} - inline LanguageType SwField::GetLanguage() const { return m_nLang; @@ -449,6 +440,7 @@ class SW_DLLPUBLIC SwValueField : public SwField { private: double m_fValue; + sal_uInt32 m_nFormat; protected: SwValueField( SwValueFieldType* pFieldType, sal_uInt32 nFormat, LanguageType nLang = LANGUAGE_SYSTEM, const double fVal = 0.0 ); @@ -457,6 +449,8 @@ protected: public: virtual ~SwValueField() override; + sal_uInt32 GetFormat() const { return m_nFormat; } + void SetFormat(sal_uInt32 nFormat) { m_nFormat = nFormat; } virtual SwFieldType* ChgTyp( SwFieldType* ) override; virtual void SetLanguage(LanguageType nLng) override; diff --git a/sw/inc/reffld.hxx b/sw/inc/reffld.hxx index 671e572f87be..8b93239bc52c 100644 --- a/sw/inc/reffld.hxx +++ b/sw/inc/reffld.hxx @@ -129,15 +129,19 @@ private: /// reference to either a SwTextFootnote::m_nSeqNo or a SwSetExpField::mnSeqNo sal_uInt16 m_nSeqNo; sal_uInt16 m_nFlags; + sal_uInt32 m_nFormat; virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; public: SW_DLLPUBLIC SwGetRefField( SwGetRefFieldType*, SwMarkName aSetRef, OUString aReferenceLanguage, - sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uInt16 nFlags, sal_uLong nFormat ); + sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uInt16 nFlags, sal_uInt32 nFormat ); SW_DLLPUBLIC virtual ~SwGetRefField() override; + sal_uInt32 GetFormat() const { return m_nFormat; } + void SetFormat(sal_uInt32 n) { m_nFormat = n; } + virtual OUString GetFieldName() const override; const SwMarkName& GetSetRefName() const { return m_sSetRefName; } diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 59759a5dd173..db4e7b1e38b0 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -1091,7 +1091,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testFdo74981) createSwDoc(); SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); - SwInputField aField(static_cast<SwInputFieldType*>(pWrtShell->GetFieldType(0, SwFieldIds::Input)), u"foo"_ustr, u"bar"_ustr, 0, 0); + SwInputField aField(static_cast<SwInputFieldType*>(pWrtShell->GetFieldType(0, SwFieldIds::Input)), u"foo"_ustr, u"bar"_ustr, 0, false); pWrtShell->InsertField2(aField); { @@ -1123,10 +1123,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf98512) SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); SwInputFieldType *const pType(static_cast<SwInputFieldType*>( pWrtShell->GetFieldType(0, SwFieldIds::Input))); - SwInputField aField1(pType, u"foo"_ustr, u"bar"_ustr, INP_TXT, 0); + SwInputField aField1(pType, u"foo"_ustr, u"bar"_ustr, INP_TXT, false); pWrtShell->InsertField2(aField1); pWrtShell->SttEndDoc(/*bStt=*/true); - SwInputField aField2(pType, u"baz"_ustr, u"quux"_ustr, INP_TXT, 0); + SwInputField aField2(pType, u"baz"_ustr, u"quux"_ustr, INP_TXT, false); pWrtShell->InsertField2(aField2); pWrtShell->SttEndDoc(/*bStt=*/true); pWrtShell->SetMark(); diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx b/sw/qa/extras/uiwriter/uiwriter7.cxx index 3607b32a3576..582110bda831 100644 --- a/sw/qa/extras/uiwriter/uiwriter7.cxx +++ b/sw/qa/extras/uiwriter/uiwriter7.cxx @@ -867,21 +867,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf77342) //reference field 1 pWrtShell->StartOfSection(); SwField* pRef1 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pRef1->GetFormat(); + aFormat = pRef1->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pRef1->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(0)), aAny); //reference field 2 pCursor->Move(fnMoveForward); SwField* pRef2 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pRef2->GetFormat(); + aFormat = pRef2->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pRef2->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(1)), aAny); //reference field 3 pCursor->Move(fnMoveForward); SwField* pRef3 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pRef3->GetFormat(); + aFormat = pRef3->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pRef3->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(2)), aAny); @@ -893,21 +893,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf77342) pWrtShell->StartOfSection(); //old reference field 1 SwField* pOldRef11 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef11->GetFormat(); + aFormat = pOldRef11->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef11->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(0)), aAny); //old reference field 2 pCursor->Move(fnMoveForward); SwField* pOldRef12 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef12->GetFormat(); + aFormat = pOldRef12->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef12->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(1)), aAny); //old reference field 3 pCursor->Move(fnMoveForward); SwField* pOldRef13 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef13->GetFormat(); + aFormat = pOldRef13->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef13->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(2)), aAny); @@ -941,14 +941,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf77342) //new reference field 1 pCursor->Move(fnMoveForward); SwField* pNewRef11 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pNewRef11->GetFormat(); + aFormat = pNewRef11->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pNewRef11->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(1)), aAny); //new reference field 2 pCursor->Move(fnMoveForward); SwField* pNewRef12 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pNewRef12->GetFormat(); + aFormat = pNewRef12->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pNewRef12->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(3)), aAny); @@ -969,14 +969,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf77342) pWrtShell->StartOfSection(); //new reference field 1 SwField* pNewRef21 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pNewRef21->GetFormat(); + aFormat = pNewRef21->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pNewRef21->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(1)), aAny); //new reference field 2 pCursor->Move(fnMoveForward); SwField* pNewRef22 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pNewRef22->GetFormat(); + aFormat = pNewRef22->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pNewRef22->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(4)), aAny); @@ -992,21 +992,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf77342) //old reference field 1 pCursor->Move(fnMoveForward); SwField* pOldRef21 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef21->GetFormat(); + aFormat = pOldRef21->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef21->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(0)), aAny); //old reference field 2 pCursor->Move(fnMoveForward); SwField* pOldRef22 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef22->GetFormat(); + aFormat = pOldRef22->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef22->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(1)), aAny); //old reference field 3 pCursor->Move(fnMoveForward); SwField* pOldRef23 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef23->GetFormat(); + aFormat = pOldRef23->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef23->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(2)), aAny); @@ -1040,14 +1040,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf77342) //old reference field 4 pCursor->Move(fnMoveForward); SwField* pOldRef24 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef24->GetFormat(); + aFormat = pOldRef24->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef24->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(1)), aAny); //old reference field 5 pCursor->Move(fnMoveForward); SwField* pOldRef25 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef25->GetFormat(); + aFormat = pOldRef25->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef25->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(3)), aAny); @@ -1139,21 +1139,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf63553) //reference field 1 pWrtShell->StartOfSection(); SwField* pRef1 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pRef1->GetFormat(); + aFormat = pRef1->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pRef1->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(0)), aAny); //reference field 2 pCursor->Move(fnMoveForward); SwField* pRef2 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pRef2->GetFormat(); + aFormat = pRef2->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pRef2->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(1)), aAny); //reference field 3 pCursor->Move(fnMoveForward); SwField* pRef3 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pRef3->GetFormat(); + aFormat = pRef3->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pRef3->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(2)), aAny); @@ -1184,21 +1184,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf63553) //now we have ref1-ref2-ref3-seq1-seq2-seq3-nref1-nref2-nseq1-nseq2 //old reference field 1 SwField* pOldRef11 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef11->GetFormat(); + aFormat = pOldRef11->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef11->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(0)), aAny); //old reference field 2 pCursor->Move(fnMoveForward); SwField* pOldRef12 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef12->GetFormat(); + aFormat = pOldRef12->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef12->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(1)), aAny); //old reference field 3 pCursor->Move(fnMoveForward); SwField* pOldRef13 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef13->GetFormat(); + aFormat = pOldRef13->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef13->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(2)), aAny); @@ -1223,14 +1223,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf63553) //new reference field 1 pCursor->Move(fnMoveForward); SwField* pNewRef11 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pNewRef11->GetFormat(); + aFormat = pNewRef11->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pNewRef11->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(4)), aAny); //new reference field 2 pCursor->Move(fnMoveForward); SwField* pNewRef12 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pNewRef12->GetFormat(); + aFormat = pNewRef12->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pNewRef12->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(2)), aAny); @@ -1255,14 +1255,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf63553) //now we have [nnref1-nnref2-nnseq1-nnseq2]-ref1-[ref2-ref3-seq1-seq2]-seq3-[nref1-nref2-nseq1-nseq2] //new reference field 1 SwField* pNewRef21 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pNewRef21->GetFormat(); + aFormat = pNewRef21->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pNewRef21->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(6)), aAny); //new reference field 2 pCursor->Move(fnMoveForward); SwField* pNewRef22 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pNewRef22->GetFormat(); + aFormat = pNewRef22->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pNewRef22->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(2)), aAny); @@ -1281,21 +1281,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf63553) //old reference field 1 pCursor->Move(fnMoveForward); SwField* pOldRef21 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef21->GetFormat(); + aFormat = pOldRef21->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef21->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(0)), aAny); //old reference field 2 pCursor->Move(fnMoveForward); SwField* pOldRef22 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef22->GetFormat(); + aFormat = pOldRef22->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef22->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(1)), aAny); //old reference field 3 pCursor->Move(fnMoveForward); SwField* pOldRef23 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef23->GetFormat(); + aFormat = pOldRef23->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef23->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(2)), aAny); @@ -1320,14 +1320,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf63553) //old reference field 4 pCursor->Move(fnMoveForward); SwField* pOldRef24 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef24->GetFormat(); + aFormat = pOldRef24->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef24->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(4)), aAny); //old reference field 5 pCursor->Move(fnMoveForward); SwField* pOldRef25 = SwCursorShell::GetFieldAtCursor(pCursor, true); - aFormat = pOldRef25->GetFormat(); + aFormat = pOldRef25->GetUntypedFormat(); CPPUNIT_ASSERT_EQUAL(sal_uInt16(REF_CONTENT), aFormat); pOldRef25->QueryValue(aAny, sal_uInt16(FIELD_PROP_SHORT1)); CPPUNIT_ASSERT_EQUAL(uno::Any(sal_uInt16(2)), aAny); diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 1947eea31fe0..5a2378110b64 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -1061,7 +1061,7 @@ OUString SwAccessibleParagraph::GetFieldTypeNameAtIndex(sal_Int32 nIndex) // <pField->GetFormat() >= 0> is always true as <pField->GetFormat()> is unsigned // if (pField->GetFormat() >= 0) { - sEntry = aMgr.GetFormatStr( pField->GetTypeId(), pField->GetFormat() ); + sEntry = aMgr.GetFormatStr( *pField ); if (sEntry.getLength() > 0) { strTypeName += "-" + sEntry; @@ -1074,7 +1074,7 @@ OUString SwAccessibleParagraph::GetFieldTypeNameAtIndex(sal_Int32 nIndex) break; case SwFieldIds::JumpEdit: { - const sal_uInt32 nFormat= pField->GetFormat(); + const sal_uInt32 nFormat = static_cast<const SwJumpEditField*>(pField)->GetFormat(); const sal_uInt16 nSize = aMgr.GetFormatCount(pField->GetTypeId(), false); if (nFormat < nSize) { @@ -1116,7 +1116,7 @@ OUString SwAccessibleParagraph::GetFieldTypeNameAtIndex(sal_Int32 nIndex) break; case SwFieldIds::Author: { - strTypeName += "-" + aMgr.GetFormatStr(pField->GetTypeId(), pField->GetFormat() & 0xff); + strTypeName += "-" + aMgr.GetFormatStr(pField->GetTypeId(), static_cast<const SwAuthorField*>(pField)->GetFormat() & 0xff); } break; default: break; diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index a6bc65851b38..e2c2abefc2a0 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -1450,14 +1450,16 @@ void DocumentFieldsManager::SetFixFields( const DateTime* pNewDateTime ) break; case SwFieldIds::Filename: - if( static_cast<SwFileNameField*>(pFormatField->GetField())->IsFixed() ) { - bChgd = true; SwFileNameField* pFileNameField = - static_cast<SwFileNameField*>(pFormatField->GetField()); - pFileNameField->SetExpansion( static_cast<SwFileNameFieldType*>( - pFileNameField->GetTyp())->Expand( - pFileNameField->GetFormat() ) ); + static_cast<SwFileNameField*>(pFormatField->GetField()); + if( pFileNameField->IsFixed() ) + { + bChgd = true; + pFileNameField->SetExpansion( static_cast<SwFileNameFieldType*>( + pFileNameField->GetTyp())->Expand( + pFileNameField->GetFormat() ) ); + } } break; default: break; diff --git a/sw/source/core/fields/chpfld.cxx b/sw/source/core/fields/chpfld.cxx index a56a779e8928..47828a8acee3 100644 --- a/sw/source/core/fields/chpfld.cxx +++ b/sw/source/core/fields/chpfld.cxx @@ -72,7 +72,8 @@ std::unique_ptr<SwFieldType> SwChapterFieldType::Copy() const // chapter field SwChapterField::SwChapterField(SwChapterFieldType* pTyp, sal_uInt32 nFormat) - : SwField(pTyp, nFormat) + : SwField(pTyp), + m_nFormat(nFormat) { } @@ -286,16 +287,20 @@ bool SwChapterField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) rAny >>= nVal; switch( nVal ) { - case text::ChapterFormat::NAME: SetFormat(CF_TITLE); break; - case text::ChapterFormat::NUMBER: SetFormat(CF_NUMBER); break; + case text::ChapterFormat::NAME: + m_nFormat = CF_TITLE; + break; + case text::ChapterFormat::NUMBER: + m_nFormat = CF_NUMBER; + break; case text::ChapterFormat::NO_PREFIX_SUFFIX: - SetFormat(CF_NUM_NOPREPST_TITLE); - break; + m_nFormat = CF_NUM_NOPREPST_TITLE; + break; case text::ChapterFormat::DIGIT: - SetFormat(CF_NUMBER_NOPREPST); - break; - - default: SetFormat(CF_NUM_TITLE); + m_nFormat = CF_NUMBER_NOPREPST; + break; + default: + m_nFormat = CF_NUM_TITLE; } } break; diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx index de9ca7208dad..5bb47e2a7d89 100644 --- a/sw/source/core/fields/dbfld.cxx +++ b/sw/source/core/fields/dbfld.cxx @@ -441,9 +441,10 @@ bool SwDBField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) // base class for all further database fields SwDBNameInfField::SwDBNameInfField(SwFieldType* pTyp, SwDBData aDBData, sal_uInt32 nFormat) : - SwField(pTyp, nFormat), + SwField(pTyp), m_aDBData(std::move(aDBData)), - m_nSubType(0) + m_nSubType(0), + m_nFormat(nFormat) { } @@ -752,8 +753,8 @@ std::unique_ptr<SwFieldType> SwDBNameFieldType::Copy() const // name of the connected database -SwDBNameField::SwDBNameField(SwDBNameFieldType* pTyp, const SwDBData& rDBData) - : SwDBNameInfField(pTyp, rDBData, 0) +SwDBNameField::SwDBNameField(SwDBNameFieldType* pTyp, const SwDBData& rDBData, sal_uInt32 nFormat) + : SwDBNameInfField(pTyp, rDBData, nFormat) {} OUString SwDBNameField::ExpandImpl(SwRootFrame const*const) const @@ -765,8 +766,7 @@ OUString SwDBNameField::ExpandImpl(SwRootFrame const*const) const std::unique_ptr<SwField> SwDBNameField::Copy() const { - std::unique_ptr<SwDBNameField> pTmp(new SwDBNameField(static_cast<SwDBNameFieldType*>(GetTyp()), GetDBData())); - pTmp->ChangeFormat(GetFormat()); + std::unique_ptr<SwDBNameField> pTmp(new SwDBNameField(static_cast<SwDBNameFieldType*>(GetTyp()), GetDBData(), GetFormat())); pTmp->SetLanguage(GetLanguage()); pTmp->SetSubType(GetSubType()); return std::unique_ptr<SwField>(pTmp.release()); diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index b1b32f188ebe..10e4f7d6ee1a 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -175,11 +175,12 @@ void SwPageNumberFieldType::ChangeExpansion( SwDoc* pDoc, } SwPageNumberField::SwPageNumberField(SwPageNumberFieldType* pTyp, - sal_uInt16 nSub, sal_uInt32 nFormat, short nOff, + sal_uInt16 nSub, SvxNumType nFormat, short nOff, sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage) - : SwField(pTyp, nFormat), m_nSubType(nSub), m_nOffset(nOff) + : SwField(pTyp), m_nSubType(nSub), m_nOffset(nOff) , m_nPageNumber(nPageNumber) , m_nMaxPage(nMaxPage) + , m_nFormat(nFormat) { } @@ -197,22 +198,22 @@ OUString SwPageNumberField::ExpandImpl(SwRootFrame const*const) const if( PG_NEXT == m_nSubType && 1 != m_nOffset ) { - sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), 1, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage()); + sRet = pFieldType->Expand(GetFormat(), 1, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage()); if (!sRet.isEmpty()) { - sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage()); + sRet = pFieldType->Expand(GetFormat(), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage()); } } else if( PG_PREV == m_nSubType && -1 != m_nOffset ) { - sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), -1, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage()); + sRet = pFieldType->Expand(GetFormat(), -1, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage()); if (!sRet.isEmpty()) { - sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage()); + sRet = pFieldType->Expand(GetFormat(), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage()); } } else - sRet = pFieldType->Expand(static_cast<SvxNumType>(GetFormat()), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage()); + sRet = pFieldType->Expand(GetFormat(), m_nOffset, m_nPageNumber, m_nMaxPage, m_sUserStr, GetLanguage()); return sRet; } @@ -285,7 +286,7 @@ bool SwPageNumberField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) // TODO: where do the defines come from? if(nSet <= SVX_NUM_PAGEDESC ) - SetFormat(nSet); + m_nFormat = static_cast<SvxNumType>(nSet); break; case FIELD_PROP_USHORT1: rAny >>= nSet; @@ -347,7 +348,8 @@ std::unique_ptr<SwFieldType> SwAuthorFieldType::Copy() const } SwAuthorField::SwAuthorField(SwAuthorFieldType* pTyp, sal_uInt32 nFormat) - : SwField(pTyp, nFormat) + : SwField(pTyp), + m_nFormat(nFormat) { m_aContent = SwAuthorFieldType::Expand(GetFormat()); } @@ -399,14 +401,14 @@ bool SwAuthorField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) switch( nWhichId ) { case FIELD_PROP_BOOL1: - SetFormat( *o3tl::doAccess<bool>(rAny) ? AF_NAME : AF_SHORTCUT ); + m_nFormat = *o3tl::doAccess<bool>(rAny) ? AF_NAME : AF_SHORTCUT; break; case FIELD_PROP_BOOL2: if( *o3tl::doAccess<bool>(rAny) ) - SetFormat( GetFormat() | AF_FIXED); + m_nFormat |= AF_FIXED; else - SetFormat( GetFormat() & ~AF_FIXED); + m_nFormat &= ~AF_FIXED; break; case FIELD_PROP_PAR1: @@ -486,7 +488,8 @@ std::unique_ptr<SwFieldType> SwFileNameFieldType::Copy() const } SwFileNameField::SwFileNameField(SwFileNameFieldType* pTyp, sal_uInt32 nFormat) - : SwField(pTyp, nFormat) + : SwField(pTyp), + m_nFormat(nFormat) { m_aContent = static_cast<SwFileNameFieldType*>(GetTyp())->Expand(GetFormat()); } @@ -573,15 +576,15 @@ bool SwFileNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) } if(bFixed) nType |= FF_FIXED; - SetFormat(nType); + m_nFormat = nType; } break; case FIELD_PROP_BOOL2: if( *o3tl::doAccess<bool>(rAny) ) - SetFormat( GetFormat() | FF_FIXED); + m_nFormat |= FF_FIXED; else - SetFormat( GetFormat() & ~FF_FIXED); + m_nFormat &= ~FF_FIXED; break; case FIELD_PROP_PAR3: @@ -656,7 +659,7 @@ std::unique_ptr<SwFieldType> SwTemplNameFieldType::Copy() const } SwTemplNameField::SwTemplNameField(SwTemplNameFieldType* pTyp, sal_uInt32 nFormat) - : SwField(pTyp, nFormat) + : SwField(pTyp), m_nFormat(nFormat) {} OUString SwTemplNameField::ExpandImpl(SwRootFrame const*const) const @@ -710,21 +713,21 @@ bool SwTemplNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) switch( nType ) { case text::FilenameDisplayFormat::PATH: - SetFormat(FF_PATH); + m_nFormat = FF_PATH; break; case text::FilenameDisplayFormat::NAME: - SetFormat(FF_NAME_NOEXT); + m_nFormat = FF_NAME_NOEXT; break; case text::FilenameDisplayFormat::NAME_AND_EXT: - SetFormat(FF_NAME); + m_nFormat = FF_NAME; break; case text::TemplateDisplayFormat::AREA : - SetFormat(FF_UI_RANGE); + m_nFormat = FF_UI_RANGE; break; case text::TemplateDisplayFormat::TITLE : - SetFormat(FF_UI_NAME); + m_nFormat = FF_UI_NAME; break; - default: SetFormat(FF_PATHNAME); + default: m_nFormat = FF_PATHNAME; } } break; @@ -814,23 +817,24 @@ void SwDocStatFieldType::UpdateRangeFields(SwRootFrame const*const pLayout) * @param nFormat */ SwDocStatField::SwDocStatField(SwDocStatFieldType* pTyp, sal_uInt16 nSub, - sal_uInt32 nFormat, sal_uInt16 nVirtPageCount) - : SwField(pTyp, nFormat), + SvxNumType nFormat, sal_uInt16 nVirtPageCount) + : SwField(pTyp), m_nSubType(nSub), - m_nVirtPageCount(nVirtPageCount) + m_nVirtPageCount(nVirtPageCount), + m_nFormat(nFormat) { } OUString SwDocStatField::ExpandImpl(SwRootFrame const*const) const { return static_cast<SwDocStatFieldType*>(GetTyp()) - ->Expand(m_nSubType, static_cast<SvxNumType>(GetFormat()), m_nVirtPageCount); + ->Expand(m_nSubType, m_nFormat, m_nVirtPageCount); } std::unique_ptr<SwField> SwDocStatField::Copy() const { return std::make_unique<SwDocStatField>( - static_cast<SwDocStatFieldType*>(GetTyp()), m_nSubType, GetFormat(), m_nVirtPageCount ); + static_cast<SwDocStatFieldType*>(GetTyp()), m_nSubType, m_nFormat, m_nVirtPageCount ); } sal_uInt16 SwDocStatField::GetSubType() const @@ -845,7 +849,7 @@ void SwDocStatField::SetSubType(sal_uInt16 nSub) void SwDocStatField::ChangeExpansion(const SwFrame* pFrame, sal_uInt16 nVirtPageCount) { - if( DS_PAGE == m_nSubType && SVX_NUM_PAGEDESC == GetFormat() ) + if( DS_PAGE == m_nSubType && SVX_NUM_PAGEDESC == m_nFormat ) static_cast<SwDocStatFieldType*>(GetTyp())->SetNumFormat( pFrame->FindPageFrame()->GetPageDesc()->GetNumType().GetNumberingType() ); else if (nVirtPageCount && DS_PAGE_RANGE == m_nSubType) @@ -857,7 +861,7 @@ bool SwDocStatField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch ( nWhichId ) { case FIELD_PROP_USHORT2: - rAny <<= static_cast<sal_Int16>(GetFormat()); + rAny <<= static_cast<sal_Int16>(m_nFormat); break; case FIELD_PROP_USHORT1: rAny <<= static_cast<sal_Int32>(m_nVirtPageCount); @@ -882,7 +886,7 @@ bool SwDocStatField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) nSet != SVX_NUM_CHAR_SPECIAL && nSet != SVX_NUM_BITMAP) { - SetFormat(nSet); + m_nFormat = static_cast<SvxNumType>(nSet); bRet = true; } } @@ -1467,7 +1471,6 @@ std::unique_ptr<SwField> SwHiddenTextField::Copy() const pField->m_bIsHidden = m_bIsHidden; pField->m_bValid = m_bValid; pField->m_aContent = m_aContent; - pField->SetFormat(GetFormat()); pField->m_nSubType = m_nSubType; return std::unique_ptr<SwField>(pField.release()); } @@ -2141,7 +2144,7 @@ OUString SwExtUserFieldType::Expand(sal_uInt16 nSub ) // extended user information field SwExtUserField::SwExtUserField(SwExtUserFieldType* pTyp, sal_uInt16 nSubTyp, sal_uInt32 nFormat) : - SwField(pTyp, nFormat), m_nType(nSubTyp) + SwField(pTyp), m_nType(nSubTyp), m_nFormat(nFormat) { m_aContent = SwExtUserFieldType::Expand(m_nType); } @@ -2212,9 +2215,9 @@ bool SwExtUserField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_BOOL1: if( *o3tl::doAccess<bool>(rAny) ) - SetFormat(GetFormat() | AF_FIXED); + m_nFormat |= AF_FIXED; else - SetFormat(GetFormat() & ~AF_FIXED); + m_nFormat &= ~AF_FIXED; break; default: assert(false); @@ -2458,11 +2461,11 @@ void SwRefPageGetFieldType::UpdateField( SwTextField const * pTextField, pRefFrame->FindPageFrame()->GetPhyPageNum() + 1; } - SvxNumType nTmpFormat = SVX_NUM_PAGEDESC == static_cast<SvxNumType>(pGetField->GetFormat()) + SvxNumType nTmpFormat = SVX_NUM_PAGEDESC == pGetField->GetFormat() ? ( !pPgFrame ? SVX_NUM_ARABIC : pPgFrame->GetPageDesc()->GetNumType().GetNumberingType() ) - : static_cast<SvxNumType>(pGetField->GetFormat()); + : pGetField->GetFormat(); const short nPageNum = std::max<short>(0, pSetField->GetOffset() + nDiff); pGetField->SetText(FormatNumber(nPageNum, nTmpFormat), pLayout); } @@ -2475,8 +2478,8 @@ void SwRefPageGetFieldType::UpdateField( SwTextField const * pTextField, // queries for relative page numbering SwRefPageGetField::SwRefPageGetField( SwRefPageGetFieldType* pTyp, - sal_uInt32 nFormat ) - : SwField( pTyp, nFormat ) + SvxNumType nFormat ) + : SwField( pTyp ), m_nFormat(nFormat) { } @@ -2562,7 +2565,7 @@ void SwRefPageGetField::ChangeExpansion(const SwFrame& rFrame, SwRefPageGetField* pGetField = const_cast<SwRefPageGetField*>(static_cast<const SwRefPageGetField*>(pField->GetFormatField().GetField())); SvxNumType nTmpFormat = SVX_NUM_PAGEDESC == pGetField->GetFormat() ? pPgFrame->GetPageDesc()->GetNumType().GetNumberingType() - : static_cast<SvxNumType>(pGetField->GetFormat()); + : pGetField->GetFormat(); const short nPageNum = std::max<short>(0, pSetField->GetOffset() + nDiff); pGetField->SetText(FormatNumber(nPageNum, nTmpFormat), &rLayout); } @@ -2592,7 +2595,7 @@ bool SwRefPageGetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) sal_Int16 nSet = 0; rAny >>= nSet; if(nSet <= SVX_NUM_PAGEDESC ) - SetFormat(nSet); + m_nFormat = static_cast<SvxNumType>(nSet); } break; case FIELD_PROP_PAR1: @@ -2624,9 +2627,9 @@ SwCharFormat* SwJumpEditFieldType::GetCharFormat() return pFormat; } -SwJumpEditField::SwJumpEditField( SwJumpEditFieldType* pTyp, sal_uInt32 nForm, +SwJumpEditField::SwJumpEditField( SwJumpEditFieldType* pTyp, sal_uInt32 nFormat, OUString aText, OUString aHelp ) - : SwField( pTyp, nForm ), m_sText( std::move(aText) ), m_sHelp( std::move(aHelp) ) + : SwField( pTyp), m_sText( std::move(aText) ), m_sHelp( std::move(aHelp) ), m_nFormat(nFormat) { } @@ -2709,11 +2712,11 @@ bool SwJumpEditField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) rAny >>= nSet; switch( nSet ) { - case text::PlaceholderType::TEXT : SetFormat(JE_FMT_TEXT); break; - case text::PlaceholderType::TABLE : SetFormat(JE_FMT_TABLE); break; - case text::PlaceholderType::TEXTFRAME: SetFormat(JE_FMT_FRAME); break; - case text::PlaceholderType::GRAPHIC : SetFormat(JE_FMT_GRAPHIC); break; - case text::PlaceholderType::OBJECT : SetFormat(JE_FMT_OLE); break; + case text::PlaceholderType::TEXT : m_nFormat = JE_FMT_TEXT; break; + case text::PlaceholderType::TABLE : m_nFormat = JE_FMT_TABLE; break; + case text::PlaceholderType::TEXTFRAME: m_nFormat = JE_FMT_FRAME; break; + case text::PlaceholderType::GRAPHIC : m_nFormat = JE_FMT_GRAPHIC; break; + case text::PlaceholderType::OBJECT : m_nFormat = JE_FMT_OLE; break; } } break; @@ -2745,7 +2748,7 @@ std::unique_ptr<SwFieldType> SwCombinedCharFieldType::Copy() const SwCombinedCharField::SwCombinedCharField( SwCombinedCharFieldType* pFTyp, const OUString& rChars ) - : SwField( pFTyp, 0 ), + : SwField( pFTyp ), m_sCharacters( rChars.copy( 0, std::min<sal_Int32>(rChars.getLength(), MAX_COMBINED_CHARACTERS) )) { } diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 12abe6e4114e..d4fa510b01c0 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -549,22 +549,22 @@ void SwSetExpFieldType::SwClientNotify(const SwModify&, const SfxHint&) // do not expand further } -void SwSetExpFieldType::SetSeqFormat(sal_uLong nFormat) +void SwSetExpFieldType::SetSeqFormat(sal_uInt32 nFormat) { std::vector<SwFormatField*> vFields; GatherFields(vFields, false); for(auto pFormatField: vFields) - pFormatField->GetField()->ChangeFormat(nFormat); + pFormatField->GetField()->SetUntypedFormat(nFormat); } -sal_uLong SwSetExpFieldType::GetSeqFormat() const +sal_uInt32 SwSetExpFieldType::GetSeqFormat() const { if( !HasWriterListeners() ) return SVX_NUM_ARABIC; std::vector<SwFormatField*> vFields; GatherFields(vFields, false); - return vFields.front()->GetField()->GetFormat(); + return vFields.front()->GetField()->GetUntypedFormat(); } void SwSetExpFieldType::SetSeqRefNo( SwSetExpField& rField ) @@ -1223,9 +1223,8 @@ SwInputField::SwInputField( SwInputFieldType* pFieldType, OUString aContent, OUString aPrompt, sal_uInt16 nSub, - sal_uLong nFormat, bool bIsFormField ) - : SwField( pFieldType, nFormat, LANGUAGE_SYSTEM, false ) + : SwField( pFieldType, LANGUAGE_SYSTEM, false ) , maContent(std::move(aContent)) , maPText(std::move(aPrompt)) , mnSubType(nSub) @@ -1304,7 +1303,6 @@ std::unique_ptr<SwField> SwInputField::Copy() const getContent(), maPText, GetSubType(), - GetFormat(), mbIsFormField )); pField->SetHelp( maHelp ); diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index e45a268a5005..cf63b5c5c90c 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -44,6 +44,8 @@ #include <viewsh.hxx> #include <hints.hxx> #include <unofield.hxx> +#include <dbfld.hxx> +#include <chpfld.hxx> using namespace ::com::sun::star; using namespace nsSwDocInfoSubType; @@ -243,11 +245,9 @@ void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const // A field (multiple can exist) references a field type (can exists only once) SwField::SwField( SwFieldType* pType, - sal_uInt32 nFormat, LanguageType nLang, bool bUseFieldValueCache) : m_pType( pType ) - , m_nFormat( nFormat ) , m_nLang( nLang ) , m_bUseFieldValueCache( bUseFieldValueCache ) , m_bIsAutomaticLanguage( true ) @@ -323,6 +323,91 @@ OUString SwField::GetFieldName() const return sRet; } +/// Helpers for those places still passing untyped format ids around for SwField +sal_uInt32 SwField::GetUntypedFormat() const +{ + switch (m_pType->Which()) + { + case SwFieldIds::PageNumber: + return static_cast<const SwPageNumberField*>(this)->GetFormat(); + case SwFieldIds::JumpEdit: + return static_cast<const SwJumpEditField*>(this)->GetFormat(); + case SwFieldIds::DocStat: + return static_cast<const SwDocStatField*>(this)->GetFormat(); + case SwFieldIds::TemplateName: + return static_cast<const SwTemplNameField*>(this)->GetFormat(); + case SwFieldIds::Chapter: + return static_cast<const SwChapterField*>(this)->GetFormat(); + case SwFieldIds::Filename: + return static_cast<const SwFileNameField*>(this)->GetFormat(); + case SwFieldIds::Author: + return static_cast<const SwAuthorField*>(this)->GetFormat(); + case SwFieldIds::ExtUser: + return static_cast<const SwExtUserField*>(this)->GetFormat(); + case SwFieldIds::DbNextSet: + case SwFieldIds::DbNumSet: + case SwFieldIds::DatabaseName: + case SwFieldIds::DbSetNumber: + return static_cast<const SwDBNameInfField*>(this)->GetFormat(); + case SwFieldIds::RefPageGet: + return static_cast<const SwRefPageGetField*>(this)->GetFormat(); + case SwFieldIds::GetRef: + return static_cast<const SwGetRefField*>(this)->GetFormat(); + default: break; + } + if (auto p = dynamic_cast<const SwValueField*>(this)) + return p->GetFormat(); + return 0; +} + +/// Helpers for those places still passing untyped format ids around for SwField +void SwField::SetUntypedFormat(sal_uInt32 n) +{ + switch (m_pType->Which()) + { + case SwFieldIds::PageNumber: + static_cast<SwPageNumberField*>(this)->SetFormat(static_cast<SvxNumType>(n)); + return; + case SwFieldIds::JumpEdit: + static_cast<SwJumpEditField*>(this)->SetFormat(n); + return; + case SwFieldIds::DocStat: + static_cast<SwDocStatField*>(this)->SetFormat(static_cast<SvxNumType>(n)); + return; + case SwFieldIds::TemplateName: + static_cast<SwTemplNameField*>(this)->SetFormat(n); + return; + case SwFieldIds::Chapter: + static_cast<SwChapterField*>(this)->SetFormat(n); + return; + case SwFieldIds::Filename: + static_cast<SwFileNameField*>(this)->SetFormat(n); + return; + case SwFieldIds::Author: + static_cast<SwAuthorField*>(this)->SetFormat(n); + return; + case SwFieldIds::ExtUser: + static_cast<SwExtUserField*>(this)->SetFormat(n); + return; + case SwFieldIds::DbNextSet: + case SwFieldIds::DbNumSet: + case SwFieldIds::DatabaseName: + case SwFieldIds::DbSetNumber: + static_cast<SwDBNameInfField*>(this)->SetFormat(n); + return; + case SwFieldIds::RefPageGet: + static_cast<SwRefPageGetField*>(this)->SetFormat(static_cast<SvxNumType>(n)); + return; + case SwFieldIds::GetRef: + static_cast<SwGetRefField*>(this)->SetFormat(n); + return; + default: break; + } + if (auto p2 = dynamic_cast<SwValueField*>(this)) + p2->SetFormat(n); +} + + OUString SwField::GetPar1() const { return OUString(); @@ -443,11 +528,6 @@ void SwField::SetLanguage(LanguageType const nLang) m_nLang = nLang; } -void SwField::ChangeFormat(sal_uInt32 const nFormat) -{ - m_nFormat = nFormat; -} - bool SwField::IsFixed() const { bool bRet = false; @@ -463,12 +543,14 @@ bool SwField::IsFixed() const break; case SwFieldIds::ExtUser: + bRet = 0 != (static_cast<const SwExtUserField*>(this)->GetFormat() & AF_FIXED); + break; case SwFieldIds::Author: - bRet = 0 != (GetFormat() & AF_FIXED); + bRet = 0 != (static_cast<const SwAuthorField*>(this)->GetFormat() & AF_FIXED); break; case SwFieldIds::Filename: - bRet = 0 != (GetFormat() & FF_FIXED); + bRet = 0 != (static_cast<const SwFileNameField*>(this)->GetFormat() & FF_FIXED); break; case SwFieldIds::DocInfo: @@ -663,8 +745,9 @@ OUString SwValueFieldType::GetInputOrDateTime( const OUString& rInput, const dou SwValueField::SwValueField( SwValueFieldType* pFieldType, sal_uInt32 nFormat, LanguageType nLng, const double fVal ) - : SwField(pFieldType, nFormat, nLng) + : SwField(pFieldType, nLng) , m_fValue(fVal) + , m_nFormat(nFormat) { } @@ -920,7 +1003,6 @@ void SwField::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwField")); (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("symbol"), "%s", BAD_CAST(typeid(*this).name())); (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nFormat"), BAD_CAST(OString::number(m_nFormat).getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nLang"), BAD_CAST(OString::number(m_nLang.get()).getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_aTitle"), BAD_CAST(m_aTitle.toUtf8().getStr())); diff --git a/sw/source/core/fields/flddat.cxx b/sw/source/core/fields/flddat.cxx index 264b7538f967..2049125c4ca1 100644 --- a/sw/source/core/fields/flddat.cxx +++ b/sw/source/core/fields/flddat.cxx @@ -50,9 +50,9 @@ SwDateTimeField::SwDateTimeField(SwDateTimeFieldType* pInitType, sal_uInt16 nSub { SvNumberFormatter* pFormatter = GetDoc()->GetNumberFormatter(); if (m_nSubType & DATEFLD) - ChangeFormat(pFormatter->GetFormatIndex(NF_DATE_SYSTEM_SHORT, GetLanguage())); + SetFormat(pFormatter->GetFormatIndex(NF_DATE_SYSTEM_SHORT, GetLanguage())); else - ChangeFormat(pFormatter->GetFormatIndex(NF_TIME_HHMMSS, GetLanguage())); + SetFormat(pFormatter->GetFormatIndex(NF_TIME_HHMMSS, GetLanguage())); } if (IsFixed()) { @@ -212,7 +212,7 @@ bool SwDateTimeField::PutValue( const uno::Any& rVal, sal_uInt16 nWhichId ) break; case FIELD_PROP_FORMAT: rVal >>= nTmp; - ChangeFormat(nTmp); + SetFormat(nTmp); break; case FIELD_PROP_SUBTYPE: rVal >>= nTmp; diff --git a/sw/source/core/fields/flddropdown.cxx b/sw/source/core/fields/flddropdown.cxx index 57106978e10f..dd78f22523e8 100644 --- a/sw/source/core/fields/flddropdown.cxx +++ b/sw/source/core/fields/flddropdown.cxx @@ -45,12 +45,12 @@ std::unique_ptr<SwFieldType> SwDropDownFieldType::Copy() const } SwDropDownField::SwDropDownField(SwFieldType * pTyp) - : SwField(pTyp, 0, LANGUAGE_SYSTEM) + : SwField(pTyp, LANGUAGE_SYSTEM) { } SwDropDownField::SwDropDownField(const SwDropDownField & rSrc) - : SwField(rSrc.GetTyp(), rSrc.GetFormat(), rSrc.GetLanguage()), + : SwField(rSrc.GetTyp(), rSrc.GetLanguage()), m_aValues(rSrc.m_aValues), m_aSelectedItem(rSrc.m_aSelectedItem), m_aName(rSrc.m_aName), m_aHelp(rSrc.m_aHelp), m_aToolTip(rSrc.m_aToolTip) { diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index c7392d889f52..a346b468d2d2 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -352,13 +352,14 @@ static void lcl_formatReferenceLanguage( OUString& rRefText, /// get references SwGetRefField::SwGetRefField( SwGetRefFieldType* pFieldType, SwMarkName aSetRef, OUString aSetReferenceLanguage, sal_uInt16 nSubTyp, - sal_uInt16 nSequenceNo, sal_uInt16 nFlags, sal_uLong nFormat ) - : SwField(pFieldType, nFormat), + sal_uInt16 nSequenceNo, sal_uInt16 nFlags, sal_uInt32 nFormat ) + : SwField(pFieldType), m_sSetRefName(std::move(aSetRef)), m_sSetReferenceLanguage(std::move(aSetReferenceLanguage)), m_nSubType(nSubTyp), m_nSeqNo(nSequenceNo), - m_nFlags(nFlags) + m_nFlags(nFlags), + m_nFormat(nFormat) { } @@ -1015,7 +1016,7 @@ bool SwGetRefField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) case ReferenceFieldPart::NUMBER_FULL_CONTEXT: nPart = REF_NUMBER_FULL_CONTEXT; break; default: return false; } - SetFormat(nPart); + m_nFormat = nPart; } break; case FIELD_PROP_USHORT2: diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index edc3f4b3cfd3..c21b7436e23d 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -134,11 +134,12 @@ SwExpandPortion *SwTextFormatter::NewFieldPortion( SwTextFormatInfo &rInf, sal_uInt16 nVirtNum = m_pFrame->GetVirtPageNum(); sal_uInt16 nNumPages = pTmpRootFrame->GetPageNum(); + auto pPageNumberField = static_cast<SwPageNumberField*>(pField); SvxNumType nNumFormat = SvxNumType(-1); - if (SVX_NUM_PAGEDESC == pField->GetFormat()) + if (SVX_NUM_PAGEDESC == pPageNumberField->GetFormat()) nNumFormat = m_pFrame->FindPageFrame()->GetPageDesc()->GetNumType().GetNumberingType(); - static_cast<SwPageNumberField*>(pField)->ChangeExpansion(nVirtNum, nNumPages); + pPageNumberField->ChangeExpansion(nVirtNum, nNumPages); pPageNr->ChangeExpansion(pSh->GetDoc(), bVirt, nNumFormat != SvxNumType(-1) ? &nNumFormat : nullptr); } @@ -177,16 +178,17 @@ SwExpandPortion *SwTextFormatter::NewFieldPortion( SwTextFormatInfo &rInf, break; case SwFieldIds::JumpEdit: { + auto pJumpEditField = static_cast<SwJumpEditField*>(pField); std::unique_ptr<SwFont> pFont; if (!bName) { pFont = std::make_unique<SwFont>(*m_pFont); pFont->SetDiffFnt( - &static_cast<SwJumpEditField*>(pField)->GetCharFormat()->GetAttrSet(), + &pJumpEditField->GetCharFormat()->GetAttrSet(), &m_pFrame->GetDoc().getIDocumentSettingAccess()); } return new SwJumpFieldPortion(ExpandField(*pField, *this, rInf), pField->GetPar2(), - std::move(pFont), pField->GetFormat()); + std::move(pFont), pJumpEditField->GetFormat()); } case SwFieldIds::GetRef: if (!bName) diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 679cf6d81085..46cd8a6df5af 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -206,7 +206,7 @@ bool SwFormatField::operator==( const SfxPoolItem& rAttr ) const return ( mpField && static_cast<const SwFormatField&>(rAttr).mpField && mpField->GetTyp() == static_cast<const SwFormatField&>(rAttr).mpField->GetTyp() - && mpField->GetFormat() == static_cast<const SwFormatField&>(rAttr).mpField->GetFormat() ) + && mpField->GetUntypedFormat() == static_cast<const SwFormatField&>(rAttr).mpField->GetUntypedFormat() ) || ( !mpField && !static_cast<const SwFormatField&>(rAttr).mpField ); } diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index e9d70d74d236..21da418cb16c 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1637,7 +1637,7 @@ void SAL_CALL SwXTextField::attach( SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::RefPageGet); SwRefPageGetField *const pRGField = new SwRefPageGetField( static_cast<SwRefPageGetFieldType*>(pFieldType), - m_pImpl->m_pProps->nUSHORT1 ); + static_cast<SvxNumType>(m_pImpl->m_pProps->nUSHORT1) ); xField.reset(pRGField); pRGField->SetText(m_pImpl->m_pProps->sPar1, nullptr); } @@ -1647,7 +1647,7 @@ void SAL_CALL SwXTextField::attach( SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::PageNumber); SwPageNumberField *const pPNField = new SwPageNumberField( static_cast<SwPageNumberFieldType*>(pFieldType), PG_RANDOM, - m_pImpl->m_pProps->nFormat, + static_cast<SvxNumType>(m_pImpl->m_pProps->nFormat), m_pImpl->m_pProps->nUSHORT1); xField.reset(pPNField); pPNField->SetUserString(m_pImpl->m_pProps->sPar1); @@ -1888,7 +1888,7 @@ void SAL_CALL SwXTextField::attach( SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocStat); xField.reset(new SwDocStatField( static_cast<SwDocStatFieldType*>(pFieldType), - nSubType, m_pImpl->m_pProps->nUSHORT2, m_pImpl->m_pProps->nUSHORT1)); + nSubType, static_cast<SvxNumType>(m_pImpl->m_pProps->nUSHORT2), m_pImpl->m_pProps->nUSHORT1)); } break; case SwServiceType::FieldTypeBibliography: diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx index 82bb0df74be7..0f55b9eea417 100644 --- a/sw/source/filter/html/htmlfldw.cxx +++ b/sw/source/filter/html/htmlfldw.cxx @@ -72,7 +72,6 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, { const SwFieldType* pFieldTyp = pField->GetTyp(); SwFieldIds nField = pFieldTyp->Which(); - sal_uLong nFormat = pField->GetFormat(); const char *pTypeStr=nullptr, // TYPE *pSubStr=nullptr, // SUBTYPE @@ -83,6 +82,7 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, double dNumValue = 0.0; // SDVAL (Number-Formatter-Value) bool bFixed=false; // SDFIXED OUString aName; // NAME (CUSTOM) + sal_uInt32 nNumFormat = 0; switch( nField ) { @@ -114,7 +114,7 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, case SwFieldIds::Author: pTypeStr = OOO_STRING_SW_HTML_FT_author; - switch( static_cast<SwAuthorFormat>(nFormat) & 0xff) + switch( static_cast<SwAuthorFormat>(static_cast<const SwAuthorField*>(pField)->GetFormat()) & 0xff) { case AF_NAME: pFormatStr = OOO_STRING_SW_HTML_FF_name; break; case AF_SHORTCUT: pFormatStr = OOO_STRING_SW_HTML_FF_shortcut; break; @@ -126,6 +126,7 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, case SwFieldIds::DateTime: pTypeStr = OOO_STRING_SW_HTML_FT_datetime; bNumFormat = true; + nNumFormat = static_cast<const SwDateTimeField*>(pField)->GetFormat(); if( static_cast<const SwDateTimeField*>(pField)->IsFixed() ) { bNumValue = true; @@ -135,6 +136,7 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, case SwFieldIds::PageNumber: { + auto pPageNumberField = static_cast<const SwPageNumberField *>(pField); pTypeStr = OOO_STRING_SW_HTML_FT_page; SwPageNumSubType eSubType = static_cast<SwPageNumSubType>(pField->GetSubType()); switch( eSubType ) @@ -144,11 +146,12 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, case PG_PREV: pSubStr = OOO_STRING_SW_HTML_FS_prev; break; } OSL_ENSURE( pSubStr, "unknown sub type for SwPageNumberField" ); + SvxNumType nFormat = pPageNumberField->GetFormat(); pFormatStr = SwHTMLWriter::GetNumFormat( static_cast< sal_uInt16 >(nFormat) ); - if( static_cast<SvxNumType>(nFormat)==SVX_NUM_CHAR_SPECIAL ) + if( nFormat == SVX_NUM_CHAR_SPECIAL ) { - aValue = static_cast<const SwPageNumberField *>(pField)->GetUserString(); + aValue = pPageNumberField->GetUserString(); } else { @@ -165,6 +168,8 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, break; case SwFieldIds::DocInfo: { + auto pDocInfoField = static_cast<const SwDocInfoField*>(pField); + nNumFormat = pDocInfoField->GetFormat(); sal_uInt16 nSubType = pField->GetSubType(); pTypeStr = OOO_STRING_SW_HTML_FT_docinfo; sal_uInt16 nExtSubType = nSubType & 0x0f00; @@ -183,7 +188,7 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, } if( DI_CUSTOM == nSubType ) { - aName = static_cast<const SwDocInfoField*>(pField)->GetName(); + aName = pDocInfoField->GetName(); } if( DI_CREATE == nSubType || DI_CHANGE == nSubType ) @@ -203,7 +208,7 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, break; } } - bFixed = static_cast<const SwDocInfoField*>(pField)->IsFixed(); + bFixed = pDocInfoField->IsFixed(); if( bNumFormat ) { if( bFixed ) @@ -214,7 +219,7 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, dNumValue = static_cast<const SwDocInfoField*>(pField)->GetValue(); bNumValue = true; } - else if( !nFormat ) + else if( !pDocInfoField->GetFormat() ) { // Non-fixed fields may not have a number format, when // they come from a 4.0-document. @@ -239,13 +244,13 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, case DS_OLE: pSubStr = OOO_STRING_SW_HTML_FS_ole; break; default: pTypeStr = nullptr; break; } - pFormatStr = SwHTMLWriter::GetNumFormat( static_cast< sal_uInt16 >(nFormat) ); + pFormatStr = SwHTMLWriter::GetNumFormat( static_cast< sal_uInt16 >(static_cast<const SwDocStatField*>(pField)->GetFormat()) ); } break; case SwFieldIds::Filename: pTypeStr = OOO_STRING_SW_HTML_FT_filename; - switch( static_cast<SwFileNameFormat>(nFormat & ~FF_FIXED) ) + switch( static_cast<SwFileNameFormat>(static_cast<const SwFileNameField*>(pField)->GetFormat() & ~FF_FIXED) ) { case FF_NAME: pFormatStr = OOO_STRING_SW_HTML_FF_name; break; case FF_PATHNAME: pFormatStr = OOO_STRING_SW_HTML_FF_pathname; break; @@ -304,9 +309,9 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, } if( bNumFormat ) { - OSL_ENSURE( nFormat, "number format is 0" ); + OSL_ENSURE( nNumFormat, "number format is 0" ); sOut.append(HTMLOutFuncs::CreateTableDataOptionsValNum( - bNumValue, dNumValue, nFormat, + bNumValue, dNumValue, nNumFormat, *rWrt.m_pDoc->GetNumberFormatter())); } if( bFixed ) diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index a7818623f5d1..cb786e35c945 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2734,7 +2734,7 @@ bool MSWordExportBase::GetNumberFormat(const SwField& rField, OUString& rStr) // Returns a date or time format string by using the US NfKeywordTable bool bHasFormat = false; SvNumberFormatter* pNFormatr = m_rDoc.GetNumberFormatter(); - sal_uInt32 nFormatIdx = rField.GetFormat(); + sal_uInt32 nFormatIdx = rField.GetUntypedFormat(); const SvNumberformat* pNumFormat = pNFormatr->GetEntry( nFormatIdx ); if( pNumFormat ) { @@ -2762,7 +2762,7 @@ bool MSWordExportBase::GetNumberFormat(const SwField& rField, OUString& rStr) void AttributeOutputBase::GetNumberPara( OUString& rStr, const SwField& rField ) { - switch(rField.GetFormat()) + switch(rField.GetUntypedFormat()) { case SVX_NUM_CHARS_UPPER_LETTER: case SVX_NUM_CHARS_UPPER_LETTER_N: @@ -2788,7 +2788,7 @@ void AttributeOutputBase::GetNumberPara( OUString& rStr, const SwField& rField ) rStr += "\* Cardtext "; break; default: - OSL_ENSURE(rField.GetFormat() == SVX_NUM_ARABIC, + OSL_ENSURE(rField.GetUntypedFormat() == SVX_NUM_ARABIC, "Unknown numbering type exported as default of Arabic"); [[fallthrough]]; case SVX_NUM_ARABIC: @@ -3018,7 +3018,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) case SwFieldIds::Filename: { OUString sStr = FieldString(ww::eFILENAME); - if (pField->GetFormat() == FF_PATHNAME) + if (static_cast<const SwFileNameField*>(pField)->GetFormat() == FF_PATHNAME) sStr += "\p "; GetExport().OutputField(pField, ww::eFILENAME, sStr); } @@ -3043,7 +3043,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) case SwFieldIds::Author: { ww::eField eField = - ((AF_SHORTCUT & pField->GetFormat()) ? ww::eUSERINITIALS : ww::eUSERNAME); + ((AF_SHORTCUT & static_cast<const SwAuthorField*>(pField)->GetFormat()) ? ww::eUSERINITIALS : ww::eUSERNAME); GetExport().OutputField(pField, eField, FieldString(eField)); } break; @@ -3238,7 +3238,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) { case REF_SETREFATTR: case REF_BOOKMARK: - switch (pField->GetFormat()) + switch (rRField.GetFormat()) { case REF_PAGE_PGDESC: case REF_PAGE: @@ -3253,7 +3253,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) sStr = FieldString(eField) + GetExport().GetBookmarkName(nSubType, &aRefName.toString(), 0); } - switch (pField->GetFormat()) + switch (rRField.GetFormat()) { case REF_NUMBER: sStr += " \r"; @@ -3272,7 +3272,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) if(GetExport().GetExportFormat() == MSWordExportBase::ExportFormat::RTF) break; - switch (pField->GetFormat()) + switch (rRField.GetFormat()) { case REF_PAGE: case REF_PAGE_PGDESC: @@ -3285,7 +3285,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) // Generate a unique bookmark name { OUString sName{rRField.GetSetRefName().toString() + OUString::number(rRField.GetSeqNo())}; - switch (pField->GetFormat()) + switch (rRField.GetFormat()) { case REF_PAGE: case REF_PAGE_PGDESC: @@ -3308,7 +3308,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) } sStr = FieldString(eField) + GetExport().GetBookmarkName(nSubType, &sName, 0); } - switch (pField->GetFormat()) + switch (rRField.GetFormat()) { case REF_NUMBER: sStr += " \r"; @@ -3324,7 +3324,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) } case REF_FOOTNOTE: case REF_ENDNOTE: - switch (pField->GetFormat()) + switch (rRField.GetFormat()) { case REF_PAGE_PGDESC: case REF_PAGE: @@ -3370,7 +3370,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) [[fallthrough]]; default: - switch (pField->GetFormat()) + switch (rRField.GetFormat()) { case REF_NUMBER: sStr += " \r " + sExtraFlags; diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 7d19ce3d99f7..b6b644eff8d0 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -120,7 +120,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormTextBox( WW8FieldDesc* pF, OUString& rStr ) aFormula.msDefault, aFormula.msTitle, INP_TXT, - 0 ); + false ); aField.SetHelp(aFormula.msHelp); aField.SetToolTip(aFormula.msToolTip); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 029184747a57..8e55622ed41e 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -1241,7 +1241,7 @@ eF_ResT SwWW8ImplReader::Read_F_Input( WW8FieldDesc* pF, OUString& rStr ) if ( pF->nId != 0x01 ) // 0x01 fields have no result { SwInputField aField( static_cast<SwInputFieldType*>(m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Input )), - aDef, aQ, INP_TXT, 0, false ); + aDef, aQ, INP_TXT, false ); m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) ); } @@ -2709,7 +2709,7 @@ eF_ResT SwWW8ImplReader::Read_F_Equation( WW8FieldDesc*, OUString& rStr ) if (aResult.sType == "Input") { SwInputField aField( static_cast<SwInputFieldType*>(m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Input )), - aResult.sResult, aResult.sResult, INP_TXT, 0 ); + aResult.sResult, aResult.sResult, INP_TXT, false ); m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) ); // insert input field } else if (aResult.sType == "CombinedCharacters") diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index 5762de379743..fa03d1f5178b 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -178,7 +178,7 @@ void SwFieldDBPage::Reset(const SfxItemSet*) m_xConditionED->save_value(); m_xValueED->save_value(); m_sOldDBName = m_xDatabaseTLB->GetDBName(m_sOldTableName, m_sOldColumnName); - m_nOldFormat = GetCurField()->GetFormat(); + m_nOldFormat = GetCurField()->GetUntypedFormat(); m_nOldSubType = GetCurField()->GetSubType(); } } @@ -337,8 +337,10 @@ void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox) if (IsFieldEdit()) { - if (GetCurField()->GetFormat() != 0 && GetCurField()->GetFormat() != SAL_MAX_UINT32) - m_xNumFormatLB->SetDefFormat(GetCurField()->GetFormat()); + auto pValueField = static_cast<SwValueField*>(GetCurField()); + auto nFormat = pValueField->GetFormat(); + if (nFormat != 0 && nFormat != SAL_MAX_UINT32) + m_xNumFormatLB->SetDefFormat(nFormat); if (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_OWN_FMT) m_xNewFormatRB->set_active(true); @@ -373,9 +375,11 @@ void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox) if( IsFieldEdit() ) { + auto pValueField = static_cast<SwValueField*>(GetCurField()); + auto nFormat = pValueField->GetFormat(); for (sal_Int32 nI = m_xFormatLB->get_count(); nI;) { - if (GetCurField()->GetFormat() == m_xFormatLB->get_id(--nI).toUInt32()) + if (nFormat == m_xFormatLB->get_id(--nI).toUInt32()) { m_xFormatLB->set_active( nI ); break; diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx index 2f2cff7b5e93..532429f2929c 100644 --- a/sw/source/ui/fldui/flddinf.cxx +++ b/sw/source/ui/fldui/flddinf.cxx @@ -146,7 +146,7 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* ) SwWrtShell *pSh = GetWrtShell(); if(pSh) { - const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat()); + const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetUntypedFormat()); if(pFormat) m_xFormatLB->SetLanguage(pFormat->GetLanguage()); } @@ -242,7 +242,7 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* ) if (IsFieldEdit()) { m_nOldSel = m_xSelectionLB->get_selected_index(); - m_nOldFormat = GetCurField()->GetFormat(); + m_nOldFormat = GetCurField()->GetUntypedFormat(); m_xFixedCB->save_state(); } } diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx index fa7e12035a24..e0530eff98ef 100644 --- a/sw/source/ui/fldui/flddok.cxx +++ b/sw/source/ui/fldui/flddok.cxx @@ -137,7 +137,7 @@ void SwFieldDokPage::Reset(const SfxItemSet* ) pSh = ::GetActiveWrtShell(); if(pSh) { - const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat()); + const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetUntypedFormat()); if(pFormat) m_xNumFormatLB->SetLanguage(pFormat->GetLanguage()); } @@ -178,7 +178,7 @@ void SwFieldDokPage::Reset(const SfxItemSet* ) if (IsFieldEdit()) { m_nOldSel = m_xSelectionLB->get_selected_index(); - m_nOldFormat = GetCurField()->GetFormat(); + m_nOldFormat = GetCurField()->GetUntypedFormat(); m_xFixedCB->save_state(); m_xValueED->save_value(); m_xLevelED->save_value(); @@ -260,7 +260,7 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) { const OUString sFormat(GetFieldMgr().GetFormatStr(nTypeId, i)); m_xSelectionLB->append(sId, sFormat); - m_xSelectionLB->select_text(GetFieldMgr().GetFormatStr(nTypeId, GetCurField()->GetFormat())); + m_xSelectionLB->select_text(GetFieldMgr().GetFormatStr(*GetCurField())); break; } @@ -384,7 +384,7 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) { if (IsFieldEdit()) { - m_xNumFormatLB->SetDefFormat(GetCurField()->GetFormat()); + m_xNumFormatLB->SetDefFormat(GetCurField()->GetUntypedFormat()); if (m_xNumFormatLB->GetFormatType() == (SvNumFormatType::DATE|SvNumFormatType::TIME)) { @@ -393,7 +393,7 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) m_xNumFormatLB->SetFormatType(SvNumFormatType::ALL); m_xNumFormatLB->SetFormatType(nFormatType); // set correct format once again - m_xNumFormatLB->SetDefFormat(GetCurField()->GetFormat()); + m_xNumFormatLB->SetDefFormat(GetCurField()->GetUntypedFormat()); } } else @@ -416,7 +416,7 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) m_xFixedCB->set_sensitive(bFixed); if (IsFieldEdit()) - m_xFixedCB->set_active((GetCurField()->GetFormat() & AF_FIXED) != 0 && bFixed); + m_xFixedCB->set_active((GetCurField()->GetUntypedFormat() & AF_FIXED) != 0 && bFixed); if (m_xNumFormatLB->get_selected_index() == -1) m_xNumFormatLB->select(0); @@ -480,7 +480,7 @@ sal_Int32 SwFieldDokPage::FillFormatLB(SwFieldTypesEnum nTypeId) if (IsFieldEdit()) { - m_xFormatLB->select_id(OUString::number(GetCurField()->GetFormat() & ~AF_FIXED)); + m_xFormatLB->select_id(OUString::number(GetCurField()->GetUntypedFormat() & ~AF_FIXED)); } else { diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx index 82a485698a2d..163d29f81470 100644 --- a/sw/source/ui/fldui/fldfunc.cxx +++ b/sw/source/ui/fldui/fldfunc.cxx @@ -174,7 +174,7 @@ void SwFieldFuncPage::Reset(const SfxItemSet* ) m_xValueED->save_value(); m_xCond1ED->save_value(); m_xCond2ED->save_value(); - m_nOldFormat = GetCurField()->GetFormat(); + m_nOldFormat = GetCurField()->GetUntypedFormat(); } } @@ -223,7 +223,7 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) if (nSize) { if (IsFieldEdit() && nTypeId == SwFieldTypesEnum::JumpEdit) - m_xFormatLB->select_text(SwResId(FMT_MARK_ARY[GetCurField()->GetFormat()])); + m_xFormatLB->select_text(SwResId(FMT_MARK_ARY[static_cast<const SwJumpEditField*>(GetCurField())->GetFormat()])); if (m_xFormatLB->get_selected_index() == -1) m_xFormatLB->select(0); diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index f0f780e214b3..11cb46cd6836 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -978,7 +978,7 @@ sal_Int32 SwFieldRefPage::FillFormatLB(sal_uInt16 nTypeId) if (!IsFieldEdit()) m_xFormatLB->select_text(sOldSel); else - m_xFormatLB->select_text(SwResId(FMT_REF_ARY[GetCurField()->GetFormat() % std::size(FMT_REF_ARY)])); + m_xFormatLB->select_text(SwResId(FMT_REF_ARY[GetCurField()->GetUntypedFormat() % std::size(FMT_REF_ARY)])); if (m_xFormatLB->get_selected_index() == -1) { diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx index 8b524ce2e79b..c2f0955d2c5d 100644 --- a/sw/source/ui/fldui/fldvar.cxx +++ b/sw/source/ui/fldui/fldvar.cxx @@ -142,7 +142,7 @@ void SwFieldVarPage::Reset(const SfxItemSet* ) pSh = ::GetActiveWrtShell(); if(pSh) { - const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat()); + const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetUntypedFormat()); if(pFormat) m_xNumFormatLB->SetLanguage(pFormat->GetLanguage()); } @@ -721,11 +721,11 @@ void SwFieldVarPage::FillFormatLB(SwFieldTypesEnum nTypeId) { if (GetCurField() != nullptr && IsFieldEdit()) { - bSpecialFormat = GetCurField()->GetFormat() == NUMBERFORMAT_ENTRY_NOT_FOUND; + bSpecialFormat = GetCurField()->GetUntypedFormat() == NUMBERFORMAT_ENTRY_NOT_FOUND; if (!bSpecialFormat) { - m_xNumFormatLB->SetDefFormat(GetCurField()->GetFormat()); + m_xNumFormatLB->SetDefFormat(GetCurField()->GetUntypedFormat()); sOldNumSel.clear(); } else if (nTypeId == SwFieldTypesEnum::Get || nTypeId == SwFieldTypesEnum::Formel) @@ -809,7 +809,7 @@ void SwFieldVarPage::FillFormatLB(SwFieldTypesEnum nTypeId) const sal_uInt16 nFieldId = GetFieldMgr().GetFormatId( nTypeId, i ); OUString sId(OUString::number(nFieldId)); m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr(nTypeId, i)); - if (IsFieldEdit() && GetCurField() && nFieldId == GetCurField()->GetFormat()) + if (IsFieldEdit() && GetCurField() && nFieldId == GetCurField()->GetUntypedFormat()) sSelectId = sId; } diff --git a/sw/source/ui/fldui/javaedit.cxx b/sw/source/ui/fldui/javaedit.cxx index f5bdc486ae88..1dfe851167bb 100644 --- a/sw/source/ui/fldui/javaedit.cxx +++ b/sw/source/ui/fldui/javaedit.cxx @@ -194,7 +194,7 @@ void SwJavaEditDialog::SetField() bool SwJavaEditDialog::IsUpdate() const { - return m_pField && ( sal_uInt32(m_bIsUrl ? 1 : 0) != m_pField->GetFormat() || m_pField->GetPar2() != m_aType || m_pField->GetPar1() != m_aText ); + return m_pField && ( m_bIsUrl != m_pField->IsCodeURL() || m_pField->GetPar2() != m_aType || m_pField->GetPar1() != m_aText ); } IMPL_LINK(SwJavaEditDialog, RadioButtonHdl, weld::Toggleable&, rButton, void) diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 27ceba387d23..4bf949757952 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -707,6 +707,12 @@ sal_uInt16 SwFieldMgr::GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) } } +// determine FormatString to a type +OUString SwFieldMgr::GetFormatStr(const SwField& rField) const +{ + return GetFormatStr(rField.GetTypeId(), rField.GetUntypedFormat()); +} + // determine FormatString to a type OUString SwFieldMgr::GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const { @@ -1026,7 +1032,7 @@ bool SwFieldMgr::InsertField( SwPageNumberFieldType* pTyp = static_cast<SwPageNumberFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::PageNumber) ); - pField.reset(new SwPageNumberField(pTyp, nSubType, nFormatId, nOff)); + pField.reset(new SwPageNumberField(pTyp, nSubType, static_cast<SvxNumType>(nFormatId), nOff)); if( SVX_NUM_CHAR_SPECIAL == nFormatId && ( PG_PREV == nSubType || PG_NEXT == nSubType ) ) @@ -1038,7 +1044,7 @@ bool SwFieldMgr::InsertField( { SwDocStatFieldType* pTyp = static_cast<SwDocStatFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DocStat) ); - pField.reset(new SwDocStatField(pTyp, nSubType, nFormatId)); + pField.reset(new SwDocStatField(pTyp, nSubType, static_cast<SvxNumType>(nFormatId))); break; } @@ -1258,7 +1264,7 @@ bool SwFieldMgr::InsertField( aDBData.sDataSource, aDBData.sCommand, sPar1, pCurShell->GetNumberFormatter(), GetCurrLanguage() ); } - pField->ChangeFormat( nFormatId ); + static_cast<SwDBField*>(pField.get())->SetFormat( nFormatId ); bExp = true; #endif @@ -1503,7 +1509,7 @@ bool SwFieldMgr::InsertField( case SwFieldTypesEnum::GetRefPage: pField.reset( new SwRefPageGetField( static_cast<SwRefPageGetFieldType*>( - pCurShell->GetFieldType( 0, SwFieldIds::RefPageGet ) ), nFormatId ) ); + pCurShell->GetFieldType( 0, SwFieldIds::RefPageGet ) ), static_cast<SvxNumType>(nFormatId) ) ); bPageVar = true; break; case SwFieldTypesEnum::Dropdown : @@ -1780,7 +1786,7 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, // set format // setup format before SetPar2 because of NumberFormatter! - pTmpField->ChangeFormat(nFormat); + pTmpField->SetUntypedFormat(nFormat); if( bSetPar1 ) pTmpField->SetPar1( rPar1 ); diff --git a/sw/source/uibase/inc/fldmgr.hxx b/sw/source/uibase/inc/fldmgr.hxx index dd327933b4b7..e9c863364fb7 100644 --- a/sw/source/uibase/inc/fldmgr.hxx +++ b/sw/source/uibase/inc/fldmgr.hxx @@ -185,6 +185,7 @@ public: // format to a type sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const; + OUString GetFormatStr(const SwField&) const; OUString GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const; sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const; sal_uInt32 GetDefaultFormat(SwFieldTypesEnum nTypeId, bool bIsText, SvNumberFormatter* pFormatter); diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index 2b6862d3a8f3..a394f2195083 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -742,7 +742,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) SwScriptField* pField = static_cast<SwScriptField*>(aMgr.GetCurField()); bNew = !pField || (pField->GetTyp()->Which() != SwFieldIds::Script); - bUpdate = pField && ( bIsUrl != static_cast<bool>(pField->GetFormat()) || pField->GetPar2() != aType || pField->GetPar1() != aText ); + bUpdate = pField && ( bIsUrl != pField->IsCodeURL() || pField->GetPar2() != aType || pField->GetPar1() != aText ); } else { diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index ad9a9fa70bdc..f7b515e3605a 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -138,6 +138,7 @@ #include <formatcontentcontrol.hxx> #include <rtl/uri.hxx> #include <unotxdoc.hxx> +#include <expfld.hxx> #include <sax/tools/converter.hxx> #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> @@ -1547,7 +1548,7 @@ void SwTextShell::Execute(SfxRequest &rReq) } if( !bDelSel && aFieldMgr.GetCurField() && SwFieldTypesEnum::Formel == aFieldMgr.GetCurTypeId() ) - aFieldMgr.UpdateCurField( aFieldMgr.GetCurField()->GetFormat(), OUString(), sFormula ); + aFieldMgr.UpdateCurField( static_cast<SwGetExpField*>(aFieldMgr.GetCurField())->GetFormat(), OUString(), sFormula ); else if( !sFormula.isEmpty() ) { if( rWrtSh.IsCursorInTable() ) diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx index adf9c21669f1..a2fbfe154d52 100644 --- a/sw/source/uibase/wrtsh/wrtsh2.cxx +++ b/sw/source/uibase/wrtsh/wrtsh2.cxx @@ -377,7 +377,7 @@ void SwWrtShell::ClickToField(const SwField& rField, bool bExecHyperlinks) case SwFieldIds::JumpEdit: { sal_uInt16 nSlotId = 0; - switch( rField.GetFormat() ) + switch( static_cast<const SwJumpEditField&>(rField).GetFormat() ) { case JE_FMT_TABLE: nSlotId = FN_INSERT_TABLE;