Kaydet (Commit) 5b6b61b0 authored tarafından Noel Grandin's avatar Noel Grandin

Convert BA flags to scoped enum

Change-Id: I22a6f41091d69ad4ed91a745e9b7cbcebd9fad55
üst 4baf56e6
...@@ -238,7 +238,7 @@ namespace xmloff ...@@ -238,7 +238,7 @@ namespace xmloff
,m_nIncludeDatabase(DAFlags::NONE) ,m_nIncludeDatabase(DAFlags::NONE)
,m_nIncludeSpecial(0) ,m_nIncludeSpecial(0)
,m_nIncludeEvents(0) ,m_nIncludeEvents(0)
,m_nIncludeBindings(0) ,m_nIncludeBindings(BAFlags::NONE)
,m_pOuterElement(nullptr) ,m_pOuterElement(nullptr)
{ {
OSL_ENSURE(m_xProps.is(), "OControlExport::OControlExport: invalid arguments!"); OSL_ENSURE(m_xProps.is(), "OControlExport::OControlExport: invalid arguments!");
...@@ -902,56 +902,56 @@ namespace xmloff ...@@ -902,56 +902,56 @@ namespace xmloff
void OControlExport::exportBindingAtributes() void OControlExport::exportBindingAtributes()
{ {
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
sal_Int32 nIncludeBinding = m_nIncludeBindings; BAFlags nIncludeBinding = m_nIncludeBindings;
#endif #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 #if OSL_DEBUG_LEVEL > 0
// reset the bit for later checking // reset the bit for later checking
nIncludeBinding = nIncludeBinding & ~( BA_LINKED_CELL | BA_LIST_LINKING_TYPE ); nIncludeBinding = nIncludeBinding & ~BAFlags( BAFlags::LinkedCell | BAFlags::ListLinkingType );
#endif #endif
} }
if ( m_nIncludeBindings & BA_LIST_CELL_RANGE ) if ( m_nIncludeBindings & BAFlags::ListCellRange )
{ {
exportCellListSourceRange(); exportCellListSourceRange();
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
// reset the bit for later checking // reset the bit for later checking
nIncludeBinding = nIncludeBinding & ~BA_LIST_CELL_RANGE; nIncludeBinding = nIncludeBinding & ~BAFlags::ListCellRange;
#endif #endif
} }
if ( m_nIncludeBindings & BA_XFORMS_BIND ) if ( m_nIncludeBindings & BAFlags::XFormsBind )
{ {
exportXFormsBindAttributes(); exportXFormsBindAttributes();
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
// reset the bit for later checking // reset the bit for later checking
nIncludeBinding = nIncludeBinding & ~BA_XFORMS_BIND; nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsBind;
#endif #endif
} }
if ( m_nIncludeBindings & BA_XFORMS_LISTBIND ) if ( m_nIncludeBindings & BAFlags::XFormsListBind )
{ {
exportXFormsListAttributes(); exportXFormsListAttributes();
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
// reset the bit for later checking // reset the bit for later checking
nIncludeBinding = nIncludeBinding & ~BA_XFORMS_LISTBIND; nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsListBind;
#endif #endif
} }
if ( m_nIncludeBindings & BA_XFORMS_SUBMISSION ) if ( m_nIncludeBindings & BAFlags::XFormsSubmission )
{ {
exportXFormsSubmissionAttributes(); exportXFormsSubmissionAttributes();
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
// reset the bit for later checking // reset the bit for later checking
nIncludeBinding = nIncludeBinding & ~BA_XFORMS_SUBMISSION; nIncludeBinding = nIncludeBinding & ~BAFlags::XFormsSubmission;
#endif #endif
} }
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
OSL_ENSURE( 0 == nIncludeBinding, OSL_ENSURE( BAFlags::NONE == nIncludeBinding,
"OControlExport::exportBindingAtributes: forgot some flags!"); "OControlExport::exportBindingAtributes: forgot some flags!");
// in the debug version, we should have removed every bit we handled from the mask, so it should // in the debug version, we should have removed every bit we handled from the mask, so it should
// be 0 now ... // be 0 now ...
...@@ -1441,7 +1441,7 @@ namespace xmloff ...@@ -1441,7 +1441,7 @@ namespace xmloff
void OControlExport::examine() void OControlExport::examine()
{ {
OSL_ENSURE( ( m_nIncludeCommon == CCAFlags::NONE ) && ( m_nIncludeSpecial == 0 ) && ( m_nIncludeDatabase == DAFlags::NONE ) 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?" ); "OControlExport::examine: called me twice? Not initialized?" );
// get the class id to decide which kind of element we need in the XML stream // get the class id to decide which kind of element we need in the XML stream
...@@ -1735,35 +1735,35 @@ namespace xmloff ...@@ -1735,35 +1735,35 @@ namespace xmloff
{ {
if ( FormCellBindingHelper::isCellBinding( aHelper.getCurrentBinding( ) ) ) if ( FormCellBindingHelper::isCellBinding( aHelper.getCurrentBinding( ) ) )
{ {
m_nIncludeBindings |= BA_LINKED_CELL; m_nIncludeBindings |= BAFlags::LinkedCell;
if ( m_nClassId == FormComponentType::LISTBOX ) 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? // is it a list-like control which uses a calc cell range as list source?
{ {
if ( FormCellBindingHelper::isCellRangeListSource( aHelper.getCurrentListSource( ) ) ) if ( FormCellBindingHelper::isCellRangeListSource( aHelper.getCurrentListSource( ) ) )
m_nIncludeBindings |= BA_LIST_CELL_RANGE; m_nIncludeBindings |= BAFlags::ListCellRange;
} }
} }
// is control bound to XForms? // is control bound to XForms?
if( !getXFormsBindName( m_xProps ).isEmpty() ) if( !getXFormsBindName( m_xProps ).isEmpty() )
{ {
m_nIncludeBindings |= BA_XFORMS_BIND; m_nIncludeBindings |= BAFlags::XFormsBind;
} }
// is (list-)control bound to XForms list? // is (list-)control bound to XForms list?
if( !getXFormsListBindName( m_xProps ).isEmpty() ) if( !getXFormsListBindName( m_xProps ).isEmpty() )
{ {
m_nIncludeBindings |= BA_XFORMS_LISTBIND; m_nIncludeBindings |= BAFlags::XFormsListBind;
} }
// does the control have an XForms submission? // does the control have an XForms submission?
if( !getXFormsSubmissionName( m_xProps ).isEmpty() ) if( !getXFormsSubmissionName( m_xProps ).isEmpty() )
{ {
m_nIncludeBindings |= BA_XFORMS_SUBMISSION; m_nIncludeBindings |= BAFlags::XFormsSubmission;
} }
} }
...@@ -1777,8 +1777,8 @@ namespace xmloff ...@@ -1777,8 +1777,8 @@ namespace xmloff
if ( xBinding.is() ) if ( xBinding.is() )
{ {
AddAttribute( AddAttribute(
OAttributeMetaData::getBindingAttributeNamespace( BA_LINKED_CELL ), OAttributeMetaData::getBindingAttributeNamespace( BAFlags::LinkedCell ),
OAttributeMetaData::getBindingAttributeName( BA_LINKED_CELL ), OAttributeMetaData::getBindingAttributeName( BAFlags::LinkedCell ),
aHelper.getStringAddressFromCellBinding( xBinding ) aHelper.getStringAddressFromCellBinding( xBinding )
); );
...@@ -1794,8 +1794,8 @@ namespace xmloff ...@@ -1794,8 +1794,8 @@ namespace xmloff
); );
AddAttribute( AddAttribute(
OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_LINKING_TYPE ), OAttributeMetaData::getBindingAttributeNamespace( BAFlags::ListLinkingType ),
OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE ), OAttributeMetaData::getBindingAttributeName( BAFlags::ListLinkingType ),
sBuffer.makeStringAndClear() sBuffer.makeStringAndClear()
); );
} }
...@@ -1838,8 +1838,8 @@ namespace xmloff ...@@ -1838,8 +1838,8 @@ namespace xmloff
FormCellBindingHelper aHelper( m_xProps, nullptr ); FormCellBindingHelper aHelper( m_xProps, nullptr );
AddAttribute( AddAttribute(
OAttributeMetaData::getBindingAttributeNamespace( BA_LIST_CELL_RANGE ), OAttributeMetaData::getBindingAttributeNamespace( BAFlags::ListCellRange ),
OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE ), OAttributeMetaData::getBindingAttributeName( BAFlags::ListCellRange ),
aHelper.getStringAddressFromCellListSource( xSource ) aHelper.getStringAddressFromCellListSource( xSource )
); );
} }
......
...@@ -98,7 +98,7 @@ namespace xmloff ...@@ -98,7 +98,7 @@ namespace xmloff
DAFlags m_nIncludeDatabase; // common database attributes to include DAFlags m_nIncludeDatabase; // common database attributes to include
sal_Int32 m_nIncludeSpecial; // special attributes to include sal_Int32 m_nIncludeSpecial; // special attributes to include
sal_Int32 m_nIncludeEvents; // events 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 SvXMLElementExport* m_pOuterElement; // XML element doing the concrete startElement etc. for the outer element
......
...@@ -701,7 +701,7 @@ namespace xmloff ...@@ -701,7 +701,7 @@ namespace xmloff
bool OControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const OUString& _rLocalName, const OUString& _rValue) 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)) if (IsXMLToken(_rLocalName, XML_ID))
{ // it's the control id { // it's the control id
...@@ -1669,13 +1669,13 @@ namespace xmloff ...@@ -1669,13 +1669,13 @@ namespace xmloff
return true; return true;
} }
if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE ) ) ) if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BAFlags::ListCellRange ) ) )
{ {
m_sCellListSource = _rValue; m_sCellListSource = _rValue;
return true; return true;
} }
if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE ) ) ) if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BAFlags::ListLinkingType ) ) )
{ {
sal_Int16 nLinkageType = 0; sal_Int16 nLinkageType = 0;
PropertyConversion::convertString( PropertyConversion::convertString(
......
...@@ -140,13 +140,13 @@ namespace xmloff ...@@ -140,13 +140,13 @@ namespace xmloff
return ""; return "";
} }
const sal_Char* OAttributeMetaData::getBindingAttributeName(sal_Int32 _nId) const sal_Char* OAttributeMetaData::getBindingAttributeName(BAFlags _nId)
{ {
switch (_nId) switch (_nId)
{ {
case BA_LINKED_CELL: return "linked-cell"; case BAFlags::LinkedCell: return "linked-cell";
case BA_LIST_LINKING_TYPE: return "list-linkage-type"; case BAFlags::ListLinkingType: return "list-linkage-type";
case BA_LIST_CELL_RANGE: return "source-cell-range"; case BAFlags::ListCellRange: return "source-cell-range";
default: default:
OSL_FAIL("OAttributeMetaData::getBindingAttributeName: invalid id (maybe you or-ed two flags?)!"); OSL_FAIL("OAttributeMetaData::getBindingAttributeName: invalid id (maybe you or-ed two flags?)!");
} }
......
...@@ -79,17 +79,24 @@ namespace o3tl { ...@@ -79,17 +79,24 @@ namespace o3tl {
template<> struct typed_flags<DAFlags> : is_typed_flags<DAFlags, 0x003f> {}; 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 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 // flags for event attributes
#define EA_CONTROL_EVENTS 0x00000001 #define EA_CONTROL_EVENTS 0x00000001
#define EA_ON_CHANGE 0x00000002 #define EA_ON_CHANGE 0x00000002
...@@ -211,13 +218,13 @@ namespace xmloff ...@@ -211,13 +218,13 @@ namespace xmloff
@param _nId @param _nId
the id of the attribute. Has to be one of the BA_* constants. 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. /** calculates the xml namespace key to use for a binding attribute.
@param _nId @param _nId
the id of the attribute. Has to be one of the BA_* constants. 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 // nothing special here
return XML_NAMESPACE_FORM; return XML_NAMESPACE_FORM;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment