autorecovery: merge after pulling CWS dba33e
This commit is contained in:
commit
38b970f683
22 changed files with 597 additions and 345 deletions
|
@ -1747,7 +1747,7 @@ void SfxLibraryContainer::implImportLibDescriptor
|
|||
|
||||
|
||||
// Methods of new XLibraryStorage interface?
|
||||
void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XStorage >& xStorage, sal_Bool bComplete )
|
||||
void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XStorage >& i_rStorage, sal_Bool bComplete )
|
||||
{
|
||||
const Sequence< OUString > aNames = maNameContainer.getElementNames();
|
||||
sal_Int32 nNameCount = aNames.getLength();
|
||||
|
@ -1768,35 +1768,13 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
|
|||
::xmlscript::LibDescriptorArray* pLibArray = new ::xmlscript::LibDescriptorArray( nLibsToSave );
|
||||
|
||||
// Write to storage?
|
||||
sal_Bool bStorage = xStorage.is();
|
||||
uno::Reference< embed::XStorage > xLibrariesStor;
|
||||
sal_Bool bStorage = i_rStorage.is();
|
||||
uno::Reference< embed::XStorage > xSourceLibrariesStor;
|
||||
if( bStorage )
|
||||
uno::Reference< embed::XStorage > xTargetLibrariesStor;
|
||||
::rtl::OUString sTempTargetStorName;
|
||||
const bool bInplaceStorage = bStorage && ( i_rStorage == mxStorage );
|
||||
if ( bStorage )
|
||||
{
|
||||
// when we save to our root storage, ensure the libs are all loaded. Else the below cleaning
|
||||
// of the target storage will loose them.
|
||||
if ( xStorage == mxStorage )
|
||||
{
|
||||
pName = aNames.getConstArray();
|
||||
for ( ; pName != pNamesEnd; ++pName )
|
||||
{
|
||||
if ( !isLibraryLoaded( *pName ) )
|
||||
loadLibrary( *pName );
|
||||
}
|
||||
}
|
||||
|
||||
// first of all, clean the target library storage, since the storing procedure must do overwrite
|
||||
try
|
||||
{
|
||||
if ( xStorage->hasByName( maLibrariesDir ) )
|
||||
xStorage->removeElement( maLibrariesDir );
|
||||
}
|
||||
catch( const uno::Exception& )
|
||||
{
|
||||
DBG_UNHANDLED_EXCEPTION();
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't write if only empty standard lib exists
|
||||
if ( ( nNameCount == 1 ) && ( aNames[0].equalsAscii( "Standard" ) ) )
|
||||
{
|
||||
|
@ -1807,29 +1785,52 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
|
|||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
xLibrariesStor.set( xStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READWRITE ), UNO_QUERY_THROW );
|
||||
}
|
||||
catch( uno::Exception& )
|
||||
{
|
||||
#if OSL_DEBUG_LEVEL > 0
|
||||
Any aError( ::cppu::getCaughtException() );
|
||||
::rtl::OStringBuffer aMessage;
|
||||
aMessage.append( "couln't open source library storage.\n\nException:" );
|
||||
aMessage.append( ::rtl::OUStringToOString( ::comphelper::anyToString( aError ), osl_getThreadTextEncoding() ) );
|
||||
OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() );
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// create the empty target storage
|
||||
try
|
||||
{
|
||||
if ( ( mxStorage != xStorage ) && ( mxStorage->hasByName( maLibrariesDir ) ) )
|
||||
xSourceLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ );
|
||||
::rtl::OUString sTargetLibrariesStoreName;
|
||||
if ( bInplaceStorage )
|
||||
{
|
||||
// create a temporary target storage
|
||||
const ::rtl::OUStringBuffer aTempTargetNameBase = maLibrariesDir + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_temp_" ) );
|
||||
do
|
||||
{
|
||||
::rtl::OUStringBuffer aTempTargetName( aTempTargetNameBase );
|
||||
sal_Int32 index = 0;
|
||||
aTempTargetName.append( index );
|
||||
|
||||
sTargetLibrariesStoreName = aTempTargetName.makeStringAndClear();
|
||||
if ( !i_rStorage->hasByName( sTargetLibrariesStoreName ) )
|
||||
break;
|
||||
}
|
||||
while ( true );
|
||||
sTempTargetStorName = sTargetLibrariesStoreName;
|
||||
}
|
||||
else
|
||||
{
|
||||
sTargetLibrariesStoreName = maLibrariesDir;
|
||||
if ( i_rStorage->hasByName( sTargetLibrariesStoreName ) )
|
||||
i_rStorage->removeElement( sTargetLibrariesStoreName );
|
||||
}
|
||||
|
||||
xTargetLibrariesStor.set( i_rStorage->openStorageElement( sTargetLibrariesStoreName, embed::ElementModes::READWRITE ), UNO_QUERY_THROW );
|
||||
}
|
||||
catch( const uno::Exception& )
|
||||
{
|
||||
DBG_UNHANDLED_EXCEPTION();
|
||||
return;
|
||||
}
|
||||
|
||||
// open the source storage which might be used to copy yet-unmodified libraries
|
||||
try
|
||||
{
|
||||
if ( mxStorage->hasByName( maLibrariesDir ) )
|
||||
xSourceLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, bInplaceStorage ? embed::ElementModes::READWRITE : embed::ElementModes::READ );
|
||||
}
|
||||
catch( const uno::Exception& )
|
||||
{
|
||||
DBG_UNHANDLED_EXCEPTION();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1841,7 +1842,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
|
|||
SfxLibrary* pImplLib = getImplLib( *pName );
|
||||
if( pImplLib->mbSharedIndexFile )
|
||||
continue;
|
||||
bool bExtensionLib = pImplLib->mbExtension;
|
||||
const bool bExtensionLib = pImplLib->mbExtension;
|
||||
::xmlscript::LibDescriptor& rLib = bExtensionLib ?
|
||||
aLibDescriptorForExtensionLibs : pLibArray->mpLibs[iArray];
|
||||
if( !bExtensionLib )
|
||||
|
@ -1861,12 +1862,14 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
|
|||
|
||||
if( pImplLib->implIsModified() || bComplete )
|
||||
{
|
||||
// Can we copy the storage?
|
||||
// Can we simply copy the storage?
|
||||
if( !mbOldInfoFormat && !pImplLib->implIsModified() && !mbOasis2OOoFormat && xSourceLibrariesStor.is() )
|
||||
{
|
||||
try {
|
||||
xSourceLibrariesStor->copyElementTo( rLib.aName, xLibrariesStor, rLib.aName );
|
||||
} catch( uno::Exception& )
|
||||
try
|
||||
{
|
||||
xSourceLibrariesStor->copyElementTo( rLib.aName, xTargetLibrariesStor, rLib.aName );
|
||||
}
|
||||
catch( const uno::Exception& )
|
||||
{
|
||||
DBG_UNHANDLED_EXCEPTION();
|
||||
// TODO: error handling?
|
||||
|
@ -1879,7 +1882,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
|
|||
{
|
||||
try
|
||||
{
|
||||
xLibraryStor = xLibrariesStor->openStorageElement(
|
||||
xLibraryStor = xTargetLibrariesStor->openStorageElement(
|
||||
rLib.aName,
|
||||
embed::ElementModes::READWRITE );
|
||||
}
|
||||
|
@ -1911,7 +1914,8 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
|
|||
implStoreLibraryIndexFile( pImplLib, rLib, xLibraryStor );
|
||||
if( bStorage )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
uno::Reference< embed::XTransactedObject > xTransact( xLibraryStor, uno::UNO_QUERY_THROW );
|
||||
xTransact->commit();
|
||||
}
|
||||
|
@ -1931,6 +1935,55 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
|
|||
rLib.bReadOnly = pImplLib->mbReadOnlyLink;
|
||||
}
|
||||
|
||||
// if we did an in-place save into a storage (i.e. a save into the storage we were already based on),
|
||||
// then we need to clean up the temporary storage we used for this
|
||||
if ( bInplaceStorage && sTempTargetStorName.getLength() )
|
||||
{
|
||||
try
|
||||
{
|
||||
// for this, we first remove everything from the source storage, then copy the complete content
|
||||
// from the temporary target storage. From then on, what used to be the "source storage" becomes
|
||||
// the "targt storage" for all subsequent operations.
|
||||
|
||||
// (We cannot simply remove the storage, denoted by maLibrariesDir, from i_rStorage - there might be
|
||||
// open references to it.)
|
||||
|
||||
// remove
|
||||
const Sequence< ::rtl::OUString > aRemoveNames( xTargetLibrariesStor->getElementNames() );
|
||||
for ( const ::rtl::OUString* pRemoveName = aRemoveNames.getConstArray();
|
||||
pRemoveName != aRemoveNames.getConstArray() + aRemoveNames.getLength();
|
||||
++pRemoveName
|
||||
)
|
||||
{
|
||||
xSourceLibrariesStor->removeElement( *pRemoveName );
|
||||
}
|
||||
|
||||
// copy
|
||||
const Sequence< ::rtl::OUString > aCopyNames( xTargetLibrariesStor->getElementNames() );
|
||||
for ( const ::rtl::OUString* pCopyName = aCopyNames.getConstArray();
|
||||
pCopyName != aCopyNames.getConstArray() + aCopyNames.getLength();
|
||||
++pCopyName
|
||||
)
|
||||
{
|
||||
xTargetLibrariesStor->copyElementTo( *pCopyName, xSourceLibrariesStor, *pCopyName );
|
||||
}
|
||||
|
||||
// close and remove temp target
|
||||
xTargetLibrariesStor->dispose();
|
||||
i_rStorage->removeElement( sTempTargetStorName );
|
||||
xTargetLibrariesStor.clear();
|
||||
sTempTargetStorName = ::rtl::OUString();
|
||||
|
||||
// adjust target
|
||||
xTargetLibrariesStor = xSourceLibrariesStor;
|
||||
xSourceLibrariesStor.clear();
|
||||
}
|
||||
catch( const Exception& )
|
||||
{
|
||||
DBG_UNHANDLED_EXCEPTION();
|
||||
}
|
||||
}
|
||||
|
||||
if( !mbOldInfoFormat && !maModifiable.isModified() )
|
||||
return;
|
||||
maModifiable.setModified( sal_False );
|
||||
|
@ -1956,7 +2009,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
|
|||
aStreamName += String( RTL_CONSTASCII_USTRINGPARAM("-lc.xml") );
|
||||
|
||||
try {
|
||||
xInfoStream = xLibrariesStor->openStreamElement( aStreamName, embed::ElementModes::READWRITE );
|
||||
xInfoStream = xTargetLibrariesStor->openStreamElement( aStreamName, embed::ElementModes::READWRITE );
|
||||
uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY );
|
||||
OSL_ENSURE ( xProps.is(), "The stream must implement XPropertySet!\n" );
|
||||
if ( !xProps.is() )
|
||||
|
@ -2015,7 +2068,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
|
|||
xmlscript::exportLibraryContainer( xHandler, pLibArray );
|
||||
if ( bStorage )
|
||||
{
|
||||
uno::Reference< embed::XTransactedObject > xTransact( xLibrariesStor, uno::UNO_QUERY );
|
||||
uno::Reference< embed::XTransactedObject > xTransact( xTargetLibrariesStor, uno::UNO_QUERY );
|
||||
OSL_ENSURE( xTransact.is(), "The storage must implement XTransactedObject!\n" );
|
||||
if ( !xTransact.is() )
|
||||
throw uno::RuntimeException();
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
#include "connectivity/sdbcx/VKey.hxx"
|
||||
#include "connectivity/StdTypeDefs.hxx"
|
||||
#include <comphelper/stl_types.hxx>
|
||||
#include <com/sun/star/sdb/tools/XTableRename.hpp>
|
||||
#include <com/sun/star/sdb/tools/XTableAlteration.hpp>
|
||||
#include <com/sun/star/sdb/tools/XKeyAlteration.hpp>
|
||||
#include <com/sun/star/sdb/tools/XIndexAlteration.hpp>
|
||||
|
||||
namespace connectivity
|
||||
{
|
||||
|
@ -158,6 +162,11 @@ namespace connectivity
|
|||
void addKey(const ::rtl::OUString& _sName,const sdbcx::TKeyProperties& _aKeyProperties);
|
||||
|
||||
virtual ::rtl::OUString getTypeCreatePattern() const;
|
||||
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XTableRename> getRenameService() const;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XTableAlteration> getAlterService() const;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XKeyAlteration> getKeyService() const;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XIndexAlteration> getIndexService() const;
|
||||
};
|
||||
}
|
||||
#endif // CONNECTIVITY_TABLEHELPER_HXX
|
||||
|
|
|
@ -353,6 +353,33 @@ namespace dbtools
|
|||
,const ::rtl::OUString& _sProperty,
|
||||
sal_Bool _bDefault = sal_False);
|
||||
|
||||
/** retrieves a particular indirect data source setting
|
||||
|
||||
@param _rxDataSource
|
||||
a data source component
|
||||
@param _pAsciiSettingsName
|
||||
the ASCII name of the setting to obtain
|
||||
@param _rSettingsValue
|
||||
the value of the setting, upon successfull return
|
||||
|
||||
@return
|
||||
<FALSE/> if the setting is not present in the <member scope="com::sun::star::sdb">DataSource::Info</member>
|
||||
member of the data source
|
||||
<TRUE/> otherwise
|
||||
*/
|
||||
OOO_DLLPUBLIC_DBTOOLS
|
||||
bool getDataSourceSetting(
|
||||
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDataSource,
|
||||
const sal_Char* _pAsciiSettingsName,
|
||||
::com::sun::star::uno::Any& /* [out] */ _rSettingsValue
|
||||
);
|
||||
OOO_DLLPUBLIC_DBTOOLS
|
||||
bool getDataSourceSetting(
|
||||
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDataSource,
|
||||
const ::rtl::OUString& _sSettingsName,
|
||||
::com::sun::star::uno::Any& /* [out] */ _rSettingsValue
|
||||
);
|
||||
|
||||
OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString getDefaultReportEngineServiceName(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
|
||||
|
||||
/** quote the given name with the given quote string.
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/sdb/XColumn.hpp>
|
||||
#include <com/sun/star/sdb/XColumnUpdate.hpp>
|
||||
#include <com/sun/star/util/XNumberFormatter.hpp>
|
||||
/** === end UNO includes === **/
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
@ -77,6 +78,19 @@ namespace dbtools
|
|||
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn
|
||||
);
|
||||
|
||||
/** constructs an instance
|
||||
|
||||
The format key for the string value exchange is taken from the given column object.
|
||||
If it has a non-<NULL/> property value <code>FormatKey</code>, this key is taken.
|
||||
Otherwise, a default format matching the column type is determined.
|
||||
|
||||
The locale of this fallback format is the current system locale.
|
||||
*/
|
||||
FormattedColumnValue(
|
||||
const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& i_rNumberFormatter,
|
||||
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_rColumn
|
||||
);
|
||||
|
||||
// note that all methods of this class need to be virtual, since it's
|
||||
// used in a load-on-demand context in module SVX
|
||||
|
||||
|
|
|
@ -143,73 +143,80 @@ sdbcx::ObjectType OIndexesHelper::appendObject( const ::rtl::OUString& _rForName
|
|||
if ( m_pTable->isNew() )
|
||||
return cloneDescriptor( descriptor );
|
||||
|
||||
::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
|
||||
::rtl::OUStringBuffer aSql( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CREATE ")));
|
||||
::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
|
||||
::rtl::OUString aDot = ::rtl::OUString::createFromAscii(".");
|
||||
|
||||
if(comphelper::getBOOL(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISUNIQUE))))
|
||||
aSql.appendAscii("UNIQUE ");
|
||||
aSql.appendAscii("INDEX ");
|
||||
|
||||
|
||||
::rtl::OUString aCatalog,aSchema,aTable;
|
||||
dbtools::qualifiedNameComponents(m_pTable->getMetaData(),m_pTable->getName(),aCatalog,aSchema,aTable,::dbtools::eInDataManipulation);
|
||||
::rtl::OUString aComposedName;
|
||||
|
||||
aComposedName = dbtools::composeTableName(m_pTable->getMetaData(),aCatalog,aSchema,aTable,sal_True,::dbtools::eInIndexDefinitions);
|
||||
if ( _rForName.getLength() )
|
||||
if ( m_pTable->getIndexService().is() )
|
||||
{
|
||||
aSql.append( ::dbtools::quoteName( aQuote, _rForName ) );
|
||||
aSql.appendAscii(" ON ");
|
||||
aSql.append(aComposedName);
|
||||
aSql.appendAscii(" ( ");
|
||||
|
||||
Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
|
||||
Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
|
||||
Reference< XPropertySet > xColProp;
|
||||
sal_Bool bAddIndexAppendix = ::dbtools::getBooleanDataSourceSetting( m_pTable->getConnection(), "AddIndexAppendix" );
|
||||
sal_Int32 nCount = xColumns->getCount();
|
||||
for(sal_Int32 i = 0 ; i < nCount; ++i)
|
||||
{
|
||||
xColProp.set(xColumns->getByIndex(i),UNO_QUERY);
|
||||
aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))));
|
||||
|
||||
if ( bAddIndexAppendix )
|
||||
{
|
||||
|
||||
aSql.appendAscii(any2bool(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISASCENDING)))
|
||||
?
|
||||
" ASC"
|
||||
:
|
||||
" DESC");
|
||||
}
|
||||
aSql.appendAscii(",");
|
||||
}
|
||||
aSql.setCharAt(aSql.getLength()-1,')');
|
||||
m_pTable->getIndexService()->addIndex(m_pTable,descriptor);
|
||||
}
|
||||
else
|
||||
{
|
||||
aSql.append(aComposedName);
|
||||
::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
|
||||
::rtl::OUStringBuffer aSql( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CREATE ")));
|
||||
::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
|
||||
::rtl::OUString aDot = ::rtl::OUString::createFromAscii(".");
|
||||
|
||||
Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
|
||||
Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
|
||||
Reference< XPropertySet > xColProp;
|
||||
if(xColumns->getCount() != 1)
|
||||
throw SQLException();
|
||||
if(comphelper::getBOOL(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISUNIQUE))))
|
||||
aSql.appendAscii("UNIQUE ");
|
||||
aSql.appendAscii("INDEX ");
|
||||
|
||||
xColumns->getByIndex(0) >>= xColProp;
|
||||
|
||||
aSql.append(aDot);
|
||||
aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))));
|
||||
}
|
||||
::rtl::OUString aCatalog,aSchema,aTable;
|
||||
dbtools::qualifiedNameComponents(m_pTable->getMetaData(),m_pTable->getName(),aCatalog,aSchema,aTable,::dbtools::eInDataManipulation);
|
||||
::rtl::OUString aComposedName;
|
||||
|
||||
Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
|
||||
if ( xStmt.is() )
|
||||
{
|
||||
::rtl::OUString sSql = aSql.makeStringAndClear();
|
||||
xStmt->execute(sSql);
|
||||
::comphelper::disposeComponent(xStmt);
|
||||
aComposedName = dbtools::composeTableName(m_pTable->getMetaData(),aCatalog,aSchema,aTable,sal_True,::dbtools::eInIndexDefinitions);
|
||||
if ( _rForName.getLength() )
|
||||
{
|
||||
aSql.append( ::dbtools::quoteName( aQuote, _rForName ) );
|
||||
aSql.appendAscii(" ON ");
|
||||
aSql.append(aComposedName);
|
||||
aSql.appendAscii(" ( ");
|
||||
|
||||
Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
|
||||
Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
|
||||
Reference< XPropertySet > xColProp;
|
||||
sal_Bool bAddIndexAppendix = ::dbtools::getBooleanDataSourceSetting( m_pTable->getConnection(), "AddIndexAppendix" );
|
||||
sal_Int32 nCount = xColumns->getCount();
|
||||
for(sal_Int32 i = 0 ; i < nCount; ++i)
|
||||
{
|
||||
xColProp.set(xColumns->getByIndex(i),UNO_QUERY);
|
||||
aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))));
|
||||
|
||||
if ( bAddIndexAppendix )
|
||||
{
|
||||
|
||||
aSql.appendAscii(any2bool(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISASCENDING)))
|
||||
?
|
||||
" ASC"
|
||||
:
|
||||
" DESC");
|
||||
}
|
||||
aSql.appendAscii(",");
|
||||
}
|
||||
aSql.setCharAt(aSql.getLength()-1,')');
|
||||
}
|
||||
else
|
||||
{
|
||||
aSql.append(aComposedName);
|
||||
|
||||
Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
|
||||
Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
|
||||
Reference< XPropertySet > xColProp;
|
||||
if(xColumns->getCount() != 1)
|
||||
throw SQLException();
|
||||
|
||||
xColumns->getByIndex(0) >>= xColProp;
|
||||
|
||||
aSql.append(aDot);
|
||||
aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))));
|
||||
}
|
||||
|
||||
Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
|
||||
if ( xStmt.is() )
|
||||
{
|
||||
::rtl::OUString sSql = aSql.makeStringAndClear();
|
||||
xStmt->execute(sSql);
|
||||
::comphelper::disposeComponent(xStmt);
|
||||
}
|
||||
}
|
||||
|
||||
return createObject( _rForName );
|
||||
|
@ -221,27 +228,34 @@ void OIndexesHelper::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElem
|
|||
Reference< XConnection> xConnection = m_pTable->getConnection();
|
||||
if( xConnection.is() && !m_pTable->isNew())
|
||||
{
|
||||
::rtl::OUString aName,aSchema;
|
||||
sal_Int32 nLen = _sElementName.indexOf('.');
|
||||
if(nLen != -1)
|
||||
aSchema = _sElementName.copy(0,nLen);
|
||||
aName = _sElementName.copy(nLen+1);
|
||||
|
||||
::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP INDEX ");
|
||||
|
||||
::rtl::OUString aComposedName = dbtools::composeTableName( m_pTable->getMetaData(), m_pTable, ::dbtools::eInIndexDefinitions, false, false, true );
|
||||
::rtl::OUString sIndexName,sTemp;
|
||||
sIndexName = dbtools::composeTableName( m_pTable->getMetaData(), sTemp, aSchema, aName, sal_True, ::dbtools::eInIndexDefinitions );
|
||||
|
||||
aSql += sIndexName
|
||||
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ON "))
|
||||
+ aComposedName;
|
||||
|
||||
Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
|
||||
if ( xStmt.is() )
|
||||
if ( m_pTable->getIndexService().is() )
|
||||
{
|
||||
xStmt->execute(aSql);
|
||||
::comphelper::disposeComponent(xStmt);
|
||||
m_pTable->getIndexService()->dropIndex(m_pTable,_sElementName);
|
||||
}
|
||||
else
|
||||
{
|
||||
::rtl::OUString aName,aSchema;
|
||||
sal_Int32 nLen = _sElementName.indexOf('.');
|
||||
if(nLen != -1)
|
||||
aSchema = _sElementName.copy(0,nLen);
|
||||
aName = _sElementName.copy(nLen+1);
|
||||
|
||||
::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP INDEX ");
|
||||
|
||||
::rtl::OUString aComposedName = dbtools::composeTableName( m_pTable->getMetaData(), m_pTable, ::dbtools::eInIndexDefinitions, false, false, true );
|
||||
::rtl::OUString sIndexName,sTemp;
|
||||
sIndexName = dbtools::composeTableName( m_pTable->getMetaData(), sTemp, aSchema, aName, sal_True, ::dbtools::eInIndexDefinitions );
|
||||
|
||||
aSql += sIndexName
|
||||
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ON "))
|
||||
+ aComposedName;
|
||||
|
||||
Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
|
||||
if ( xStmt.is() )
|
||||
{
|
||||
xStmt->execute(aSql);
|
||||
::comphelper::disposeComponent(xStmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,69 +150,80 @@ sdbcx::ObjectType OKeysHelper::appendObject( const ::rtl::OUString& _rForName, c
|
|||
return xNewDescriptor;
|
||||
}
|
||||
|
||||
// if we're here, we belong to a table which is not new, i.e. already exists in the database.
|
||||
// In this case, really append the new index.
|
||||
|
||||
const ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
|
||||
sal_Int32 nKeyType = getINT32(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)));
|
||||
|
||||
::rtl::OUString aSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ALTER TABLE "));
|
||||
::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( );
|
||||
::rtl::OUString aDot = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("."));
|
||||
|
||||
aSql += composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable, ::dbtools::eInTableDefinitions, false, false, true );
|
||||
aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ADD "));
|
||||
|
||||
if ( nKeyType == KeyType::PRIMARY )
|
||||
{
|
||||
aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" PRIMARY KEY ("));
|
||||
}
|
||||
else if ( nKeyType == KeyType::FOREIGN )
|
||||
{
|
||||
aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FOREIGN KEY ("));
|
||||
}
|
||||
else
|
||||
throw SQLException();
|
||||
|
||||
Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
|
||||
Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
|
||||
Reference< XPropertySet > xColProp;
|
||||
for(sal_Int32 i=0;i<xColumns->getCount();++i)
|
||||
{
|
||||
::cppu::extractInterface(xColProp,xColumns->getByIndex(i));
|
||||
aSql += ::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))))
|
||||
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
|
||||
}
|
||||
aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
|
||||
|
||||
sal_Int32 nUpdateRule = 0, nDeleteRule = 0;
|
||||
::rtl::OUString sReferencedName;
|
||||
|
||||
if ( nKeyType == KeyType::FOREIGN )
|
||||
{
|
||||
descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)) >>= sReferencedName;
|
||||
|
||||
aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" REFERENCES "))
|
||||
+ ::dbtools::quoteTableName(m_pTable->getConnection()->getMetaData(),sReferencedName,::dbtools::eInTableDefinitions);
|
||||
aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ("));
|
||||
|
||||
for(sal_Int32 i=0;i<xColumns->getCount();++i)
|
||||
{
|
||||
xColumns->getByIndex(i) >>= xColProp;
|
||||
aSql += ::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_RELATEDCOLUMN))))
|
||||
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
|
||||
}
|
||||
aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
|
||||
|
||||
descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_UPDATERULE)) >>= nUpdateRule;
|
||||
descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DELETERULE)) >>= nDeleteRule;
|
||||
|
||||
aSql += getKeyRuleString(sal_True ,nUpdateRule);
|
||||
aSql += getKeyRuleString(sal_False ,nDeleteRule);
|
||||
}
|
||||
|
||||
Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
|
||||
xStmt->execute(aSql);
|
||||
if ( m_pTable->getKeyService().is() )
|
||||
{
|
||||
m_pTable->getKeyService()->addKey(m_pTable,descriptor);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we're here, we belong to a table which is not new, i.e. already exists in the database.
|
||||
// In this case, really append the new index.
|
||||
::rtl::OUStringBuffer aSql;
|
||||
aSql.appendAscii("ALTER TABLE ");
|
||||
::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( );
|
||||
::rtl::OUString aDot = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("."));
|
||||
|
||||
aSql.append(composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable, ::dbtools::eInTableDefinitions, false, false, true ));
|
||||
aSql.appendAscii(" ADD ");
|
||||
|
||||
if ( nKeyType == KeyType::PRIMARY )
|
||||
{
|
||||
aSql.appendAscii(" PRIMARY KEY (");
|
||||
}
|
||||
else if ( nKeyType == KeyType::FOREIGN )
|
||||
{
|
||||
aSql.appendAscii(" FOREIGN KEY (");
|
||||
}
|
||||
else
|
||||
throw SQLException();
|
||||
|
||||
Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
|
||||
Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
|
||||
Reference< XPropertySet > xColProp;
|
||||
for(sal_Int32 i = 0 ; i < xColumns->getCount() ; ++i)
|
||||
{
|
||||
if ( i > 0 )
|
||||
aSql.appendAscii(",");
|
||||
::cppu::extractInterface(xColProp,xColumns->getByIndex(i));
|
||||
aSql.append( ::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))) );
|
||||
|
||||
}
|
||||
aSql.appendAscii(")");
|
||||
|
||||
if ( nKeyType == KeyType::FOREIGN )
|
||||
{
|
||||
aSql.appendAscii(" REFERENCES ");
|
||||
aSql.append(::dbtools::quoteTableName(m_pTable->getConnection()->getMetaData(),sReferencedName,::dbtools::eInTableDefinitions));
|
||||
aSql.appendAscii(" (");
|
||||
|
||||
for(sal_Int32 i=0;i<xColumns->getCount();++i)
|
||||
{
|
||||
if ( i > 0 )
|
||||
aSql.appendAscii(",");
|
||||
xColumns->getByIndex(i) >>= xColProp;
|
||||
aSql.append(::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_RELATEDCOLUMN)))));
|
||||
|
||||
}
|
||||
aSql.appendAscii(")");
|
||||
aSql.append(getKeyRuleString(sal_True ,nUpdateRule));
|
||||
aSql.append(getKeyRuleString(sal_False ,nDeleteRule));
|
||||
}
|
||||
|
||||
Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
|
||||
xStmt->execute(aSql.makeStringAndClear());
|
||||
}
|
||||
// find the name which the database gave the new key
|
||||
::rtl::OUString sNewName( _rForName );
|
||||
try
|
||||
|
@ -269,34 +280,41 @@ void OKeysHelper::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName
|
|||
Reference< XConnection> xConnection = m_pTable->getConnection();
|
||||
if ( xConnection.is() && !m_pTable->isNew() )
|
||||
{
|
||||
::rtl::OUString aSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ALTER TABLE "));
|
||||
|
||||
aSql += composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable,::dbtools::eInTableDefinitions, false, false, true );
|
||||
|
||||
Reference<XPropertySet> xKey(getObject(_nPos),UNO_QUERY);
|
||||
|
||||
sal_Int32 nKeyType = KeyType::PRIMARY;
|
||||
if ( xKey.is() )
|
||||
if ( m_pTable->getKeyService().is() )
|
||||
{
|
||||
::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
|
||||
xKey->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)) >>= nKeyType;
|
||||
}
|
||||
if ( KeyType::PRIMARY == nKeyType )
|
||||
{
|
||||
aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DROP PRIMARY KEY"));
|
||||
m_pTable->getKeyService()->dropKey(m_pTable,xKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
aSql += getDropForeignKey();
|
||||
const ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString();
|
||||
aSql += ::dbtools::quoteName( aQuote,_sElementName);
|
||||
}
|
||||
::rtl::OUStringBuffer aSql;
|
||||
aSql.appendAscii("ALTER TABLE ");
|
||||
|
||||
Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
|
||||
if ( xStmt.is() )
|
||||
{
|
||||
xStmt->execute(aSql);
|
||||
::comphelper::disposeComponent(xStmt);
|
||||
aSql.append( composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable,::dbtools::eInTableDefinitions, false, false, true ));
|
||||
|
||||
sal_Int32 nKeyType = KeyType::PRIMARY;
|
||||
if ( xKey.is() )
|
||||
{
|
||||
::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
|
||||
xKey->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)) >>= nKeyType;
|
||||
}
|
||||
if ( KeyType::PRIMARY == nKeyType )
|
||||
{
|
||||
aSql.appendAscii(" DROP PRIMARY KEY");
|
||||
}
|
||||
else
|
||||
{
|
||||
aSql.append(getDropForeignKey());
|
||||
const ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString();
|
||||
aSql.append( ::dbtools::quoteName( aQuote,_sElementName) );
|
||||
}
|
||||
|
||||
Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
|
||||
if ( xStmt.is() )
|
||||
{
|
||||
xStmt->execute(aSql.makeStringAndClear());
|
||||
::comphelper::disposeComponent(xStmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,11 +101,40 @@ namespace connectivity
|
|||
struct OTableHelperImpl
|
||||
{
|
||||
TKeyMap m_aKeys;
|
||||
Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
|
||||
// helper services which can be provided by extensions
|
||||
Reference< ::com::sun::star::sdb::tools::XTableRename> m_xRename;
|
||||
Reference< ::com::sun::star::sdb::tools::XTableAlteration> m_xAlter;
|
||||
Reference< ::com::sun::star::sdb::tools::XKeyAlteration> m_xKeyAlter;
|
||||
Reference< ::com::sun::star::sdb::tools::XIndexAlteration> m_xIndexAlter;
|
||||
|
||||
Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
|
||||
Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
|
||||
::comphelper::ImplementationReference< OTableContainerListener,XContainerListener>
|
||||
m_xTablePropertyListener;
|
||||
::std::vector< ColumnDesc > m_aColumnDesc;
|
||||
OTableHelperImpl(const Reference< ::com::sun::star::sdbc::XConnection >& _xConnection)
|
||||
: m_xConnection(_xConnection)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_xMetaData = m_xConnection->getMetaData();
|
||||
Reference<XMultiServiceFactory> xFac(_xConnection,UNO_QUERY);
|
||||
if ( xFac.is() )
|
||||
{
|
||||
static const ::rtl::OUString s_sTableRename(RTL_CONSTASCII_USTRINGPARAM("TableRenameServiceName"));
|
||||
m_xRename.set(xFac->createInstance(s_sTableRename),UNO_QUERY);
|
||||
static const ::rtl::OUString s_sTableAlteration(RTL_CONSTASCII_USTRINGPARAM("TableAlterationServiceName"));
|
||||
m_xAlter.set(xFac->createInstance(s_sTableAlteration),UNO_QUERY);
|
||||
static const ::rtl::OUString s_sKeyAlteration(RTL_CONSTASCII_USTRINGPARAM("KeyAlterationServiceName"));
|
||||
m_xKeyAlter.set(xFac->createInstance(s_sKeyAlteration),UNO_QUERY);
|
||||
static const ::rtl::OUString s_sIndexAlteration(RTL_CONSTASCII_USTRINGPARAM("IndexAlterationServiceName"));
|
||||
m_xIndexAlter.set(xFac->createInstance(s_sIndexAlteration),UNO_QUERY);
|
||||
}
|
||||
}
|
||||
catch(const Exception&)
|
||||
{
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -113,16 +142,8 @@ OTableHelper::OTableHelper( sdbcx::OCollection* _pTables,
|
|||
const Reference< XConnection >& _xConnection,
|
||||
sal_Bool _bCase)
|
||||
:OTable_TYPEDEF(_pTables,_bCase)
|
||||
,m_pImpl(new OTableHelperImpl)
|
||||
,m_pImpl(new OTableHelperImpl(_xConnection))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_pImpl->m_xConnection = _xConnection;
|
||||
m_pImpl->m_xMetaData = m_pImpl->m_xConnection->getMetaData();
|
||||
}
|
||||
catch(const Exception&)
|
||||
{
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
OTableHelper::OTableHelper( sdbcx::OCollection* _pTables,
|
||||
|
@ -140,16 +161,8 @@ OTableHelper::OTableHelper( sdbcx::OCollection* _pTables,
|
|||
_Description,
|
||||
_SchemaName,
|
||||
_CatalogName)
|
||||
,m_pImpl(new OTableHelperImpl)
|
||||
,m_pImpl(new OTableHelperImpl(_xConnection))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_pImpl->m_xConnection = _xConnection;
|
||||
m_pImpl->m_xMetaData = m_pImpl->m_xConnection->getMetaData();
|
||||
}
|
||||
catch(const Exception&)
|
||||
{
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
OTableHelper::~OTableHelper()
|
||||
|
@ -483,24 +496,31 @@ void SAL_CALL OTableHelper::rename( const ::rtl::OUString& newName ) throw(SQLEx
|
|||
|
||||
if(!isNew())
|
||||
{
|
||||
::rtl::OUString sSql = getRenameStart();
|
||||
::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
|
||||
|
||||
::rtl::OUString sCatalog,sSchema,sTable;
|
||||
::dbtools::qualifiedNameComponents(getMetaData(),newName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
|
||||
|
||||
::rtl::OUString sComposedName;
|
||||
sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,sal_True,::dbtools::eInDataManipulation);
|
||||
sSql += sComposedName
|
||||
+ ::rtl::OUString::createFromAscii(" TO ");
|
||||
sComposedName = ::dbtools::composeTableName(getMetaData(),sCatalog,sSchema,sTable,sal_True,::dbtools::eInDataManipulation);
|
||||
sSql += sComposedName;
|
||||
|
||||
Reference< XStatement > xStmt = m_pImpl->m_xConnection->createStatement( );
|
||||
if ( xStmt.is() )
|
||||
if ( m_pImpl->m_xRename.is() )
|
||||
{
|
||||
xStmt->execute(sSql);
|
||||
::comphelper::disposeComponent(xStmt);
|
||||
m_pImpl->m_xRename->rename(this,newName);
|
||||
}
|
||||
else
|
||||
{
|
||||
::rtl::OUString sSql = getRenameStart();
|
||||
::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
|
||||
|
||||
::rtl::OUString sCatalog,sSchema,sTable;
|
||||
::dbtools::qualifiedNameComponents(getMetaData(),newName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
|
||||
|
||||
::rtl::OUString sComposedName;
|
||||
sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,sal_True,::dbtools::eInDataManipulation);
|
||||
sSql += sComposedName
|
||||
+ ::rtl::OUString::createFromAscii(" TO ");
|
||||
sComposedName = ::dbtools::composeTableName(getMetaData(),sCatalog,sSchema,sTable,sal_True,::dbtools::eInDataManipulation);
|
||||
sSql += sComposedName;
|
||||
|
||||
Reference< XStatement > xStmt = m_pImpl->m_xConnection->createStatement( );
|
||||
if ( xStmt.is() )
|
||||
{
|
||||
xStmt->execute(sSql);
|
||||
::comphelper::disposeComponent(xStmt);
|
||||
}
|
||||
}
|
||||
|
||||
OTable_TYPEDEF::rename(newName);
|
||||
|
@ -579,3 +599,24 @@ Reference< XConnection> OTableHelper::getConnection() const
|
|||
{
|
||||
return m_pImpl->m_xConnection;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
Reference< ::com::sun::star::sdb::tools::XTableRename> OTableHelper::getRenameService() const
|
||||
{
|
||||
return m_pImpl->m_xRename;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
Reference< ::com::sun::star::sdb::tools::XTableAlteration> OTableHelper::getAlterService() const
|
||||
{
|
||||
return m_pImpl->m_xAlter;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
Reference< ::com::sun::star::sdb::tools::XKeyAlteration> OTableHelper::getKeyService() const
|
||||
{
|
||||
return m_pImpl->m_xKeyAlter;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
Reference< ::com::sun::star::sdb::tools::XIndexAlteration> OTableHelper::getIndexService() const
|
||||
{
|
||||
return m_pImpl->m_xIndexAlter;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -596,7 +596,39 @@ bool getBooleanDataSourceSetting( const Reference< XConnection >& _rxConnection,
|
|||
}
|
||||
return bValue;
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
bool getDataSourceSetting( const Reference< XInterface >& _xChild, const ::rtl::OUString& _sAsciiSettingsName,
|
||||
Any& /* [out] */ _rSettingsValue )
|
||||
{
|
||||
bool bIsPresent = false;
|
||||
try
|
||||
{
|
||||
const Reference< XPropertySet> xDataSourceProperties( findDataSource( _xChild ), UNO_QUERY );
|
||||
OSL_ENSURE( xDataSourceProperties.is(), "getDataSourceSetting: invalid data source object!" );
|
||||
if ( !xDataSourceProperties.is() )
|
||||
return false;
|
||||
|
||||
const Reference< XPropertySet > xSettings(
|
||||
xDataSourceProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings") ) ),
|
||||
UNO_QUERY_THROW
|
||||
);
|
||||
|
||||
_rSettingsValue = xSettings->getPropertyValue( _sAsciiSettingsName );
|
||||
bIsPresent = true;
|
||||
}
|
||||
catch( const Exception& )
|
||||
{
|
||||
bIsPresent = false;
|
||||
}
|
||||
return bIsPresent;
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
bool getDataSourceSetting( const Reference< XInterface >& _rxDataSource, const sal_Char* _pAsciiSettingsName,
|
||||
Any& /* [out] */ _rSettingsValue )
|
||||
{
|
||||
::rtl::OUString sAsciiSettingsName = ::rtl::OUString::createFromAscii(_pAsciiSettingsName);
|
||||
return getDataSourceSetting( _rxDataSource, sAsciiSettingsName,_rSettingsValue );
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
sal_Bool isDataSourcePropertyEnabled(const Reference<XInterface>& _xProp,const ::rtl::OUString& _sProperty,sal_Bool _bDefault)
|
||||
{
|
||||
|
|
|
@ -45,13 +45,11 @@
|
|||
/** === end UNO includes === **/
|
||||
|
||||
//#include <unotools/syslocale.hxx>
|
||||
|
||||
#include <tools/diagnose_ex.h>
|
||||
|
||||
#include <i18npool/mslangid.hxx>
|
||||
|
||||
#include <comphelper/numbers.hxx>
|
||||
#include <comphelper/componentcontext.hxx>
|
||||
#include <unotools/sharedunocomponent.hxx>
|
||||
|
||||
//........................................................................
|
||||
namespace dbtools
|
||||
|
@ -62,6 +60,7 @@ namespace dbtools
|
|||
using ::com::sun::star::uno::Reference;
|
||||
using ::com::sun::star::uno::UNO_QUERY;
|
||||
using ::com::sun::star::uno::UNO_QUERY_THROW;
|
||||
using ::com::sun::star::uno::UNO_SET_THROW;
|
||||
using ::com::sun::star::uno::Exception;
|
||||
using ::com::sun::star::uno::RuntimeException;
|
||||
using ::com::sun::star::uno::Any;
|
||||
|
@ -116,21 +115,7 @@ namespace dbtools
|
|||
//................................................................
|
||||
void lcl_clear_nothrow( FormattedColumnValue_Data& _rData )
|
||||
{
|
||||
if ( _rData.m_xFormatter.is() )
|
||||
{
|
||||
try
|
||||
{
|
||||
Reference< XComponent > xFormatterComp( _rData.m_xFormatter, UNO_QUERY );
|
||||
if ( xFormatterComp.is() )
|
||||
xFormatterComp->dispose();
|
||||
}
|
||||
catch( const Exception& )
|
||||
{
|
||||
DBG_UNHANDLED_EXCEPTION();
|
||||
}
|
||||
_rData.m_xFormatter.clear();
|
||||
}
|
||||
|
||||
_rData.m_xFormatter.clear();
|
||||
_rData.m_nFormatKey = 0;
|
||||
_rData.m_nFieldType = DataType::OTHER;
|
||||
_rData.m_nKeyType = NumberFormat::UNDEFINED;
|
||||
|
@ -141,21 +126,24 @@ namespace dbtools
|
|||
}
|
||||
|
||||
//................................................................
|
||||
void lcl_initColumnDataValue_nothrow( const ::comphelper::ComponentContext& _rContext, FormattedColumnValue_Data& _rData,
|
||||
const Reference< XRowSet >& _rxRowSet, const Reference< XPropertySet >& _rxColumn )
|
||||
void lcl_initColumnDataValue_nothrow( FormattedColumnValue_Data& _rData,
|
||||
const Reference< XNumberFormatter >& i_rNumberFormatter, const Reference< XPropertySet >& _rxColumn )
|
||||
{
|
||||
lcl_clear_nothrow( _rData );
|
||||
|
||||
OSL_PRECOND( _rxRowSet.is(), "lcl_initColumnDataValue_nothrow: no row set!" );
|
||||
OSL_PRECOND( _rxColumn.is(), "lcl_initColumnDataValue_nothrow: no column!" );
|
||||
if ( !_rxRowSet.is() || !_rxColumn.is() )
|
||||
OSL_PRECOND( i_rNumberFormatter.is(), "lcl_initColumnDataValue_nothrow: no number formats -> no formatted values!" );
|
||||
if ( !i_rNumberFormatter.is() )
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
Reference< XNumberFormatsSupplier > xNumberFormatsSupp( i_rNumberFormatter->getNumberFormatsSupplier(), UNO_SET_THROW );
|
||||
|
||||
// remember the column
|
||||
_rData.m_xColumn.set( _rxColumn, UNO_QUERY_THROW );
|
||||
_rData.m_xColumnUpdate.set( _rxColumn, UNO_QUERY );
|
||||
|
||||
// determine the field type, and whether it's a numeric field
|
||||
OSL_VERIFY( _rxColumn->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) ) ) >>= _rData.m_nFieldType );
|
||||
|
||||
switch ( _rData.m_nFieldType )
|
||||
|
@ -180,10 +168,6 @@ namespace dbtools
|
|||
break;
|
||||
}
|
||||
|
||||
// get the number formats supplier of the connection of the form
|
||||
Reference< XConnection > xConnection( getConnection( _rxRowSet ), UNO_QUERY_THROW );
|
||||
Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( xConnection, sal_False, _rContext.getLegacyServiceFactory() ), UNO_QUERY_THROW );
|
||||
|
||||
// get the format key of our bound field
|
||||
Reference< XPropertySetInfo > xPSI( _rxColumn->getPropertySetInfo(), UNO_QUERY_THROW );
|
||||
bool bHaveFieldFormat = false;
|
||||
|
@ -197,35 +181,69 @@ namespace dbtools
|
|||
// fall back to a format key as indicated by the field type
|
||||
Locale aSystemLocale;
|
||||
MsLangId::convertLanguageToLocale( MsLangId::getSystemLanguage(), aSystemLocale );
|
||||
Reference< XNumberFormatTypes > xNumTypes( xSupplier->getNumberFormats(), UNO_QUERY_THROW );
|
||||
Reference< XNumberFormatTypes > xNumTypes( xNumberFormatsSupp->getNumberFormats(), UNO_QUERY_THROW );
|
||||
_rData.m_nFormatKey = getDefaultNumberFormat( _rxColumn, xNumTypes, aSystemLocale );
|
||||
}
|
||||
|
||||
// some more formatter settings
|
||||
_rData.m_nKeyType = ::comphelper::getNumberFormatType( xSupplier->getNumberFormats(), _rData.m_nFormatKey );
|
||||
Reference< XPropertySet > xFormatSettings( xSupplier->getNumberFormatSettings(), UNO_QUERY_THROW );
|
||||
_rData.m_nKeyType = ::comphelper::getNumberFormatType( xNumberFormatsSupp->getNumberFormats(), _rData.m_nFormatKey );
|
||||
Reference< XPropertySet > xFormatSettings( xNumberFormatsSupp->getNumberFormatSettings(), UNO_QUERY_THROW );
|
||||
OSL_VERIFY( xFormatSettings->getPropertyValue( ::rtl::OUString::createFromAscii( "NullDate" ) ) >>= _rData.m_aNullDate );
|
||||
|
||||
// create a formatter working with the connection's number format supplier
|
||||
_rData.m_xFormatter.set( _rContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY_THROW );
|
||||
_rData.m_xFormatter->attachNumberFormatsSupplier( xSupplier );
|
||||
// remember the formatter
|
||||
_rData.m_xFormatter = i_rNumberFormatter;
|
||||
}
|
||||
catch( const Exception& )
|
||||
{
|
||||
DBG_UNHANDLED_EXCEPTION();
|
||||
}
|
||||
}
|
||||
|
||||
//................................................................
|
||||
void lcl_initColumnDataValue_nothrow( const ::comphelper::ComponentContext& i_rContext, FormattedColumnValue_Data& i_rData,
|
||||
const Reference< XRowSet >& i_rRowSet, const Reference< XPropertySet >& i_rColumn )
|
||||
{
|
||||
OSL_PRECOND( i_rRowSet.is(), "lcl_initColumnDataValue_nothrow: no row set!" );
|
||||
if ( !i_rRowSet.is() )
|
||||
return;
|
||||
|
||||
Reference< XNumberFormatter > xNumberFormatter;
|
||||
try
|
||||
{
|
||||
// get the number formats supplier of the connection of the form
|
||||
Reference< XConnection > xConnection( getConnection( i_rRowSet ), UNO_QUERY_THROW );
|
||||
Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( xConnection, sal_True, i_rContext.getLegacyServiceFactory() ), UNO_SET_THROW );
|
||||
|
||||
// create a number formatter for it
|
||||
xNumberFormatter.set( i_rContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY_THROW );
|
||||
xNumberFormatter->attachNumberFormatsSupplier( xSupplier );
|
||||
}
|
||||
catch( const Exception& )
|
||||
{
|
||||
DBG_UNHANDLED_EXCEPTION();
|
||||
}
|
||||
|
||||
lcl_initColumnDataValue_nothrow( i_rData, xNumberFormatter, i_rColumn );
|
||||
}
|
||||
}
|
||||
|
||||
//====================================================================
|
||||
//= FormattedColumnValue
|
||||
//====================================================================
|
||||
//--------------------------------------------------------------------
|
||||
FormattedColumnValue::FormattedColumnValue( const ::comphelper::ComponentContext& _rContext,
|
||||
const Reference< XRowSet >& _rxRowSet, const Reference< XPropertySet >& _rxColumn )
|
||||
FormattedColumnValue::FormattedColumnValue( const ::comphelper::ComponentContext& i_rContext,
|
||||
const Reference< XRowSet >& _rxRowSet, const Reference< XPropertySet >& i_rColumn )
|
||||
:m_pData( new FormattedColumnValue_Data )
|
||||
{
|
||||
lcl_initColumnDataValue_nothrow( _rContext, *m_pData, _rxRowSet, _rxColumn );
|
||||
lcl_initColumnDataValue_nothrow( i_rContext, *m_pData, _rxRowSet, i_rColumn );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
FormattedColumnValue::FormattedColumnValue( const Reference< XNumberFormatter >& i_rNumberFormatter,
|
||||
const Reference< XPropertySet >& _rxColumn )
|
||||
:m_pData( new FormattedColumnValue_Data )
|
||||
{
|
||||
lcl_initColumnDataValue_nothrow( *m_pData, i_rNumberFormatter, _rxColumn );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -157,6 +157,11 @@
|
|||
<value>3</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name="ColumnAliasInOrderBy" oor:op="replace">
|
||||
<prop oor:name="Value" oor:type="xs:boolean">
|
||||
<value>false</value>
|
||||
</prop>
|
||||
</node>
|
||||
</node>
|
||||
<node oor:name="Features">
|
||||
<node oor:name="UseSQL92NamingConstraints" oor:op="replace">
|
||||
|
|
|
@ -214,7 +214,7 @@ void SAL_CALL OHSQLTable::alterColumnByName( const ::rtl::OUString& colName, con
|
|||
// now we should look if the name of the column changed
|
||||
::rtl::OUString sNewColumnName;
|
||||
descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_NAME)) >>= sNewColumnName;
|
||||
if ( !sNewColumnName.equalsIgnoreAsciiCase(colName) )
|
||||
if ( !sNewColumnName.equals(colName) )
|
||||
{
|
||||
const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
|
||||
|
||||
|
|
|
@ -712,38 +712,44 @@ void java_sql_Statement_Base::getFastPropertyValue(
|
|||
) const
|
||||
{
|
||||
java_sql_Statement_Base* THIS = const_cast<java_sql_Statement_Base*>(this);
|
||||
switch(nHandle)
|
||||
try
|
||||
{
|
||||
switch(nHandle)
|
||||
{
|
||||
case PROPERTY_ID_QUERYTIMEOUT:
|
||||
rValue <<= THIS->getQueryTimeOut();
|
||||
break;
|
||||
case PROPERTY_ID_MAXFIELDSIZE:
|
||||
rValue <<= THIS->getMaxFieldSize();
|
||||
break;
|
||||
case PROPERTY_ID_MAXROWS:
|
||||
rValue <<= THIS->getMaxRows();
|
||||
break;
|
||||
case PROPERTY_ID_CURSORNAME:
|
||||
rValue <<= THIS->getCursorName();
|
||||
break;
|
||||
case PROPERTY_ID_RESULTSETCONCURRENCY:
|
||||
rValue <<= THIS->getResultSetConcurrency();
|
||||
break;
|
||||
case PROPERTY_ID_RESULTSETTYPE:
|
||||
rValue <<= THIS->getResultSetType();
|
||||
break;
|
||||
case PROPERTY_ID_FETCHDIRECTION:
|
||||
rValue <<= THIS->getFetchDirection();
|
||||
break;
|
||||
case PROPERTY_ID_FETCHSIZE:
|
||||
rValue <<= THIS->getFetchSize();
|
||||
break;
|
||||
case PROPERTY_ID_ESCAPEPROCESSING:
|
||||
rValue <<= (sal_Bool)m_bEscapeProcessing;
|
||||
break;
|
||||
case PROPERTY_ID_USEBOOKMARKS:
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
catch(const Exception&)
|
||||
{
|
||||
case PROPERTY_ID_QUERYTIMEOUT:
|
||||
rValue <<= THIS->getQueryTimeOut();
|
||||
break;
|
||||
case PROPERTY_ID_MAXFIELDSIZE:
|
||||
rValue <<= THIS->getMaxFieldSize();
|
||||
break;
|
||||
case PROPERTY_ID_MAXROWS:
|
||||
rValue <<= THIS->getMaxRows();
|
||||
break;
|
||||
case PROPERTY_ID_CURSORNAME:
|
||||
rValue <<= THIS->getCursorName();
|
||||
break;
|
||||
case PROPERTY_ID_RESULTSETCONCURRENCY:
|
||||
rValue <<= THIS->getResultSetConcurrency();
|
||||
break;
|
||||
case PROPERTY_ID_RESULTSETTYPE:
|
||||
rValue <<= THIS->getResultSetType();
|
||||
break;
|
||||
case PROPERTY_ID_FETCHDIRECTION:
|
||||
rValue <<= THIS->getFetchDirection();
|
||||
break;
|
||||
case PROPERTY_ID_FETCHSIZE:
|
||||
rValue <<= THIS->getFetchSize();
|
||||
break;
|
||||
case PROPERTY_ID_ESCAPEPROCESSING:
|
||||
rValue <<= (sal_Bool)m_bEscapeProcessing;
|
||||
break;
|
||||
case PROPERTY_ID_USEBOOKMARKS:
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
|
@ -33,12 +33,6 @@
|
|||
#include <MNSINIParser.hxx>
|
||||
#include <rtl/byteseq.hxx>
|
||||
|
||||
ini_Section * IniParser::getSection(OUString const & secName)
|
||||
{
|
||||
if (mAllSection.find(secName) != mAllSection.end())
|
||||
return &mAllSection[secName];
|
||||
return NULL;
|
||||
}
|
||||
IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException )
|
||||
{
|
||||
OUString iniUrl;
|
||||
|
|
|
@ -75,7 +75,6 @@ class IniParser
|
|||
IniSectionMap mAllSection;
|
||||
public:
|
||||
IniSectionMap * getAllSection(){return &mAllSection;};
|
||||
ini_Section * getSection(OUString const & secName);
|
||||
IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException );
|
||||
#if OSL_DEBUG_LEVEL > 0
|
||||
void Dump();
|
||||
|
|
|
@ -284,7 +284,7 @@ void SAL_CALL OMySQLTable::alterColumnByName( const ::rtl::OUString& colName, co
|
|||
const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
|
||||
sSql += ::dbtools::quoteName(sQuote,colName);
|
||||
sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
|
||||
sSql += ::dbtools::createStandardColumnPart(descriptor,getConnection(),getTypeCreatePattern());
|
||||
sSql += OTables::adjustSQL(::dbtools::createStandardColumnPart(descriptor,getConnection(),getTypeCreatePattern()));
|
||||
executeStatement(sSql);
|
||||
}
|
||||
m_pColumns->refresh();
|
||||
|
@ -313,7 +313,7 @@ void OMySQLTable::alterColumnType(sal_Int32 nNewType,const ::rtl::OUString& _rCo
|
|||
::comphelper::copyProperties(_xDescriptor,xProp);
|
||||
xProp->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),makeAny(nNewType));
|
||||
|
||||
sSql += ::dbtools::createStandardColumnPart(xProp,getConnection(),getTypeCreatePattern());
|
||||
sSql += OTables::adjustSQL(::dbtools::createStandardColumnPart(xProp,getConnection(),getTypeCreatePattern()));
|
||||
executeStatement(sSql);
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -187,12 +187,27 @@ void OTables::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
|
|||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
::rtl::OUString OTables::adjustSQL(const ::rtl::OUString& _sSql)
|
||||
{
|
||||
::rtl::OUString sSQL = _sSql;
|
||||
static const ::rtl::OUString s_sUNSIGNED(RTL_CONSTASCII_USTRINGPARAM("UNSIGNED"));
|
||||
sal_Int32 nIndex = sSQL.indexOf(s_sUNSIGNED);
|
||||
while(nIndex != -1 )
|
||||
{
|
||||
sal_Int32 nParen = sSQL.indexOf(')',nIndex);
|
||||
sal_Int32 nPos = nIndex + s_sUNSIGNED.getLength();
|
||||
::rtl::OUString sNewUnsigned( sSQL.copy(nPos,nParen - nPos + 1));
|
||||
sSQL = sSQL.replaceAt(nIndex,s_sUNSIGNED.getLength()+sNewUnsigned.getLength(),sNewUnsigned + s_sUNSIGNED);
|
||||
nIndex = sSQL.indexOf(s_sUNSIGNED,nIndex + s_sUNSIGNED.getLength()+sNewUnsigned.getLength());
|
||||
}
|
||||
return sSQL;
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
void OTables::createTable( const Reference< XPropertySet >& descriptor )
|
||||
{
|
||||
const Reference< XConnection > xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
|
||||
static const ::rtl::OUString s_sCreatePattern(RTL_CONSTASCII_USTRINGPARAM("(M,D)"));
|
||||
const ::rtl::OUString aSql = ::dbtools::createSqlCreateTableStatement(descriptor,xConnection,s_sCreatePattern);
|
||||
|
||||
const ::rtl::OUString aSql = adjustSQL(::dbtools::createSqlCreateTableStatement(descriptor,xConnection,s_sCreatePattern));
|
||||
Reference< XStatement > xStmt = xConnection->createStatement( );
|
||||
if ( xStmt.is() )
|
||||
{
|
||||
|
|
|
@ -469,11 +469,9 @@ Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) thro
|
|||
return nRet;
|
||||
}
|
||||
|
||||
::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
|
||||
if ( aFind == m_aODBCColumnTypes.end() )
|
||||
aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,columnIndex))).first;
|
||||
const SWORD nColumnType = impl_getColumnType_nothrow(columnIndex);
|
||||
|
||||
switch(aFind->second)
|
||||
switch(nColumnType)
|
||||
{
|
||||
case SQL_WVARCHAR:
|
||||
case SQL_WCHAR:
|
||||
|
@ -482,7 +480,7 @@ Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) thro
|
|||
case SQL_CHAR:
|
||||
case SQL_LONGVARCHAR:
|
||||
{
|
||||
::rtl::OUString aRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,aFind->second,m_bWasNull,**this,m_nTextEncoding);
|
||||
::rtl::OUString aRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,nColumnType,m_bWasNull,**this,m_nTextEncoding);
|
||||
return Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aRet.getStr()),sizeof(sal_Unicode)*aRet.getLength());
|
||||
}
|
||||
default:
|
||||
|
@ -627,10 +625,8 @@ sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLExcept
|
|||
else
|
||||
{
|
||||
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
||||
::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
|
||||
if ( aFind == m_aODBCColumnTypes.end() )
|
||||
aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,columnIndex))).first;
|
||||
nRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,aFind->second,m_bWasNull,**this,m_nTextEncoding);
|
||||
const SWORD nColumnType = impl_getColumnType_nothrow(columnIndex);
|
||||
nRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,nColumnType,m_bWasNull,**this,m_nTextEncoding);
|
||||
}
|
||||
return nRet;
|
||||
}
|
||||
|
@ -1505,10 +1501,8 @@ void OResultSet::fillRow(sal_Int32 _nToColumn)
|
|||
case DataType::LONGVARCHAR:
|
||||
case DataType::CLOB:
|
||||
{
|
||||
::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(nColumn);
|
||||
if ( aFind == m_aODBCColumnTypes.end() )
|
||||
aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(nColumn,OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,nColumn))).first;
|
||||
*pColumn = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,nColumn,aFind->second,m_bWasNull,**this,m_nTextEncoding);
|
||||
const SWORD nColumnType = impl_getColumnType_nothrow(nColumn);
|
||||
*pColumn = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,nColumn,nColumnType,m_bWasNull,**this,m_nTextEncoding);
|
||||
}
|
||||
break;
|
||||
case DataType::BIGINT:
|
||||
|
@ -1753,4 +1747,12 @@ void OResultSet::fillNeededData(SQLRETURN _nRet)
|
|||
while (nRet == SQL_NEED_DATA);
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
SWORD OResultSet::impl_getColumnType_nothrow(sal_Int32 columnIndex)
|
||||
{
|
||||
::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
|
||||
if ( aFind == m_aODBCColumnTypes.end() )
|
||||
aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,columnIndex))).first;
|
||||
return aFind->second;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,11 @@ namespace connectivity
|
|||
can contain () which have to filled with values
|
||||
*/
|
||||
static ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColProp);
|
||||
|
||||
/** convert the sql statement to fit MySQL notation
|
||||
@param _sSql in/out
|
||||
*/
|
||||
static ::rtl::OUString adjustSQL(const ::rtl::OUString& _sSql);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace connectivity
|
|||
sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
||||
sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
||||
::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
||||
SWORD impl_getColumnType_nothrow(sal_Int32 column);
|
||||
SWORD impl_getColumnType_nothrow(sal_Int32 columnIndex);
|
||||
|
||||
sal_Int32 mapColumn (sal_Int32 column);
|
||||
|
||||
|
|
|
@ -176,6 +176,7 @@ namespace connectivity
|
|||
sal_Bool moveImpl(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData);
|
||||
TVoidPtr allocBindColumn(sal_Int32 _nType,sal_Int32 _nColumnIndex);
|
||||
SQLRETURN unbind(sal_Bool _bUnbindHandle = sal_True);
|
||||
SWORD impl_getColumnType_nothrow(sal_Int32 columnIndex);
|
||||
|
||||
// OPropertyArrayUsageHelper
|
||||
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
|
||||
|
|
|
@ -598,7 +598,7 @@
|
|||
<value>GenericCategories</value>
|
||||
</prop>
|
||||
<prop oor:name="ooSetupFactoryUIName">
|
||||
<value>Table Data View</value>
|
||||
<value xml:lang="en-US">Base: Table Data View</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name="com.sun.star.frame.Bibliography" oor:op="replace">
|
||||
|
@ -620,7 +620,7 @@
|
|||
<value >GenericCategories</value>
|
||||
</prop>
|
||||
<prop oor:name="ooSetupFactoryUIName">
|
||||
<value >Bibliography</value>
|
||||
<value xml:lang="en-US">Bibliography</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name="com.sun.star.script.BasicIDE" oor:op="replace">
|
||||
|
|
|
@ -519,7 +519,7 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface >
|
|||
while (nCurrentSourceIndex <= nIndex)
|
||||
{
|
||||
sal_Bool bEqualDSS = sal_False;
|
||||
while (!bEqualDSS) // (we don't have to check nCurrentSourceIndex here : it's bounded by nIndex)
|
||||
while (!bEqualDSS) // (we don't have to check nCurrentSourceIndex here : it's bound by nIndex)
|
||||
{
|
||||
xSourceContainer->getByIndex(nCurrentSourceIndex) >>= xCurrentSourceForm;
|
||||
DBG_ASSERT(xCurrentSourceForm.is(), "FmFormObj::ensureModelEnv : invalid form ancestor (2) !");
|
||||
|
@ -581,12 +581,11 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface >
|
|||
// correct this ...
|
||||
try
|
||||
{
|
||||
Reference< XPersistObject > xSourcePersist(xCurrentSourceForm, UNO_QUERY);
|
||||
DBG_ASSERT(xSourcePersist.is(), "FmFormObj::ensureModelEnv : invalid form (no persist object) !");
|
||||
|
||||
// create and insert (into the destination) a clone of the form
|
||||
Reference< XCloneable > xCloneable( xSourcePersist, UNO_QUERY_THROW );
|
||||
xCurrentDestForm.set( xCloneable->createClone(), UNO_QUERY_THROW );
|
||||
// create and insert (into the destination) a copy of the form
|
||||
xCurrentDestForm.set(
|
||||
::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.form.component.DataForm" ) ),
|
||||
UNO_QUERY_THROW );
|
||||
::comphelper::copyProperties( xCurrentSourceForm, xCurrentDestForm );
|
||||
|
||||
DBG_ASSERT(nCurrentDestIndex == xDestContainer->getCount(), "FmFormObj::ensureModelEnv : something went wrong with the numbers !");
|
||||
xDestContainer->insertByIndex(nCurrentDestIndex, makeAny(xCurrentDestForm));
|
||||
|
@ -604,7 +603,7 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface >
|
|||
}
|
||||
}
|
||||
|
||||
// now xCurrentDestForm is a form aequivalent to xSourceForm (which means they have the same DSS and the same number
|
||||
// now xCurrentDestForm is a form equivalent to xSourceForm (which means they have the same DSS and the same number
|
||||
// of left siblings with the same DSS, which counts for all their ancestors, too)
|
||||
|
||||
// go down
|
||||
|
|
Loading…
Reference in a new issue