diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-29 13:03:39 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-30 06:22:16 +0000 |
commit | 3c1b1fb937c261987a430593ed525df78fa5ce07 (patch) | |
tree | d3ca5c69f17c8769124dc98edee23d44ab3faf12 /sw | |
parent | 4307a850a310c0371bee1f79a8eb41fa8ff7fed2 (diff) |
convert SwTOOElements to o3tl::typed_flags
Change-Id: Ic0636c8f641cf70e0372b31f8a8d111b45ba6070
Reviewed-on: https://gerrit.libreoffice.org/31357
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/tox.hxx | 27 | ||||
-rw-r--r-- | sw/source/core/doc/doctxm.cxx | 38 | ||||
-rw-r--r-- | sw/source/core/tox/tox.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unoidx.cxx | 24 | ||||
-rw-r--r-- | sw/source/ui/index/cntex.cxx | 12 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.cxx | 12 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.src | 10 | ||||
-rw-r--r-- | sw/source/uibase/inc/toxmgr.hxx | 8 |
8 files changed, 66 insertions, 67 deletions
diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx index 27e84de490f6..d612d0d400ea 100644 --- a/sw/inc/tox.hxx +++ b/sw/inc/tox.hxx @@ -372,14 +372,17 @@ enum SwCaptionDisplay CAPTION_TEXT }; -typedef sal_uInt16 SwTOOElements; -namespace nsSwTOOElements -{ - const SwTOOElements TOO_MATH = 0x01; - const SwTOOElements TOO_CHART = 0x02; - const SwTOOElements TOO_CALC = 0x08; - const SwTOOElements TOO_DRAW_IMPRESS = 0x10; - const SwTOOElements TOO_OTHER = 0x80; +enum class SwTOOElements : sal_uInt16 +{ + NONE = 0x00, + Math = 0x01, + Chart = 0x02, + Calc = 0x08, + DrawImpress = 0x10, + Other = 0x80, +}; +namespace o3tl { + template<> struct typed_flags<SwTOOElements> : is_typed_flags<SwTOOElements, 0x9b> {}; } #define TOX_STYLE_DELIMITER ((sal_Unicode)0x01) @@ -406,8 +409,8 @@ class SW_DLLPUBLIC SwTOXBase : public SwClient SwTOIOptions nOptions; // options of alphabetical index } m_aData; - SwTOXElement m_nCreateType; // sources to create the index from - sal_uInt16 m_nOLEOptions; // OLE sources + SwTOXElement m_nCreateType; // sources to create the index from + SwTOOElements m_nOLEOptions; // OLE sources SwCaptionDisplay m_eCaptionDisplay; bool m_bProtected : 1; // index protected ? bool m_bFromChapter : 1; // create from chapter or document @@ -474,8 +477,8 @@ public: inline void SetOptions(SwTOIOptions nOpt); // index of objects - sal_uInt16 GetOLEOptions() const {return m_nOLEOptions;} - void SetOLEOptions(sal_uInt16 nOpt) {m_nOLEOptions = nOpt;} + SwTOOElements GetOLEOptions() const {return m_nOLEOptions;} + void SetOLEOptions(SwTOOElements nOpt) {m_nOLEOptions = nOpt;} // index of objects diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 75f11686946a..4b7418e08e4e 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -1329,10 +1329,10 @@ void SwTOXBaseSection::UpdateAuthorities( const SwTOXInternational& rIntl ) } } -static long lcl_IsSOObject( const SvGlobalName& rFactoryNm ) +static SwTOOElements lcl_IsSOObject( const SvGlobalName& rFactoryNm ) { - static struct SoObjType { - long nFlag; + static const struct SoObjType { + SwTOOElements nFlag; // GlobalNameId struct GlobalNameIds { sal_uInt32 n1; @@ -1340,27 +1340,24 @@ static long lcl_IsSOObject( const SvGlobalName& rFactoryNm ) sal_uInt8 b8, b9, b10, b11, b12, b13, b14, b15; } aGlNmIds[4]; } aArr[] = { - { nsSwTOOElements::TOO_MATH, + { SwTOOElements::Math, { {SO3_SM_CLASSID_60},{SO3_SM_CLASSID_50}, {SO3_SM_CLASSID_40},{SO3_SM_CLASSID_30} } }, - { nsSwTOOElements::TOO_CHART, + { SwTOOElements::Chart, { {SO3_SCH_CLASSID_60},{SO3_SCH_CLASSID_50}, {SO3_SCH_CLASSID_40},{SO3_SCH_CLASSID_30} } }, - { nsSwTOOElements::TOO_CALC, + { SwTOOElements::Calc, { {SO3_SC_CLASSID_60},{SO3_SC_CLASSID_50}, {SO3_SC_CLASSID_40},{SO3_SC_CLASSID_30} } }, - { nsSwTOOElements::TOO_DRAW_IMPRESS, + { SwTOOElements::DrawImpress, { {SO3_SIMPRESS_CLASSID_60},{SO3_SIMPRESS_CLASSID_50}, {SO3_SIMPRESS_CLASSID_40},{SO3_SIMPRESS_CLASSID_30} } }, - { nsSwTOOElements::TOO_DRAW_IMPRESS, - { {SO3_SDRAW_CLASSID_60},{SO3_SDRAW_CLASSID_50}}}, - { 0,{{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0} } } + { SwTOOElements::DrawImpress, + { {SO3_SDRAW_CLASSID_60},{SO3_SDRAW_CLASSID_50} } } }; - long nRet = 0; - for( const SoObjType* pArr = aArr; !nRet && pArr->nFlag; ++pArr ) - for (auto & rId : pArr->aGlNmIds) + for( SoObjType const & rArr : aArr ) + for (auto & rId : rArr.aGlNmIds) { if( !rId.n1 ) break; @@ -1369,12 +1366,11 @@ static long lcl_IsSOObject( const SvGlobalName& rFactoryNm ) rId.b12, rId.b13, rId.b14, rId.b15 ); if( rFactoryNm == aGlbNm ) { - nRet = pArr->nFlag; - break; + return rArr.nFlag; } } - return nRet; + return SwTOOElements::NONE; } void SwTOXBaseSection::UpdateContent( SwTOXElement eMyType, @@ -1416,15 +1412,15 @@ void SwTOXBaseSection::UpdateContent( SwTOXElement eMyType, if(TOX_OBJECTS == SwTOXBase::GetType()) { SwOLENode* pOLENode = pNd->GetOLENode(); - long nMyOLEOptions = GetOLEOptions(); + SwTOOElements nMyOLEOptions = GetOLEOptions(); SwOLEObj& rOLEObj = pOLENode->GetOLEObj(); if( rOLEObj.IsOleRef() ) // Not yet loaded { SvGlobalName aTmpName = SvGlobalName( rOLEObj.GetOleRef()->getClassID() ); - long nObj = ::lcl_IsSOObject( aTmpName ); - bInclude = ( (nMyOLEOptions & nsSwTOOElements::TOO_OTHER) && 0 == nObj) - || (0 != (nMyOLEOptions & nObj)); + SwTOOElements nObj = ::lcl_IsSOObject( aTmpName ); + bInclude = ( (nMyOLEOptions & SwTOOElements::Other) && SwTOOElements::NONE == nObj ) + || (nMyOLEOptions & nObj); } else { diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index b1d2fdfcfbef..8ddf22514b49 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -429,7 +429,7 @@ SwTOXBase::SwTOXBase(const SwTOXType* pTyp, const SwForm& rForm, , m_aTitle(rTitle) , m_eLanguage((LanguageType)::GetAppLanguage()) , m_nCreateType(nCreaType) - , m_nOLEOptions(0) + , m_nOLEOptions(SwTOOElements::NONE) , m_eCaptionDisplay(CAPTION_COMPLETE) , m_bProtected( true ) , m_bFromChapter(false) diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 0d5aae914c4e..5cd0397df4f3 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -577,7 +577,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, SwTOXBase & rTOXBase( m_pImpl->GetTOXSectionOrThrow() ); SwTOXElement nCreate = rTOXBase.GetCreateType(); - sal_uInt16 nOLEOptions = rTOXBase.GetOLEOptions(); + SwTOOElements nOLEOptions = rTOXBase.GetOLEOptions(); const TOXTypes eTxBaseType = rTOXBase.GetTOXType()->GetType(); SwTOIOptions nTOIOptions = (eTxBaseType == TOX_INDEX) ? rTOXBase.GetOptions() : SwTOIOptions::NONE; @@ -787,20 +787,20 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Ole); break; case WID_CREATE_FROM_STAR_MATH: - lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_MATH); + lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Math); break; case WID_CREATE_FROM_STAR_CHART: - lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_CHART); + lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Chart); break; case WID_CREATE_FROM_STAR_CALC: - lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_CALC); + lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Calc); break; case WID_CREATE_FROM_STAR_DRAW: lcl_AnyToBitMask(rValue, nOLEOptions, - nsSwTOOElements::TOO_DRAW_IMPRESS); + SwTOOElements::DrawImpress); break; case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS: - lcl_AnyToBitMask(rValue, nOLEOptions, nsSwTOOElements::TOO_OTHER); + lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Other); break; case WID_PARA_HEAD: { @@ -915,7 +915,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, if(pTOXBase) { const SwTOXElement nCreate = pTOXBase->GetCreateType(); - const sal_uInt16 nOLEOptions = pTOXBase->GetOLEOptions(); + const SwTOOElements nOLEOptions = pTOXBase->GetOLEOptions(); const SwTOIOptions nTOIOptions = (pTOXBase->GetTOXType()->GetType() == TOX_INDEX) ? pTOXBase->GetOptions() @@ -1120,20 +1120,20 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Ole); break; case WID_CREATE_FROM_STAR_MATH: - lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_MATH); + lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Math); break; case WID_CREATE_FROM_STAR_CHART: - lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_CHART); + lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Chart); break; case WID_CREATE_FROM_STAR_CALC: - lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_CALC); + lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Calc); break; case WID_CREATE_FROM_STAR_DRAW: lcl_BitMaskToAny(aRet, nOLEOptions, - nsSwTOOElements::TOO_DRAW_IMPRESS); + SwTOOElements::DrawImpress); break; case WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS: - lcl_BitMaskToAny(aRet, nOLEOptions, nsSwTOOElements::TOO_OTHER); + lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Other); break; case WID_CREATE_FROM_PARAGRAPH_STYLES: lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Template); diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx index 81b027d104da..394683bc8d82 100644 --- a/sw/source/ui/index/cntex.cxx +++ b/sw/source/ui/index/cntex.cxx @@ -263,12 +263,12 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( } lcl_SetProp(xInfo, xIdxProps, UNO_NAME_LABEL_DISPLAY_TYPE, nSet); - sal_uInt16 nOLEOptions = rDesc.GetOLEOptions(); - lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_MATH, 0 != (nsSwTOOElements::TOO_MATH &nOLEOptions )); - lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_CHART, 0 != (nsSwTOOElements::TOO_CHART &nOLEOptions )); - lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_CALC, 0 != (nsSwTOOElements::TOO_CALC &nOLEOptions )); - lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_DRAW, 0 != (nsSwTOOElements::TOO_DRAW_IMPRESS&nOLEOptions)); - lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_OTHER_EMBEDDED_OBJECTS, 0 != (nsSwTOOElements::TOO_OTHER & nOLEOptions)); + SwTOOElements nOLEOptions = rDesc.GetOLEOptions(); + lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_MATH, bool(SwTOOElements::Math &nOLEOptions )); + lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_CHART, bool(SwTOOElements::Chart &nOLEOptions )); + lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_CALC, bool(SwTOOElements::Calc &nOLEOptions )); + lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_STAR_DRAW, bool(SwTOOElements::DrawImpress&nOLEOptions)); + lcl_SetBOOLProp(xInfo, xIdxProps, UNO_NAME_CREATE_FROM_OTHER_EMBEDDED_OBJECTS, bool(SwTOOElements::Other & nOLEOptions)); } const SwForm* pForm = GetForm(eCurrentTOXType); if(bInitialCreate || !nPage || nPage == TOX_PAGE_ENTRY) diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 6e7de7dcc844..b565df9db20c 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -1107,11 +1107,11 @@ void SwTOXSelectTabPage::ApplyTOXDescription() } else if(TOX_OBJECTS == aCurType.eType) { - long nOLEData = rDesc.GetOLEOptions(); + SwTOOElements nOLEData = rDesc.GetOLEOptions(); for(sal_uLong nFromObj = 0; nFromObj < m_pFromObjCLB->GetEntryCount(); nFromObj++) { - sal_IntPtr nData = reinterpret_cast<sal_IntPtr>(m_pFromObjCLB->GetEntryData(nFromObj)); - m_pFromObjCLB->CheckEntryPos(nFromObj, 0 != (nData & nOLEData)); + SwTOOElements nData = static_cast<SwTOOElements>(reinterpret_cast<sal_IntPtr>(m_pFromObjCLB->GetEntryData(nFromObj))); + m_pFromObjCLB->CheckEntryPos(nFromObj, bool(nData & nOLEData)); } } else if(TOX_AUTHORITIES == aCurType.eType) @@ -1204,16 +1204,16 @@ void SwTOXSelectTabPage::FillTOXDescription() break; case TOX_OBJECTS: { - long nOLEData = 0; + SwTOOElements nOLEData = SwTOOElements::NONE; for(sal_uLong i = 0; i < m_pFromObjCLB->GetEntryCount(); i++) { if(m_pFromObjCLB->IsChecked(i)) { - sal_IntPtr nData = reinterpret_cast<sal_IntPtr>(m_pFromObjCLB->GetEntryData(i)); + SwTOOElements nData = static_cast<SwTOOElements>(reinterpret_cast<sal_IntPtr>(m_pFromObjCLB->GetEntryData(i))); nOLEData |= nData; } } - rDesc.SetOLEOptions((sal_uInt16)nOLEData); + rDesc.SetOLEOptions(nOLEData); } break; case TOX_AUTHORITIES: diff --git a/sw/source/ui/index/cnttab.src b/sw/source/ui/index/cnttab.src index 7205296e9216..82f561abb841 100644 --- a/sw/source/ui/index/cnttab.src +++ b/sw/source/ui/index/cnttab.src @@ -141,12 +141,12 @@ String STR_CHARSTYLE StringArray RES_SRCTYPES { /* ids from tox.hxx - TOO_MATH = 0x01, - TOO_CHART = 0x02, + SwTOOElements::Math = 0x01, + SwTOOElements::Chart = 0x02, TOO_IMAGE = 0x04, - TOO_CALC = 0x08, - TOO_DRAW_IMPRESS= 0x10, - TOO_OTHER = 0x80 + SwTOOElements::Calc = 0x08, + SwTOOElements::DrawImpress= 0x10, + SwTOOElements::Other = 0x80 */ ItemList [ en-US ] = { diff --git a/sw/source/uibase/inc/toxmgr.hxx b/sw/source/uibase/inc/toxmgr.hxx index 61ae0f220b8a..2a42cd88031e 100644 --- a/sw/source/uibase/inc/toxmgr.hxx +++ b/sw/source/uibase/inc/toxmgr.hxx @@ -41,7 +41,7 @@ class SW_DLLPUBLIC SwTOXDescription SwForm* m_pForm; SwTOXElement m_nContent; SwTOIOptions m_nIndexOptions; - sal_uInt16 m_nOLEOptions; + SwTOOElements m_nOLEOptions; LanguageType m_eLanguage; OUString m_sSortAlgorithm; @@ -73,7 +73,7 @@ public: m_pForm(nullptr), m_nContent(SwTOXElement::Mark | SwTOXElement::OutlineLevel), m_nIndexOptions(SwTOIOptions::SameEntry|SwTOIOptions::FF|SwTOIOptions::CaseSensitive), - m_nOLEOptions(0), + m_nOLEOptions(SwTOOElements::NONE), m_eLanguage((LanguageType)::GetAppLanguage()), m_eCaptionDisplay(CAPTION_COMPLETE), m_nLevel(MAXLEVEL), @@ -137,8 +137,8 @@ public: void SetReadonly(bool bSet){m_bReadonly = bSet;} bool IsReadonly() const {return m_bReadonly;} - sal_uInt16 GetOLEOptions() const {return m_nOLEOptions;} - void SetOLEOptions(sal_uInt16 nOpt) {m_nOLEOptions = nOpt;} + SwTOOElements GetOLEOptions() const {return m_nOLEOptions;} + void SetOLEOptions(SwTOOElements nOpt) {m_nOLEOptions = nOpt;} bool IsLevelFromChapter() const {return m_bLevelFromChapter;} void SetLevelFromChapter(bool bSet) {m_bLevelFromChapter = bSet;} |