summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-05-12 14:12:29 +0200
committerNoel Grandin <noel@peralex.com>2016-05-12 14:13:04 +0200
commit0dc0f9733f2c83ec350aa9f04a4b31d66ab97284 (patch)
tree629f83051f192284c06158dd9a58d77e0eef7c87 /xmloff
parentf7b3cef45b26321f76ec24e5fd027b1c096d3118 (diff)
Convert DA flags to scoped enum
Change-Id: Iabbf4b32a1b5b47e6cfe791a15f111918d5bd3a9
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/forms/elementexport.cxx74
-rw-r--r--xmloff/source/forms/elementexport.hxx2
-rw-r--r--xmloff/source/forms/elementimport.cxx6
-rw-r--r--xmloff/source/forms/formattributes.cxx14
-rw-r--r--xmloff/source/forms/formattributes.hxx26
-rw-r--r--xmloff/source/forms/layerimport.cxx10
6 files changed, 69 insertions, 63 deletions
diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx
index 2aa81cfed7e4..cd9b82eccb20 100644
--- a/xmloff/source/forms/elementexport.cxx
+++ b/xmloff/source/forms/elementexport.cxx
@@ -235,7 +235,7 @@ namespace xmloff
,m_nClassId(FormComponentType::CONTROL)
,m_eType( UNKNOWN )
,m_nIncludeCommon(CCAFlags::NONE)
- ,m_nIncludeDatabase(0)
+ ,m_nIncludeDatabase(DAFlags::NONE)
,m_nIncludeSpecial(0)
,m_nIncludeEvents(0)
,m_nIncludeBindings(0)
@@ -824,75 +824,75 @@ namespace xmloff
void OControlExport::exportDatabaseAttributes()
{
#if OSL_DEBUG_LEVEL > 0
- sal_Int32 nIncludeDatabase = m_nIncludeDatabase;
+ DAFlags nIncludeDatabase = m_nIncludeDatabase;
#endif
// the only string property: DataField
- if (DA_DATA_FIELD & m_nIncludeDatabase)
+ if (DAFlags::DataField & m_nIncludeDatabase)
{
exportStringPropertyAttribute(
- OAttributeMetaData::getDatabaseAttributeNamespace(DA_DATA_FIELD),
- OAttributeMetaData::getDatabaseAttributeName(DA_DATA_FIELD),
+ OAttributeMetaData::getDatabaseAttributeNamespace(DAFlags::DataField),
+ OAttributeMetaData::getDatabaseAttributeName(DAFlags::DataField),
PROPERTY_DATAFIELD);
- RESET_BIT( nIncludeDatabase, DA_DATA_FIELD );
+ RESET_BIT( nIncludeDatabase, DAFlags::DataField );
}
// InputRequired
- if ( DA_INPUT_REQUIRED & m_nIncludeDatabase )
+ if ( DAFlags::InputRequired & m_nIncludeDatabase )
{
exportBooleanPropertyAttribute(
- OAttributeMetaData::getDatabaseAttributeNamespace( DA_INPUT_REQUIRED ),
- OAttributeMetaData::getDatabaseAttributeName( DA_INPUT_REQUIRED ),
+ OAttributeMetaData::getDatabaseAttributeNamespace( DAFlags::InputRequired ),
+ OAttributeMetaData::getDatabaseAttributeName( DAFlags::InputRequired ),
PROPERTY_INPUT_REQUIRED,
BoolAttrFlags::DefaultTrue
);
- RESET_BIT( nIncludeDatabase, DA_INPUT_REQUIRED );
+ RESET_BIT( nIncludeDatabase, DAFlags::InputRequired );
}
// the only int16 property: BoundColumn
- if (DA_BOUND_COLUMN & m_nIncludeDatabase)
+ if (DAFlags::BoundColumn & m_nIncludeDatabase)
{
exportInt16PropertyAttribute(
- OAttributeMetaData::getDatabaseAttributeNamespace(DA_BOUND_COLUMN),
- OAttributeMetaData::getDatabaseAttributeName(DA_BOUND_COLUMN),
+ OAttributeMetaData::getDatabaseAttributeNamespace(DAFlags::BoundColumn),
+ OAttributeMetaData::getDatabaseAttributeName(DAFlags::BoundColumn),
PROPERTY_BOUNDCOLUMN,
0,
true);
- RESET_BIT( nIncludeDatabase, DA_BOUND_COLUMN );
+ RESET_BIT( nIncludeDatabase, DAFlags::BoundColumn );
}
// ConvertEmptyToNull
- if (DA_CONVERT_EMPTY & m_nIncludeDatabase)
+ if (DAFlags::ConvertEmpty & m_nIncludeDatabase)
{
exportBooleanPropertyAttribute(
- OAttributeMetaData::getDatabaseAttributeNamespace(DA_CONVERT_EMPTY),
- OAttributeMetaData::getDatabaseAttributeName(DA_CONVERT_EMPTY),
+ OAttributeMetaData::getDatabaseAttributeNamespace(DAFlags::ConvertEmpty),
+ OAttributeMetaData::getDatabaseAttributeName(DAFlags::ConvertEmpty),
PROPERTY_EMPTY_IS_NULL,
BoolAttrFlags::DefaultFalse
);
- RESET_BIT( nIncludeDatabase, DA_CONVERT_EMPTY );
+ RESET_BIT( nIncludeDatabase, DAFlags::ConvertEmpty );
}
// the only enum property: ListSourceType
- if (DA_LIST_SOURCE_TYPE & m_nIncludeDatabase)
+ if (DAFlags::ListSource_TYPE & m_nIncludeDatabase)
{
exportEnumPropertyAttribute(
- OAttributeMetaData::getDatabaseAttributeNamespace(DA_LIST_SOURCE_TYPE),
- OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE_TYPE),
+ OAttributeMetaData::getDatabaseAttributeNamespace(DAFlags::ListSource_TYPE),
+ OAttributeMetaData::getDatabaseAttributeName(DAFlags::ListSource_TYPE),
PROPERTY_LISTSOURCETYPE,
OEnumMapper::getEnumMap(OEnumMapper::epListSourceType),
ListSourceType_VALUELIST
);
- RESET_BIT( nIncludeDatabase, DA_LIST_SOURCE_TYPE );
+ RESET_BIT( nIncludeDatabase, DAFlags::ListSource_TYPE );
}
- if (m_nIncludeDatabase & DA_LIST_SOURCE)
+ if (m_nIncludeDatabase & DAFlags::ListSource)
{
exportListSourceAsAttribute();
- RESET_BIT( nIncludeDatabase, DA_LIST_SOURCE );
+ RESET_BIT( nIncludeDatabase, DAFlags::ListSource );
}
#if OSL_DEBUG_LEVEL > 0
- OSL_ENSURE(0 == nIncludeDatabase,
+ OSL_ENSURE(DAFlags::NONE == nIncludeDatabase,
"OControlExport::exportDatabaseAttributes: 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 ...
@@ -1250,15 +1250,15 @@ namespace xmloff
void OControlExport::exportListSourceAsAttribute()
{
- // DA_LIST_SOURCE needs some special handling
+ // DAFlags::ListSource needs some special handling
DBG_CHECK_PROPERTY_NO_TYPE( PROPERTY_LISTSOURCE );
OUString sListSource = getScalarListSourceValue();
if ( !sListSource.isEmpty() )
{ // the ListSource property needs to be exported as attribute, and it is not empty
AddAttribute(
- OAttributeMetaData::getDatabaseAttributeNamespace(DA_LIST_SOURCE),
- OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE),
+ OAttributeMetaData::getDatabaseAttributeNamespace(DAFlags::ListSource),
+ OAttributeMetaData::getDatabaseAttributeName(DAFlags::ListSource),
sListSource);
}
@@ -1284,7 +1284,7 @@ namespace xmloff
m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aItems;
DBG_CHECK_PROPERTY( PROPERTY_LISTSOURCE, Sequence< OUString > );
- if ( 0 == ( m_nIncludeDatabase & DA_LIST_SOURCE ) )
+ if ( DAFlags::NONE == ( m_nIncludeDatabase & DAFlags::ListSource ) )
m_xProps->getPropertyValue(PROPERTY_LISTSOURCE) >>= aValues;
// if we exported the list source as attribute, we do not repeat it as sub elements
@@ -1440,7 +1440,7 @@ namespace xmloff
void OControlExport::examine()
{
- OSL_ENSURE( ( m_nIncludeCommon == CCAFlags::NONE ) && ( m_nIncludeSpecial == 0 ) && ( m_nIncludeDatabase == 0 )
+ OSL_ENSURE( ( m_nIncludeCommon == CCAFlags::NONE ) && ( m_nIncludeSpecial == 0 ) && ( m_nIncludeDatabase == DAFlags::NONE )
&& ( m_nIncludeEvents == 0 ) && ( m_nIncludeBindings == 0),
"OControlExport::examine: called me twice? Not initialized?" );
@@ -1527,7 +1527,7 @@ namespace xmloff
m_nIncludeCommon |= CCAFlags::Value;
// database attributes
- m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
+ m_nIncludeDatabase = DAFlags::DataField | DAFlags::InputRequired;
// event attributes
m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT;
@@ -1536,7 +1536,7 @@ namespace xmloff
if ( ( m_nClassId == FormComponentType::TEXTFIELD )
|| ( m_nClassId == FormComponentType::PATTERNFIELD )
)
- m_nIncludeDatabase |= DA_CONVERT_EMPTY;
+ m_nIncludeDatabase |= DAFlags::ConvertEmpty;
// all controls but the file control fields have a readonly property
if ( m_nClassId != FormComponentType::FILECONTROL )
@@ -1593,7 +1593,7 @@ namespace xmloff
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_nIncludeDatabase = DA_CONVERT_EMPTY | DA_DATA_FIELD | DA_INPUT_REQUIRED | DA_LIST_SOURCE | DA_LIST_SOURCE_TYPE;
+ m_nIncludeDatabase = DAFlags::ConvertEmpty | DAFlags::DataField | DAFlags::InputRequired | DAFlags::ListSource | DAFlags::ListSource_TYPE;
m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE | EA_ON_SELECT;
break;
@@ -1603,7 +1603,7 @@ namespace xmloff
CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::Disabled | CCAFlags::Dropdown |
CCAFlags::Printable | CCAFlags::Size | CCAFlags::TabIndex | CCAFlags::TabStop | CCAFlags::Title;
m_nIncludeSpecial = SCA_MULTIPLE;
- m_nIncludeDatabase = DA_BOUND_COLUMN | DA_DATA_FIELD | DA_INPUT_REQUIRED | DA_LIST_SOURCE_TYPE;
+ 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;
// check if we need to export the ListSource as attribute
{
@@ -1615,7 +1615,7 @@ namespace xmloff
OSL_ENSURE(bSuccess, "OControlExport::examineControl: could not retrieve the ListSourceType!");
if (ListSourceType_VALUELIST != eListSourceType)
{
- m_nIncludeDatabase |= DA_LIST_SOURCE;
+ m_nIncludeDatabase |= DAFlags::ListSource;
}
}
@@ -1656,7 +1656,7 @@ namespace xmloff
m_nIncludeSpecial |= SCA_IMAGE_POSITION;
if ( m_xPropertyInfo->hasPropertyByName( PROPERTY_GROUP_NAME ) )
m_nIncludeSpecial |= SCA_GROUP_NAME;
- m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
+ m_nIncludeDatabase = DAFlags::DataField | DAFlags::InputRequired;
m_nIncludeEvents = EA_CONTROL_EVENTS | EA_ON_CHANGE;
break;
@@ -1673,7 +1673,7 @@ namespace xmloff
m_nIncludeCommon =
CCAFlags::Name | CCAFlags::ServiceName | CCAFlags::Disabled | CCAFlags::ImageData |
CCAFlags::Printable | CCAFlags::ReadOnly | CCAFlags::Title;
- m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED;
+ m_nIncludeDatabase = DAFlags::DataField | DAFlags::InputRequired;
m_nIncludeEvents = EA_CONTROL_EVENTS;
break;
diff --git a/xmloff/source/forms/elementexport.hxx b/xmloff/source/forms/elementexport.hxx
index 07552b574375..3423de083104 100644
--- a/xmloff/source/forms/elementexport.hxx
+++ b/xmloff/source/forms/elementexport.hxx
@@ -95,7 +95,7 @@ namespace xmloff
sal_Int16 m_nClassId; // class id of the control we're representing
ElementType m_eType; // (XML) type of the control we're representing
CCAFlags m_nIncludeCommon; // common control attributes to include
- sal_Int32 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_nIncludeEvents; // events to include
sal_Int32 m_nIncludeBindings; // binding attributes to include
diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx
index a43359aac1ec..22fe2f14e037 100644
--- a/xmloff/source/forms/elementimport.cxx
+++ b/xmloff/source/forms/elementimport.cxx
@@ -1413,7 +1413,7 @@ namespace xmloff
// same XML element), though not all of them know this property.
// So we have to do a check ...
if (m_xElement.is() && m_xInfo.is() && m_xInfo->hasPropertyByName(PROPERTY_EMPTY_IS_NULL) )
- simulateDefaultedAttribute(OAttributeMetaData::getDatabaseAttributeName(DA_CONVERT_EMPTY), PROPERTY_EMPTY_IS_NULL, "false");
+ simulateDefaultedAttribute(OAttributeMetaData::getDatabaseAttributeName(DAFlags::ConvertEmpty), PROPERTY_EMPTY_IS_NULL, "false");
}
struct EqualHandle : public ::std::unary_function< PropertyValue, bool >
@@ -1580,7 +1580,7 @@ namespace xmloff
simulateDefaultedAttribute( OAttributeMetaData::getSpecialAttributeName( SCA_AUTOMATIC_COMPLETION ), PROPERTY_AUTOCOMPLETE, "false");
// same for the convert-empty-to-null attribute, which's default is different from the property default
- simulateDefaultedAttribute( OAttributeMetaData::getDatabaseAttributeName( DA_CONVERT_EMPTY ), PROPERTY_EMPTY_IS_NULL, "false");
+ simulateDefaultedAttribute( OAttributeMetaData::getDatabaseAttributeName( DAFlags::ConvertEmpty ), PROPERTY_EMPTY_IS_NULL, "false");
}
}
@@ -1644,7 +1644,7 @@ namespace xmloff
bool OListAndComboImport::handleAttribute(sal_uInt16 _nNamespaceKey, const OUString& _rLocalName, const OUString& _rValue)
{
- static const sal_Char* pListSourceAttributeName = OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE);
+ static const sal_Char* pListSourceAttributeName = OAttributeMetaData::getDatabaseAttributeName(DAFlags::ListSource);
if ( _rLocalName.equalsAscii(pListSourceAttributeName) )
{
PropertyValue aListSource;
diff --git a/xmloff/source/forms/formattributes.cxx b/xmloff/source/forms/formattributes.cxx
index 22e226f671ea..b13cd7c80e8f 100644
--- a/xmloff/source/forms/formattributes.cxx
+++ b/xmloff/source/forms/formattributes.cxx
@@ -124,16 +124,16 @@ namespace xmloff
return XML_NAMESPACE_FORM;
}
- const sal_Char* OAttributeMetaData::getDatabaseAttributeName(sal_Int32 _nId)
+ const sal_Char* OAttributeMetaData::getDatabaseAttributeName(DAFlags _nId)
{
switch (_nId)
{
- case DA_BOUND_COLUMN: return "bound-column";
- case DA_CONVERT_EMPTY: return "convert-empty-to-null";
- case DA_DATA_FIELD: return "data-field";
- case DA_LIST_SOURCE: return "list-source";
- case DA_LIST_SOURCE_TYPE: return "list-source-type";
- case DA_INPUT_REQUIRED: return "input-required";
+ case DAFlags::BoundColumn: return "bound-column";
+ case DAFlags::ConvertEmpty: return "convert-empty-to-null";
+ case DAFlags::DataField: return "data-field";
+ case DAFlags::ListSource: return "list-source";
+ case DAFlags::ListSource_TYPE: return "list-source-type";
+ case DAFlags::InputRequired: return "input-required";
default:
OSL_FAIL("OAttributeMetaData::getDatabaseAttributeName: invalid id (maybe you or-ed two flags?)!");
}
diff --git a/xmloff/source/forms/formattributes.hxx b/xmloff/source/forms/formattributes.hxx
index f89d25e37fa0..48be949b0493 100644
--- a/xmloff/source/forms/formattributes.hxx
+++ b/xmloff/source/forms/formattributes.hxx
@@ -65,17 +65,23 @@ namespace o3tl {
template<> struct typed_flags<CCAFlags> : is_typed_flags<CCAFlags, 0x01ffffff> {};
}
+ // flags for database control attributes
+enum class DAFlags {
+ NONE = 0x0000,
+ BoundColumn = 0x0001,
+ ConvertEmpty = 0x0002,
+ DataField = 0x0004,
+ ListSource = 0x0008,
+ ListSource_TYPE = 0x0010,
+ InputRequired = 0x0020,
+};
+namespace o3tl {
+ template<> struct typed_flags<DAFlags> : is_typed_flags<DAFlags, 0x003f> {};
+}
+
namespace xmloff
{
- // flags for database control attributes
- #define DA_BOUND_COLUMN 0x00000001
- #define DA_CONVERT_EMPTY 0x00000002
- #define DA_DATA_FIELD 0x00000004
- #define DA_LIST_SOURCE 0x00000008
- #define DA_LIST_SOURCE_TYPE 0x00000010
- #define DA_INPUT_REQUIRED 0x00000020
-
// flags for binding related control attributes
#define BA_LINKED_CELL 0x00000001
#define BA_LIST_LINKING_TYPE 0x00000002
@@ -183,13 +189,13 @@ namespace xmloff
@param _nId
the id of the attribute. Has to be one of the DA_* constants.
*/
- static const sal_Char* getDatabaseAttributeName(sal_Int32 _nId);
+ static const sal_Char* getDatabaseAttributeName(DAFlags _nId);
/** calculates the xml namespace key to use for a database attribute.
@param _nId
the id of the attribute. Has to be one of the DA_* constants.
*/
- static inline sal_uInt16 getDatabaseAttributeNamespace(sal_Int32 )
+ static inline sal_uInt16 getDatabaseAttributeNamespace(DAFlags )
{
// nothing special here
return XML_NAMESPACE_FORM;
diff --git a/xmloff/source/forms/layerimport.cxx b/xmloff/source/forms/layerimport.cxx
index ad9d8e86179f..afbd759e4e8f 100644
--- a/xmloff/source/forms/layerimport.cxx
+++ b/xmloff/source/forms/layerimport.cxx
@@ -90,7 +90,7 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter)
m_aAttributeMetaData.addStringProperty(
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::TargetFrame), PROPERTY_TARGETFRAME, "_blank");
m_aAttributeMetaData.addStringProperty(
- OAttributeMetaData::getDatabaseAttributeName(DA_DATA_FIELD), PROPERTY_DATAFIELD);
+ OAttributeMetaData::getDatabaseAttributeName(DAFlags::DataField), PROPERTY_DATAFIELD);
m_aAttributeMetaData.addStringProperty(
OAttributeMetaData::getFormAttributeName(faCommand), PROPERTY_COMMAND);
m_aAttributeMetaData.addStringProperty(
@@ -131,7 +131,7 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter)
m_aAttributeMetaData.addBooleanProperty(
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::TabStop), PROPERTY_TABSTOP, true);
m_aAttributeMetaData.addBooleanProperty(
- OAttributeMetaData::getDatabaseAttributeName(DA_CONVERT_EMPTY), PROPERTY_EMPTY_IS_NULL, false);
+ OAttributeMetaData::getDatabaseAttributeName(DAFlags::ConvertEmpty), PROPERTY_EMPTY_IS_NULL, false);
m_aAttributeMetaData.addBooleanProperty(
OAttributeMetaData::getSpecialAttributeName(SCA_VALIDATION), PROPERTY_STRICTFORMAT, false);
m_aAttributeMetaData.addBooleanProperty(
@@ -161,7 +161,7 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter)
m_aAttributeMetaData.addBooleanProperty(
OAttributeMetaData::getSpecialAttributeName( SCA_FOCUS_ON_CLICK ), PROPERTY_FOCUS_ON_CLICK, true );
m_aAttributeMetaData.addBooleanProperty(
- OAttributeMetaData::getDatabaseAttributeName( DA_INPUT_REQUIRED ), PROPERTY_INPUT_REQUIRED, false );
+ OAttributeMetaData::getDatabaseAttributeName( DAFlags::InputRequired ), PROPERTY_INPUT_REQUIRED, false );
// the int16 attributes
m_aAttributeMetaData.addInt16Property(
@@ -171,7 +171,7 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter)
m_aAttributeMetaData.addInt16Property(
OAttributeMetaData::getCommonControlAttributeName(CCAFlags::TabIndex), PROPERTY_TABINDEX, 0);
m_aAttributeMetaData.addInt16Property(
- OAttributeMetaData::getDatabaseAttributeName(DA_BOUND_COLUMN), PROPERTY_BOUNDCOLUMN, 0);
+ OAttributeMetaData::getDatabaseAttributeName(DAFlags::BoundColumn), PROPERTY_BOUNDCOLUMN, 0);
// the int32 attributes
m_aAttributeMetaData.addInt32Property(
@@ -191,7 +191,7 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter)
FormButtonType_PUSH, OEnumMapper::getEnumMap(OEnumMapper::epButtonType),
&::cppu::UnoType<FormButtonType>::get());
m_aAttributeMetaData.addEnumProperty(
- OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE_TYPE), PROPERTY_LISTSOURCETYPE,
+ OAttributeMetaData::getDatabaseAttributeName(DAFlags::ListSource_TYPE), PROPERTY_LISTSOURCETYPE,
ListSourceType_VALUELIST, OEnumMapper::getEnumMap(OEnumMapper::epListSourceType),
&::cppu::UnoType<ListSourceType>::get());
m_aAttributeMetaData.addEnumProperty(