24#include <com/sun/star/awt/XWindow.hpp>
25#include <com/sun/star/beans/NamedValue.hpp>
26#include <com/sun/star/beans/PropertyAttribute.hpp>
27#include <com/sun/star/container/XChild.hpp>
28#include <com/sun/star/form/FormComponentType.hpp>
29#include <com/sun/star/io/XInputStream.hpp>
30#include <com/sun/star/lang/DisposedException.hpp>
31#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
32#include <com/sun/star/lang/XInitialization.hpp>
33#include <com/sun/star/lang/XMultiServiceFactory.hpp>
34#include <com/sun/star/sdb/DatabaseContext.hpp>
35#include <com/sun/star/sdb/BooleanComparisonMode.hpp>
36#include <com/sun/star/sdb/CommandType.hpp>
37#include <com/sun/star/sdb/ErrorMessageDialog.hpp>
38#include <com/sun/star/sdb/ParametersRequest.hpp>
39#include <com/sun/star/sdb/RowSetVetoException.hpp>
40#include <com/sun/star/sdb/SQLContext.hpp>
41#include <com/sun/star/sdb/XCompletedConnection.hpp>
42#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
43#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
44#include <com/sun/star/sdb/XParametersSupplier.hpp>
45#include <com/sun/star/sdb/XQueriesSupplier.hpp>
46#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
47#include <com/sun/star/sdbc/ConnectionPool.hpp>
48#include <com/sun/star/sdbc/DataType.hpp>
49#include <com/sun/star/sdbc/XConnection.hpp>
50#include <com/sun/star/sdbc/XDataSource.hpp>
51#include <com/sun/star/sdbc/XParameters.hpp>
52#include <com/sun/star/sdbc/XRow.hpp>
53#include <com/sun/star/sdbc/XRowSet.hpp>
54#include <com/sun/star/sdbc/XRowUpdate.hpp>
55#include <com/sun/star/sdbcx/KeyType.hpp>
56#include <com/sun/star/sdbcx/Privilege.hpp>
57#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
58#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
59#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
60#include <com/sun/star/task/InteractionHandler.hpp>
61#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
62#include <com/sun/star/util/NumberFormat.hpp>
63#include <com/sun/star/util/NumberFormatsSupplier.hpp>
64#include <com/sun/star/util/XNumberFormatTypes.hpp>
78#include <osl/diagnose.h>
79#include <rtl/ustrbuf.hxx>
112 typedef sal_Bool (SAL_CALL XDatabaseMetaData::*FMetaDataSupport)();
116 const Reference< XNumberFormatTypes >& _xTypes,
117 const Locale& _rLocale)
119 OSL_ENSURE(_xTypes.is() && _xColumn.is(),
"dbtools::getDefaultNumberFormat: invalid arg !");
120 if (!_xTypes.is() || !_xColumn.is())
121 return NumberFormat::UNDEFINED;
124 sal_Int32 nScale = 0;
128 _xColumn->getPropertyValue(
"Type") >>=
nDataType;
131 _xColumn->getPropertyValue(
"Scale") >>= nScale;
135 return NumberFormat::UNDEFINED;
139 ::cppu::any2bool(_xColumn->getPropertyValue(
"IsCurrency")),
147 const Reference< XNumberFormatTypes >& _xTypes,
148 const Locale& _rLocale)
150 OSL_ENSURE(_xTypes.is() ,
"dbtools::getDefaultNumberFormat: invalid arg !");
152 return NumberFormat::UNDEFINED;
154 sal_Int32 nFormat = 0;
155 sal_Int32 nNumberType = _bIsCurrency ? NumberFormat::CURRENCY : NumberFormat::NUMBER;
159 case DataType::BOOLEAN:
160 nFormat = _xTypes->getStandardFormat(NumberFormat::LOGICAL, _rLocale);
162 case DataType::TINYINT:
163 case DataType::SMALLINT:
164 case DataType::INTEGER:
165 case DataType::BIGINT:
166 case DataType::FLOAT:
168 case DataType::DOUBLE:
169 case DataType::NUMERIC:
170 case DataType::DECIMAL:
174 nFormat = _xTypes->getStandardFormat(
static_cast<sal_Int16
>(nNumberType), _rLocale);
178 Reference< XNumberFormats > xFormats(_xTypes, UNO_QUERY);
179 OUString sNewFormat = xFormats->generateFormat( 0, _rLocale,
false,
false,
static_cast<sal_Int16
>(_nScale), 1);
182 nFormat = xFormats->queryKey(sNewFormat, _rLocale,
false);
183 if (nFormat == sal_Int32(-1))
184 nFormat = xFormats->addNew(sNewFormat, _rLocale);
189 nFormat = _xTypes->getStandardFormat(
static_cast<sal_Int16
>(nNumberType), _rLocale);
193 case DataType::VARCHAR:
194 case DataType::LONGVARCHAR:
196 nFormat = _xTypes->getStandardFormat(NumberFormat::TEXT, _rLocale);
199 nFormat = _xTypes->getStandardFormat(NumberFormat::DATE, _rLocale);
202 nFormat = _xTypes->getStandardFormat(NumberFormat::TIME, _rLocale);
204 case DataType::TIMESTAMP:
205 nFormat = _xTypes->getStandardFormat(NumberFormat::DATETIME, _rLocale);
207 case DataType::BINARY:
208 case DataType::VARBINARY:
209 case DataType::LONGVARBINARY:
210 case DataType::SQLNULL:
211 case DataType::OTHER:
212 case DataType::OBJECT:
213 case DataType::DISTINCT:
214 case DataType::STRUCT:
215 case DataType::ARRAY:
219 nFormat = _xTypes->getStandardFormat(NumberFormat::UNDEFINED, _rLocale);
224static Reference< XConnection>
findConnection(
const Reference< XInterface >& xParent)
226 Reference< XConnection> xConnection(xParent, UNO_QUERY);
227 if (!xConnection.is())
229 Reference< XChild> xChild(xParent, UNO_QUERY);
237 const OUString& _rsTitleOrPath,
238 const Reference< XComponentContext >& _rxContext )
240 ENSURE_OR_RETURN( !_rsTitleOrPath.isEmpty(),
"getDataSource_allowException: invalid arg !",
nullptr );
242 Reference< XDatabaseContext> xDatabaseContext = DatabaseContext::create(_rxContext);
244 return Reference< XDataSource >( xDatabaseContext->getByName( _rsTitleOrPath ), UNO_QUERY );
248 const OUString& _rsTitleOrPath,
249 const Reference< XComponentContext >& _rxContext )
251 Reference< XDataSource > xDS;
265 const OUString& _rsTitleOrPath,
266 const OUString& _rsUser,
267 const OUString& _rsPwd,
268 const Reference< XComponentContext>& _rxContext,
269 const Reference< XWindow >& _rxParent)
272 Reference<XConnection> xConnection;
273 if (xDataSource.is())
278 Reference<XInitialization> xIni(xDataSource, UNO_QUERY);
281 Sequence< Any > aArgs{
Any(NamedValue(
"ParentWindow",
Any(_rxParent) )) };
282 xIni->initialize(aArgs);
286 if(_rsUser.isEmpty() || _rsPwd.isEmpty())
288 Reference<XPropertySet> xProp(xDataSource,UNO_QUERY);
289 OUString sPwd, sUser;
290 bool bPwdReq =
false;
294 bPwdReq = ::cppu::any2bool(xProp->getPropertyValue(
"IsPasswordRequired"));
295 xProp->getPropertyValue(
"User") >>= sUser;
299 OSL_FAIL(
"dbtools::getConnection: error while retrieving data source properties!");
301 if(bPwdReq && sPwd.isEmpty())
303 Reference<XCompletedConnection> xConnectionCompletion(xProp, UNO_QUERY);
304 if (xConnectionCompletion.is())
306 Reference< XInteractionHandler > xHandler =
307 InteractionHandler::createWithParent(_rxContext, _rxParent);
308 xConnection = xConnectionCompletion->connectWithCompletion(xHandler);
312 xConnection = xDataSource->getConnection(sUser, sPwd);
314 if(!xConnection.is())
315 xConnection = xDataSource->getConnection(_rsUser, _rsPwd);
319 Sequence< Any > aArgs{
Any(NamedValue(
"ParentWindow",
Any(Reference<XWindow>()) )) };
320 xIni->initialize(aArgs);
328 const OUString& _rUser,
const OUString& _rPwd,
const Reference< XComponentContext>& _rxContext,
329 const Reference< XWindow >& _rxParent)
331 Reference< XConnection > xReturn;
343 TOOLS_WARN_EXCEPTION(
"connectivity.commontools",
"::dbtools::getConnection_withFeedback: unexpected (non-SQL) exception caught!");
350 Reference< XConnection> xReturn;
351 Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
352 if (xRowSetProps.is())
353 xRowSetProps->getPropertyValue(
"ActiveConnection") >>= xReturn;
361 bool _bAttachAutoDisposer,
const Reference< XWindow >& _rxParent)
367 Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
368 if ( !xRowSetProps.is() )
372 Reference< XConnection > xExistingConn(
373 xRowSetProps->getPropertyValue(
"ActiveConnection"),
376 if ( xExistingConn.is()
383 xRowSetProps->setPropertyValue(
"ActiveConnection",
Any( xExistingConn ) );
392 static constexpr OUStringLiteral sUserProp(
u"User" );
393 OUString sDataSourceName;
394 xRowSetProps->getPropertyValue(
"DataSourceName") >>= sDataSourceName;
396 xRowSetProps->getPropertyValue(
"URL") >>= sURL;
398 Reference< XConnection > xPureConnection;
399 if (!sDataSourceName.isEmpty())
402 OUString sUser, sPwd;
405 xRowSetProps->getPropertyValue(sUserProp) >>= sUser;
411 else if (!sURL.isEmpty())
414 Reference< XConnectionPool > xDriverManager;
416 xDriverManager = ConnectionPool::create( _rxContext );
418 if (xDriverManager.is())
420 OUString sUser, sPwd;
422 xRowSetProps->getPropertyValue(sUserProp) >>= sUser;
425 if (!sUser.isEmpty())
427 auto aInfo(::comphelper::InitPropertySequence({
428 {
"user",
Any(sUser) },
429 {
"password",
Any(sPwd) }
431 xPureConnection = xDriverManager->getConnectionWithInfo( sURL, aInfo );
435 xPureConnection = xDriverManager->getConnection( sURL );
445 if ( xConnection.
is() )
449 if ( _bAttachAutoDisposer )
454 xRowSetProps->setPropertyValue(
461 TOOLS_WARN_EXCEPTION(
"connectivity.commontools",
"EXception when we set the new active connection!");
470Reference< XConnection>
connectRowset(
const Reference< XRowSet>& _rxRowSet,
const Reference< XComponentContext >& _rxContext,
const Reference< XWindow >& _rxParent)
481Reference< XNameAccess>
getTableFields(
const Reference< XConnection>& _rxConn,
const OUString& _rName)
483 Reference< XComponent > xDummy;
489 const Reference< XPropertySet > xTable(i_aTable,UNO_QUERY_THROW);
495 Reference<XNameAccess> xKeyColumns;
496 const Reference<XKeysSupplier> xKeySup(i_xTable,UNO_QUERY);
499 const Reference<XIndexAccess> xKeys = xKeySup->getKeys();
504 Reference<XPropertySet> xProp;
505 const sal_Int32
nCount = xKeys->getCount();
508 xProp.set(xKeys->getByIndex(
i),UNO_QUERY_THROW);
509 sal_Int32 nKeyType = 0;
510 xProp->getPropertyValue(sPropName) >>= nKeyType;
511 if(KeyType::PRIMARY == nKeyType)
513 const Reference<XColumnsSupplier> xKeyColsSup(xProp,UNO_QUERY_THROW);
514 xKeyColumns = xKeyColsSup->getColumns();
526 enum FieldLookupState
528 HANDLE_TABLE, HANDLE_QUERY, HANDLE_SQL, RETRIEVE_OBJECT, RETRIEVE_COLUMNS,
DONE, FAILED
533 const sal_Int32 _nCommandType,
const OUString& _rCommand,
534 Reference< XComponent >& _rxKeepFieldsAlive,
SQLExceptionInfo* _pErrorInfo )
536 OSL_PRECOND( _rxConnection.is(),
"::dbtools::getFieldsByCommandDescriptor: invalid connection!" );
537 OSL_PRECOND( ( CommandType::TABLE == _nCommandType ) || ( CommandType::QUERY == _nCommandType ) || ( CommandType::COMMAND == _nCommandType ),
538 "::dbtools::getFieldsByCommandDescriptor: invalid command type!" );
539 OSL_PRECOND( !_rCommand.isEmpty(),
"::dbtools::getFieldsByCommandDescriptor: invalid command (empty)!" );
541 Reference< XNameAccess > xFields;
547 _rxKeepFieldsAlive.clear();
553 FieldLookupState eState = FAILED;
554 switch ( _nCommandType )
556 case CommandType::TABLE:
557 eState = HANDLE_TABLE;
559 case CommandType::QUERY:
560 eState = HANDLE_QUERY;
562 case CommandType::COMMAND:
568 Reference< XNameAccess > xObjectCollection;
569 Reference< XColumnsSupplier > xSupplyColumns;
572 while ( (
DONE != eState ) && ( FAILED != eState ) )
581 Reference< XTablesSupplier > xSupplyTables( _rxConnection, UNO_QUERY );
582 if ( xSupplyTables.is() )
583 xObjectCollection = xSupplyTables->getTables();
587 eState = RETRIEVE_OBJECT;
596 Reference< XQueriesSupplier > xSupplyQueries( _rxConnection, UNO_QUERY );
597 if ( xSupplyQueries.is() )
598 xObjectCollection = xSupplyQueries->getQueries();
602 eState = RETRIEVE_OBJECT;
606 case RETRIEVE_OBJECT:
613 OSL_ENSURE( xObjectCollection.is(),
"::dbtools::getFieldsByCommandDescriptor: invalid connection (no sdb.Connection, or no Tables-/QueriesSupplier)!");
614 if ( xObjectCollection.is() && xObjectCollection->hasByName( _rCommand ) )
616 xObjectCollection->getByName( _rCommand ) >>= xSupplyColumns;
620 eState = RETRIEVE_COLUMNS;
624 case RETRIEVE_COLUMNS:
625 OSL_ENSURE( xSupplyColumns.is(),
"::dbtools::getFieldsByCommandDescriptor: could not retrieve the columns supplier!" );
630 if ( xSupplyColumns.is() )
632 xFields = xSupplyColumns->getColumns();
640 OUString sStatementToExecute( _rCommand );
652 Reference< XMultiServiceFactory > xComposerFac( _rxConnection, UNO_QUERY );
654 if ( xComposerFac.is() )
656 Reference< XSingleSelectQueryComposer > xComposer(xComposerFac->createInstance(
"com.sun.star.sdb.SingleSelectQueryComposer"),UNO_QUERY);
657 if ( xComposer.is() )
659 xComposer->setQuery( sStatementToExecute );
663 xComposer->setFilter(
"0=1" );
664 sStatementToExecute = xComposer->getQuery( );
675 Reference< XPreparedStatement > xStatement = _rxConnection->prepareStatement( sStatementToExecute );
677 _rxKeepFieldsAlive.set(xStatement, css::uno::UNO_QUERY);
682 Reference< XPropertySet > xStatementProps( xStatement,UNO_QUERY );
685 if ( xStatementProps.is() )
686 xStatementProps->setPropertyValue(
"MaxRows",
Any( sal_Int32( 0 ) ) );
690 OSL_FAIL(
"::dbtools::getFieldsByCommandDescriptor: could not set the MaxRows!" );
695 xSupplyColumns.set(xStatement->executeQuery(), css::uno::UNO_QUERY);
700 eState = RETRIEVE_COLUMNS;
705 OSL_FAIL(
"::dbtools::getFieldsByCommandDescriptor: oops! unhandled state here!" );
710 catch(
const SQLContext& e ) {
if ( _pErrorInfo ) *_pErrorInfo =
SQLExceptionInfo( e ); }
711 catch(
const SQLWarning& e ) {
if ( _pErrorInfo ) *_pErrorInfo =
SQLExceptionInfo( e ); }
712 catch(
const SQLException& e ) {
if ( _pErrorInfo ) *_pErrorInfo =
SQLExceptionInfo( e ); }
715 TOOLS_WARN_EXCEPTION(
"connectivity.commontools",
"::dbtools::getFieldsByCommandDescriptor: caught an exception while retrieving the fields!" );
722 const sal_Int32 _nCommandType,
const OUString& _rCommand,
726 Reference< XComponent > xKeepFieldsAlive;
727 Reference< XNameAccess > xFieldContainer =
getFieldsByCommandDescriptor( _rxConnection, _nCommandType, _rCommand, xKeepFieldsAlive, _pErrorInfo );
730 Sequence< OUString > aNames;
731 if ( xFieldContainer.is() )
732 aNames = xFieldContainer->getElementNames();
741SQLException
prependErrorInfo(
const SQLException& _rChainedException,
const Reference< XInterface >& _rxContext,
744 return SQLException( _rAdditionalError, _rxContext,
746 0,
Any( _rChainedException ) );
751 struct NameComponentSupport
756 NameComponentSupport(
const bool _bCatalogs,
const bool _bSchemas )
763 NameComponentSupport lcl_getNameComponentSupport(
const Reference< XDatabaseMetaData >& _rxMetaData,
EComposeRule _eComposeRule )
765 OSL_PRECOND( _rxMetaData.is(),
"lcl_getNameComponentSupport: invalid meta data!" );
767 FMetaDataSupport pCatalogCall = &XDatabaseMetaData::supportsCatalogsInDataManipulation;
768 FMetaDataSupport pSchemaCall = &XDatabaseMetaData::supportsSchemasInDataManipulation;
769 bool bIgnoreMetaData =
false;
771 switch ( _eComposeRule )
774 pCatalogCall = &XDatabaseMetaData::supportsCatalogsInTableDefinitions;
775 pSchemaCall = &XDatabaseMetaData::supportsSchemasInTableDefinitions;
778 pCatalogCall = &XDatabaseMetaData::supportsCatalogsInIndexDefinitions;
779 pSchemaCall = &XDatabaseMetaData::supportsSchemasInIndexDefinitions;
782 pCatalogCall = &XDatabaseMetaData::supportsCatalogsInProcedureCalls;
783 pSchemaCall = &XDatabaseMetaData::supportsSchemasInProcedureCalls;
786 pCatalogCall = &XDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions;
787 pSchemaCall = &XDatabaseMetaData::supportsSchemasInPrivilegeDefinitions;
790 bIgnoreMetaData =
true;
796 return NameComponentSupport(
797 bIgnoreMetaData || (_rxMetaData.get()->*pCatalogCall)(),
798 bIgnoreMetaData || (_rxMetaData.get()->*pSchemaCall)()
804 const OUString& _rCatalog,
const OUString& _rSchema,
const OUString& _rName,
807 OSL_ENSURE(_rxMetaData.is(),
"impl_doComposeTableName : invalid meta data !");
808 if ( !_rxMetaData.is() )
810 OSL_ENSURE(!_rName.isEmpty(),
"impl_doComposeTableName : at least the name should be non-empty !");
812 const OUString sQuoteString = _rxMetaData->getIdentifierQuoteString();
813 const NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxMetaData, _eComposeRule ) );
815 OUStringBuffer aComposedName;
817 OUString sCatalogSep;
818 bool bCatalogAtStart =
true;
819 if ( !_rCatalog.isEmpty() && aNameComps.bCatalogs )
821 sCatalogSep = _rxMetaData->getCatalogSeparator();
822 bCatalogAtStart = _rxMetaData->isCatalogAtStart();
824 if ( bCatalogAtStart && !sCatalogSep.isEmpty())
826 aComposedName.append( _bQuote ?
quoteName( sQuoteString, _rCatalog ) : _rCatalog );
827 aComposedName.append( sCatalogSep );
831 if ( !_rSchema.isEmpty() && aNameComps.bSchemas )
833 aComposedName.append(
834 (_bQuote ?
quoteName( sQuoteString, _rSchema ) : _rSchema )
838 aComposedName.append( _bQuote ?
quoteName( sQuoteString, _rName ) : _rName );
840 if ( !_rCatalog.isEmpty()
842 && !sCatalogSep.isEmpty()
843 && aNameComps.bCatalogs
846 aComposedName.append( sCatalogSep );
847 aComposedName.append( _bQuote ?
quoteName( sQuoteString, _rCatalog ) : _rCatalog );
850 return aComposedName.makeStringAndClear();
854 ,
const OUString& _rName
862void qualifiedNameComponents(
const Reference< XDatabaseMetaData >& _rxConnMetaData,
const OUString& _rQualifiedName, OUString& _rCatalog, OUString& _rSchema, OUString& _rName,
EComposeRule _eComposeRule)
864 OSL_ENSURE(_rxConnMetaData.is(),
"QualifiedNameComponents : invalid meta data!");
866 NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxConnMetaData, _eComposeRule ) );
868 OUString sSeparator = _rxConnMetaData->getCatalogSeparator();
870 OUString
sName(_rQualifiedName);
872 if ( aNameComps.bCatalogs )
874 if (_rxConnMetaData->isCatalogAtStart())
896 if ( aNameComps.bSchemas )
909 const Reference< XConnection>& _rxConn,
910 bool _bAlloweDefault,
911 const Reference< XComponentContext>& _rxContext)
914 Reference< XNumberFormatsSupplier> xReturn;
915 Reference< XChild> xConnAsChild(_rxConn, UNO_QUERY);
916 static constexpr OUStringLiteral sPropFormatsSupplier(
u"NumberFormatsSupplier" );
917 if (xConnAsChild.is())
919 Reference< XPropertySet> xConnParentProps(xConnAsChild->getParent(), UNO_QUERY);
920 if (xConnParentProps.is() &&
hasProperty(sPropFormatsSupplier, xConnParentProps))
921 xConnParentProps->getPropertyValue(sPropFormatsSupplier) >>= xReturn;
923 else if(_bAlloweDefault && _rxContext.is())
925 xReturn = NumberFormatsSupplier::createWithDefaultLocale( _rxContext );
931 const Reference< XPropertySet>& xOldProps,
932 const Reference< XPropertySet>& xNewProps,
933 const Locale& _rLocale)
937 OSL_ENSURE( xOldProps.is() && xNewProps.is(),
"TransferFormComponentProperties: invalid source/dest!" );
938 if ( !xOldProps.is() || !xNewProps.is() )
942 Reference< XPropertySetInfo> xOldInfo( xOldProps->getPropertySetInfo());
943 Reference< XPropertySetInfo> xNewInfo( xNewProps->getPropertySetInfo());
945 const Sequence< Property> aOldProperties = xOldInfo->getProperties();
946 const Sequence< Property> aNewProperties = xNewInfo->getProperties();
948 static constexpr OUStringLiteral sPropFormatsSupplier(
u"FormatsSupplier");
949 static constexpr OUStringLiteral sPropCurrencySymbol(
u"CurrencySymbol");
950 static constexpr OUStringLiteral sPropDecimals(
u"Decimals");
951 static constexpr OUStringLiteral sPropEffectiveMin(
u"EffectiveMin");
952 static constexpr OUStringLiteral sPropEffectiveMax(
u"EffectiveMax");
953 static constexpr OUStringLiteral sPropEffectiveDefault(
u"EffectiveDefault");
954 static constexpr OUStringLiteral sPropDefaultText(
u"DefaultText");
955 static constexpr OUStringLiteral sPropDefaultDate(
u"DefaultDate");
956 static constexpr OUStringLiteral sPropDefaultTime(
u"DefaultTime");
957 static constexpr OUStringLiteral sPropValueMin(
u"ValueMin");
958 static constexpr OUStringLiteral sPropValueMax(
u"ValueMax");
959 static constexpr OUStringLiteral sPropDecimalAccuracy(
u"DecimalAccuracy");
960 static constexpr OUStringLiteral sPropClassId(
u"ClassId");
961 static constexpr OUStringLiteral sFormattedServiceName(
u"com.sun.star.form.component.FormattedField" );
963 for (
const Property& rOldProp : aOldProperties)
965 if ( rOldProp.Name !=
"DefaultControl" && rOldProp.Name !=
"LabelControl" )
968 const Property* pResult = std::lower_bound(
971 if ( ( pResult != aNewProperties.end() )
972 && ( pResult->Name == rOldProp.Name )
973 && ( (pResult->Attributes & PropertyAttribute::READONLY) == 0 )
974 && ( pResult->Type.equals(rOldProp.Type)) )
978 xNewProps->setPropertyValue(pResult->Name, xOldProps->getPropertyValue(pResult->Name));
980 catch(IllegalArgumentException
const &)
982 TOOLS_WARN_EXCEPTION(
"connectivity.commontools",
"TransferFormComponentProperties : could not transfer the value for property \""
983 << pResult->Name <<
"\"");
990 Reference< XServiceInfo > xSI( xOldProps, UNO_QUERY );
991 bool bOldIsFormatted = xSI.is() && xSI->supportsService( sFormattedServiceName );
992 xSI.set( xNewProps, UNO_QUERY );
993 bool bNewIsFormatted = xSI.is() && xSI->supportsService( sFormattedServiceName );
995 if (!bOldIsFormatted && !bNewIsFormatted)
998 if (bOldIsFormatted && bNewIsFormatted)
1002 if (bOldIsFormatted)
1006 if (aFormatKey.hasValue())
1008 Reference< XNumberFormatsSupplier> xSupplier;
1009 xOldProps->getPropertyValue(sPropFormatsSupplier) >>= xSupplier;
1012 Reference< XNumberFormats> xFormats(xSupplier->getNumberFormats());
1013 Reference< XPropertySet> xFormat(xFormats->getByKey(
getINT32(aFormatKey)));
1016 Any aVal( xFormat->getPropertyValue(sPropCurrencySymbol) );
1017 if (aVal.hasValue() &&
hasProperty(sPropCurrencySymbol, xNewProps))
1020 xNewProps->setPropertyValue(sPropCurrencySymbol, aVal);
1023 xNewProps->setPropertyValue(sPropDecimals, xFormat->getPropertyValue(sPropDecimals));
1028 Any aEffectiveMin( xOldProps->getPropertyValue(sPropEffectiveMin) );
1029 if (aEffectiveMin.hasValue())
1033 OSL_ENSURE(aEffectiveMin.getValueType().getTypeClass() == TypeClass_DOUBLE,
1034 "TransferFormComponentProperties : invalid property type !");
1035 xNewProps->setPropertyValue(sPropValueMin, aEffectiveMin);
1038 Any aEffectiveMax( xOldProps->getPropertyValue(sPropEffectiveMax) );
1039 if (aEffectiveMax.hasValue())
1043 OSL_ENSURE(aEffectiveMax.getValueType().getTypeClass() == TypeClass_DOUBLE,
1044 "TransferFormComponentProperties : invalid property type !");
1045 xNewProps->setPropertyValue(sPropValueMax, aEffectiveMax);
1050 Any aEffectiveDefault( xOldProps->getPropertyValue(sPropEffectiveDefault) );
1051 if (aEffectiveDefault.hasValue())
1053 bool bIsString = aEffectiveDefault.getValueType().getTypeClass() == TypeClass_STRING;
1054 OSL_ENSURE(bIsString || aEffectiveDefault.getValueType().getTypeClass() == TypeClass_DOUBLE,
1055 "TransferFormComponentProperties : invalid property type !");
1058 if (
hasProperty(sPropDefaultDate, xNewProps) && !bIsString)
1062 xNewProps->setPropertyValue(sPropDefaultDate,
Any(aDate));
1065 if (
hasProperty(sPropDefaultTime, xNewProps) && !bIsString)
1068 xNewProps->setPropertyValue(sPropDefaultTime,
Any(aTime));
1076 if (
hasProperty(sPropDefaultText, xNewProps) && bIsString)
1078 xNewProps->setPropertyValue(sPropDefaultText, aEffectiveDefault);
1086 if (bNewIsFormatted)
1090 Reference< XNumberFormatsSupplier> xSupplier;
1091 xNewProps->getPropertyValue(sPropFormatsSupplier) >>= xSupplier;
1094 Reference< XNumberFormats> xFormats(xSupplier->getNumberFormats());
1097 sal_Int16 nDecimals = 2;
1099 xOldProps->getPropertyValue(sPropDecimalAccuracy) >>= nDecimals;
1102 sal_Int32 nBaseKey = 0;
1105 Reference< XNumberFormatTypes> xTypeList(xFormats, UNO_QUERY);
1108 sal_Int16 nClassId = 0;
1109 xOldProps->getPropertyValue(sPropClassId) >>= nClassId;
1112 case FormComponentType::DATEFIELD :
1113 nBaseKey = xTypeList->getStandardFormat(NumberFormat::DATE, _rLocale);
1116 case FormComponentType::TIMEFIELD :
1117 nBaseKey = xTypeList->getStandardFormat(NumberFormat::TIME, _rLocale);
1120 case FormComponentType::CURRENCYFIELD :
1121 nBaseKey = xTypeList->getStandardFormat(NumberFormat::CURRENCY, _rLocale);
1128 OUString sNewFormat = xFormats->generateFormat(nBaseKey, _rLocale,
false,
false, nDecimals, 0);
1132 sal_Int32 nKey = xFormats->queryKey(sNewFormat, _rLocale,
false);
1133 if (nKey == sal_Int32(-1))
1135 nKey = xFormats->addNew(sNewFormat, _rLocale);
1142 Any aNewMin, aNewMax;
1144 aNewMin = xOldProps->getPropertyValue(sPropValueMin);
1146 aNewMax = xOldProps->getPropertyValue(sPropValueMax);
1147 xNewProps->setPropertyValue(sPropEffectiveMin, aNewMin);
1148 xNewProps->setPropertyValue(sPropEffectiveMax, aNewMax);
1154 Any aDate( xOldProps->getPropertyValue(sPropDefaultDate) );
1155 if (aDate.hasValue())
1156 aNewDefault <<= DBTypeConversion::toDouble(*o3tl::doAccess<Date>(aDate));
1161 Any aTime( xOldProps->getPropertyValue(sPropDefaultTime) );
1162 if (aTime.hasValue())
1163 aNewDefault <<= DBTypeConversion::toDouble(*o3tl::doAccess<Time>(aTime));
1170 aNewDefault = xOldProps->getPropertyValue(sPropDefaultText);
1172 if (aNewDefault.hasValue())
1173 xNewProps->setPropertyValue(sPropEffectiveDefault, aNewDefault);
1184 return (_rxCursorSet.is() && (
getINT32(_rxCursorSet->getPropertyValue(
"Privileges")) & Privilege::INSERT) != 0);
1189 return (_rxCursorSet.is() && (
getINT32(_rxCursorSet->getPropertyValue(
"Privileges")) & Privilege::UPDATE) != 0);
1194 return (_rxCursorSet.is() && (
getINT32(_rxCursorSet->getPropertyValue(
"Privileges")) & Privilege::DELETE) != 0);
1199 Reference< XOfficeDatabaseDocument> xDatabaseDocument(_xParent, UNO_QUERY);
1200 Reference< XDataSource> xDataSource;
1201 if ( xDatabaseDocument.is() )
1202 xDataSource = xDatabaseDocument->getDataSource();
1203 if ( !xDataSource.is() )
1204 xDataSource.set(_xParent, UNO_QUERY);
1205 if (!xDataSource.is())
1207 Reference< XChild> xChild(_xParent, UNO_QUERY);
1214static Reference< XSingleSelectQueryComposer >
getComposedRowSetStatement(
const Reference< XPropertySet >& _rxRowSet,
const Reference< XComponentContext >& _rxContext,
const Reference< XWindow >& _rxParent )
1216 Reference< XSingleSelectQueryComposer > xComposer;
1219 Reference< XConnection> xConn =
connectRowset( Reference< XRowSet >( _rxRowSet, UNO_QUERY ), _rxContext, _rxParent );
1225 sal_Int32 nCommandType = CommandType::COMMAND;
1227 bool bEscapeProcessing =
false;
1229 OSL_VERIFY( _rxRowSet->getPropertyValue(
"CommandType") >>= nCommandType );
1230 OSL_VERIFY( _rxRowSet->getPropertyValue(
"Command") >>= sCommand );
1231 OSL_VERIFY( _rxRowSet->getPropertyValue(
"EscapeProcessing") >>= bEscapeProcessing );
1233 StatementComposer aComposer( xConn, sCommand, nCommandType, bEscapeProcessing );
1238 bool bApplyFilter =
true;
1239 _rxRowSet->getPropertyValue(
"ApplyFilter") >>= bApplyFilter;
1252 catch(
const SQLException& )
1265 const Reference< XPropertySet>& _rxRowSetProps,
1266 const Reference< XComponentContext>& _rxContext,
1267 const Reference< XWindow >& _rxParent)
1269 Reference< XSingleSelectQueryComposer > xReturn;
1274 catch(
const SQLException& )
1280 TOOLS_WARN_EXCEPTION(
"connectivity.commontools",
"::getCurrentSettingsComposer : caught an exception !" );
1287 const OUString& _rCatalog,
1288 const OUString& _rSchema,
1289 const OUString& _rName,
1297 const OUString& _rCatalog,
const OUString& _rSchema,
const OUString& _rName )
1303 _rxConnection->getMetaData(),
1304 bUseCatalogInSelect ? _rCatalog : OUString(),
1305 bUseSchemaInSelect ? _rSchema : OUString(),
1314 void lcl_getTableNameComponents(
const Reference<XPropertySet>& _xTable,
1315 OUString& _out_rCatalog, OUString& _out_rSchema, OUString& _out_rName )
1318 Reference< XPropertySetInfo > xInfo;
1320 xInfo = _xTable->getPropertySetInfo();
1333 OSL_FAIL(
"::dbtools::lcl_getTableNameComponents: this is no table object!" );
1346 const Reference<XPropertySet>& _xTable,
1365 sal_Int32 nSearchFlag = 0;
1366 Reference<XResultSet> xSet = _rxConn->getMetaData()->getTypeInfo();
1369 Reference<XRow> xRow(xSet,UNO_QUERY);
1372 if(xRow->getInt(2) == _nDataType)
1374 nSearchFlag = xRow->getInt(9);
1382OUString
createUniqueName(
const Sequence< OUString >& _rNames,
const OUString& _rBaseName,
bool _bStartWithNumber )
1384 std::set< OUString > aUsedNames(_rNames.begin(), _rNames.end());
1386 OUString
sName( _rBaseName );
1388 if ( _bStartWithNumber )
1391 while ( aUsedNames.find(
sName ) != aUsedNames.end() )
1393 sName = _rBaseName + OUString::number( ++
nPos );
1398OUString
createUniqueName(
const Reference<XNameAccess>& _rxContainer,
const OUString& _rBaseName,
bool _bStartWithNumber)
1400 Sequence< OUString > aElementNames;
1402 OSL_ENSURE( _rxContainer.is(),
"createUniqueName: invalid container!" );
1403 if ( _rxContainer.is() )
1404 aElementNames = _rxContainer->getElementNames();
1410 const Reference< XWindow>& _xParent,
1411 const Reference< XComponentContext >& _rxContext)
1417 Reference< XExecutableDialog > xErrorDialog = ErrorMessageDialog::create( _rxContext,
"", _xParent, _rInfo.
get() );
1418 xErrorDialog->execute();
1422 OSL_FAIL(
"showError: could not display the error message!");
1428 const sal_Int32 _nColumnIndex,
const Any& _rValue)
1430 bool bSuccessfullyReRouted =
true;
1431 switch (_rValue.getValueTypeClass())
1435 bSuccessfullyReRouted =
implUpdateObject(_rxUpdatedObject, _nColumnIndex, _rValue);
1439 case TypeClass_VOID:
1440 _rxUpdatedObject->updateNull(_nColumnIndex);
1443 case TypeClass_STRING:
1444 _rxUpdatedObject->updateString(_nColumnIndex, *o3tl::forceAccess<OUString>(_rValue));
1447 case TypeClass_BOOLEAN:
1448 _rxUpdatedObject->updateBoolean(_nColumnIndex, *o3tl::forceAccess<bool>(_rValue));
1451 case TypeClass_BYTE:
1452 _rxUpdatedObject->updateByte(_nColumnIndex, *o3tl::forceAccess<sal_Int8>(_rValue));
1455 case TypeClass_UNSIGNED_SHORT:
1456 case TypeClass_SHORT:
1457 _rxUpdatedObject->updateShort(_nColumnIndex, *o3tl::forceAccess<sal_Int16>(_rValue));
1460 case TypeClass_CHAR:
1461 _rxUpdatedObject->updateString(_nColumnIndex,OUString(*o3tl::forceAccess<sal_Unicode>(_rValue)));
1464 case TypeClass_UNSIGNED_LONG:
1465 case TypeClass_LONG:
1466 _rxUpdatedObject->updateInt(_nColumnIndex, *o3tl::forceAccess<sal_Int32>(_rValue));
1469 case TypeClass_HYPER:
1472 OSL_VERIFY( _rValue >>=
nValue );
1473 _rxUpdatedObject->updateLong( _nColumnIndex,
nValue );
1477 case TypeClass_FLOAT:
1478 _rxUpdatedObject->updateFloat(_nColumnIndex, *o3tl::forceAccess<float>(_rValue));
1481 case TypeClass_DOUBLE:
1482 _rxUpdatedObject->updateDouble(_nColumnIndex, *o3tl::forceAccess<double>(_rValue));
1485 case TypeClass_SEQUENCE:
1487 _rxUpdatedObject->updateBytes(_nColumnIndex, *s);
1489 bSuccessfullyReRouted =
false;
1491 case TypeClass_STRUCT:
1492 if (
auto s1 = o3tl::tryAccess<DateTime>(_rValue))
1493 _rxUpdatedObject->updateTimestamp(_nColumnIndex, *s1);
1494 else if (
auto s2 = o3tl::tryAccess<Date>(_rValue))
1495 _rxUpdatedObject->updateDate(_nColumnIndex, *s2);
1496 else if (
auto s3 = o3tl::tryAccess<Time>(_rValue))
1497 _rxUpdatedObject->updateTime(_nColumnIndex, *s3);
1499 bSuccessfullyReRouted =
false;
1502 case TypeClass_INTERFACE:
1505 _rxUpdatedObject->updateBinaryStream(_nColumnIndex, *
xStream, (*xStream)->available());
1510 bSuccessfullyReRouted =
false;
1513 return bSuccessfullyReRouted;
1517 const sal_Int32 _nColumnIndex,
const Any& _rValue)
1519 bool bSuccessfullyReRouted =
true;
1520 switch (_rValue.getValueTypeClass())
1522 case TypeClass_UNSIGNED_HYPER:
1525 OSL_VERIFY( _rValue >>=
nValue );
1526 _rxParameters->setString(_nColumnIndex, OUString::number(
nValue));
1530 case TypeClass_UNSIGNED_LONG:
1531 case TypeClass_HYPER:
1534 OSL_VERIFY( _rValue >>=
nValue );
1535 _rxParameters->setLong( _nColumnIndex,
nValue );
1541 bSuccessfullyReRouted =
implSetObject(_rxParameters, _nColumnIndex, _rValue);
1545 case TypeClass_VOID:
1546 _rxParameters->setNull(_nColumnIndex,DataType::VARCHAR);
1549 case TypeClass_STRING:
1550 _rxParameters->setString(_nColumnIndex, *o3tl::forceAccess<OUString>(_rValue));
1553 case TypeClass_BOOLEAN:
1554 _rxParameters->setBoolean(_nColumnIndex, *o3tl::forceAccess<bool>(_rValue));
1557 case TypeClass_BYTE:
1558 _rxParameters->setByte(_nColumnIndex, *o3tl::forceAccess<sal_Int8>(_rValue));
1561 case TypeClass_SHORT:
1562 _rxParameters->setShort(_nColumnIndex, *o3tl::forceAccess<sal_Int16>(_rValue));
1565 case TypeClass_CHAR:
1566 _rxParameters->setString(_nColumnIndex, OUString(*o3tl::forceAccess<sal_Unicode>(_rValue)));
1569 case TypeClass_UNSIGNED_SHORT:
1570 case TypeClass_LONG:
1573 OSL_VERIFY( _rValue >>=
nValue );
1574 _rxParameters->setInt(_nColumnIndex,
nValue);
1578 case TypeClass_FLOAT:
1579 _rxParameters->setFloat(_nColumnIndex, *o3tl::forceAccess<float>(_rValue));
1582 case TypeClass_DOUBLE:
1583 _rxParameters->setDouble(_nColumnIndex, *o3tl::forceAccess<double>(_rValue));
1586 case TypeClass_SEQUENCE:
1589 _rxParameters->setBytes(_nColumnIndex, *s);
1592 bSuccessfullyReRouted =
false;
1594 case TypeClass_STRUCT:
1595 if (
auto s1 = o3tl::tryAccess<DateTime>(_rValue))
1596 _rxParameters->setTimestamp(_nColumnIndex, *s1);
1597 else if (
auto s2 = o3tl::tryAccess<Date>(_rValue))
1598 _rxParameters->setDate(_nColumnIndex, *s2);
1599 else if (
auto s3 = o3tl::tryAccess<Time>(_rValue))
1600 _rxParameters->setTime(_nColumnIndex, *s3);
1602 bSuccessfullyReRouted =
false;
1605 case TypeClass_INTERFACE:
1608 Reference< XInputStream >
xStream;
1610 _rxParameters->setBinaryStream(_nColumnIndex,
xStream,
xStream->available());
1615 bSuccessfullyReRouted =
false;
1619 return bSuccessfullyReRouted;
1624 class OParameterWrapper :
public ::cppu::WeakImplHelper< XIndexAccess >
1626 std::vector<bool, std::allocator<bool> >
m_aSet;
1629 OParameterWrapper(std::vector<
bool, std::allocator<bool> >&& _aSet,
const Reference<XIndexAccess>& _xSource)
1633 virtual Type SAL_CALL getElementType()
override
1637 virtual sal_Bool SAL_CALL hasElements( )
override
1641 return std::count(
m_aSet.begin(),
m_aSet.end(),
false) != 0;
1644 virtual sal_Int32 SAL_CALL getCount( )
override
1650 virtual Any SAL_CALL getByIndex( sal_Int32
Index )
override
1655 throw IndexOutOfBoundsException();
1657 std::vector<bool, std::allocator<bool> >::const_iterator aIter =
m_aSet.begin();
1658 std::vector<bool, std::allocator<bool> >::const_iterator aEnd =
m_aSet.end();
1660 for(; aIter != aEnd &&
i <=
Index; ++aIter)
1667 auto nParamPos =
static_cast<sal_Int32
>(std::distance(
m_aSet.cbegin(), aIter)) - 1;
1668 return m_xSource->getByIndex(nParamPos);
1674 const Reference<XParameters>& _xParameters,
1675 const Reference< XConnection>& _xConnection,
1676 const Reference< XInteractionHandler >& _rxHandler,
1677 const std::vector<
bool, std::allocator<bool> >& _aParametersSet)
1679 OSL_ENSURE(_xComposer.is(),
"dbtools::askForParameters XSQLQueryComposer is null!");
1680 OSL_ENSURE(_xParameters.is(),
"dbtools::askForParameters XParameters is null!");
1681 OSL_ENSURE(_xConnection.is(),
"dbtools::askForParameters XConnection is null!");
1682 OSL_ENSURE(_rxHandler.is(),
"dbtools::askForParameters XInteractionHandler is null!");
1685 Reference<XParametersSupplier> xParameters(_xComposer, UNO_QUERY);
1687 Reference<XIndexAccess> xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>();
1688 sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0;
1689 std::vector<bool, std::allocator<bool> > aNewParameterSet( _aParametersSet );
1690 if ( !(nParamCount && std::count(aNewParameterSet.begin(),aNewParameterSet.end(),
true) != nParamCount) )
1694 aNewParameterSet.resize(nParamCount ,
false);
1695 typedef std::map< OUString, std::vector<sal_Int32> > TParameterPositions;
1696 TParameterPositions aParameterNames;
1697 for(sal_Int32
i = 0;
i < nParamCount; ++
i)
1699 Reference<XPropertySet> xParam(xParamsAsIndicies->getByIndex(
i),UNO_QUERY);
1703 TParameterPositions::const_iterator aFind = aParameterNames.find(
sName);
1704 if ( aFind != aParameterNames.end() )
1705 aNewParameterSet[
i] =
true;
1706 aParameterNames[
sName].push_back(
i+1);
1713 ParametersRequest aRequest;
1714 Reference<XIndexAccess> xWrappedParameters =
new OParameterWrapper(std::move(aNewParameterSet),xParamsAsIndicies);
1715 aRequest.Parameters = xWrappedParameters;
1716 aRequest.Connection = _xConnection;
1719 pRequest->addContinuation(pAbort);
1720 pRequest->addContinuation(pParams);
1723 _rxHandler->handle(pRequest);
1725 if (!pParams->wasSelected())
1728 RowSetVetoException e;
1734 Sequence< PropertyValue > aFinalValues = pParams->getValues();
1735 const PropertyValue* pFinalValues = aFinalValues.getConstArray();
1736 for (sal_Int32
i=0;
i<aFinalValues.getLength(); ++
i, ++pFinalValues)
1738 Reference< XPropertySet > xParamColumn(xWrappedParameters->getByIndex(
i),UNO_QUERY);
1739 if (xParamColumn.is())
1743 OSL_ENSURE(
sName == pFinalValues->Name,
"::dbaui::askForParameters: inconsistent parameter names!");
1746 sal_Int32 nParamType = 0;
1749 sal_Int32 nScale = 0;
1753 TParameterPositions::const_iterator aFind = aParameterNames.find(pFinalValues->Name);
1754 for(
const auto& rItem : aFind->second)
1756 if ( _aParametersSet.empty() || !_aParametersSet[rItem-1] )
1758 _xParameters->setObjectWithInfo(rItem, pFinalValues->Value, nParamType, nScale);
1766 sal_Int32 parameterIndex,
1777 sal_Int32 parameterIndex,
1778 const ::connectivity::ORowSetValue& _rValue,
1782 if ( _rValue.isNull() )
1783 _xParams->setNull(parameterIndex,sqlType);
1788 case DataType::DECIMAL:
1789 case DataType::NUMERIC:
1790 _xParams->setObjectWithInfo(parameterIndex,_rValue.makeAny(),sqlType,
scale);
1792 case DataType::CHAR:
1793 case DataType::VARCHAR:
1794 case DataType::LONGVARCHAR:
1795 _xParams->setString(parameterIndex,_rValue.getString());
1797 case DataType::CLOB:
1799 Any x(_rValue.makeAny());
1802 _xParams->setString(parameterIndex,sValue);
1805 Reference< XClob > xClob;
1807 _xParams->setClob(parameterIndex,xClob);
1810 Reference< css::io::XInputStream >
xStream;
1812 _xParams->setCharacterStream(parameterIndex,
xStream,
xStream->available());
1817 case DataType::BIGINT:
1818 if ( _rValue.isSigned() )
1819 _xParams->setLong(parameterIndex,_rValue.getLong());
1821 _xParams->setString(parameterIndex,_rValue.getString());
1824 case DataType::FLOAT:
1825 _xParams->setFloat(parameterIndex,_rValue.getFloat());
1827 case DataType::REAL:
1828 case DataType::DOUBLE:
1829 _xParams->setDouble(parameterIndex,_rValue.getDouble());
1831 case DataType::DATE:
1832 _xParams->setDate(parameterIndex,_rValue.getDate());
1834 case DataType::TIME:
1835 _xParams->setTime(parameterIndex,_rValue.getTime());
1837 case DataType::TIMESTAMP:
1838 _xParams->setTimestamp(parameterIndex,_rValue.getDateTime());
1840 case DataType::BINARY:
1841 case DataType::VARBINARY:
1842 case DataType::LONGVARBINARY:
1843 case DataType::BLOB:
1845 Any x(_rValue.makeAny());
1846 Sequence< sal_Int8> aBytes;
1848 _xParams->setBytes(parameterIndex,aBytes);
1851 Reference< XBlob > xBlob;
1853 _xParams->setBlob(parameterIndex,xBlob);
1856 Reference< XClob > xClob;
1858 _xParams->setClob(parameterIndex,xClob);
1861 Reference< css::io::XInputStream > xBinStream;
1862 if(
x >>= xBinStream)
1863 _xParams->setBinaryStream(parameterIndex,xBinStream,xBinStream->available());
1870 case DataType::BOOLEAN:
1871 _xParams->setBoolean(parameterIndex,_rValue.getBool());
1873 case DataType::TINYINT:
1874 if ( _rValue.isSigned() )
1875 _xParams->setByte(parameterIndex,_rValue.getInt8());
1877 _xParams->setShort(parameterIndex,_rValue.getInt16());
1879 case DataType::SMALLINT:
1880 if ( _rValue.isSigned() )
1881 _xParams->setShort(parameterIndex,_rValue.getInt16());
1883 _xParams->setInt(parameterIndex,_rValue.getInt32());
1885 case DataType::INTEGER:
1886 if ( _rValue.isSigned() )
1887 _xParams->setInt(parameterIndex,_rValue.getULong());
1889 _xParams->setLong(parameterIndex,_rValue.getLong());
1895 STR_UNKNOWN_PARA_TYPE,
1896 "$position$", OUString::number(parameterIndex)
1905 OUStringBuffer& _out_rSQLPredicate )
1907 switch ( _nBooleanComparisonMode )
1909 case BooleanComparisonMode::IS_LITERAL:
1910 _out_rSQLPredicate.append( _rExpression );
1912 _out_rSQLPredicate.append(
" IS TRUE" );
1914 _out_rSQLPredicate.append(
" IS FALSE" );
1917 case BooleanComparisonMode::EQUAL_LITERAL:
1918 _out_rSQLPredicate.append( _rExpression );
1919 _out_rSQLPredicate.appendAscii( _bValue ?
" = TRUE" :
" = FALSE" );
1922 case BooleanComparisonMode::ACCESS_COMPAT:
1925 _out_rSQLPredicate.append(
" NOT ( ( " );
1926 _out_rSQLPredicate.append( _rExpression );
1927 _out_rSQLPredicate.append(
" = 0 ) OR ( " );
1928 _out_rSQLPredicate.append( _rExpression );
1929 _out_rSQLPredicate.append(
" IS NULL ) )" );
1933 _out_rSQLPredicate.append( _rExpression );
1934 _out_rSQLPredicate.append(
" = 0" );
1938 case BooleanComparisonMode::EQUAL_INTEGER:
1941 _out_rSQLPredicate.append( _rExpression );
1942 _out_rSQLPredicate.appendAscii( _bValue ?
" = 1" :
" = 0" );
1954 throw DisposedException();
1958OSQLColumns::const_iterator
find(
const OSQLColumns::const_iterator& first,
1959 const OSQLColumns::const_iterator& last,
1960 std::u16string_view _rVal,
1961 const ::comphelper::UStringMixEqual& _rCase)
1967OSQLColumns::const_iterator
findRealName(
const OSQLColumns::const_iterator& first,
1968 const OSQLColumns::const_iterator& last,
1969 std::u16string_view _rVal,
1970 const ::comphelper::UStringMixEqual& _rCase)
1976OSQLColumns::const_iterator
find(OSQLColumns::const_iterator first,
1977 const OSQLColumns::const_iterator& last,
1978 const OUString& _rProp,
1979 std::u16string_view _rVal,
1980 const ::comphelper::UStringMixEqual& _rCase)
1982 while (
first !=
last && !_rCase(
getString((*first)->getPropertyValue(_rProp)),_rVal))
2007 if (nCodepage != 0x00)
2009 auto eEncoding(RTL_TEXTENCODING_DONTKNOW);
2012 case 0x01: eEncoding = RTL_TEXTENCODING_IBM_437;
break;
2013 case 0x02: eEncoding = RTL_TEXTENCODING_IBM_850;
break;
2014 case 0x03: eEncoding = RTL_TEXTENCODING_MS_1252;
break;
2015 case 0x04: eEncoding = RTL_TEXTENCODING_APPLE_ROMAN;
break;
2016 case 0x64: eEncoding = RTL_TEXTENCODING_IBM_852;
break;
2017 case 0x65: eEncoding = RTL_TEXTENCODING_IBM_866;
break;
2018 case 0x66: eEncoding = RTL_TEXTENCODING_IBM_865;
break;
2019 case 0x67: eEncoding = RTL_TEXTENCODING_IBM_861;
break;
2020 case 0x68: eEncoding = RTL_TEXTENCODING_KAMENICKY;
break;
2021 case 0x69: eEncoding = RTL_TEXTENCODING_MAZOVIA;
break;
2022 case 0x6A: eEncoding = RTL_TEXTENCODING_IBM_737;
break;
2023 case 0x6B: eEncoding = RTL_TEXTENCODING_IBM_857;
break;
2024 case 0x6C: eEncoding = RTL_TEXTENCODING_IBM_863;
break;
2025 case 0x78: eEncoding = RTL_TEXTENCODING_MS_950;
break;
2026 case 0x79: eEncoding = RTL_TEXTENCODING_MS_949;
break;
2027 case 0x7A: eEncoding = RTL_TEXTENCODING_MS_936;
break;
2028 case 0x7B: eEncoding = RTL_TEXTENCODING_MS_932;
break;
2029 case 0x7C: eEncoding = RTL_TEXTENCODING_MS_874;
break;
2030 case 0x7D: eEncoding = RTL_TEXTENCODING_MS_1255;
break;
2031 case 0x7E: eEncoding = RTL_TEXTENCODING_MS_1256;
break;
2032 case 0x96: eEncoding = RTL_TEXTENCODING_APPLE_CYRILLIC;
break;
2033 case 0x97: eEncoding = RTL_TEXTENCODING_APPLE_CENTEURO;
break;
2034 case 0x98: eEncoding = RTL_TEXTENCODING_APPLE_GREEK;
break;
2035 case 0xC8: eEncoding = RTL_TEXTENCODING_MS_1250;
break;
2036 case 0xC9: eEncoding = RTL_TEXTENCODING_MS_1251;
break;
2037 case 0xCA: eEncoding = RTL_TEXTENCODING_MS_1254;
break;
2038 case 0xCB: eEncoding = RTL_TEXTENCODING_MS_1253;
break;
2039 case 0xCC: eEncoding = RTL_TEXTENCODING_MS_1257;
break;
2041 if(eEncoding != RTL_TEXTENCODING_DONTKNOW)
2043 _out_encoding = eEncoding;
2058 if (dbf_Stream->
eof())
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & ReadUChar(unsigned char &rChar)
void fill(sal_Int32 _nPos, sal_Int32 _nType, const css::uno::Reference< css::sdbc::XRow > &_xRow)
fetches a single value out of the row
helper class for accessing resources shared by different libraries in the connectivity module
OUString getResourceStringWithSubstitution(TranslateId pResId, const char *_pAsciiPatternToReplace, const OUString &_rStringToSubstitute) const
loads a string from the shared resource file, and replaces a given ASCII pattern with a given string
const css::uno::Reference< INTERFACE > & getTyped() const
void reset(const css::uno::Reference< INTERFACE > &_rxComponent, AssignmentMode _eMode=TakeOwnership)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define ENSURE_OR_RETURN(c, m, r)
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr OUStringLiteral PROPERTY_NAME
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
void disposeComponent(css::uno::Reference< TYPE > &_rxComp)
double getDouble(const Any &_rAny)
sal_Int32 getINT32(const Any &_rAny)
OUString getString(const Any &_rAny)
bool dbfReadCharset(rtl_TextEncoding &nCharSet, SvStream *dbf_Stream)
decode a DBase file's codepage byte to a RTL charset
bool dbfDecodeCharset(rtl_TextEncoding &_out_encoding, sal_uInt8 nType, sal_uInt8 nCodepage)
decode a DBase file's codepage byte to a RTL charset
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
void checkDisposed(bool _bThrow)
OSQLColumns::const_iterator findRealName(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
constexpr OUStringLiteral first
constexpr OUStringLiteral last
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
std::enable_if<!(detail::IsDerivedReference< T >::value||detail::IsUnoSequenceType< T >::value||std::is_base_of< css::uno::XInterface, T >::value), typenamedetail::Optional< T >::type >::type tryAccess(css::uno::Any const &any)
#define PROPERTY_ID_FORMATKEY
#define PROPERTY_ID_CATALOGNAME
#define PROPERTY_ID_PASSWORD
#define PROPERTY_ID_SCHEMANAME
#define PROPERTY_ID_DEFAULTVALUE
#define PROPERTY_ID_REALNAME
#define PROPERTY_ID_SCALE
#define STREAM_SEEK_TO_BEGIN