Kaydet (Commit) 0c2d51e0 authored tarafından Noel Grandin's avatar Noel Grandin

Convert SCA flags to scoped enum

Change-Id: I761022dd78f6c1d19cf4f2650a5ac7b2212c11c3
üst aba06d6f
......@@ -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
......
......@@ -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");
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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(
......
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