sw/inc/chpfld.hxx | 21 ++++---- sw/inc/docufld.hxx | 20 ++++---- sw/inc/fldbas.hxx | 22 +++++---- sw/inc/tox.hxx | 5 +- sw/qa/core/test_ToxTextGenerator.cxx | 8 +-- sw/qa/core/uwriter.cxx | 8 +-- sw/source/core/fields/chpfld.cxx | 42 ++++++++++------- sw/source/core/fields/docufld.cxx | 75 ++++++++++++++++---------------- sw/source/core/fields/fldbas.cxx | 14 ++--- sw/source/core/fields/reffld.cxx | 2 sw/source/core/tox/ToxTextGenerator.cxx | 8 +-- sw/source/core/tox/tox.cxx | 4 - sw/source/core/unocore/unofield.cxx | 8 +-- sw/source/core/unocore/unoidx.cxx | 33 ++++++-------- sw/source/filter/html/htmlfld.cxx | 12 ++--- sw/source/filter/html/htmlfldw.cxx | 10 ++-- sw/source/filter/ww8/ww8atr.cxx | 2 sw/source/filter/ww8/ww8par5.cxx | 8 +-- sw/source/ui/fldui/flddok.cxx | 2 sw/source/ui/index/cnttab.cxx | 22 ++++----- sw/source/uibase/fldui/fldmgr.cxx | 8 +-- 21 files changed, 171 insertions(+), 163 deletions(-)
New commits: commit 2f5fcf5df0e8fef80def70c4127a36bb72022595 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Jul 5 10:33:19 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Mon Jul 7 14:51:48 2025 +0200 Convert SwFileNameFormat to scoped enum Change-Id: I128f322fa09531c2dc70202910392f15e23f70c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187462 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index c2189f0fdfaf..98e373d83f2f 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -218,20 +218,20 @@ class SAL_DLLPUBLIC_RTTI SwFileNameFieldType final : public SwFieldType public: SwFileNameFieldType(SwDoc&); - OUString Expand(sal_uLong) const; + OUString Expand(SwFileNameFormat) const; virtual std::unique_ptr<SwFieldType> Copy() const override; }; class SW_DLLPUBLIC SwFileNameField final : public SwField { OUString m_aContent; - sal_uInt32 m_nFormat; + SwFileNameFormat m_nFormat; public: - SwFileNameField(SwFileNameFieldType*, sal_uInt32 nFormat); + SwFileNameField(SwFileNameFieldType*, SwFileNameFormat nFormat); - sal_uInt32 GetFormat() const { return m_nFormat; } - void SetFormat(sal_uInt32 n) { m_nFormat = n; } + SwFileNameFormat GetFormat() const { return m_nFormat; } + void SetFormat(SwFileNameFormat n) { m_nFormat = n; } virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; @@ -248,18 +248,18 @@ class SAL_DLLPUBLIC_RTTI SwTemplNameFieldType final : public SwFieldType public: SwTemplNameFieldType(SwDoc&); - OUString Expand(sal_uLong) const; + OUString Expand(SwFileNameFormat) const; virtual std::unique_ptr<SwFieldType> Copy() const override; }; class SW_DLLPUBLIC SwTemplNameField final : public SwField { - sal_uInt32 m_nFormat; + SwFileNameFormat m_nFormat; public: - SwTemplNameField(SwTemplNameFieldType*, sal_uInt32 nFormat); + SwTemplNameField(SwTemplNameFieldType*, SwFileNameFormat nFormat); - sal_uInt32 GetFormat() const { return m_nFormat; } - void SetFormat(sal_uInt32 n) { m_nFormat = n; } + SwFileNameFormat GetFormat() const { return m_nFormat; } + void SetFormat(SwFileNameFormat 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; diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index 857198b57579..ba16540599a5 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -155,17 +155,19 @@ enum SwAttrFieldType { ATTR_BOOKMARKFLD, ATTR_SETREFATTRFLD }; -enum SwFileNameFormat { - FF_BEGIN, - FF_NAME = FF_BEGIN, - FF_PATHNAME, - FF_PATH, - FF_NAME_NOEXT, - FF_UI_NAME, - FF_UI_RANGE, - FF_END, - FF_FIXED = 0x8000 +enum class SwFileNameFormat { + // most of the constants are a regular enum + Name, + PathName, + Path, + NameNoExt, + UIName, + UIRange, + End, // marker value, used for asserts + // except for this, which is a flag + Fixed = 0x8000 }; +namespace o3tl { template<> struct typed_flags<SwFileNameFormat> : is_typed_flags<SwFileNameFormat, 0x800f> {}; } enum SwVarFormat { VVF_CMD = 0x0010, ///< Show command. diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index ec4c21f03b24..fab8befe39b8 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -224,20 +224,20 @@ void SwDocTest::testFileNameFields() SwFileNameFieldType aNameField(*m_pDoc); { - OUString sResult(aNameField.Expand(FF_NAME)); + OUString sResult(aNameField.Expand(SwFileNameFormat::Name)); OUString sExpected(rUrlObj.getName(INetURLObject::LAST_SEGMENT, true,INetURLObject::DecodeMechanism::WithCharset)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected Readable FileName", sExpected, sResult); } { - OUString sResult(aNameField.Expand(FF_PATHNAME)); + OUString sResult(aNameField.Expand(SwFileNameFormat::PathName)); OUString sExpected(rUrlObj.GetFull()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected Readable FileName", sExpected, sResult); } { - OUString sResult(aNameField.Expand(FF_PATH)); + OUString sResult(aNameField.Expand(SwFileNameFormat::Path)); INetURLObject aTemp(rUrlObj); aTemp.removeSegment(); OUString sExpected(aTemp.PathToFileName()); @@ -245,7 +245,7 @@ void SwDocTest::testFileNameFields() } { - OUString sResult(aNameField.Expand(FF_NAME_NOEXT)); + OUString sResult(aNameField.Expand(SwFileNameFormat::NameNoExt)); OUString sExpected(rUrlObj.getName(INetURLObject::LAST_SEGMENT, true,INetURLObject::DecodeMechanism::WithCharset)); //Chop off .tmp diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 10e4f7d6ee1a..fa273b4b1784 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -430,16 +430,16 @@ SwFileNameFieldType::SwFileNameFieldType(SwDoc& rDocument) { } -OUString SwFileNameFieldType::Expand(sal_uLong nFormat) const +OUString SwFileNameFieldType::Expand(SwFileNameFormat nFormat) const { OUString aRet; const SwDocShell* pDShell = m_rDoc.GetDocShell(); if( pDShell && pDShell->HasName() ) { const INetURLObject& rURLObj = pDShell->GetMedium()->GetURLObject(); - switch( nFormat & ~FF_FIXED ) + switch( nFormat & ~SwFileNameFormat::Fixed ) { - case FF_PATH: + case SwFileNameFormat::Path: { if( INetProtocol::File == rURLObj.GetProtocol() ) { @@ -462,11 +462,11 @@ OUString SwFileNameFieldType::Expand(sal_uLong nFormat) const } break; - case FF_NAME: + case SwFileNameFormat::Name: aRet = rURLObj.GetLastName( INetURLObject::DecodeMechanism::WithCharset ); break; - case FF_NAME_NOEXT: + case SwFileNameFormat::NameNoExt: aRet = rURLObj.GetBase(); break; @@ -487,7 +487,7 @@ std::unique_ptr<SwFieldType> SwFileNameFieldType::Copy() const return std::make_unique<SwFileNameFieldType>(m_rDoc); } -SwFileNameField::SwFileNameField(SwFileNameFieldType* pTyp, sal_uInt32 nFormat) +SwFileNameField::SwFileNameField(SwFileNameFieldType* pTyp, SwFileNameFormat nFormat) : SwField(pTyp), m_nFormat(nFormat) { @@ -518,15 +518,15 @@ bool SwFileNameField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const case FIELD_PROP_FORMAT: { sal_Int16 nRet; - switch( GetFormat() &(~FF_FIXED) ) + switch( GetFormat() & (~SwFileNameFormat::Fixed) ) { - case FF_PATH: + case SwFileNameFormat::Path: nRet = text::FilenameDisplayFormat::PATH; break; - case FF_NAME_NOEXT: + case SwFileNameFormat::NameNoExt: nRet = text::FilenameDisplayFormat::NAME; break; - case FF_NAME: + case SwFileNameFormat::Name: nRet = text::FilenameDisplayFormat::NAME_AND_EXT; break; default: nRet = text::FilenameDisplayFormat::FULL; @@ -564,27 +564,27 @@ bool SwFileNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) switch( nType ) { case text::FilenameDisplayFormat::PATH: - nType = FF_PATH; + m_nFormat = SwFileNameFormat::Path; break; case text::FilenameDisplayFormat::NAME: - nType = FF_NAME_NOEXT; + m_nFormat = SwFileNameFormat::NameNoExt; break; case text::FilenameDisplayFormat::NAME_AND_EXT: - nType = FF_NAME; + m_nFormat = SwFileNameFormat::Name; break; - default: nType = FF_PATHNAME; + default: + m_nFormat = SwFileNameFormat::PathName; } if(bFixed) - nType |= FF_FIXED; - m_nFormat = nType; + m_nFormat |= SwFileNameFormat::Fixed; } break; case FIELD_PROP_BOOL2: if( *o3tl::doAccess<bool>(rAny) ) - m_nFormat |= FF_FIXED; + m_nFormat |= SwFileNameFormat::Fixed; else - m_nFormat &= ~FF_FIXED; + m_nFormat &= ~SwFileNameFormat::Fixed; break; case FIELD_PROP_PAR3: @@ -603,9 +603,9 @@ SwTemplNameFieldType::SwTemplNameFieldType(SwDoc& rDocument) { } -OUString SwTemplNameFieldType::Expand(sal_uLong nFormat) const +OUString SwTemplNameFieldType::Expand(SwFileNameFormat nFormat) const { - OSL_ENSURE( nFormat < FF_END, "Expand: no valid Format!" ); + OSL_ENSURE( nFormat < SwFileNameFormat::End, "Expand: no valid Format!" ); OUString aRet; SwDocShell *pDocShell(m_rDoc.GetDocShell()); @@ -617,11 +617,11 @@ OUString SwTemplNameFieldType::Expand(sal_uLong nFormat) const xDPS->getDocumentProperties()); OSL_ENSURE(xDocProps.is(), "Doc has no DocumentProperties"); - if( FF_UI_NAME == nFormat ) + if( SwFileNameFormat::UIName == nFormat ) aRet = xDocProps->getTemplateName(); else if( !xDocProps->getTemplateURL().isEmpty() ) { - if( FF_UI_RANGE == nFormat ) + if( SwFileNameFormat::UIRange == nFormat ) { // for getting region names! SfxDocumentTemplates aFac; @@ -633,13 +633,13 @@ OUString SwTemplNameFieldType::Expand(sal_uLong nFormat) const else { INetURLObject aPathName( xDocProps->getTemplateURL() ); - if( FF_NAME == nFormat ) + if( SwFileNameFormat::Name == nFormat ) aRet = aPathName.GetLastName(URL_DECODE); - else if( FF_NAME_NOEXT == nFormat ) + else if( SwFileNameFormat::NameNoExt == nFormat ) aRet = aPathName.GetBase(); else { - if( FF_PATH == nFormat ) + if( SwFileNameFormat::Path == nFormat ) { aPathName.removeSegment(); aRet = aPathName.GetFull(); @@ -658,7 +658,7 @@ std::unique_ptr<SwFieldType> SwTemplNameFieldType::Copy() const return std::make_unique<SwTemplNameFieldType>(m_rDoc); } -SwTemplNameField::SwTemplNameField(SwTemplNameFieldType* pTyp, sal_uInt32 nFormat) +SwTemplNameField::SwTemplNameField(SwTemplNameFieldType* pTyp, SwFileNameFormat nFormat) : SwField(pTyp), m_nFormat(nFormat) {} @@ -681,11 +681,11 @@ bool SwTemplNameField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const sal_Int16 nRet; switch( GetFormat() ) { - case FF_PATH: nRet = text::FilenameDisplayFormat::PATH; break; - case FF_NAME_NOEXT: nRet = text::FilenameDisplayFormat::NAME; break; - case FF_NAME: nRet = text::FilenameDisplayFormat::NAME_AND_EXT; break; - case FF_UI_RANGE: nRet = text::TemplateDisplayFormat::AREA; break; - case FF_UI_NAME: nRet = text::TemplateDisplayFormat::TITLE; break; + case SwFileNameFormat::Path: nRet = text::FilenameDisplayFormat::PATH; break; + case SwFileNameFormat::NameNoExt: nRet = text::FilenameDisplayFormat::NAME; break; + case SwFileNameFormat::Name: nRet = text::FilenameDisplayFormat::NAME_AND_EXT; break; + case SwFileNameFormat::UIRange: nRet = text::TemplateDisplayFormat::AREA; break; + case SwFileNameFormat::UIName: nRet = text::TemplateDisplayFormat::TITLE; break; default: nRet = text::FilenameDisplayFormat::FULL; } @@ -713,21 +713,22 @@ bool SwTemplNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) switch( nType ) { case text::FilenameDisplayFormat::PATH: - m_nFormat = FF_PATH; + m_nFormat = SwFileNameFormat::Path; break; case text::FilenameDisplayFormat::NAME: - m_nFormat = FF_NAME_NOEXT; + m_nFormat = SwFileNameFormat::NameNoExt; break; case text::FilenameDisplayFormat::NAME_AND_EXT: - m_nFormat = FF_NAME; + m_nFormat = SwFileNameFormat::Name; break; case text::TemplateDisplayFormat::AREA : - m_nFormat = FF_UI_RANGE; + m_nFormat = SwFileNameFormat::UIRange; break; case text::TemplateDisplayFormat::TITLE : - m_nFormat = FF_UI_NAME; + m_nFormat = SwFileNameFormat::UIName; break; - default: m_nFormat = FF_PATHNAME; + default: + m_nFormat = SwFileNameFormat::PathName; } } break; diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index c2a4cb3ef444..173b8a2e8c30 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -335,11 +335,11 @@ sal_uInt32 SwField::GetUntypedFormat() const case SwFieldIds::DocStat: return static_cast<const SwDocStatField*>(this)->GetFormat(); case SwFieldIds::TemplateName: - return static_cast<const SwTemplNameField*>(this)->GetFormat(); + return static_cast<sal_uInt32>(static_cast<const SwTemplNameField*>(this)->GetFormat()); case SwFieldIds::Chapter: return static_cast<sal_uInt32>(static_cast<const SwChapterField*>(this)->GetFormat()); case SwFieldIds::Filename: - return static_cast<const SwFileNameField*>(this)->GetFormat(); + return static_cast<sal_uInt32>(static_cast<const SwFileNameField*>(this)->GetFormat()); case SwFieldIds::Author: return static_cast<const SwAuthorField*>(this)->GetFormat(); case SwFieldIds::ExtUser: @@ -375,13 +375,13 @@ void SwField::SetUntypedFormat(sal_uInt32 n) static_cast<SwDocStatField*>(this)->SetFormat(static_cast<SvxNumType>(n)); return; case SwFieldIds::TemplateName: - static_cast<SwTemplNameField*>(this)->SetFormat(n); + static_cast<SwTemplNameField*>(this)->SetFormat(static_cast<SwFileNameFormat>(n)); return; case SwFieldIds::Chapter: static_cast<SwChapterField*>(this)->SetFormat(static_cast<SwChapterFormat>(n)); return; case SwFieldIds::Filename: - static_cast<SwFileNameField*>(this)->SetFormat(n); + static_cast<SwFileNameField*>(this)->SetFormat(static_cast<SwFileNameFormat>(n)); return; case SwFieldIds::Author: static_cast<SwAuthorField*>(this)->SetFormat(n); @@ -550,7 +550,7 @@ bool SwField::IsFixed() const break; case SwFieldIds::Filename: - bRet = 0 != (static_cast<const SwFileNameField*>(this)->GetFormat() & FF_FIXED); + bRet = bool(static_cast<const SwFileNameField*>(this)->GetFormat() & SwFileNameFormat::Fixed); break; case SwFieldIds::DocInfo: diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 62e5eaa05d16..17cad02d9cc8 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1437,9 +1437,9 @@ void SAL_CALL SwXTextField::attach( case SwServiceType::FieldTypeFileName: { SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::Filename); - sal_Int32 nFormat = m_pImpl->m_pProps->nFormat; + SwFileNameFormat nFormat = static_cast<SwFileNameFormat>(m_pImpl->m_pProps->nFormat); if (m_pImpl->m_pProps->bBool2) - nFormat |= FF_FIXED; + nFormat |= SwFileNameFormat::Fixed; SwFileNameField *const pFNField = new SwFileNameField( static_cast<SwFileNameFieldType*>(pFieldType), nFormat); xField.reset(pFNField); @@ -1454,7 +1454,7 @@ void SAL_CALL SwXTextField::attach( { SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::TemplateName); xField.reset(new SwTemplNameField(static_cast<SwTemplNameFieldType*>(pFieldType), - m_pImpl->m_pProps->nFormat)); + static_cast<SwFileNameFormat>(m_pImpl->m_pProps->nFormat))); uno::Any aFormat; aFormat <<= m_pImpl->m_pProps->nFormat; xField->PutValue(aFormat, FIELD_PROP_FORMAT); diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx index d8ac54918283..e4a556b9eed9 100644 --- a/sw/source/filter/html/htmlfld.cxx +++ b/sw/source/filter/html/htmlfld.cxx @@ -190,10 +190,10 @@ HTMLOptionEnum<SwDocStatSubType> const aHTMLDocStatFieldSubTable[] = HTMLOptionEnum<SwFileNameFormat> const aHTMLFileNameFieldFormatTable[] = { - { OOO_STRING_SW_HTML_FF_name, FF_NAME }, - { OOO_STRING_SW_HTML_FF_pathname, FF_PATHNAME }, - { OOO_STRING_SW_HTML_FF_path, FF_PATH }, - { OOO_STRING_SW_HTML_FF_name_noext, FF_NAME_NOEXT }, + { OOO_STRING_SW_HTML_FF_name, SwFileNameFormat::Name }, + { OOO_STRING_SW_HTML_FF_pathname, SwFileNameFormat::PathName }, + { OOO_STRING_SW_HTML_FF_path, SwFileNameFormat::Path }, + { OOO_STRING_SW_HTML_FF_name_noext, SwFileNameFormat::NameNoExt }, { nullptr, SwFileNameFormat(0) } }; @@ -505,12 +505,12 @@ void SwHTMLParser::NewField() case SwFieldIds::Filename: { - SwFileNameFormat nFormat = FF_NAME; + SwFileNameFormat nFormat = SwFileNameFormat::Name; if( pFormatOption ) pFormatOption->GetEnum( nFormat, aHTMLFileNameFieldFormatTable ); if( bFixed ) { - nFormat = static_cast<SwFileNameFormat>(static_cast<int>(nFormat) | FF_FIXED); + nFormat |= SwFileNameFormat::Fixed; bInsOnEndTag = true; } diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx index 0f55b9eea417..9e443f22f086 100644 --- a/sw/source/filter/html/htmlfldw.cxx +++ b/sw/source/filter/html/htmlfldw.cxx @@ -250,12 +250,12 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, case SwFieldIds::Filename: pTypeStr = OOO_STRING_SW_HTML_FT_filename; - switch( static_cast<SwFileNameFormat>(static_cast<const SwFileNameField*>(pField)->GetFormat() & ~FF_FIXED) ) + switch( static_cast<const SwFileNameField*>(pField)->GetFormat() & ~SwFileNameFormat::Fixed ) { - case FF_NAME: pFormatStr = OOO_STRING_SW_HTML_FF_name; break; - case FF_PATHNAME: pFormatStr = OOO_STRING_SW_HTML_FF_pathname; break; - case FF_PATH: pFormatStr = OOO_STRING_SW_HTML_FF_path; break; - case FF_NAME_NOEXT: pFormatStr = OOO_STRING_SW_HTML_FF_name_noext; break; + case SwFileNameFormat::Name: pFormatStr = OOO_STRING_SW_HTML_FF_name; break; + case SwFileNameFormat::PathName: pFormatStr = OOO_STRING_SW_HTML_FF_pathname; break; + case SwFileNameFormat::Path: pFormatStr = OOO_STRING_SW_HTML_FF_path; break; + case SwFileNameFormat::NameNoExt: pFormatStr = OOO_STRING_SW_HTML_FF_name_noext; break; default: ; } diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index cb786e35c945..ab64c12c73f7 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -3018,7 +3018,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) case SwFieldIds::Filename: { OUString sStr = FieldString(ww::eFILENAME); - if (static_cast<const SwFileNameField*>(pField)->GetFormat() == FF_PATHNAME) + if (static_cast<const SwFileNameField*>(pField)->GetFormat() == SwFileNameFormat::PathName) sStr += "\p "; GetExport().OutputField(pField, ww::eFILENAME, sStr); } diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 327195086fdb..25f991022bb6 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -1875,7 +1875,7 @@ eF_ResT SwWW8ImplReader::Read_F_Author(WW8FieldDesc* pF, OUString&) eF_ResT SwWW8ImplReader::Read_F_TemplName( WW8FieldDesc*, OUString& ) { SwTemplNameField aField( static_cast<SwTemplNameFieldType*>( - m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::TemplateName )), FF_NAME ); + m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::TemplateName )), SwFileNameFormat::Name ); m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) ); return eF_ResT::OK; } @@ -1951,7 +1951,7 @@ eF_ResT SwWW8ImplReader::Read_F_DateTime( WW8FieldDesc*pF, OUString& rStr ) eF_ResT SwWW8ImplReader::Read_F_FileName(WW8FieldDesc*, OUString &rStr) { - SwFileNameFormat eType = FF_NAME; + SwFileNameFormat eType = SwFileNameFormat::Name; WW8ReadFieldParams aReadParam(rStr); for (;;) { @@ -1961,7 +1961,7 @@ eF_ResT SwWW8ImplReader::Read_F_FileName(WW8FieldDesc*, OUString &rStr) switch (nRet) { case 'p': - eType = FF_PATHNAME; + eType = SwFileNameFormat::PathName; break; case '*': //Skip over MERGEFORMAT diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx index e0530eff98ef..1393fc8e3241 100644 --- a/sw/source/ui/fldui/flddok.cxx +++ b/sw/source/ui/fldui/flddok.cxx @@ -571,7 +571,7 @@ bool SwFieldDokPage::FillItemSet(SfxItemSet* ) break; case SwFieldTypesEnum::Filename: - nFormat |= m_xFixedCB->get_active() ? FF_FIXED : 0; + nFormat |= m_xFixedCB->get_active() ? static_cast<sal_uInt32>(SwFileNameFormat::Fixed) : 0; break; case SwFieldTypesEnum::Date: diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index ac571cf5be19..4ceac9f9061f 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -727,7 +727,7 @@ OUString SwFieldMgr::GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId return OUString(); if (SwFieldTypesEnum::Author == nTypeId || SwFieldTypesEnum::Filename == nTypeId) - nFormatId &= ~static_cast<sal_uInt32>(FF_FIXED); // mask out Fixed-Flag + nFormatId &= ~static_cast<sal_uInt32>(SwFileNameFormat::Fixed); // mask out Fixed-Flag if (nFormatId < aSwFields[nPos].nFormatLength) return SwResId(pStart[nFormatId]); @@ -980,7 +980,7 @@ bool SwFieldMgr::InsertField( { SwFileNameFieldType* pTyp = static_cast<SwFileNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Filename) ); - pField.reset(new SwFileNameField(pTyp, nFormatId)); + pField.reset(new SwFileNameField(pTyp, static_cast<SwFileNameFormat>(nFormatId))); break; } @@ -988,7 +988,7 @@ bool SwFieldMgr::InsertField( { SwTemplNameFieldType* pTyp = static_cast<SwTemplNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::TemplateName) ); - pField.reset(new SwTemplNameField(pTyp, nFormatId)); + pField.reset(new SwTemplNameField(pTyp, static_cast<SwFileNameFormat>(nFormatId))); break; } commit 7c3d3681a50a7a12905703689be2336e635a9217 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Jul 5 09:22:22 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jul 7 14:51:39 2025 +0200 Convert SwChapterFormat to scoped enum Change-Id: I678a5a32f41de8b61b923c1513264dcc9ee9c2a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187461 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/sw/inc/chpfld.hxx b/sw/inc/chpfld.hxx index 78076cd83cd4..d31b14afdc07 100644 --- a/sw/inc/chpfld.hxx +++ b/sw/inc/chpfld.hxx @@ -25,14 +25,13 @@ class SwContentNode; class SwTextNode; class SwRootFrame; -enum SwChapterFormat +enum class SwChapterFormat : sal_uInt16 { - CF_BEGIN, - CF_NUMBER = CF_BEGIN, ///< only the chapter number - CF_TITLE, ///< only the title - CF_NUM_TITLE, ///< number and title - CF_NUMBER_NOPREPST, ///< only chapter number without post-/prefix - CF_NUM_NOPREPST_TITLE, ///< chapter number without post-/prefix and title + Number, ///< only the chapter number + Title, ///< only the title + NumberAndTitle, ///< number and title + NumberNoPrePost, ///< only chapter number without post-/prefix + NumberNoPrePostAndTitle ///< chapter number without post-/prefix and title }; class SAL_DLLPUBLIC_RTTI SwChapterFieldType final : public SwFieldType @@ -61,16 +60,16 @@ class SW_DLLPUBLIC SwChapterField final : public SwField }; State m_State; State m_StateRLHidden; - sal_uInt32 m_nFormat; + SwChapterFormat m_nFormat; virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; public: - SwChapterField(SwChapterFieldType*, sal_uInt32 nFormat = 0); + SwChapterField(SwChapterFieldType*, SwChapterFormat nFormat = SwChapterFormat::Number); - sal_uInt32 GetFormat() const { return m_nFormat; } - void SetFormat(sal_uInt32 n) { m_nFormat = n; } + SwChapterFormat GetFormat() const { return m_nFormat; } + void SetFormat(SwChapterFormat n) { m_nFormat = n; } // #i53420# void ChangeExpansion( const SwFrame&, diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx index 8892e331a2e1..99047ed34bfe 100644 --- a/sw/inc/tox.hxx +++ b/sw/inc/tox.hxx @@ -36,6 +36,7 @@ #include "hints.hxx" #include "swtypes.hxx" #include "toxe.hxx" +#include "chpfld.hxx" class SwTOXType; class SwTOXMark; @@ -249,7 +250,7 @@ struct SW_DLLPUBLIC SwFormToken FormTokenType eTokenType; sal_uInt16 nPoolId; SvxTabAdjust eTabAlign; - sal_uInt16 nChapterFormat; //SwChapterFormat; + SwChapterFormat nChapterFormat; //SwChapterFormat; sal_uInt16 nOutlineLevel;//the maximum permitted outline level in numbering sal_uInt16 nAuthorityField; //enum ToxAuthorityField sal_Unicode cTabFillChar; @@ -262,7 +263,7 @@ struct SW_DLLPUBLIC SwFormToken eTokenType(eType), nPoolId(USHRT_MAX), eTabAlign( SvxTabAdjust::Left ), - nChapterFormat(0 /*CF_NUMBER*/), + nChapterFormat(SwChapterFormat::Number), nOutlineLevel(MAXLEVEL), //default to maximum outline level nAuthorityField(0 /*AUTH_FIELD_IDENTIFIER*/), cTabFillChar(' '), diff --git a/sw/qa/core/test_ToxTextGenerator.cxx b/sw/qa/core/test_ToxTextGenerator.cxx index d64830a770ac..9d5901ddbe86 100644 --- a/sw/qa/core/test_ToxTextGenerator.cxx +++ b/sw/qa/core/test_ToxTextGenerator.cxx @@ -160,7 +160,7 @@ ToxTextGeneratorTest::ChapterNumberWithoutTextIsGeneratedForNoprepstTitle() ttg.GetChapterField().m_State.sTitle = "TITLE"; SwFormToken token(TOKEN_CHAPTER_INFO); - token.nChapterFormat = CF_NUM_NOPREPST_TITLE; + token.nChapterFormat = SwChapterFormat::NumberNoPrePostAndTitle; OUString expected(u"1"_ustr); OUString actual = ttg.GenerateTextForChapterToken(token, nullptr, nullptr, nullptr); @@ -168,7 +168,7 @@ ToxTextGeneratorTest::ChapterNumberWithoutTextIsGeneratedForNoprepstTitle() // we cannot mock the pre- and suffix generation in the chapterfield. We just test that sNumber and // sTitle are used and hope that the pre- and suffix addition works. - token.nChapterFormat = CF_NUMBER; + token.nChapterFormat = SwChapterFormat::Number; expected = ttg.GenerateTextForChapterToken(token, nullptr, nullptr, nullptr); CPPUNIT_ASSERT_EQUAL(expected, actual); } @@ -186,7 +186,7 @@ ToxTextGeneratorTest::ChapterNumberWithTitleIsGeneratedForNumberNoPrepst() ttg.GetChapterField().m_State.sTitle = "myTitle"; SwFormToken token(TOKEN_CHAPTER_INFO); - token.nChapterFormat = CF_NUMBER_NOPREPST; + token.nChapterFormat = SwChapterFormat::NumberNoPrePost; OUString expected(u"5 myTitle"_ustr); OUString actual = ttg.GenerateTextForChapterToken(token, nullptr, nullptr, nullptr); @@ -194,7 +194,7 @@ ToxTextGeneratorTest::ChapterNumberWithTitleIsGeneratedForNumberNoPrepst() // we cannot mock the pre- and suffix generation in the chapterfield. We just test that sNumber and // sTitle are used and hope that the pre- and suffix addition works. - token.nChapterFormat = CF_NUM_TITLE; + token.nChapterFormat = SwChapterFormat::NumberAndTitle; expected = ttg.GenerateTextForChapterToken(token, nullptr, nullptr, nullptr); CPPUNIT_ASSERT_EQUAL(expected, actual); } diff --git a/sw/source/core/fields/chpfld.cxx b/sw/source/core/fields/chpfld.cxx index 47828a8acee3..aa85808a7ac6 100644 --- a/sw/source/core/fields/chpfld.cxx +++ b/sw/source/core/fields/chpfld.cxx @@ -71,7 +71,7 @@ std::unique_ptr<SwFieldType> SwChapterFieldType::Copy() const // chapter field -SwChapterField::SwChapterField(SwChapterFieldType* pTyp, sal_uInt32 nFormat) +SwChapterField::SwChapterField(SwChapterFieldType* pTyp, SwChapterFormat nFormat) : SwField(pTyp), m_nFormat(nFormat) { @@ -107,14 +107,15 @@ OUString SwChapterField::ExpandImpl(SwRootFrame const*const pLayout) const State const& rState(pLayout && pLayout->IsHideRedlines() ? m_StateRLHidden : m_State); switch( GetFormat() ) { - case CF_TITLE: + case SwChapterFormat::Title: return rState.sTitle; - case CF_NUMBER: + case SwChapterFormat::Number: return rState.sPre + rState.sNumber + rState.sPost; - case CF_NUM_TITLE: + case SwChapterFormat::NumberAndTitle: return rState.sPre + rState.sNumber + rState.sPost + rState.sLabelFollowedBy + rState.sTitle; - case CF_NUM_NOPREPST_TITLE: + case SwChapterFormat::NumberNoPrePostAndTitle: return rState.sNumber + rState.sLabelFollowedBy + rState.sTitle; + default: break; } // CF_NUMBER_NOPREPST return rState.sNumber; @@ -241,16 +242,21 @@ bool SwChapterField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const sal_Int16 nRet; switch( GetFormat() ) { - case CF_NUMBER: nRet = text::ChapterFormat::NUMBER; break; - case CF_TITLE: nRet = text::ChapterFormat::NAME; break; - case CF_NUMBER_NOPREPST: + case SwChapterFormat::Number: + nRet = text::ChapterFormat::NUMBER; + break; + case SwChapterFormat::Title: + nRet = text::ChapterFormat::NAME; + break; + case SwChapterFormat::NumberNoPrePost: nRet = text::ChapterFormat::DIGIT; - break; - case CF_NUM_NOPREPST_TITLE: + break; + case SwChapterFormat::NumberNoPrePostAndTitle: nRet = text::ChapterFormat::NO_PREFIX_SUFFIX; - break; - case CF_NUM_TITLE: - default: nRet = text::ChapterFormat::NAME_NUMBER; + break; + case SwChapterFormat::NumberAndTitle: + default: + nRet = text::ChapterFormat::NAME_NUMBER; } rAny <<= nRet; } @@ -288,19 +294,19 @@ bool SwChapterField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) switch( nVal ) { case text::ChapterFormat::NAME: - m_nFormat = CF_TITLE; + m_nFormat = SwChapterFormat::Title; break; case text::ChapterFormat::NUMBER: - m_nFormat = CF_NUMBER; + m_nFormat = SwChapterFormat::Number; break; case text::ChapterFormat::NO_PREFIX_SUFFIX: - m_nFormat = CF_NUM_NOPREPST_TITLE; + m_nFormat = SwChapterFormat::NumberNoPrePostAndTitle; break; case text::ChapterFormat::DIGIT: - m_nFormat = CF_NUMBER_NOPREPST; + m_nFormat = SwChapterFormat::NumberNoPrePost; break; default: - m_nFormat = CF_NUM_TITLE; + m_nFormat = SwChapterFormat::NumberAndTitle; } } break; diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index cf63b5c5c90c..c2a4cb3ef444 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -337,7 +337,7 @@ sal_uInt32 SwField::GetUntypedFormat() const case SwFieldIds::TemplateName: return static_cast<const SwTemplNameField*>(this)->GetFormat(); case SwFieldIds::Chapter: - return static_cast<const SwChapterField*>(this)->GetFormat(); + return static_cast<sal_uInt32>(static_cast<const SwChapterField*>(this)->GetFormat()); case SwFieldIds::Filename: return static_cast<const SwFileNameField*>(this)->GetFormat(); case SwFieldIds::Author: @@ -378,7 +378,7 @@ void SwField::SetUntypedFormat(sal_uInt32 n) static_cast<SwTemplNameField*>(this)->SetFormat(n); return; case SwFieldIds::Chapter: - static_cast<SwChapterField*>(this)->SetFormat(n); + static_cast<SwChapterField*>(this)->SetFormat(static_cast<SwChapterFormat>(n)); return; case SwFieldIds::Filename: static_cast<SwFileNameField*>(this)->SetFormat(n); diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index a346b468d2d2..280e070d8589 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -712,7 +712,7 @@ void SwGetRefField::UpdateField(const SwTextField* pFieldTextAttr, SwFrame* pFra if (pFrame) { SwChapterFieldType aFieldTyp; - SwChapterField aField(&aFieldTyp, 0); + SwChapterField aField(&aFieldTyp, SwChapterFormat::Number); aField.SetLevel(MAXLEVEL - 1); aField.ChangeExpansion(*pFrame, pTextNd, true); diff --git a/sw/source/core/tox/ToxTextGenerator.cxx b/sw/source/core/tox/ToxTextGenerator.cxx index 2ee7533cebdc..e4e9171a3559 100644 --- a/sw/source/core/tox/ToxTextGenerator.cxx +++ b/sw/source/core/tox/ToxTextGenerator.cxx @@ -154,12 +154,12 @@ ToxTextGenerator::GenerateTextForChapterToken(const SwFormToken& chapterToken, c //---> #i89791# // continue to support CF_NUMBER and CF_NUM_TITLE in order to handle ODF 1.0/1.1 written by OOo 3.x // in the same way as OOo 2.x would handle them. - if (CF_NUM_NOPREPST_TITLE == chapterToken.nChapterFormat || CF_NUMBER == chapterToken.nChapterFormat) { + if (SwChapterFormat::NumberNoPrePostAndTitle == chapterToken.nChapterFormat || SwChapterFormat::Number == chapterToken.nChapterFormat) { retval += aField.GetNumber(pLayout); // get the string number without pre/postfix } - else if (CF_NUMBER_NOPREPST == chapterToken.nChapterFormat || CF_NUM_TITLE == chapterToken.nChapterFormat) { + else if (SwChapterFormat::NumberNoPrePost == chapterToken.nChapterFormat || SwChapterFormat::NumberAndTitle == chapterToken.nChapterFormat) { retval += aField.GetNumber(pLayout) + " " + aField.GetTitle(pLayout); - } else if (CF_TITLE == chapterToken.nChapterFormat) { + } else if (SwChapterFormat::Title == chapterToken.nChapterFormat) { retval += aField.GetTitle(pLayout); } return retval; @@ -205,7 +205,7 @@ ToxTextGenerator::GenerateText(SwDoc& rDoc, // is the entry text: it can also be e.g. a tab, or the entry number can be used // in page number area like "2-15" for chapter 2, page 15. rText += GetNumStringOfFirstNode(rBase, - aToken.nChapterFormat == CF_NUMBER, + aToken.nChapterFormat == SwChapterFormat::Number, static_cast<sal_uInt8>(aToken.nOutlineLevel - 1), pLayout, i < aPattern.size() - 1 && aPattern[i + 1].eTokenType == TOKEN_ENTRY_TEXT); break; diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index 3a85782811e8..9d733bf5705b 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -732,7 +732,7 @@ OUString SwFormToken::GetString() const case TOKEN_CHAPTER_INFO: case TOKEN_ENTRY_NO: // add also maximum permitted level - sData += OUString::number( nChapterFormat ) + "," + sData += OUString::number( static_cast<sal_uInt16>(nChapterFormat) ) + "," + OUString::number( nOutlineLevel ); break; case TOKEN_TEXT: @@ -882,7 +882,7 @@ lcl_BuildToken(std::u16string_view sPattern, size_t & nCurPatternPos) case TOKEN_ENTRY_NO: sTmp = o3tl::getToken(sToken, 0, ',', nIdx ); // token 2 if( !sTmp.empty() ) - eRet.nChapterFormat = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(sTmp)); + eRet.nChapterFormat = static_cast<SwChapterFormat>(o3tl::toInt32(sTmp)); sTmp = o3tl::getToken(sToken, 0, ',', nIdx ); // token 3 if( !sTmp.empty() ) eRet.nOutlineLevel = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(sTmp)); //the maximum outline level to examine diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 21da418cb16c..62e5eaa05d16 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1465,7 +1465,7 @@ void SAL_CALL SwXTextField::attach( SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::Chapter); SwChapterField *const pChapterField = new SwChapterField( static_cast<SwChapterFieldType*>(pFieldType), - m_pImpl->m_pProps->nUSHORT1); + static_cast<SwChapterFormat>(m_pImpl->m_pProps->nUSHORT1)); xField.reset(pChapterField); pChapterField->SetLevel(m_pImpl->m_pProps->nByte1); uno::Any aVal; diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 946421dffeed..2c4709e95991 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -2726,24 +2726,23 @@ SwXDocumentIndex::TokenAccess_Impl::replaceByIndex( switch(nFormat) { case text::ChapterFormat::NUMBER: - nFormat = CF_NUMBER; + aToken.nChapterFormat = SwChapterFormat::Number; break; case text::ChapterFormat::NAME: - nFormat = CF_TITLE; + aToken.nChapterFormat = SwChapterFormat::Title; break; case text::ChapterFormat::NAME_NUMBER: - nFormat = CF_NUM_TITLE; + aToken.nChapterFormat = SwChapterFormat::NumberAndTitle; break; case text::ChapterFormat::NO_PREFIX_SUFFIX: - nFormat = CF_NUMBER_NOPREPST; + aToken.nChapterFormat = SwChapterFormat::NumberNoPrePost; break; case text::ChapterFormat::DIGIT: - nFormat = CF_NUM_NOPREPST_TITLE; + aToken.nChapterFormat = SwChapterFormat::NumberNoPrePostAndTitle; break; default: throw lang::IllegalArgumentException(); } - aToken.nChapterFormat = nFormat; } // #i53420# else if ( pProperties[j].Name == "ChapterLevel" ) @@ -2792,8 +2791,8 @@ SwXDocumentIndex::TokenAccess_Impl::replaceByIndex( { switch(aToken.nChapterFormat) { - case CF_NUMBER: - case CF_NUM_NOPREPST_TITLE: + case SwChapterFormat::Number: + case SwChapterFormat::NumberNoPrePostAndTitle: break; default: throw lang::IllegalArgumentException(); @@ -2865,7 +2864,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) sal_Int32 nCurrentElement = 0; // check for default value - if (aToken.nChapterFormat != CF_NUMBER) + if (aToken.nChapterFormat != SwChapterFormat::Number) { nElements++;//we need the element } @@ -2884,7 +2883,7 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[nCurrentElement].Name = "CharacterStyleName"; pArr[nCurrentElement++].Value <<= aProgCharStyle.toString(); - if( aToken.nChapterFormat != CF_NUMBER ) + if( aToken.nChapterFormat != SwChapterFormat::Number ) { pArr[nCurrentElement].Name = "ChapterFormat"; sal_Int16 nVal; @@ -2894,10 +2893,10 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) switch(aToken.nChapterFormat) { default: - case CF_NUMBER: + case SwChapterFormat::Number: nVal = text::ChapterFormat::NUMBER; break; - case CF_NUM_NOPREPST_TITLE: + case SwChapterFormat::NumberNoPrePostAndTitle: nVal = text::ChapterFormat::DIGIT; break; } @@ -2997,19 +2996,19 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) sal_Int16 nVal = text::ChapterFormat::NUMBER; switch(aToken.nChapterFormat) { - case CF_NUMBER: + case SwChapterFormat::Number: nVal = text::ChapterFormat::NUMBER; break; - case CF_TITLE: + case SwChapterFormat::Title: nVal = text::ChapterFormat::NAME; break; - case CF_NUM_TITLE: + case SwChapterFormat::NumberAndTitle: nVal = text::ChapterFormat::NAME_NUMBER; break; - case CF_NUMBER_NOPREPST: + case SwChapterFormat::NumberNoPrePost: nVal = text::ChapterFormat::NO_PREFIX_SUFFIX; break; - case CF_NUM_NOPREPST_TITLE: + case SwChapterFormat::NumberNoPrePostAndTitle: nVal = text::ChapterFormat::DIGIT; break; } diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 1d7ea27a60a9..327195086fdb 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -1577,7 +1577,7 @@ eF_ResT SwWW8ImplReader::Read_F_Styleref(WW8FieldDesc*, OUString& rString) return eF_ResT::TAGIGN; SwFieldType* pFieldType = m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::Chapter); - SwChapterField aField(static_cast<SwChapterFieldType*>(pFieldType), CF_TITLE); + SwChapterField aField(static_cast<SwChapterFieldType*>(pFieldType), SwChapterFormat::Title); aField.SetLevel(nResult - 1); m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SwFormatField(aField)); diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index b92e80a650fe..45b19c75e9fb 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -1787,10 +1787,10 @@ public: { default: case 0: - m_aFormToken.nChapterFormat = CF_NUMBER; + m_aFormToken.nChapterFormat = SwChapterFormat::Number; break; case 1: - m_aFormToken.nChapterFormat = CF_NUM_NOPREPST_TITLE; + m_aFormToken.nChapterFormat = SwChapterFormat::NumberNoPrePostAndTitle; break; } } @@ -1800,13 +1800,13 @@ public: { default: case 0: - m_aFormToken.nChapterFormat = CF_NUM_NOPREPST_TITLE; + m_aFormToken.nChapterFormat = SwChapterFormat::NumberNoPrePostAndTitle; break; case 1: - m_aFormToken.nChapterFormat = CF_TITLE; + m_aFormToken.nChapterFormat = SwChapterFormat::Title; break; case 2: - m_aFormToken.nChapterFormat = CF_NUMBER_NOPREPST; + m_aFormToken.nChapterFormat = SwChapterFormat::NumberNoPrePost; break; } } @@ -2383,7 +2383,7 @@ IMPL_LINK(SwTOXEntryTabPage, InsertTokenHdl, weld::Button&, rBtn, void) { FormTokenType eTokenType = TOKEN_ENTRY_NO; OUString sCharStyle; - sal_uInt16 nChapterFormat = CF_NUMBER; // i89791 + SwChapterFormat nChapterFormat = SwChapterFormat::Number; // i89791 if (&rBtn == m_xEntryNoPB.get()) { eTokenType = TOKEN_ENTRY_NO; @@ -2402,7 +2402,7 @@ IMPL_LINK(SwTOXEntryTabPage, InsertTokenHdl, weld::Button&, rBtn, void) else if (&rBtn == m_xChapterInfoPB.get()) { eTokenType = TOKEN_CHAPTER_INFO; - nChapterFormat = CF_NUM_NOPREPST_TITLE; // i89791 + nChapterFormat = SwChapterFormat::NumberNoPrePostAndTitle; // i89791 } else if (&rBtn == m_xPageNoPB.get()) { @@ -2522,13 +2522,13 @@ IMPL_LINK(SwTOXEntryTabPage, TokenSelectedHdl, SwFormToken&, rToken, void) default: m_xChapterEntryLB->set_active(-1);//to alert the user break; - case CF_NUM_NOPREPST_TITLE: + case SwChapterFormat::NumberNoPrePostAndTitle: m_xChapterEntryLB->set_active(0); break; - case CF_TITLE: + case SwChapterFormat::Title: m_xChapterEntryLB->set_active(1); break; - case CF_NUMBER_NOPREPST: + case SwChapterFormat::NumberNoPrePost: m_xChapterEntryLB->set_active(2); break; } @@ -2542,7 +2542,7 @@ IMPL_LINK(SwTOXEntryTabPage, TokenSelectedHdl, SwFormToken&, rToken, void) { m_xEntryOutlineLevelNF->set_value(rToken.nOutlineLevel); const sal_uInt16 nFormat = - rToken.nChapterFormat == CF_NUM_NOPREPST_TITLE ? 1 : 0; + rToken.nChapterFormat == SwChapterFormat::NumberNoPrePostAndTitle ? 1 : 0; m_xNumberFormatLB->set_active(nFormat); } diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 4bf949757952..ac571cf5be19 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -997,7 +997,7 @@ bool SwFieldMgr::InsertField( sal_uInt16 nByte = o3tl::narrowing<sal_uInt16>(rData.m_sPar2.toInt32()); SwChapterFieldType* pTyp = static_cast<SwChapterFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Chapter) ); - pField.reset(new SwChapterField(pTyp, nFormatId)); + pField.reset(new SwChapterField(pTyp, static_cast<SwChapterFormat>(nFormatId))); nByte = std::max(sal_uInt16(1), nByte); nByte = std::min(nByte, sal_uInt16(MAXLEVEL)); nByte -= 1;