implemented the usage if the 'Info' property of the data sources / allow key usage in the data source list
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: dbadmin.cxx,v $
|
* $RCSfile: dbadmin.cxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.4 $
|
* $Revision: 1.5 $
|
||||||
*
|
*
|
||||||
* last change: $Author: fs $ $Date: 2000-10-12 16:20:42 $
|
* last change: $Author: fs $ $Date: 2000-10-13 16:06:20 $
|
||||||
*
|
*
|
||||||
* The Contents of this file are made available subject to the terms of
|
* The Contents of this file are made available subject to the terms of
|
||||||
* either of the following licenses
|
* either of the following licenses
|
||||||
@@ -92,6 +92,9 @@
|
|||||||
#ifndef _SVTOOLS_LOGINDLG_HXX_
|
#ifndef _SVTOOLS_LOGINDLG_HXX_
|
||||||
#include <svtools/logindlg.hxx>
|
#include <svtools/logindlg.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
|
||||||
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
||||||
|
#endif
|
||||||
#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
|
#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
|
||||||
#include <com/sun/star/uno/XNamingService.hpp>
|
#include <com/sun/star/uno/XNamingService.hpp>
|
||||||
#endif
|
#endif
|
||||||
@@ -113,6 +116,15 @@
|
|||||||
#ifndef _DBAUI_STRINGLISTITEM_HXX_
|
#ifndef _DBAUI_STRINGLISTITEM_HXX_
|
||||||
#include "stringlistitem.hxx"
|
#include "stringlistitem.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef _CPPUHELPER_EXTRACT_HXX_
|
||||||
|
#include <cppuhelper/extract.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
|
||||||
|
#include <typelib/typedescription.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _COMPHELPER_PROPERTY_HXX_
|
||||||
|
#include <comphelper/property.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
//.........................................................................
|
//.........................................................................
|
||||||
namespace dbaui
|
namespace dbaui
|
||||||
@@ -602,6 +614,26 @@ ODbAdminDialog::ODbAdminDialog(Window* _pParent, SfxItemSet* _pItems, const Refe
|
|||||||
// no local resources needed anymore
|
// no local resources needed anymore
|
||||||
FreeResource();
|
FreeResource();
|
||||||
|
|
||||||
|
/// initialize the property translation map
|
||||||
|
// direct properties of a data source
|
||||||
|
m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_CONNECTURL, PROPERTY_URL));
|
||||||
|
m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_NAME, PROPERTY_NAME));
|
||||||
|
m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_USER, PROPERTY_USER));
|
||||||
|
m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_PASSWORD, PROPERTY_PASSWORD));
|
||||||
|
m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_PASSWORDREQUIRED, PROPERTY_ISPASSWORDREQUIRED));
|
||||||
|
m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_TABLEFILTER, PROPERTY_TABLEFILTER));
|
||||||
|
m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_READONLY, PROPERTY_ISREADONLY));
|
||||||
|
// implicit properties, to be found in the direct property "Info"
|
||||||
|
m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_JDBCDRIVERCLASS, ::rtl::OUString::createFromAscii("JDBCDRV")));
|
||||||
|
m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTFILEEXTENSION, ::rtl::OUString::createFromAscii("Extension")));
|
||||||
|
m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CHARSET, ::rtl::OUString::createFromAscii("CharSet")));
|
||||||
|
m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTFILEHEADER, ::rtl::OUString::createFromAscii("HeaderLine")));
|
||||||
|
m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_FIELDDELIMITER, ::rtl::OUString::createFromAscii("FieldDelimiter")));
|
||||||
|
m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTDELIMITER, ::rtl::OUString::createFromAscii("StringDelimiter")));
|
||||||
|
m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_DECIMALDELIMITER, ::rtl::OUString::createFromAscii("DecimalDelimiter")));
|
||||||
|
m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_SHOWDELETEDROWS, ::rtl::OUString::createFromAscii("ShowDeleted")));
|
||||||
|
m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ALLOWLONGTABLENAMES, ::rtl::OUString::createFromAscii("NoNameLengthLimit")));
|
||||||
|
|
||||||
// register the view window
|
// register the view window
|
||||||
SetViewWindow(&m_aSelector);
|
SetViewWindow(&m_aSelector);
|
||||||
SetViewAlign(WINDOWALIGN_LEFT);
|
SetViewAlign(WINDOWALIGN_LEFT);
|
||||||
@@ -967,10 +999,10 @@ SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rp
|
|||||||
*pCounter++ = new SfxBoolItem(DSID_SHOWDELETEDROWS, sal_False);
|
*pCounter++ = new SfxBoolItem(DSID_SHOWDELETEDROWS, sal_False);
|
||||||
*pCounter++ = new SfxBoolItem(DSID_ALLOWLONGTABLENAMES, sal_False);
|
*pCounter++ = new SfxBoolItem(DSID_ALLOWLONGTABLENAMES, sal_False);
|
||||||
*pCounter++ = new SfxStringItem(DSID_JDBCDRIVERCLASS, String());
|
*pCounter++ = new SfxStringItem(DSID_JDBCDRIVERCLASS, String());
|
||||||
*pCounter++ = new SfxUInt16Item(DSID_FIELDDELIMITER, ';');
|
*pCounter++ = new SfxStringItem(DSID_FIELDDELIMITER, ';');
|
||||||
*pCounter++ = new SfxUInt16Item(DSID_TEXTDELIMITER, '"');
|
*pCounter++ = new SfxStringItem(DSID_TEXTDELIMITER, '"');
|
||||||
*pCounter++ = new SfxUInt16Item(DSID_DECIMALDELIMITER, '.');
|
*pCounter++ = new SfxStringItem(DSID_DECIMALDELIMITER, '.');
|
||||||
*pCounter++ = new SfxUInt16Item(DSID_THOUSANDSDELIMITER, ',');
|
*pCounter++ = new SfxStringItem(DSID_THOUSANDSDELIMITER, ',');
|
||||||
*pCounter++ = new SfxStringItem(DSID_TEXTFILEEXTENSION, String::CreateFromAscii("txt"));
|
*pCounter++ = new SfxStringItem(DSID_TEXTFILEEXTENSION, String::CreateFromAscii("txt"));
|
||||||
*pCounter++ = new SfxBoolItem(DSID_TEXTFILEHEADER, sal_True);
|
*pCounter++ = new SfxBoolItem(DSID_TEXTFILEHEADER, sal_True);
|
||||||
*pCounter++ = new SfxBoolItem(DSID_NEWDATASOURCE, sal_False);
|
*pCounter++ = new SfxBoolItem(DSID_NEWDATASOURCE, sal_False);
|
||||||
@@ -1279,70 +1311,273 @@ void ODbAdminDialog::resetPages(const Reference< XPropertySet >& _rxDatasource,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
Any ODbAdminDialog::implTranslateProperty(const SfxPoolItem* _pItem)
|
||||||
|
{
|
||||||
|
// translate the SfxPoolItem
|
||||||
|
Any aValue;
|
||||||
|
if (_pItem->ISA(SfxStringItem))
|
||||||
|
aValue <<= ::rtl::OUString(PTR_CAST(SfxStringItem, _pItem)->GetValue().GetBuffer());
|
||||||
|
else if (_pItem->ISA(SfxBoolItem))
|
||||||
|
aValue = ::cppu::bool2any(PTR_CAST(SfxBoolItem, _pItem)->GetValue());
|
||||||
|
else if (_pItem->ISA(OStringListItem))
|
||||||
|
aValue <<= PTR_CAST(OStringListItem, _pItem)->getList();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBG_ERROR("ODbAdminDialog::implTranslateProperty: unsupported item type!");
|
||||||
|
return aValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return aValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
void ODbAdminDialog::implTranslateProperty(const Reference< XPropertySet >& _rxSet, const ::rtl::OUString& _rName, const SfxPoolItem* _pItem)
|
||||||
|
{
|
||||||
|
Any aValue = implTranslateProperty(_pItem);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_rxSet->setPropertyValue(_rName, aValue);
|
||||||
|
}
|
||||||
|
catch(Exception&)
|
||||||
|
{
|
||||||
|
#ifdef DBG_UTIL
|
||||||
|
::rtl::OString sMessage("ODbAdminDialog::implTranslateProperty: could not set the property ");
|
||||||
|
sMessage += ::rtl::OString(_rName.getStr(), _rName.getLength(), RTL_TEXTENCODING_ASCII_US);
|
||||||
|
sMessage += ::rtl::OString("!");
|
||||||
|
DBG_ERROR(sMessage.getStr());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
void ODbAdminDialog::implTranslateProperty(SfxItemSet& _rSet, sal_Int32 _nId, const Any& _rValue)
|
||||||
|
{
|
||||||
|
switch (_rValue.getValueType().getTypeClass())
|
||||||
|
{
|
||||||
|
case TypeClass_STRING:
|
||||||
|
{
|
||||||
|
::rtl::OUString sValue;
|
||||||
|
_rValue >>= sValue;
|
||||||
|
_rSet.Put(SfxStringItem(_nId, sValue.getStr()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TypeClass_BOOLEAN:
|
||||||
|
_rSet.Put(SfxBoolItem(_nId, ::cppu::any2bool(_rValue)));
|
||||||
|
break;
|
||||||
|
case TypeClass_SEQUENCE:
|
||||||
|
{
|
||||||
|
// determine the element type
|
||||||
|
TypeDescription aTD(_rValue.getValueType());
|
||||||
|
typelib_IndirectTypeDescription* pSequenceTD =
|
||||||
|
reinterpret_cast< typelib_IndirectTypeDescription* >(aTD.get());
|
||||||
|
DBG_ASSERT(pSequenceTD && pSequenceTD->pType, "ODbAdminDialog::implTranslateProperty: invalid sequence type!");
|
||||||
|
|
||||||
|
Type aElementType(pSequenceTD->pType);
|
||||||
|
switch (aElementType.getTypeClass())
|
||||||
|
{
|
||||||
|
case TypeClass_STRING:
|
||||||
|
{
|
||||||
|
Sequence< ::rtl::OUString > aStringList;
|
||||||
|
_rValue >>= aStringList;
|
||||||
|
_rSet.Put(OStringListItem(_nId, aStringList));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DBG_ERROR("ODbAdminDialog::implTranslateProperty: unsupported property value type!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TypeClass_VOID:
|
||||||
|
_rSet.ClearItem(_nId);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DBG_ERROR("ODbAdminDialog::implTranslateProperty: unsupported property value type!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
struct PropertyValueLess
|
||||||
|
{
|
||||||
|
bool operator() (const PropertyValue& x, const PropertyValue& y) const
|
||||||
|
{ return x.Name < y.Name ? true : false; } // construct prevents a MSVC6 warning
|
||||||
|
};
|
||||||
|
DECLARE_STL_SET( PropertyValue, PropertyValueLess, PropertyValueSet);
|
||||||
|
|
||||||
|
//........................................................................
|
||||||
void ODbAdminDialog::translateProperties(const Reference< XPropertySet >& _rxSource, SfxItemSet& _rDest)
|
void ODbAdminDialog::translateProperties(const Reference< XPropertySet >& _rxSource, SfxItemSet& _rDest)
|
||||||
{
|
{
|
||||||
::rtl::OUString sNewConnectURL, sName, sUid, sPwd;
|
::rtl::OUString sNewConnectURL, sName, sUid, sPwd;
|
||||||
Sequence< ::rtl::OUString > aTableFitler;
|
Sequence< ::rtl::OUString > aTableFitler;
|
||||||
sal_Bool bPasswordRequired = sal_False;
|
sal_Bool bPasswordRequired = sal_False;
|
||||||
sal_Bool bReadOnly = sal_True;
|
sal_Bool bReadOnly = sal_True;
|
||||||
try
|
|
||||||
|
if (_rxSource.is())
|
||||||
{
|
{
|
||||||
if (_rxSource.is())
|
for ( ConstMapInt2StringIterator aDirect = m_aDirectPropTranslator.begin();
|
||||||
|
aDirect != m_aDirectPropTranslator.end();
|
||||||
|
++aDirect
|
||||||
|
)
|
||||||
{
|
{
|
||||||
_rxSource->getPropertyValue(PROPERTY_URL) >>= sNewConnectURL;
|
// get the property value
|
||||||
_rxSource->getPropertyValue(PROPERTY_NAME) >>= sName;
|
Any aValue;
|
||||||
_rxSource->getPropertyValue(PROPERTY_USER) >>= sUid;
|
try
|
||||||
_rxSource->getPropertyValue(PROPERTY_PASSWORD) >>= sPwd;
|
{
|
||||||
_rxSource->getPropertyValue(PROPERTY_TABLEFILTER) >>= aTableFitler;
|
aValue = _rxSource->getPropertyValue(aDirect->second);
|
||||||
_rxSource->getPropertyValue(PROPERTY_ISPASSWORDREQUIRED) >>= bPasswordRequired;
|
}
|
||||||
_rxSource->getPropertyValue(PROPERTY_ISREADONLY) >>= bReadOnly;
|
catch(Exception&)
|
||||||
|
{
|
||||||
|
#if DBG_UTIL
|
||||||
|
::rtl::OString aMessage("ODbAdminDialog::translateProperties: could not extract the property ");
|
||||||
|
aMessage += ::rtl::OString(aDirect->second.getStr(), aDirect->second.getLength(), RTL_TEXTENCODING_ASCII_US);
|
||||||
|
aMessage += ::rtl::OString("!");
|
||||||
|
DBG_ERROR(aMessage.getStr());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
// transfer it into an item
|
||||||
|
implTranslateProperty(_rDest, aDirect->first, aValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the additional informations
|
||||||
|
Sequence< PropertyValue > aAdditionalInfo;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_rxSource->getPropertyValue(PROPERTY_INFO) >>= aAdditionalInfo;
|
||||||
|
}
|
||||||
|
catch(Exception&) { }
|
||||||
|
|
||||||
|
// collect the names of the additional settings
|
||||||
|
const PropertyValue* pAdditionalInfo = aAdditionalInfo.getConstArray();
|
||||||
|
PropertyValueSet aInfos;
|
||||||
|
for (sal_Int32 i=0; i<aAdditionalInfo.getLength(); ++i, ++pAdditionalInfo)
|
||||||
|
aInfos.insert(*pAdditionalInfo);
|
||||||
|
|
||||||
|
// go through all known translations and check if we have such a setting
|
||||||
|
PropertyValue aSearchFor;
|
||||||
|
for ( ConstMapInt2StringIterator aIndirect = m_aIndirectPropTranslator.begin();
|
||||||
|
aIndirect != m_aIndirectPropTranslator.end();
|
||||||
|
++aIndirect
|
||||||
|
)
|
||||||
|
{
|
||||||
|
aSearchFor.Name = aIndirect->second;
|
||||||
|
ConstPropertyValueSetIterator aInfoPos = aInfos.find(aSearchFor);
|
||||||
|
if (aInfos.end() != aInfoPos)
|
||||||
|
// the property is contained in the info sequence
|
||||||
|
// -> transfer it into an item
|
||||||
|
implTranslateProperty(_rDest, aIndirect->first, aInfoPos->Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception&)
|
|
||||||
{
|
|
||||||
DBG_ERROR("ODbAdminDialog::translateProperties : could not extract all the relevant datasource properties!");
|
|
||||||
}
|
|
||||||
|
|
||||||
_rDest.Put(SfxStringItem(DSID_CONNECTURL, sNewConnectURL));
|
|
||||||
_rDest.Put(SfxStringItem(DSID_NAME, sName));
|
|
||||||
_rDest.Put(SfxStringItem(DSID_USER, sUid));
|
|
||||||
_rDest.Put(SfxStringItem(DSID_PASSWORD, sPwd));
|
|
||||||
_rDest.Put(OStringListItem(DSID_TABLEFILTER, aTableFitler));
|
|
||||||
_rDest.Put(SfxBoolItem(DSID_PASSWORDREQUIRED, bPasswordRequired));
|
|
||||||
_rDest.Put(SfxBoolItem(DSID_READONLY, bReadOnly));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
void ODbAdminDialog::translateProperties(const SfxItemSet& _rSource, const Reference< XPropertySet >& _rxDest)
|
void ODbAdminDialog::translateProperties(const SfxItemSet& _rSource, const Reference< XPropertySet >& _rxDest)
|
||||||
{
|
{
|
||||||
DBG_ASSERT(_rxDest.is(), "ODbAdminDialog::translateProperties : invalid property set!");
|
DBG_ASSERT(_rxDest.is(), "ODbAdminDialog::translateProperties: invalid property set!");
|
||||||
if (!_rxDest.is())
|
if (!_rxDest.is())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// get the items
|
// the property set info
|
||||||
SFX_ITEMSET_GET(_rSource, pConnectURL, SfxStringItem, DSID_CONNECTURL, sal_True);
|
Reference< XPropertySetInfo > xInfo;
|
||||||
SFX_ITEMSET_GET(_rSource, pUser, SfxStringItem, DSID_USER, sal_True);
|
try { xInfo = _rxDest->getPropertySetInfo(); }
|
||||||
SFX_ITEMSET_GET(_rSource, pPassword, SfxStringItem, DSID_PASSWORD, sal_True);
|
catch(Exception&) { }
|
||||||
SFX_ITEMSET_GET(_rSource, pTableFilter, OStringListItem, DSID_TABLEFILTER, sal_True);
|
|
||||||
SFX_ITEMSET_GET(_rSource, pPasswordRequired, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True);
|
|
||||||
|
|
||||||
// set the values
|
// -----------------------------
|
||||||
|
// transfer the direct propertis
|
||||||
|
for ( ConstMapInt2StringIterator aDirect = m_aDirectPropTranslator.begin();
|
||||||
|
aDirect != m_aDirectPropTranslator.end();
|
||||||
|
++aDirect
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const SfxPoolItem* pCurrentItem = _rSource.GetItem(aDirect->first);
|
||||||
|
if (pCurrentItem)
|
||||||
|
{
|
||||||
|
sal_Int16 nAttributes = PropertyAttribute::READONLY;
|
||||||
|
if (xInfo.is())
|
||||||
|
{
|
||||||
|
try { nAttributes = xInfo->getPropertyByName(aDirect->second).Attributes; }
|
||||||
|
catch(Exception&) { }
|
||||||
|
}
|
||||||
|
if ((nAttributes & PropertyAttribute::READONLY) == 0)
|
||||||
|
implTranslateProperty(_rxDest, aDirect->second, pCurrentItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------
|
||||||
|
// now for the indirect properties
|
||||||
|
|
||||||
|
// first determine which of all the items are relevant for the data source (depends on the connection url)
|
||||||
|
sal_Int32* pRelevantItems = NULL;
|
||||||
|
|
||||||
|
SFX_ITEMSET_GET(_rSource, pConnectURL, SfxStringItem, DSID_CONNECTURL, sal_True);
|
||||||
|
SFX_ITEMSET_GET(_rSource, pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
|
||||||
|
DBG_ASSERT(pConnectURL && pTypeCollection, "ODbAdminDialog::translateProperties: invalid items in the source set!");
|
||||||
|
String sConnectURL = pConnectURL->GetValue();
|
||||||
|
ODsnTypeCollection* pCollection = pTypeCollection->getCollection();
|
||||||
|
DBG_ASSERT(pCollection, "ODbAdminDialog::translateProperties: invalid type collection!");
|
||||||
|
DATASOURCE_TYPE eType = pCollection->getType(sConnectURL);
|
||||||
|
switch (eType)
|
||||||
|
{
|
||||||
|
case DST_ADABAS: pRelevantItems = OAdabasDetailsPage::getDetailIds(); break;
|
||||||
|
case DST_JDBC: pRelevantItems = OJdbcDetailsPage::getDetailIds(); break;
|
||||||
|
case DST_ODBC: pRelevantItems = OOdbcDetailsPage::getDetailIds(); break;
|
||||||
|
case DST_DBASE: pRelevantItems = ODbaseDetailsPage::getDetailIds(); break;
|
||||||
|
case DST_TEXT: pRelevantItems = OTextDetailsPage::getDetailIds(); break;
|
||||||
|
}
|
||||||
|
DBG_ASSERT(pRelevantItems, "ODbAdminDialog::translateProperties: invalid item ids got from the page!");
|
||||||
|
|
||||||
|
// collect the translated property values
|
||||||
|
PropertyValueSet aRelevantSettings;
|
||||||
|
ConstMapInt2StringIterator aTranslation;
|
||||||
|
while (*pRelevantItems)
|
||||||
|
{
|
||||||
|
const SfxPoolItem* pCurrent = _rSource.GetItem(*pRelevantItems);
|
||||||
|
aTranslation = m_aIndirectPropTranslator.find(*pRelevantItems);
|
||||||
|
if (pCurrent && (m_aIndirectPropTranslator.end() != aTranslation))
|
||||||
|
aRelevantSettings.insert(PropertyValue(aTranslation->second, 0, implTranslateProperty(pCurrent), PropertyState_DIRECT_VALUE));
|
||||||
|
|
||||||
|
++pRelevantItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
// within the current "Info" sequence, replace the ones we
|
||||||
|
// (we don't just fill a completely new sequence with our own items, but we preserve any properties unknown to
|
||||||
|
// us)
|
||||||
|
Sequence< PropertyValue > aInfo;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (pConnectURL)
|
_rxDest->getPropertyValue(PROPERTY_INFO) >>= aInfo;
|
||||||
_rxDest->setPropertyValue(PROPERTY_URL, makeAny(::rtl::OUString(pConnectURL->GetValue().GetBuffer())));
|
}
|
||||||
if (pUser)
|
catch(Exception&) { }
|
||||||
_rxDest->setPropertyValue(PROPERTY_USER, makeAny(::rtl::OUString(pUser->GetValue().GetBuffer())));
|
PropertyValue* pInfo = aInfo.getArray();
|
||||||
if (pPassword)
|
PropertyValue aSearchFor;
|
||||||
_rxDest->setPropertyValue(PROPERTY_PASSWORD, makeAny(::rtl::OUString(pPassword->GetValue().GetBuffer())));
|
for (sal_Int32 i=0; i<aInfo.getLength(); ++i, ++pInfo)
|
||||||
if (pTableFilter)
|
{
|
||||||
_rxDest->setPropertyValue(PROPERTY_TABLEFILTER, makeAny(pTableFilter->getList()));
|
aSearchFor.Name = pInfo->Name;
|
||||||
if (pPasswordRequired)
|
PropertyValueSetIterator aOverwrittenSetting = aRelevantSettings.find(aSearchFor);
|
||||||
_rxDest->setPropertyValue(PROPERTY_ISPASSWORDREQUIRED, makeAny(pPasswordRequired->GetValue()));
|
if (aRelevantSettings.end() != aOverwrittenSetting)
|
||||||
|
{ // the setting was present in the original sequence, and it is to be overwritten -> replace it
|
||||||
|
*pInfo = *aOverwrittenSetting;
|
||||||
|
aRelevantSettings.erase(aOverwrittenSetting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check which settings are still left ('cause they were not present in the original sequence, but are to be set)
|
||||||
|
sal_Int32 nOldLength = aInfo.getLength();
|
||||||
|
aInfo.realloc(nOldLength + aRelevantSettings.size());
|
||||||
|
PropertyValue* pAppendValues = aInfo.getArray() + nOldLength;
|
||||||
|
for ( ConstPropertyValueSetIterator aLoop = aRelevantSettings.begin();
|
||||||
|
aLoop != aRelevantSettings.end();
|
||||||
|
++aLoop, ++pAppendValues
|
||||||
|
)
|
||||||
|
{
|
||||||
|
*pAppendValues = *aLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
// and propagate the (newly composed) sequence to the set
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_rxDest->setPropertyValue(PROPERTY_INFO, makeAny(aInfo));
|
||||||
}
|
}
|
||||||
catch(Exception&)
|
catch(Exception&)
|
||||||
{
|
{
|
||||||
DBG_ERROR("ODbAdminDialog::translateProperties : could not set all the relevant datasource properties!");
|
DBG_ERROR("ODbAdminDialog::translateProperties: could not propagate the composed info sequence to the property set!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1690,52 +1925,74 @@ long ODatasourceSelector::Notify(NotifyEvent& _rNEvt)
|
|||||||
{
|
{
|
||||||
sal_Bool bHandled = sal_False;
|
sal_Bool bHandled = sal_False;
|
||||||
|
|
||||||
if (EVENT_COMMAND == _rNEvt.GetType())
|
switch (_rNEvt.GetType())
|
||||||
{
|
{
|
||||||
const CommandEvent* pCommand = _rNEvt.GetCommandEvent();
|
case EVENT_COMMAND:
|
||||||
if (COMMAND_CONTEXTMENU == pCommand->GetCommand())
|
|
||||||
{
|
{
|
||||||
// check if the context menu request occured in the listbox
|
const CommandEvent* pCommand = _rNEvt.GetCommandEvent();
|
||||||
if (m_aDatasourceList.IsChild(_rNEvt.GetWindow()))
|
if (COMMAND_CONTEXTMENU == pCommand->GetCommand())
|
||||||
{
|
{
|
||||||
// calc the pos where to open the menu
|
// check if the context menu request occured in the listbox
|
||||||
Point aWhere;
|
if (m_aDatasourceList.IsChild(_rNEvt.GetWindow()))
|
||||||
if (pCommand->IsMouseEvent())
|
|
||||||
{
|
{
|
||||||
aWhere = pCommand->GetMousePosPixel();
|
// calc the pos where to open the menu
|
||||||
}
|
Point aWhere;
|
||||||
else
|
if (pCommand->IsMouseEvent())
|
||||||
{ // context menu via keyboard -> assume the center of the currently selected data source
|
{
|
||||||
// TODO: use another class instead of the listbox (e.g. a SvTreeListBox). We have no change
|
aWhere = pCommand->GetMousePosPixel();
|
||||||
// to get an item rect or the item height or something like that from a listbox ...
|
}
|
||||||
aWhere = Point(0, 0);
|
else
|
||||||
}
|
{ // context menu via keyboard -> assume the center of the currently selected data source
|
||||||
PopupMenu aMenu(ModuleRes(MENU_DATASOURCELIST_POPUP));
|
// TODO: use another class instead of the listbox (e.g. a SvTreeListBox). We have no change
|
||||||
aMenu.SetMenuFlags(aMenu.GetMenuFlags() | MENU_FLAG_HIDEDISABLEDENTRIES);
|
// to get an item rect or the item height or something like that from a listbox ...
|
||||||
|
aWhere = Point(0, 0);
|
||||||
|
}
|
||||||
|
PopupMenu aMenu(ModuleRes(MENU_DATASOURCELIST_POPUP));
|
||||||
|
aMenu.SetMenuFlags(aMenu.GetMenuFlags() | MENU_FLAG_HIDEDISABLEDENTRIES);
|
||||||
|
|
||||||
// we don't really know if adding datasources is allowed currently. But an other instance does
|
// we don't really know if adding datasources is allowed currently. But an other instance does
|
||||||
// (the dialog), and this instance en- or disables our "new datasource" button
|
// (the dialog), and this instance en- or disables our "new datasource" button
|
||||||
aMenu.EnableItem(MID_NEW_DATASOURCE, m_aNewDatasource.IsEnabled());
|
aMenu.EnableItem(MID_NEW_DATASOURCE, m_aNewDatasource.IsEnabled());
|
||||||
|
|
||||||
DatasourceState eState = getEntryState(m_aDatasourceList.GetSelectEntryPos());
|
DatasourceState eState = getEntryState(m_aDatasourceList.GetSelectEntryPos());
|
||||||
aMenu.EnableItem(MID_DELETE_DATASOURCE, DELETED != eState);
|
aMenu.EnableItem(MID_DELETE_DATASOURCE, DELETED != eState);
|
||||||
aMenu.EnableItem(MID_RESTORE_DATASOURCE, DELETED == eState);
|
aMenu.EnableItem(MID_RESTORE_DATASOURCE, DELETED == eState);
|
||||||
|
|
||||||
switch (aMenu.Execute(_rNEvt.GetWindow(), aWhere))
|
switch (aMenu.Execute(_rNEvt.GetWindow(), aWhere))
|
||||||
{
|
{
|
||||||
case MID_NEW_DATASOURCE:
|
case MID_NEW_DATASOURCE:
|
||||||
m_aNewHandler.Call(this);
|
m_aNewHandler.Call(this);
|
||||||
break;
|
break;
|
||||||
case MID_DELETE_DATASOURCE:
|
case MID_DELETE_DATASOURCE:
|
||||||
m_aDeleteHandler.Call(this);
|
m_aDeleteHandler.Call(this);
|
||||||
break;
|
break;
|
||||||
case MID_RESTORE_DATASOURCE:
|
case MID_RESTORE_DATASOURCE:
|
||||||
m_aRestoreHandler.Call(this);
|
m_aRestoreHandler.Call(this);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
bHandled = sal_True;
|
||||||
}
|
}
|
||||||
bHandled = sal_True;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case EVENT_KEYINPUT:
|
||||||
|
{
|
||||||
|
const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
|
||||||
|
const KeyCode& rKeyCode = pKeyEvent->GetKeyCode();
|
||||||
|
if ((0 == rKeyCode.GetAllModifier()) && ((sal_uInt16)-1 != m_aDatasourceList.GetSelectEntryPos()))
|
||||||
|
switch (rKeyCode.GetCode())
|
||||||
|
{
|
||||||
|
case KEY_DELETE:
|
||||||
|
m_aDeleteHandler.Call(this);
|
||||||
|
bHandled = sal_True;
|
||||||
|
break;
|
||||||
|
case KEY_INSERT:
|
||||||
|
m_aNewHandler.Call(this);
|
||||||
|
bHandled = sal_True;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bHandled ? 1 : Window::Notify(_rNEvt);
|
return bHandled ? 1 : Window::Notify(_rNEvt);
|
||||||
@@ -1769,6 +2026,9 @@ IMPL_LINK(ODatasourceSelector, OnButtonPressed, Button*, EMPTYARG)
|
|||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* history:
|
* history:
|
||||||
* $Log: not supported by cvs2svn $
|
* $Log: not supported by cvs2svn $
|
||||||
|
* Revision 1.4 2000/10/12 16:20:42 fs
|
||||||
|
* new implementations ... still under construction
|
||||||
|
*
|
||||||
* Revision 1.3 2000/10/11 11:31:03 fs
|
* Revision 1.3 2000/10/11 11:31:03 fs
|
||||||
* new implementations - still under construction
|
* new implementations - still under construction
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user