summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/misc/dsmeta.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/misc/dsmeta.cxx')
-rw-r--r--dbaccess/source/ui/misc/dsmeta.cxx177
1 files changed, 64 insertions, 113 deletions
diff --git a/dbaccess/source/ui/misc/dsmeta.cxx b/dbaccess/source/ui/misc/dsmeta.cxx
index b152f12688e2..7d299c7f5910 100644
--- a/dbaccess/source/ui/misc/dsmeta.cxx
+++ b/dbaccess/source/ui/misc/dsmeta.cxx
@@ -47,32 +47,6 @@ namespace dbaui
using namespace ::com::sun::star;
/** === end UNO using === **/
- struct InitAdvanced : public AdvancedSettingsSupport
- {
- enum Special { All, AllButIgnoreCurrency, None };
-
- InitAdvanced( Special _eType )
- :AdvancedSettingsSupport()
- {
- bGeneratedValues = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bUseSQL92NamingConstraints = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bAppendTableAliasInSelect = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bUseKeywordAsBeforeAlias = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bUseBracketedOuterJoinSyntax = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bIgnoreDriverPrivileges = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bParameterNameSubstitution = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bDisplayVersionColumns = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bUseCatalogInSelect = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bUseSchemaInSelect = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bUseIndexDirectionKeyword = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bUseDOSLineEnds = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bBooleanComparisonMode = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bFormsCheckRequiredFields = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- bIgnoreCurrency = ( _eType == All );
- bEscapeDateTime = ( _eType == All ) || ( _eType == AllButIgnoreCurrency );
- }
- };
-
struct FeatureSupport
{
// authentication mode of the data source
@@ -89,98 +63,75 @@ namespace dbaui
}
};
+ struct FeatureMapping
+ {
+ /// one of the items from dsitems.hxx
+ ItemID nItemID;
+ const sal_Char* pAsciiFeatureName;
+ };
+
//====================================================================
//= global tables
//====================================================================
//--------------------------------------------------------------------
- static const AdvancedSettingsSupport& getAdvancedSettingsSupport( const ::rtl::OUString& _sURL )
+ static const FeatureMapping* lcl_getFeatureMappings()
{
- DECLARE_STL_USTRINGACCESS_MAP( AdvancedSettingsSupport, AdvancedSupport);
- static AdvancedSupport s_aSupport;
- if ( s_aSupport.empty() )
+ static const FeatureMapping s_aMappings[] = {
+ { DSID_AUTORETRIEVEENABLED, "GeneratedValues" },
+ { DSID_AUTOINCREMENTVALUE, "GeneratedValues" },
+ { DSID_AUTORETRIEVEVALUE, "GeneratedValues" },
+ { DSID_SQL92CHECK, "UseSQL92NamingConstraints" },
+ { DSID_APPEND_TABLE_ALIAS, "AppendTableAliasInSelect" },
+ { DSID_AS_BEFORE_CORRNAME, "UseKeywordAsBeforeAlias" },
+ { DSID_ENABLEOUTERJOIN, "UseBracketedOuterJoinSyntax" },
+ { DSID_IGNOREDRIVER_PRIV, "IgnoreDriverPrivileges" },
+ { DSID_PARAMETERNAMESUBST, "ParameterNameSubstitution" },
+ { DSID_SUPPRESSVERSIONCL, "DisplayVersionColumns" },
+ { DSID_CATALOG, "UseCatalogInSelect" },
+ { DSID_SCHEMA, "UseSchemaInSelect" },
+ { DSID_INDEXAPPENDIX, "UseIndexDirectionKeyword" },
+ { DSID_DOSLINEENDS, "UseDOSLineEnds" },
+ { DSID_BOOLEANCOMPARISON, "BooleanComparisonMode" },
+ { DSID_CHECK_REQUIRED_FIELDS, "FormsCheckRequiredFields" },
+ { DSID_IGNORECURRENCY, "IgnoreCurrency" },
+ { DSID_ESCAPE_DATETIME, "EscapeDateTime" },
+ { DSID_PRIMARY_KEY_SUPPORT, "PrimaryKeySupport" },
+ { 0, NULL }
+ };
+ return s_aMappings;
+ }
+
+ //--------------------------------------------------------------------
+ static const FeatureSet& lcl_getFeatureSet( const ::rtl::OUString _rURL )
+ {
+ typedef ::std::map< ::rtl::OUString, FeatureSet, ::comphelper::UStringLess > FeatureSets;
+ static FeatureSets s_aFeatureSets;
+ if ( s_aFeatureSets.empty() )
{
- ::connectivity::DriversConfig aDriverConfig(::comphelper::getProcessServiceFactory());
- const uno::Sequence< ::rtl::OUString > aURLs = aDriverConfig.getURLs();
- const ::rtl::OUString* pIter = aURLs.getConstArray();
- const ::rtl::OUString* pEnd = pIter + aURLs.getLength();
- for(;pIter != pEnd;++pIter)
+ ::connectivity::DriversConfig aDriverConfig( ::comphelper::getProcessServiceFactory() );
+ const uno::Sequence< ::rtl::OUString > aPatterns = aDriverConfig.getURLs();
+ for ( const ::rtl::OUString* pattern = aPatterns.getConstArray();
+ pattern != aPatterns.getConstArray() + aPatterns.getLength();
+ ++pattern
+ )
{
- InitAdvanced aInit(InitAdvanced::None);
- const uno::Sequence< beans::NamedValue> aProperties = aDriverConfig.getFeatures(*pIter).getNamedValues();
- const beans::NamedValue* pPropertiesIter = aProperties.getConstArray();
- const beans::NamedValue* pPropertiesEnd = pPropertiesIter + aProperties.getLength();
- for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter)
+ FeatureSet aCurrentSet;
+ const ::comphelper::NamedValueCollection aCurrentFeatures( aDriverConfig.getFeatures( *pattern ).getNamedValues() );
+
+ const FeatureMapping* pFeatureMapping = lcl_getFeatureMappings();
+ while ( pFeatureMapping->pAsciiFeatureName )
{
- if ( pPropertiesIter->Name.equalsAscii("GeneratedValues") )
- {
- pPropertiesIter->Value >>= aInit.bGeneratedValues;
- }
- else if ( pPropertiesIter->Name.equalsAscii("UseSQL92NamingConstraints") )
- {
- pPropertiesIter->Value >>= aInit.bUseSQL92NamingConstraints;
- }
- else if ( pPropertiesIter->Name.equalsAscii("AppendTableAliasInSelect") )
- {
- pPropertiesIter->Value >>= aInit.bAppendTableAliasInSelect;
- }
- else if ( pPropertiesIter->Name.equalsAscii("UseKeywordAsBeforeAlias") )
- {
- pPropertiesIter->Value >>= aInit.bUseKeywordAsBeforeAlias;
- }
- else if ( pPropertiesIter->Name.equalsAscii("UseBracketedOuterJoinSyntax") )
- {
- pPropertiesIter->Value >>= aInit.bUseBracketedOuterJoinSyntax;
- }
- else if ( pPropertiesIter->Name.equalsAscii("IgnoreDriverPrivileges") )
- {
- pPropertiesIter->Value >>= aInit.bIgnoreDriverPrivileges;
- }
- else if ( pPropertiesIter->Name.equalsAscii("ParameterNameSubstitution") )
- {
- pPropertiesIter->Value >>= aInit.bParameterNameSubstitution;
- }
- else if ( pPropertiesIter->Name.equalsAscii("DisplayVersionColumns") )
- {
- pPropertiesIter->Value >>= aInit.bDisplayVersionColumns;
- }
- else if ( pPropertiesIter->Name.equalsAscii("UseCatalogInSelect") )
- {
- pPropertiesIter->Value >>= aInit.bUseCatalogInSelect;
- }
- else if ( pPropertiesIter->Name.equalsAscii("UseSchemaInSelect") )
- {
- pPropertiesIter->Value >>= aInit.bUseSchemaInSelect;
- }
- else if ( pPropertiesIter->Name.equalsAscii("UseIndexDirectionKeyword") )
- {
- pPropertiesIter->Value >>= aInit.bUseIndexDirectionKeyword;
- }
- else if ( pPropertiesIter->Name.equalsAscii("UseDOSLineEnds") )
- {
- pPropertiesIter->Value >>= aInit.bUseDOSLineEnds;
- }
- else if ( pPropertiesIter->Name.equalsAscii("BooleanComparisonMode") )
- {
- pPropertiesIter->Value >>= aInit.bBooleanComparisonMode;
- }
- else if ( pPropertiesIter->Name.equalsAscii("FormsCheckRequiredFields") )
- {
- pPropertiesIter->Value >>= aInit.bFormsCheckRequiredFields;
- }
- else if ( pPropertiesIter->Name.equalsAscii("IgnoreCurrency") )
- {
- pPropertiesIter->Value >>= aInit.bIgnoreCurrency;
- }
- else if ( pPropertiesIter->Name.equalsAscii("EscapeDateTime") )
- {
- pPropertiesIter->Value >>= aInit.bEscapeDateTime;
- }
- } // for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter)
- s_aSupport.insert(AdvancedSupport::value_type(*pIter,aInit));
+ if ( aCurrentFeatures.has( pFeatureMapping->pAsciiFeatureName ) )
+ aCurrentSet.put( pFeatureMapping->nItemID );
+ ++pFeatureMapping;
+ }
+
+ s_aFeatureSets[ *pattern ] = aCurrentSet;
}
- } // if ( s_aSupport.empty() )
- OSL_ENSURE(s_aSupport.find(_sURL) != s_aSupport.end(),"Illegal URL!");
- return s_aSupport[ _sURL ];
+ }
+
+ OSL_ENSURE( s_aFeatureSets.find( _rURL ) != s_aFeatureSets.end(), "invalid URL/pattern!" );
+ return s_aFeatureSets[ _rURL ];
}
//--------------------------------------------------------------------
@@ -208,8 +159,8 @@ namespace dbaui
aInit = AuthPwd;
}
s_aSupport.insert(Supported::value_type(*pIter,aInit));
- } // for(;pIter != pEnd;++pIter)
- } // if ( s_aSupport.empty() )
+ }
+ }
OSL_ENSURE(s_aSupport.find(_sURL) != s_aSupport.end(),"Illegal URL!");
return s_aSupport[ _sURL ].eAuthentication;
}
@@ -249,9 +200,9 @@ namespace dbaui
}
//--------------------------------------------------------------------
- const AdvancedSettingsSupport& DataSourceMetaData::getAdvancedSettingsSupport() const
+ const FeatureSet& DataSourceMetaData::getFeatureSet() const
{
- return ::dbaui::getAdvancedSettingsSupport( m_pImpl->getType() );
+ return lcl_getFeatureSet( m_pImpl->getType() );
}
//--------------------------------------------------------------------