sw/inc/expfld.hxx | 39 +++---- sw/inc/fldbas.hxx | 27 +++-- sw/source/core/doc/DocumentFieldsManager.cxx | 26 ++--- sw/source/core/doc/docfld.cxx | 2 sw/source/core/edit/edfld.cxx | 2 sw/source/core/fields/expfld.cxx | 140 +++++++++++++-------------- sw/source/core/fields/fldbas.cxx | 16 +-- sw/source/core/fields/reffld.cxx | 2 sw/source/core/fields/tblcalc.cxx | 20 +-- sw/source/core/inc/unofield.hxx | 2 sw/source/core/table/swtable.cxx | 4 sw/source/core/txtnode/atrfld.cxx | 4 sw/source/core/txtnode/thints.cxx | 2 sw/source/core/unocore/unofield.cxx | 48 ++++----- sw/source/filter/basflt/fltshell.cxx | 4 sw/source/filter/html/htmlfldw.cxx | 2 sw/source/filter/ww8/docxattributeoutput.cxx | 4 sw/source/filter/ww8/ww8atr.cxx | 12 +- sw/source/filter/ww8/ww8par5.cxx | 22 ++-- sw/source/ui/config/optload.cxx | 2 sw/source/ui/fldui/fldpage.cxx | 6 - sw/source/ui/fldui/fldref.cxx | 2 sw/source/ui/fldui/fldvar.cxx | 37 +++---- sw/source/ui/frmdlg/cption.cxx | 6 - sw/source/ui/index/cnttab.cxx | 2 sw/source/uibase/docvw/edtwin2.cxx | 12 +- sw/source/uibase/fldui/fldmgr.cxx | 21 +--- sw/source/uibase/shells/textsh1.cxx | 2 sw/source/uibase/uiview/viewdlg2.cxx | 2 29 files changed, 244 insertions(+), 226 deletions(-)
New commits: commit c7ba98c5d8e981c162ccf57d94fff479849539f9 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sun Jul 6 14:08:47 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Thu Jul 10 08:54:39 2025 +0200 convert SwGetSetExpType to scoped enum and SwTableFieldSubType into another enum, since it only uses a subset of the SwGetSetExpType values. and adjust DocumentFieldsManager::UpdateExpFieldsImpl where we are calling SwUserFieldType::Expand with a formatId of SwGetSetExpType::GSE_STRING. This cannot be correct but the code goes back to initial import. Replace it with the constant 1 which does the same thing, and probably maps to some default number format. Change-Id: I6c5c4b8f42cb2239ba8e1da7eb42a8adb8f7c2e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187594 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/sw/inc/expfld.hxx b/sw/inc/expfld.hxx index 2e5502e538da..cdc738d775c9 100644 --- a/sw/inc/expfld.hxx +++ b/sw/inc/expfld.hxx @@ -88,7 +88,7 @@ class SW_DLLPUBLIC SwGetExpField final : public SwFormulaField OUString m_sExpand; OUString m_sExpandRLHidden; ///< hidden redlines bool m_bIsInBodyText; - sal_uInt16 m_nSubType; + SwGetSetExpType m_nSubType; bool m_bLateInitialization; // #i82544# @@ -99,7 +99,7 @@ class SW_DLLPUBLIC SwGetExpField final : public SwFormulaField public: SwGetExpField( SwGetExpFieldType*, const OUString& rFormel, - sal_uInt16 nSubType, sal_uLong nFormat); + SwGetSetExpType nSubType, sal_uLong nFormat); double GetValue(SwRootFrame const* pLayout) const; void SetValue(const double& rVal, SwRootFrame const* pLayout); @@ -124,8 +124,9 @@ public: virtual OUString GetPar2() const override; virtual void SetPar2(const OUString& rStr) override; - sal_uInt16 GetSubType() const; - void SetSubType(sal_uInt16 nType); + SwGetSetExpType GetSubType() const; + void SetSubType(SwGetSetExpType nType); + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; @@ -148,7 +149,7 @@ class SW_DLLPUBLIC SwSetExpFieldType final : public SwValueFieldType { UIName m_sName; OUString m_sDelim; - sal_uInt16 m_nType; + SwGetSetExpType m_nType; sal_uInt8 m_nLevel; bool m_bDeleted; @@ -156,12 +157,12 @@ class SW_DLLPUBLIC SwSetExpFieldType final : public SwValueFieldType public: SwSetExpFieldType( SwDoc* pDoc, UIName aName, - sal_uInt16 nType = nsSwGetSetExpType::GSE_EXPR ); + SwGetSetExpType nType = SwGetSetExpType::Expr ); virtual std::unique_ptr<SwFieldType> Copy() const override; virtual UIName GetName() const override; - inline void SetType(sal_uInt16 nTyp); - inline sal_uInt16 GetType() const; + inline void SetType(SwGetSetExpType nTyp); + inline SwGetSetExpType GetType() const; void SetSeqFormat(sal_uInt32 nFormat); sal_uInt32 GetSeqFormat() const; @@ -188,13 +189,13 @@ public: virtual void UpdateFields() override {}; }; -inline void SwSetExpFieldType::SetType( sal_uInt16 nTyp ) +inline void SwSetExpFieldType::SetType( SwGetSetExpType nTyp ) { m_nType = nTyp; - EnableFormat( !(m_nType & (nsSwGetSetExpType::GSE_SEQ|nsSwGetSetExpType::GSE_STRING))); + EnableFormat( !(m_nType & (SwGetSetExpType::Sequence | SwGetSetExpType::String))); } -inline sal_uInt16 SwSetExpFieldType::GetType() const +inline SwGetSetExpType SwSetExpFieldType::GetType() const { return m_nType; } inline const UIName& SwSetExpFieldType::GetSetRefName() const @@ -208,7 +209,7 @@ class SW_DLLPUBLIC SwSetExpField final : public SwFormulaField OUString maPText; bool mbInput; sal_uInt16 mnSeqNo; - sal_uInt16 mnSubType; + SwGetSetExpType mnSubType; SwFormatField * mpFormatField; /// pool item to which the SwSetExpField belongs virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; @@ -237,8 +238,8 @@ public: virtual OUString GetFieldName() const override; - sal_uInt16 GetSubType() const; - void SetSubType(sal_uInt16 nType); + SwGetSetExpType GetSubType() const; + void SetSubType(SwGetSetExpType nType); inline bool IsSequenceField() const; @@ -269,7 +270,7 @@ inline bool SwSetExpField::GetInputFlag() const { return mbInput; } inline bool SwSetExpField::IsSequenceField() const - { return 0 != (nsSwGetSetExpType::GSE_SEQ & static_cast<SwSetExpFieldType*>(GetTyp())->GetType()); } + { return bool(SwGetSetExpType::Sequence & static_cast<SwSetExpFieldType*>(GetTyp())->GetType()); } class SAL_DLLPUBLIC_RTTI SwInputFieldType final : public SwFieldType { @@ -380,7 +381,7 @@ public: class SwTableField final : public SwValueField, public SwTableFormula { OUString m_sExpand; - sal_uInt16 m_nSubType; + SwTableFieldSubType m_nSubType; virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; @@ -392,11 +393,11 @@ class SwTableField final : public SwValueField, public SwTableFormula public: SwTableField( SwTableFieldType*, const OUString& rFormel, - sal_uInt16 nSubType, sal_uLong nFormat); + SwTableFieldSubType nSubType, sal_uLong nFormat); virtual void SetValue( const double& rVal ) override; - sal_uInt16 GetSubType() const; - void SetSubType(sal_uInt16 nType); + SwTableFieldSubType GetSubType() const; + void SetSubType(SwTableFieldSubType nType); void ChgExpStr(const OUString& rStr) { m_sExpand = rStr; } diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index 50601c2f9d0f..afcaded28c8f 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -160,14 +160,27 @@ enum class SwFileNameFormat { }; namespace o3tl { template<> struct typed_flags<SwFileNameFormat> : is_typed_flags<SwFileNameFormat, 0x800f> {}; } -typedef sal_uInt16 SwGetSetExpType; -namespace nsSwGetSetExpType +enum class SwTableFieldSubType : sal_uInt16 { -const SwGetSetExpType GSE_STRING = 0x0001; ///< String -const SwGetSetExpType GSE_EXPR = 0x0002; ///< Expression -const SwGetSetExpType GSE_SEQ = 0x0008; ///< Sequence -const SwGetSetExpType GSE_FORMULA = 0x0010; ///< Formula -} + String = 0x0001, ///< String + Formula = 0x0010, ///< Formula + Command = 0x0100, ///< Show command. +}; +namespace o3tl { template<> struct typed_flags<SwTableFieldSubType> : is_typed_flags<SwTableFieldSubType, 0x0111> {}; } + +enum class SwGetSetExpType : sal_uInt16 +{ + None = 0x0000, + String = 0x0001, ///< String + Expr = 0x0002, ///< Expression + Sequence = 0x0008, ///< Sequence + Formula = 0x0010, ///< Formula + LowerMask = 0x001f, + UpperMask = 0x0300, + Command = 0x0100, ///< Show command. + Invisible = 0x0200 ///< Invisible. +}; +namespace o3tl { template<> struct typed_flags<SwGetSetExpType> : is_typed_flags<SwGetSetExpType, 0x031f> {}; } typedef sal_uInt16 SwExtendedSubType; namespace nsSwExtendedSubType diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index d4ddf7027982..8782c293628d 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -135,7 +135,7 @@ namespace { auto pSetExpField = static_cast<const SwSetExpField*>(pField); SwSbxValue aValue; - if( nsSwGetSetExpType::GSE_EXPR & pSetExpField->GetSubType() ) + if( SwGetSetExpType::Expr & pSetExpField->GetSubType() ) aValue.PutDouble( pSetExpField->GetValue(pLayout) ); else // Extension to calculate with Strings @@ -220,7 +220,7 @@ SwFieldType* DocumentFieldsManager::InsertFieldType(const SwFieldType &rFieldTyp // Or we get doubble number circles!! //MIB 14.03.95: From now on also the SW3-Reader relies on this, when //constructing string pools and when reading SetExp fields - if( nsSwGetSetExpType::GSE_SEQ & static_cast<const SwSetExpFieldType&>(rFieldTyp).GetType() ) + if( SwGetSetExpType::Sequence & static_cast<const SwSetExpFieldType&>(rFieldTyp).GetType() ) i -= INIT_SEQ_FLDTYPES; [[fallthrough]]; case SwFieldIds::Database: @@ -610,7 +610,7 @@ void DocumentFieldsManager::UpdateTableFields(const SwTable* pTable) // re-set the value flag // JP 17.06.96: internal representation of all formulas // (reference to other table!!!) - if(pTable && nsSwExtendedSubType::SUB_CMD & pField->GetSubType()) + if(pTable && SwTableFieldSubType::Command & pField->GetSubType()) pField->PtrToBoxNm(pTable); else // reset the value flag for all @@ -646,7 +646,7 @@ void DocumentFieldsManager::UpdateTableFields(const SwTable* pTable) // that gives faster calculation on import // mba: do we really need this "optimization"? Is it still valid? SwTableField *const pField(static_cast<SwTableField*>(pFormatField->GetField())); - if (nsSwExtendedSubType::SUB_CMD & pField->GetSubType()) + if (SwTableFieldSubType::Command & pField->GetSubType()) continue; // needs to be recalculated @@ -872,7 +872,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl( { // Entry present? const OUString aNm = pFieldType->GetName().toString(); - OUString sExpand(const_cast<SwUserFieldType*>(static_cast<const SwUserFieldType*>(pFieldType))->Expand(nsSwGetSetExpType::GSE_STRING, SwUserType::None, LANGUAGE_SYSTEM)); + OUString sExpand(const_cast<SwUserFieldType*>(static_cast<const SwUserFieldType*>(pFieldType))->Expand(1, SwUserType::None, LANGUAGE_SYSTEM)); auto pFnd = aHashStrTable.find( aNm ); if( pFnd != aHashStrTable.end() ) // modify entry in the hash table @@ -1069,7 +1069,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl( case SwFieldIds::GetExp: { SwGetExpField* pGField = const_cast<SwGetExpField*>(static_cast<const SwGetExpField*>(pField)); - if( nsSwGetSetExpType::GSE_STRING & pGField->GetSubType() ) // replace String + if( SwGetSetExpType::String & pGField->GetSubType() ) // replace String { if( (!pUpdateField || pUpdateField == pTextField ) && pGField->IsInBodyText() ) @@ -1094,7 +1094,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl( case SwFieldIds::SetExp: { SwSetExpField* pSField = const_cast<SwSetExpField*>(static_cast<const SwSetExpField*>(pField)); - if( nsSwGetSetExpType::GSE_STRING & pSField->GetSubType() ) // replace String + if( SwGetSetExpType::String & pSField->GetSubType() ) // replace String { // is the "formula" a field? OUString aNew = LookString( aHashStrTable, pSField->GetFormula() ); @@ -1581,7 +1581,7 @@ void DocumentFieldsManager::FieldsToExpand( std::unordered_map<OUString, OUStrin case SwFieldIds::SetExp: { SwSetExpField* pSField = const_cast<SwSetExpField*>(static_cast<const SwSetExpField*>(pField)); - if( nsSwGetSetExpType::GSE_STRING & pSField->GetSubType() ) + if( SwGetSetExpType::String & pSField->GetSubType() ) { // set the new value in the hash table // is the formula a field? @@ -1720,15 +1720,15 @@ void DocumentFieldsManager::InitFieldTypes() // is being called by the CTO // MIB 14.04.95: In Sw3StringPool::Setup (sw3imp.cxx) and // lcl_sw3io_InSetExpField (sw3field.cxx) now also mpFieldTypes->emplace_back( new SwSetExpFieldType(&m_rDoc, - UIName(SwResId(STR_POOLCOLL_LABEL_ABB)), nsSwGetSetExpType::GSE_SEQ) ); + UIName(SwResId(STR_POOLCOLL_LABEL_ABB)), SwGetSetExpType::Sequence) ); mpFieldTypes->emplace_back( new SwSetExpFieldType(&m_rDoc, - UIName(SwResId(STR_POOLCOLL_LABEL_TABLE)), nsSwGetSetExpType::GSE_SEQ) ); + UIName(SwResId(STR_POOLCOLL_LABEL_TABLE)), SwGetSetExpType::Sequence) ); mpFieldTypes->emplace_back( new SwSetExpFieldType(&m_rDoc, - UIName(SwResId(STR_POOLCOLL_LABEL_FRAME)), nsSwGetSetExpType::GSE_SEQ) ); + UIName(SwResId(STR_POOLCOLL_LABEL_FRAME)), SwGetSetExpType::Sequence) ); mpFieldTypes->emplace_back( new SwSetExpFieldType(&m_rDoc, - UIName(SwResId(STR_POOLCOLL_LABEL_DRAWING)), nsSwGetSetExpType::GSE_SEQ) ); + UIName(SwResId(STR_POOLCOLL_LABEL_DRAWING)), SwGetSetExpType::Sequence) ); mpFieldTypes->emplace_back( new SwSetExpFieldType(&m_rDoc, - UIName(SwResId(STR_POOLCOLL_LABEL_FIGURE)), nsSwGetSetExpType::GSE_SEQ) ); + UIName(SwResId(STR_POOLCOLL_LABEL_FIGURE)), SwGetSetExpType::Sequence) ); assert( mpFieldTypes->size() == INIT_FLDTYPES ); } diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 094c66bfbbda..71fb079f4926 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -926,7 +926,7 @@ void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int eGetMode ) { auto pSetExpField = static_cast<const SwSetExpField*>(pField); if ((eGetMode != GETFLD_EXPAND) || - (nsSwGetSetExpType::GSE_STRING & pSetExpField->GetSubType())) + (SwGetSetExpType::String & pSetExpField->GetSubType())) { sFormula = sTrue; } diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx index a4290981f46f..335892dc6762 100644 --- a/sw/source/core/edit/edfld.cxx +++ b/sw/source/core/edit/edfld.cxx @@ -169,7 +169,7 @@ static SwTextField* lcl_FindInputField( const SwDoc* pDoc, const SwField& rField || (SwFieldIds::SetExp == rField.Which() && static_cast<const SwSetExpField&>(rField).GetInputFlag() && (static_cast<SwSetExpFieldType*>(rField.GetTyp())->GetType() - & nsSwGetSetExpType::GSE_STRING))) + & SwGetSetExpType::String))) { pDoc->ForEachFormatField(RES_TXTATR_INPUTFIELD, [&rField, &pTField] (const SwFormatField& rFormatField) -> bool diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 2a36c7d8759b..17fe0ef0f260 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -64,41 +64,41 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::text; -static sal_Int16 lcl_SubTypeToAPI(sal_uInt16 nSubType) +static sal_Int16 lcl_SubTypeToAPI(SwGetSetExpType nSubType) { sal_Int16 nRet = 0; switch(nSubType) { - case nsSwGetSetExpType::GSE_EXPR: + case SwGetSetExpType::Expr: nRet = SetVariableType::VAR; // 0 break; - case nsSwGetSetExpType::GSE_SEQ: + case SwGetSetExpType::Sequence: nRet = SetVariableType::SEQUENCE; // 1 break; - case nsSwGetSetExpType::GSE_FORMULA: + case SwGetSetExpType::Formula: nRet = SetVariableType::FORMULA; // 2 break; - case nsSwGetSetExpType::GSE_STRING: + case SwGetSetExpType::String: nRet = SetVariableType::STRING; // 3 break; + default: break; } return nRet; } -static sal_Int32 lcl_APIToSubType(const uno::Any& rAny) +static std::optional<SwGetSetExpType> lcl_APIToSubType(const uno::Any& rAny) { sal_Int16 nVal = 0; rAny >>= nVal; - sal_Int32 nSet = 0; + std::optional<SwGetSetExpType> nSet; switch(nVal) { - case SetVariableType::VAR: nSet = nsSwGetSetExpType::GSE_EXPR; break; - case SetVariableType::SEQUENCE: nSet = nsSwGetSetExpType::GSE_SEQ; break; - case SetVariableType::FORMULA: nSet = nsSwGetSetExpType::GSE_FORMULA; break; - case SetVariableType::STRING: nSet = nsSwGetSetExpType::GSE_STRING; break; + case SetVariableType::VAR: nSet = SwGetSetExpType::Expr; break; + case SetVariableType::SEQUENCE: nSet = SwGetSetExpType::Sequence; break; + case SetVariableType::FORMULA: nSet = SwGetSetExpType::Formula; break; + case SetVariableType::STRING: nSet = SwGetSetExpType::String; break; default: OSL_FAIL("wrong value"); - nSet = -1; } return nSet; } @@ -276,7 +276,7 @@ void SwGetExpFieldType::SwClientNotify(const SwModify&, const SfxHint&) } SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const OUString& rFormel, - sal_uInt16 nSub, sal_uLong nFormat) + SwGetSetExpType nSub, sal_uLong nFormat) : SwFormulaField( pTyp, nFormat, 0.0 ) , m_fValueRLHidden(0.0) , @@ -301,7 +301,7 @@ void SwGetExpField::ChgExpStr(const OUString& rExpand, SwRootFrame const*const p OUString SwGetExpField::ExpandImpl(SwRootFrame const*const pLayout) const { - if(m_nSubType & nsSwExtendedSubType::SUB_CMD) + if(m_nSubType & SwGetSetExpType::Command) return GetFormula(); return (pLayout && pLayout->IsHideRedlines()) ? m_sExpandRLHidden : m_sExpand; @@ -310,7 +310,7 @@ OUString SwGetExpField::ExpandImpl(SwRootFrame const*const pLayout) const OUString SwGetExpField::GetFieldName() const { const SwFieldTypesEnum nType = - (nsSwGetSetExpType::GSE_FORMULA & m_nSubType) + (SwGetSetExpType::Formula & m_nSubType) ? SwFieldTypesEnum::Formel : SwFieldTypesEnum::Get; @@ -360,9 +360,9 @@ void SwGetExpField::ChangeExpansion( const SwFrame& rFrame, const SwTextField& r if( pSetExpField ) { m_bLateInitialization = false; - if( !(GetSubType() & nsSwGetSetExpType::GSE_STRING) && - static_cast< SwSetExpFieldType* >(pSetExpField)->GetType() == nsSwGetSetExpType::GSE_STRING ) - SetSubType( nsSwGetSetExpType::GSE_STRING ); + if( !(GetSubType() & SwGetSetExpType::String) && + static_cast< SwSetExpFieldType* >(pSetExpField)->GetType() == SwGetSetExpType::String ) + SetSubType( SwGetSetExpType::String ); } } @@ -370,7 +370,7 @@ void SwGetExpField::ChangeExpansion( const SwFrame& rFrame, const SwTextField& r OUString & rExpand(rLayout.IsHideRedlines() ? m_sExpandRLHidden : m_sExpand); // here a page number is needed to sort correctly SetGetExpField aEndField(aPos.GetNode(), &rField, aPos.GetContentIndex(), rFrame.GetPhyPageNum()); - if(GetSubType() & nsSwGetSetExpType::GSE_STRING) + if(GetSubType() & SwGetSetExpType::String) { std::unordered_map<OUString, OUString> aHashTable; rDoc.getIDocumentFieldsAccess().FieldsToExpand(aHashTable, aEndField, rLayout); @@ -401,19 +401,19 @@ void SwGetExpField::SetPar2(const OUString& rStr) SetFormula(rStr); } -sal_uInt16 SwGetExpField::GetSubType() const +SwGetSetExpType SwGetExpField::GetSubType() const { return m_nSubType; } -void SwGetExpField::SetSubType(sal_uInt16 nType) +void SwGetExpField::SetSubType(SwGetSetExpType nType) { m_nSubType = nType; } void SwGetExpField::SetLanguage(LanguageType nLng) { - if (m_nSubType & nsSwExtendedSubType::SUB_CMD) + if (m_nSubType & SwGetSetExpType::Command) SwField::SetLanguage(nLng); else SwValueField::SetLanguage(nLng); @@ -437,12 +437,12 @@ bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const break; case FIELD_PROP_SUBTYPE: { - sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & 0xff); + sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & SwGetSetExpType::LowerMask); rAny <<= nRet; } break; case FIELD_PROP_BOOL2: - rAny <<= 0 != (m_nSubType & nsSwExtendedSubType::SUB_CMD); + rAny <<= bool(m_nSubType & SwGetSetExpType::Command); break; case FIELD_PROP_PAR4: rAny <<= m_sExpand; @@ -468,7 +468,7 @@ bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_USHORT1: rAny >>= nTmp; - m_nSubType = o3tl::narrowing<sal_uInt16>(nTmp); + m_nSubType = static_cast<SwGetSetExpType>(nTmp); break; case FIELD_PROP_PAR1: { @@ -478,15 +478,17 @@ bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; } case FIELD_PROP_SUBTYPE: - nTmp = lcl_APIToSubType(rAny); - if( nTmp >=0 ) - SetSubType( o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp)); + { + std::optional<SwGetSetExpType> nTmpSub = lcl_APIToSubType(rAny); + if( nTmpSub ) + SetSubType( (GetSubType() & SwGetSetExpType::UpperMask) | *nTmpSub ); break; + } case FIELD_PROP_BOOL2: if(*o3tl::doAccess<bool>(rAny)) - m_nSubType |= nsSwExtendedSubType::SUB_CMD; + m_nSubType |= SwGetSetExpType::Command; else - m_nSubType &= (~nsSwExtendedSubType::SUB_CMD); + m_nSubType &= ~SwGetSetExpType::Command; break; case FIELD_PROP_PAR4: { @@ -501,14 +503,14 @@ bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) return true; } -SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, UIName aName, sal_uInt16 nTyp ) +SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, UIName aName, SwGetSetExpType nTyp ) : SwValueFieldType( pDc, SwFieldIds::SetExp ), m_sName( std::move(aName) ), m_sDelim( u"."_ustr ), m_nType(nTyp), m_nLevel( UCHAR_MAX ), m_bDeleted( false ) { - if( ( nsSwGetSetExpType::GSE_SEQ | nsSwGetSetExpType::GSE_STRING ) & m_nType ) + if( ( SwGetSetExpType::Sequence | SwGetSetExpType::String ) & m_nType ) EnableFormat(false); // do not use Numberformatter } @@ -569,7 +571,7 @@ sal_uInt32 SwSetExpFieldType::GetSeqFormat() const void SwSetExpFieldType::SetSeqRefNo( SwSetExpField& rField ) { - if( !HasWriterListeners() || !(nsSwGetSetExpType::GSE_SEQ & m_nType) ) + if( !HasWriterListeners() || !(SwGetSetExpType::Sequence & m_nType) ) return; std::vector<sal_uInt16> aArr; @@ -691,9 +693,9 @@ void SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { case FIELD_PROP_SUBTYPE: { - sal_Int32 nSet = lcl_APIToSubType(rAny); - if(nSet >=0) - SetType(o3tl::narrowing<sal_uInt16>(nSet)); + std::optional<SwGetSetExpType> nSet = lcl_APIToSubType(rAny); + if(nSet) + SetType(*nSet); } break; case FIELD_PROP_PAR2: @@ -805,7 +807,7 @@ SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const OUString& rFormel, : SwFormulaField( pTyp, nFormat, 0.0 ) , m_fValueRLHidden(0.0) , mnSeqNo( USHRT_MAX ) - , mnSubType(0) + , mnSubType(SwGetSetExpType::None) , mpFormatField(nullptr) { SetFormula(rFormel); @@ -829,11 +831,11 @@ void SwSetExpField::SetFormatField(SwFormatField & rFormatField) OUString SwSetExpField::ExpandImpl(SwRootFrame const*const pLayout) const { - if (mnSubType & nsSwExtendedSubType::SUB_CMD) + if (mnSubType & SwGetSetExpType::Command) { // we need the CommandString return GetTyp()->GetName().toString() + " = " + GetFormula(); } - if(!(mnSubType & nsSwExtendedSubType::SUB_INVISIBLE)) + if(!(mnSubType & SwGetSetExpType::Invisible)) { // value is visible return (pLayout && pLayout->IsHideRedlines()) ? msExpandRLHidden : msExpand; } @@ -880,14 +882,14 @@ std::unique_ptr<SwField> SwSetExpField::Copy() const return std::unique_ptr<SwField>(pTmp.release()); } -void SwSetExpField::SetSubType(sal_uInt16 nSub) +void SwSetExpField::SetSubType(SwGetSetExpType nSub) { - assert((nSub & 0xff) != (nsSwGetSetExpType::GSE_STRING|nsSwGetSetExpType::GSE_EXPR) && "SubType is illegal!"); - static_cast<SwSetExpFieldType*>(GetTyp())->SetType(nSub & 0xff); - mnSubType = nSub & 0xff00; + assert((nSub & SwGetSetExpType::LowerMask) != (SwGetSetExpType::String | SwGetSetExpType::Expr) && "SubType is illegal!"); + static_cast<SwSetExpFieldType*>(GetTyp())->SetType(nSub & SwGetSetExpType::LowerMask); + mnSubType = nSub & SwGetSetExpType::UpperMask; } -sal_uInt16 SwSetExpField::GetSubType() const +SwGetSetExpType SwSetExpField::GetSubType() const { return static_cast<SwSetExpFieldType*>(GetTyp())->GetType() | mnSubType; } @@ -1021,20 +1023,20 @@ OUString SwSetExpField::GetPar1() const OUString SwSetExpField::GetPar2() const { - sal_uInt16 nType = static_cast<SwSetExpFieldType*>(GetTyp())->GetType(); + SwGetSetExpType nType = static_cast<SwSetExpFieldType*>(GetTyp())->GetType(); - if (nType & nsSwGetSetExpType::GSE_STRING) + if (nType & SwGetSetExpType::String) return GetFormula(); return GetExpandedFormula(); } void SwSetExpField::SetPar2(const OUString& rStr) { - sal_uInt16 nType = static_cast<SwSetExpFieldType*>(GetTyp())->GetType(); + SwGetSetExpType nType = static_cast<SwSetExpFieldType*>(GetTyp())->GetType(); - if( !(nType & nsSwGetSetExpType::GSE_SEQ) || !rStr.isEmpty() ) + if( !(nType & SwGetSetExpType::Sequence) || !rStr.isEmpty() ) { - if (nType & nsSwGetSetExpType::GSE_STRING) + if (nType & SwGetSetExpType::String) SetFormula(rStr); else SetExpandedFormula(rStr); @@ -1049,9 +1051,9 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { case FIELD_PROP_BOOL2: if(*o3tl::doAccess<bool>(rAny)) - mnSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE; + mnSubType &= ~SwGetSetExpType::Invisible; else - mnSubType |= nsSwExtendedSubType::SUB_INVISIBLE; + mnSubType |= SwGetSetExpType::Invisible; break; case FIELD_PROP_FORMAT: rAny >>= nTmp32; @@ -1099,18 +1101,20 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) } break; case FIELD_PROP_SUBTYPE: - nTmp32 = lcl_APIToSubType(rAny); - if (0 <= nTmp32 && nTmp32 != (GetSubType() & 0xff)) { - auto const subType(o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp32)); - if (((nTmp32 & nsSwGetSetExpType::GSE_STRING) != (GetSubType() & nsSwGetSetExpType::GSE_STRING)) - && GetInputFlag()) - { - SwXTextField::TransmuteLeadToInputField(*this, &subType); - } - else + std::optional<SwGetSetExpType> oTmpSub = lcl_APIToSubType(rAny); + if (oTmpSub && *oTmpSub != (GetSubType() & SwGetSetExpType::LowerMask)) { - SetSubType(subType); + SwGetSetExpType const subType((GetSubType() & SwGetSetExpType::UpperMask) | *oTmpSub); + if (((*oTmpSub & SwGetSetExpType::String) != (GetSubType() & SwGetSetExpType::String)) + && GetInputFlag()) + { + SwXTextField::TransmuteLeadToInputField(*this, subType); + } + else + { + SetSubType(subType); + } } } break; @@ -1119,9 +1123,9 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_BOOL3: if(*o3tl::doAccess<bool>(rAny)) - mnSubType |= nsSwExtendedSubType::SUB_CMD; + mnSubType |= SwGetSetExpType::Command; else - mnSubType &= (~nsSwExtendedSubType::SUB_CMD); + mnSubType &= ~SwGetSetExpType::Command; break; case FIELD_PROP_BOOL1: { @@ -1129,9 +1133,9 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) if (newInput != GetInputFlag()) { if (static_cast<SwSetExpFieldType*>(GetTyp())->GetType() - & nsSwGetSetExpType::GSE_STRING) + & SwGetSetExpType::String) { - SwXTextField::TransmuteLeadToInputField(*this, nullptr); + SwXTextField::TransmuteLeadToInputField(*this, std::nullopt); } else { @@ -1158,7 +1162,7 @@ bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_BOOL2: - rAny <<= 0 == (mnSubType & nsSwExtendedSubType::SUB_INVISIBLE); + rAny <<= !(mnSubType & SwGetSetExpType::Invisible); break; case FIELD_PROP_FORMAT: rAny <<= static_cast<sal_Int32>(GetFormat()); @@ -1186,7 +1190,7 @@ bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const break; case FIELD_PROP_SUBTYPE: { - sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & 0xff); + sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & SwGetSetExpType::LowerMask); rAny <<= nRet; } break; @@ -1194,7 +1198,7 @@ bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= maPText; break; case FIELD_PROP_BOOL3: - rAny <<= 0 != (mnSubType & nsSwExtendedSubType::SUB_CMD); + rAny <<= bool(mnSubType & SwGetSetExpType::Command); break; case FIELD_PROP_BOOL1: rAny <<= GetInputFlag(); diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 291891dc735c..a1fb16a3c838 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -279,7 +279,7 @@ SwFieldTypesEnum SwField::GetTypeId() const case SwFieldIds::GetExp: { auto pGetExpField = static_cast<const SwGetExpField*>(this); - nRet = nsSwGetSetExpType::GSE_FORMULA & pGetExpField->GetSubType() ? SwFieldTypesEnum::Formel : SwFieldTypesEnum::Get; + nRet = SwGetSetExpType::Formula & pGetExpField->GetSubType() ? SwFieldTypesEnum::Formel : SwFieldTypesEnum::Get; } break; @@ -293,7 +293,7 @@ SwFieldTypesEnum SwField::GetTypeId() const case SwFieldIds::SetExp: { auto pSetExpField = static_cast<const SwSetExpField*>(this); - if( nsSwGetSetExpType::GSE_SEQ & pSetExpField->GetSubType() ) + if( SwGetSetExpType::Sequence & pSetExpField->GetSubType() ) nRet = SwFieldTypesEnum::Sequence; else if( pSetExpField->GetInputFlag() ) nRet = SwFieldTypesEnum::SetInput; @@ -457,13 +457,13 @@ sal_uInt16 SwField::GetUntypedSubType() const case SwFieldIds::DateTime: return static_cast<sal_uInt16>(static_cast<const SwDateTimeField*>(this)->GetSubType()); case SwFieldIds::Table: - return static_cast<const SwTableField*>(this)->GetSubType(); + return static_cast<sal_uInt16>(static_cast<const SwTableField*>(this)->GetSubType()); case SwFieldIds::Input: return static_cast<sal_uInt16>(static_cast<const SwInputField*>(this)->GetSubType()); case SwFieldIds::GetExp: - return static_cast<const SwGetExpField*>(this)->GetSubType(); + return static_cast<sal_uInt16>(static_cast<const SwGetExpField*>(this)->GetSubType()); case SwFieldIds::SetExp: - return static_cast<const SwSetExpField*>(this)->GetSubType(); + return static_cast<sal_uInt16>(static_cast<const SwSetExpField*>(this)->GetSubType()); case SwFieldIds::ExtUser: return static_cast<sal_uInt32>(static_cast<const SwExtUserField*>(this)->GetSubType()); case SwFieldIds::DocInfo: @@ -500,16 +500,16 @@ void SwField::SetUntypedSubType(sal_uInt16 n) static_cast<SwDateTimeField*>(this)->SetSubType(static_cast<SwDateTimeSubType>(n)); break; case SwFieldIds::Table: - static_cast<SwTableField*>(this)->SetSubType(n); + static_cast<SwTableField*>(this)->SetSubType(static_cast<SwTableFieldSubType>(n)); break; case SwFieldIds::Input: static_cast<SwInputField*>(this)->SetSubType(static_cast<SwInputFieldSubType>(n)); break; case SwFieldIds::GetExp: - static_cast<SwGetExpField*>(this)->SetSubType(n); + static_cast<SwGetExpField*>(this)->SetSubType(static_cast<SwGetSetExpType>(n)); break; case SwFieldIds::SetExp: - static_cast<SwSetExpField*>(this)->SetSubType(n); + static_cast<SwSetExpField*>(this)->SetSubType(static_cast<SwGetSetExpType>(n)); break; case SwFieldIds::ExtUser: static_cast<SwExtUserField*>(this)->SetSubType(static_cast<SwExtUserSubType>(n)); diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 280e070d8589..bf1cd4c9a0e1 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -1399,7 +1399,7 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const SwMarkName& rRefMar { SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetFieldType( SwFieldIds::SetExp, rRefMark, false ); if( pFieldType && pFieldType->HasWriterListeners() && - nsSwGetSetExpType::GSE_SEQ & static_cast<SwSetExpFieldType*>(pFieldType)->GetType() ) + SwGetSetExpType::Sequence & static_cast<SwSetExpFieldType*>(pFieldType)->GetType() ) { std::vector<SwFormatField*> vFields; pFieldType->GatherFields(vFields, false); diff --git a/sw/source/core/fields/tblcalc.cxx b/sw/source/core/fields/tblcalc.cxx index c75da9a44234..3ba0e908ba76 100644 --- a/sw/source/core/fields/tblcalc.cxx +++ b/sw/source/core/fields/tblcalc.cxx @@ -53,7 +53,7 @@ void SwTableField::CalcField( SwTableCalcPara& rCalcPara ) } SwTableField::SwTableField( SwTableFieldType* pInitType, const OUString& rFormel, - sal_uInt16 nType, sal_uLong nFormat ) + SwTableFieldSubType nType, sal_uLong nFormat ) : SwValueField( pInitType, nFormat ), SwTableFormula( rFormel ), m_nSubType(nType) { @@ -101,12 +101,12 @@ OUString SwTableField::GetCommand() OUString SwTableField::ExpandImpl(SwRootFrame const*const) const { - if (m_nSubType & nsSwExtendedSubType::SUB_CMD) + if (m_nSubType & SwTableFieldSubType::Command) { return const_cast<SwTableField *>(this)->GetCommand(); } - if(m_nSubType & nsSwGetSetExpType::GSE_STRING) + if(m_nSubType & SwTableFieldSubType::String) { // it is a string return m_sExpand.copy(1, m_sExpand.getLength()-2); @@ -115,12 +115,12 @@ OUString SwTableField::ExpandImpl(SwRootFrame const*const) const return m_sExpand; } -sal_uInt16 SwTableField::GetSubType() const +SwTableFieldSubType SwTableField::GetSubType() const { return m_nSubType; } -void SwTableField::SetSubType(sal_uInt16 nType) +void SwTableField::SetSubType(SwTableFieldSubType nType) { m_nSubType = nType; } @@ -148,15 +148,15 @@ bool SwTableField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const { case FIELD_PROP_PAR2: { - sal_uInt16 nOldSubType = m_nSubType; + SwTableFieldSubType nOldSubType = m_nSubType; SwTableField* pThis = const_cast<SwTableField*>(this); - pThis->m_nSubType |= nsSwExtendedSubType::SUB_CMD; + pThis->m_nSubType |= SwTableFieldSubType::Command; rAny <<= ExpandImpl(nullptr); pThis->m_nSubType = nOldSubType; } break; case FIELD_PROP_BOOL1: - rAny <<= 0 != (nsSwExtendedSubType::SUB_CMD & m_nSubType); + rAny <<= bool(SwTableFieldSubType::Command & m_nSubType); break; case FIELD_PROP_PAR1: rAny <<= m_sExpand; @@ -184,9 +184,9 @@ bool SwTableField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_BOOL1: if(*o3tl::doAccess<bool>(rAny)) - m_nSubType = nsSwGetSetExpType::GSE_FORMULA|nsSwExtendedSubType::SUB_CMD; + m_nSubType = SwTableFieldSubType::Formula | SwTableFieldSubType::Command; else - m_nSubType = nsSwGetSetExpType::GSE_FORMULA; + m_nSubType = SwTableFieldSubType::Formula; break; case FIELD_PROP_PAR1: { diff --git a/sw/source/core/inc/unofield.hxx b/sw/source/core/inc/unofield.hxx index fbd0f86a1369..e16476a798dc 100644 --- a/sw/source/core/inc/unofield.hxx +++ b/sw/source/core/inc/unofield.hxx @@ -135,7 +135,7 @@ private: public: SwServiceType GetServiceId() const; - static void TransmuteLeadToInputField(SwSetExpField & rField, sal_uInt16 const*const pSubType); + static void TransmuteLeadToInputField(SwSetExpField & rField, std::optional<SwGetSetExpType> oSubType); /// @return an SwXTextField, either an already existing one or a new one static rtl::Reference<SwXTextField> diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index cb633900d9e3..c013e3164c8b 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2953,9 +2953,9 @@ SwNodeOffset SwTableBox::IsValidNumTextNd( bool bCheckAttr ) const const SwField* pField = pAttr->GetFormatField().GetField(); if (pField && (pField->GetTypeId() == SwFieldTypesEnum::Set) && - (0 != (static_cast<SwSetExpField const*> + (static_cast<SwSetExpField const*> (pField)->GetSubType() & - nsSwExtendedSubType::SUB_INVISIBLE))) + SwGetSetExpType::Invisible)) { nNextSetField = pAttr->GetStart() + 1; continue; diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index d57022e8bd91..ed123fe433d3 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -75,7 +75,7 @@ SwFormatField::SwFormatField( const SwField &rField ) // only for string fields for now - inline editing of number fields // tends to produce error messages... && (static_cast<SwSetExpFieldType*>(pSetField->GetTyp())->GetType() - & nsSwGetSetExpType::GSE_STRING)) + & SwGetSetExpType::String)) { SetWhich( RES_TXTATR_INPUTFIELD ); } @@ -117,7 +117,7 @@ SwFormatField::SwFormatField( const SwFormatField& rAttr ) SwSetExpField *const pSetField(static_cast<SwSetExpField *>(mpField.get())); if (pSetField->GetInputFlag() && (static_cast<SwSetExpFieldType*>(pSetField->GetTyp())->GetType() - & nsSwGetSetExpType::GSE_STRING)) + & SwGetSetExpType::String)) { SetWhich( RES_TXTATR_INPUTFIELD ); } diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index d806b2737e47..cdee95a4b665 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -3172,7 +3172,7 @@ bool SwpHints::TryInsertHint( { case SwFieldIds::SetExp: bInsFieldType = static_cast<SwSetExpFieldType*>(pField->GetTyp())->IsDeleted(); - if( nsSwGetSetExpType::GSE_SEQ & static_cast<SwSetExpFieldType*>(pField->GetTyp())->GetType() ) + if( SwGetSetExpType::Sequence & static_cast<SwSetExpFieldType*>(pField->GetTyp())->GetType() ) { // register the field at its FieldType before setting // the sequence reference number! diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index cee718207584..687ce6b68c95 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1248,11 +1248,11 @@ SwServiceType SwXTextField::GetServiceId() const new instance! */ void SwXTextField::TransmuteLeadToInputField(SwSetExpField & rField, - sal_uInt16 const*const pSubType) + std::optional<SwGetSetExpType> oSubType) { #ifndef NDEBUG auto const oldWhich( - (pSubType ? (rField.GetSubType() & nsSwGetSetExpType::GSE_STRING) != 0 : rField.GetInputFlag()) + (oSubType ? bool(rField.GetSubType() & SwGetSetExpType::String) : rField.GetInputFlag()) ? RES_TXTATR_INPUTFIELD : RES_TXTATR_FIELD); auto const newWhich(oldWhich == RES_TXTATR_FIELD ? RES_TXTATR_INPUTFIELD : RES_TXTATR_FIELD); #endif @@ -1263,9 +1263,9 @@ void SwXTextField::TransmuteLeadToInputField(SwSetExpField & rField, pXField->m_pImpl->SetFormatField(nullptr, nullptr); SwTextField *const pOldAttr(rField.GetFormatField()->GetTextField()); SwSetExpField tempField(rField); - if (pSubType) + if (oSubType) { - tempField.SetSubType(*pSubType); + tempField.SetSubType(*oSubType); } else { @@ -1291,7 +1291,7 @@ void SwXTextField::TransmuteLeadToInputField(SwSetExpField & rField, SwFormatField const& rNewFormat(pNewAttr->GetFormatField()); assert(rNewFormat.Which() == newWhich); assert((dynamic_cast<SwTextInputField const*>(pNewAttr) != nullptr) - == ((static_cast<SwSetExpField const*>(rNewFormat.GetField())->GetSubType() & nsSwGetSetExpType::GSE_STRING) + == ((static_cast<SwSetExpField const*>(rNewFormat.GetField())->GetSubType() & SwGetSetExpType::String) && static_cast<SwSetExpField const*>(rNewFormat.GetField())->GetInputFlag())); if (pXField) { @@ -1757,7 +1757,7 @@ void SAL_CALL SwXTextField::attach( throw uno::RuntimeException(); // detect the field type's sub type and set an appropriate number format if (m_pImpl->m_pProps->bFormatIsDefault && - nsSwGetSetExpType::GSE_STRING == static_cast<SwSetExpFieldType*>(pFieldType)->GetType()) + SwGetSetExpType::String == static_cast<SwSetExpFieldType*>(pFieldType)->GetType()) { m_pImpl->m_pProps->nFormat = -1; } @@ -1768,15 +1768,15 @@ void SAL_CALL SwXTextField::attach( m_pImpl->m_pProps->nUSHORT2 : m_pImpl->m_pProps->nFormat); xField.reset(pSEField); - sal_uInt16 nSubType = pSEField->GetSubType(); + SwGetSetExpType nSubType = pSEField->GetSubType(); if (m_pImpl->m_pProps->bBool2) - nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE; + nSubType &= ~SwGetSetExpType::Invisible; else - nSubType |= nsSwExtendedSubType::SUB_INVISIBLE; + nSubType |= SwGetSetExpType::Invisible; if (m_pImpl->m_pProps->bBool3) - nSubType |= nsSwExtendedSubType::SUB_CMD; + nSubType |= SwGetSetExpType::Command; else - nSubType &= ~nsSwExtendedSubType::SUB_CMD; + nSubType &= ~SwGetSetExpType::Command; pSEField->SetSubType(nSubType); pSEField->SetSeqNumber(m_pImpl->m_pProps->nUSHORT1); pSEField->SetInputFlag(m_pImpl->m_pProps->bBool1); @@ -1788,16 +1788,16 @@ void SAL_CALL SwXTextField::attach( break; case SwServiceType::FieldTypeGetExp: { - sal_uInt16 nSubType; + SwGetSetExpType nSubType; switch (m_pImpl->m_pProps->nSubType) { - case text::SetVariableType::STRING: nSubType = nsSwGetSetExpType::GSE_STRING; break; - case text::SetVariableType::VAR: nSubType = nsSwGetSetExpType::GSE_EXPR; break; - //case text::SetVariableType::SEQUENCE: nSubType = nsSwGetSetExpType::GSE_SEQ; break; - case text::SetVariableType::FORMULA: nSubType = nsSwGetSetExpType::GSE_FORMULA; break; + case text::SetVariableType::STRING: nSubType = SwGetSetExpType::String; break; + case text::SetVariableType::VAR: nSubType = SwGetSetExpType::Expr; break; + //case text::SetVariableType::SEQUENCE: nSubType = nsSwGetSetExpType::Sequence; break; + case text::SetVariableType::FORMULA: nSubType = SwGetSetExpType::Formula; break; default: OSL_FAIL("wrong value"); - nSubType = nsSwGetSetExpType::GSE_EXPR; + nSubType = SwGetSetExpType::Expr; } //make sure the SubType matches the field type SwFieldType* pSetExpField = pDoc->getIDocumentFieldsAccess().GetFieldType( @@ -1805,17 +1805,17 @@ void SAL_CALL SwXTextField::attach( bool bSetGetExpFieldUninitialized = false; if (pSetExpField) { - if (nSubType != nsSwGetSetExpType::GSE_STRING && - static_cast< SwSetExpFieldType* >(pSetExpField)->GetType() == nsSwGetSetExpType::GSE_STRING) - nSubType = nsSwGetSetExpType::GSE_STRING; + if (nSubType != SwGetSetExpType::String && + static_cast< SwSetExpFieldType* >(pSetExpField)->GetType() == SwGetSetExpType::String) + nSubType = SwGetSetExpType::String; } else bSetGetExpFieldUninitialized = true; // #i82544# if (m_pImpl->m_pProps->bBool2) - nSubType |= nsSwExtendedSubType::SUB_CMD; + nSubType |= SwGetSetExpType::Command; else - nSubType &= ~nsSwExtendedSubType::SUB_CMD; + nSubType &= ~SwGetSetExpType::Command; SwGetExpField *const pGEField = new SwGetExpField( static_cast<SwGetExpFieldType*>( pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::GetExp)), @@ -1935,10 +1935,10 @@ void SAL_CALL SwXTextField::attach( case SwServiceType::FieldTypeTableFormula: { // create field - sal_uInt16 nType = nsSwGetSetExpType::GSE_FORMULA; + SwTableFieldSubType nType = SwTableFieldSubType::Formula; if (m_pImpl->m_pProps->bBool1) { - nType |= nsSwExtendedSubType::SUB_CMD; + nType |= SwTableFieldSubType::Command; if (m_pImpl->m_pProps->bFormatIsDefault) m_pImpl->m_pProps->nFormat = -1; } diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index a97f7e825a08..bb21ac01bb6a 100644 --- a/sw/source/filter/basflt/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx @@ -557,11 +557,11 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFieldType* pFT = m_rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::SetExp, rName, false); if (!pFT) { - SwSetExpFieldType aS(&m_rDoc, UIName(rName), nsSwGetSetExpType::GSE_STRING); + SwSetExpFieldType aS(&m_rDoc, UIName(rName), SwGetSetExpType::String); pFT = m_rDoc.getIDocumentFieldsAccess().InsertFieldType(aS); } SwSetExpField aField(static_cast<SwSetExpFieldType*>(pFT), pB->GetValSys()); - aField.SetSubType( nsSwExtendedSubType::SUB_INVISIBLE ); + aField.SetSubType( SwGetSetExpType::Invisible ); MakePoint(rEntry, aRegion); m_rDoc.getIDocumentContentOperations().InsertPoolItem(aRegion, SwFormatField(aField)); MoveAttrs( *(aRegion.GetPoint()) ); diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx index e79c3847d656..4d2297bbb9a5 100644 --- a/sw/source/filter/html/htmlfldw.cxx +++ b/sw/source/filter/html/htmlfldw.cxx @@ -476,7 +476,7 @@ SwHTMLWriter& OutHTML_SwFormatField( SwHTMLWriter& rWrt, const SfxPoolItem& rHt const SwFieldType* pFieldTyp = pField->GetTyp(); if( SwFieldIds::SetExp == pFieldTyp->Which() && - (nsSwGetSetExpType::GSE_STRING & static_cast<const SwSetExpField*>(pField)->GetSubType()) ) + (SwGetSetExpType::String & static_cast<const SwSetExpField*>(pField)->GetSubType()) ) { const bool bOn = pFieldTyp->GetName() == "HTML_ON"; if (!bOn && pFieldTyp->GetName() != "HTML_OFF") diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index e5447609345a..d6851b19903d 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3273,7 +3273,7 @@ void DocxAttributeOutput::EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos } bool bIsSetField = rInfos.pField->GetTyp( )->Which( ) == SwFieldIds::SetExp; - bool bShowRef = bIsSetField && ( static_cast<const SwSetExpField*>(rInfos.pField.get())->GetSubType( ) & nsSwExtendedSubType::SUB_INVISIBLE ) == 0; + bool bShowRef = bIsSetField && !( static_cast<const SwSetExpField*>(rInfos.pField.get())->GetSubType( ) & SwGetSetExpType::Invisible ); if (!bShowRef) { @@ -8736,7 +8736,7 @@ void DocxAttributeOutput::WriteField_Impl(const SwField *const pField, if ( nType == SwFieldIds::SetExp ) { const SwSetExpField *pSet = static_cast<const SwSetExpField*>( pField ); - if ( pSet->GetSubType() & nsSwGetSetExpType::GSE_STRING ) + if ( pSet->GetSubType() & SwGetSetExpType::String ) m_sFieldBkm = pSet->GetPar1( ); } else if ( nType == SwFieldIds::Dropdown ) diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 6d43e40d540e..321be7ba70a9 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2179,7 +2179,7 @@ void AttributeOutputBase::GenerateBookmarksForSequenceField(const SwTextNode& rN const SwFormatField& rField = static_cast<const SwFormatField&>(pHt->GetAttr()); const SwField* pField = rField.GetField(); // Need to have bookmarks only for sequence fields - if (pField && pField->GetTyp()->Which() == SwFieldIds::SetExp && static_cast<const SwSetExpField*>(pField)->GetSubType() == nsSwGetSetExpType::GSE_SEQ) + if (pField && pField->GetTyp()->Which() == SwFieldIds::SetExp && static_cast<const SwSetExpField*>(pField)->GetSubType() == SwGetSetExpType::Sequence) { const sal_uInt16 nSeqFieldNumber = static_cast<const SwSetExpField*>(pField)->GetSeqNumber(); const UIName sObjectName = static_cast<const SwSetExpFieldType*>(pField->GetTyp())->GetName(); @@ -2959,7 +2959,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) case SwFieldIds::GetExp: { const SwGetExpField *pGet = static_cast<const SwGetExpField*>(pField); - if (pGet->GetSubType() == nsSwGetSetExpType::GSE_STRING) + if (pGet->GetSubType() == SwGetSetExpType::String) { RefField( *pGet, pGet->GetFormula() ); } @@ -2970,8 +2970,8 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) case SwFieldIds::SetExp: { const SwSetExpField *pSet = static_cast<const SwSetExpField*>(pField); - sal_uInt16 nSubType = pSet->GetSubType(); - if (nsSwGetSetExpType::GSE_SEQ == nSubType) + SwGetSetExpType nSubType = pSet->GetSubType(); + if (SwGetSetExpType::Sequence == nSubType) { OUString sStr; if (GetExport().FieldsQuoted()) @@ -2981,7 +2981,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) GetNumberPara( sStr, *pField ); GetExport().OutputField(pField, ww::eSEQ, sStr); } - else if (nSubType & nsSwGetSetExpType::GSE_STRING) + else if (nSubType & SwGetSetExpType::String) { bool bShowAsWell = false; ww::eField eFieldNo; @@ -3001,7 +3001,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) + pSet->GetPar1() + " \"" + sVar + "\" "; eFieldNo = ww::eSET; - bShowAsWell = (nSubType & nsSwExtendedSubType::SUB_INVISIBLE) == 0; + bShowAsWell = !(nSubType & SwGetSetExpType::Invisible); } SetField( *pField, eFieldNo, sStr ); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 57b121e1e535..3ea53f54ca74 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -1179,10 +1179,10 @@ void SwWW8ImplReader::InsertTagField( const sal_uInt16 nId, const OUString& rTag { // tag normally SwFieldType* pFT = m_rDoc.getIDocumentFieldsAccess().InsertFieldType( - SwSetExpFieldType( &m_rDoc, UIName(aName), nsSwGetSetExpType::GSE_STRING ) ); + SwSetExpFieldType( &m_rDoc, UIName(aName), SwGetSetExpType::String ) ); SwSetExpField aField( static_cast<SwSetExpFieldType*>(pFT), rTagText ); // SUB_INVISIBLE - sal_uInt16 nSubType = ( SwFltGetFlag( m_nFieldFlags, SwFltControlStack::TAGS_VISIBLE ) ) ? 0 : nsSwExtendedSubType::SUB_INVISIBLE; - aField.SetSubType(nSubType | nsSwGetSetExpType::GSE_STRING); + SwGetSetExpType nSubType = ( SwFltGetFlag( m_nFieldFlags, SwFltControlStack::TAGS_VISIBLE ) ) ? SwGetSetExpType::None : SwGetSetExpType::Invisible; + aField.SetSubType(nSubType | SwGetSetExpType::String); m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) ); } @@ -1392,7 +1392,7 @@ SwFltStackEntry *SwWW8FltRefStack::RefToVar(const SwField* pField, if (aResult != m_aFieldVarNames.end()) { SwGetExpField aField( static_cast<SwGetExpFieldType*>( - m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::GetExp)), sName, nsSwGetSetExpType::GSE_STRING, 0); + m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::GetExp)), sName, SwGetSetExpType::String, 0); SwFormatField aTmp(aField); rEntry.m_pAttr.reset( aTmp.Clone() ); pRet = &rEntry; @@ -1460,9 +1460,9 @@ eF_ResT SwWW8ImplReader::Read_F_InputVar( WW8FieldDesc* pF, OUString& rStr ) const tools::Long nNo = MapBookmarkVariables(pF, sOrigName, aResult); SwSetExpFieldType* pFT = static_cast<SwSetExpFieldType*>(m_rDoc.getIDocumentFieldsAccess().InsertFieldType( - SwSetExpFieldType(&m_rDoc, UIName(sOrigName), nsSwGetSetExpType::GSE_STRING))); + SwSetExpFieldType(&m_rDoc, UIName(sOrigName), SwGetSetExpType::String))); SwSetExpField aField(pFT, aResult); - aField.SetSubType(nsSwExtendedSubType::SUB_INVISIBLE | nsSwGetSetExpType::GSE_STRING); + aField.SetSubType(SwGetSetExpType::Invisible | SwGetSetExpType::String); aField.SetInputFlag(true); aField.SetPromptText( aQ ); @@ -1476,7 +1476,7 @@ eF_ResT SwWW8ImplReader::Read_F_InputVar( WW8FieldDesc* pF, OUString& rStr ) eF_ResT SwWW8ImplReader::Read_F_ANumber( WW8FieldDesc*, OUString& rStr ) { if( !m_pNumFieldType ){ // 1st time - SwSetExpFieldType aT( &m_rDoc, UIName(u"AutoNr"_ustr), nsSwGetSetExpType::GSE_SEQ ); + SwSetExpFieldType aT( &m_rDoc, UIName(u"AutoNr"_ustr), SwGetSetExpType::Sequence ); m_pNumFieldType = static_cast<SwSetExpFieldType*>(m_rDoc.getIDocumentFieldsAccess().InsertFieldType( aT )); } SwSetExpField aField( m_pNumFieldType, OUString(), GetNumberPara( rStr ) ); @@ -1546,12 +1546,12 @@ eF_ResT SwWW8ImplReader::Read_F_Seq( WW8FieldDesc*, OUString& rStr ) return eF_ResT::TAGIGN; SwSetExpFieldType* pFT = static_cast<SwSetExpFieldType*>(m_rDoc.getIDocumentFieldsAccess().InsertFieldType( - SwSetExpFieldType( &m_rDoc, UIName(aSequenceName), nsSwGetSetExpType::GSE_SEQ ) ) ); + SwSetExpFieldType( &m_rDoc, UIName(aSequenceName), SwGetSetExpType::Sequence ) ) ); SwSetExpField aField( pFT, OUString(), eNumFormat ); //#i120654# Add bHidden for /h flag (/h: Hide the field result.) if (bHidden) - aField.SetSubType(aField.GetSubType() | nsSwExtendedSubType::SUB_INVISIBLE); + aField.SetSubType(aField.GetSubType() | SwGetSetExpType::Invisible); if (!sStart.isEmpty()) aField.SetFormula( aSequenceName + "=" + sStart ); @@ -2128,9 +2128,9 @@ eF_ResT SwWW8ImplReader::Read_F_Set( WW8FieldDesc* pF, OUString& rStr ) const tools::Long nNo = MapBookmarkVariables(pF, sOrigName, sVal); SwFieldType* pFT = m_rDoc.getIDocumentFieldsAccess().InsertFieldType( SwSetExpFieldType( &m_rDoc, UIName(sOrigName), - nsSwGetSetExpType::GSE_STRING ) ); + SwGetSetExpType::String ) ); SwSetExpField aField( static_cast<SwSetExpFieldType*>(pFT), sVal, ULONG_MAX ); - aField.SetSubType(nsSwExtendedSubType::SUB_INVISIBLE | nsSwGetSetExpType::GSE_STRING); + aField.SetSubType(SwGetSetExpType::Invisible | SwGetSetExpType::String); m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) ); diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx index 618673ddde3c..4098d1d07b8e 100644 --- a/sw/source/ui/config/optload.cxx +++ b/sw/source/ui/config/optload.cxx @@ -1237,7 +1237,7 @@ void SwCaptionOptPage::UpdateEntry(int nSelEntry) { SwFieldType *pType = m_pMgr->GetFieldType( SwFieldIds::Unknown, i ); if( pType->Which() == SwFieldIds::SetExp && - static_cast<SwSetExpFieldType *>( pType)->GetType() & nsSwGetSetExpType::GSE_SEQ ) + static_cast<SwSetExpFieldType *>( pType)->GetType() & SwGetSetExpType::Sequence ) { m_xCategoryBox->append_text(pType->GetName().toString()); } diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx index 5b1db59a2ca2..dd30971ecb29 100644 --- a/sw/source/ui/fldui/fldpage.cxx +++ b/sw/source/ui/fldui/fldpage.cxx @@ -89,9 +89,9 @@ void SwFieldPage::Init() { SwDoc* pDoc = pSh->GetDoc(); pSh->InsertFieldType( SwSetExpFieldType( pDoc, - UIName(u"HTML_ON"_ustr), 1)); + UIName(u"HTML_ON"_ustr), SwGetSetExpType::String)); pSh->InsertFieldType( SwSetExpFieldType(pDoc, - UIName(u"HTML_OFF"_ustr), 1)); + UIName(u"HTML_OFF"_ustr), SwGetSetExpType::String)); } } @@ -229,7 +229,7 @@ void SwFieldPage::InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, con pTyp->SetOutlineLvl( static_cast< sal_uInt8 >(nSubType & 0xff)); pTyp->SetDelimiter(OUString(cSeparator)); - nSubType = nsSwGetSetExpType::GSE_SEQ; + nSubType = static_cast<sal_uInt16>(SwGetSetExpType::Sequence); } break; diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index 14542cdd7715..32205c64c88d 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -236,7 +236,7 @@ void SwFieldRefPage::Reset(const SfxItemSet* ) { SwSetExpFieldType* pType = static_cast<SwSetExpFieldType*>(pSh->GetFieldType(n, SwFieldIds::SetExp)); - if ((nsSwGetSetExpType::GSE_SEQ & pType->GetType()) && pType->HasWriterListeners() && pSh->IsUsed(*pType)) + if ((SwGetSetExpType::Sequence & pType->GetType()) && pType->HasWriterListeners() && pSh->IsUsed(*pType)) { m_xTypeLB->append(OUString::number(REFFLDFLAG | n), pType->GetName().toString()); } diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx index 22e86d744e9a..062ac70b2884 100644 --- a/sw/source/ui/fldui/fldvar.cxx +++ b/sw/source/ui/fldui/fldvar.cxx @@ -360,7 +360,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>( pSh->GetFieldType(SwFieldIds::SetExp, sName)); - if (pSetTyp && pSetTyp->GetType() == nsSwGetSetExpType::GSE_STRING) + if (pSetTyp && pSetTyp->GetType() == SwGetSetExpType::String) m_xNumFormatLB->select(0); // textual } } @@ -407,7 +407,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) if(pSetTyp) { - if (pSetTyp->GetType() & nsSwGetSetExpType::GSE_STRING) // textual? + if (pSetTyp->GetType() & SwGetSetExpType::String) // textual? bFormat = true; else // numeric bNumFormat = true; @@ -440,7 +440,7 @@ void SwFieldVarPage::SubTypeHdl(const weld::TreeView* pBox) if(pSetTyp) { - if (pSetTyp->GetType() == nsSwGetSetExpType::GSE_STRING) // textual? + if (pSetTyp->GetType() == SwGetSetExpType::String) // textual? { m_xNumFormatLB->clear(); m_xNumFormatLB->append(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND), SwResId(FMT_USERVAR_TEXT)); @@ -635,7 +635,7 @@ void SwFieldVarPage::UpdateSubType() if (GetCurField() && aList[i] == GetCurField()->GetTyp()->GetName()) { bInsert = true; - if (static_cast<SwSetExpField*>(GetCurField())->GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE) + if (static_cast<SwSetExpField*>(GetCurField())->GetSubType() & SwGetSetExpType::Invisible) m_xInvisibleCB->set_active(true); } break; @@ -937,10 +937,10 @@ IMPL_LINK_NOARG(SwFieldVarPage, ModifyHdl, weld::Entry&, void) if (i >= INIT_FLDTYPES && !pSh->IsUsed(*pFieldType)) bDelete = true; - if (nTypeId == SwFieldTypesEnum::Sequence && !(pFieldType->GetType() & nsSwGetSetExpType::GSE_SEQ)) + if (nTypeId == SwFieldTypesEnum::Sequence && !(pFieldType->GetType() & SwGetSetExpType::Sequence)) bInsert = false; - if (nTypeId == SwFieldTypesEnum::Set && (pFieldType->GetType() & nsSwGetSetExpType::GSE_SEQ)) + if (nTypeId == SwFieldTypesEnum::Set && (pFieldType->GetType() & SwGetSetExpType::Sequence)) bInsert = false; } } @@ -1177,27 +1177,29 @@ bool SwFieldVarPage::FillItemSet(SfxItemSet* ) { case SwFieldTypesEnum::User: { - nSubType = (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR; + SwGetSetExpType nUserSubType = (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) ? SwGetSetExpType::String : SwGetSetExpType::Expr; if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND && m_xNumFormatLB->get_selected_text() == SwResId(FMT_USERVAR_CMD)) - nSubType |= nsSwExtendedSubType::SUB_CMD; + nUserSubType |= SwGetSetExpType::Command; if (m_xInvisibleCB->get_active()) - nSubType |= nsSwExtendedSubType::SUB_INVISIBLE; + nUserSubType |= SwGetSetExpType::Invisible; + nSubType = static_cast<sal_uInt16>(nUserSubType); break; } case SwFieldTypesEnum::Formel: { - nSubType = nsSwGetSetExpType::GSE_FORMULA; + SwGetSetExpType nFormSubType = SwGetSetExpType::Formula; if (m_xNumFormatLB->get_visible() && nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) - nSubType |= nsSwExtendedSubType::SUB_CMD; + nFormSubType |= SwGetSetExpType::Command; + nSubType = static_cast<sal_uInt16>(nFormSubType); break; } case SwFieldTypesEnum::Get: { nSubType &= 0xff00; if (m_xNumFormatLB->get_visible() && nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) - nSubType |= nsSwExtendedSubType::SUB_CMD; + nSubType |= static_cast<sal_uInt16>(SwGetSetExpType::Command); break; } case SwFieldTypesEnum::Input: @@ -1209,16 +1211,15 @@ bool SwFieldVarPage::FillItemSet(SfxItemSet* ) case SwFieldTypesEnum::Set: { + SwGetSetExpType nSetSubType = SwGetSetExpType::None; if (IsFieldDlgHtmlMode()) - { - nSubType = 0x0100; - nSubType = (nSubType & 0xff00) | nsSwGetSetExpType::GSE_STRING; - } + nSetSubType = SwGetSetExpType::Command | SwGetSetExpType::String; else - nSubType = (nSubType & 0xff00) | ((nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR); + nSetSubType = ((nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) ? SwGetSetExpType::String : SwGetSetExpType::Expr); if (m_xInvisibleCB->get_active()) - nSubType |= nsSwExtendedSubType::SUB_INVISIBLE; + nSetSubType |= SwGetSetExpType::Invisible; + nSubType = static_cast<sal_uInt16>(nSetSubType); break; } case SwFieldTypesEnum::Sequence: diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx index 8e35ed8deb05..9bde9b1535cf 100644 --- a/sw/source/ui/frmdlg/cption.cxx +++ b/sw/source/ui/frmdlg/cption.cxx @@ -141,7 +141,7 @@ SwCaptionDialog::SwCaptionDialog(weld::Window *pParent, SwView &rV) { SwFieldType *pType = m_pMgr->GetFieldType( SwFieldIds::Unknown, i ); if( pType->Which() == SwFieldIds::SetExp && - static_cast<SwSetExpFieldType *>( pType)->GetType() & nsSwGetSetExpType::GSE_SEQ ) + static_cast<SwSetExpFieldType *>( pType)->GetType() & SwGetSetExpType::Sequence ) m_xCategoryBox->append_text(pType->GetName().toString()); } @@ -340,7 +340,7 @@ void SwCaptionDialog::ModifyHdl() : nullptr; m_xOKButton->set_sensitive( bCorrectFieldName && (!pType || - static_cast<SwSetExpFieldType*>(pType)->GetType() == nsSwGetSetExpType::GSE_SEQ) ); + static_cast<SwSetExpFieldType*>(pType)->GetType() == SwGetSetExpType::Sequence) ); m_xOptionButton->set_sensitive(m_xOKButton->get_sensitive() && !bNone); m_xNumberingSeparatorFT->set_sensitive(m_bOrderNumberingFirst && !bNone); m_xNumberingSeparatorED->set_sensitive(m_bOrderNumberingFirst && !bNone); @@ -497,7 +497,7 @@ void SwSequenceOptionDialog::Apply() else if( !m_aFieldTypeName.isEmpty() && nLvl < MAXLEVEL ) { // then we have to insert that - SwSetExpFieldType aFieldType( rSh.GetDoc(), UIName(m_aFieldTypeName), nsSwGetSetExpType::GSE_SEQ ); + SwSetExpFieldType aFieldType( rSh.GetDoc(), UIName(m_aFieldTypeName), SwGetSetExpType::Sequence ); aFieldType.SetDelimiter( OUString(cDelim) ); aFieldType.SetOutlineLvl( nLvl ); rSh.InsertFieldType( aFieldType ); diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 45b19c75e9fb..9f329afb21ca 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -1261,7 +1261,7 @@ void SwTOXSelectTabPage::Reset( const SfxItemSet* ) { SwFieldType *pType = rSh.GetFieldType( i, SwFieldIds::SetExp ); if( pType->Which() == SwFieldIds::SetExp && - static_cast<SwSetExpFieldType *>( pType)->GetType() & nsSwGetSetExpType::GSE_SEQ ) + static_cast<SwSetExpFieldType *>( pType)->GetType() & SwGetSetExpType::Sequence ) m_xCaptionSequenceLB->append_text(pType->GetName().toString()); } diff --git a/sw/source/uibase/docvw/edtwin2.cxx b/sw/source/uibase/docvw/edtwin2.cxx index 248eb2fa09d7..933df0b301b0 100644 --- a/sw/source/uibase/docvw/edtwin2.cxx +++ b/sw/source/uibase/docvw/edtwin2.cxx @@ -573,8 +573,8 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) case SwFieldIds::SetExp: { auto pSetExpField = const_cast<SwSetExpField*>(static_cast<const SwSetExpField*>(pField)); - sal_uInt16 nOldSubType = pSetExpField->GetSubType(); - pSetExpField->SetSubType(nsSwExtendedSubType::SUB_CMD); + SwGetSetExpType nOldSubType = pSetExpField->GetSubType(); + pSetExpField->SetSubType(SwGetSetExpType::Command); sText = pSetExpField->ExpandField(true, rSh.GetLayout()); pSetExpField->SetSubType(nOldSubType); break; @@ -582,8 +582,8 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) case SwFieldIds::Table: { auto pTableField = const_cast<SwTableField*>(static_cast<const SwTableField*>(pField)); - sal_uInt16 nOldSubType = pTableField->GetSubType(); - pTableField->SetSubType(nsSwExtendedSubType::SUB_CMD); + SwTableFieldSubType nOldSubType = pTableField->GetSubType(); + pTableField->SetSubType(SwTableFieldSubType::Command); sText = pTableField->ExpandField(true, rSh.GetLayout()); pTableField->SetSubType(nOldSubType); break; @@ -591,8 +591,8 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) case SwFieldIds::GetExp: { auto pGetExpField = const_cast<SwGetExpField*>(static_cast<const SwGetExpField*>(pField)); - sal_uInt16 nOldSubType = pGetExpField->GetSubType(); - pGetExpField->SetSubType(nsSwExtendedSubType::SUB_CMD); + SwGetSetExpType nOldSubType = pGetExpField->GetSubType(); + pGetExpField->SetSubType(SwGetSetExpType::Command); sText = pGetExpField->ExpandField(true, rSh.GetLayout()); pGetExpField->SetSubType(nOldSubType); break; diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index baa4e3fbea12..3e679bb83553 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -607,18 +607,18 @@ void SwFieldMgr::GetSubTypes(SwFieldTypesEnum nTypeId, std::vector<OUString>& rT (nTypeId == SwFieldTypesEnum::User && nWhich == SwFieldIds::User) || (nTypeId == SwFieldTypesEnum::Get && nWhich == SwFieldIds::SetExp && - !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) || + !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & SwGetSetExpType::Sequence)) || (nTypeId == SwFieldTypesEnum::Set && nWhich == SwFieldIds::SetExp && - !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) || + !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & SwGetSetExpType::Sequence)) || (nTypeId == SwFieldTypesEnum::Sequence && nWhich == SwFieldIds::SetExp && - (static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) || + (static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & SwGetSetExpType::Sequence)) || ((nTypeId == SwFieldTypesEnum::Input || nTypeId == SwFieldTypesEnum::Formel) && (nWhich == SwFieldIds::User || (nWhich == SwFieldIds::SetExp && - !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ))) ) ) + !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & SwGetSetExpType::Sequence))) ) ) { rToFill.push_back(pFieldType->GetName().toString()); } @@ -1391,8 +1391,8 @@ bool SwFieldMgr::InsertField( // Don't change type of SwSetExpFieldType: if (nInputSubType & SwInputFieldSubType::Invisible) { - sal_uInt16 nOldSubType = pExpField->GetSubType(); - pExpField->SetSubType(nOldSubType | nsSwExtendedSubType::SUB_INVISIBLE); + SwGetSetExpType nOldSubType = pExpField->GetSubType(); + pExpField->SetSubType(nOldSubType | SwGetSetExpType::Invisible); } pExpField->SetPromptText(rData.m_sPar2); pExpField->SetInputFlag(true) ; @@ -1415,7 +1415,7 @@ bool SwFieldMgr::InsertField( case SwFieldTypesEnum::Set: { - sal_uInt16 nSubType = rData.m_nSubType; + SwGetSetExpType nSubType = static_cast<SwGetSetExpType>(rData.m_nSubType); if (rData.m_sPar2.isEmpty()) // empty variables are not allowed return false; @@ -1434,7 +1434,7 @@ bool SwFieldMgr::InsertField( { sal_uInt16 nSubType = rData.m_nSubType; SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>( pCurShell->InsertFieldType( - SwSetExpFieldType(pCurShell->GetDoc(), UIName(rData.m_sPar1), nsSwGetSetExpType::GSE_SEQ))); + SwSetExpFieldType(pCurShell->GetDoc(), UIName(rData.m_sPar1), SwGetSetExpType::Sequence))); sal_uInt8 nLevel = static_cast< sal_uInt8 >(nSubType & 0xff); @@ -1450,7 +1450,7 @@ bool SwFieldMgr::InsertField( case SwFieldTypesEnum::Get: { - sal_uInt16 nSubType = rData.m_nSubType; + SwGetSetExpType nSubType = static_cast<SwGetSetExpType>(rData.m_nSubType); // is there a corresponding SetField SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>( pCurShell->GetFieldType(SwFieldIds::SetExp, rData.m_sPar1)); @@ -1469,7 +1469,6 @@ bool SwFieldMgr::InsertField( case SwFieldTypesEnum::Formel: { - sal_uInt16 nSubType = rData.m_nSubType; if(pCurShell->GetFrameType(nullptr,false) & FrameTypeFlags::TABLE) { pCurShell->StartAllAction(); @@ -1505,7 +1504,7 @@ bool SwFieldMgr::InsertField( { SwGetExpFieldType* pTyp = static_cast<SwGetExpFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::GetExp) ); - pField.reset( new SwGetExpField(pTyp, rData.m_sPar2, nSubType, nFormatId) ); + pField.reset( new SwGetExpField(pTyp, rData.m_sPar2, static_cast<SwGetSetExpType>(rData.m_nSubType), nFormatId) ); bExp = true; } break; diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index f7b515e3605a..c8a2bce3c1fc 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1562,7 +1562,7 @@ void SwTextShell::Execute(SfxRequest &rReq) { SvNumberFormatter* pFormatter = rWrtSh.GetNumberFormatter(); const sal_uInt32 nSysNumFormat = pFormatter->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM); - SwInsertField_Data aData(SwFieldTypesEnum::Formel, nsSwGetSetExpType::GSE_FORMULA, OUString(), sFormula, nSysNumFormat); + SwInsertField_Data aData(SwFieldTypesEnum::Formel, static_cast<sal_uInt16>(SwGetSetExpType::Formula), OUString(), sFormula, nSysNumFormat); aFieldMgr.InsertField(aData); } } diff --git a/sw/source/uibase/uiview/viewdlg2.cxx b/sw/source/uibase/uiview/viewdlg2.cxx index c26acb1fc537..ff57083b1ed6 100644 --- a/sw/source/uibase/uiview/viewdlg2.cxx +++ b/sw/source/uibase/uiview/viewdlg2.cxx @@ -245,7 +245,7 @@ void SwView::InsertCaption(const InsCaptionOpt *pOpt) if (!pFieldType && !rName.isEmpty() ) { // Create new field types - SwSetExpFieldType aSwSetExpFieldType(rSh.GetDoc(), UIName(rName), nsSwGetSetExpType::GSE_SEQ); + SwSetExpFieldType aSwSetExpFieldType(rSh.GetDoc(), UIName(rName), SwGetSetExpType::Sequence); aMgr.InsertFieldType(aSwSetExpFieldType); pFieldType = static_cast<SwSetExpFieldType*>(aMgr.GetFieldType(SwFieldIds::SetExp, rName)); }