xmloff/source/forms/elementexport.cxx | 200 ++++++++++++++++----------------- xmloff/source/forms/elementexport.hxx | 6 xmloff/source/forms/elementimport.cxx | 18 +- xmloff/source/forms/formattributes.cxx | 51 ++++---- xmloff/source/forms/formattributes.hxx | 97 +++++++++------- xmloff/source/forms/layerimport.cxx | 24 +-- 6 files changed, 208 insertions(+), 188 deletions(-)
New commits: commit 0c2d51e0daf2ce5e18af915ec40ec3196db8ab88 Author: Noel Grandin <[email protected]> Date: Thu May 12 14:32:30 2016 +0200 Convert SCA flags to scoped enum Change-Id: I761022dd78f6c1d19cf4f2650a5ac7b2212c11c3 diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index abd6e50..b80d7b0 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -236,7 +236,7 @@ namespace xmloff ,m_eType( UNKNOWN ) ,m_nIncludeCommon(CCAFlags::NONE) ,m_nIncludeDatabase(DAFlags::NONE) - ,m_nIncludeSpecial(0) + ,m_nIncludeSpecial(SCAFlags::NONE) ,m_nIncludeEvents(EAFlags::NONE) ,m_nIncludeBindings(BAFlags::NONE) ,m_pOuterElement(nullptr) @@ -964,10 +964,10 @@ namespace xmloff // the boolean properties { - static const sal_Int32 nBooleanPropertyAttributeIds[] = + static const SCAFlags nBooleanPropertyAttributeIds[] = { // attribute flags - SCA_VALIDATION, SCA_MULTI_LINE, SCA_AUTOMATIC_COMPLETION, SCA_MULTIPLE, SCA_DEFAULT_BUTTON, SCA_IS_TRISTATE, - SCA_TOGGLE, SCA_FOCUS_ON_CLICK + SCAFlags::Validation, SCAFlags::MultiLine, SCAFlags::AutoCompletion, SCAFlags::Multiple, SCAFlags::DefaultButton, SCAFlags::IsTristate, + SCAFlags::Toggle, SCAFlags::FocusOnClick }; static const char * pBooleanPropertyNames[] = { // property names @@ -983,7 +983,7 @@ namespace xmloff OSL_ENSURE((nIdCount == nNameCount), "OControlExport::exportSpecialAttributes: somebody tampered with the maps (1)!"); #endif - const sal_Int32* pAttributeId = nBooleanPropertyAttributeIds; + const SCAFlags* pAttributeId = nBooleanPropertyAttributeIds; for ( i = 0; i < nIdCount; ++i, ++pAttributeId ) { if ( *pAttributeId & m_nIncludeSpecial) @@ -992,7 +992,7 @@ namespace xmloff OAttributeMetaData::getSpecialAttributeNamespace( *pAttributeId ), OAttributeMetaData::getSpecialAttributeName( *pAttributeId ), OUString::createFromAscii(pBooleanPropertyNames[i]), - ( *pAttributeId == SCA_FOCUS_ON_CLICK ) ? BoolAttrFlags::DefaultTrue : BoolAttrFlags::DefaultFalse + ( *pAttributeId == SCAFlags::FocusOnClick ) ? BoolAttrFlags::DefaultTrue : BoolAttrFlags::DefaultFalse ); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking @@ -1004,9 +1004,9 @@ namespace xmloff // the integer properties { - static sal_Int32 nIntegerPropertyAttributeIds[] = + static SCAFlags nIntegerPropertyAttributeIds[] = { // attribute flags - SCA_PAGE_STEP_SIZE + SCAFlags::PageStepSize }; static const char * pIntegerPropertyNames[] = { // property names @@ -1041,7 +1041,7 @@ namespace xmloff #endif } - if ( SCA_STEP_SIZE & m_nIncludeSpecial ) + if ( SCAFlags::StepSize & m_nIncludeSpecial ) { OUString sPropertyName; if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_LINE_INCREMENT ) ) @@ -1053,15 +1053,15 @@ namespace xmloff if ( !sPropertyName.isEmpty() ) exportInt32PropertyAttribute( - OAttributeMetaData::getSpecialAttributeNamespace( SCA_STEP_SIZE ), - OAttributeMetaData::getSpecialAttributeName( SCA_STEP_SIZE ), + OAttributeMetaData::getSpecialAttributeNamespace( SCAFlags::StepSize ), + OAttributeMetaData::getSpecialAttributeName( SCAFlags::StepSize ), sPropertyName, 1 ); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking - m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_STEP_SIZE; + m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::StepSize; #endif } @@ -1069,31 +1069,31 @@ namespace xmloff // the enum properties { - if (SCA_STATE & m_nIncludeSpecial) + if (SCAFlags::State & m_nIncludeSpecial) { exportEnumPropertyAttribute( - OAttributeMetaData::getSpecialAttributeNamespace(SCA_STATE), - OAttributeMetaData::getSpecialAttributeName(SCA_STATE), + OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::State), + OAttributeMetaData::getSpecialAttributeName(SCAFlags::State), PROPERTY_DEFAULT_STATE, OEnumMapper::getEnumMap(OEnumMapper::epCheckState), TRISTATE_FALSE); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking - m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_STATE; + m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::State; #endif } - if (SCA_CURRENT_STATE & m_nIncludeSpecial) + if (SCAFlags::CurrentState & m_nIncludeSpecial) { exportEnumPropertyAttribute( - OAttributeMetaData::getSpecialAttributeNamespace(SCA_CURRENT_STATE), - OAttributeMetaData::getSpecialAttributeName(SCA_CURRENT_STATE), + OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::CurrentState), + OAttributeMetaData::getSpecialAttributeName(SCAFlags::CurrentState), PROPERTY_STATE, OEnumMapper::getEnumMap(OEnumMapper::epCheckState), TRISTATE_FALSE); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking - m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_CURRENT_STATE; + m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::CurrentState; #endif } } @@ -1101,7 +1101,7 @@ namespace xmloff // some properties which require a special handling // the repeat delay { - if ( m_nIncludeSpecial & SCA_REPEAT_DELAY ) + if ( m_nIncludeSpecial & SCAFlags::RepeatDelay ) { DBG_CHECK_PROPERTY( PROPERTY_REPEAT_DELAY, sal_Int32 ); @@ -1117,22 +1117,22 @@ namespace xmloff OUStringBuffer buf; ::sax::Converter::convertDuration(buf, aDuration); - AddAttribute(OAttributeMetaData::getSpecialAttributeNamespace( SCA_REPEAT_DELAY ) - ,OAttributeMetaData::getSpecialAttributeName( SCA_REPEAT_DELAY ) + AddAttribute(OAttributeMetaData::getSpecialAttributeNamespace( SCAFlags::RepeatDelay ) + ,OAttributeMetaData::getSpecialAttributeName( SCAFlags::RepeatDelay ) ,buf.makeStringAndClear()); exportedProperty( PROPERTY_REPEAT_DELAY ); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking - m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_REPEAT_DELAY; + m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::RepeatDelay; #endif } } // the EchoChar property needs special handling, cause it's a Int16, but must be stored as one-character-string { - if (SCA_ECHO_CHAR & m_nIncludeSpecial) + if (SCAFlags::EchoChar & m_nIncludeSpecial) { DBG_CHECK_PROPERTY( PROPERTY_ECHO_CHAR, sal_Int16 ); sal_Int16 nValue(0); @@ -1141,23 +1141,23 @@ namespace xmloff { OUString sCharacter(reinterpret_cast<const sal_Unicode*>(&nValue), 1); AddAttribute( - OAttributeMetaData::getSpecialAttributeNamespace(SCA_ECHO_CHAR), - OAttributeMetaData::getSpecialAttributeName(SCA_ECHO_CHAR), + OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::EchoChar), + OAttributeMetaData::getSpecialAttributeName(SCAFlags::EchoChar), sCharacter); } exportedProperty(PROPERTY_ECHO_CHAR); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking - m_nIncludeSpecial = m_nIncludeSpecial & ~SCA_ECHO_CHAR; + m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags::EchoChar; #endif } } // the string properties { - static const sal_Int32 nStringPropertyAttributeIds[] = + static const SCAFlags nStringPropertyAttributeIds[] = { // attribute flags - SCA_GROUP_NAME + SCAFlags::GroupName }; static const OUString pStringPropertyNames[] = { // property names @@ -1185,7 +1185,7 @@ namespace xmloff } } - if ((SCA_MIN_VALUE | SCA_MAX_VALUE) & m_nIncludeSpecial) + if ((SCAFlags::MinValue | SCAFlags::MaxValue) & m_nIncludeSpecial) { // need to export the min value and the max value as attributes // It depends on the real type (FormComponentType) of the control, which properties hold these @@ -1194,41 +1194,41 @@ namespace xmloff const sal_Char* pMaxValuePropertyName = nullptr; getValueLimitPropertyNames(m_nClassId, pMinValuePropertyName, pMaxValuePropertyName); - OSL_ENSURE((nullptr == pMinValuePropertyName) == (0 == (SCA_MIN_VALUE & m_nIncludeSpecial)), + OSL_ENSURE((nullptr == pMinValuePropertyName) == (SCAFlags::NONE == (SCAFlags::MinValue & m_nIncludeSpecial)), "OControlExport::exportCommonControlAttributes: no property found for the min value attribute!"); - OSL_ENSURE((nullptr == pMaxValuePropertyName) == (0 == (SCA_MAX_VALUE & m_nIncludeSpecial)), + OSL_ENSURE((nullptr == pMaxValuePropertyName) == (SCAFlags::NONE == (SCAFlags::MaxValue & m_nIncludeSpecial)), "OControlExport::exportCommonControlAttributes: no property found for the max value attribute!"); // add the two attributes - static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MIN_VALUE); - static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MAX_VALUE); - static const sal_uInt16 nMinValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCA_MIN_VALUE); - static const sal_uInt16 nMaxValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCA_MAX_VALUE); + static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MinValue); + static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MaxValue); + static const sal_uInt16 nMinValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::MinValue); + static const sal_uInt16 nMaxValueNamespaceKey = OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags::MaxValue); - if (pMinValuePropertyName && (SCA_MIN_VALUE & m_nIncludeSpecial)) + if (pMinValuePropertyName && (SCAFlags::MinValue & m_nIncludeSpecial)) exportGenericPropertyAttribute( nMinValueNamespaceKey, pMinValueAttributeName, pMinValuePropertyName); - if (pMaxValuePropertyName && (SCA_MAX_VALUE & m_nIncludeSpecial)) + if (pMaxValuePropertyName && (SCAFlags::MaxValue & m_nIncludeSpecial)) exportGenericPropertyAttribute( nMaxValueNamespaceKey, pMaxValueAttributeName, pMaxValuePropertyName); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking - m_nIncludeSpecial = m_nIncludeSpecial & ~(SCA_MIN_VALUE | SCA_MAX_VALUE); + m_nIncludeSpecial = m_nIncludeSpecial & ~SCAFlags(SCAFlags::MinValue | SCAFlags::MaxValue); #endif } - if ( SCA_IMAGE_POSITION & m_nIncludeSpecial ) + if ( SCAFlags::ImagePosition & m_nIncludeSpecial ) { exportImagePositionAttributes(); - RESET_BIT( m_nIncludeSpecial, SCA_IMAGE_POSITION ); + RESET_BIT( m_nIncludeSpecial, SCAFlags::ImagePosition ); } - OSL_ENSURE(0 == m_nIncludeSpecial, + OSL_ENSURE(SCAFlags::NONE == m_nIncludeSpecial, "OControlExport::exportSpecialAttributes: forgot some flags!"); // in the dbg_util version, we should have removed every bit we handled from the mask, so it should // be 0 now ... @@ -1440,7 +1440,7 @@ namespace xmloff void OControlExport::examine() { - OSL_ENSURE( ( m_nIncludeCommon == CCAFlags::NONE ) && ( m_nIncludeSpecial == 0 ) && ( m_nIncludeDatabase == DAFlags::NONE ) + OSL_ENSURE( ( m_nIncludeCommon == CCAFlags::NONE ) && ( m_nIncludeSpecial == SCAFlags::NONE ) && ( m_nIncludeDatabase == DAFlags::NONE ) && ( m_nIncludeEvents == EAFlags::NONE ) && ( m_nIncludeBindings == BAFlags::NONE), "OControlExport::examine: called me twice? Not initialized?" ); @@ -1461,7 +1461,7 @@ namespace xmloff m_eType = TIME; knownType = true; } - m_nIncludeSpecial |= SCA_VALIDATION; + m_nIncludeSpecial |= SCAFlags::Validation; SAL_FALLTHROUGH; case FormComponentType::NUMERICFIELD: case FormComponentType::CURRENCYFIELD: @@ -1495,7 +1495,7 @@ namespace xmloff if (nEchoChar) { m_eType = PASSWORD; - m_nIncludeSpecial |= SCA_ECHO_CHAR; + m_nIncludeSpecial |= SCAFlags::EchoChar; } else { @@ -1550,11 +1550,11 @@ namespace xmloff if (FORMATTED_TEXT == m_eType) { // in general all controls represented as formatted-text have these props if ( FormComponentType::PATTERNFIELD != m_nClassId ) // except the PatternField - m_nIncludeSpecial |= SCA_MAX_VALUE | SCA_MIN_VALUE; + m_nIncludeSpecial |= SCAFlags::MaxValue | SCAFlags::MinValue; if (FormComponentType::TEXTFIELD != m_nClassId) // and the FormattedField does not have a validation flag - m_nIncludeSpecial |= SCA_VALIDATION; + m_nIncludeSpecial |= SCAFlags::Validation; } // if it's not a password field or rich text control, the CurrentValue needs to be stored, too @@ -1582,7 +1582,7 @@ namespace xmloff m_nIncludeCommon = CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::Disabled | CCAFlags::Label | CCAFlags::Printable | CCAFlags::Title | CCAFlags::For; - m_nIncludeSpecial = SCA_MULTI_LINE; + m_nIncludeSpecial = SCAFlags::MultiLine; m_nIncludeEvents = EAFlags::ControlEvents; break; @@ -1592,7 +1592,7 @@ namespace xmloff CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::CurrentValue | CCAFlags::Disabled | CCAFlags::Dropdown | CCAFlags::MaxLength | CCAFlags::Printable | CCAFlags::ReadOnly | CCAFlags::Size | CCAFlags::TabIndex | CCAFlags::TabStop | CCAFlags::Title | CCAFlags::Value; - m_nIncludeSpecial = SCA_AUTOMATIC_COMPLETION; + m_nIncludeSpecial = SCAFlags::AutoCompletion; m_nIncludeDatabase = DAFlags::ConvertEmpty | DAFlags::DataField | DAFlags::InputRequired | DAFlags::ListSource | DAFlags::ListSource_TYPE; m_nIncludeEvents = EAFlags::ControlEvents | EAFlags::OnChange | EAFlags::OnSelect; break; @@ -1602,7 +1602,7 @@ namespace xmloff m_nIncludeCommon = CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::Disabled | CCAFlags::Dropdown | CCAFlags::Printable | CCAFlags::Size | CCAFlags::TabIndex | CCAFlags::TabStop | CCAFlags::Title; - m_nIncludeSpecial = SCA_MULTIPLE; + m_nIncludeSpecial = SCAFlags::Multiple; m_nIncludeDatabase = DAFlags::BoundColumn | DAFlags::DataField | DAFlags::InputRequired | DAFlags::ListSource_TYPE; m_nIncludeEvents = EAFlags::ControlEvents | EAFlags::OnChange | EAFlags::OnClick | EAFlags::OnDoubleClick; // check if we need to export the ListSource as attribute @@ -1624,7 +1624,7 @@ namespace xmloff case FormComponentType::COMMANDBUTTON: m_eType = BUTTON; m_nIncludeCommon |= CCAFlags::TabStop | CCAFlags::Label; - m_nIncludeSpecial = SCA_DEFAULT_BUTTON | SCA_TOGGLE | SCA_FOCUS_ON_CLICK | SCA_IMAGE_POSITION | SCA_REPEAT_DELAY; + m_nIncludeSpecial = SCAFlags::DefaultButton | SCAFlags::Toggle | SCAFlags::FocusOnClick | SCAFlags::ImagePosition | SCAFlags::RepeatDelay; SAL_FALLTHROUGH; case FormComponentType::IMAGEBUTTON: if (BUTTON != m_eType) @@ -1641,7 +1641,7 @@ namespace xmloff case FormComponentType::CHECKBOX: m_eType = CHECKBOX; - m_nIncludeSpecial = SCA_CURRENT_STATE | SCA_IS_TRISTATE | SCA_STATE; + m_nIncludeSpecial = SCAFlags::CurrentState | SCAFlags::IsTristate | SCAFlags::State; SAL_FALLTHROUGH; case FormComponentType::RADIOBUTTON: m_nIncludeCommon = @@ -1653,9 +1653,9 @@ namespace xmloff m_nIncludeCommon |= CCAFlags::CurrentSelected | CCAFlags::Selected; } if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_IMAGE_POSITION ) ) - m_nIncludeSpecial |= SCA_IMAGE_POSITION; + m_nIncludeSpecial |= SCAFlags::ImagePosition; if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_GROUP_NAME ) ) - m_nIncludeSpecial |= SCA_GROUP_NAME; + m_nIncludeSpecial |= SCAFlags::GroupName; m_nIncludeDatabase = DAFlags::DataField | DAFlags::InputRequired; m_nIncludeEvents = EAFlags::ControlEvents | EAFlags::OnChange; break; @@ -1697,10 +1697,10 @@ namespace xmloff m_nIncludeCommon = CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::Disabled | CCAFlags::Printable | CCAFlags::Title | CCAFlags::CurrentValue | CCAFlags::Value | CCAFlags::Orientation; - m_nIncludeSpecial = SCA_MAX_VALUE | SCA_STEP_SIZE | SCA_MIN_VALUE | SCA_REPEAT_DELAY; + m_nIncludeSpecial = SCAFlags::MaxValue | SCAFlags::StepSize | SCAFlags::MinValue | SCAFlags::RepeatDelay; if ( m_nClassId == FormComponentType::SCROLLBAR ) - m_nIncludeSpecial |= SCA_PAGE_STEP_SIZE ; + m_nIncludeSpecial |= SCAFlags::PageStepSize ; m_nIncludeEvents = EAFlags::ControlEvents; break; @@ -2015,8 +2015,8 @@ namespace xmloff if ( !sStyleName.isEmpty() ) { AddAttribute( - OAttributeMetaData::getSpecialAttributeNamespace( SCA_COLUMN_STYLE_NAME ), - OAttributeMetaData::getSpecialAttributeName( SCA_COLUMN_STYLE_NAME ), + OAttributeMetaData::getSpecialAttributeNamespace( SCAFlags::ColumnStyleName ), + OAttributeMetaData::getSpecialAttributeName( SCAFlags::ColumnStyleName ), sStyleName ); } @@ -2028,7 +2028,7 @@ namespace xmloff // grid columns miss some properties of the controls they're representing m_nIncludeCommon &= ~CCAFlags(CCAFlags::For | CCAFlags::Printable | CCAFlags::TabIndex | CCAFlags::TabStop | CCAFlags::Label); - m_nIncludeSpecial &= ~(SCA_ECHO_CHAR | SCA_AUTOMATIC_COMPLETION | SCA_MULTIPLE | SCA_MULTI_LINE); + m_nIncludeSpecial &= ~SCAFlags(SCAFlags::EchoChar | SCAFlags::AutoCompletion | SCAFlags::Multiple | SCAFlags::MultiLine); if (FormComponentType::DATEFIELD != m_nClassId) // except date fields, no column has the DropDown property diff --git a/xmloff/source/forms/elementexport.hxx b/xmloff/source/forms/elementexport.hxx index da7123d..f3b2f0a 100644 --- a/xmloff/source/forms/elementexport.hxx +++ b/xmloff/source/forms/elementexport.hxx @@ -96,7 +96,7 @@ namespace xmloff ElementType m_eType; // (XML) type of the control we're representing CCAFlags m_nIncludeCommon; // common control attributes to include DAFlags m_nIncludeDatabase; // common database attributes to include - sal_Int32 m_nIncludeSpecial; // special attributes to include + SCAFlags m_nIncludeSpecial; // special attributes to include EAFlags m_nIncludeEvents; // events to include BAFlags m_nIncludeBindings; // binding attributes to include diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 32cd55a..b39b731 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -754,9 +754,9 @@ namespace xmloff static const sal_Char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Value); static const sal_Char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::CurrentValue); - static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MIN_VALUE); - static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MAX_VALUE); - static const sal_Char* pRepeatDelayAttributeName = OAttributeMetaData::getSpecialAttributeName( SCA_REPEAT_DELAY ); + static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MinValue); + static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::MaxValue); + static const sal_Char* pRepeatDelayAttributeName = OAttributeMetaData::getSpecialAttributeName( SCAFlags::RepeatDelay ); sal_Int32 nHandle = -1; if ( _rLocalName.equalsAscii( pValueAttributeName ) ) @@ -1211,7 +1211,7 @@ namespace xmloff bool OPasswordImport::handleAttribute(sal_uInt16 _nNamespaceKey, const OUString& _rLocalName, const OUString& _rValue) { - static const char * s_sEchoCharAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_ECHO_CHAR); + static const char * s_sEchoCharAttributeName = OAttributeMetaData::getSpecialAttributeName(SCAFlags::EchoChar); if (_rLocalName.equalsAscii(s_sEchoCharAttributeName)) { // need a special handling for the EchoChar property @@ -1333,7 +1333,7 @@ namespace xmloff bool OValueRangeImport::handleAttribute( sal_uInt16 _nNamespaceKey, const OUString& _rLocalName, const OUString& _rValue ) { - if ( _rLocalName.equalsAscii( OAttributeMetaData::getSpecialAttributeName( SCA_STEP_SIZE ) ) ) + if ( _rLocalName.equalsAscii( OAttributeMetaData::getSpecialAttributeName( SCAFlags::StepSize ) ) ) { ::sax::Converter::convertNumber( m_nStepSizeValue, _rValue ); return true; @@ -1577,7 +1577,7 @@ namespace xmloff // for the auto-completion // the attribute default does not equal the property default, so in case we did not read this attribute, // we have to simulate it - simulateDefaultedAttribute( OAttributeMetaData::getSpecialAttributeName( SCA_AUTOMATIC_COMPLETION ), PROPERTY_AUTOCOMPLETE, "false"); + simulateDefaultedAttribute( OAttributeMetaData::getSpecialAttributeName( SCAFlags::AutoCompletion ), PROPERTY_AUTOCOMPLETE, "false"); // same for the convert-empty-to-null attribute, which's default is different from the property default simulateDefaultedAttribute( OAttributeMetaData::getDatabaseAttributeName( DAFlags::ConvertEmpty ), PROPERTY_EMPTY_IS_NULL, "false"); diff --git a/xmloff/source/forms/formattributes.cxx b/xmloff/source/forms/formattributes.cxx index 4788a3b..aeed736 100644 --- a/xmloff/source/forms/formattributes.cxx +++ b/xmloff/source/forms/formattributes.cxx @@ -153,39 +153,40 @@ namespace xmloff return ""; } - const sal_Char* OAttributeMetaData::getSpecialAttributeName(sal_Int32 _nId) + const sal_Char* OAttributeMetaData::getSpecialAttributeName(SCAFlags _nId) { switch (_nId) { - case SCA_ECHO_CHAR: return "echo-char"; - case SCA_MAX_VALUE: return "max-value"; - case SCA_MIN_VALUE: return "min-value"; - case SCA_VALIDATION: return "validation"; - case SCA_GROUP_NAME: return "group-name"; - case SCA_MULTI_LINE: return "multi-line"; - case SCA_AUTOMATIC_COMPLETION: return "auto-complete"; - case SCA_MULTIPLE: return "multiple"; - case SCA_DEFAULT_BUTTON: return "default-button"; - case SCA_CURRENT_STATE: return "current-state"; - case SCA_IS_TRISTATE: return "is-tristate"; - case SCA_STATE: return "state"; - case SCA_COLUMN_STYLE_NAME: return "text-style-name"; - case SCA_STEP_SIZE: return "step-size"; - case SCA_PAGE_STEP_SIZE: return "page-step-size"; - case SCA_REPEAT_DELAY: return "delay-for-repeat"; - case SCA_TOGGLE: return "toggle"; - case SCA_FOCUS_ON_CLICK: return "focus-on-click"; + case SCAFlags::EchoChar: return "echo-char"; + case SCAFlags::MaxValue: return "max-value"; + case SCAFlags::MinValue: return "min-value"; + case SCAFlags::Validation: return "validation"; + case SCAFlags::GroupName: return "group-name"; + case SCAFlags::MultiLine: return "multi-line"; + case SCAFlags::AutoCompletion: return "auto-complete"; + case SCAFlags::Multiple: return "multiple"; + case SCAFlags::DefaultButton: return "default-button"; + case SCAFlags::CurrentState: return "current-state"; + case SCAFlags::IsTristate: return "is-tristate"; + case SCAFlags::State: return "state"; + case SCAFlags::ColumnStyleName: return "text-style-name"; + case SCAFlags::StepSize: return "step-size"; + case SCAFlags::PageStepSize: return "page-step-size"; + case SCAFlags::RepeatDelay: return "delay-for-repeat"; + case SCAFlags::Toggle: return "toggle"; + case SCAFlags::FocusOnClick: return "focus-on-click"; default: OSL_FAIL("OAttributeMetaData::getSpecialAttributeName: invalid id (maybe you or-ed two flags?)!"); } return ""; } - sal_uInt16 OAttributeMetaData::getSpecialAttributeNamespace(sal_Int32 _nId) + sal_uInt16 OAttributeMetaData::getSpecialAttributeNamespace(SCAFlags _nId) { switch( _nId ) { - case SCA_GROUP_NAME: return XML_NAMESPACE_FORMX; + case SCAFlags::GroupName: return XML_NAMESPACE_FORMX; + default: break; } return XML_NAMESPACE_FORM; } diff --git a/xmloff/source/forms/formattributes.hxx b/xmloff/source/forms/formattributes.hxx index 68048ba..d0a2405 100644 --- a/xmloff/source/forms/formattributes.hxx +++ b/xmloff/source/forms/formattributes.hxx @@ -106,6 +106,34 @@ namespace o3tl { template<> struct typed_flags<EAFlags> : is_typed_flags<EAFlags, 0x001f> {}; } + // any other attributes, which are special to some control types +enum class SCAFlags { + NONE = 0x000000, + EchoChar = 0x000001, + MaxValue = 0x000002, + MinValue = 0x000004, + Validation = 0x000008, + GroupName = 0x000010, + MultiLine = 0x000020, + AutoCompletion = 0x000080, + Multiple = 0x000100, + DefaultButton = 0x000200, + CurrentState = 0x000400, + IsTristate = 0x000800, + State = 0x001000, + ColumnStyleName = 0x002000, + StepSize = 0x004000, + PageStepSize = 0x008000, + RepeatDelay = 0x010000, + Toggle = 0x020000, + FocusOnClick = 0x040000, + ImagePosition = 0x080000 +}; +namespace o3tl { + template<> struct typed_flags<SCAFlags> : is_typed_flags<SCAFlags, 0x0fffff> {}; +} + + namespace xmloff { @@ -136,27 +164,6 @@ namespace xmloff faTabbingCycle }; - // any other attributes, which are special to some control types - #define SCA_ECHO_CHAR 0x00000001 - #define SCA_MAX_VALUE 0x00000002 - #define SCA_MIN_VALUE 0x00000004 - #define SCA_VALIDATION 0x00000008 - #define SCA_GROUP_NAME 0x00000010 - #define SCA_MULTI_LINE 0x00000020 - #define SCA_AUTOMATIC_COMPLETION 0x00000080 - #define SCA_MULTIPLE 0x00000100 - #define SCA_DEFAULT_BUTTON 0x00000200 - #define SCA_CURRENT_STATE 0x00000400 - #define SCA_IS_TRISTATE 0x00000800 - #define SCA_STATE 0x00001000 - #define SCA_COLUMN_STYLE_NAME 0x00002000 - #define SCA_STEP_SIZE 0x00004000 - #define SCA_PAGE_STEP_SIZE 0x00008000 - #define SCA_REPEAT_DELAY 0x00010000 - #define SCA_TOGGLE 0x00020000 - #define SCA_FOCUS_ON_CLICK 0x00040000 - #define SCA_IMAGE_POSITION 0x00080000 - // attributes of the office:forms element enum OfficeFormsAttributes { @@ -217,7 +224,7 @@ namespace xmloff @param _nId the id of the attribute. Has to be one of the SCA_* constants. */ - static const sal_Char* getSpecialAttributeName(sal_Int32 _nId); + static const sal_Char* getSpecialAttributeName(SCAFlags _nId); /** calculates the xml attribute representation of a binding attribute. @param _nId @@ -239,7 +246,7 @@ namespace xmloff @param _nId the id of the attribute. Has to be one of the SCA_* constants. */ - static sal_uInt16 getSpecialAttributeNamespace(sal_Int32 _nId); + static sal_uInt16 getSpecialAttributeNamespace(SCAFlags _nId); /** calculates the xml attribute representation of a attribute of the office:forms element @param _nId diff --git a/xmloff/source/forms/layerimport.cxx b/xmloff/source/forms/layerimport.cxx index afbd759..c25565e 100644 --- a/xmloff/source/forms/layerimport.cxx +++ b/xmloff/source/forms/layerimport.cxx @@ -78,7 +78,7 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter) m_aAttributeMetaData.addStringProperty( OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Name), PROPERTY_NAME); m_aAttributeMetaData.addStringProperty( - OAttributeMetaData::getSpecialAttributeName(SCA_GROUP_NAME), PROPERTY_GROUP_NAME); + OAttributeMetaData::getSpecialAttributeName(SCAFlags::GroupName), PROPERTY_GROUP_NAME); m_aAttributeMetaData.addStringProperty( OAttributeMetaData::getCommonControlAttributeName(CCAFlags::ImageData), PROPERTY_IMAGEURL); m_aAttributeMetaData.addStringProperty( @@ -133,17 +133,17 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter) m_aAttributeMetaData.addBooleanProperty( OAttributeMetaData::getDatabaseAttributeName(DAFlags::ConvertEmpty), PROPERTY_EMPTY_IS_NULL, false); m_aAttributeMetaData.addBooleanProperty( - OAttributeMetaData::getSpecialAttributeName(SCA_VALIDATION), PROPERTY_STRICTFORMAT, false); + OAttributeMetaData::getSpecialAttributeName(SCAFlags::Validation), PROPERTY_STRICTFORMAT, false); m_aAttributeMetaData.addBooleanProperty( - OAttributeMetaData::getSpecialAttributeName(SCA_MULTI_LINE), PROPERTY_MULTILINE, false); + OAttributeMetaData::getSpecialAttributeName(SCAFlags::MultiLine), PROPERTY_MULTILINE, false); m_aAttributeMetaData.addBooleanProperty( - OAttributeMetaData::getSpecialAttributeName(SCA_AUTOMATIC_COMPLETION), PROPERTY_AUTOCOMPLETE, false); + OAttributeMetaData::getSpecialAttributeName(SCAFlags::AutoCompletion), PROPERTY_AUTOCOMPLETE, false); m_aAttributeMetaData.addBooleanProperty( - OAttributeMetaData::getSpecialAttributeName(SCA_MULTIPLE), PROPERTY_MULTISELECTION, false); + OAttributeMetaData::getSpecialAttributeName(SCAFlags::Multiple), PROPERTY_MULTISELECTION, false); m_aAttributeMetaData.addBooleanProperty( - OAttributeMetaData::getSpecialAttributeName(SCA_DEFAULT_BUTTON), PROPERTY_DEFAULTBUTTON, false); + OAttributeMetaData::getSpecialAttributeName(SCAFlags::DefaultButton), PROPERTY_DEFAULTBUTTON, false); m_aAttributeMetaData.addBooleanProperty( - OAttributeMetaData::getSpecialAttributeName(SCA_IS_TRISTATE), PROPERTY_TRISTATE, false); + OAttributeMetaData::getSpecialAttributeName(SCAFlags::IsTristate), PROPERTY_TRISTATE, false); m_aAttributeMetaData.addBooleanProperty( OAttributeMetaData::getFormAttributeName(faAllowDeletes), PROPERTY_ALLOWDELETES, true); m_aAttributeMetaData.addBooleanProperty( @@ -157,9 +157,9 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter) m_aAttributeMetaData.addBooleanProperty( OAttributeMetaData::getFormAttributeName(faIgnoreResult), PROPERTY_IGNORERESULT, false); m_aAttributeMetaData.addBooleanProperty( - OAttributeMetaData::getSpecialAttributeName( SCA_TOGGLE ), PROPERTY_TOGGLE, false ); + OAttributeMetaData::getSpecialAttributeName( SCAFlags::Toggle ), PROPERTY_TOGGLE, false ); m_aAttributeMetaData.addBooleanProperty( - OAttributeMetaData::getSpecialAttributeName( SCA_FOCUS_ON_CLICK ), PROPERTY_FOCUS_ON_CLICK, true ); + OAttributeMetaData::getSpecialAttributeName( SCAFlags::FocusOnClick ), PROPERTY_FOCUS_ON_CLICK, true ); m_aAttributeMetaData.addBooleanProperty( OAttributeMetaData::getDatabaseAttributeName( DAFlags::InputRequired ), PROPERTY_INPUT_REQUIRED, false ); @@ -175,7 +175,7 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter) // the int32 attributes m_aAttributeMetaData.addInt32Property( - OAttributeMetaData::getSpecialAttributeName( SCA_PAGE_STEP_SIZE ), PROPERTY_BLOCK_INCREMENT, 10 ); + OAttributeMetaData::getSpecialAttributeName( SCAFlags::PageStepSize ), PROPERTY_BLOCK_INCREMENT, 10 ); // the enum attributes m_aAttributeMetaData.addEnumProperty( @@ -195,11 +195,11 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter) ListSourceType_VALUELIST, OEnumMapper::getEnumMap(OEnumMapper::epListSourceType), &::cppu::UnoType<ListSourceType>::get()); m_aAttributeMetaData.addEnumProperty( - OAttributeMetaData::getSpecialAttributeName(SCA_STATE), PROPERTY_DEFAULT_STATE, TRISTATE_FALSE, + OAttributeMetaData::getSpecialAttributeName(SCAFlags::State), PROPERTY_DEFAULT_STATE, TRISTATE_FALSE, OEnumMapper::getEnumMap(OEnumMapper::epCheckState), &::cppu::UnoType<sal_Int16>::get()); m_aAttributeMetaData.addEnumProperty( - OAttributeMetaData::getSpecialAttributeName(SCA_CURRENT_STATE), PROPERTY_STATE, TRISTATE_FALSE, + OAttributeMetaData::getSpecialAttributeName(SCAFlags::CurrentState), PROPERTY_STATE, TRISTATE_FALSE, OEnumMapper::getEnumMap(OEnumMapper::epCheckState), &::cppu::UnoType<sal_Int16>::get()); m_aAttributeMetaData.addEnumProperty( commit aba06d6f8d69632559ca9a74320fcd048855a3a3 Author: Noel Grandin <[email protected]> Date: Thu May 12 14:23:44 2016 +0200 Convert EA flags to scoped enum Change-Id: I7fbd4cea13fc311624804f7acd9dd66955b860d3 diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index 844ed2e..abd6e50 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -237,7 +237,7 @@ namespace xmloff ,m_nIncludeCommon(CCAFlags::NONE) ,m_nIncludeDatabase(DAFlags::NONE) ,m_nIncludeSpecial(0) - ,m_nIncludeEvents(0) + ,m_nIncludeEvents(EAFlags::NONE) ,m_nIncludeBindings(BAFlags::NONE) ,m_pOuterElement(nullptr) { @@ -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 == BAFlags::NONE), + && ( m_nIncludeEvents == EAFlags::NONE ) && ( 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 @@ -1530,7 +1530,7 @@ namespace xmloff m_nIncludeDatabase = DAFlags::DataField | DAFlags::InputRequired; // event attributes - m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT; + m_nIncludeEvents = EAFlags::ControlEvents | EAFlags::OnChange | EAFlags::OnSelect; // only text and pattern fields have a ConvertEmptyToNull property if ( ( m_nClassId == FormComponentType::TEXTFIELD ) @@ -1574,7 +1574,7 @@ namespace xmloff CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::CurrentValue | CCAFlags::Disabled | CCAFlags::Printable | CCAFlags::TabIndex | CCAFlags::TabStop | CCAFlags::Title | CCAFlags::Value; - m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT; + m_nIncludeEvents = EAFlags::ControlEvents | EAFlags::OnChange | EAFlags::OnSelect; break; case FormComponentType::FIXEDTEXT: @@ -1583,7 +1583,7 @@ namespace xmloff CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::Disabled | CCAFlags::Label | CCAFlags::Printable | CCAFlags::Title | CCAFlags::For; m_nIncludeSpecial = SCA_MULTI_LINE; - m_nIncludeEvents = EA_CONTROL_EVENTS; + m_nIncludeEvents = EAFlags::ControlEvents; break; case FormComponentType::COMBOBOX: @@ -1594,7 +1594,7 @@ namespace xmloff CCAFlags::TabIndex | CCAFlags::TabStop | CCAFlags::Title | CCAFlags::Value; m_nIncludeSpecial = SCA_AUTOMATIC_COMPLETION; m_nIncludeDatabase = DAFlags::ConvertEmpty | DAFlags::DataField | DAFlags::InputRequired | DAFlags::ListSource | DAFlags::ListSource_TYPE; - m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT; + m_nIncludeEvents = EAFlags::ControlEvents | EAFlags::OnChange | EAFlags::OnSelect; break; case FormComponentType::LISTBOX: @@ -1604,7 +1604,7 @@ namespace xmloff CCAFlags::Printable | CCAFlags::Size | CCAFlags::TabIndex | CCAFlags::TabStop | CCAFlags::Title; m_nIncludeSpecial = SCA_MULTIPLE; m_nIncludeDatabase = DAFlags::BoundColumn | DAFlags::DataField | DAFlags::InputRequired | DAFlags::ListSource_TYPE; - m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_CLICK | EA_ON_DBLCLICK; + m_nIncludeEvents = EAFlags::ControlEvents | EAFlags::OnChange | EAFlags::OnClick | EAFlags::OnDoubleClick; // check if we need to export the ListSource as attribute { // for a list box, if the ListSourceType is VALUE_LIST, no ListSource is stored, but instead @@ -1636,7 +1636,7 @@ namespace xmloff CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::ButtonType | CCAFlags::Disabled | CCAFlags::ImageData | CCAFlags::Printable | CCAFlags::TabIndex | CCAFlags::TargetFrame | CCAFlags::TargetLocation | CCAFlags::Title; - m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CLICK | EA_ON_DBLCLICK; + m_nIncludeEvents = EAFlags::ControlEvents | EAFlags::OnClick | EAFlags::OnDoubleClick; break; case FormComponentType::CHECKBOX: @@ -1657,7 +1657,7 @@ namespace xmloff if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_GROUP_NAME ) ) m_nIncludeSpecial |= SCA_GROUP_NAME; m_nIncludeDatabase = DAFlags::DataField | DAFlags::InputRequired; - m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE; + m_nIncludeEvents = EAFlags::ControlEvents | EAFlags::OnChange; break; case FormComponentType::GROUPBOX: @@ -1665,7 +1665,7 @@ namespace xmloff m_nIncludeCommon = CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::Disabled | CCAFlags::Label | CCAFlags::Printable | CCAFlags::Title | CCAFlags::For; - m_nIncludeEvents = EA_CONTROL_EVENTS; + m_nIncludeEvents = EAFlags::ControlEvents; break; case FormComponentType::IMAGECONTROL: @@ -1674,7 +1674,7 @@ namespace xmloff CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::Disabled | CCAFlags::ImageData | CCAFlags::Printable | CCAFlags::ReadOnly | CCAFlags::Title; m_nIncludeDatabase = DAFlags::DataField | DAFlags::InputRequired; - m_nIncludeEvents = EA_CONTROL_EVENTS; + m_nIncludeEvents = EAFlags::ControlEvents; break; case FormComponentType::HIDDENCONTROL: @@ -1688,7 +1688,7 @@ namespace xmloff m_nIncludeCommon = CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::Disabled | CCAFlags::Printable | CCAFlags::TabIndex | CCAFlags::TabStop | CCAFlags::Title; - m_nIncludeEvents = EA_CONTROL_EVENTS; + m_nIncludeEvents = EAFlags::ControlEvents; break; case FormComponentType::SCROLLBAR: @@ -1702,7 +1702,7 @@ namespace xmloff if ( m_nClassId == FormComponentType::SCROLLBAR ) m_nIncludeSpecial |= SCA_PAGE_STEP_SIZE ; - m_nIncludeEvents = EA_CONTROL_EVENTS; + m_nIncludeEvents = EAFlags::ControlEvents; break; default: @@ -1720,7 +1720,7 @@ namespace xmloff // at least a name should be there, 'cause without a name the control could never have been // inserted into its parent container // In addition, the service name is absolutely necessary to create the control upon reading. - m_nIncludeEvents = EA_CONTROL_EVENTS; + m_nIncludeEvents = EAFlags::ControlEvents; // we always should be able to export events - this is not control type dependent break; } diff --git a/xmloff/source/forms/elementexport.hxx b/xmloff/source/forms/elementexport.hxx index 0ef7b94..da7123d 100644 --- a/xmloff/source/forms/elementexport.hxx +++ b/xmloff/source/forms/elementexport.hxx @@ -97,7 +97,7 @@ namespace xmloff CCAFlags m_nIncludeCommon; // common control attributes to include DAFlags m_nIncludeDatabase; // common database attributes to include sal_Int32 m_nIncludeSpecial; // special attributes to include - sal_Int32 m_nIncludeEvents; // events to include + EAFlags m_nIncludeEvents; // events 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/formattributes.hxx b/xmloff/source/forms/formattributes.hxx index 5412e28..68048ba 100644 --- a/xmloff/source/forms/formattributes.hxx +++ b/xmloff/source/forms/formattributes.hxx @@ -93,17 +93,22 @@ namespace o3tl { template<> struct typed_flags<BAFlags> : is_typed_flags<BAFlags, 0x003f> {}; } + // flags for event attributes +enum class EAFlags { + NONE = 0x0000, + ControlEvents = 0x0001, + OnChange = 0x0002, + OnClick = 0x0004, + OnDoubleClick = 0x0008, + OnSelect = 0x0010 +}; +namespace o3tl { + template<> struct typed_flags<EAFlags> : is_typed_flags<EAFlags, 0x001f> {}; +} namespace xmloff { - // flags for event attributes - #define EA_CONTROL_EVENTS 0x00000001 - #define EA_ON_CHANGE 0x00000002 - #define EA_ON_CLICK 0x00000004 - #define EA_ON_DBLCLICK 0x00000008 - #define EA_ON_SELECT 0x00000010 - /// attributes in the xml tag representing a form enum FormAttributes { commit 5b6b61b00bc850c58046cfdb59e4a919e55edab7 Author: Noel Grandin <[email protected]> Date: Thu May 12 14:18:30 2016 +0200 Convert BA flags to scoped enum Change-Id: I22a6f41091d69ad4ed91a745e9b7cbcebd9fad55 diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index cd9b82e..844ed2e 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 3423de0..0ef7b94 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 22fe2f1..32cd55a 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 b13cd7c..4788a3b 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 48be949..5412e28 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; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
