diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-09-20 15:18:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-09-20 18:21:50 +0200 |
commit | ebdf70cc68989d209965768edc8a3bdf27543c48 (patch) | |
tree | d89afb49072248692cc355bf24402fa6d66898ad | |
parent | e15297a72e3483a6e5641253920e71f6e4570c28 (diff) |
convert SwFieldTypesEnum to scoped enum
clamp it to sal_uInt16 since we convert it that type when passing
it via SfxItemSet
Change-Id: I4b7bd4ba5e19015af357d5a81a629239451d71e4
Reviewed-on: https://gerrit.libreoffice.org/79289
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
38 files changed, 658 insertions, 642 deletions
diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index e6afd73af156..cb6f0c2159c2 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -295,7 +295,7 @@ class SW_DLLPUBLIC SwHiddenTextField : public SwField OUString m_aContent; ///< Evaluated DB-text. OUString m_aCond; ///< Condition. - sal_uInt16 m_nSubType; + SwFieldTypesEnum m_nSubType; bool m_bCanToggle : 1; ///< Can field be toggled alone? bool m_bIsHidden : 1; ///< Is it not visible? @@ -310,13 +310,13 @@ public: const OUString& rCond, const OUString& rText, bool bHidden, - sal_uInt16 nSubType = TYP_HIDDENTXTFLD); + SwFieldTypesEnum nSubType = SwFieldTypesEnum::HiddenText); SwHiddenTextField( SwHiddenTextFieldType*, const OUString& rCond, const OUString& rTrue, const OUString& rFalse, - sal_uInt16 nSubType = TYP_HIDDENTXTFLD); + SwFieldTypesEnum nSubType = SwFieldTypesEnum::HiddenText); virtual OUString GetFieldName() const override; diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index aafce0c4c718..664f74b45242 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -84,54 +84,55 @@ enum class SwFieldIds : sal_uInt16 { }; /// List of FieldTypes at UI. -enum SwFieldTypesEnum { - TYP_BEGIN, - TYP_DATEFLD = TYP_BEGIN, // 0 - TYP_TIMEFLD, - TYP_FILENAMEFLD, - TYP_DBNAMEFLD, - TYP_CHAPTERFLD, - TYP_PAGENUMBERFLD, - TYP_DOCSTATFLD, - TYP_AUTHORFLD, - TYP_SETFLD, - TYP_GETFLD, - TYP_FORMELFLD, // 10 - TYP_HIDDENTXTFLD, - TYP_SETREFFLD, - TYP_GETREFFLD, - TYP_DDEFLD, - TYP_MACROFLD, - TYP_INPUTFLD, - TYP_HIDDENPARAFLD, - TYP_DOCINFOFLD, - TYP_DBFLD, - TYP_USERFLD, // 20 - TYP_POSTITFLD, - TYP_TEMPLNAMEFLD, - TYP_SEQFLD, - TYP_DBNEXTSETFLD, - TYP_DBNUMSETFLD, - TYP_DBSETNUMBERFLD, - TYP_CONDTXTFLD, - TYP_NEXTPAGEFLD, - TYP_PREVPAGEFLD, - TYP_EXTUSERFLD, // 30 - TYP_FIXDATEFLD, - TYP_FIXTIMEFLD, - TYP_SETINPFLD, - TYP_USRINPFLD, - TYP_SETREFPAGEFLD, - TYP_GETREFPAGEFLD, - TYP_INTERNETFLD, - TYP_JUMPEDITFLD, - TYP_SCRIPTFLD, - TYP_AUTHORITY, // 40 - TYP_COMBINED_CHARS, - TYP_DROPDOWN, - TYP_CUSTOM, // Unused - necessary for alignment with aSwFields in fldmgr.cxx - TYP_PARAGRAPHSIGFLD, - TYP_END +enum class SwFieldTypesEnum : sal_uInt16 { + Begin, + Date = Begin, // 0 + Time, + Filename, + DatabaseName, + Chapter, + PageNumber, + DocumentStatistics, + Author, + Set, + Get, + Formel, // 10 + HiddenText, + SetRef, + GetRef, + DDE, + Macro, + Input, + HiddenParagraph, + DocumentInfo, + Database, + User, // 20 + Postit, + TemplateName, + Sequence, + DatabaseNextSet, + DatabaseNumberSet, + DatabaseSetNumber, + ConditionalText, + NextPage, + PreviousPage, + ExtendedUser, // 30 + FixedDate, + FixedTime, + SetInput, + UserInput, + SetRefPage, + GetRefPage, + Internet, + JumpEdit, + Script, + Authority, // 40 + CombinedChars, + Dropdown, + Custom, // Unused - necessary for alignment with aSwFields in fldmgr.cxx + ParagraphSignature, + LAST, + Unknown = USHRT_MAX // used by SwFieldMgr::GetCurTypeId }; enum SwAttrFieldType { ATTR_NONE, @@ -254,7 +255,7 @@ public: m_wXFieldMaster = xFieldMaster; } - static OUString GetTypeStr( sal_uInt16 nTypeId ); + static OUString GetTypeStr( SwFieldTypesEnum nTypeId ); /// Only in derived classes. virtual OUString GetName() const; @@ -340,7 +341,7 @@ public: #endif // TYP_ID - sal_uInt16 GetTypeId() const; + SwFieldTypesEnum GetTypeId() const; virtual sal_uInt16 GetSubType() const; virtual void SetSubType(sal_uInt16); diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx index a2140e497ce2..41b4352eee7a 100644 --- a/sw/source/core/bastyp/calc.cxx +++ b/sw/source/core/bastyp/calc.cxx @@ -496,7 +496,7 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns ) OUString sColumnName( GetColumnName( sTmpName )); OSL_ENSURE(!sColumnName.isEmpty(), "Missing DB column name"); - OUString sDBNum( SwFieldType::GetTypeStr(TYP_DBSETNUMBERFLD) ); + OUString sDBNum( SwFieldType::GetTypeStr(SwFieldTypesEnum::DatabaseSetNumber) ); sDBNum = m_pCharClass->lowercase(sDBNum); // Initialize again because this doesn't happen in docfld anymore for @@ -543,7 +543,7 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns ) OUString sColumnName( GetColumnName( sTmpName )); OSL_ENSURE( !sColumnName.isEmpty(), "Missing DB column name" ); if( sColumnName.equalsIgnoreAsciiCase( - SwFieldType::GetTypeStr( TYP_DBSETNUMBERFLD ) )) + SwFieldType::GetTypeStr( SwFieldTypesEnum::DatabaseSetNumber ) )) { #if HAVE_FEATURE_DBCONNECTIVITY SwDBManager *pMgr = m_rDoc.GetDBManager(); diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index 7f7a5b9e1c74..a76701348a1d 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -90,7 +90,7 @@ namespace sDBNumNm = aDBData.sDataSource + OUStringLiteral1(DB_DELIM) + aDBData.sCommand + OUStringLiteral1(DB_DELIM); } - sDBNumNm += SwFieldType::GetTypeStr(TYP_DBSETNUMBERFLD); + sDBNumNm += SwFieldType::GetTypeStr(SwFieldTypesEnum::DatabaseSetNumber); return sDBNumNm; } @@ -981,7 +981,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl( SwCalc aCalc( m_rDoc ); #if HAVE_FEATURE_DBCONNECTIVITY - OUString sDBNumNm( SwFieldType::GetTypeStr( TYP_DBSETNUMBERFLD ) ); + OUString sDBNumNm( SwFieldType::GetTypeStr( SwFieldTypesEnum::DatabaseSetNumber ) ); // already set the current record number SwDBManager* pMgr = m_rDoc.GetDBManager(); diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 19da42aa5cf8..0a7fa64efd7b 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -1270,11 +1270,11 @@ SwHiddenTextField::SwHiddenTextField( SwHiddenTextFieldType* pFieldType, const OUString& rCond, const OUString& rStr, bool bHidden, - sal_uInt16 nSub) : + SwFieldTypesEnum nSub) : SwField( pFieldType ), m_aCond(rCond), m_nSubType(nSub), m_bCanToggle(bConditional), m_bIsHidden(bHidden), m_bValid(false) { - if(m_nSubType == TYP_CONDTXTFLD) + if(m_nSubType == SwFieldTypesEnum::ConditionalText) { sal_Int32 nPos = 0; m_aTRUEText = rStr.getToken(0, '|', nPos); @@ -1297,7 +1297,7 @@ SwHiddenTextField::SwHiddenTextField( SwHiddenTextFieldType* pFieldType, const OUString& rCond, const OUString& rTrue, const OUString& rFalse, - sal_uInt16 nSub) + SwFieldTypesEnum nSub) : SwField( pFieldType ), m_aTRUEText(rTrue), m_aFALSEText(rFalse), m_aCond(rCond), m_nSubType(nSub), m_bIsHidden(true), m_bValid(false) { @@ -1309,7 +1309,7 @@ OUString SwHiddenTextField::ExpandImpl(SwRootFrame const*const) const // Type: !Hidden -> show always // Hide -> evaluate condition - if( TYP_CONDTXTFLD == m_nSubType ) + if( SwFieldTypesEnum::ConditionalText == m_nSubType ) { if( m_bValid ) return m_aContent; @@ -1329,7 +1329,7 @@ void SwHiddenTextField::Evaluate(SwDoc* pDoc) { OSL_ENSURE(pDoc, "got no document"); - if( TYP_CONDTXTFLD == m_nSubType ) + if( SwFieldTypesEnum::ConditionalText == m_nSubType ) { #if !HAVE_FEATURE_DBCONNECTIVITY (void) pDoc; @@ -1387,7 +1387,7 @@ OUString SwHiddenTextField::GetFieldName() const OUString aStr = SwFieldType::GetTypeStr(m_nSubType) + " " + m_aCond + " " + m_aTRUEText; - if (m_nSubType == TYP_CONDTXTFLD) + if (m_nSubType == SwFieldTypesEnum::ConditionalText) { aStr += " : " + m_aFALSEText; } @@ -1422,7 +1422,7 @@ OUString SwHiddenTextField::GetPar1() const /// set True/False text void SwHiddenTextField::SetPar2(const OUString& rStr) { - if (m_nSubType == TYP_CONDTXTFLD) + if (m_nSubType == SwFieldTypesEnum::ConditionalText) { sal_Int32 nPos = rStr.indexOf('|'); if (nPos == -1) @@ -1440,7 +1440,7 @@ void SwHiddenTextField::SetPar2(const OUString& rStr) /// get True/False text OUString SwHiddenTextField::GetPar2() const { - if(m_nSubType != TYP_CONDTXTFLD) + if(m_nSubType != SwFieldTypesEnum::ConditionalText) { return m_aTRUEText; } @@ -1449,7 +1449,7 @@ OUString SwHiddenTextField::GetPar2() const sal_uInt16 SwHiddenTextField::GetSubType() const { - return m_nSubType; + return static_cast<sal_uInt16>(m_nSubType); } bool SwHiddenTextField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 9c90867d5924..3490d548ad1b 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -315,10 +315,10 @@ OUString SwGetExpField::ExpandImpl(SwRootFrame const*const pLayout) const OUString SwGetExpField::GetFieldName() const { - const sal_uInt16 nType = static_cast<sal_uInt16>( + const SwFieldTypesEnum nType = (nsSwGetSetExpType::GSE_FORMULA & m_nSubType) - ? TYP_FORMELFLD - : TYP_GETFLD); + ? SwFieldTypesEnum::Formel + : SwFieldTypesEnum::Get; return SwFieldType::GetTypeStr(nType) + " " + GetFormula(); } @@ -855,18 +855,18 @@ OUString SwSetExpField::ExpandImpl(SwRootFrame const*const pLayout) const OUString SwSetExpField::GetFieldName() const { SwFieldTypesEnum const nStrType( (IsSequenceField()) - ? TYP_SEQFLD + ? SwFieldTypesEnum::Sequence : mbInput - ? TYP_SETINPFLD - : TYP_SETFLD ); + ? SwFieldTypesEnum::SetInput + : SwFieldTypesEnum::Set ); OUString aStr( - SwFieldType::GetTypeStr( static_cast<sal_uInt16>(nStrType) ) + SwFieldType::GetTypeStr( nStrType ) + " " + GetTyp()->GetName() ); // Sequence: without formula - if (TYP_SEQFLD != nStrType) + if (SwFieldTypesEnum::Sequence != nStrType) { aStr += " = " + GetFormula(); } diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index a5008b4c4e3a..c46e5bfd3824 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -80,59 +80,57 @@ namespace { const o3tl::enumarray<SwFieldIds,SwFieldTypesEnum> aTypeTab { - /* SwFieldIds::Database */ TYP_DBFLD, - /* SwFieldIds::User */ TYP_USERFLD, - /* SwFieldIds::Filename */ TYP_FILENAMEFLD, - /* SwFieldIds::DatabaseName */ TYP_DBNAMEFLD, - /* SwFieldIds::Date */ TYP_DATEFLD, - /* SwFieldIds::Time */ TYP_TIMEFLD, - /* SwFieldIds::PageNumber */ TYP_PAGENUMBERFLD, // dynamic - /* SwFieldIds::Author */ TYP_AUTHORFLD, - /* SwFieldIds::Chapter */ TYP_CHAPTERFLD, - /* SwFieldIds::DocStat */ TYP_DOCSTATFLD, - /* SwFieldIds::GetExp */ TYP_GETFLD, // dynamic - /* SwFieldIds::SetExp */ TYP_SETFLD, // dynamic - /* SwFieldIds::GetRef */ TYP_GETREFFLD, - /* SwFieldIds::HiddenText */ TYP_HIDDENTXTFLD, - /* SwFieldIds::Postit */ TYP_POSTITFLD, - /* SwFieldIds::FixDate */ TYP_FIXDATEFLD, - /* SwFieldIds::FixTime */ TYP_FIXTIMEFLD, - /* SwFieldIds::Reg */ TYP_BEGIN, // old (no change since 2000) - /* SwFieldIds::VarReg */ TYP_BEGIN, // old (no change since 2000) - /* SwFieldIds::SetRef */ TYP_SETREFFLD, - /* SwFieldIds::Input */ TYP_INPUTFLD, - /* SwFieldIds::Macro */ TYP_MACROFLD, - /* SwFieldIds::Dde */ TYP_DDEFLD, - /* SwFieldIds::Table */ TYP_FORMELFLD, - /* SwFieldIds::HiddenPara */ TYP_HIDDENPARAFLD, - /* SwFieldIds::DocInfo */ TYP_DOCINFOFLD, - /* SwFieldIds::TemplateName */ TYP_TEMPLNAMEFLD, - /* SwFieldIds::DbNextSet */ TYP_DBNEXTSETFLD, - /* SwFieldIds::DbNumSet */ TYP_DBNUMSETFLD, - /* SwFieldIds::DbSetNumber */ TYP_DBSETNUMBERFLD, - /* SwFieldIds::ExtUser */ TYP_EXTUSERFLD, - /* SwFieldIds::RefPageSet */ TYP_SETREFPAGEFLD, - /* SwFieldIds::RefPageGet */ TYP_GETREFPAGEFLD, - /* SwFieldIds::Internet */ TYP_INTERNETFLD, - /* SwFieldIds::JumpEdit */ TYP_JUMPEDITFLD, - /* SwFieldIds::Script */ TYP_SCRIPTFLD, - /* SwFieldIds::DateTime */ TYP_BEGIN, // dynamic - /* SwFieldIds::TableOfAuthorities*/ TYP_AUTHORITY, - /* SwFieldIds::CombinedChars */ TYP_COMBINED_CHARS, - /* SwFieldIds::Dropdown */ TYP_DROPDOWN, - /* SwFieldIds::ParagraphSignature */ TYP_PARAGRAPHSIGFLD + /* SwFieldIds::Database */ SwFieldTypesEnum::Database, + /* SwFieldIds::User */ SwFieldTypesEnum::User, + /* SwFieldIds::Filename */ SwFieldTypesEnum::Filename, + /* SwFieldIds::DatabaseName */ SwFieldTypesEnum::DatabaseName, + /* SwFieldIds::Date */ SwFieldTypesEnum::Date, + /* SwFieldIds::Time */ SwFieldTypesEnum::Time, + /* SwFieldIds::PageNumber */ SwFieldTypesEnum::PageNumber, // dynamic + /* SwFieldIds::Author */ SwFieldTypesEnum::Author, + /* SwFieldIds::Chapter */ SwFieldTypesEnum::Chapter, + /* SwFieldIds::DocStat */ SwFieldTypesEnum::DocumentStatistics, + /* SwFieldIds::GetExp */ SwFieldTypesEnum::Get, // dynamic + /* SwFieldIds::SetExp */ SwFieldTypesEnum::Set, // dynamic + /* SwFieldIds::GetRef */ SwFieldTypesEnum::GetRef, + /* SwFieldIds::HiddenText */ SwFieldTypesEnum::HiddenText, + /* SwFieldIds::Postit */ SwFieldTypesEnum::Postit, + /* SwFieldIds::FixDate */ SwFieldTypesEnum::FixedDate, + /* SwFieldIds::FixTime */ SwFieldTypesEnum::FixedTime, + /* SwFieldIds::Reg */ SwFieldTypesEnum::Begin, // old (no change since 2000) + /* SwFieldIds::VarReg */ SwFieldTypesEnum::Begin, // old (no change since 2000) + /* SwFieldIds::SetRef */ SwFieldTypesEnum::SetRef, + /* SwFieldIds::Input */ SwFieldTypesEnum::Input, + /* SwFieldIds::Macro */ SwFieldTypesEnum::Macro, + /* SwFieldIds::Dde */ SwFieldTypesEnum::DDE, + /* SwFieldIds::Table */ SwFieldTypesEnum::Formel, + /* SwFieldIds::HiddenPara */ SwFieldTypesEnum::HiddenParagraph, + /* SwFieldIds::DocInfo */ SwFieldTypesEnum::DocumentInfo, + /* SwFieldIds::TemplateName */ SwFieldTypesEnum::TemplateName, + /* SwFieldIds::DbNextSet */ SwFieldTypesEnum::DatabaseNextSet, + /* SwFieldIds::DbNumSet */ SwFieldTypesEnum::DatabaseNumberSet, + /* SwFieldIds::DbSetNumber */ SwFieldTypesEnum::DatabaseSetNumber, + /* SwFieldIds::ExtUser */ SwFieldTypesEnum::ExtendedUser, + /* SwFieldIds::RefPageSet */ SwFieldTypesEnum::SetRefPage, + /* SwFieldIds::RefPageGet */ SwFieldTypesEnum::GetRefPage, + /* SwFieldIds::Internet */ SwFieldTypesEnum::Internet, + /* SwFieldIds::JumpEdit */ SwFieldTypesEnum::JumpEdit, + /* SwFieldIds::Script */ SwFieldTypesEnum::Script, + /* SwFieldIds::DateTime */ SwFieldTypesEnum::Begin, // dynamic + /* SwFieldIds::TableOfAuthorities*/ SwFieldTypesEnum::Authority, + /* SwFieldIds::CombinedChars */ SwFieldTypesEnum::CombinedChars, + /* SwFieldIds::Dropdown */ SwFieldTypesEnum::Dropdown, + /* SwFieldIds::ParagraphSignature */ SwFieldTypesEnum::ParagraphSignature }; } -OUString SwFieldType::GetTypeStr(sal_uInt16 nTypeId) +OUString SwFieldType::GetTypeStr(SwFieldTypesEnum nTypeId) { if (!s_pFieldNames) GetFieldName_(); - if (nTypeId < SwFieldType::s_pFieldNames->size()) - return (*SwFieldType::s_pFieldNames)[nTypeId]; - return OUString(); + return (*SwFieldType::s_pFieldNames)[static_cast<int>(nTypeId)]; } // each field references a field type that is unique for each document @@ -206,43 +204,45 @@ SwFieldIds SwField::Which() const } #endif -sal_uInt16 SwField::GetTypeId() const +SwFieldTypesEnum SwField::GetTypeId() const { - sal_uInt16 nRet; + SwFieldTypesEnum nRet; switch (m_pType->Which()) { case SwFieldIds::DateTime: if (GetSubType() & FIXEDFLD) - nRet = static_cast<sal_uInt16>(GetSubType() & DATEFLD ? TYP_FIXDATEFLD : TYP_FIXTIMEFLD); + nRet = GetSubType() & DATEFLD ? SwFieldTypesEnum::FixedDate : SwFieldTypesEnum::FixedTime; else - nRet = static_cast<sal_uInt16>(GetSubType() & DATEFLD ? TYP_DATEFLD : TYP_TIMEFLD); + nRet = GetSubType() & DATEFLD ? SwFieldTypesEnum::Date : SwFieldTypesEnum::Time; break; case SwFieldIds::GetExp: - nRet = static_cast<sal_uInt16>(nsSwGetSetExpType::GSE_FORMULA & GetSubType() ? TYP_FORMELFLD : TYP_GETFLD); + nRet = nsSwGetSetExpType::GSE_FORMULA & GetSubType() ? SwFieldTypesEnum::Formel : SwFieldTypesEnum::Get; break; case SwFieldIds::HiddenText: - nRet = GetSubType(); + nRet = static_cast<SwFieldTypesEnum>(GetSubType()); break; case SwFieldIds::SetExp: if( nsSwGetSetExpType::GSE_SEQ & GetSubType() ) - nRet = TYP_SEQFLD; + nRet = SwFieldTypesEnum::Sequence; else if( static_cast<const SwSetExpField*>(this)->GetInputFlag() ) - nRet = TYP_SETINPFLD; + nRet = SwFieldTypesEnum::SetInput; else - nRet = TYP_SETFLD; + nRet = SwFieldTypesEnum::Set; break; case SwFieldIds::PageNumber: - nRet = GetSubType(); - if( PG_NEXT == nRet ) - nRet = TYP_NEXTPAGEFLD; - else if( PG_PREV == nRet ) - nRet = TYP_PREVPAGEFLD; - else - nRet = TYP_PAGENUMBERFLD; + { + auto nSubType = GetSubType(); + if( PG_NEXT == nSubType ) + nRet = SwFieldTypesEnum::NextPage; + else if( PG_PREV == nSubType ) + nRet = SwFieldTypesEnum::PreviousPage; + else + nRet = SwFieldTypesEnum::PageNumber; + } break; default: @@ -254,11 +254,11 @@ sal_uInt16 SwField::GetTypeId() const /// get name or content OUString SwField::GetFieldName() const { - sal_uInt16 nTypeId = GetTypeId(); + SwFieldTypesEnum nTypeId = GetTypeId(); if (SwFieldIds::DateTime == GetTyp()->Which()) { - nTypeId = static_cast<sal_uInt16>( - ((GetSubType() & DATEFLD) != 0) ? TYP_DATEFLD : TYP_TIMEFLD); + nTypeId = + ((GetSubType() & DATEFLD) != 0) ? SwFieldTypesEnum::Date : SwFieldTypesEnum::Time; } OUString sRet = SwFieldType::GetTypeStr( nTypeId ); if (IsFixed()) @@ -415,7 +415,7 @@ SwField::ExpandField(bool const bCached, SwRootFrame const*const pLayout) const { if (!bCached) // #i85766# do not expand fields in clipboard documents { - if (GetTypeId() == TYP_AUTHORITY) + if (GetTypeId() == SwFieldTypesEnum::Authority) { const SwAuthorityField* pAuthorityField = static_cast<const SwAuthorityField*>(this); m_Cache = pAuthorityField->ConditionalExpandAuthIdentifier(pLayout); diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx index 89ef18611115..56c8ff44b318 100644 --- a/sw/source/core/fields/usrfld.cxx +++ b/sw/source/core/fields/usrfld.cxx @@ -79,7 +79,7 @@ std::unique_ptr<SwField> SwUserField::Copy() const OUString SwUserField::GetFieldName() const { - return SwFieldType::GetTypeStr(TYP_USERFLD) + + return SwFieldType::GetTypeStr(SwFieldTypesEnum::User) + " " + GetTyp()->GetName() + " = " + static_cast<SwUserFieldType*>(GetTyp())->GetContent(); } diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 9e7644dd7f8e..622eaf732c76 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -1324,7 +1324,7 @@ Size SwFEShell::RequestObjectResize( const SwRect &rRect, const uno::Reference < { const SfxPoolItem* pItem = &pHint->GetAttr(); if( RES_TXTATR_FIELD == pItem->Which() - && TYP_SEQFLD == static_cast<const SwFormatField*>(pItem)->GetField()->GetTypeId() ) + && SwFieldTypesEnum::Sequence == static_cast<const SwFormatField*>(pItem)->GetField()->GetTypeId() ) { // sequence field found SwFlyFrame* pChgFly = const_cast<SwFlyFrame*>(static_cast<const SwFlyFrame*>(pAnchor->GetUpper())); diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index f550aed40da8..4723ba3e5fe6 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2518,7 +2518,7 @@ sal_uLong SwTableBox::IsValidNumTextNd( bool bCheckAttr ) const // should not turn cell into text cell const SwField* pField = pAttr->GetFormatField().GetField(); if (pField && - (pField->GetTypeId() == TYP_SETFLD) && + (pField->GetTypeId() == SwFieldTypesEnum::Set) && (0 != (static_cast<SwSetExpField const*> (pField)->GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE))) diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index a23a88b85121..cbf34d1ffb5d 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -245,7 +245,7 @@ static SwServiceType lcl_GetServiceForField( const SwField& rField ) break; case SwFieldIds::HiddenText: - nSrvId = TYP_CONDTXTFLD == rField.GetSubType() + nSrvId = SwFieldTypesEnum::ConditionalText == static_cast<SwFieldTypesEnum>(rField.GetSubType()) ? SwServiceType::FieldTypeConditionedText : SwServiceType::FieldTypeHiddenText; break; @@ -1534,8 +1534,8 @@ void SAL_CALL SwXTextField::attach( static_cast<SwHiddenTextFieldType*>(pFieldType), m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar2, m_pImpl->m_pProps->sPar3, - static_cast<sal_uInt16>(SwServiceType::FieldTypeHiddenText == m_pImpl->m_nServiceId ? - TYP_HIDDENTXTFLD : TYP_CONDTXTFLD)); + SwServiceType::FieldTypeHiddenText == m_pImpl->m_nServiceId ? + SwFieldTypesEnum::HiddenText : SwFieldTypesEnum::ConditionalText); xField.reset(pHTField); pHTField->SetValue(m_pImpl->m_pProps->bBool1); uno::Any aVal; diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index b44ad01485bc..cddefb0002da 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -610,7 +610,7 @@ sal_uInt16 SwWW8ImplReader::End_Field() paramCondition, paramTrue, paramFalse, - static_cast<sal_uInt16>(TYP_CONDTXTFLD)); + SwFieldTypesEnum::ConditionalText); // insert new field into document m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SwFormatField(aHTField)); diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx index b932724bd5b2..0af4778387fe 100644 --- a/sw/source/ui/config/optload.cxx +++ b/sw/source/ui/config/optload.cxx @@ -495,11 +495,11 @@ SwCaptionOptPage::SwCaptionOptPage(TabPageParent pParent, const SfxItemSet& rSet ::FillCharStyleListBox( *m_xCharStyleLB, pSh->GetView().GetDocShell(), true, true ); } - const sal_uInt16 nCount = pMgr->GetFormatCount(TYP_SEQFLD, false); + const sal_uInt16 nCount = pMgr->GetFormatCount(SwFieldTypesEnum::Sequence, false); for ( sal_uInt16 i = 0; i < nCount; ++i ) { - const sal_uInt16 nFormatId = pMgr->GetFormatId(TYP_SEQFLD, i); - m_xFormatBox->append(OUString::number(nFormatId), pMgr->GetFormatStr(TYP_SEQFLD, i)); + const sal_uInt16 nFormatId = pMgr->GetFormatId(SwFieldTypesEnum::Sequence, i); + m_xFormatBox->append(OUString::number(nFormatId), pMgr->GetFormatStr(SwFieldTypesEnum::Sequence, i)); if (nFormatId == nSelFormat) m_xFormatBox->set_active(i); } diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx index 95a27bf16615..83e4f1f0868d 100644 --- a/sw/source/ui/dbui/mmlayoutpage.cxx +++ b/sw/source/ui/dbui/mmlayoutpage.cxx @@ -356,7 +356,7 @@ SwFrameFormat* SwMailMergeLayoutPage::InsertAddressFrame( if( !rExcludeCountry.isEmpty() ) { const OUString sExpression("[" + sDatabaseConditionPrefix + sCountryColumn + "]"); - SwInsertField_Data aData(TYP_CONDTXTFLD, 0, + SwInsertField_Data aData(SwFieldTypesEnum::ConditionalText, 0, sExpression + " != \"" + rExcludeCountry + "\"", sExpression, 0, &rShell ); @@ -364,13 +364,13 @@ SwFrameFormat* SwMailMergeLayoutPage::InsertAddressFrame( } else { - SwInsertField_Data aData(TYP_HIDDENPARAFLD, 0, "", "", 0, &rShell ); + SwInsertField_Data aData(SwFieldTypesEnum::HiddenParagraph, 0, "", "", 0, &rShell ); aFieldMgr.InsertField( aData ); } } else { - SwInsertField_Data aData(TYP_DBFLD, 0, sDB, OUString(), 0, &rShell); + SwInsertField_Data aData(SwFieldTypesEnum::Database, 0, sDB, OUString(), 0, &rShell); aFieldMgr.InsertField( aData ); } } @@ -382,7 +382,7 @@ SwFrameFormat* SwMailMergeLayoutPage::InsertAddressFrame( { if(bHideEmptyParagraphs) { - SwInsertField_Data aData(TYP_HIDDENPARAFLD, 0, sHideParagraphsExpression, OUString(), 0, &rShell); + SwInsertField_Data aData(SwFieldTypesEnum::HiddenParagraph, 0, sHideParagraphsExpression, OUString(), 0, &rShell); aFieldMgr.InsertField( aData ); } sHideParagraphsExpression.clear(); @@ -392,7 +392,7 @@ SwFrameFormat* SwMailMergeLayoutPage::InsertAddressFrame( } if(bHideEmptyParagraphs && !sHideParagraphsExpression.isEmpty()) { - SwInsertField_Data aData(TYP_HIDDENPARAFLD, 0, sHideParagraphsExpression, OUString(), 0, &rShell); + SwInsertField_Data aData(SwFieldTypesEnum::HiddenParagraph, 0, sHideParagraphsExpression, OUString(), 0, &rShell); aFieldMgr.InsertField( aData ); } } @@ -532,12 +532,12 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig if(bHideEmptyParagraphs && !sHideParagraphsExpression.isEmpty()) { OUString sComplete = "(" + sCondition + ") OR (" + sHideParagraphsExpression + ")"; - SwInsertField_Data aData(TYP_HIDDENPARAFLD, 0, sComplete, OUString(), 0, &rShell); + SwInsertField_Data aData(SwFieldTypesEnum::HiddenParagraph, 0, sComplete, OUString(), 0, &rShell); aFieldMgr.InsertField( aData ); } else { - SwInsertField_Data aData(TYP_HIDDENPARAFLD, 0, sCondition, OUString(), 0, &rShell); + SwInsertField_Data aData(SwFieldTypesEnum::HiddenParagraph, 0, sCondition, OUString(), 0, &rShell); aFieldMgr.InsertField( aData ); } //now the text has to be inserted @@ -563,7 +563,7 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig break; } } - SwInsertField_Data aData(TYP_DBFLD, 0, + SwInsertField_Data aData(SwFieldTypesEnum::Database, 0, sDBName + sConvertedColumn, OUString(), 0, &rShell); aFieldMgr.InsertField( aData ); diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index cca2f31abaeb..b8a1cff07158 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -104,14 +104,14 @@ void SwFieldDBPage::Reset(const SfxItemSet*) for(sal_uInt16 i = rRg.nStart; i < rRg.nEnd; ++i) { - const sal_uInt16 nTypeId = SwFieldMgr::GetTypeId(i); - m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(i)); + const SwFieldTypesEnum nTypeId = SwFieldMgr::GetTypeId(i); + m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(i)); } } else { - const sal_uInt16 nTypeId = GetCurField()->GetTypeId(); - m_xTypeLB->append(OUString::number(nTypeId), + const SwFieldTypesEnum nTypeId = GetCurField()->GetTypeId(); + m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId))); } @@ -123,12 +123,12 @@ void SwFieldDBPage::Reset(const SfxItemSet*) m_xFormatLB->clear(); - const sal_uInt16 nSize = GetFieldMgr().GetFormatCount(TYP_DBSETNUMBERFLD, IsFieldDlgHtmlMode()); + const sal_uInt16 nSize = GetFieldMgr().GetFormatCount(SwFieldTypesEnum::DatabaseSetNumber, IsFieldDlgHtmlMode()); for( sal_uInt16 i = 0; i < nSize; ++i ) { - const sal_uInt16 nFormatId = GetFieldMgr().GetFormatId( TYP_DBSETNUMBERFLD, i ); + const sal_uInt16 nFormatId = GetFieldMgr().GetFormatId( SwFieldTypesEnum::DatabaseSetNumber, i ); OUString sId(OUString::number(nFormatId)); - m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr(TYP_DBSETNUMBERFLD, i)); + m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr(SwFieldTypesEnum::DatabaseSetNumber, i)); if (SVX_NUM_ARABIC == nFormatId) m_xFormatLB->set_active_id(sId); } @@ -212,7 +212,7 @@ bool SwFieldDBPage::FillItemSet(SfxItemSet* ) if(!aData.sDataSource.isEmpty()) // without database no new field command { - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); sal_uLong nFormat = 0; sal_uInt16 nSubType = 0; @@ -230,16 +230,17 @@ bool SwFieldDBPage::FillItemSet(SfxItemSet* ) switch (nTypeId) { - case TYP_DBFLD: + case SwFieldTypesEnum::Database: nFormat = m_xNumFormatLB->GetFormat(); if (m_xNewFormatRB->get_sensitive() && m_xNewFormatRB->get_active()) nSubType = nsSwExtendedSubType::SUB_OWN_FMT; aName = sDBName; break; - case TYP_DBSETNUMBERFLD: + case SwFieldTypesEnum::DatabaseSetNumber: nFormat = m_xFormatLB->get_active_id().toUInt32(); break; + default: break; } const OUString aVal(m_xValueED->get_text()); @@ -298,15 +299,15 @@ void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox) if(!pSh) pSh = ::GetActiveWrtShell(); bool bCond = false, bSetNo = false, bFormat = false, bDBFormat = false; - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); - m_xDatabaseTLB->ShowColumns(nTypeId == TYP_DBFLD); + m_xDatabaseTLB->ShowColumns(nTypeId == SwFieldTypesEnum::Database); if (IsFieldEdit()) { SwDBData aData; OUString sColumnName; - if (nTypeId == TYP_DBFLD) + if (nTypeId == SwFieldTypesEnum::Database) { aData = static_cast<SwDBField*>(GetCurField())->GetDBData(); sColumnName = static_cast<SwDBFieldType*>(GetCurField()->GetTyp())->GetColumnName(); @@ -320,7 +321,7 @@ void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox) switch (nTypeId) { - case TYP_DBFLD: + case SwFieldTypesEnum::Database: { bFormat = true; bDBFormat = true; @@ -347,10 +348,10 @@ void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox) } break; } - case TYP_DBNUMSETFLD: + case SwFieldTypesEnum::DatabaseNumberSet: bSetNo = true; [[fallthrough]]; - case TYP_DBNEXTSETFLD: + case SwFieldTypesEnum::DatabaseNextSet: bCond = true; if (IsFieldEdit()) { @@ -359,10 +360,10 @@ void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox) } break; - case TYP_DBNAMEFLD: + case SwFieldTypesEnum::DatabaseName: break; - case TYP_DBSETNUMBERFLD: + case SwFieldTypesEnum::DatabaseSetNumber: { bFormat = true; m_xNewFormatRB->set_active(true); @@ -387,11 +388,12 @@ void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox) } break; } + default: break; } m_xCondition->set_sensitive(bCond); m_xValue->set_sensitive(bSetNo); - if (nTypeId != TYP_DBFLD) + if (nTypeId != SwFieldTypesEnum::Database) { m_xDBFormatRB->set_sensitive(bDBFormat); m_xNewFormatRB->set_sensitive(bDBFormat || bFormat); @@ -421,14 +423,14 @@ IMPL_LINK_NOARG(SwFieldDBPage, NumSelectHdl, weld::ComboBox&, void) void SwFieldDBPage::CheckInsert() { bool bInsert = true; - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); std::unique_ptr<weld::TreeIter> xIter(m_xDatabaseTLB->make_iterator()); if (m_xDatabaseTLB->get_selected(xIter.get())) { bool bEntry = m_xDatabaseTLB->iter_parent(*xIter); - if (nTypeId == TYP_DBFLD && bEntry) + if (nTypeId == SwFieldTypesEnum::Database && bEntry) bEntry = m_xDatabaseTLB->iter_parent(*xIter); bInsert &= bEntry; @@ -436,7 +438,7 @@ void SwFieldDBPage::CheckInsert() else bInsert = false; - if (nTypeId == TYP_DBNUMSETFLD) + if (nTypeId == SwFieldTypesEnum::DatabaseNumberSet) { bool bHasValue = !m_xValueED->get_text().isEmpty(); @@ -451,16 +453,16 @@ IMPL_LINK(SwFieldDBPage, TreeSelectHdl, weld::TreeView&, rBox, void) std::unique_ptr<weld::TreeIter> xIter(rBox.make_iterator()); if (rBox.get_selected(xIter.get())) { - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); bool bEntry = m_xDatabaseTLB->iter_parent(*xIter); - if (nTypeId == TYP_DBFLD && bEntry) + if (nTypeId == SwFieldTypesEnum::Database && bEntry) bEntry = m_xDatabaseTLB->iter_parent(*xIter); CheckInsert(); - if (nTypeId == TYP_DBFLD) + if (nTypeId == SwFieldTypesEnum::Database) { bool bNumFormat = false; @@ -516,7 +518,7 @@ void SwFieldDBPage::FillUserData() void SwFieldDBPage::ActivateMailMergeAddress() { - m_xTypeLB->select_id(OUString::number(TYP_DBFLD)); + m_xTypeLB->select_id(OUString::number(static_cast<sal_uInt16>(SwFieldTypesEnum::Database))); TypeListBoxHdl(*m_xTypeLB); const SwDBData& rData = SW_MOD()->GetDBConfig()->GetAddressSource(); m_xDatabaseTLB->Select(rData.sDataSource, rData.sCommand, OUString()); diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx index 3c29bd911a43..1e4a70f9c5cb 100644 --- a/sw/source/ui/fldui/flddinf.cxx +++ b/sw/source/ui/fldui/flddinf.cxx @@ -124,7 +124,7 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* ) } std::vector<OUString> aLst; - GetFieldMgr().GetSubTypes(TYP_DOCINFOFLD, aLst); + GetFieldMgr().GetSubTypes(SwFieldTypesEnum::DocumentInfo, aLst); std::unique_ptr<weld::TreeIter> xEntry(m_xTypeTLB->make_iterator()); std::unique_ptr<weld::TreeIter> xExpandEntry; for(size_t i = 0; i < aLst.size(); ++i) @@ -357,7 +357,7 @@ IMPL_LINK_NOARG(SwFieldDokInfPage, SubTypeHdl, weld::TreeView&, void) sal_Int32 SwFieldDokInfPage::FillSelectionLB(sal_uInt16 nSubType) { // fill Format-Listbox - sal_uInt16 nTypeId = TYP_DOCINFOFLD; + SwFieldTypesEnum nTypeId = SwFieldTypesEnum::DocumentInfo; EnableInsert(nSubType != USHRT_MAX); @@ -437,7 +437,7 @@ bool SwFieldDokInfPage::FillItemSet(SfxItemSet* ) nOldFormat != nFormat || m_xFixedCB->get_state_changed_from_saved() || (DI_CUSTOM == nSubType && aName != m_sOldCustomFieldName )) { - InsertField(TYP_DOCINFOFLD, nSubType, aName, OUString(), nFormat, + InsertField(SwFieldTypesEnum::DocumentInfo, nSubType, aName, OUString(), nFormat, ' ', m_xFormatLB->IsAutomaticLanguage()); } diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx index 7cee887a6687..1744b6d19f67 100644 --- a/sw/source/ui/fldui/flddok.cxx +++ b/sw/source/ui/fldui/flddok.cxx @@ -94,13 +94,13 @@ void SwFieldDokPage::Reset(const SfxItemSet* ) // fill Type-Listbox for(sal_uInt16 i = rRg.nStart; i < rRg.nEnd; ++i) { - const sal_uInt16 nTypeId = SwFieldMgr::GetTypeId(i); + const SwFieldTypesEnum nTypeId = SwFieldMgr::GetTypeId(i); switch (nTypeId) { - case TYP_PREVPAGEFLD: - case TYP_NEXTPAGEFLD: - case TYP_PAGENUMBERFLD: + case SwFieldTypesEnum::PreviousPage: + case SwFieldTypesEnum::NextPage: + case SwFieldTypesEnum::PageNumber: if (!bPage) { m_xTypeLB->append(OUString::number(USHRT_MAX), SwResId(FMT_REF_PAGE)); @@ -109,7 +109,7 @@ void SwFieldDokPage::Reset(const SfxItemSet* ) break; default: - m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(i)); + m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(i)); break; } } @@ -117,12 +117,12 @@ void SwFieldDokPage::Reset(const SfxItemSet* ) else { const SwField* pCurField = GetCurField(); - sal_uInt16 nTypeId = pCurField->GetTypeId(); - if (nTypeId == TYP_FIXDATEFLD) - nTypeId = TYP_DATEFLD; - if (nTypeId == TYP_FIXTIMEFLD) - nTypeId = TYP_TIMEFLD; - m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId))); + SwFieldTypesEnum nTypeId = pCurField->GetTypeId(); + if (nTypeId == SwFieldTypesEnum::FixedDate) + nTypeId = SwFieldTypesEnum::Date; + if (nTypeId == SwFieldTypesEnum::FixedTime) + nTypeId = SwFieldTypesEnum::Time; + m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId))); m_xNumFormatLB->SetAutomaticLanguage(pCurField->IsAutomaticLanguage()); SwWrtShell *pSh = GetWrtShell(); if(!pSh) @@ -200,17 +200,17 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) m_xDateFT->hide(); m_xTimeFT->hide(); - sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); // fill Selection-Listbox m_xSelectionLB->clear(); - if (nTypeId != USHRT_MAX) + if (nTypeId != SwFieldTypesEnum::Unknown) { std::vector<OUString> aLst; GetFieldMgr().GetSubTypes(nTypeId, aLst); - if (nTypeId != TYP_AUTHORFLD) + if (nTypeId != SwFieldTypesEnum::Author) nCount = aLst.size(); else nCount = GetFieldMgr().GetFormatCount(nTypeId, IsFieldDlgHtmlMode()); @@ -220,7 +220,7 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) if (!IsFieldEdit()) { OUString sId(OUString::number(i)); - if (nTypeId != TYP_AUTHORFLD) + if (nTypeId != SwFieldTypesEnum::Author) m_xSelectionLB->append(sId, aLst[i]); else m_xSelectionLB->append(sId, GetFieldMgr().GetFormatStr(nTypeId, i)); @@ -233,22 +233,22 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) switch (nTypeId) { - case TYP_DATEFLD: - case TYP_TIMEFLD: + case SwFieldTypesEnum::Date: + case SwFieldTypesEnum::Time: m_xSelectionLB->append(sId, aLst[i]); if (static_cast<SwDateTimeField*>(GetCurField())->IsFixed() && !i) m_xSelectionLB->select_id(sId); if (!static_cast<SwDateTimeField*>(GetCurField())->IsFixed() && i) m_xSelectionLB->select_id(sId); break; - case TYP_EXTUSERFLD: - case TYP_DOCSTATFLD: + case SwFieldTypesEnum::ExtendedUser: + case SwFieldTypesEnum::DocumentStatistics: m_xSelectionLB->append(sId, aLst[i]); if (GetCurField()->GetSubType() == i) m_xSelectionLB->select_id(sId); break; - case TYP_AUTHORFLD: + case SwFieldTypesEnum::Author: { const OUString sFormat(GetFieldMgr().GetFormatStr(nTypeId, i)); m_xSelectionLB->append(sId, sFormat); @@ -272,10 +272,10 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) } else { - AddSubType(TYP_PAGENUMBERFLD); - AddSubType(TYP_PREVPAGEFLD); - AddSubType(TYP_NEXTPAGEFLD); - nTypeId = m_xSelectionLB->get_id(0).toUInt32(); + AddSubType(SwFieldTypesEnum::PageNumber); + AddSubType(SwFieldTypesEnum::PreviousPage); + AddSubType(SwFieldTypesEnum::NextPage); + nTypeId = static_cast<SwFieldTypesEnum>(m_xSelectionLB->get_id(0).toUInt32()); nCount = 3; m_xSelectionLB->connect_changed(LINK(this, SwFieldDokPage, SubTypeHdl)); } @@ -298,7 +298,7 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) switch (nTypeId) { - case TYP_DATEFLD: + case SwFieldTypesEnum::Date: bFormat = bNumFormat = bOneArea = bOffset = true; nFormatType = SvNumFormatType::DATE; @@ -311,7 +311,7 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) m_xDateOffsetED->set_value( static_cast<SwDateTimeField*>(GetCurField())->GetOffset() / 24 / 60); break; - case TYP_TIMEFLD: + case SwFieldTypesEnum::Time: bFormat = bNumFormat = bOneArea = bOffset = true; nFormatType = SvNumFormatType::TIME; @@ -324,8 +324,8 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) m_xDateOffsetED->set_value( static_cast<SwDateTimeField*>(GetCurField())->GetOffset() ); break; - case TYP_PREVPAGEFLD: - case TYP_NEXTPAGEFLD: + case SwFieldTypesEnum::PreviousPage: + case SwFieldTypesEnum::NextPage: if (IsFieldEdit()) { const sal_uInt16 nTmp = m_xFormatLB->get_selected_id().toUInt32(); @@ -333,10 +333,10 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) if(SVX_NUM_CHAR_SPECIAL != nTmp) { sal_Int32 nOff = GetCurField()->GetPar2().toInt32(); - if( TYP_NEXTPAGEFLD == nTypeId && 1 != nOff ) + if( SwFieldTypesEnum::NextPage == nTypeId && 1 != nOff ) m_xValueED->set_text( OUString::number(nOff - 1) ); - else if( TYP_PREVPAGEFLD == nTypeId && -1 != nOff ) + else if( SwFieldTypesEnum::PreviousPage == nTypeId && -1 != nOff ) m_xValueED->set_text( OUString::number(nOff + 1) ); else @@ -348,23 +348,23 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) bValue = true; break; - case TYP_CHAPTERFLD: + case SwFieldTypesEnum::Chapter: m_xValueFT->set_label(SwResId(STR_LEVEL)); if (IsFieldEdit()) m_xLevelED->set_text(OUString::number(static_cast<SwChapterField*>(GetCurField())->GetLevel(GetWrtShell()->GetLayout()) + 1)); bLevel = true; break; - case TYP_PAGENUMBERFLD: + case SwFieldTypesEnum::PageNumber: m_xValueFT->set_label( SwResId( STR_OFFSET )); if (IsFieldEdit()) m_xValueED->set_text(GetCurField()->GetPar2()); bValue = true; break; - case TYP_EXTUSERFLD: - case TYP_AUTHORFLD: - case TYP_FILENAMEFLD: + case SwFieldTypesEnum::ExtendedUser: + case SwFieldTypesEnum::Author: + case SwFieldTypesEnum::Filename: bFixed = true; break; @@ -416,9 +416,9 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) m_xValueED->set_sensitive(bValue); } -void SwFieldDokPage::AddSubType(sal_uInt16 nTypeId) +void SwFieldDokPage::AddSubType(SwFieldTypesEnum nTypeId) { - m_xSelectionLB->append(OUString::number(nTypeId), SwFieldType::GetTypeStr(nTypeId)); + m_xSelectionLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldType::GetTypeStr(nTypeId)); } IMPL_LINK_NOARG(SwFieldDokPage, SubTypeHdl, weld::TreeView&, void) @@ -427,37 +427,38 @@ IMPL_LINK_NOARG(SwFieldDokPage, SubTypeHdl, weld::TreeView&, void) if(nPos == -1) nPos = 0; - const sal_uInt16 nTypeId = m_xSelectionLB->get_id(nPos).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xSelectionLB->get_id(nPos).toUInt32()); FillFormatLB(nTypeId); const char* pTextRes = nullptr; switch (nTypeId) { - case TYP_CHAPTERFLD: + case SwFieldTypesEnum::Chapter: pTextRes = STR_LEVEL; break; - case TYP_PREVPAGEFLD: - case TYP_NEXTPAGEFLD: + case SwFieldTypesEnum::PreviousPage: + case SwFieldTypesEnum::NextPage: pTextRes = SVX_NUM_CHAR_SPECIAL == m_xFormatLB->get_selected_id().toUInt32() ? STR_VALUE : STR_OFFSET; break; - case TYP_PAGENUMBERFLD: + case SwFieldTypesEnum::PageNumber: pTextRes = STR_OFFSET; break; + default: break; } if (pTextRes) m_xValueFT->set_label(SwResId(pTextRes)); } -sal_Int32 SwFieldDokPage::FillFormatLB(sal_uInt16 nTypeId) +sal_Int32 SwFieldDokPage::FillFormatLB(SwFieldTypesEnum nTypeId) { // fill Format-Listbox m_xFormatLB->clear(); - if (nTypeId == TYP_AUTHORFLD) + if (nTypeId == SwFieldTypesEnum::Author) return m_xFormatLB->n_children(); const sal_uInt16 nSize = GetFieldMgr().GetFormatCount(nTypeId, IsFieldDlgHtmlMode()); @@ -489,18 +490,18 @@ sal_Int32 SwFieldDokPage::FillFormatLB(sal_uInt16 nTypeId) IMPL_LINK_NOARG(SwFieldDokPage, FormatHdl, weld::TreeView&, void) { - sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); - if (nTypeId == USHRT_MAX) + if (nTypeId == SwFieldTypesEnum::Unknown) { sal_Int32 nPos = m_xSelectionLB->get_selected_index(); if(nPos == -1) nPos = 0; - nTypeId = m_xSelectionLB->get_id(nPos).toUInt32(); + nTypeId = static_cast<SwFieldTypesEnum>(m_xSelectionLB->get_id(nPos).toUInt32()); } - if (nTypeId == TYP_NEXTPAGEFLD || nTypeId == TYP_PREVPAGEFLD) + if (nTypeId == SwFieldTypesEnum::NextPage || nTypeId == SwFieldTypesEnum::PreviousPage) { // Prev/Next - PageNumFields special treatment: sal_uInt16 nTmp = m_xFormatLB->get_selected_id().toUInt32(); @@ -518,14 +519,14 @@ IMPL_LINK_NOARG(SwFieldDokPage, FormatHdl, weld::TreeView&, void) bool SwFieldDokPage::FillItemSet(SfxItemSet* ) { - sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); - if (nTypeId == USHRT_MAX) + if (nTypeId == SwFieldTypesEnum::Unknown) { sal_Int32 nPos = m_xSelectionLB->get_selected_index(); if(nPos == -1) nPos = 0; - nTypeId = m_xSelectionLB->get_id(nPos).toUInt32(); + nTypeId = static_cast<SwFieldTypesEnum>(m_xSelectionLB->get_id(nPos).toUInt32()); } OUString aVal(m_xValueED->get_text()); @@ -548,37 +549,37 @@ bool SwFieldDokPage::FillItemSet(SfxItemSet* ) switch (nTypeId) { - case TYP_AUTHORFLD: + case SwFieldTypesEnum::Author: nFormat = nSubType; nSubType = 0; [[fallthrough]]; - case TYP_EXTUSERFLD: + case SwFieldTypesEnum::ExtendedUser: nFormat |= m_xFixedCB->get_active() ? AF_FIXED : 0; break; - case TYP_FILENAMEFLD: + case SwFieldTypesEnum::Filename: nFormat |= m_xFixedCB->get_active() ? FF_FIXED : 0; break; - case TYP_DATEFLD: - case TYP_TIMEFLD: + case SwFieldTypesEnum::Date: + case SwFieldTypesEnum::Time: { nFormat = m_xNumFormatLB->GetFormat(); long nVal = static_cast< long >(m_xDateOffsetED->get_value()); - if (nTypeId == TYP_DATEFLD) + if (nTypeId == SwFieldTypesEnum::Date) aVal = OUString::number(nVal * 60 * 24); else aVal = OUString::number(nVal); break; } - case TYP_NEXTPAGEFLD: - case TYP_PREVPAGEFLD: - case TYP_PAGENUMBERFLD: - case TYP_GETREFPAGEFLD: + case SwFieldTypesEnum::NextPage: + case SwFieldTypesEnum::PreviousPage: + case SwFieldTypesEnum::PageNumber: + case SwFieldTypesEnum::GetRefPage: { if( SVX_NUM_CHAR_SPECIAL != nFormat && - (TYP_PREVPAGEFLD == nTypeId || TYP_NEXTPAGEFLD == nTypeId)) + (SwFieldTypesEnum::PreviousPage == nTypeId || SwFieldTypesEnum::NextPage == nTypeId)) { sal_Int32 nVal = m_xValueED->get_text().toInt32(); aVal = OUString::number(nVal); @@ -586,7 +587,7 @@ bool SwFieldDokPage::FillItemSet(SfxItemSet* ) break; } - case TYP_CHAPTERFLD: + case SwFieldTypesEnum::Chapter: aVal = m_xLevelED->get_text(); break; diff --git a/sw/source/ui/fldui/flddok.hxx b/sw/source/ui/fldui/flddok.hxx index 88a7b3ecbee7..4ed50de52a38 100644 --- a/sw/source/ui/fldui/flddok.hxx +++ b/sw/source/ui/fldui/flddok.hxx @@ -48,8 +48,8 @@ class SwFieldDokPage : public SwFieldPage DECL_LINK(FormatHdl, weld::TreeView&, void); DECL_LINK(SubTypeHdl, weld::TreeView&, void); - void AddSubType(sal_uInt16 nTypeId); - sal_Int32 FillFormatLB(sal_uInt16 nTypeId); + void AddSubType(SwFieldTypesEnum nTypeId); + sal_Int32 FillFormatLB(SwFieldTypesEnum nTypeId); protected: virtual sal_uInt16 GetGroup() override; diff --git a/sw/source/ui/fldui/fldedt.cxx b/sw/source/ui/fldui/fldedt.cxx index aaaf1e21d28f..84074dd4b45a 100644 --- a/sw/source/ui/fldui/fldedt.cxx +++ b/sw/source/ui/fldui/fldedt.cxx @@ -161,7 +161,7 @@ void SwFieldEditDlg::Init() rMgr.GoNext(); m_xPrevBT->set_sensitive( bMove ); - if (pCurField->GetTypeId() == TYP_EXTUSERFLD) + if (pCurField->GetTypeId() == SwFieldTypesEnum::ExtendedUser) m_xAddressBT->set_sensitive(true); else m_xAddressBT->set_sensitive(false); @@ -284,7 +284,7 @@ IMPL_LINK(SwFieldEditDlg, NextPrevHdl, weld::Button&, rButton, void) SwFieldMgr& rMgr = pTabPage->GetFieldMgr(); SwField *pCurField = rMgr.GetCurField(); - if (pCurField->GetTypeId() == TYP_DBFLD) + if (pCurField->GetTypeId() == SwFieldTypesEnum::Database) pOldTyp = pCurField->GetTyp(); rMgr.GoNextPrev( bNext, pOldTyp ); diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx index 26b32e94c3f6..2517ba7e684a 100644 --- a/sw/source/ui/fldui/fldfunc.cxx +++ b/sw/source/ui/fldui/fldfunc.cxx @@ -108,16 +108,16 @@ void SwFieldFuncPage::Reset(const SfxItemSet* ) // fill Typ-Listbox for(sal_uInt16 i = rRg.nStart; i < rRg.nEnd; ++i) { - const sal_uInt16 nTypeId = SwFieldMgr::GetTypeId(i); - m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(i)); + const SwFieldTypesEnum nTypeId = SwFieldMgr::GetTypeId(i); + m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(i)); } } else { - const sal_uInt16 nTypeId = GetCurField()->GetTypeId(); - m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId))); + const SwFieldTypesEnum nTypeId = GetCurField()->GetTypeId(); + m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId))); - if (nTypeId == TYP_MACROFLD) + if (nTypeId == SwFieldTypesEnum::Macro) { GetFieldMgr().SetMacroPath(GetCurField()->GetPar1()); } @@ -207,7 +207,7 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) if (nOld == GetTypeSel()) return; - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); // fill Selection-Listbox UpdateSubType(); @@ -225,7 +225,7 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) if (nSize) { - if (IsFieldEdit() && nTypeId == TYP_JUMPEDITFLD) + if (IsFieldEdit() && nTypeId == SwFieldTypesEnum::JumpEdit) m_xFormatLB->select_text(SwResId(FMT_MARK_ARY[GetCurField()->GetFormat()])); if (m_xFormatLB->get_selected_index() == -1) @@ -236,8 +236,8 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) bool bFormat = nSize != 0; // two controls for conditional text - bool bDropDown = TYP_DROPDOWN == nTypeId; - bool bCondTextField = TYP_CONDTXTFLD == nTypeId; + bool bDropDown = SwFieldTypesEnum::Dropdown == nTypeId; + bool bCondTextField = SwFieldTypesEnum::ConditionalText == nTypeId; m_xCond1FT->set_visible(!bDropDown && bCondTextField); m_xCond1ED->set_visible(!bDropDown && bCondTextField); @@ -287,7 +287,7 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) switch (nTypeId) { - case TYP_MACROFLD: + case SwFieldTypesEnum::Macro: bMacro = true; if (!GetFieldMgr().GetMacroPath().isEmpty()) bValue = true; @@ -301,7 +301,7 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) m_xValueED->set_accessible_name(m_xValueFT->get_label()); break; - case TYP_HIDDENPARAFLD: + case SwFieldTypesEnum::HiddenParagraph: m_xNameFT->set_label(SwResId(STR_COND)); m_xNameED->SetDropEnable(true); bName = true; @@ -309,7 +309,7 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) m_xValueED->set_accessible_name(m_xValueFT->get_label()); break; - case TYP_HIDDENTXTFLD: + case SwFieldTypesEnum::HiddenText: { m_xNameFT->set_label(SwResId(STR_COND)); m_xNameED->SetDropEnable(true); @@ -323,7 +323,7 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) } break; - case TYP_CONDTXTFLD: + case SwFieldTypesEnum::ConditionalText: m_xNameFT->set_label(SwResId(STR_COND)); m_xNameED->SetDropEnable(true); if (IsFieldEdit()) @@ -338,7 +338,7 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) m_xValueED->set_accessible_name(m_xValueFT->get_label()); break; - case TYP_JUMPEDITFLD: + case SwFieldTypesEnum::JumpEdit: m_xNameFT->set_label(SwResId(STR_JUMPEDITFLD)); m_xValueFT->set_label(SwResId(STR_PROMPT)); bName = bValue = true; @@ -346,14 +346,14 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) m_xValueED->set_accessible_name(m_xValueFT->get_label()); break; - case TYP_INPUTFLD: + case SwFieldTypesEnum::Input: m_xValueFT->set_label(SwResId(STR_PROMPT)); bValue = true; m_xNameED->set_accessible_name(m_xNameFT->get_label()); m_xValueED->set_accessible_name(m_xValueFT->get_label()); break; - case TYP_COMBINED_CHARS: + case SwFieldTypesEnum::CombinedChars: { m_xNameFT->set_label(SwResId(STR_COMBCHRS_FT)); m_xNameED->SetDropEnable(true); @@ -366,7 +366,7 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) m_xValueED->set_accessible_name(m_xValueFT->get_label()); } break; - case TYP_DROPDOWN : + case SwFieldTypesEnum::Dropdown : break; default: break; @@ -385,9 +385,9 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) IMPL_LINK_NOARG(SwFieldFuncPage, SelectHdl, weld::TreeView&, void) { - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); - if( TYP_MACROFLD == nTypeId ) + if( SwFieldTypesEnum::Macro == nTypeId ) m_xNameED->set_text( m_xSelectionLB->get_selected_text() ); } @@ -472,7 +472,7 @@ IMPL_LINK_NOARG(SwFieldFuncPage, ListEnableHdl, weld::Entry&, void) // renew types in SelectionBox void SwFieldFuncPage::UpdateSubType() { - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); // fill Selection-Listbox m_xSelectionLB->freeze(); @@ -493,7 +493,7 @@ void SwFieldFuncPage::UpdateSubType() if (bEnable) m_xSelectionLB->select(0); - if (nTypeId == TYP_MACROFLD) + if (nTypeId == SwFieldTypesEnum::Macro) { const bool bHasMacro = !GetFieldMgr().GetMacroPath().isEmpty(); @@ -515,7 +515,7 @@ IMPL_LINK_NOARG( SwFieldFuncPage, MacroHdl, weld::Button&, void) bool SwFieldFuncPage::FillItemSet(SfxItemSet* ) { - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); sal_uInt16 nSubType = 0; @@ -528,7 +528,7 @@ bool SwFieldFuncPage::FillItemSet(SfxItemSet* ) switch(nTypeId) { - case TYP_INPUTFLD: + case SwFieldTypesEnum::Input: nSubType = INP_TXT; // to prevent removal of CR/LF restore old content if (!m_xNameED->get_value_changed_from_saved() && IsFieldEdit()) @@ -536,15 +536,15 @@ bool SwFieldFuncPage::FillItemSet(SfxItemSet* ) break; - case TYP_MACROFLD: + case SwFieldTypesEnum::Macro: // use the full script URL, not the name in the Edit control aName = GetFieldMgr().GetMacroPath(); break; - case TYP_CONDTXTFLD: + case SwFieldTypesEnum::ConditionalText: aVal = m_xCond1ED->get_text() + "|" + m_xCond2ED->get_text(); break; - case TYP_DROPDOWN : + case SwFieldTypesEnum::Dropdown : { aName = m_xListNameED->get_text(); for (sal_Int32 i = 0, nEntryCount = m_xListItemsLB->n_children(); i < nEntryCount; ++i) @@ -601,9 +601,9 @@ IMPL_LINK_NOARG(SwFieldFuncPage, ModifyHdl, weld::Entry&, void) const sal_Int32 nLen = m_xNameED->get_text().getLength(); bool bEnable = true; - sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); - if( TYP_COMBINED_CHARS == nTypeId && + if( SwFieldTypesEnum::CombinedChars == nTypeId && (!nLen || nLen > MAX_COMBINED_CHARACTERS )) bEnable = false; diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx index 705ec45fdc7c..b200528674a5 100644 --- a/sw/source/ui/fldui/fldpage.cxx +++ b/sw/source/ui/fldui/fldpage.cxx @@ -114,7 +114,7 @@ void SwFieldPage::EditNewField( bool bOnlyActivate ) } // insert field -void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUString& rPar1, +void SwFieldPage::InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, const OUString& rPar1, const OUString& rPar2, sal_uInt32 nFormatId, sal_Unicode cSeparator, bool bIsAutomaticLanguage) { @@ -132,11 +132,11 @@ void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUS pView->GetViewFrame()->GetBindings().GetRecorder(); if ( xRecorder.is() ) { - bool bRecordDB = TYP_DBFLD == nTypeId || - TYP_DBSETNUMBERFLD == nTypeId || - TYP_DBNUMSETFLD == nTypeId || - TYP_DBNEXTSETFLD == nTypeId || - TYP_DBNAMEFLD == nTypeId ; + bool bRecordDB = SwFieldTypesEnum::Database == nTypeId || + SwFieldTypesEnum::DatabaseSetNumber == nTypeId || + SwFieldTypesEnum::DatabaseNumberSet == nTypeId || + SwFieldTypesEnum::DatabaseNextSet == nTypeId || + SwFieldTypesEnum::DatabaseName == nTypeId ; SfxRequest aReq( pView->GetViewFrame(), bRecordDB ? FN_INSERT_DBFIELD : FN_INSERT_FIELD ); @@ -159,7 +159,7 @@ void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUS (FN_PARAM_3, OUString(cSeparator))); aReq.AppendItem(SfxUInt16Item(FN_PARAM_FIELD_SUBTYPE, nSubType)); } - aReq.AppendItem(SfxUInt16Item(FN_PARAM_FIELD_TYPE , nTypeId)); + aReq.AppendItem(SfxUInt16Item(FN_PARAM_FIELD_TYPE , static_cast<sal_uInt16>(nTypeId))); aReq.AppendItem(SfxStringItem(FN_PARAM_FIELD_CONTENT, rPar2)); aReq.AppendItem(SfxUInt32Item(FN_PARAM_FIELD_FORMAT , nFormatId)); aReq.Done(); @@ -174,16 +174,16 @@ void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUS OUString sPar2(rPar2); switch( nTypeId ) { - case TYP_DATEFLD: - case TYP_TIMEFLD: - nSubType = static_cast< sal_uInt16 >(((nTypeId == TYP_DATEFLD) ? DATEFLD : TIMEFLD) | + case SwFieldTypesEnum::Date: + case SwFieldTypesEnum::Time: + nSubType = static_cast< sal_uInt16 >(((nTypeId == SwFieldTypesEnum::Date) ? DATEFLD : TIMEFLD) | ((nSubType == DATE_VAR) ? 0 : FIXEDFLD)); break; - case TYP_DBNAMEFLD: - case TYP_DBNEXTSETFLD: - case TYP_DBNUMSETFLD: - case TYP_DBSETNUMBERFLD: + case SwFieldTypesEnum::DatabaseName: + case SwFieldTypesEnum::DatabaseNextSet: + case SwFieldTypesEnum::DatabaseNumberSet: + case SwFieldTypesEnum::DatabaseSetNumber: { sal_Int32 nPos = 0; SwDBData aData; @@ -197,7 +197,7 @@ void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUS } break; - case TYP_DBFLD: + case SwFieldTypesEnum::Database: { SwDBData aData; sal_Int32 nIdx{ 0 }; @@ -224,7 +224,7 @@ void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUS } break; - case TYP_SEQFLD: + case SwFieldTypesEnum::Sequence: { SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>(pTmpField->GetTyp()); pTyp->SetOutlineLvl( static_cast< sal_uInt8 >(nSubType & 0xff)); @@ -234,7 +234,7 @@ void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUS } break; - case TYP_INPUTFLD: + case SwFieldTypesEnum::Input: { // User- or SetField ? if (m_aMgr.GetFieldType(SwFieldIds::User, sPar1) == nullptr && @@ -246,7 +246,7 @@ void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUS } } break; - case TYP_DOCINFOFLD: + case SwFieldTypesEnum::DocumentInfo: { if( nSubType == nsSwDocInfoSubType::DI_CUSTOM ) { @@ -255,6 +255,7 @@ void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUS } } break; + default: break; } pSh->StartAllAction(); @@ -268,10 +269,11 @@ void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUS switch (nTypeId) { - case TYP_HIDDENTXTFLD: - case TYP_HIDDENPARAFLD: + case SwFieldTypesEnum::HiddenText: + case SwFieldTypesEnum::HiddenParagraph: m_aMgr.EvalExpFields(pSh); break; + default: break; } pSh->SetUndoNoResetModified(); diff --git a/sw/source/ui/fldui/fldpage.hxx b/sw/source/ui/fldui/fldpage.hxx index f09d368ba4f5..4cb0115f3d35 100644 --- a/sw/source/ui/fldui/fldpage.hxx +++ b/sw/source/ui/fldui/fldpage.hxx @@ -62,7 +62,7 @@ protected: bool IsFieldEdit() const { return m_bFieldEdit; } // insert field - void InsertField(sal_uInt16 nTypeId, + void InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, const OUString& rPar1, const OUString& rPar2, diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index d034a61337da..ca2ed6d5cb1e 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -173,11 +173,11 @@ void SwFieldRefPage::Reset(const SfxItemSet* ) for (short i = rRg.nStart; i < rRg.nEnd; ++i) { - const sal_uInt16 nTypeId = SwFieldMgr::GetTypeId(i); + const SwFieldTypesEnum nTypeId = SwFieldMgr::GetTypeId(i); - if (!IsFieldEdit() || nTypeId != TYP_SETREFFLD) + if (!IsFieldEdit() || nTypeId != SwFieldTypesEnum::SetRef) { - m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(i)); + m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(i)); } } @@ -372,14 +372,14 @@ IMPL_LINK_NOARG(SwFieldRefPage, TypeHdl, weld::TreeView&, void) switch (nTypeId) { - case TYP_GETREFFLD: + case static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef): if (REFFLDFLAG & m_xTypeLB->get_id(nOld).toUInt32()) // the old one stays nFieldDlgFormatSel = m_xFormatLB->get_selected_index(); bName = true; break; - case TYP_SETREFFLD: + case static_cast<sal_uInt16>(SwFieldTypesEnum::SetRef): bName = true; break; @@ -390,7 +390,7 @@ IMPL_LINK_NOARG(SwFieldRefPage, TypeHdl, weld::TreeView&, void) if( REFFLDFLAG & nTypeId ) { const sal_uInt16 nOldId = nOld != -1 ? m_xTypeLB->get_id(nOld).toUInt32() : 0; - if( nOldId & REFFLDFLAG || nOldId == TYP_GETREFFLD ) + if( nOldId & REFFLDFLAG || nOldId == static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef) ) // then the old one stays nFieldDlgFormatSel = m_xFormatLB->get_selected_index(); } @@ -426,7 +426,7 @@ void SwFieldRefPage::SubTypeHdl() switch(nTypeId) { - case TYP_GETREFFLD: + case static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef): if (!IsFieldEdit() || m_xSelectionLB->get_selected_index() != -1) { m_xNameED->set_text(m_xSelectionLB->get_selected_text()); @@ -434,7 +434,7 @@ void SwFieldRefPage::SubTypeHdl() } break; - case TYP_SETREFFLD: + case static_cast<sal_uInt16>(SwFieldTypesEnum::SetRef): { SwWrtShell *pSh = GetWrtShell(); if(!pSh) @@ -655,7 +655,7 @@ void SwFieldRefPage::UpdateSubType(const OUString& filterString) else { std::vector<OUString> aLst; - GetFieldMgr().GetSubTypes(nTypeId, aLst); + GetFieldMgr().GetSubTypes(static_cast<SwFieldTypesEnum>(nTypeId), aLst); for(const OUString & i : aLst) { bool isSubstring = MatchSubstring( i , filterString ); @@ -769,7 +769,7 @@ sal_Int32 SwFieldRefPage::FillFormatLB(sal_uInt16 nTypeId) bAddCrossRefFormats = true; [[fallthrough]]; - case TYP_GETREFFLD: + case static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef): case REFFLDFLAG_BOOKMARK: case REFFLDFLAG_FOOTNOTE: case REFFLDFLAG_ENDNOTE: @@ -785,18 +785,19 @@ sal_Int32 SwFieldRefPage::FillFormatLB(sal_uInt16 nTypeId) } else { - nSize = GetFieldMgr().GetFormatCount( nTypeId, IsFieldDlgHtmlMode() ); + nSize = GetFieldMgr().GetFormatCount( static_cast<SwFieldTypesEnum>(nTypeId), IsFieldDlgHtmlMode() ); } break; } if (REFFLDFLAG & nTypeId) - nTypeId = TYP_GETREFFLD; + nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef); + SwFieldTypesEnum nFieldType = static_cast<SwFieldTypesEnum>(nTypeId); for (sal_uInt16 i = 0; i < nSize; i++) { - OUString sId(OUString::number(GetFieldMgr().GetFormatId( nTypeId, i ))); - m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr(nTypeId, i)); + OUString sId(OUString::number(GetFieldMgr().GetFormatId( nFieldType, i ))); + m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr(nFieldType, i)); } // #i83479# @@ -804,14 +805,14 @@ sal_Int32 SwFieldRefPage::FillFormatLB(sal_uInt16 nTypeId) if ( bAddCrossRefFormats ) { sal_uInt16 nFormat = FMT_REF_NUMBER_IDX; - OUString sId(OUString::number(GetFieldMgr().GetFormatId(nTypeId, nFormat))); - m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr( nTypeId, nFormat )); + OUString sId(OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat))); + m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr( nFieldType, nFormat )); nFormat = FMT_REF_NUMBER_NO_CONTEXT_IDX; - sId = OUString::number(GetFieldMgr().GetFormatId(nTypeId, nFormat)); - m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr( nTypeId, nFormat )); + sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat)); + m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr( nFieldType, nFormat )); nFormat = FMT_REF_NUMBER_FULL_CONTEXT_IDX; - sId = OUString::number(GetFieldMgr().GetFormatId(nTypeId, nFormat)); - m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr( nTypeId, nFormat )); + sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat)); + m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr( nFieldType, nFormat )); nExtraSize = 3; } @@ -823,42 +824,42 @@ sal_Int32 SwFieldRefPage::FillFormatLB(sal_uInt16 nTypeId) { for (sal_uInt16 i = 0; i < nSize; i++) { - OUString sId(OUString::number(GetFieldMgr().GetFormatId( nTypeId, i + SAL_N_ELEMENTS(FMT_REF_ARY)))); - m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nTypeId, i )); + OUString sId(OUString::number(GetFieldMgr().GetFormatId( nFieldType, i + SAL_N_ELEMENTS(FMT_REF_ARY)))); + m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, i )); } nExtraSize += nSize; if ( bAddCrossRefFormats ) { sal_uInt16 nFormat = FMT_REF_NUMBER_IDX + SAL_N_ELEMENTS(FMT_REF_ARY); - OUString sId(OUString::number(GetFieldMgr().GetFormatId(nTypeId, nFormat))); - m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nTypeId, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); + OUString sId(OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat))); + m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); nFormat = FMT_REF_NUMBER_NO_CONTEXT_IDX + SAL_N_ELEMENTS(FMT_REF_ARY); - sId = OUString::number(GetFieldMgr().GetFormatId(nTypeId, nFormat)); - m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nTypeId, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); + sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat)); + m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); nFormat = FMT_REF_NUMBER_FULL_CONTEXT_IDX + SAL_N_ELEMENTS(FMT_REF_ARY); - sId = OUString::number(GetFieldMgr().GetFormatId(nTypeId, nFormat)); - m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nTypeId, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); + sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat)); + m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); nExtraSize += 3; } // uppercase article for (sal_uInt16 i = 0; i < nSize; i++) { - OUString sId(OUString::number(GetFieldMgr().GetFormatId( nTypeId, i + 2 * SAL_N_ELEMENTS(FMT_REF_ARY)))); - m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nTypeId, i )); + OUString sId(OUString::number(GetFieldMgr().GetFormatId( nFieldType, i + 2 * SAL_N_ELEMENTS(FMT_REF_ARY)))); + m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, i )); } nExtraSize += nSize; if ( bAddCrossRefFormats ) { sal_uInt16 nFormat = FMT_REF_NUMBER_IDX + 2 * SAL_N_ELEMENTS(FMT_REF_ARY); - OUString sId(OUString::number(GetFieldMgr().GetFormatId(nTypeId, nFormat))); - m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nTypeId, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); + OUString sId(OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat))); + m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); nFormat = FMT_REF_NUMBER_NO_CONTEXT_IDX + 2 * SAL_N_ELEMENTS(FMT_REF_ARY); - sId = OUString::number(GetFieldMgr().GetFormatId(nTypeId, nFormat)); - m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nTypeId, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); + sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat)); + m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); nFormat = FMT_REF_NUMBER_FULL_CONTEXT_IDX + 2 * SAL_N_ELEMENTS(FMT_REF_ARY); - sId = OUString::number(GetFieldMgr().GetFormatId(nTypeId, nFormat)); - m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nTypeId, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); + sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat)); + m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY))); nExtraSize += 3; } } @@ -894,8 +895,8 @@ IMPL_LINK_NOARG(SwFieldRefPage, ModifyHdl, weld::Entry&, void) bool bEnable = true; sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); - if ((nTypeId == TYP_SETREFFLD && !GetFieldMgr().CanInsertRefMark(aName)) || - (bEmptyName && (nTypeId == TYP_GETREFFLD || nTypeId == TYP_SETREFFLD || + if ((nTypeId == static_cast<sal_uInt16>(SwFieldTypesEnum::SetRef) && !GetFieldMgr().CanInsertRefMark(aName)) || + (bEmptyName && (nTypeId == static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef) || nTypeId == static_cast<sal_uInt16>(SwFieldTypesEnum::SetRef) || nTypeId == REFFLDFLAG_BOOKMARK))) bEnable = false; @@ -919,11 +920,11 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) switch(nTypeId) { - case TYP_GETREFFLD: + case static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef): nSubType = REF_SETREFATTR; break; - case TYP_SETREFFLD: + case static_cast<sal_uInt16>(SwFieldTypesEnum::SetRef): { SwFieldType* pType = GetFieldMgr().GetFieldType(SwFieldIds::SetExp, aName); @@ -948,7 +949,7 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) if (nTypeId == REFFLDFLAG_BOOKMARK) // text marks! { aName = m_xNameED->get_text(); - nTypeId = TYP_GETREFFLD; + nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef); nSubType = REF_BOOKMARK; } else if (REFFLDFLAG_FOOTNOTE == nTypeId) // footnotes @@ -958,7 +959,7 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) size_t nPos = 0; - nTypeId = TYP_GETREFFLD; + nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef); nSubType = REF_FOOTNOTE; aName.clear(); @@ -979,7 +980,7 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) size_t nPos = 0; - nTypeId = TYP_GETREFFLD; + nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef); nSubType = REF_ENDNOTE; aName.clear(); @@ -1009,7 +1010,7 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) *(maOutlineNodes[nOutlIdx]), IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK); aName = pMark->GetName(); - nTypeId = TYP_GETREFFLD; + nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef); nSubType = REF_BOOKMARK; } } @@ -1029,7 +1030,7 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) *(maNumItems[nNumItemIdx]->GetTextNode()), IDocumentMarkAccess::MarkType::CROSSREF_NUMITEM_BOOKMARK); aName = pMark->GetName(); - nTypeId = TYP_GETREFFLD; + nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef); nSubType = REF_BOOKMARK; } } @@ -1046,7 +1047,7 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) size_t nPos = 0; - nTypeId = TYP_GETREFFLD; + nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef); nSubType = REF_SEQUENCEFLD; aName = pType->GetName(); @@ -1064,7 +1065,7 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) } } - if (IsFieldEdit() && nTypeId == TYP_GETREFFLD) + if (IsFieldEdit() && nTypeId == static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef)) { aVal = OUString::number(nSubType) + "|" + aVal; } @@ -1076,7 +1077,7 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) m_xSelectionLB->get_value_changed_from_saved() || m_xFormatLB->get_value_changed_from_saved()) { - InsertField( nTypeId, nSubType, aName, aVal, nFormat ); + InsertField( static_cast<SwFieldTypesEnum>(nTypeId), nSubType, aName, aVal, nFormat ); } ModifyHdl(*m_xNameED); // enable/disable insert if applicable diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx index b56f88bd4470..c22517e3cf4d 100644 --- a/sw/source/ui/fldui/fldvar.cxx +++ b/sw/source/ui/fldui/fldvar.cxx @@ -96,7 +96,7 @@ void SwFieldVarPage::Reset(const SfxItemSet* ) m_xTypeLB->freeze(); m_xTypeLB->clear(); - sal_uInt16 nTypeId; + SwFieldTypesEnum nTypeId; if (!IsFieldEdit()) { @@ -106,7 +106,7 @@ void SwFieldVarPage::Reset(const SfxItemSet* ) for (short i = rRg.nStart; i < rRg.nEnd; ++i) { nTypeId = SwFieldMgr::GetTypeId(i); - m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(i)); + m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(i)); } } else @@ -114,9 +114,9 @@ void SwFieldVarPage::Reset(const SfxItemSet* ) const SwField* pCurField = GetCurField(); assert(pCurField && "<SwFieldVarPage::Reset(..)> - <SwField> instance missing!"); nTypeId = pCurField->GetTypeId(); - if (nTypeId == TYP_SETINPFLD) - nTypeId = TYP_INPUTFLD; - m_xTypeLB->append(OUString::number(nTypeId), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId))); + if (nTypeId == SwFieldTypesEnum::SetInput) + nTypeId = SwFieldTypesEnum::Input; + m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId))); m_xNumFormatLB->SetAutomaticLanguage(pCurField->IsAutomaticLanguage()); SwWrtShell *pSh = GetWrtShell(); if(!pSh) @@ -220,7 +220,7 @@ IMPL_LINK( SwFieldVarPage, SubTypeListBoxHdl, weld::TreeView&, rBox, void ) void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) { - sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); sal_Int32 nSelPos = m_xSelectionLB->get_selected_index(); size_t nSelData = SIZE_MAX; @@ -229,7 +229,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) if (IsFieldEdit() && (!pBox || bInit)) { - if (nTypeId != TYP_FORMELFLD) + if (nTypeId != SwFieldTypesEnum::Formel) m_xNameED->set_text(GetFieldMgr().GetCurFieldPar1()); m_xValueED->set_text(GetFieldMgr().GetCurFieldPar2()); @@ -250,7 +250,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) switch (nTypeId) { - case TYP_USERFLD: + case SwFieldTypesEnum::User: { // change or create user type SwUserFieldType* pType = static_cast<SwUserFieldType*>( @@ -290,7 +290,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) break; } - case TYP_SETFLD: + case SwFieldTypesEnum::Set: bValue = true; bNumFormat = bInvisible = true; @@ -339,7 +339,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) m_xValueED->SetDropEnable(true); break; - case TYP_FORMELFLD: + case SwFieldTypesEnum::Formel: { bValue = true; bNumFormat = true; @@ -348,7 +348,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) } break; - case TYP_GETFLD: + case SwFieldTypesEnum::Get: { if (!IsFieldEdit()) { @@ -387,7 +387,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) } break; - case TYP_INPUTFLD: + case SwFieldTypesEnum::Input: m_xValueFT->set_label(SwResId(STR_PROMPT)); if (nSelPos != -1) @@ -398,10 +398,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) m_xNameED->set_text( sName ); // User- or SetField ? - const sal_uInt16 nInpType = static_cast< sal_uInt16 > - (GetFieldMgr().GetFieldType(SwFieldIds::User, sName) ? 0 : TYP_SETINPFLD); - - if (nInpType) // SETEXPFLD + if (GetFieldMgr().GetFieldType(SwFieldIds::User, sName)) { // is there a corresponding SetField SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>( @@ -424,7 +421,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) } break; - case TYP_DDEFLD: + case SwFieldTypesEnum::DDE: m_xValueFT->set_label(SwResId(STR_DDE_CMD)); if (IsFieldEdit() || pBox) // only when interacting via mouse @@ -453,7 +450,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) bName = bValue = true; break; - case TYP_SEQFLD: + case SwFieldTypesEnum::Sequence: { bName = bValue = bShowChapterFrame = true; @@ -491,7 +488,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) } break; - case TYP_SETREFPAGEFLD: + case SwFieldTypesEnum::SetRefPage: { bValue = false; m_xValueFT->set_label( SwResId( STR_OFFSET )); @@ -508,10 +505,12 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) } break; - case TYP_GETREFPAGEFLD: + case SwFieldTypesEnum::GetRefPage: m_xNameED->set_text(OUString()); m_xValueED->set_text(OUString()); break; + + default: break; } m_xNumFormatLB->set_visible(bNumFormat); @@ -537,8 +536,8 @@ IMPL_LINK(SwFieldVarPage, SubTypeInsertHdl, weld::TreeView&, rBox, void) { if (!bInit) { - sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); - if (nTypeId == TYP_FORMELFLD) + SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); + if (nTypeId == SwFieldTypesEnum::Formel) { auto nSelPos = m_xSelectionLB->get_selected_index(); if (nSelPos != -1) @@ -565,13 +564,13 @@ void SwFieldVarPage::UpdateSubType() m_xSelectionLB->freeze(); m_xSelectionLB->clear(); - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); std::vector<OUString> aList; GetFieldMgr().GetSubTypes(nTypeId, aList); const size_t nCount = aList.size(); for (size_t i = 0; i < nCount; ++i) { - if (nTypeId != TYP_INPUTFLD || i) + if (nTypeId != SwFieldTypesEnum::Input || i) { if (!IsFieldEdit()) { @@ -583,22 +582,22 @@ void SwFieldVarPage::UpdateSubType() switch (nTypeId) { - case TYP_INPUTFLD: + case SwFieldTypesEnum::Input: if (GetCurField() && aList[i] == GetCurField()->GetPar1()) bInsert = true; break; - case TYP_FORMELFLD: + case SwFieldTypesEnum::Formel: bInsert = true; break; - case TYP_GETFLD: + case SwFieldTypesEnum::Get: if (GetCurField() && aList[i] == static_cast<const SwFormulaField*>(GetCurField())->GetFormula()) bInsert = true; break; - case TYP_SETFLD: - case TYP_USERFLD: + case SwFieldTypesEnum::Set: + case SwFieldTypesEnum::User: if (GetCurField() && aList[i] == GetCurField()->GetTyp()->GetName()) { bInsert = true; @@ -607,7 +606,7 @@ void SwFieldVarPage::UpdateSubType() } break; - case TYP_SETREFPAGEFLD: + case SwFieldTypesEnum::SetRefPage: { if (GetCurField() != nullptr && ((static_cast<SwRefPageSetField*>(GetCurField())->IsOn() @@ -630,7 +629,7 @@ void SwFieldVarPage::UpdateSubType() if (bInsert) { m_xSelectionLB->append(OUString::number(i), aList[i]); - if (nTypeId != TYP_FORMELFLD) + if (nTypeId != SwFieldTypesEnum::Formel) break; } } @@ -659,7 +658,7 @@ void SwFieldVarPage::UpdateSubType() SubTypeHdl(pLB); } -void SwFieldVarPage::FillFormatLB(sal_uInt16 nTypeId) +void SwFieldVarPage::FillFormatLB(SwFieldTypesEnum nTypeId) { OUString sOldSel; const sal_Int32 nFormatSel = m_xFormatLB->get_selected_index(); @@ -683,7 +682,7 @@ void SwFieldVarPage::FillFormatLB(sal_uInt16 nTypeId) m_xNumFormatLB->clear(); // flags list as dirty and needing refilling with stock entries bool bSpecialFormat = false; - if( TYP_GETREFPAGEFLD != nTypeId ) + if( SwFieldTypesEnum::GetRefPage != nTypeId ) { if (GetCurField() != nullptr && IsFieldEdit()) { @@ -694,7 +693,7 @@ void SwFieldVarPage::FillFormatLB(sal_uInt16 nTypeId) m_xNumFormatLB->SetDefFormat(GetCurField()->GetFormat()); sOldNumSel.clear(); } - else if (nTypeId == TYP_GETFLD || nTypeId == TYP_FORMELFLD) + else if (nTypeId == SwFieldTypesEnum::Get || nTypeId == SwFieldTypesEnum::Formel) { m_xNumFormatLB->SetFormatType(SvNumFormatType::NUMBER); } @@ -710,7 +709,7 @@ void SwFieldVarPage::FillFormatLB(sal_uInt16 nTypeId) switch (nTypeId) { - case TYP_USERFLD: + case SwFieldTypesEnum::User: { if (!IsFieldEdit() || bSpecialFormat) { @@ -721,7 +720,7 @@ void SwFieldVarPage::FillFormatLB(sal_uInt16 nTypeId) } break; - case TYP_SETFLD: + case SwFieldTypesEnum::Set: { if (!IsFieldEdit() || bSpecialFormat) { @@ -731,24 +730,26 @@ void SwFieldVarPage::FillFormatLB(sal_uInt16 nTypeId) } break; - case TYP_FORMELFLD: + case SwFieldTypesEnum::Formel: { OUString sId(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND)); rWidget.insert(0, SwResId(FMT_GETVAR_NAME), &sId, nullptr, nullptr); } break; - case TYP_GETFLD: + case SwFieldTypesEnum::Get: { OUString sId(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND)); rWidget.insert(0, SwResId(FMT_GETVAR_NAME), &sId, nullptr, nullptr); } break; + + default: break; } if (IsFieldEdit() && bSpecialFormat) { - if (nTypeId == TYP_USERFLD && (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_CMD)) + if (nTypeId == SwFieldTypesEnum::User && (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_CMD)) rWidget.select(1); else rWidget.select(0); @@ -796,7 +797,7 @@ IMPL_LINK_NOARG(SwFieldVarPage, ModifyHdl, weld::Entry&, void) { OUString sValue(m_xValueED->get_text()); bool bHasValue = !sValue.isEmpty(); - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); bool bInsert = false, bApply = false, bDelete = false; OUString sName( m_xNameED->get_text() ); @@ -804,10 +805,10 @@ IMPL_LINK_NOARG(SwFieldVarPage, ModifyHdl, weld::Entry&, void) switch( nTypeId ) { - case TYP_DDEFLD: - case TYP_USERFLD: - case TYP_SETFLD: - case TYP_SEQFLD: + case SwFieldTypesEnum::DDE: + case SwFieldTypesEnum::User: + case SwFieldTypesEnum::Set: + case SwFieldTypesEnum::Sequence: SwCalc::IsValidVarName( sName, &sName ); if ( sName.getLength() != nLen ) { @@ -818,12 +819,13 @@ IMPL_LINK_NOARG(SwFieldVarPage, ModifyHdl, weld::Entry&, void) m_xNameED->select_region(nStartPos, nEndPos); // restore Cursorpos } break; + default: break; } // check buttons switch (nTypeId) { - case TYP_DDEFLD: + case SwFieldTypesEnum::DDE: if( nLen ) { // is there already a corresponding type @@ -839,7 +841,7 @@ IMPL_LINK_NOARG(SwFieldVarPage, ModifyHdl, weld::Entry&, void) } break; - case TYP_USERFLD: + case SwFieldTypesEnum::User: if( nLen ) { // is there already a corresponding type @@ -864,7 +866,7 @@ IMPL_LINK_NOARG(SwFieldVarPage, ModifyHdl, weld::Entry&, void) default: bInsert = true; - if (nTypeId == TYP_SETFLD || nTypeId == TYP_SEQFLD) + if (nTypeId == SwFieldTypesEnum::Set || nTypeId == SwFieldTypesEnum::Sequence) { SwSetExpFieldType* pFieldType = static_cast<SwSetExpFieldType*>( GetFieldMgr().GetFieldType(SwFieldIds::SetExp, sName)); @@ -890,10 +892,10 @@ IMPL_LINK_NOARG(SwFieldVarPage, ModifyHdl, weld::Entry&, void) if (i >= INIT_FLDTYPES && !pSh->IsUsed(*pFieldType)) bDelete = true; - if (nTypeId == TYP_SEQFLD && !(pFieldType->GetType() & nsSwGetSetExpType::GSE_SEQ)) + if (nTypeId == SwFieldTypesEnum::Sequence && !(pFieldType->GetType() & nsSwGetSetExpType::GSE_SEQ)) bInsert = false; - if (nTypeId == TYP_SETFLD && (pFieldType->GetType() & nsSwGetSetExpType::GSE_SEQ)) + if (nTypeId == SwFieldTypesEnum::Set && (pFieldType->GetType() & nsSwGetSetExpType::GSE_SEQ)) bInsert = false; } } @@ -901,11 +903,11 @@ IMPL_LINK_NOARG(SwFieldVarPage, ModifyHdl, weld::Entry&, void) bInsert = false; } - if (!nLen && (nTypeId == TYP_SETFLD || nTypeId == TYP_INPUTFLD || - (!IsFieldEdit() && nTypeId == TYP_GETFLD ) ) ) + if (!nLen && (nTypeId == SwFieldTypesEnum::Set || nTypeId == SwFieldTypesEnum::Input || + (!IsFieldEdit() && nTypeId == SwFieldTypesEnum::Get ) ) ) bInsert = false; - if( (nTypeId == TYP_SETFLD || nTypeId == TYP_FORMELFLD) && + if( (nTypeId == SwFieldTypesEnum::Set || nTypeId == SwFieldTypesEnum::Formel) && !bHasValue ) bInsert = false; break; @@ -918,11 +920,11 @@ IMPL_LINK_NOARG(SwFieldVarPage, ModifyHdl, weld::Entry&, void) IMPL_LINK(SwFieldVarPage, TBClickHdl, weld::Button&, rBox, void) { - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); if (&rBox == m_xDelPB.get()) { - if( nTypeId == TYP_USERFLD ) + if( nTypeId == SwFieldTypesEnum::User ) GetFieldMgr().RemoveFieldType(SwFieldIds::User, m_xSelectionLB->get_selected_text()); else { @@ -930,8 +932,8 @@ IMPL_LINK(SwFieldVarPage, TBClickHdl, weld::Button&, rBox, void) switch(nTypeId) { - case TYP_SETFLD: - case TYP_SEQFLD: + case SwFieldTypesEnum::Set: + case SwFieldTypesEnum::Sequence: nWhich = SwFieldIds::SetExp; break; default: @@ -960,9 +962,10 @@ IMPL_LINK(SwFieldVarPage, TBClickHdl, weld::Button&, rBox, void) switch (nTypeId) { - case TYP_USERFLD: nId = SwFieldIds::User; break; - case TYP_DDEFLD: nId = SwFieldIds::Dde; break; - case TYP_SETFLD: nId = SwFieldIds::SetExp;break; + case SwFieldTypesEnum::User: nId = SwFieldIds::User; break; + case SwFieldTypesEnum::DDE: nId = SwFieldIds::Dde; break; + case SwFieldTypesEnum::Set: nId = SwFieldIds::SetExp;break; + default: break; } pType = GetFieldMgr().GetFieldType(nId, sName); @@ -979,7 +982,7 @@ IMPL_LINK(SwFieldVarPage, TBClickHdl, weld::Button&, rBox, void) { pSh->StartAllAction(); - if (nTypeId == TYP_USERFLD) + if (nTypeId == SwFieldTypesEnum::User) { if (nNumFormatPos != -1) { @@ -1015,7 +1018,7 @@ IMPL_LINK(SwFieldVarPage, TBClickHdl, weld::Button&, rBox, void) } else // new { - if(nTypeId == TYP_USERFLD) + if(nTypeId == SwFieldTypesEnum::User) { SwWrtShell *pSh = GetWrtShell(); if(!pSh) @@ -1076,7 +1079,7 @@ IMPL_LINK_NOARG(SwFieldVarPage, SeparatorHdl, weld::Entry&, void) bool SwFieldVarPage::FillItemSet(SfxItemSet* ) { - const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); + const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); OUString aVal(m_xValueED->get_text()); OUString aName(m_xNameED->get_text()); @@ -1116,7 +1119,7 @@ bool SwFieldVarPage::FillItemSet(SfxItemSet* ) sal_Unicode cSeparator = ' '; switch (nTypeId) { - case TYP_USERFLD: + case SwFieldTypesEnum::User: { nSubType = (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR; @@ -1127,28 +1130,28 @@ bool SwFieldVarPage::FillItemSet(SfxItemSet* ) nSubType |= nsSwExtendedSubType::SUB_INVISIBLE; break; } - case TYP_FORMELFLD: + case SwFieldTypesEnum::Formel: { nSubType = nsSwGetSetExpType::GSE_FORMULA; if (m_xNumFormatLB->get_visible() && nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) nSubType |= nsSwExtendedSubType::SUB_CMD; break; } - case TYP_GETFLD: + case SwFieldTypesEnum::Get: { nSubType &= 0xff00; if (m_xNumFormatLB->get_visible() && nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) nSubType |= nsSwExtendedSubType::SUB_CMD; break; } - case TYP_INPUTFLD: + case SwFieldTypesEnum::Input: { SwFieldType* pType = GetFieldMgr().GetFieldType(SwFieldIds::User, aName); nSubType = static_cast< sal_uInt16 >((nSubType & 0xff00) | (pType ? INP_USR : INP_VAR)); break; } - case TYP_SETFLD: + case SwFieldTypesEnum::Set: { if (IsFieldDlgHtmlMode()) { @@ -1162,7 +1165,7 @@ bool SwFieldVarPage::FillItemSet(SfxItemSet* ) nSubType |= nsSwExtendedSubType::SUB_INVISIBLE; break; } - case TYP_SEQFLD: + case SwFieldTypesEnum::Sequence: { nSubType = static_cast< sal_uInt16 >(m_xChapterLevelLB->get_active()); if (nSubType == 0) @@ -1175,10 +1178,11 @@ bool SwFieldVarPage::FillItemSet(SfxItemSet* ) } break; } - case TYP_GETREFPAGEFLD: + case SwFieldTypesEnum::GetRefPage: if( SVX_NUM_CHAR_SPECIAL == nFormat ) aVal = m_xValueED->get_text(); break; + default: break; } if (!IsFieldEdit() || diff --git a/sw/source/ui/fldui/fldvar.hxx b/sw/source/ui/fldui/fldvar.hxx index 323e01ef2b58..245f575db77d 100644 --- a/sw/source/ui/fldui/fldvar.hxx +++ b/sw/source/ui/fldui/fldvar.hxx @@ -63,7 +63,7 @@ class SwFieldVarPage : public SwFieldPage void SubTypeHdl(const weld::TreeView*); void UpdateSubType(); - void FillFormatLB(sal_uInt16 nTypeId); + void FillFormatLB(SwFieldTypesEnum nTypeId); protected: virtual sal_uInt16 GetGroup() override; diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx index ba85d16fcb5f..823431d6f888 100644 --- a/sw/source/ui/frmdlg/cption.cxx +++ b/sw/source/ui/frmdlg/cption.cxx @@ -232,11 +232,11 @@ SwCaptionDialog::SwCaptionDialog(weld::Window *pParent, SwView &rV) } } - sal_uInt16 nFormatCount = pMgr->GetFormatCount(TYP_SEQFLD, false); + sal_uInt16 nFormatCount = pMgr->GetFormatCount(SwFieldTypesEnum::Sequence, false); for ( sal_uInt16 i = 0; i < nFormatCount; ++i ) { - const sal_uInt16 nFormatId = pMgr->GetFormatId(TYP_SEQFLD, i); - m_xFormatBox->append(OUString::number(nFormatId), pMgr->GetFormatStr(TYP_SEQFLD, i)); + const sal_uInt16 nFormatId = pMgr->GetFormatId(SwFieldTypesEnum::Sequence, i); + m_xFormatBox->append(OUString::number(nFormatId), pMgr->GetFormatStr(SwFieldTypesEnum::Sequence, i)); if (nFormatId == nSelFormat) m_xFormatBox->set_active(i); } diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index 0d2c9f5a0bbb..33a0eab8cd69 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -1232,7 +1232,7 @@ IMPL_LINK_NOARG(SwAuthorMarkPane, InsertHdl, weld::Button&, void) xNewData->SetAuthorField(static_cast<ToxAuthorityField>(i), m_sFields[i]); pSh->ChangeAuthorityData(xNewData.get()); } - SwInsertField_Data aData(TYP_AUTHORITY, 0, sFields.makeStringAndClear(), OUString(), 0 ); + SwInsertField_Data aData(SwFieldTypesEnum::Authority, 0, sFields.makeStringAndClear(), OUString(), 0 ); aMgr.InsertField( aData ); } else if(aMgr.GetCurField()) diff --git a/sw/source/uibase/app/appenv.cxx b/sw/source/uibase/app/appenv.cxx index 7f6a13c476e1..c4ce58a03c01 100644 --- a/sw/source/uibase/app/appenv.cxx +++ b/sw/source/uibase/app/appenv.cxx @@ -112,7 +112,7 @@ OUString InsertLabEnvText( SwWrtShell& rSh, SwFieldMgr& rFieldMgr, const OUStrin if (comphelper::string::getTokenCount(sDBName, '.') >= 3) { sDBName = ::ReplacePoint(sDBName, true); - SwInsertField_Data aData(TYP_DBFLD, 0, sDBName, OUString(), 0, &rSh); + SwInsertField_Data aData(SwFieldTypesEnum::Database, 0, sDBName, OUString(), 0, &rSh); rFieldMgr.InsertField( aData ); sRet = sDBName; bField = true; diff --git a/sw/source/uibase/app/applab.cxx b/sw/source/uibase/app/applab.cxx index 85f72818d506..5ca5eb8e8b49 100644 --- a/sw/source/uibase/app/applab.cxx +++ b/sw/source/uibase/app/applab.cxx @@ -142,7 +142,7 @@ static const SwFrameFormat *lcl_InsertLabText( SwWrtShell& rSh, const SwLabItem& if( (!rItem.m_bSynchron || !(nCol|nRow)) && !(sDBName = InsertLabEnvText( rSh, rFieldMgr, rItem.m_aWriting )).isEmpty() && !bLast ) { sDBName = comphelper::string::setToken(sDBName, 3, DB_DELIM, "True"); - SwInsertField_Data aData(TYP_DBNEXTSETFLD, 0, sDBName, OUString(), 0, &rSh); + SwInsertField_Data aData(SwFieldTypesEnum::DatabaseNextSet, 0, sDBName, OUString(), 0, &rSh); rFieldMgr.InsertField( aData ); } diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 8513e2060c4c..cb1fff7214ee 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -2206,7 +2206,7 @@ bool SwDBManager::FillCalcWithMergeData( SvNumberFormatter *pDocFormatter, // add the "record number" variable, as SwCalc::VarLook would. rCalc.VarChange( GetAppCharClass().lowercase( - SwFieldType::GetTypeStr(TYP_DBSETNUMBERFLD) ), GetSelectedRecordId() ); + SwFieldType::GetTypeStr(SwFieldTypesEnum::DatabaseSetNumber) ), GetSelectedRecordId() ); for( const OUString& rColName : aColNames ) { diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 214a90c26e9c..8c2d5e389bfc 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -3324,26 +3324,26 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) GetView().GetViewFrame()->GetBindings().Execute( FN_EDIT_FOOTNOTE ); else { - sal_uInt16 nTypeId = pField->GetTypeId(); + SwFieldTypesEnum nTypeId = pField->GetTypeId(); SfxViewFrame* pVFrame = GetView().GetViewFrame(); switch( nTypeId ) { - case TYP_POSTITFLD: - case TYP_SCRIPTFLD: + case SwFieldTypesEnum::Postit: + case SwFieldTypesEnum::Script: { // if it's a Readonly region, status has to be enabled - sal_uInt16 nSlot = TYP_POSTITFLD == nTypeId ? FN_POSTIT : FN_JAVAEDIT; + sal_uInt16 nSlot = SwFieldTypesEnum::Postit == nTypeId ? FN_POSTIT : FN_JAVAEDIT; SfxBoolItem aItem(nSlot, true); pVFrame->GetBindings().SetState(aItem); pVFrame->GetBindings().Execute(nSlot); break; } - case TYP_AUTHORITY : + case SwFieldTypesEnum::Authority : pVFrame->GetBindings().Execute(FN_EDIT_AUTH_ENTRY_DLG); break; - case TYP_INPUTFLD: - case TYP_DROPDOWN: - case TYP_SETINPFLD: + case SwFieldTypesEnum::Input: + case SwFieldTypesEnum::Dropdown: + case SwFieldTypesEnum::SetInput: pVFrame->GetBindings().Execute(FN_UPDATE_INPUTFIELDS); break; default: diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 65acd7366a06..bf65c6034008 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -291,7 +291,7 @@ static const char* FMT_USERVAR_ARY[] = // field types and subtypes struct SwFieldPack { - sal_uInt16 const nTypeId; + SwFieldTypesEnum const nTypeId; const char** pSubTypeResIds; size_t const nSubTypeLength; @@ -304,55 +304,55 @@ struct SwFieldPack static const SwFieldPack aSwFields[] = { // Document - { TYP_EXTUSERFLD, FLD_EU_ARY, SAL_N_ELEMENTS(FLD_EU_ARY), nullptr, 0 }, - { TYP_AUTHORFLD, nullptr, 0, FMT_AUTHOR_ARY, SAL_N_ELEMENTS(FMT_AUTHOR_ARY) }, - { TYP_DATEFLD, FLD_DATE_ARY, SAL_N_ELEMENTS(FLD_DATE_ARY), nullptr, 0 }, - { TYP_TIMEFLD, FLD_TIME_ARY, SAL_N_ELEMENTS(FLD_TIME_ARY), nullptr, 0 }, - { TYP_PAGENUMBERFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) -1 }, - { TYP_NEXTPAGEFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) }, - { TYP_PREVPAGEFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) }, - { TYP_FILENAMEFLD, nullptr, 0, FMT_FF_ARY, SAL_N_ELEMENTS(FMT_FF_ARY) }, - { TYP_DOCSTATFLD, FLD_STAT_ARY, SAL_N_ELEMENTS(FLD_STAT_ARY), FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) -1 }, - - { TYP_CHAPTERFLD, nullptr, 0, FMT_CHAPTER_ARY, SAL_N_ELEMENTS(FMT_CHAPTER_ARY) }, - { TYP_TEMPLNAMEFLD, nullptr, 0, FMT_FF_ARY, SAL_N_ELEMENTS(FMT_FF_ARY) }, - { TYP_PARAGRAPHSIGFLD, nullptr, 0, nullptr, 0 }, + { SwFieldTypesEnum::ExtendedUser, FLD_EU_ARY, SAL_N_ELEMENTS(FLD_EU_ARY), nullptr, 0 }, + { SwFieldTypesEnum::Author, nullptr, 0, FMT_AUTHOR_ARY, SAL_N_ELEMENTS(FMT_AUTHOR_ARY) }, + { SwFieldTypesEnum::Date, FLD_DATE_ARY, SAL_N_ELEMENTS(FLD_DATE_ARY), nullptr, 0 }, + { SwFieldTypesEnum::Time, FLD_TIME_ARY, SAL_N_ELEMENTS(FLD_TIME_ARY), nullptr, 0 }, + { SwFieldTypesEnum::PageNumber, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) -1 }, + { SwFieldTypesEnum::NextPage, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) }, + { SwFieldTypesEnum::PreviousPage, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) }, + { SwFieldTypesEnum::Filename, nullptr, 0, FMT_FF_ARY, SAL_N_ELEMENTS(FMT_FF_ARY) }, + { SwFieldTypesEnum::DocumentStatistics, FLD_STAT_ARY, SAL_N_ELEMENTS(FLD_STAT_ARY), FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) -1 }, + + { SwFieldTypesEnum::Chapter, nullptr, 0, FMT_CHAPTER_ARY, SAL_N_ELEMENTS(FMT_CHAPTER_ARY) }, + { SwFieldTypesEnum::TemplateName, nullptr, 0, FMT_FF_ARY, SAL_N_ELEMENTS(FMT_FF_ARY) }, + { SwFieldTypesEnum::ParagraphSignature, nullptr, 0, nullptr, 0 }, // Functions - { TYP_CONDTXTFLD, nullptr, 0, nullptr, 0 }, - { TYP_DROPDOWN, nullptr, 0, nullptr, 0 }, - { TYP_INPUTFLD, FLD_INPUT_ARY, SAL_N_ELEMENTS(FLD_INPUT_ARY), nullptr, 0 }, - { TYP_MACROFLD, nullptr, 0, nullptr, 0 }, - { TYP_JUMPEDITFLD, nullptr, 0, FMT_MARK_ARY, SAL_N_ELEMENTS(FMT_MARK_ARY) }, - { TYP_COMBINED_CHARS, nullptr, 0, nullptr, 0 }, - { TYP_HIDDENTXTFLD, nullptr, 0, nullptr, 0 }, - { TYP_HIDDENPARAFLD, nullptr, 0, nullptr, 0 }, + { SwFieldTypesEnum::ConditionalText, nullptr, 0, nullptr, 0 }, + { SwFieldTypesEnum::Dropdown, nullptr, 0, nullptr, 0 }, + { SwFieldTypesEnum::Input, FLD_INPUT_ARY, SAL_N_ELEMENTS(FLD_INPUT_ARY), nullptr, 0 }, + { SwFieldTypesEnum::Macro, nullptr, 0, nullptr, 0 }, + { SwFieldTypesEnum::JumpEdit, nullptr, 0, FMT_MARK_ARY, SAL_N_ELEMENTS(FMT_MARK_ARY) }, + { SwFieldTypesEnum::CombinedChars, nullptr, 0, nullptr, 0 }, + { SwFieldTypesEnum::HiddenText, nullptr, 0, nullptr, 0 }, + { SwFieldTypesEnum::HiddenParagraph, nullptr, 0, nullptr, 0 }, // Cross-References - { TYP_SETREFFLD, nullptr, 0, nullptr, 0 }, - { TYP_GETREFFLD, nullptr, 0, FMT_REF_ARY, SAL_N_ELEMENTS(FMT_REF_ARY) }, + { SwFieldTypesEnum::SetRef, nullptr, 0, nullptr, 0 }, + { SwFieldTypesEnum::GetRef, nullptr, 0, FMT_REF_ARY, SAL_N_ELEMENTS(FMT_REF_ARY) }, // DocInformation - { TYP_DOCINFOFLD, nullptr, 0, FMT_REG_ARY, SAL_N_ELEMENTS(FMT_REG_ARY) }, + { SwFieldTypesEnum::DocumentInfo, nullptr, 0, FMT_REG_ARY, SAL_N_ELEMENTS(FMT_REG_ARY) }, // Database - { TYP_DBFLD, nullptr, 0, FMT_DBFLD_ARY, SAL_N_ELEMENTS(FMT_DBFLD_ARY) }, - { TYP_DBNEXTSETFLD, nullptr, 0, nullptr, 0 }, - { TYP_DBNUMSETFLD, nullptr, 0, nullptr, 0 }, - { TYP_DBSETNUMBERFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 2 }, - { TYP_DBNAMEFLD, nullptr, 0, nullptr, 0 }, + { SwFieldTypesEnum::Database, nullptr, 0, FMT_DBFLD_ARY, SAL_N_ELEMENTS(FMT_DBFLD_ARY) }, + { SwFieldTypesEnum::DatabaseNextSet, nullptr, 0, nullptr, 0 }, + { SwFieldTypesEnum::DatabaseNumberSet, nullptr, 0, nullptr, 0 }, + { SwFieldTypesEnum::DatabaseSetNumber, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 2 }, + { SwFieldTypesEnum::DatabaseName, nullptr, 0, nullptr, 0 }, // Variables - { TYP_SETFLD, nullptr, 0, FMT_SETVAR_ARY, SAL_N_ELEMENTS(FMT_SETVAR_ARY) }, - - { TYP_GETFLD, nullptr, 0, FMT_GETVAR_ARY, SAL_N_ELEMENTS(FMT_GETVAR_ARY) }, - { TYP_DDEFLD, nullptr, 0, FMT_DDE_ARY, SAL_N_ELEMENTS(FMT_DDE_ARY) }, - { TYP_FORMELFLD, nullptr, 0, FMT_GETVAR_ARY, SAL_N_ELEMENTS(FMT_GETVAR_ARY) }, - { TYP_INPUTFLD, FLD_INPUT_ARY, SAL_N_ELEMENTS(FLD_INPUT_ARY), nullptr, 0 }, - { TYP_SEQFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 2 }, - { TYP_SETREFPAGEFLD, FLD_PAGEREF_ARY, SAL_N_ELEMENTS(FLD_PAGEREF_ARY),nullptr, 0 }, - { TYP_GETREFPAGEFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 1 }, - { TYP_USERFLD, nullptr, 0, FMT_USERVAR_ARY, SAL_N_ELEMENTS(FMT_USERVAR_ARY) } + { SwFieldTypesEnum::Set, nullptr, 0, FMT_SETVAR_ARY, SAL_N_ELEMENTS(FMT_SETVAR_ARY) }, + + { SwFieldTypesEnum::Get, nullptr, 0, FMT_GETVAR_ARY, SAL_N_ELEMENTS(FMT_GETVAR_ARY) }, + { SwFieldTypesEnum::DDE, nullptr, 0, FMT_DDE_ARY, SAL_N_ELEMENTS(FMT_DDE_ARY) }, + { SwFieldTypesEnum::Formel, nullptr, 0, FMT_GETVAR_ARY, SAL_N_ELEMENTS(FMT_GETVAR_ARY) }, + { SwFieldTypesEnum::Input, FLD_INPUT_ARY, SAL_N_ELEMENTS(FLD_INPUT_ARY), nullptr, 0 }, + { SwFieldTypesEnum::Sequence, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 2 }, + { SwFieldTypesEnum::SetRefPage, FLD_PAGEREF_ARY, SAL_N_ELEMENTS(FLD_PAGEREF_ARY),nullptr, 0 }, + { SwFieldTypesEnum::GetRefPage, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 1 }, + { SwFieldTypesEnum::User, nullptr, 0, FMT_USERVAR_ARY, SAL_N_ELEMENTS(FMT_USERVAR_ARY) } }; // access to the shell @@ -449,7 +449,7 @@ SwField* SwFieldMgr::GetCurField() // preprocess current values; determine parameter 1 and parameter 2 // as well as the format - const sal_uInt16 nTypeId = m_pCurField->GetTypeId(); + const SwFieldTypesEnum nTypeId = m_pCurField->GetTypeId(); m_nCurFormat = m_pCurField->GetFormat(); m_aCurPar1 = m_pCurField->GetPar1(); @@ -457,13 +457,14 @@ SwField* SwFieldMgr::GetCurField() switch( nTypeId ) { - case TYP_PAGENUMBERFLD: - case TYP_NEXTPAGEFLD: - case TYP_PREVPAGEFLD: - case TYP_GETREFPAGEFLD: + case SwFieldTypesEnum::PageNumber: + case SwFieldTypesEnum::NextPage: + case SwFieldTypesEnum::PreviousPage: + case SwFieldTypesEnum::GetRefPage: if( m_nCurFormat == SVX_NUM_PAGEDESC ) m_nCurFormat -= 2; break; + default: break; } return m_pCurField; } @@ -497,19 +498,19 @@ const SwFieldGroupRgn& SwFieldMgr::GetGroupRange(bool bHtmlMode, sal_uInt16 nGrp } // determine GroupId -sal_uInt16 SwFieldMgr::GetGroup(sal_uInt16 nTypeId, sal_uInt16 nSubType) +sal_uInt16 SwFieldMgr::GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType) { - if (nTypeId == TYP_SETINPFLD) - nTypeId = TYP_SETFLD; + if (nTypeId == SwFieldTypesEnum::SetInput) + nTypeId = SwFieldTypesEnum::Set; - if (nTypeId == TYP_INPUTFLD && (nSubType & INP_USR)) - nTypeId = TYP_USERFLD; + if (nTypeId == SwFieldTypesEnum::Input && (nSubType & INP_USR)) + nTypeId = SwFieldTypesEnum::User; - if (nTypeId == TYP_FIXDATEFLD) - nTypeId = TYP_DATEFLD; + if (nTypeId == SwFieldTypesEnum::FixedDate) + nTypeId = SwFieldTypesEnum::Date; - if (nTypeId == TYP_FIXTIMEFLD) - nTypeId = TYP_TIMEFLD; + if (nTypeId == SwFieldTypesEnum::FixedTime) + nTypeId = SwFieldTypesEnum::Time; for (sal_uInt16 i = GRP_DOC; i <= GRP_VAR; i++) { @@ -525,7 +526,7 @@ sal_uInt16 SwFieldMgr::GetGroup(sal_uInt16 nTypeId, sal_uInt16 nSubType) // determine names to TypeId // ACCESS over TYP_... -sal_uInt16 SwFieldMgr::GetTypeId(sal_uInt16 nPos) +SwFieldTypesEnum SwFieldMgr::GetTypeId(sal_uInt16 nPos) { OSL_ENSURE(nPos < ::GetPackCount(), "forbidden Pos"); return aSwFields[ nPos ].nTypeId; @@ -535,15 +536,15 @@ OUString SwFieldMgr::GetTypeStr(sal_uInt16 nPos) { OSL_ENSURE(nPos < ::GetPackCount(), "forbidden TypeId"); - sal_uInt16 nFieldWh = aSwFields[ nPos ].nTypeId; + SwFieldTypesEnum nFieldWh = aSwFields[ nPos ].nTypeId; // special treatment for date/time fields (without var/fix) - if( TYP_DATEFLD == nFieldWh ) + if( SwFieldTypesEnum::Date == nFieldWh ) { static OUString g_aDate( SwResId( STR_DATEFLD ) ); return g_aDate; } - if( TYP_TIMEFLD == nFieldWh ) + if( SwFieldTypesEnum::Time == nFieldWh ) { static OUString g_aTime( SwResId( STR_TIMEFLD ) ); return g_aTime; @@ -553,14 +554,15 @@ OUString SwFieldMgr::GetTypeStr(sal_uInt16 nPos) } // determine Pos in the list -sal_uInt16 SwFieldMgr::GetPos(sal_uInt16 nTypeId) +sal_uInt16 SwFieldMgr::GetPos(SwFieldTypesEnum nTypeId) { switch( nTypeId ) { - case TYP_FIXDATEFLD: nTypeId = TYP_DATEFLD; break; - case TYP_FIXTIMEFLD: nTypeId = TYP_TIMEFLD; break; - case TYP_SETINPFLD: nTypeId = TYP_SETFLD; break; - case TYP_USRINPFLD: nTypeId = TYP_USERFLD; break; + case SwFieldTypesEnum::FixedDate: nTypeId = SwFieldTypesEnum::Date; break; + case SwFieldTypesEnum::FixedTime: nTypeId = SwFieldTypesEnum::Time; break; + case SwFieldTypesEnum::SetInput: nTypeId = SwFieldTypesEnum::Set; break; + case SwFieldTypesEnum::UserInput: nTypeId = SwFieldTypesEnum::User; break; + default: break; } for(sal_uInt16 i = 0; i < GetPackCount(); i++) @@ -571,7 +573,7 @@ sal_uInt16 SwFieldMgr::GetPos(sal_uInt16 nTypeId) } // localise subtypes of a field -void SwFieldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill) +void SwFieldMgr::GetSubTypes(SwFieldTypesEnum nTypeId, std::vector<OUString>& rToFill) { SwWrtShell *pSh = m_pWrtShell ? m_pWrtShell : lcl_GetShell(); OSL_ENSURE(pSh, "no SwWrtShell found"); @@ -581,28 +583,28 @@ void SwFieldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill) switch(nTypeId) { - case TYP_SETREFFLD: - case TYP_GETREFFLD: + case SwFieldTypesEnum::SetRef: + case SwFieldTypesEnum::GetRef: { // references are no fields pSh->GetRefMarks( &rToFill ); break; } - case TYP_MACROFLD: + case SwFieldTypesEnum::Macro: { break; } - case TYP_INPUTFLD: + case SwFieldTypesEnum::Input: { rToFill.push_back(SwResId(aSwFields[nPos].pSubTypeResIds[0])); [[fallthrough]]; // move on at generic types } - case TYP_DDEFLD: - case TYP_SEQFLD: - case TYP_FORMELFLD: - case TYP_GETFLD: - case TYP_SETFLD: - case TYP_USERFLD: + case SwFieldTypesEnum::DDE: + case SwFieldTypesEnum::Sequence: + case SwFieldTypesEnum::Formel: + case SwFieldTypesEnum::Get: + case SwFieldTypesEnum::Set: + case SwFieldTypesEnum::User: { const size_t nCount = pSh->GetFieldTypeCount(); @@ -611,20 +613,20 @@ void SwFieldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill) SwFieldType* pFieldType = pSh->GetFieldType( i ); const SwFieldIds nWhich = pFieldType->Which(); - if((nTypeId == TYP_DDEFLD && pFieldType->Which() == SwFieldIds::Dde) || + if((nTypeId == SwFieldTypesEnum::DDE && pFieldType->Which() == SwFieldIds::Dde) || - (nTypeId == TYP_USERFLD && nWhich == SwFieldIds::User) || + (nTypeId == SwFieldTypesEnum::User && nWhich == SwFieldIds::User) || - (nTypeId == TYP_GETFLD && nWhich == SwFieldIds::SetExp && + (nTypeId == SwFieldTypesEnum::Get && nWhich == SwFieldIds::SetExp && !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) || - (nTypeId == TYP_SETFLD && nWhich == SwFieldIds::SetExp && + (nTypeId == SwFieldTypesEnum::Set && nWhich == SwFieldIds::SetExp && !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) || - (nTypeId == TYP_SEQFLD && nWhich == SwFieldIds::SetExp && + (nTypeId == SwFieldTypesEnum::Sequence && nWhich == SwFieldIds::SetExp && (static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) || - ((nTypeId == TYP_INPUTFLD || nTypeId == TYP_FORMELFLD) && + ((nTypeId == SwFieldTypesEnum::Input || nTypeId == SwFieldTypesEnum::Formel) && (nWhich == SwFieldIds::User || (nWhich == SwFieldIds::SetExp && !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ))) ) ) @@ -634,10 +636,10 @@ void SwFieldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill) } break; } - case TYP_DBNEXTSETFLD: - case TYP_DBNUMSETFLD: - case TYP_DBNAMEFLD: - case TYP_DBSETNUMBERFLD: + case SwFieldTypesEnum::DatabaseNextSet: + case SwFieldTypesEnum::DatabaseNumberSet: + case SwFieldTypesEnum::DatabaseName: + case SwFieldTypesEnum::DatabaseSetNumber: break; default: @@ -646,7 +648,7 @@ void SwFieldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill) if(nPos != USHRT_MAX) { sal_uInt16 nCount; - if (nTypeId == TYP_DOCINFOFLD) + if (nTypeId == SwFieldTypesEnum::DocumentInfo) nCount = DI_SUBTYPE_END - DI_SUBTYPE_BEGIN; else nCount = aSwFields[nPos].nSubTypeLength; @@ -654,7 +656,7 @@ void SwFieldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill) for(sal_uInt16 i = 0; i < nCount; ++i) { OUString sNew; - if (nTypeId == TYP_DOCINFOFLD) + if (nTypeId == SwFieldTypesEnum::DocumentInfo) { if ( i == DI_CUSTOM ) sNew = SwResId(STR_CUSTOM_FIELD); @@ -674,18 +676,18 @@ void SwFieldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill) // determine format // ACCESS over TYP_... -sal_uInt16 SwFieldMgr::GetFormatCount(sal_uInt16 nTypeId, bool bHtmlMode) const +sal_uInt16 SwFieldMgr::GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const { - OSL_ENSURE(nTypeId < TYP_END, "forbidden TypeId"); + assert(nTypeId < SwFieldTypesEnum::LAST && "forbidden TypeId"); { const sal_uInt16 nPos = GetPos(nTypeId); - if (nPos == USHRT_MAX || (bHtmlMode && nTypeId == TYP_SETFLD)) + if (nPos == USHRT_MAX || (bHtmlMode && nTypeId == SwFieldTypesEnum::Set)) return 0; sal_uInt16 nCount = aSwFields[nPos].nFormatLength; - if (nTypeId == TYP_FILENAMEFLD) + if (nTypeId == SwFieldTypesEnum::Filename) nCount -= 2; // no range or template const char** pStart = aSwFields[nPos].pFormatResIds; @@ -717,9 +719,9 @@ sal_uInt16 SwFieldMgr::GetFormatCount(sal_uInt16 nTypeId, bool bHtmlMode) const } // determine FormatString to a type -OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const +OUString SwFieldMgr::GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const { - OSL_ENSURE(nTypeId < TYP_END, "forbidden TypeId"); + assert(nTypeId < SwFieldTypesEnum::LAST && "forbidden TypeId"); const sal_uInt16 nPos = GetPos(nTypeId); if (nPos == USHRT_MAX) @@ -729,7 +731,7 @@ OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uInt32 nFormatId) cons if (!pStart) return OUString(); - if (TYP_AUTHORFLD == nTypeId|| TYP_FILENAMEFLD == nTypeId) + if (SwFieldTypesEnum::Author == nTypeId || SwFieldTypesEnum::Filename == nTypeId) nFormatId &= ~static_cast<sal_uInt32>(FF_FIXED); // mask out Fixed-Flag if (nFormatId < aSwFields[nPos].nFormatLength) @@ -771,12 +773,12 @@ OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uInt32 nFormatId) cons } // determine FormatId from Pseudo-ID -sal_uInt16 SwFieldMgr::GetFormatId(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const +sal_uInt16 SwFieldMgr::GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const { sal_uInt16 nId = static_cast<sal_uInt16>(nFormatId); switch( nTypeId ) { - case TYP_DOCINFOFLD: + case SwFieldTypesEnum::DocumentInfo: { const OString sId(aSwFields[GetPos(nTypeId)].pFormatResIds[nFormatId]); if (sId == FMT_REG_AUTHOR) @@ -787,13 +789,13 @@ sal_uInt16 SwFieldMgr::GetFormatId(sal_uInt16 nTypeId, sal_uInt32 nFormatId) con nId = DI_SUB_DATE; break; } - case TYP_PAGENUMBERFLD: - case TYP_NEXTPAGEFLD: - case TYP_PREVPAGEFLD: - case TYP_DOCSTATFLD: - case TYP_DBSETNUMBERFLD: - case TYP_SEQFLD: - case TYP_GETREFPAGEFLD: + case SwFieldTypesEnum::PageNumber: + case SwFieldTypesEnum::NextPage: + case SwFieldTypesEnum::PreviousPage: + case SwFieldTypesEnum::DocumentStatistics: + case SwFieldTypesEnum::DatabaseSetNumber: + case SwFieldTypesEnum::Sequence: + case SwFieldTypesEnum::GetRefPage: { sal_uInt16 nPos = GetPos(nTypeId); if (nFormatId < aSwFields[nPos].nFormatLength) @@ -838,7 +840,7 @@ sal_uInt16 SwFieldMgr::GetFormatId(sal_uInt16 nTypeId, sal_uInt32 nFormatId) con } break; } - case TYP_DDEFLD: + case SwFieldTypesEnum::DDE: { const OString sId(aSwFields[GetPos(nTypeId)].pFormatResIds[nFormatId]); if (sId == FMT_DDE_NORMAL) @@ -847,6 +849,7 @@ sal_uInt16 SwFieldMgr::GetFormatId(sal_uInt16 nTypeId, sal_uInt32 nFormatId) con nId = static_cast<sal_uInt16>(SfxLinkUpdateMode::ALWAYS); break; } + default: break; } return nId; } @@ -860,8 +863,8 @@ bool SwFieldMgr::GoNextPrev( bool bNext, SwFieldType* pTyp ) if( !pTyp && m_pCurField ) { - const sal_uInt16 nTypeId = m_pCurField->GetTypeId(); - if( TYP_SETINPFLD == nTypeId || TYP_USRINPFLD == nTypeId ) + const SwFieldTypesEnum nTypeId = m_pCurField->GetTypeId(); + if( SwFieldTypesEnum::SetInput == nTypeId || SwFieldTypesEnum::UserInput == nTypeId ) pTyp = pSh->GetFieldType( 0, SwFieldIds::Input ); else pTyp = m_pCurField->GetTyp(); @@ -886,9 +889,9 @@ void SwFieldMgr::InsertFieldType(SwFieldType const & rType) } // determine current TypeId -sal_uInt16 SwFieldMgr::GetCurTypeId() const +SwFieldTypesEnum SwFieldMgr::GetCurTypeId() const { - return m_pCurField ? m_pCurField->GetTypeId() : USHRT_MAX; + return m_pCurField ? m_pCurField->GetTypeId() : SwFieldTypesEnum::Unknown; } // Over string insert field or update @@ -911,7 +914,7 @@ bool SwFieldMgr::InsertField( switch (rData.m_nTypeId) { // ATTENTION this field is inserted by a separate dialog - case TYP_POSTITFLD: + case SwFieldTypesEnum::Postit: { SvtUserOptions aUserOpt; SwPostItFieldType* pType = static_cast<SwPostItFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Postit)); @@ -925,7 +928,7 @@ bool SwFieldMgr::InsertField( DateTime(DateTime::SYSTEM) )); } break; - case TYP_SCRIPTFLD: + case SwFieldTypesEnum::Script: { SwScriptFieldType* pType = static_cast<SwScriptFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Script)); @@ -933,7 +936,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_COMBINED_CHARS: + case SwFieldTypesEnum::CombinedChars: { SwCombinedCharFieldType* pType = static_cast<SwCombinedCharFieldType*>( pCurShell->GetFieldType( 0, SwFieldIds::CombinedChars )); @@ -941,7 +944,7 @@ bool SwFieldMgr::InsertField( } break; - case TYP_AUTHORITY: + case SwFieldTypesEnum::Authority: { SwAuthorityFieldType* pType = static_cast<SwAuthorityFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::TableOfAuthorities)); @@ -955,10 +958,10 @@ bool SwFieldMgr::InsertField( } break; - case TYP_DATEFLD: - case TYP_TIMEFLD: + case SwFieldTypesEnum::Date: + case SwFieldTypesEnum::Time: { - sal_uInt16 nSub = static_cast< sal_uInt16 >(rData.m_nTypeId == TYP_DATEFLD ? DATEFLD : TIMEFLD); + sal_uInt16 nSub = static_cast< sal_uInt16 >(rData.m_nTypeId == SwFieldTypesEnum::Date ? DATEFLD : TIMEFLD); nSub |= nSubType == DATE_VAR ? 0 : FIXEDFLD; SwDateTimeFieldType* pTyp = @@ -968,7 +971,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_FILENAMEFLD: + case SwFieldTypesEnum::Filename: { SwFileNameFieldType* pTyp = static_cast<SwFileNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Filename) ); @@ -976,7 +979,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_TEMPLNAMEFLD: + case SwFieldTypesEnum::TemplateName: { SwTemplNameFieldType* pTyp = static_cast<SwTemplNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::TemplateName) ); @@ -984,7 +987,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_CHAPTERFLD: + case SwFieldTypesEnum::Chapter: { sal_uInt16 nByte = static_cast<sal_uInt16>(rData.m_sPar2.toInt32()); SwChapterFieldType* pTyp = @@ -997,13 +1000,13 @@ bool SwFieldMgr::InsertField( break; } - case TYP_NEXTPAGEFLD: - case TYP_PREVPAGEFLD: - case TYP_PAGENUMBERFLD: + case SwFieldTypesEnum::NextPage: + case SwFieldTypesEnum::PreviousPage: + case SwFieldTypesEnum::PageNumber: { short nOff = static_cast<short>(rData.m_sPar2.toInt32()); - if(rData.m_nTypeId == TYP_NEXTPAGEFLD) + if(rData.m_nTypeId == SwFieldTypesEnum::NextPage) { if( SVX_NUM_CHAR_SPECIAL == nFormatId ) nOff = 1; @@ -1011,7 +1014,7 @@ bool SwFieldMgr::InsertField( nOff += 1; nSubType = PG_NEXT; } - else if(rData.m_nTypeId == TYP_PREVPAGEFLD) + else if(rData.m_nTypeId == SwFieldTypesEnum::PreviousPage) { if( SVX_NUM_CHAR_SPECIAL == nFormatId ) nOff = -1; @@ -1032,7 +1035,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_DOCSTATFLD: + case SwFieldTypesEnum::DocumentStatistics: { SwDocStatFieldType* pTyp = static_cast<SwDocStatFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DocStat) ); @@ -1040,7 +1043,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_AUTHORFLD: + case SwFieldTypesEnum::Author: { SwAuthorFieldType* pTyp = static_cast<SwAuthorFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Author) ); @@ -1048,8 +1051,8 @@ bool SwFieldMgr::InsertField( break; } - case TYP_CONDTXTFLD: - case TYP_HIDDENTXTFLD: + case SwFieldTypesEnum::ConditionalText: + case SwFieldTypesEnum::HiddenText: { SwHiddenTextFieldType* pTyp = static_cast<SwHiddenTextFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::HiddenText) ); @@ -1058,7 +1061,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_HIDDENPARAFLD: + case SwFieldTypesEnum::HiddenParagraph: { SwHiddenParaFieldType* pTyp = static_cast<SwHiddenParaFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::HiddenPara) ); @@ -1067,7 +1070,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_SETREFFLD: + case SwFieldTypesEnum::SetRef: { if( !rData.m_sPar1.isEmpty() && CanInsertRefMark( rData.m_sPar1 ) ) { @@ -1077,7 +1080,7 @@ bool SwFieldMgr::InsertField( return false; } - case TYP_GETREFFLD: + case SwFieldTypesEnum::GetRef: { SwGetRefFieldType* pTyp = static_cast<SwGetRefFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::GetRef) ); @@ -1101,7 +1104,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_DDEFLD: + case SwFieldTypesEnum::DDE: { //JP 28.08.95: DDE-Topics/-Items can have blanks in their names! // That's not yet considered here. @@ -1118,7 +1121,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_MACROFLD: + case SwFieldTypesEnum::Macro: { SwMacroFieldType* pTyp = static_cast<SwMacroFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Macro)); @@ -1128,13 +1131,13 @@ bool SwFieldMgr::InsertField( break; } - case TYP_INTERNETFLD: + case SwFieldTypesEnum::Internet: { SwFormatINetFormat aFormat( rData.m_sPar1, m_sCurFrame ); return pCurShell->InsertURL( aFormat, rData.m_sPar2 ); } - case TYP_JUMPEDITFLD: + case SwFieldTypesEnum::JumpEdit: { SwJumpEditFieldType* pTyp = static_cast<SwJumpEditFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::JumpEdit)); @@ -1143,7 +1146,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_DOCINFOFLD: + case SwFieldTypesEnum::DocumentInfo: { SwDocInfoFieldType* pTyp = static_cast<SwDocInfoFieldType*>( pCurShell->GetFieldType( 0, SwFieldIds::DocInfo ) ); @@ -1151,7 +1154,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_EXTUSERFLD: + case SwFieldTypesEnum::ExtendedUser: { SwExtUserFieldType* pTyp = static_cast<SwExtUserFieldType*>( pCurShell->GetFieldType( 0, SwFieldIds::ExtUser) ); @@ -1159,7 +1162,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_DBFLD: + case SwFieldTypesEnum::Database: { #if HAVE_FEATURE_DBCONNECTIVITY SwDBData aDBData; @@ -1212,10 +1215,10 @@ bool SwFieldMgr::InsertField( break; } - case TYP_DBSETNUMBERFLD: - case TYP_DBNUMSETFLD: - case TYP_DBNEXTSETFLD: - case TYP_DBNAMEFLD: + case SwFieldTypesEnum::DatabaseSetNumber: + case SwFieldTypesEnum::DatabaseNumberSet: + case SwFieldTypesEnum::DatabaseNextSet: + case SwFieldTypesEnum::DatabaseName: { #if HAVE_FEATURE_DBCONNECTIVITY SwDBData aDBData; @@ -1253,7 +1256,7 @@ bool SwFieldMgr::InsertField( switch(rData.m_nTypeId) { - case TYP_DBNAMEFLD: + case SwFieldTypesEnum::DatabaseName: { SwDBNameFieldType* pTyp = static_cast<SwDBNameFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::DatabaseName)); @@ -1261,7 +1264,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_DBNEXTSETFLD: + case SwFieldTypesEnum::DatabaseNextSet: { SwDBNextSetFieldType* pTyp = static_cast<SwDBNextSetFieldType*>(pCurShell->GetFieldType( 0, SwFieldIds::DbNextSet) ); @@ -1269,7 +1272,7 @@ bool SwFieldMgr::InsertField( bExp = true; break; } - case TYP_DBNUMSETFLD: + case SwFieldTypesEnum::DatabaseNumberSet: { SwDBNumSetFieldType* pTyp = static_cast<SwDBNumSetFieldType*>( pCurShell->GetFieldType( 0, SwFieldIds::DbNumSet) ); @@ -1277,7 +1280,7 @@ bool SwFieldMgr::InsertField( bExp = true; break; } - case TYP_DBSETNUMBERFLD: + case SwFieldTypesEnum::DatabaseSetNumber: { SwDBSetNumberFieldType* pTyp = static_cast<SwDBSetNumberFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DbSetNumber) ); @@ -1285,12 +1288,13 @@ bool SwFieldMgr::InsertField( bExp = true; break; } + default: break; } #endif break; } - case TYP_USERFLD: + case SwFieldTypesEnum::User: { SwUserFieldType* pTyp = static_cast<SwUserFieldType*>( pCurShell->GetFieldType(SwFieldIds::User, rData.m_sPar1) ); @@ -1310,7 +1314,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_INPUTFLD: + case SwFieldTypesEnum::Input: { if ((nSubType & 0x00ff) == INP_VAR) { @@ -1346,7 +1350,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_SETFLD: + case SwFieldTypesEnum::Set: { if (rData.m_sPar2.isEmpty()) // empty variables are not allowed return false; @@ -1362,7 +1366,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_SEQFLD: + case SwFieldTypesEnum::Sequence: { SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>( pCurShell->InsertFieldType( SwSetExpFieldType(pCurShell->GetDoc(), rData.m_sPar1, nsSwGetSetExpType::GSE_SEQ))); @@ -1379,7 +1383,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_GETFLD: + case SwFieldTypesEnum::Get: { // is there a corresponding SetField SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>( @@ -1398,7 +1402,7 @@ bool SwFieldMgr::InsertField( break; } - case TYP_FORMELFLD: + case SwFieldTypesEnum::Formel: { if(pCurShell->GetFrameType(nullptr,false) & FrameTypeFlags::TABLE) { @@ -1442,19 +1446,19 @@ bool SwFieldMgr::InsertField( } break; } - case TYP_SETREFPAGEFLD: + case SwFieldTypesEnum::SetRefPage: pField.reset( new SwRefPageSetField( static_cast<SwRefPageSetFieldType*>( pCurShell->GetFieldType( 0, SwFieldIds::RefPageSet ) ), static_cast<short>(rData.m_sPar2.toInt32()), 0 != nSubType ) ); bPageVar = true; break; - case TYP_GETREFPAGEFLD: + case SwFieldTypesEnum::GetRefPage: pField.reset( new SwRefPageGetField( static_cast<SwRefPageGetFieldType*>( pCurShell->GetFieldType( 0, SwFieldIds::RefPageGet ) ), nFormatId ) ); bPageVar = true; break; - case TYP_DROPDOWN : + case SwFieldTypesEnum::Dropdown : { pField.reset( new SwDropDownField(pCurShell->GetFieldType( 0, SwFieldIds::Dropdown )) ); const sal_Int32 nTokenCount = comphelper::string::getTokenCount(rData.m_sPar2, DB_DELIM); @@ -1469,7 +1473,7 @@ bool SwFieldMgr::InsertField( // Insert Paragraph Signature field by signing the paragraph. // The resulting field is really a metadata field, created and added via signing. - case TYP_PARAGRAPHSIGFLD: + case SwFieldTypesEnum::ParagraphSignature: pCurShell->SignParagraph(); return true; break; @@ -1491,7 +1495,7 @@ bool SwFieldMgr::InsertField( pCurShell->Insert(*pField, rData.m_pAnnotationRange.get()); - if (TYP_INPUTFLD == rData.m_nTypeId) + if (SwFieldTypesEnum::Input == rData.m_nTypeId) { pCurShell->Push(); @@ -1514,7 +1518,7 @@ bool SwFieldMgr::InsertField( } else if( bPageVar ) static_cast<SwRefPageGetFieldType*>(pCurShell->GetFieldType( 0, SwFieldIds::RefPageGet ))->UpdateFields(); - else if( TYP_GETREFFLD == rData.m_nTypeId ) + else if( SwFieldTypesEnum::GetRef == rData.m_nTypeId ) pField->GetTyp()->ModifyNotification( nullptr, nullptr ); // delete temporary field @@ -1537,7 +1541,7 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, pTmpField = m_pCurField->CopyField(); SwFieldType* pType = pTmpField->GetTyp(); - const sal_uInt16 nTypeId = pTmpField->GetTypeId(); + const SwFieldTypesEnum nTypeId = pTmpField->GetTypeId(); SwWrtShell* pSh = m_pWrtShell ? m_pWrtShell : ::lcl_GetShell(); OSL_ENSURE(pSh, "no SwWrtShell found"); @@ -1552,7 +1556,7 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, // Order to Format switch( nTypeId ) { - case TYP_DDEFLD: + case SwFieldTypesEnum::DDE: { // DDE-Topics/-Items can have blanks in their names! // That's not yet considered here! @@ -1565,7 +1569,7 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, break; } - case TYP_CHAPTERFLD: + case SwFieldTypesEnum::Chapter: { sal_uInt16 nByte = static_cast<sal_uInt16>(rPar2.toInt32()); nByte = std::max(sal_uInt16(1), nByte); @@ -1576,11 +1580,11 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, break; } - case TYP_SCRIPTFLD: + case SwFieldTypesEnum::Script: static_cast<SwScriptField*>(pTmpField.get())->SetCodeURL(static_cast<bool>(nFormat)); break; - case TYP_NEXTPAGEFLD: + case SwFieldTypesEnum::NextPage: if( SVX_NUM_CHAR_SPECIAL == nFormat ) { static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 ); @@ -1596,7 +1600,7 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, } break; - case TYP_PREVPAGEFLD: + case SwFieldTypesEnum::PreviousPage: if( SVX_NUM_CHAR_SPECIAL == nFormat ) { static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 ); @@ -1612,13 +1616,13 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, } break; - case TYP_PAGENUMBERFLD: - case TYP_GETREFPAGEFLD: + case SwFieldTypesEnum::PageNumber: + case SwFieldTypesEnum::GetRefPage: if( nFormat + 2 == SVX_NUM_PAGEDESC ) nFormat = SVX_NUM_PAGEDESC; break; - case TYP_GETREFFLD: + case SwFieldTypesEnum::GetRef: { bSetPar2 = false; static_cast<SwGetRefField*>(pTmpField.get())->SetSubType( static_cast<sal_uInt16>(rPar2.toInt32()) ); @@ -1627,7 +1631,7 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, static_cast<SwGetRefField*>(pTmpField.get())->SetSeqNo( static_cast<sal_uInt16>(rPar2.copy( nPos + 1 ).toInt32())); } break; - case TYP_DROPDOWN: + case SwFieldTypesEnum::Dropdown: { sal_Int32 nTokenCount = comphelper::string::getTokenCount(sPar2, DB_DELIM); Sequence<OUString> aEntries(nTokenCount); @@ -1639,7 +1643,7 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, bSetPar1 = bSetPar2 = false; } break; - case TYP_AUTHORITY : + case SwFieldTypesEnum::Authority : { //#i99069# changes to a bibliography field should change the field type SwAuthorityField* pAuthorityField = static_cast<SwAuthorityField*>(pTmpField.get()); @@ -1660,6 +1664,7 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, bSetPar2 = false; } break; + default: break; } // set format @@ -1672,9 +1677,9 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat, pTmpField->SetPar2( sPar2 ); // kick off update - if(nTypeId == TYP_DDEFLD || - nTypeId == TYP_USERFLD || - nTypeId == TYP_USRINPFLD) + if(nTypeId == SwFieldTypesEnum::DDE || + nTypeId == SwFieldTypesEnum::User || + nTypeId == SwFieldTypesEnum::UserInput) { pType->UpdateFields(); pSh->SetModified(); @@ -1812,16 +1817,16 @@ void SwFieldMgr::SetMacroPath(const OUString& rPath) } } -sal_uInt32 SwFieldMgr::GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter) +sal_uInt32 SwFieldMgr::GetDefaultFormat(SwFieldTypesEnum nTypeId, bool bIsText, SvNumberFormatter* pFormatter) { SvNumFormatType nDefFormat; switch (nTypeId) { - case TYP_TIMEFLD: - case TYP_DATEFLD: + case SwFieldTypesEnum::Time: + case SwFieldTypesEnum::Date: { - nDefFormat = (nTypeId == TYP_DATEFLD) ? SvNumFormatType::DATE : SvNumFormatType::TIME; + nDefFormat = (nTypeId == SwFieldTypesEnum::Date) ? SvNumFormatType::DATE : SvNumFormatType::TIME; } break; diff --git a/sw/source/uibase/inc/fldmgr.hxx b/sw/source/uibase/inc/fldmgr.hxx index 8f5a0a791508..6046e9c50a07 100644 --- a/sw/source/uibase/inc/fldmgr.hxx +++ b/sw/source/uibase/inc/fldmgr.hxx @@ -68,7 +68,7 @@ struct SwFieldGroupRgn // with command strings struct SwInsertField_Data { - sal_uInt16 const m_nTypeId; + SwFieldTypesEnum const m_nTypeId; sal_uInt16 const m_nSubType; const OUString m_sPar1; const OUString m_sPar2; @@ -83,7 +83,7 @@ struct SwInsertField_Data /// Marks the PostIt field's annotation start/end if it differs from the cursor selection. std::unique_ptr<SwPaM> m_pAnnotationRange; - SwInsertField_Data(sal_uInt16 nType, sal_uInt16 nSub, const OUString& rPar1, const OUString& rPar2, + SwInsertField_Data(SwFieldTypesEnum nType, sal_uInt16 nSub, const OUString& rPar1, const OUString& rPar2, sal_uInt32 nFormatId, SwWrtShell* pShell = nullptr, sal_Unicode cSep = ' ', bool bIsAutoLanguage = true) : m_nTypeId(nType), m_nSubType(nSub), @@ -166,27 +166,27 @@ public: // access via TypeId from the dialog // Ids for a range of fields static const SwFieldGroupRgn& GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId); - static sal_uInt16 GetGroup(sal_uInt16 nTypeId, sal_uInt16 nSubType); + static sal_uInt16 GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType); // the current field's TypeId - sal_uInt16 GetCurTypeId() const; + SwFieldTypesEnum GetCurTypeId() const; // TypeId for a concrete position in the list - static sal_uInt16 GetTypeId(sal_uInt16 nPos); + static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos); // name of the type in the list of fields static OUString GetTypeStr(sal_uInt16 nPos); // Pos in the list of fields - static sal_uInt16 GetPos(sal_uInt16 nTypeId); + static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId); // subtypes to a type - void GetSubTypes(sal_uInt16 nId, std::vector<OUString>& rToFill); + void GetSubTypes(SwFieldTypesEnum nId, std::vector<OUString>& rToFill); // format to a type - sal_uInt16 GetFormatCount(sal_uInt16 nTypeId, bool bHtmlMode) const; - OUString GetFormatStr(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const; - sal_uInt16 GetFormatId(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const; - sal_uInt32 GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter); + sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) 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); // turn off evaluation of expression fields for insertation // of many expression fields (see labels) diff --git a/sw/source/uibase/ribbar/inputwin.cxx b/sw/source/uibase/ribbar/inputwin.cxx index 6391dabce175..09275a67339b 100644 --- a/sw/source/uibase/ribbar/inputwin.cxx +++ b/sw/source/uibase/ribbar/inputwin.cxx @@ -219,7 +219,7 @@ void SwInputWindow::ShowWin() // Form should always begin with "=" , so set here OUString sEdit('='); - if( pMgr->GetCurField() && TYP_FORMELFLD == pMgr->GetCurTypeId() ) + if( pMgr->GetCurField() && SwFieldTypesEnum::Formel == pMgr->GetCurTypeId() ) { sEdit += pMgr->GetCurFieldPar2(); } diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index bdf21d3c2e04..bd27ab4b40b0 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -127,7 +127,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) bool bMore = false; bool bIsText = true; - sal_uInt16 nInsertType = 0; + SwFieldTypesEnum nInsertType = SwFieldTypesEnum::Date; sal_uInt16 nInsertSubType = 0; sal_uInt32 nInsertFormat = 0; @@ -140,7 +140,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) { switch ( pField->GetTypeId() ) { - case TYP_DDEFLD: + case SwFieldTypesEnum::DDE: { ::sfx2::SvBaseLink& rLink = static_cast<SwDDEFieldType*>(pField->GetTyp())-> GetBaseLink(); @@ -228,14 +228,14 @@ void SwTextShell::ExecField(SfxRequest &rReq) if( pItem ) { sal_uInt32 nFormat = 0; - sal_uInt16 nType = 0; + SwFieldTypesEnum nType = SwFieldTypesEnum::Date; OUString aPar1 = static_cast<const SfxStringItem *>(pItem)->GetValue(); OUString aPar2; sal_Int32 nCommand = 0; if( SfxItemState::SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE, false, &pItem )) - nType = static_cast<const SfxUInt16Item *>(pItem)->GetValue(); + nType = static_cast<SwFieldTypesEnum>(static_cast<const SfxUInt16Item *>(pItem)->GetValue()); aPar1 += OUStringLiteral1(DB_DELIM); if( SfxItemState::SET == pArgs->GetItemState( FN_PARAM_1, false, &pItem )) @@ -273,7 +273,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) if( pItem && nSlot != FN_INSERT_FIELD_CTRL) { sal_uInt32 nFormat = 0; - sal_uInt16 nType = 0; + SwFieldTypesEnum nType = SwFieldTypesEnum::Date; sal_uInt16 nSubType = 0; OUString aPar1 = static_cast<const SfxStringItem *>(pItem)->GetValue(); OUString aPar2; @@ -281,7 +281,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) if( SfxItemState::SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE, false, &pItem )) - nType = static_cast<const SfxUInt16Item *>(pItem)->GetValue(); + nType = static_cast<SwFieldTypesEnum>(static_cast<const SfxUInt16Item *>(pItem)->GetValue()); if( SfxItemState::SET == pArgs->GetItemState( FN_PARAM_FIELD_SUBTYPE, false, &pItem )) nSubType = static_cast<const SfxUInt16Item *>(pItem)->GetValue(); @@ -619,7 +619,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) if( bNew ) { - SwInsertField_Data aData(TYP_SCRIPTFLD, 0, aType, aText, bIsUrl ? 1 : 0); + SwInsertField_Data aData(SwFieldTypesEnum::Script, 0, aType, aText, bIsUrl ? 1 : 0); aMgr.InsertField(aData); rReq.Done(); } @@ -635,34 +635,34 @@ void SwTextShell::ExecField(SfxRequest &rReq) break; case FN_INSERT_FLD_DATE : - nInsertType = TYP_DATEFLD; + nInsertType = SwFieldTypesEnum::Date; bIsText = false; goto FIELD_INSERT; case FN_INSERT_FLD_TIME : - nInsertType = TYP_TIMEFLD; + nInsertType = SwFieldTypesEnum::Time; bIsText = false; goto FIELD_INSERT; case FN_INSERT_FLD_PGNUMBER: - nInsertType = TYP_PAGENUMBERFLD; + nInsertType = SwFieldTypesEnum::PageNumber; nInsertFormat = SVX_NUM_PAGEDESC; // Like page template bIsText = false; goto FIELD_INSERT; case FN_INSERT_FLD_PGCOUNT : - nInsertType = TYP_DOCSTATFLD; + nInsertType = SwFieldTypesEnum::DocumentStatistics; nInsertSubType = 0; bIsText = false; nInsertFormat = SVX_NUM_PAGEDESC; goto FIELD_INSERT; case FN_INSERT_FLD_TOPIC : - nInsertType = TYP_DOCINFOFLD; + nInsertType = SwFieldTypesEnum::DocumentInfo; nInsertSubType = DI_THEMA; goto FIELD_INSERT; case FN_INSERT_FLD_TITLE : - nInsertType = TYP_DOCINFOFLD; + nInsertType = SwFieldTypesEnum::DocumentInfo; nInsertSubType = DI_TITLE; goto FIELD_INSERT; case FN_INSERT_FLD_AUTHOR : - nInsertType = TYP_DOCINFOFLD; + nInsertType = SwFieldTypesEnum::DocumentInfo; nInsertSubType = DI_CREATE|DI_SUB_AUTHOR; FIELD_INSERT: diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 64deda9f1594..10dd4bbb5bcf 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -804,7 +804,7 @@ void SwTextShell::Execute(SfxRequest &rReq) case FN_GOTO_REFERENCE: { SwField *pField = rWrtSh.GetCurField(); - if(pField && pField->GetTypeId() == TYP_GETREFFLD) + if(pField && pField->GetTypeId() == SwFieldTypesEnum::GetRef) { rWrtSh.StartAllAction(); rWrtSh.SwCursorShell::GotoRefMark( static_cast<SwGetRefField*>(pField)->GetSetRefName(), @@ -842,7 +842,7 @@ void SwTextShell::Execute(SfxRequest &rReq) rWrtSh.EnterStdMode(); } - if( !bDelSel && aFieldMgr.GetCurField() && TYP_FORMELFLD == aFieldMgr.GetCurTypeId() ) + if( !bDelSel && aFieldMgr.GetCurField() && SwFieldTypesEnum::Formel == aFieldMgr.GetCurTypeId() ) aFieldMgr.UpdateCurField( aFieldMgr.GetCurField()->GetFormat(), OUString(), sFormula ); else if( !sFormula.isEmpty() ) { @@ -857,7 +857,7 @@ void SwTextShell::Execute(SfxRequest &rReq) { SvNumberFormatter* pFormatter = rWrtSh.GetNumberFormatter(); const sal_uInt32 nSysNumFormat = pFormatter->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM); - SwInsertField_Data aData(TYP_FORMELFLD, nsSwGetSetExpType::GSE_FORMULA, OUString(), sFormula, nSysNumFormat); + SwInsertField_Data aData(SwFieldTypesEnum::Formel, nsSwGetSetExpType::GSE_FORMULA, OUString(), sFormula, nSysNumFormat); aFieldMgr.InsertField(aData); } } @@ -1563,7 +1563,7 @@ void SwTextShell::GetState( SfxItemSet &rSet ) case FN_GOTO_REFERENCE: { SwField *pField = rSh.GetCurField(); - if ( !pField || (pField->GetTypeId() != TYP_GETREFFLD) ) + if ( !pField || (pField->GetTypeId() != SwFieldTypesEnum::GetRef) ) rSet.DisableItem(nWhich); } break; diff --git a/sw/source/uibase/shells/textsh2.cxx b/sw/source/uibase/shells/textsh2.cxx index f3f3d8937b8f..1f7b59fea20b 100644 --- a/sw/source/uibase/shells/textsh2.cxx +++ b/sw/source/uibase/shells/textsh2.cxx @@ -192,7 +192,7 @@ void SwTextShell::ExecDB(SfxRequest const &rReq) + OUStringLiteral1(DB_DELIM) + sColumnName; SwFieldMgr aFieldMgr(GetShellPtr()); - SwInsertField_Data aData(TYP_DBFLD, 0, sDBName, OUString(), 0); + SwInsertField_Data aData(SwFieldTypesEnum::Database, 0, sDBName, OUString(), 0); if(pConnectionItem) aData.m_aDBConnection = static_cast<const SfxUnoAnyItem*>(pConnectionItem)->GetValue(); if(pColumnItem) @@ -204,7 +204,7 @@ void SwTextShell::ExecDB(SfxRequest const &rReq) if ( xRecorder.is() ) { SfxRequest aReq( pViewFrame, FN_INSERT_DBFIELD ); - aReq.AppendItem( SfxUInt16Item(FN_PARAM_FIELD_TYPE, TYP_DBFLD)); + aReq.AppendItem( SfxUInt16Item(FN_PARAM_FIELD_TYPE, static_cast<sal_uInt16>(SwFieldTypesEnum::Database))); aReq.AppendItem( SfxStringItem( FN_INSERT_DBFIELD, sDBName )); aReq.AppendItem( SfxStringItem( FN_PARAM_1, sCommandArg )); aReq.AppendItem( SfxStringItem( FN_PARAM_2, sColumnName )); diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index 9f360c2ff266..5ed017ade921 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -1932,7 +1932,7 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, SfxRequest& rReq) // --> suggestion has to be removed before GetView().GetEditWin().StopQuickHelp(); - SwInsertField_Data aData(TYP_POSTITFLD, 0, sAuthor, sText, 0); + SwInsertField_Data aData(SwFieldTypesEnum::Postit, 0, sAuthor, sText, 0); if (IsSelFrameMode()) { |