sw/inc/docufld.hxx | 94 ++++++++++++---------- sw/source/core/access/accpara.cxx | 7 - sw/source/core/fields/docufld.cxx | 102 ++++++++++++------------ sw/source/core/fields/fldbas.cxx | 11 +- sw/source/core/text/txtfld.cxx | 2 sw/source/core/txtnode/atrfld.cxx | 15 +-- sw/source/core/unocore/unofield.cxx | 114 +++++++++++++-------------- sw/source/filter/html/htmlfld.cxx | 81 ++++++++----------- sw/source/filter/html/htmlfldw.cxx | 49 +++++------ sw/source/filter/ww8/docxattributeoutput.cxx | 1 sw/source/filter/ww8/ww8atr.cxx | 42 ++++----- sw/source/filter/ww8/ww8par5.cxx | 64 +++++++-------- sw/source/ui/fldui/flddinf.cxx | 92 +++++++++++---------- sw/source/ui/fldui/flddinf.hxx | 3 sw/source/ui/fldui/flddok.cxx | 2 sw/source/ui/fldui/fldedt.cxx | 4 sw/source/ui/fldui/fldpage.cxx | 2 sw/source/uibase/fldui/fldmgr.cxx | 15 +-- sw/source/uibase/shells/textfld.cxx | 12 +- sw/source/uibase/utlui/content.cxx | 2 20 files changed, 358 insertions(+), 356 deletions(-)
New commits: commit 3ee7fc8b29bbb0fcb39b21962f357868ade2d4aa Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Jul 5 18:43:01 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Tue Jul 8 08:13:04 2025 +0200 Convert SwDocInfoSubType to scoped enum Change-Id: If341422ae097caacdfd4cd4d734d478de0d83f72 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187501 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index 8690a49d5581..393632a29497 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -65,32 +65,43 @@ enum class SwDocStatSubType : sal_uInt16 OLE }; -typedef sal_uInt16 SwDocInfoSubType; -namespace nsSwDocInfoSubType +enum class SwDocInfoSubType : sal_uInt16 { /** NB: these must denote consecutive integers! NB2: these are extended by 4 DI_INFO values for backward compatibility in filter/html/htmlfld.cxx, so make sure that DI_SUBTYPE_END really is the end, and is at least 4 less than DI_SUB_*! */ - const SwDocInfoSubType DI_SUBTYPE_BEGIN = 0; - const SwDocInfoSubType DI_TITLE = DI_SUBTYPE_BEGIN; - const SwDocInfoSubType DI_SUBJECT = 1; - const SwDocInfoSubType DI_KEYS = 2; - const SwDocInfoSubType DI_COMMENT = 3; - const SwDocInfoSubType DI_CREATE = 4; - const SwDocInfoSubType DI_CHANGE = 5; - const SwDocInfoSubType DI_PRINT = 6; - const SwDocInfoSubType DI_DOCNO = 7; - const SwDocInfoSubType DI_EDIT = 8; - const SwDocInfoSubType DI_CUSTOM = 9; - const SwDocInfoSubType DI_SUBTYPE_END = 10; - - const SwDocInfoSubType DI_SUB_AUTHOR = 0x0100; - const SwDocInfoSubType DI_SUB_TIME = 0x0200; - const SwDocInfoSubType DI_SUB_DATE = 0x0300; - const SwDocInfoSubType DI_SUB_FIXED = 0x1000; - const SwDocInfoSubType DI_SUB_MASK = 0x0f00; -} + SubtypeBegin = 0, + Title = SubtypeBegin, + Subject = 1, + Keys = 2, + Comment = 3, + Create = 4, + Change = 5, + Print = 6, + DocNo = 7, + Edit = 8, + Custom = 9, + SubtypeEnd = 10, + LowerMask = 0x00ff, + UpperMask = 0xff00, + + // UGLY: these are necessary for importing document info fields written by + // older versions of OOo (< 3.0) which did not have Custom fields + Info1 = SubtypeEnd + 1, + Info2 = SubtypeEnd + 2, + Info3 = SubtypeEnd + 3, + Info4 = SubtypeEnd + 4, + + SubAuthor = 0x0100, + SubTime = 0x0200, + SubDate = 0x0300, + SubFixed = 0x1000, + SubMask = 0x0f00, + + Max = 0xffff // used as a flag by SwFieldDokInfPage +}; +namespace o3tl { template<> struct typed_flags<SwDocInfoSubType> : is_typed_flags<SwDocInfoSubType, 0xffff> {}; } enum SwPageNumSubType { @@ -566,13 +577,13 @@ class SAL_DLLPUBLIC_RTTI SwDocInfoFieldType final : public SwValueFieldType public: SwDocInfoFieldType(SwDoc* pDc); - OUString Expand(sal_uInt16 nSubType, sal_uInt32 nFormat, LanguageType nLang, const OUString& rName) const; + OUString Expand(SwDocInfoSubType nSubType, sal_uInt32 nFormat, LanguageType nLang, const OUString& rName) const; virtual std::unique_ptr<SwFieldType> Copy() const override; }; class SW_DLLPUBLIC SwDocInfoField final : public SwValueField { - sal_uInt16 m_nSubType; + SwDocInfoSubType m_nSubType; OUString m_aContent; OUString m_aName; @@ -580,11 +591,11 @@ class SW_DLLPUBLIC SwDocInfoField final : public SwValueField virtual std::unique_ptr<SwField> Copy() const override; public: - SwDocInfoField(SwDocInfoFieldType*, sal_uInt16 nSub, const OUString& rName, sal_uInt32 nFormat=0); - SwDocInfoField(SwDocInfoFieldType*, sal_uInt16 nSub, const OUString& rName, const OUString& rValue, sal_uInt32 nFormat=0); + SwDocInfoField(SwDocInfoFieldType*, SwDocInfoSubType nSub, const OUString& rName, sal_uInt32 nFormat=0); + SwDocInfoField(SwDocInfoFieldType*, SwDocInfoSubType nSub, const OUString& rName, const OUString& rValue, sal_uInt32 nFormat=0); - void SetSubType(sal_uInt16); - sal_uInt16 GetSubType() const; + void SetSubType(SwDocInfoSubType); + SwDocInfoSubType GetSubType() const; virtual void SetLanguage(LanguageType nLng) override; virtual OUString GetFieldName() const override; const OUString& GetName() const { return m_aName; } diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 5175f6f7222d..106293fe7180 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -1102,8 +1102,7 @@ OUString SwAccessibleParagraph::GetFieldTypeNameAtIndex(sal_Int32 nIndex) case SwFieldIds::DocInfo: { const SwDocInfoField* pDocInfoField = static_cast<const SwDocInfoField*>(pField); - subType = pDocInfoField->GetSubType(); - subType &= 0x00ff; + subType = static_cast<sal_uInt16>(pDocInfoField->GetSubType() & SwDocInfoSubType::LowerMask); } break; case SwFieldIds::RefPageSet: @@ -1139,7 +1138,7 @@ OUString SwAccessibleParagraph::GetFieldTypeNameAtIndex(sal_Int32 nIndex) strTypeName = sEntry; sal_uInt16 nSize = aMgr.GetFormatCount(pField->GetTypeId(), false); auto pDocInfoField = static_cast<const SwDocInfoField*>(pField); - const sal_uInt16 nExSub = pDocInfoField->GetSubType() & 0xff00; + const sal_uInt16 nExSub = static_cast<sal_uInt16>(pDocInfoField->GetSubType() & SwDocInfoSubType::UpperMask); if (nSize > 0 && nExSub > 0) { //Get extra subtype string diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index e580248c498b..a6987f4281a1 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -93,7 +93,6 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; -using namespace nsSwDocInfoSubType; SwPageNumberFieldType::SwPageNumberFieldType() : SwFieldType( SwFieldIds::PageNumber ), @@ -933,7 +932,7 @@ static void lcl_GetLocalDataWrapper( LanguageType nLang, *ppLocalData = new LocaleDataWrapper(LanguageTag( nLang )); } -OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, +OUString SwDocInfoFieldType::Expand( SwDocInfoSubType nSub, sal_uInt32 nFormat, LanguageType nLang, const OUString& rName ) const { const LocaleDataWrapper *pAppLocalData = nullptr, *pLocalData = nullptr; @@ -947,22 +946,22 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, xDPS->getDocumentProperties()); OSL_ENSURE(xDocProps.is(), "Doc has no DocumentProperties"); - sal_uInt16 nExtSub = nSub & 0xff00; - nSub &= 0xff; // do not consider extended SubTypes + SwDocInfoSubType nExtSub = nSub & SwDocInfoSubType::UpperMask; + nSub &= SwDocInfoSubType::LowerMask; // do not consider extended SubTypes OUString aStr; switch(nSub) { - case DI_TITLE: aStr = xDocProps->getTitle(); break; - case DI_SUBJECT:aStr = xDocProps->getSubject(); break; - case DI_KEYS: aStr = ::comphelper::string::convertCommaSeparated( + case SwDocInfoSubType::Title: aStr = xDocProps->getTitle(); break; + case SwDocInfoSubType::Subject:aStr = xDocProps->getSubject(); break; + case SwDocInfoSubType::Keys: aStr = ::comphelper::string::convertCommaSeparated( xDocProps->getKeywords()); break; - case DI_COMMENT:aStr = xDocProps->getDescription(); break; - case DI_DOCNO: aStr = OUString::number( + case SwDocInfoSubType::Comment:aStr = xDocProps->getDescription(); break; + case SwDocInfoSubType::DocNo: aStr = OUString::number( xDocProps->getEditingCycles() ); break; - case DI_EDIT: + case SwDocInfoSubType::Edit: if ( !nFormat ) { lcl_GetLocalDataWrapper( nLang, &pAppLocalData, &pLocalData ); @@ -978,7 +977,7 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, aStr = ExpandValue(fVal, nFormat, nLang); } break; - case DI_CUSTOM: + case SwDocInfoSubType::Custom: { OUString sVal; try @@ -1002,15 +1001,15 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, OUString aName( xDocProps->getAuthor() ); util::DateTime uDT( xDocProps->getCreationDate() ); DateTime aDate(uDT); - if( nSub == DI_CREATE ) + if( nSub == SwDocInfoSubType::Create ) ; // that's it !! - else if( nSub == DI_CHANGE ) + else if( nSub == SwDocInfoSubType::Change ) { aName = xDocProps->getModifiedBy(); uDT = xDocProps->getModificationDate(); aDate = DateTime(uDT); } - else if( nSub == DI_PRINT ) + else if( nSub == SwDocInfoSubType::Print ) { aName = xDocProps->getPrintedBy(); if ( !std::getenv("STABLE_FIELDS_HACK") ) @@ -1024,13 +1023,13 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, if (aDate.IsValidAndGregorian()) { - switch (nExtSub & ~DI_SUB_FIXED) + switch (nExtSub & ~SwDocInfoSubType::SubFixed) { - case DI_SUB_AUTHOR: + case SwDocInfoSubType::SubAuthor: aStr = aName; break; - case DI_SUB_TIME: + case SwDocInfoSubType::SubTime: if (!nFormat) { lcl_GetLocalDataWrapper( nLang, &pAppLocalData, @@ -1047,7 +1046,7 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, } break; - case DI_SUB_DATE: + case SwDocInfoSubType::SubDate: if (!nFormat) { lcl_GetLocalDataWrapper( nLang, &pAppLocalData, @@ -1062,6 +1061,7 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, aStr = ExpandValue(fVal, nFormat, nLang); } break; + default: break; } } } @@ -1076,14 +1076,14 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, // document info field -SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const OUString& rName, sal_uInt32 nFormat) : +SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, SwDocInfoSubType nSub, const OUString& rName, sal_uInt32 nFormat) : SwValueField(pTyp, nFormat), m_nSubType(nSub) { m_aName = rName; m_aContent = static_cast<SwDocInfoFieldType*>(GetTyp())->Expand(m_nSubType, nFormat, GetLanguage(), m_aName); } -SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const OUString& rName, const OUString& rValue, sal_uInt32 nFormat) : +SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, SwDocInfoSubType nSub, const OUString& rName, const OUString& rValue, sal_uInt32 nFormat) : SwValueField(pTyp, nFormat), m_nSubType(nSub) { m_aName = rName; @@ -1113,7 +1113,7 @@ OUString SwDocInfoField::ExpandImpl(SwRootFrame const*const) const // if the field is "fixed" we don't update it from the property if (!IsFixed()) { - if ( ( m_nSubType & 0xFF ) == DI_CUSTOM ) + if ( ( m_nSubType & SwDocInfoSubType::LowerMask ) == SwDocInfoSubType::Custom ) { // custom properties currently need special treatment // We don't have a secure way to detect "real" custom properties in Word import of text @@ -1181,17 +1181,17 @@ OUString SwDocInfoField::GetFieldName() const { OUString aStr(SwFieldType::GetTypeStr(GetTypeId()) + ":"); - sal_uInt16 const nSub = m_nSubType & 0xff; + SwDocInfoSubType const nSub = m_nSubType & SwDocInfoSubType::LowerMask; switch (nSub) { - case DI_CUSTOM: + case SwDocInfoSubType::Custom: aStr += m_aName; break; default: aStr += SwViewShell::GetShellRes() - ->aDocInfoLst[ nSub - DI_SUBTYPE_BEGIN ]; + ->aDocInfoLst[ static_cast<sal_uInt16>(nSub) - static_cast<sal_uInt16>(SwDocInfoSubType::SubtypeBegin) ]; break; } if (IsFixed()) @@ -1210,12 +1210,12 @@ std::unique_ptr<SwField> SwDocInfoField::Copy() const return std::unique_ptr<SwField>(pField.release()); } -sal_uInt16 SwDocInfoField::GetSubType() const +SwDocInfoSubType SwDocInfoField::GetSubType() const { return m_nSubType; } -void SwDocInfoField::SetSubType(sal_uInt16 nSub) +void SwDocInfoField::SetSubType(SwDocInfoSubType nSub) { m_nSubType = nSub; } @@ -1245,7 +1245,7 @@ bool SwDocInfoField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const break; case FIELD_PROP_BOOL1: - rAny <<= 0 != (m_nSubType & DI_SUB_FIXED); + rAny <<= bool(m_nSubType & SwDocInfoSubType::SubFixed); break; case FIELD_PROP_FORMAT: @@ -1263,8 +1263,8 @@ bool SwDocInfoField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const break; case FIELD_PROP_BOOL2: { - sal_uInt16 nExtSub = (m_nSubType & 0xff00) & ~DI_SUB_FIXED; - rAny <<= nExtSub == DI_SUB_DATE; + SwDocInfoSubType nExtSub = (m_nSubType & SwDocInfoSubType::UpperMask) & ~SwDocInfoSubType::SubFixed; + rAny <<= nExtSub == SwDocInfoSubType::SubDate; } break; default: @@ -1279,12 +1279,12 @@ bool SwDocInfoField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) switch( nWhichId ) { case FIELD_PROP_PAR1: - if( m_nSubType & DI_SUB_FIXED ) + if( m_nSubType & SwDocInfoSubType::SubFixed ) rAny >>= m_aContent; break; case FIELD_PROP_USHORT1: - if( m_nSubType & DI_SUB_FIXED ) + if( m_nSubType & SwDocInfoSubType::SubFixed ) { rAny >>= nValue; m_aContent = OUString::number(nValue); @@ -1293,9 +1293,9 @@ bool SwDocInfoField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) case FIELD_PROP_BOOL1: if(*o3tl::doAccess<bool>(rAny)) - m_nSubType |= DI_SUB_FIXED; + m_nSubType |= SwDocInfoSubType::SubFixed; else - m_nSubType &= ~DI_SUB_FIXED; + m_nSubType &= ~SwDocInfoSubType::SubFixed; break; case FIELD_PROP_FORMAT: { @@ -1309,11 +1309,11 @@ bool SwDocInfoField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) rAny >>= m_aContent; break; case FIELD_PROP_BOOL2: - m_nSubType &= 0xf0ff; + m_nSubType &= ~SwDocInfoSubType::SubMask; if(*o3tl::doAccess<bool>(rAny)) - m_nSubType |= DI_SUB_DATE; + m_nSubType |= SwDocInfoSubType::SubDate; else - m_nSubType |= DI_SUB_TIME; + m_nSubType |= SwDocInfoSubType::SubTime; break; default: return SwField::PutValue(rAny, nWhichId); diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 97a748b773b9..92aad51de83d 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -50,7 +50,6 @@ #include <usrfld.hxx> using namespace ::com::sun::star; -using namespace nsSwDocInfoSubType; static LanguageType lcl_GetLanguageOfFormat(LanguageType nLng, sal_uLong nFormat) { @@ -468,7 +467,7 @@ sal_uInt16 SwField::GetUntypedSubType() const case SwFieldIds::ExtUser: return static_cast<sal_uInt32>(static_cast<const SwExtUserField*>(this)->GetSubType()); case SwFieldIds::DocInfo: - return static_cast<const SwDocInfoField*>(this)->GetSubType(); + return static_cast<sal_uInt16>(static_cast<const SwDocInfoField*>(this)->GetSubType()); case SwFieldIds::HiddenText: return static_cast<sal_uInt16>(static_cast<const SwHiddenTextField*>(this)->GetSubType()); case SwFieldIds::DocStat: @@ -516,7 +515,7 @@ void SwField::SetUntypedSubType(sal_uInt16 n) static_cast<SwExtUserField*>(this)->SetSubType(n); break; case SwFieldIds::DocInfo: - static_cast<SwDocInfoField*>(this)->SetSubType(n); + static_cast<SwDocInfoField*>(this)->SetSubType(static_cast<SwDocInfoSubType>(n)); break; case SwFieldIds::HiddenText: static_cast<SwHiddenTextField*>(this)->SetSubType(static_cast<SwFieldTypesEnum>(n)); @@ -658,7 +657,7 @@ bool SwField::IsFixed() const break; case SwFieldIds::DocInfo: - bRet = 0 != (static_cast<const SwDocInfoField*>(this)->GetSubType() & DI_SUB_FIXED); + bRet = bool(static_cast<const SwDocInfoField*>(this)->GetSubType() & SwDocInfoSubType::SubFixed); break; default: break; } diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 41424ccd36f8..d57022e8bd91 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -363,16 +363,17 @@ namespace if (rField.GetTyp()->Which() == SwFieldIds::DocInfo) { auto pDocInfoField = static_cast<const SwDocInfoField*>(&rField); - sal_uInt16 nSubType = pDocInfoField->GetSubType(); + SwDocInfoSubType nSubType = pDocInfoField->GetSubType(); // Do not consider extended SubTypes. - nSubType &= 0xff; + nSubType &= SwDocInfoSubType::LowerMask; switch (nSubType) { - case nsSwDocInfoSubType::DI_TITLE: - case nsSwDocInfoSubType::DI_SUBJECT: - case nsSwDocInfoSubType::DI_CHANGE: - case nsSwDocInfoSubType::DI_CUSTOM: + case SwDocInfoSubType::Title: + case SwDocInfoSubType::Subject: + case SwDocInfoSubType::Change: + case SwDocInfoSubType::Custom: return false; + default: break; } } return true; diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 7433847565b4..04819887e1d3 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -90,31 +90,30 @@ #include <vector> using namespace ::com::sun::star; -using namespace nsSwDocInfoSubType; // case-corrected version of the first part for the service names (see #i67811) constexpr OUString COM_TEXT_FLDMASTER_CC = u"com.sun.star.text.fieldmaster."_ustr; // note: this thing is indexed as an array, so do not insert/remove entries! -const sal_uInt16 aDocInfoSubTypeFromService[] = -{ - DI_CHANGE | DI_SUB_AUTHOR, //PROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_AUTHOR - DI_CHANGE | DI_SUB_DATE, //PROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_DATE_TIME - DI_EDIT | DI_SUB_TIME, //PROPERTY_MAP_FLDTYP_DOCINFO_EDIT_TIME - DI_COMMENT, //PROPERTY_MAP_FLDTYP_DOCINFO_DESCRIPTION - DI_CREATE | DI_SUB_AUTHOR, //PROPERTY_MAP_FLDTYP_DOCINFO_CREATE_AUTHOR - DI_CREATE | DI_SUB_DATE, //PROPERTY_MAP_FLDTYP_DOCINFO_CREATE_DATE_TIME - 0, //DUMMY - 0, //DUMMY - 0, //DUMMY - 0, //DUMMY - DI_CUSTOM, //PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM - DI_PRINT | DI_SUB_AUTHOR, //PROPERTY_MAP_FLDTYP_DOCINFO_PRINT_AUTHOR - DI_PRINT | DI_SUB_DATE, //PROPERTY_MAP_FLDTYP_DOCINFO_PRINT_DATE_TIME - DI_KEYS, //PROPERTY_MAP_FLDTYP_DOCINFO_KEY_WORDS - DI_SUBJECT, //PROPERTY_MAP_FLDTYP_DOCINFO_SUBJECT - DI_TITLE, //PROPERTY_MAP_FLDTYP_DOCINFO_TITLE - DI_DOCNO //PROPERTY_MAP_FLDTYP_DOCINFO_REVISION +const SwDocInfoSubType aDocInfoSubTypeFromService[] = +{ + SwDocInfoSubType::Change | SwDocInfoSubType::SubAuthor, //PROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_AUTHOR + SwDocInfoSubType::Change | SwDocInfoSubType::SubDate, //PROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_DATE_TIME + SwDocInfoSubType::Edit | SwDocInfoSubType::SubTime, //PROPERTY_MAP_FLDTYP_DOCINFO_EDIT_TIME + SwDocInfoSubType::Comment, //PROPERTY_MAP_FLDTYP_DOCINFO_DESCRIPTION + SwDocInfoSubType::Create | SwDocInfoSubType::SubAuthor, //PROPERTY_MAP_FLDTYP_DOCINFO_CREATE_AUTHOR + SwDocInfoSubType::Create | SwDocInfoSubType::SubDate, //PROPERTY_MAP_FLDTYP_DOCINFO_CREATE_DATE_TIME + SwDocInfoSubType::SubtypeBegin, //DUMMY + SwDocInfoSubType::SubtypeBegin, //DUMMY + SwDocInfoSubType::SubtypeBegin, //DUMMY + SwDocInfoSubType::SubtypeBegin, //DUMMY + SwDocInfoSubType::Custom, //PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM + SwDocInfoSubType::Print | SwDocInfoSubType::SubAuthor, //PROPERTY_MAP_FLDTYP_DOCINFO_PRINT_AUTHOR + SwDocInfoSubType::Print | SwDocInfoSubType::SubDate, //PROPERTY_MAP_FLDTYP_DOCINFO_PRINT_DATE_TIME + SwDocInfoSubType::Keys, //PROPERTY_MAP_FLDTYP_DOCINFO_KEY_WORDS + SwDocInfoSubType::Subject, //PROPERTY_MAP_FLDTYP_DOCINFO_SUBJECT + SwDocInfoSubType::Title, //PROPERTY_MAP_FLDTYP_DOCINFO_TITLE + SwDocInfoSubType::DocNo //PROPERTY_MAP_FLDTYP_DOCINFO_REVISION }; namespace { @@ -212,31 +211,32 @@ static SwServiceType lcl_GetServiceForField( const SwField& rField ) case SwFieldIds::DocInfo: { auto rDocInfoField = static_cast<const SwDocInfoField&>(rField); - const sal_uInt16 nSubType = rDocInfoField.GetSubType(); - switch( nSubType & 0xff ) + const SwDocInfoSubType nSubType = rDocInfoField.GetSubType(); + switch( nSubType & SwDocInfoSubType::LowerMask ) { - case DI_CHANGE: - nSrvId = ((nSubType&0x300) == DI_SUB_AUTHOR) + case SwDocInfoSubType::Change: + nSrvId = ((nSubType & SwDocInfoSubType::SubMask) == SwDocInfoSubType::SubAuthor) ? SwServiceType::FieldTypeDocInfoChangeAuthor : SwServiceType::FieldTypeDocInfoChangeDateTime; break; - case DI_CREATE: - nSrvId = ((nSubType&0x300) == DI_SUB_AUTHOR) + case SwDocInfoSubType::Create: + nSrvId = ((nSubType & SwDocInfoSubType::SubMask) == SwDocInfoSubType::SubAuthor) ? SwServiceType::FieldTypeDocInfoCreateAuthor : SwServiceType::FieldTypeDocInfoCreateDateTime; break; - case DI_PRINT: - nSrvId = ((nSubType&0x300) == DI_SUB_AUTHOR) + case SwDocInfoSubType::Print: + nSrvId = ((nSubType & SwDocInfoSubType::SubMask) == SwDocInfoSubType::SubAuthor) ? SwServiceType::FieldTypeDocInfoPrintAuthor : SwServiceType::FieldTypeDocInfoPrintDateTime; break; - case DI_EDIT: nSrvId = SwServiceType::FieldTypeDocInfoEditTime;break; - case DI_COMMENT:nSrvId = SwServiceType::FieldTypeDocInfoDescription;break; - case DI_KEYS: nSrvId = SwServiceType::FieldTypeDocInfoKeywords;break; - case DI_SUBJECT:nSrvId = SwServiceType::FieldTypeDocInfoSubject; break; - case DI_TITLE: nSrvId = SwServiceType::FieldTypeDocInfoTitle; break; - case DI_DOCNO: nSrvId = SwServiceType::FieldTypeDocInfoRevision; break; - case DI_CUSTOM: nSrvId = SwServiceType::FieldTypeDocInfoCustom; break; + case SwDocInfoSubType::Edit: nSrvId = SwServiceType::FieldTypeDocInfoEditTime;break; + case SwDocInfoSubType::Comment:nSrvId = SwServiceType::FieldTypeDocInfoDescription;break; + case SwDocInfoSubType::Keys: nSrvId = SwServiceType::FieldTypeDocInfoKeywords;break; + case SwDocInfoSubType::Subject:nSrvId = SwServiceType::FieldTypeDocInfoSubject; break; + case SwDocInfoSubType::Title: nSrvId = SwServiceType::FieldTypeDocInfoTitle; break; + case SwDocInfoSubType::DocNo: nSrvId = SwServiceType::FieldTypeDocInfoRevision; break; + case SwDocInfoSubType::Custom: nSrvId = SwServiceType::FieldTypeDocInfoCustom; break; + default: break; } } break; @@ -1570,7 +1570,7 @@ void SAL_CALL SwXTextField::attach( case SwServiceType::FieldTypeDocInfo: { SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocInfo); - sal_uInt16 nSubType = aDocInfoSubTypeFromService[ + SwDocInfoSubType nSubType = aDocInfoSubTypeFromService[ static_cast<sal_uInt16>(m_pImpl->m_nServiceId) - sal_uInt16(SwServiceType::FieldTypeDocInfoChangeAuthor)]; if (SwServiceType::FieldTypeDocInfoChangeDateTime == m_pImpl->m_nServiceId || SwServiceType::FieldTypeDocInfoCreateDateTime == m_pImpl->m_nServiceId || @@ -1579,17 +1579,17 @@ void SAL_CALL SwXTextField::attach( { if (m_pImpl->m_pProps->bBool2) //IsDate { - nSubType &= 0xf0ff; - nSubType |= DI_SUB_DATE; + nSubType &= ~SwDocInfoSubType::SubMask; + nSubType |= SwDocInfoSubType::SubDate; } else { - nSubType &= 0xf0ff; - nSubType |= DI_SUB_TIME; + nSubType &= ~SwDocInfoSubType::SubMask; + nSubType |= SwDocInfoSubType::SubTime; } } if (m_pImpl->m_pProps->bBool1) - nSubType |= DI_SUB_FIXED; + nSubType |= SwDocInfoSubType::SubFixed; xField.reset(new SwDocInfoField( static_cast<SwDocInfoFieldType*>(pFieldType), nSubType, m_pImpl->m_pProps->sPar4, m_pImpl->m_pProps->nFormat)); diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx index 984240f78425..901be06a099b 100644 --- a/sw/source/filter/html/htmlfld.cxx +++ b/sw/source/filter/html/htmlfld.cxx @@ -37,7 +37,6 @@ #include "htmlfld.hxx" #include "swhtml.hxx" -using namespace nsSwDocInfoSubType; using namespace ::com::sun::star; namespace { @@ -144,36 +143,28 @@ HTMLOptionEnum<SwPageNumSubType> const aHTMLPageNumFieldSubTable[] = { nullptr, SwPageNumSubType(0) } }; -// UGLY: these are extensions of nsSwDocInfoSubType (in inc/docufld.hxx) -// these are necessary for importing document info fields written by -// older versions of OOo (< 3.0) which did not have DI_CUSTOM fields - const SwDocInfoSubType DI_INFO1 = DI_SUBTYPE_END + 1; - const SwDocInfoSubType DI_INFO2 = DI_SUBTYPE_END + 2; - const SwDocInfoSubType DI_INFO3 = DI_SUBTYPE_END + 3; - const SwDocInfoSubType DI_INFO4 = DI_SUBTYPE_END + 4; - -HTMLOptionEnum<sal_uInt16> const aHTMLDocInfoFieldSubTable[] = +HTMLOptionEnum<SwDocInfoSubType> const aHTMLDocInfoFieldSubTable[] = { - { OOO_STRING_SW_HTML_FS_title, DI_TITLE }, - { OOO_STRING_SW_HTML_FS_theme, DI_SUBJECT }, - { OOO_STRING_SW_HTML_FS_keys, DI_KEYS }, - { OOO_STRING_SW_HTML_FS_comment, DI_COMMENT }, - { "INFO1", DI_INFO1 }, - { "INFO2", DI_INFO2 }, - { "INFO3", DI_INFO3 }, - { "INFO4", DI_INFO4 }, - { OOO_STRING_SW_HTML_FS_custom, DI_CUSTOM }, - { OOO_STRING_SW_HTML_FS_create, DI_CREATE }, - { OOO_STRING_SW_HTML_FS_change, DI_CHANGE }, - { nullptr, 0 } + { OOO_STRING_SW_HTML_FS_title, SwDocInfoSubType::Title }, + { OOO_STRING_SW_HTML_FS_theme, SwDocInfoSubType::Subject }, + { OOO_STRING_SW_HTML_FS_keys, SwDocInfoSubType::Keys }, + { OOO_STRING_SW_HTML_FS_comment, SwDocInfoSubType::Comment }, + { "INFO1", SwDocInfoSubType::Info1 }, + { "INFO2", SwDocInfoSubType::Info2 }, + { "INFO3", SwDocInfoSubType::Info3 }, + { "INFO4", SwDocInfoSubType::Info4 }, + { OOO_STRING_SW_HTML_FS_custom, SwDocInfoSubType::Custom }, + { OOO_STRING_SW_HTML_FS_create, SwDocInfoSubType::Create }, + { OOO_STRING_SW_HTML_FS_change, SwDocInfoSubType::Change }, + { nullptr, SwDocInfoSubType(0) } }; -HTMLOptionEnum<sal_uInt16> const aHTMLDocInfoFieldFormatTable[] = +HTMLOptionEnum<SwDocInfoSubType> const aHTMLDocInfoFieldFormatTable[] = { - { OOO_STRING_SW_HTML_FF_author, DI_SUB_AUTHOR }, - { OOO_STRING_SW_HTML_FF_time, DI_SUB_TIME }, - { OOO_STRING_SW_HTML_FF_date, DI_SUB_DATE }, - { nullptr, 0 } + { OOO_STRING_SW_HTML_FF_author, SwDocInfoSubType::SubAuthor }, + { OOO_STRING_SW_HTML_FF_time, SwDocInfoSubType::SubTime }, + { OOO_STRING_SW_HTML_FF_date, SwDocInfoSubType::SubDate }, + { nullptr, SwDocInfoSubType(0) } }; HTMLOptionEnum<SwDocStatSubType> const aHTMLDocStatFieldSubTable[] = @@ -441,14 +432,14 @@ void SwHTMLParser::NewField() case SwFieldIds::DocInfo: if( pSubOption ) { - sal_uInt16 nSub; + SwDocInfoSubType nSub; if( pSubOption->GetEnum( nSub, aHTMLDocInfoFieldSubTable ) ) { - sal_uInt16 nExtSub = 0; - if( DI_CREATE==static_cast<SwDocInfoSubType>(nSub) || - DI_CHANGE==static_cast<SwDocInfoSubType>(nSub) ) + SwDocInfoSubType nExtSub = SwDocInfoSubType::Title; + if( SwDocInfoSubType::Create == nSub || + SwDocInfoSubType::Change == nSub ) { - nExtSub = DI_SUB_AUTHOR; + nExtSub = SwDocInfoSubType::SubAuthor; if( pFormatOption ) pFormatOption->GetEnum( nExtSub, aHTMLDocInfoFieldFormatTable ); nSub |= nExtSub; @@ -456,7 +447,7 @@ void SwHTMLParser::NewField() sal_uInt32 nNumFormat = 0; double dValue = 0; - if( bHasNumFormat && (DI_SUB_DATE==nExtSub || DI_SUB_TIME==nExtSub) ) + if( bHasNumFormat && (SwDocInfoSubType::SubDate==nExtSub || SwDocInfoSubType::SubTime==nExtSub) ) { LanguageType eLang; dValue = GetTableDataOptionsValNum( @@ -467,17 +458,17 @@ void SwHTMLParser::NewField() else bHasNumValue = false; - if( nSub >= DI_INFO1 && nSub <= DI_INFO4 && aName.isEmpty() ) + if( nSub >= SwDocInfoSubType::Info1 && nSub <= SwDocInfoSubType::Info4 && aName.isEmpty() ) { // backward compatibility for OOo 2: // map to names stored in AddMetaUserDefined - aName = m_InfoNames[nSub - DI_INFO1]; - nSub = DI_CUSTOM; + aName = m_InfoNames[static_cast<sal_uInt16>(nSub) - static_cast<sal_uInt16>(SwDocInfoSubType::Info1)]; + nSub = SwDocInfoSubType::Custom; } if( bFixed ) { - nSub |= DI_SUB_FIXED; + nSub |= SwDocInfoSubType::SubFixed; bInsOnEndTag = true; } diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx index b6aa316c786a..c23ceab25fe8 100644 --- a/sw/source/filter/html/htmlfldw.cxx +++ b/sw/source/filter/html/htmlfldw.cxx @@ -43,8 +43,6 @@ #include "css1atr.hxx" #include "css1kywd.hxx" -using namespace nsSwDocInfoSubType; - const char *SwHTMLWriter::GetNumFormat( sal_uInt16 nFormat ) { const char *pFormatStr = nullptr; @@ -174,42 +172,43 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, { auto pDocInfoField = static_cast<const SwDocInfoField*>(pField); nNumFormat = pDocInfoField->GetFormat(); - sal_uInt16 nSubType = pDocInfoField->GetSubType(); + SwDocInfoSubType nSubType = pDocInfoField->GetSubType(); pTypeStr = OOO_STRING_SW_HTML_FT_docinfo; - sal_uInt16 nExtSubType = nSubType & 0x0f00; - nSubType &= 0x00ff; + SwDocInfoSubType nExtSubType = nSubType & SwDocInfoSubType::SubMask; + nSubType &= SwDocInfoSubType::LowerMask; switch( nSubType ) { - case DI_TITLE: pSubStr = OOO_STRING_SW_HTML_FS_title; break; - case DI_SUBJECT: pSubStr = OOO_STRING_SW_HTML_FS_theme; break; - case DI_KEYS: pSubStr = OOO_STRING_SW_HTML_FS_keys; break; - case DI_COMMENT: pSubStr = OOO_STRING_SW_HTML_FS_comment; break; - case DI_CREATE: pSubStr = OOO_STRING_SW_HTML_FS_create; break; - case DI_CHANGE: pSubStr = OOO_STRING_SW_HTML_FS_change; break; - case DI_CUSTOM: pSubStr = OOO_STRING_SW_HTML_FS_custom; break; + case SwDocInfoSubType::Title: pSubStr = OOO_STRING_SW_HTML_FS_title; break; + case SwDocInfoSubType::Subject: pSubStr = OOO_STRING_SW_HTML_FS_theme; break; + case SwDocInfoSubType::Keys: pSubStr = OOO_STRING_SW_HTML_FS_keys; break; + case SwDocInfoSubType::Comment: pSubStr = OOO_STRING_SW_HTML_FS_comment; break; + case SwDocInfoSubType::Create: pSubStr = OOO_STRING_SW_HTML_FS_create; break; + case SwDocInfoSubType::Change: pSubStr = OOO_STRING_SW_HTML_FS_change; break; + case SwDocInfoSubType::Custom: pSubStr = OOO_STRING_SW_HTML_FS_custom; break; default: pTypeStr = nullptr; break; } - if( DI_CUSTOM == nSubType ) { + if( SwDocInfoSubType::Custom == nSubType ) { aName = pDocInfoField->GetName(); } - if( DI_CREATE == nSubType || DI_CHANGE == nSubType ) + if( SwDocInfoSubType::Create == nSubType || SwDocInfoSubType::Change == nSubType ) { switch( nExtSubType ) { - case DI_SUB_AUTHOR: + case SwDocInfoSubType::SubAuthor: pFormatStr = OOO_STRING_SW_HTML_FF_author; break; - case DI_SUB_TIME: + case SwDocInfoSubType::SubTime: pFormatStr = OOO_STRING_SW_HTML_FF_time; bNumFormat = true; break; - case DI_SUB_DATE: + case SwDocInfoSubType::SubDate: pFormatStr = OOO_STRING_SW_HTML_FF_date; bNumFormat = true; break; + default: break; } } bFixed = pDocInfoField->IsFixed(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 39ddd1f5dca5..94417461faee 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -173,7 +173,6 @@ using ::editeng::SvxBorderLine; using namespace oox; using namespace docx; using namespace sax_fastparser; -using namespace nsSwDocInfoSubType; using namespace sw::util; using namespace ::com::sun::star; using namespace ::com::sun::star::drawing; diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 4e630a7d8168..8a09016fa157 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -147,7 +147,6 @@ using ::editeng::SvxBorderLine; using namespace ::com::sun::star; -using namespace nsSwDocInfoSubType; using namespace sw::util; using namespace sw::types; @@ -3059,34 +3058,34 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) case SwFieldIds::DocInfo: // Last printed, last edited,... { auto pDocInfoField = static_cast<const SwDocInfoField*>(pField); - const sal_uInt16 nSubType = pDocInfoField->GetSubType(); - if( DI_SUB_FIXED & nSubType ) + const SwDocInfoSubType nSubType = pDocInfoField->GetSubType(); + if( SwDocInfoSubType::SubFixed & nSubType ) bWriteExpand = true; OUString sStr; ww::eField eField(ww::eNONE); - switch (0xff & nSubType) + switch (SwDocInfoSubType::LowerMask & nSubType) { - case DI_TITLE: + case SwDocInfoSubType::Title: eField = ww::eTITLE; break; - case DI_SUBJECT: + case SwDocInfoSubType::Subject: eField = ww::eSUBJECT; break; - case DI_KEYS: + case SwDocInfoSubType::Keys: eField = ww::eKEYWORDS; break; - case DI_COMMENT: + case SwDocInfoSubType::Comment: eField = ww::eCOMMENTS; break; - case DI_DOCNO: + case SwDocInfoSubType::DocNo: eField = ww::eREVNUM; break; - case DI_EDIT: + case SwDocInfoSubType::Edit: eField = ww::eEDITTIME; break; - case DI_CREATE: - if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK)) + case SwDocInfoSubType::Create: + if (SwDocInfoSubType::SubAuthor == (nSubType & SwDocInfoSubType::SubMask)) eField = ww::eAUTHOR; else if (GetExport().GetNumberFormat(*pField, sStr) || sStr.isEmpty()) eField = ww::eCREATEDATE; @@ -3095,8 +3094,8 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) bWriteExpand = false; break; - case DI_CHANGE: - if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK)) + case SwDocInfoSubType::Change: + if (SwDocInfoSubType::SubAuthor == (nSubType & SwDocInfoSubType::SubMask)) { eField = ww::eLASTSAVEDBY; bWriteExpand=false; @@ -3105,12 +3104,12 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) eField = ww::eSAVEDATE; break; - case DI_PRINT: - if (DI_SUB_AUTHOR != (nSubType & DI_SUB_MASK) && + case SwDocInfoSubType::Print: + if (SwDocInfoSubType::SubAuthor != (nSubType & SwDocInfoSubType::SubMask) && (GetExport().GetNumberFormat(*pField, sStr) || sStr.isEmpty())) eField = ww::ePRINTDATE; break; - case DI_CUSTOM: + case SwDocInfoSubType::Custom: eField = ww::eDOCPROPERTY; sStr = "\"" + pDocInfoField->GetName() + "\""; bWriteExpand = false; diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index fb508de09d6e..8b2aa0c7bc2c 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -96,7 +96,6 @@ using namespace ::com::sun::star; using namespace msfilter::util; using namespace sw::util; using namespace sw::mark; -using namespace nsSwDocInfoSubType; // Bookmarks namespace @@ -1586,11 +1585,11 @@ eF_ResT SwWW8ImplReader::Read_F_Styleref(WW8FieldDesc*, OUString& rString) eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr ) { - sal_uInt16 nSub=0; + SwDocInfoSubType nSub = SwDocInfoSubType::SubtypeBegin; // RegInfoFormat, DefaultFormat for DocInfoFields - sal_uInt16 nReg = DI_SUB_AUTHOR; + SwDocInfoSubType nReg = SwDocInfoSubType::SubAuthor; bool bDateTime = false; - const sal_uInt16 nFldLock = (pF->nOpt & 0x10) ? DI_SUB_FIXED : 0; + const SwDocInfoSubType nFldLock = (pF->nOpt & 0x10) ? SwDocInfoSubType::SubFixed : SwDocInfoSubType::SubtypeBegin; if( 85 == pF->nId ) { @@ -1710,7 +1709,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr ) const auto pType(static_cast<SwDocInfoFieldType*>( m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocInfo))); const OUString sDisplayed = GetFieldResult(pF); - SwDocInfoField aField(pType, DI_CUSTOM | nReg, aDocProperty); + SwDocInfoField aField(pType, SwDocInfoSubType::Custom | nReg, aDocProperty); // If text already matches the DocProperty var, then safe to treat as refreshable field. OUString sVariable = aField.ExpandField(/*bCache=*/false, nullptr); @@ -1725,7 +1724,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr ) else { // They don't match, so use a fixed field to prevent LO from altering the contents. - SwDocInfoField aFixedField(pType, DI_CUSTOM | DI_SUB_FIXED | nReg, aDocProperty, + SwDocInfoField aFixedField(pType, SwDocInfoSubType::Custom | SwDocInfoSubType::SubFixed | nReg, aDocProperty, sDisplayed); rIDCO.InsertPoolItem(*m_pPaM, SwFormatField(aFixedField)); } @@ -1738,51 +1737,51 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr ) { case 14: /* supports all INFO variables! */ - nSub = DI_KEYS; + nSub = SwDocInfoSubType::Keys; break; case 15: - nSub = DI_TITLE; + nSub = SwDocInfoSubType::Title; break; case 16: - nSub = DI_SUBJECT; + nSub = SwDocInfoSubType::Subject; break; case 18: - nSub = DI_KEYS; + nSub = SwDocInfoSubType::Keys; break; case 19: - nSub = DI_COMMENT; + nSub = SwDocInfoSubType::Comment; break; case 20: // MS Word never updates this automatically, so mark as fixed for best compatibility - nSub = DI_CHANGE | DI_SUB_FIXED; - nReg = DI_SUB_AUTHOR; + nSub = SwDocInfoSubType::Change | SwDocInfoSubType::SubFixed; + nReg = SwDocInfoSubType::SubAuthor; break; case 21: // The real create date can never change, so mark as fixed for best compatibility - nSub = DI_CREATE | DI_SUB_FIXED; - nReg = DI_SUB_DATE; + nSub = SwDocInfoSubType::Create | SwDocInfoSubType::SubFixed; + nReg = SwDocInfoSubType::SubDate; bDateTime = true; break; case 23: - nSub = DI_PRINT | nFldLock; - nReg = DI_SUB_DATE; + nSub = SwDocInfoSubType::Print | nFldLock; + nReg = SwDocInfoSubType::SubDate; bDateTime = true; break; case 24: - nSub = DI_DOCNO; + nSub = SwDocInfoSubType::DocNo; break; case 22: - nSub = DI_CHANGE | nFldLock; - nReg = DI_SUB_DATE; + nSub = SwDocInfoSubType::Change | nFldLock; + nReg = SwDocInfoSubType::SubDate; bDateTime = true; break; case 25: - nSub = DI_CHANGE | nFldLock; - nReg = DI_SUB_TIME; + nSub = SwDocInfoSubType::Change | nFldLock; + nReg = SwDocInfoSubType::SubTime; bDateTime = true; break; case 64: // DOCVARIABLE - nSub = DI_CUSTOM; + nSub = SwDocInfoSubType::Custom; break; } @@ -1795,16 +1794,16 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr ) switch (nDT) { case SvNumFormatType::DATE: - nReg = DI_SUB_DATE; + nReg = SwDocInfoSubType::SubDate; break; case SvNumFormatType::TIME: - nReg = DI_SUB_TIME; + nReg = SwDocInfoSubType::SubTime; break; case SvNumFormatType::DATETIME: - nReg = DI_SUB_DATE; + nReg = SwDocInfoSubType::SubDate; break; default: - nReg = DI_SUB_DATE; + nReg = SwDocInfoSubType::SubDate; break; } } @@ -1836,7 +1835,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr ) } bool bDone = false; - if (DI_CUSTOM == nSub) + if (SwDocInfoSubType::Custom == nSub) { const auto pType(static_cast<SwUserFieldType*>( m_rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::User, aData, false))); @@ -1867,7 +1866,8 @@ eF_ResT SwWW8ImplReader::Read_F_Author(WW8FieldDesc* pF, OUString&) // SH: The SwAuthorField refers not to the original author but to the current user, better use DocInfo SwDocInfoField aField( static_cast<SwDocInfoFieldType*>( m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::DocInfo )), - DI_CREATE|DI_SUB_AUTHOR|DI_SUB_FIXED, OUString(), GetFieldResult(pF)); + SwDocInfoSubType::Create | SwDocInfoSubType::SubAuthor | SwDocInfoSubType::SubFixed, + OUString(), GetFieldResult(pF)); m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) ); return eF_ResT::OK; } diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx index 00862cf23a0c..7c8e6ab84778 100644 --- a/sw/source/ui/fldui/flddinf.cxx +++ b/sw/source/ui/fldui/flddinf.cxx @@ -41,7 +41,6 @@ #define USER_DATA_VERSION_1 "1" #define USER_DATA_VERSION USER_DATA_VERSION_1 -using namespace nsSwDocInfoSubType; using namespace com::sun::star; void FillFieldSelect(weld::TreeView& rListBox) @@ -130,14 +129,14 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* ) m_xSelEntry.reset(); // display SubTypes in TypeLB - sal_uInt16 nSubType = USHRT_MAX; + SwDocInfoSubType nSubType = SwDocInfoSubType::Max; if (IsFieldEdit()) { const SwField* pCurField = GetCurField(); if (auto const pField = dynamic_cast<SwDocInfoField const*>(pCurField)) { - nSubType = pField->GetSubType() & 0xff; - if( nSubType == DI_CUSTOM ) + nSubType = pField->GetSubType() & SwDocInfoSubType::LowerMask; + if( nSubType == SwDocInfoSubType::Custom ) m_sOldCustomFieldName = pField->GetName(); } m_xFormatLB->SetAutomaticLanguage(pCurField->IsAutomaticLanguage()); @@ -164,10 +163,10 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* ) std::unique_ptr<weld::TreeIter> xExpandEntry; for(size_t i = 0; i < aLst.size(); ++i) { - if (!IsFieldEdit() || nSubType == i) + if (!IsFieldEdit() || static_cast<sal_uInt16>(nSubType) == i) { const OUString sId(OUString::number(i)); - if (DI_CUSTOM == i) + if (static_cast<sal_uInt16>(SwDocInfoSubType::Custom) == i) { if(m_xCustomPropertySet.is() ) { @@ -196,7 +195,10 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* ) } else { - if (!(IsFieldDlgHtmlMode() && (i == DI_EDIT || i == DI_SUBJECT || i == DI_PRINT))) + if (!(IsFieldDlgHtmlMode() + && (i == static_cast<sal_uInt16>(SwDocInfoSubType::Edit) + || i == static_cast<sal_uInt16>(SwDocInfoSubType::Subject) + || i == static_cast<sal_uInt16>(SwDocInfoSubType::Print)))) { m_pTypeView->insert(nullptr, -1, &aLst[i], &sId, nullptr, nullptr, false, xEntry.get()); @@ -216,13 +218,13 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* ) if (m_xSelEntry) { m_pTypeView->select(*m_xSelEntry); - nSubType = m_pTypeView->get_id(*m_xSelEntry).toUInt32(); + nSubType = static_cast<SwDocInfoSubType>(m_pTypeView->get_id(*m_xSelEntry).toUInt32()); } else { m_xSelEntry = m_pTypeView->make_iterator(); if (m_pTypeView->get_iter_first(*m_xSelEntry)) - nSubType = m_pTypeView->get_id(*m_xSelEntry).toUInt32(); + nSubType = static_cast<SwDocInfoSubType>(m_pTypeView->get_id(*m_xSelEntry).toUInt32()); else m_xSelEntry.reset(); } @@ -253,18 +255,18 @@ IMPL_LINK_NOARG(SwFieldDokInfPage, TypeHdl, weld::TreeView&, void) { m_pTypeView->select(*m_xSelEntry); } - FillSelectionLB(m_pTypeView->get_id(*m_xSelEntry).toUInt32()); + FillSelectionLB(static_cast<SwDocInfoSubType>(m_pTypeView->get_id(*m_xSelEntry).toUInt32())); SubTypeHdl(*m_xSelectionLB); } IMPL_LINK_NOARG(SwFieldDokInfPage, SubTypeHdl, weld::TreeView&, void) { - sal_uInt16 nSubType = m_pTypeView->get_id(*m_xSelEntry).toUInt32(); + SwDocInfoSubType nSubType = static_cast<SwDocInfoSubType>(m_pTypeView->get_id(*m_xSelEntry).toUInt32()); sal_Int32 nPos = m_xSelectionLB->get_selected_index(); - sal_uInt16 nExtSubType; + SwDocInfoSubType nExtSubType; SvNumFormatType nNewType = SvNumFormatType::ALL; - if (nSubType != DI_EDIT) + if (nSubType != SwDocInfoSubType::Edit) { if (nPos == -1) { @@ -272,7 +274,7 @@ IMPL_LINK_NOARG(SwFieldDokInfPage, SubTypeHdl, weld::TreeView&, void) { m_xFormatLB->clear(); m_xFormat->set_sensitive(false); - if( nSubType == DI_CUSTOM ) + if( nSubType == SwDocInfoSubType::Custom ) { //find out which type the custom field has - for a start set to DATE format const OUString sName = m_pTypeView->get_text(*m_xSelEntry); @@ -303,10 +305,10 @@ IMPL_LINK_NOARG(SwFieldDokInfPage, SubTypeHdl, weld::TreeView&, void) nPos = 0; } - nExtSubType = m_xSelectionLB->get_id(nPos).toUInt32(); + nExtSubType = static_cast<SwDocInfoSubType>(m_xSelectionLB->get_id(nPos).toUInt32()); } else - nExtSubType = DI_SUB_TIME; + nExtSubType = SwDocInfoSubType::SubTime; SvNumFormatType nOldType = SvNumFormatType::ALL; bool bEnable = false; @@ -317,18 +319,20 @@ IMPL_LINK_NOARG(SwFieldDokInfPage, SubTypeHdl, weld::TreeView&, void) switch (nExtSubType) { - case DI_SUB_AUTHOR: + case SwDocInfoSubType::SubAuthor: break; - case DI_SUB_DATE: + case SwDocInfoSubType::SubDate: nNewType = SvNumFormatType::DATE; bOneArea = true; break; - case DI_SUB_TIME: + case SwDocInfoSubType::SubTime: nNewType = SvNumFormatType::TIME; bOneArea = true; break; + + default: break; } if (nNewType == SvNumFormatType::ALL) { @@ -346,21 +350,21 @@ IMPL_LINK_NOARG(SwFieldDokInfPage, SubTypeHdl, weld::TreeView&, void) sal_uInt32 nFormat = 0; - sal_uInt16 nOldSubType = 0; + SwDocInfoSubType nOldSubType = SwDocInfoSubType::Title; if (IsFieldEdit()) { if (auto const pField = dynamic_cast<SwDocInfoField const*>(GetCurField())) { - nFormat = pField->GetFormat(); - nOldSubType = pField->GetSubType() & 0xff00; + nFormat = static_cast<sal_uInt16>(pField->GetFormat()); + nOldSubType = pField->GetSubType() & SwDocInfoSubType::UpperMask; } nPos = m_xSelectionLB->get_selected_index(); if (nPos != -1) { - nSubType = m_xSelectionLB->get_id(nPos).toUInt32(); + nSubType = static_cast<SwDocInfoSubType>(m_xSelectionLB->get_id(nPos).toUInt32()); - nOldSubType &= ~DI_SUB_FIXED; + nOldSubType &= ~SwDocInfoSubType::SubFixed; if (nOldSubType == nSubType) { if (!nFormat && (nNewType == SvNumFormatType::DATE || nNewType == SvNumFormatType::TIME)) @@ -379,7 +383,7 @@ IMPL_LINK_NOARG(SwFieldDokInfPage, SubTypeHdl, weld::TreeView&, void) m_xFormatLB->SetDefFormat(nFormat); } } - else if( (nSubType == DI_CUSTOM) && (nNewType != SvNumFormatType::ALL) ) + else if( (nSubType == SwDocInfoSubType::Custom) && (nNewType != SvNumFormatType::ALL) ) { m_xFormatLB->SetDefFormat(nFormat); } @@ -394,33 +398,37 @@ IMPL_LINK_NOARG(SwFieldDokInfPage, SubTypeHdl, weld::TreeView&, void) m_xFormatLB->select(0); } -sal_Int32 SwFieldDokInfPage::FillSelectionLB(sal_uInt16 nSubType) +sal_Int32 SwFieldDokInfPage::FillSelectionLB(SwDocInfoSubType nSubType) { // fill Format-Listbox SwFieldTypesEnum nTypeId = SwFieldTypesEnum::DocumentInfo; - EnableInsert(nSubType != USHRT_MAX, IsCurrentPage()); + EnableInsert(nSubType != SwDocInfoSubType::Max, IsCurrentPage()); - if (nSubType == USHRT_MAX) // Info-Text - nSubType = DI_SUBTYPE_BEGIN; + if (nSubType == SwDocInfoSubType::Max) // Info-Text + nSubType = SwDocInfoSubType::SubtypeBegin; m_xSelectionLB->clear(); sal_uInt16 nSize = 0; sal_Int32 nSelPos = -1; - sal_uInt16 nExtSubType = 0; + sal_uInt16 nExtSubIdx = 0; if (IsFieldEdit()) { + SwDocInfoSubType nExtSubType = SwDocInfoSubType::Title; if (auto const pField = dynamic_cast<SwDocInfoField const*>(GetCurField())) { - nExtSubType = pField->GetSubType() & 0xff00; + nExtSubType = pField->GetSubType() & SwDocInfoSubType::UpperMask; } - m_xFixedCB->set_active((nExtSubType & DI_SUB_FIXED) != 0); - nExtSubType = ((nExtSubType & ~DI_SUB_FIXED) >> 8) - 1; + m_xFixedCB->set_active(bool(nExtSubType & SwDocInfoSubType::SubFixed)); + nExtSubIdx = (static_cast<sal_uInt16>(nExtSubType & ~SwDocInfoSubType::SubFixed) >> 8) - 1; } - if (nSubType < DI_CREATE || nSubType == DI_DOCNO || nSubType == DI_EDIT|| nSubType == DI_CUSTOM ) + if (nSubType < SwDocInfoSubType::Create + || nSubType == SwDocInfoSubType::DocNo + || nSubType == SwDocInfoSubType::Edit + || nSubType == SwDocInfoSubType::Custom ) { // Format Box is empty for Title and Time } @@ -431,7 +439,7 @@ sal_Int32 SwFieldDokInfPage::FillSelectionLB(sal_uInt16 nSubType) { OUString sId(OUString::number(GetFieldMgr().GetFormatId(nTypeId, i))); m_xSelectionLB->append(sId, GetFieldMgr().GetFormatStr(nTypeId, i)); - if (IsFieldEdit() && i == nExtSubType) + if (IsFieldEdit() && i == nExtSubIdx) nSelPos = i; } } @@ -455,8 +463,8 @@ bool SwFieldDokInfPage::FillItemSet(SfxItemSet* ) if (!m_xSelEntry) return false; - sal_uInt16 nSubType = m_pTypeView->get_id(*m_xSelEntry).toUInt32(); - if (nSubType == USHRT_MAX) + SwDocInfoSubType nSubType = static_cast<SwDocInfoSubType>(m_pTypeView->get_id(*m_xSelEntry).toUInt32()); + if (nSubType == SwDocInfoSubType::Max) return false; sal_uInt32 nFormat = 0; @@ -464,14 +472,14 @@ bool SwFieldDokInfPage::FillItemSet(SfxItemSet* ) sal_Int32 nPos = m_xSelectionLB->get_selected_index(); OUString aName; - if (DI_CUSTOM == nSubType) + if (SwDocInfoSubType::Custom == nSubType) aName = m_pTypeView->get_text(*m_xSelEntry); if (nPos != -1) - nSubType |= m_xSelectionLB->get_id(nPos).toUInt32(); + nSubType |= static_cast<SwDocInfoSubType>(m_xSelectionLB->get_id(nPos).toUInt32()); if (m_xFixedCB->get_active()) - nSubType |= DI_SUB_FIXED; + nSubType |= SwDocInfoSubType::SubFixed; nPos = m_xFormatLB->get_selected_index(); if(nPos != -1) @@ -479,9 +487,9 @@ bool SwFieldDokInfPage::FillItemSet(SfxItemSet* ) if (!IsFieldEdit() || m_nOldSel != m_xSelectionLB->get_selected_index() || m_nOldFormat != nFormat || m_xFixedCB->get_state_changed_from_saved() - || (DI_CUSTOM == nSubType && aName != m_sOldCustomFieldName )) + || (SwDocInfoSubType::Custom == nSubType && aName != m_sOldCustomFieldName )) { - InsertField(SwFieldTypesEnum::DocumentInfo, nSubType, aName, OUString(), nFormat, + InsertField(SwFieldTypesEnum::DocumentInfo, static_cast<sal_uInt16>(nSubType), aName, OUString(), nFormat, ' ', m_xFormatLB->IsAutomaticLanguage()); } diff --git a/sw/source/ui/fldui/flddinf.hxx b/sw/source/ui/fldui/flddinf.hxx index c3773af163b9..38b5c1f80569 100644 --- a/sw/source/ui/fldui/flddinf.hxx +++ b/sw/source/ui/fldui/flddinf.hxx @@ -24,6 +24,7 @@ #include "fldpage.hxx" namespace com::sun::star::beans { class XPropertySet; } +enum class SwDocInfoSubType : sal_uInt16; class SwFieldDokInfPage : public SwFieldPage { @@ -46,7 +47,7 @@ class SwFieldDokInfPage : public SwFieldPage DECL_LINK(TypeHdl, weld::TreeView&, void); DECL_LINK(SubTypeHdl, weld::TreeView&, void); - sal_Int32 FillSelectionLB(sal_uInt16 nSubTypeId); + sal_Int32 FillSelectionLB(SwDocInfoSubType nSubTypeId); protected: virtual sal_uInt16 GetGroup() override; diff --git a/sw/source/ui/fldui/fldedt.cxx b/sw/source/ui/fldui/fldedt.cxx index c38561e64e4c..6c44739af3f4 100644 --- a/sw/source/ui/fldui/fldedt.cxx +++ b/sw/source/ui/fldui/fldedt.cxx @@ -158,11 +158,9 @@ void SwFieldEditDlg::Init() rMgr.GoNext(); m_xPrevBT->set_sensitive( bMove ); { - using namespace nsSwDocInfoSubType; - const SwFieldTypesEnum aId(pCurField->GetTypeId()); if ( (aId == SwFieldTypesEnum::Author) || - ((aId == SwFieldTypesEnum::DocumentInfo) && (static_cast<const SwDocInfoField*>(pCurField)->GetSubType() != (DI_CREATE|DI_SUB_AUTHOR)))) // except DocumentInfo > Author + ((aId == SwFieldTypesEnum::DocumentInfo) && (static_cast<const SwDocInfoField*>(pCurField)->GetSubType() != (SwDocInfoSubType::Create | SwDocInfoSubType::SubAuthor)))) // except DocumentInfo > Author m_xAddressBT->set_visible(true); else m_xAddressBT->set_visible(false); diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx index 762b3de89636..bd17a35ac69b 100644 --- a/sw/source/ui/fldui/fldpage.cxx +++ b/sw/source/ui/fldui/fldpage.cxx @@ -244,7 +244,7 @@ void SwFieldPage::InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, con break; case SwFieldTypesEnum::DocumentInfo: { - if( nSubType == nsSwDocInfoSubType::DI_CUSTOM ) + if( nSubType == static_cast<sal_uInt16>(SwDocInfoSubType::Custom) ) { SwDocInfoField* pDocInfo = static_cast<SwDocInfoField*>( pTmpField.get() ); pDocInfo->SetName( rPar1 ); diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 65a61a47d6b9..0faff4c545ec 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -89,7 +89,6 @@ using namespace com::sun::star::text; using namespace com::sun::star::style; using namespace com::sun::star::sdbc; using namespace ::com::sun::star; -using namespace nsSwDocInfoSubType; // groups of fields enum @@ -639,7 +638,7 @@ void SwFieldMgr::GetSubTypes(SwFieldTypesEnum nTypeId, std::vector<OUString>& rT { sal_uInt16 nCount; if (nTypeId == SwFieldTypesEnum::DocumentInfo) - nCount = DI_SUBTYPE_END - DI_SUBTYPE_BEGIN; + nCount = static_cast<sal_uInt16>(SwDocInfoSubType::SubtypeEnd) - static_cast<sal_uInt16>(SwDocInfoSubType::SubtypeBegin); else nCount = aSwFields[nPos].nSubTypeLength; @@ -648,7 +647,7 @@ void SwFieldMgr::GetSubTypes(SwFieldTypesEnum nTypeId, std::vector<OUString>& rT OUString sNew; if (nTypeId == SwFieldTypesEnum::DocumentInfo) { - if ( i == DI_CUSTOM ) + if ( i == static_cast<sal_uInt16>(SwDocInfoSubType::Custom) ) sNew = SwResId(STR_CUSTOM_FIELD); else sNew = SwViewShell::GetShellRes()->aDocInfoLst[i]; @@ -777,11 +776,11 @@ sal_uInt16 SwFieldMgr::GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatI { TranslateId sId = aSwFields[GetPos(nTypeId)].pFormatResIds[nFormatId]; if (sId == FMT_REG_AUTHOR) - nId = DI_SUB_AUTHOR; + nId = static_cast<sal_uInt16>(SwDocInfoSubType::SubAuthor); else if (sId == FMT_REG_TIME) - nId = DI_SUB_TIME; + nId = static_cast<sal_uInt16>(SwDocInfoSubType::SubTime); else if (sId == FMT_REG_DATE) - nId = DI_SUB_DATE; + nId = static_cast<sal_uInt16>(SwDocInfoSubType::SubDate); break; } case SwFieldTypesEnum::PageNumber: @@ -1206,7 +1205,7 @@ bool SwFieldMgr::InsertField( { SwDocInfoFieldType* pTyp = static_cast<SwDocInfoFieldType*>( pCurShell->GetFieldType( 0, SwFieldIds::DocInfo ) ); - pField.reset(new SwDocInfoField(pTyp, nSubType, rData.m_sPar1, nFormatId)); + pField.reset(new SwDocInfoField(pTyp, static_cast<SwDocInfoSubType>(nSubType), rData.m_sPar1, nFormatId)); break; } diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index 5fcdf7cfc165..6dd740a18ad9 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -83,8 +83,6 @@ #include <sfx2/dispatch.hxx> -using namespace nsSwDocInfoSubType; - static OUString lcl_BuildTitleWithRedline( const SwRangeRedline *pRedline ) { const OUString sTitle(SwResId(STR_REDLINE_COMMENT)); @@ -814,15 +812,15 @@ void SwTextShell::ExecField(SfxRequest &rReq) goto FIELD_INSERT; case FN_INSERT_FLD_TOPIC : nInsertType = SwFieldTypesEnum::DocumentInfo; - nInsertSubType = DI_SUBJECT; + nInsertSubType = static_cast<sal_uInt16>(SwDocInfoSubType::Subject); goto FIELD_INSERT; case FN_INSERT_FLD_TITLE : nInsertType = SwFieldTypesEnum::DocumentInfo; - nInsertSubType = DI_TITLE; + nInsertSubType = static_cast<sal_uInt16>(SwDocInfoSubType::Title); goto FIELD_INSERT; case FN_INSERT_FLD_AUTHOR : nInsertType = SwFieldTypesEnum::DocumentInfo; - nInsertSubType = DI_CREATE|DI_SUB_AUTHOR; + nInsertSubType = static_cast<sal_uInt16>(SwDocInfoSubType::Create | SwDocInfoSubType::SubAuthor); FIELD_INSERT: { commit fc4b6d64773482c7009524fc9f678beb8653f806 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Jul 5 16:55:51 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Tue Jul 8 08:12:54 2025 +0200 Convert SwDocStatSubType to scoped enum Change-Id: I281b39e9f37ae4024a67a3f521f0c84903b2ef27 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187500 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index 5506ee45e0cd..8690a49d5581 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -52,18 +52,17 @@ enum class SwAuthorFormat : sal_uInt32 namespace o3tl { template<> struct typed_flags<SwAuthorFormat> : is_typed_flags<SwAuthorFormat, 0x8003> {}; } // Subtype of document statistics. -enum SwDocStatSubType +enum class SwDocStatSubType : sal_uInt16 { - DS_BEGIN, - DS_PAGE = DS_BEGIN, + Page, // page count in current section - DS_PAGE_RANGE, - DS_PARA, - DS_WORD, - DS_CHAR, - DS_TBL, - DS_GRF, - DS_OLE + PageRange, + Paragraph, + Word, + Character, + Table, + Graphic, + OLE }; typedef sal_uInt16 SwDocInfoSubType; @@ -278,7 +277,7 @@ class SAL_DLLPUBLIC_RTTI SwDocStatFieldType final : public SwFieldType public: SwDocStatFieldType(SwDoc&); - OUString Expand(sal_uInt16 nSubType, SvxNumType nFormat, + OUString Expand(SwDocStatSubType nSubType, SvxNumType nFormat, sal_uInt16 nVirtPageCount) const; virtual std::unique_ptr<SwFieldType> Copy() const override; @@ -288,12 +287,12 @@ public: class SW_DLLPUBLIC SwDocStatField final : public SwField { - sal_uInt16 m_nSubType; + SwDocStatSubType m_nSubType; sal_uInt16 m_nVirtPageCount; SvxNumType m_nFormat; public: SwDocStatField( SwDocStatFieldType*, - sal_uInt16 nSubType, SvxNumType nFormat, sal_uInt16 nVirtPageCount = 0); + SwDocStatSubType nSubType, SvxNumType nFormat, sal_uInt16 nVirtPageCount = 0); SvxNumType GetFormat() const { return m_nFormat; } void SetFormat(SvxNumType n) { m_nFormat = n; } @@ -303,8 +302,8 @@ public: virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; virtual std::unique_ptr<SwField> Copy() const override; - sal_uInt16 GetSubType() const; - void SetSubType(sal_uInt16 nSub); + SwDocStatSubType GetSubType() const; + void SetSubType(SwDocStatSubType nSub); virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; }; diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 97374ab8f562..5175f6f7222d 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -1023,7 +1023,7 @@ OUString SwAccessibleParagraph::GetFieldTypeNameAtIndex(sal_Int32 nIndex) switch (nWhich) { case SwFieldIds::DocStat: - subType = static_cast<const SwDocStatField*>(pField)->GetSubType(); + subType = static_cast<sal_uInt16>(static_cast<const SwDocStatField*>(pField)->GetSubType()); break; case SwFieldIds::GetRef: { diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 873702dcc60a..e580248c498b 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -746,27 +746,27 @@ SwDocStatFieldType::SwDocStatFieldType(SwDoc& rDocument) { } -OUString SwDocStatFieldType::Expand(sal_uInt16 nSubType, +OUString SwDocStatFieldType::Expand(SwDocStatSubType nSubType, SvxNumType nFormat, sal_uInt16 nVirtPageCount) const { sal_uInt32 nVal = 0; const SwDocStat& rDStat = m_rDoc.getIDocumentStatistics().GetDocStat(); switch( nSubType ) { - case DS_TBL: nVal = rDStat.nTable; break; - case DS_GRF: nVal = rDStat.nGrf; break; - case DS_OLE: nVal = rDStat.nOLE; break; - case DS_PARA: nVal = rDStat.nPara; break; - case DS_WORD: nVal = rDStat.nWord; break; - case DS_CHAR: nVal = rDStat.nChar; break; - case DS_PAGE: + case SwDocStatSubType::Table: nVal = rDStat.nTable; break; + case SwDocStatSubType::Graphic: nVal = rDStat.nGrf; break; + case SwDocStatSubType::OLE: nVal = rDStat.nOLE; break; + case SwDocStatSubType::Paragraph: nVal = rDStat.nPara; break; + case SwDocStatSubType::Word: nVal = rDStat.nWord; break; + case SwDocStatSubType::Character: nVal = rDStat.nChar; break; + case SwDocStatSubType::Page: if( m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout() ) const_cast<SwDocStat &>(rDStat).nPage = m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout()->GetPageNum(); nVal = rDStat.nPage; if( SVX_NUM_PAGEDESC == nFormat ) nFormat = m_nNumberingType; break; - case DS_PAGE_RANGE: + case SwDocStatSubType::PageRange: nVal = nVirtPageCount; if( SVX_NUM_PAGEDESC == nFormat ) nFormat = m_nNumberingType; @@ -792,7 +792,7 @@ void SwDocStatFieldType::UpdateRangeFields(SwRootFrame const*const pLayout) for(auto pFormatField: vFields) { SwDocStatField* pDocStatField = static_cast<SwDocStatField*>(pFormatField->GetField()); - if (pDocStatField->GetSubType() == DS_PAGE_RANGE) + if (pDocStatField->GetSubType() == SwDocStatSubType::PageRange) { SwTextField* pTField = pFormatField->GetTextField(); const SwTextNode& rTextNd = pTField->GetTextNode(); @@ -817,7 +817,7 @@ void SwDocStatFieldType::UpdateRangeFields(SwRootFrame const*const pLayout) * @param nSub SubType * @param nFormat */ -SwDocStatField::SwDocStatField(SwDocStatFieldType* pTyp, sal_uInt16 nSub, +SwDocStatField::SwDocStatField(SwDocStatFieldType* pTyp, SwDocStatSubType nSub, SvxNumType nFormat, sal_uInt16 nVirtPageCount) : SwField(pTyp), m_nSubType(nSub), @@ -838,22 +838,22 @@ std::unique_ptr<SwField> SwDocStatField::Copy() const static_cast<SwDocStatFieldType*>(GetTyp()), m_nSubType, m_nFormat, m_nVirtPageCount ); } -sal_uInt16 SwDocStatField::GetSubType() const +SwDocStatSubType SwDocStatField::GetSubType() const { return m_nSubType; } -void SwDocStatField::SetSubType(sal_uInt16 nSub) +void SwDocStatField::SetSubType(SwDocStatSubType nSub) { m_nSubType = nSub; } void SwDocStatField::ChangeExpansion(const SwFrame* pFrame, sal_uInt16 nVirtPageCount) { - if( DS_PAGE == m_nSubType && SVX_NUM_PAGEDESC == m_nFormat ) + if( SwDocStatSubType::Page == m_nSubType && SVX_NUM_PAGEDESC == m_nFormat ) static_cast<SwDocStatFieldType*>(GetTyp())->SetNumFormat( pFrame->FindPageFrame()->GetPageDesc()->GetNumType().GetNumberingType() ); - else if (nVirtPageCount && DS_PAGE_RANGE == m_nSubType) + else if (nVirtPageCount && SwDocStatSubType::PageRange == m_nSubType) m_nVirtPageCount = nVirtPageCount; } diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index c98f95886d18..97a748b773b9 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -472,7 +472,7 @@ sal_uInt16 SwField::GetUntypedSubType() const case SwFieldIds::HiddenText: return static_cast<sal_uInt16>(static_cast<const SwHiddenTextField*>(this)->GetSubType()); case SwFieldIds::DocStat: - return static_cast<const SwDocStatField*>(this)->GetSubType(); + return static_cast<sal_uInt16>(static_cast<const SwDocStatField*>(this)->GetSubType()); case SwFieldIds::PageNumber: return static_cast<const SwPageNumberField*>(this)->GetSubType(); case SwFieldIds::DbNextSet: @@ -522,7 +522,7 @@ void SwField::SetUntypedSubType(sal_uInt16 n) static_cast<SwHiddenTextField*>(this)->SetSubType(static_cast<SwFieldTypesEnum>(n)); break; case SwFieldIds::DocStat: - static_cast<SwDocStatField*>(this)->SetSubType(n); + static_cast<SwDocStatField*>(this)->SetSubType(static_cast<SwDocStatSubType>(n)); break; case SwFieldIds::PageNumber: static_cast<SwPageNumberField*>(this)->SetSubType(n); diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index c21b7436e23d..9f2276640ebd 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -119,7 +119,7 @@ SwExpandPortion *SwTextFormatter::NewFieldPortion( SwTextFormatInfo &rInf, { SwDocStatField* pDocStatField = static_cast<SwDocStatField*>(pField); sal_uInt16 nVirtPageCount = 0; - if (pDocStatField->GetSubType() == SwDocStatSubType::DS_PAGE_RANGE) + if (pDocStatField->GetSubType() == SwDocStatSubType::PageRange) nVirtPageCount = m_pFrame->GetVirtPageCount(); pDocStatField->ChangeExpansion(m_pFrame, nVirtPageCount); } diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index a30655086c36..41424ccd36f8 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -613,7 +613,7 @@ void SwTextField::ExpandTextField(const bool bForceNotify) const // Page count fields to not use aExpand during formatting, // therefore an invalidation of the text frame has to be triggered even if aNewExpand == aExpand: && (SwFieldIds::DocStat != nWhich - || DS_PAGE != static_cast<const SwDocStatField*>(pField)->GetSubType()) + || SwDocStatSubType::Page != static_cast<const SwDocStatField*>(pField)->GetSubType()) && (SwFieldIds::GetExp != nWhich || static_cast<const SwGetExpField*>(pField)->IsInBodyText()); diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 32eb20768768..7433847565b4 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -255,14 +255,14 @@ static SwServiceType lcl_GetServiceForField( const SwField& rField ) auto rDocStatField = static_cast<const SwDocStatField&>(rField); switch( rDocStatField.GetSubType() ) { - case DS_PAGE_RANGE:nSrvId = SwServiceType::FieldTypePageCountRange; break; - case DS_PAGE: nSrvId = SwServiceType::FieldTypePageCount; break; - case DS_PARA: nSrvId = SwServiceType::FieldTypeParagraphCount; break; - case DS_WORD: nSrvId = SwServiceType::FieldTypeWordCount ; break; - case DS_CHAR: nSrvId = SwServiceType::FieldTypeCharacterCount; break; - case DS_TBL: nSrvId = SwServiceType::FieldTypeTableCount ; break; - case DS_GRF: nSrvId = SwServiceType::FieldTypeGraphicObjectCount; break; - case DS_OLE: nSrvId = SwServiceType::FieldTypeEmbeddedObjectCount; break; + case SwDocStatSubType::PageRange:nSrvId = SwServiceType::FieldTypePageCountRange; break; + case SwDocStatSubType::Page: nSrvId = SwServiceType::FieldTypePageCount; break; + case SwDocStatSubType::Paragraph: nSrvId = SwServiceType::FieldTypeParagraphCount; break; + case SwDocStatSubType::Word: nSrvId = SwServiceType::FieldTypeWordCount ; break; + case SwDocStatSubType::Character: nSrvId = SwServiceType::FieldTypeCharacterCount; break; + case SwDocStatSubType::Table: nSrvId = SwServiceType::FieldTypeTableCount ; break; + case SwDocStatSubType::Graphic: nSrvId = SwServiceType::FieldTypeGraphicObjectCount; break; + case SwDocStatSubType::OLE: nSrvId = SwServiceType::FieldTypeEmbeddedObjectCount; break; } } break; @@ -1880,16 +1880,16 @@ void SAL_CALL SwXTextField::attach( case SwServiceType::FieldTypeGraphicObjectCount: case SwServiceType::FieldTypeEmbeddedObjectCount: { - sal_uInt16 nSubType = DS_PAGE; + SwDocStatSubType nSubType = SwDocStatSubType::Page; switch (m_pImpl->m_nServiceId) { - case SwServiceType::FieldTypeParagraphCount : nSubType = DS_PARA; break; - case SwServiceType::FieldTypeWordCount : nSubType = DS_WORD; break; - case SwServiceType::FieldTypeCharacterCount : nSubType = DS_CHAR; break; - case SwServiceType::FieldTypeTableCount : nSubType = DS_TBL; break; - case SwServiceType::FieldTypeGraphicObjectCount : nSubType = DS_GRF; break; - case SwServiceType::FieldTypeEmbeddedObjectCount : nSubType = DS_OLE; break; - case SwServiceType::FieldTypePageCountRange : nSubType = DS_PAGE_RANGE; break; + case SwServiceType::FieldTypeParagraphCount : nSubType = SwDocStatSubType::Paragraph; break; + case SwServiceType::FieldTypeWordCount : nSubType = SwDocStatSubType::Word; break; + case SwServiceType::FieldTypeCharacterCount : nSubType = SwDocStatSubType::Character; break; + case SwServiceType::FieldTypeTableCount : nSubType = SwDocStatSubType::Table; break; + case SwServiceType::FieldTypeGraphicObjectCount : nSubType = SwDocStatSubType::Graphic; break; + case SwServiceType::FieldTypeEmbeddedObjectCount : nSubType = SwDocStatSubType::OLE; break; + case SwServiceType::FieldTypePageCountRange : nSubType = SwDocStatSubType::PageRange; break; default: break; } SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocStat); diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx index 343b9694dfc5..984240f78425 100644 --- a/sw/source/filter/html/htmlfld.cxx +++ b/sw/source/filter/html/htmlfld.cxx @@ -178,13 +178,13 @@ HTMLOptionEnum<sal_uInt16> const aHTMLDocInfoFieldFormatTable[] = HTMLOptionEnum<SwDocStatSubType> const aHTMLDocStatFieldSubTable[] = { - { OOO_STRING_SW_HTML_FS_page, DS_PAGE }, - { OOO_STRING_SW_HTML_FS_para, DS_PARA }, - { OOO_STRING_SW_HTML_FS_word, DS_WORD }, - { OOO_STRING_SW_HTML_FS_char, DS_CHAR }, - { OOO_STRING_SW_HTML_FS_tbl, DS_TBL }, - { OOO_STRING_SW_HTML_FS_grf, DS_GRF }, - { OOO_STRING_SW_HTML_FS_ole, DS_OLE }, + { OOO_STRING_SW_HTML_FS_page, SwDocStatSubType::Page }, + { OOO_STRING_SW_HTML_FS_para, SwDocStatSubType::Paragraph }, + { OOO_STRING_SW_HTML_FS_word, SwDocStatSubType::Word }, + { OOO_STRING_SW_HTML_FS_char, SwDocStatSubType::Character }, + { OOO_STRING_SW_HTML_FS_tbl, SwDocStatSubType::Table }, + { OOO_STRING_SW_HTML_FS_grf, SwDocStatSubType::Graphic }, + { OOO_STRING_SW_HTML_FS_ole, SwDocStatSubType::OLE }, { nullptr, SwDocStatSubType(0) } }; @@ -498,7 +498,7 @@ void SwHTMLParser::NewField() if( pFormatOption ) pFormatOption->GetEnum( nFormat, aHTMLPageNumFieldFormatTable ); xNewField.reset(new SwDocStatField(static_cast<SwDocStatFieldType*>(pType), nSub, nFormat)); - m_bUpdateDocStat |= (DS_PAGE != nSub); + m_bUpdateDocStat |= (SwDocStatSubType::Page != nSub); } } break; diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx index 3e151c1ca79b..b6aa316c786a 100644 --- a/sw/source/filter/html/htmlfldw.cxx +++ b/sw/source/filter/html/htmlfldw.cxx @@ -237,16 +237,16 @@ static SwHTMLWriter& OutHTML_SwField( SwHTMLWriter& rWrt, const SwField* pField, { auto pDocStatField = static_cast<const SwDocStatField*>(pField); pTypeStr = OOO_STRING_SW_HTML_FT_docstat; - sal_uInt16 nSubType = pDocStatField->GetSubType(); + SwDocStatSubType nSubType = pDocStatField->GetSubType(); switch( nSubType ) { - case DS_PAGE: pSubStr = OOO_STRING_SW_HTML_FS_page; break; - case DS_PARA: pSubStr = OOO_STRING_SW_HTML_FS_para; break; - case DS_WORD: pSubStr = OOO_STRING_SW_HTML_FS_word; break; - case DS_CHAR: pSubStr = OOO_STRING_SW_HTML_FS_char; break; - case DS_TBL: pSubStr = OOO_STRING_SW_HTML_FS_tbl; break; - case DS_GRF: pSubStr = OOO_STRING_SW_HTML_FS_grf; break; - case DS_OLE: pSubStr = OOO_STRING_SW_HTML_FS_ole; break; + case SwDocStatSubType::Page: pSubStr = OOO_STRING_SW_HTML_FS_page; break; + case SwDocStatSubType::Paragraph: pSubStr = OOO_STRING_SW_HTML_FS_para; break; + case SwDocStatSubType::Word: pSubStr = OOO_STRING_SW_HTML_FS_word; break; + case SwDocStatSubType::Character: pSubStr = OOO_STRING_SW_HTML_FS_char; break; + case SwDocStatSubType::Table: pSubStr = OOO_STRING_SW_HTML_FS_tbl; break; + case SwDocStatSubType::Graphic: pSubStr = OOO_STRING_SW_HTML_FS_grf; break; + case SwDocStatSubType::OLE: pSubStr = OOO_STRING_SW_HTML_FS_ole; break; default: pTypeStr = nullptr; break; } pFormatStr = SwHTMLWriter::GetNumFormat( static_cast< sal_uInt16 >(pDocStatField->GetFormat()) ); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index fbfeb01e861e..4e630a7d8168 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -3144,20 +3144,21 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) case SwFieldIds::DocStat: { auto pDocStatField = static_cast<const SwDocStatField*>(pField); - const sal_uInt16 nSubType = pDocStatField->GetSubType(); + const SwDocStatSubType nSubType = pDocStatField->GetSubType(); ww::eField eField = ww::eNONE; switch (nSubType) { - case DS_PAGE: + case SwDocStatSubType::Page: eField = ww::eNUMPAGES; break; - case DS_WORD: + case SwDocStatSubType::Word: eField = ww::eNUMWORDS; break; - case DS_CHAR: + case SwDocStatSubType::Character: eField = ww::eNUMCHARS; break; + default: break; } if (eField != ww::eNONE) diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 25f991022bb6..fb508de09d6e 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -1981,10 +1981,10 @@ eF_ResT SwWW8ImplReader::Read_F_FileName(WW8FieldDesc*, OUString &rStr) eF_ResT SwWW8ImplReader::Read_F_Num( WW8FieldDesc* pF, OUString& rStr ) { - sal_uInt16 nSub = DS_PAGE; // page number + SwDocStatSubType nSub = SwDocStatSubType::Page; // page number switch ( pF->nId ){ - case 27: nSub = DS_WORD; break; // number of words - case 28: nSub = DS_CHAR; break; // number of characters + case 27: nSub = SwDocStatSubType::Word; break; // number of words + case 28: nSub = SwDocStatSubType::Character; break; // number of characters } SwDocStatField aField( static_cast<SwDocStatFieldType*>( m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::DocStat )), nSub, diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx index 8487e03d3362..71a608634001 100644 --- a/sw/source/ui/fldui/flddok.cxx +++ b/sw/source/ui/fldui/flddok.cxx @@ -256,7 +256,7 @@ IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView&, void) break; case SwFieldTypesEnum::DocumentStatistics: m_xSelectionLB->append(sId, aLst[i]); - if (static_cast<const SwDocStatField*>(GetCurField())->GetSubType() == i) + if (static_cast<sal_uInt16>(static_cast<const SwDocStatField*>(GetCurField())->GetSubType()) == i) m_xSelectionLB->select_id(sId); break; diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 49358acbfae7..65a61a47d6b9 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -1044,7 +1044,7 @@ bool SwFieldMgr::InsertField( { SwDocStatFieldType* pTyp = static_cast<SwDocStatFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DocStat) ); - pField.reset(new SwDocStatField(pTyp, nSubType, static_cast<SvxNumType>(nFormatId))); + pField.reset(new SwDocStatField(pTyp, static_cast<SwDocStatSubType>(nSubType), static_cast<SvxNumType>(nFormatId))); break; } diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index a394f2195083..5fcdf7cfc165 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -1423,7 +1423,7 @@ FIELD_INSERT: { rDoc.getIDocumentContentOperations().InsertString(*rSh.GetCursor(), u" / "_ustr); SwInsertField_Data aPageTotalData(SwFieldTypesEnum::DocumentStatistics, - pDlg->GetIncludePageTotal() ? DS_PAGE : DS_PAGE_RANGE, + static_cast<sal_uInt16>(pDlg->GetIncludePageTotal() ? SwDocStatSubType::Page : SwDocStatSubType::PageRange), OUString(), OUString(), SVX_NUM_PAGEDESC); aMgr.InsertField(aPageTotalData); } @@ -1477,7 +1477,7 @@ FIELD_INSERT: { rDoc.getIDocumentContentOperations().InsertString(*rSh.GetCursor(), u" / "_ustr); SwInsertField_Data aPageTotalData(SwFieldTypesEnum::DocumentStatistics, - DS_PAGE, OUString(), OUString(), + static_cast<sal_uInt16>(SwDocStatSubType::Page), OUString(), OUString(), SVX_NUM_PAGEDESC); aMgr.InsertField(aPageTotalData); } diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index c473faf56fcd..cc770a5a2531 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -781,7 +781,7 @@ void SwContentType::FillMemberList(bool* pbContentChanged) SwFieldMgr(m_pWrtShell).GetSubTypes(SwFieldTypesEnum::DocumentStatistics, aDocumentStatisticsSubTypesList); OUString sSubType; - sal_uInt16 nSubStype = static_cast<const SwDocStatField*>(pField)->GetSubType(); + sal_uInt16 nSubStype = static_cast<sal_uInt16>(static_cast<const SwDocStatField*>(pField)->GetSubType()); if (nSubStype < aDocumentStatisticsSubTypesList.size()) sSubType = u" - " + aDocumentStatisticsSubTypesList[nSubStype]; sText = pField->GetDescription() + u" - " + pField->GetFieldName() + sSubType +