diff options
author | Noel Grandin <noel@peralex.com> | 2016-05-12 14:18:30 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-05-12 14:33:35 +0200 |
commit | 5b6b61b00bc850c58046cfdb59e4a919e55edab7 (patch) | |
tree | 9d03d57e4e46c904b8a5a8c367956897f6edd290 /xmloff | |
parent | 4baf56e63d7386475b631a7cf86cf0d08d139681 (diff) |
Convert BA flags to scoped enum
Change-Id: I22a6f41091d69ad4ed91a745e9b7cbcebd9fad55
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/forms/elementexport.cxx | 54 | ||||
-rw-r--r-- | xmloff/source/forms/elementexport.hxx | 2 | ||||
-rw-r--r-- | xmloff/source/forms/elementimport.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/forms/formattributes.cxx | 8 | ||||
-rw-r--r-- | xmloff/source/forms/formattributes.hxx | 27 |
5 files changed, 52 insertions, 45 deletions
diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index cd9b82eccb20..844ed2ef0d62 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -238,7 +238,7 @@ namespace xmloff ,m_nIncludeDatabase(DAFlags::NONE) ,m_nIncludeSpecial(0) ,m_nIncludeEvents(0) - ,m_nIncludeBindings(0) + ,m_nIncludeBindings(BAFlags::NONE) ,m_pOuterElement(nullptr) { OSL_ENSURE(m_xProps.is(), "OControlExport::OControlExport: invalid arguments!"); @@ -902,56 +902,56 @@ namespace xmloff void OControlExport::exportBindingAtributes() { #if OSL_DEBUG_LEVEL > 0 - sal_Int32 nIncludeBinding = m_nIncludeBindings; + BAFlags nIncludeBinding = m_nIncludeBindings; #endif - if ( m_nIncludeBindings & BA_LINKED_CELL ) + if ( m_nIncludeBindings & BAFlags::LinkedCell ) { - exportCellBindingAttributes( ( m_nIncludeBindings & BA_LIST_LINKING_TYPE ) != 0 ); + exportCellBindingAttributes( bool(m_nIncludeBindings & BAFlags::ListLinkingType) ); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking - nIncludeBinding = nIncludeBinding & ~( BA_LINKED_CELL | BA_LIST_LINKING_TYPE ); + nIncludeBinding = nIncludeBinding & ~BAFlags( BAFlags::LinkedCell | BAFlags::ListLinkingType ); #endif } - if ( m_nIncludeBindings & BA_LIST_CELL_RANGE ) + if ( m_nIncludeBindings & BAFlags::ListCellRange ) { exportCellListSourceRange(); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking - nIncludeBinding = nIncludeBinding & ~BA_LIST_CELL_RANGE; + nIncludeBinding = nIncludeBinding & ~BAFlags::ListCellRange; #endif } - if ( m_nIncludeBindings & BA_XFORMS_BIND ) + if ( m_nIncludeBindings & BAFlags::XFormsBind ) { exportXFormsBindAttributes(); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking - nIncludeBinding = nIncludeBinding & ~BA_XFORMS_BIND; + nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsBind; #endif } - if ( m_nIncludeBindings & BA_XFORMS_LISTBIND ) + if ( m_nIncludeBindings & BAFlags::XFormsListBind ) { exportXFormsListAttributes(); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking - nIncludeBinding = nIncludeBinding & ~BA_XFORMS_LISTBIND; + nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsListBind; #endif } - if ( m_nIncludeBindings & BA_XFORMS_SUBMISSION ) + if ( m_nIncludeBindings & BAFlags::XFormsSubmission ) { exportXFormsSubmissionAttributes(); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking - nIncludeBinding = nIncludeBinding & ~BA_XFORMS_SUBMISSION; + nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsSubmission; #endif } #if OSL_DEBUG_LEVEL > 0 - OSL_ENSURE( 0 == nIncludeBinding, + OSL_ENSURE( BAFlags::NONE == nIncludeBinding, "OControlExport::exportBindingAtributes: forgot some flags!"); // in the debug version, we should have removed every bit we handled from the mask, so it should // be 0 now ... @@ -1441,7 +1441,7 @@ namespace xmloff void OControlExport::examine() { OSL_ENSURE( ( m_nIncludeCommon == CCAFlags::NONE ) && ( m_nIncludeSpecial == 0 ) && ( m_nIncludeDatabase == DAFlags::NONE ) - && ( m_nIncludeEvents == 0 ) && ( m_nIncludeBindings == 0), + && ( m_nIncludeEvents == 0 ) && ( m_nIncludeBindings == BAFlags::NONE), "OControlExport::examine: called me twice? Not initialized?" ); // get the class id to decide which kind of element we need in the XML stream @@ -1735,35 +1735,35 @@ namespace xmloff { if ( FormCellBindingHelper::isCellBinding( aHelper.getCurrentBinding( ) ) ) { - m_nIncludeBindings |= BA_LINKED_CELL; + m_nIncludeBindings |= BAFlags::LinkedCell; if ( m_nClassId == FormComponentType::LISTBOX ) - m_nIncludeBindings |= BA_LIST_LINKING_TYPE; + m_nIncludeBindings |= BAFlags::ListLinkingType; } } // is it a list-like control which uses a calc cell range as list source? { if ( FormCellBindingHelper::isCellRangeListSource( aHelper.getCurrentListSource( ) ) ) - m_nIncludeBindings |= BA_LIST_CELL_RANGE; + m_nIncludeBindings |= BAFlags::ListCellRange; } } // is control bound to XForms? if( !getXFormsBindName( m_xProps ).isEmpty() ) { - m_nIncludeBindings |= BA_XFORMS_BIND; + m_nIncludeBindings |= BAFlags::XFormsBind; } // is (list-)control bound to XForms list? if( !getXFormsListBindName( m_xProps ).isEmpty() ) { - m_nIncludeBindings |= BA_XFORMS_LISTBIND; + m_nIncludeBindings |= BAFlags::XFormsListBind; } // does the control have an XForms submission? if( !getXFormsSubmissionName( m_xProps ).isEmpty() ) { - m_nIncludeBindings |= BA_XFORMS_SUBMISSION; + m_nIncludeBindings |= BAFlags::XFormsSubmission; } } @@ -1777,8 +1777,8 @@ namespace xmloff if ( xBinding.is() ) { AddAttribute( - OAttributeMetaData::getBindingAttributeNamespace( BA_LINKED_CELL ), - OAttributeMetaData::getBindingAttributeName( BA_LINKED_CELL ), + OAttributeMetaData::getBindingAttributeNamespace( BAFlags::LinkedCell ), + OAttributeMetaData::getBindingAttributeName( BAFlags::LinkedCell ), aHelper.getStringAddressFromCellBinding( xBinding ) ); @@ -1794,8 +1794,8 @@ namespace xmloff ); AddAttribute( - OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_LINKING_TYPE ), - OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE ), + OAttributeMetaData::getBindingAttributeNamespace( BAFlags::ListLinkingType ), + OAttributeMetaData::getBindingAttributeName( BAFlags::ListLinkingType ), sBuffer.makeStringAndClear() ); } @@ -1838,8 +1838,8 @@ namespace xmloff FormCellBindingHelper aHelper( m_xProps, nullptr ); AddAttribute( - OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_CELL_RANGE ), - OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE ), + OAttributeMetaData::getBindingAttributeNamespace( BAFlags::ListCellRange ), + OAttributeMetaData::getBindingAttributeName( BAFlags::ListCellRange ), aHelper.getStringAddressFromCellListSource( xSource ) ); } diff --git a/xmloff/source/forms/elementexport.hxx b/xmloff/source/forms/elementexport.hxx index 3423de083104..0ef7b9463b29 100644 --- a/xmloff/source/forms/elementexport.hxx +++ b/xmloff/source/forms/elementexport.hxx @@ -98,7 +98,7 @@ namespace xmloff DAFlags m_nIncludeDatabase; // common database attributes to include sal_Int32 m_nIncludeSpecial; // special attributes to include sal_Int32 m_nIncludeEvents; // events to include - sal_Int32 m_nIncludeBindings; // binding attributes to include + BAFlags m_nIncludeBindings; // binding attributes to include SvXMLElementExport* m_pOuterElement; // XML element doing the concrete startElement etc. for the outer element diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 22fe2f14e037..32cd55a1c91d 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -701,7 +701,7 @@ namespace xmloff bool OControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const OUString& _rLocalName, const OUString& _rValue) { - static const sal_Char* pLinkedCellAttributeName = OAttributeMetaData::getBindingAttributeName(BA_LINKED_CELL); + static const sal_Char* pLinkedCellAttributeName = OAttributeMetaData::getBindingAttributeName(BAFlags::LinkedCell); if (IsXMLToken(_rLocalName, XML_ID)) { // it's the control id @@ -1669,13 +1669,13 @@ namespace xmloff return true; } - if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE ) ) ) + if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BAFlags::ListCellRange ) ) ) { m_sCellListSource = _rValue; return true; } - if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE ) ) ) + if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BAFlags::ListLinkingType ) ) ) { sal_Int16 nLinkageType = 0; PropertyConversion::convertString( diff --git a/xmloff/source/forms/formattributes.cxx b/xmloff/source/forms/formattributes.cxx index b13cd7c80e8f..4788a3b1e3aa 100644 --- a/xmloff/source/forms/formattributes.cxx +++ b/xmloff/source/forms/formattributes.cxx @@ -140,13 +140,13 @@ namespace xmloff return ""; } - const sal_Char* OAttributeMetaData::getBindingAttributeName(sal_Int32 _nId) + const sal_Char* OAttributeMetaData::getBindingAttributeName(BAFlags _nId) { switch (_nId) { - case BA_LINKED_CELL: return "linked-cell"; - case BA_LIST_LINKING_TYPE: return "list-linkage-type"; - case BA_LIST_CELL_RANGE: return "source-cell-range"; + case BAFlags::LinkedCell: return "linked-cell"; + case BAFlags::ListLinkingType: return "list-linkage-type"; + case BAFlags::ListCellRange: return "source-cell-range"; default: OSL_FAIL("OAttributeMetaData::getBindingAttributeName: invalid id (maybe you or-ed two flags?)!"); } diff --git a/xmloff/source/forms/formattributes.hxx b/xmloff/source/forms/formattributes.hxx index 48be949b0493..5412e2894a84 100644 --- a/xmloff/source/forms/formattributes.hxx +++ b/xmloff/source/forms/formattributes.hxx @@ -79,17 +79,24 @@ namespace o3tl { template<> struct typed_flags<DAFlags> : is_typed_flags<DAFlags, 0x003f> {}; } + // flags for binding related control attributes +enum class BAFlags { + NONE = 0x0000, + LinkedCell = 0x0001, + ListLinkingType = 0x0002, + ListCellRange = 0x0004, + XFormsBind = 0x0008, + XFormsListBind = 0x0010, + XFormsSubmission = 0x0020 +}; +namespace o3tl { + template<> struct typed_flags<BAFlags> : is_typed_flags<BAFlags, 0x003f> {}; +} + + namespace xmloff { - // flags for binding related control attributes - #define BA_LINKED_CELL 0x00000001 - #define BA_LIST_LINKING_TYPE 0x00000002 - #define BA_LIST_CELL_RANGE 0x00000004 - #define BA_XFORMS_BIND 0x00000008 - #define BA_XFORMS_LISTBIND 0x00000010 - #define BA_XFORMS_SUBMISSION 0x00000020 - // flags for event attributes #define EA_CONTROL_EVENTS 0x00000001 #define EA_ON_CHANGE 0x00000002 @@ -211,13 +218,13 @@ namespace xmloff @param _nId the id of the attribute. Has to be one of the BA_* constants. */ - static const sal_Char* getBindingAttributeName(sal_Int32 _nId); + static const sal_Char* getBindingAttributeName(BAFlags _nId); /** calculates the xml namespace key to use for a binding attribute. @param _nId the id of the attribute. Has to be one of the BA_* constants. */ - static inline sal_uInt16 getBindingAttributeNamespace(sal_Int32 ) + static inline sal_uInt16 getBindingAttributeNamespace(BAFlags ) { // nothing special here return XML_NAMESPACE_FORM; |