LibreOffice Module dbaccess (master) 1
WCopyTable.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <strings.hrc>
21#include <strings.hxx>
22#include <core_resource.hxx>
23#include <sqlmessage.hxx>
24#include <UITools.hxx>
25#include <WColumnSelect.hxx>
26#include <WCopyTable.hxx>
27#include <WCPage.hxx>
28#include <WExtendPages.hxx>
29#include <WNameMatch.hxx>
30#include <WTypeSelect.hxx>
31
32#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
33#include <com/sun/star/sdb/SQLContext.hpp>
34#include <com/sun/star/sdbc/ColumnValue.hpp>
35#include <com/sun/star/sdbc/DataType.hpp>
36#include <com/sun/star/sdbc/XResultSet.hpp>
37#include <com/sun/star/sdbc/XStatement.hpp>
38#include <com/sun/star/sdbc/XRow.hpp>
39#include <com/sun/star/sdbcx/KeyType.hpp>
40#include <com/sun/star/sdbcx/XAppend.hpp>
41#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
42#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
43#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
44#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
45#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
46#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
47#include <com/sun/star/task/InteractionHandler.hpp>
48
53#include <o3tl/safeint.hxx>
54#include <rtl/ustrbuf.hxx>
55#include <sal/log.hxx>
57
58#include <algorithm>
59#include <utility>
60
61using namespace ::dbaui;
62using namespace ::com::sun::star::uno;
63using namespace ::com::sun::star::beans;
64using namespace ::com::sun::star::container;
65using namespace ::com::sun::star::util;
66using namespace ::com::sun::star::sdb;
67using namespace ::com::sun::star::sdbc;
68using namespace ::com::sun::star::sdbcx;
69using namespace ::com::sun::star::lang;
70using namespace ::com::sun::star::task;
71using namespace dbtools;
72
73namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
74
75#define MAX_PAGES 4 // max. number of pages, which are shown
76
77namespace
78{
79 void clearColumns(ODatabaseExport::TColumns& _rColumns, ODatabaseExport::TColumnVector& _rColumnsVec)
80 {
81 for (auto const& column : _rColumns)
82 delete column.second;
83
84 _rColumnsVec.clear();
85 _rColumns.clear();
86 }
87}
88
89// ICopyTableSourceObject
90ICopyTableSourceObject::~ICopyTableSourceObject()
91{
92}
93
94// ObjectCopySource
95ObjectCopySource::ObjectCopySource( const Reference< XConnection >& _rxConnection, const Reference< XPropertySet >& _rxObject )
96 :m_xConnection( _rxConnection, UNO_SET_THROW )
97 ,m_xMetaData( _rxConnection->getMetaData(), UNO_SET_THROW )
98 ,m_xObject( _rxObject, UNO_SET_THROW )
99 ,m_xObjectPSI( _rxObject->getPropertySetInfo(), UNO_SET_THROW )
100 ,m_xObjectColumns( Reference< XColumnsSupplier >( _rxObject, UNO_QUERY_THROW )->getColumns(), UNO_SET_THROW )
101{
102}
103
105{
106 OUString sName;
107
108 if ( !m_xObjectPSI->hasPropertyByName( PROPERTY_COMMAND ) )
109 sName = ::dbtools::composeTableName( m_xMetaData, m_xObject, ::dbtools::EComposeRule::InDataManipulation, false );
110 else
111 m_xObject->getPropertyValue( PROPERTY_NAME ) >>= sName;
112 return sName;
113}
114
116{
117 bool bIsView = false;
118 try
119 {
120 if ( m_xObjectPSI->hasPropertyByName( PROPERTY_TYPE ) )
121 {
122 OUString sObjectType;
123 OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_TYPE ) >>= sObjectType );
124 bIsView = sObjectType == "VIEW";
125 }
126 }
127 catch( const Exception& )
128 {
129 DBG_UNHANDLED_EXCEPTION("dbaccess");
130 }
131 return bIsView;
132}
133
135{
136 const OUString aCopyProperties[] = {
138 };
139 for (const auto & aCopyProperty : aCopyProperties)
140 {
141 if ( m_xObjectPSI->hasPropertyByName( aCopyProperty ) )
142 _rxObject->setPropertyValue( aCopyProperty, m_xObject->getPropertyValue( aCopyProperty ) );
143 }
144}
145
147{
148 std::pair< OUString, OUString > aProperties[] = {
149 std::pair< OUString, OUString >(PROPERTY_FILTER,OUString(" AND "))
150 ,std::pair< OUString, OUString >(PROPERTY_ORDER,OUString(" ORDER BY "))
151 };
152
153 try
154 {
155 const OUString sSourceName = ::dbtools::composeTableNameForSelect(m_xConnection,m_xObject) + ".";
156 const OUString sTargetName = ::dbtools::composeTableNameForSelect(_xConnection,_rxObject);
157 const OUString sTargetNameTemp = sTargetName + ".";
158
159 OUStringBuffer sStatement = "SELECT * FROM " + sTargetName + " WHERE 0=1";
160
161 for (const std::pair<OUString,OUString> & aProperty : aProperties)
162 {
163 if ( m_xObjectPSI->hasPropertyByName( aProperty.first ) )
164 {
165 OUString sFilter;
166 m_xObject->getPropertyValue( aProperty.first ) >>= sFilter;
167 if ( !sFilter.isEmpty() )
168 {
169 sStatement.append(aProperty.second);
170 sFilter = sFilter.replaceFirst(sSourceName,sTargetNameTemp);
171 _rxObject->setPropertyValue( aProperty.first, Any(sFilter) );
172 sStatement.append(sFilter);
173 }
174 }
175 }
176
177 _xConnection->createStatement()->executeQuery(sStatement.makeStringAndClear());
178
179 if ( m_xObjectPSI->hasPropertyByName( PROPERTY_APPLYFILTER ) )
180 _rxObject->setPropertyValue( PROPERTY_APPLYFILTER, m_xObject->getPropertyValue( PROPERTY_APPLYFILTER ) );
181 }
182 catch(Exception&)
183 {
184 }
185}
186
188{
189 return m_xObjectColumns->getElementNames();
190}
191
193{
195 Sequence< OUString > aKeyColNames;
196 if ( xPrimaryKeyColumns.is() )
197 aKeyColNames = xPrimaryKeyColumns->getElementNames();
198 return aKeyColNames;
199}
200
202{
203 Reference< XPropertySet > xColumn( m_xObjectColumns->getByName( _rColumnName ), UNO_QUERY_THROW );
204 return new OFieldDescription( xColumn );
205}
206
208{
209 OUString sSelectStatement;
210 if ( m_xObjectPSI->hasPropertyByName( PROPERTY_COMMAND ) )
211 { // query
212 OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_COMMAND ) >>= sSelectStatement );
213 }
214 else
215 { // table
216 OUStringBuffer aSQL( "SELECT " );
217
218 // we need to create the sql stmt with column names
219 // otherwise it is possible that names don't match
220 const OUString sQuote = m_xMetaData->getIdentifierQuoteString();
221
222 Sequence< OUString > aColumnNames = getColumnNames();
223 const OUString* pColumnName = aColumnNames.getConstArray();
224 const OUString* pEnd = pColumnName + aColumnNames.getLength();
225 for ( ; pColumnName != pEnd; )
226 {
227 aSQL.append( ::dbtools::quoteName( sQuote, *pColumnName++ ) );
228
229 if ( pColumnName == pEnd )
230 aSQL.append( " " );
231 else
232 aSQL.append( ", " );
233 }
234
235 aSQL.append( "FROM " + ::dbtools::composeTableNameForSelect( m_xConnection, m_xObject ) );
236
237 sSelectStatement = aSQL.makeStringAndClear();
238 }
239
240 return sSelectStatement;
241}
242
244{
246 m_xConnection->prepareStatement( getSelectStatement() ),
248 );
249 return xStatement;
250}
251
252// NamedTableCopySource
253NamedTableCopySource::NamedTableCopySource( const Reference< XConnection >& _rxConnection, OUString _sTableName )
254 :m_xConnection( _rxConnection, UNO_SET_THROW )
255 ,m_xMetaData( _rxConnection->getMetaData(), UNO_SET_THROW )
256 ,m_sTableName(std::move( _sTableName ))
257{
258 ::dbtools::qualifiedNameComponents( m_xMetaData, m_sTableName, m_sTableCatalog, m_sTableSchema, m_sTableBareName, ::dbtools::EComposeRule::Complete );
260}
261
263{
264 return m_sTableName;
265}
266
268{
269 OUString sTableType;
270 try
271 {
274 Reference< XRow > xTableDescRow( xTableDesc, UNO_QUERY_THROW );
275 OSL_VERIFY( xTableDesc->next() );
276 sTableType = xTableDescRow->getString( 4 );
277 OSL_ENSURE( !xTableDescRow->wasNull(), "NamedTableCopySource::isView: invalid table type!" );
278 }
279 catch( const Exception& )
280 {
281 DBG_UNHANDLED_EXCEPTION("dbaccess");
282 }
283 return sTableType == "VIEW";
284}
285
287{
288 // not supported: we do not have UI settings to copy
289}
290
292{
293}
294
296{
297 if ( !m_aColumnInfo.empty() )
298 return;
299
300 Reference< XResultSetMetaDataSupplier > xStatementMetaSupp( impl_ensureStatement_throw().getTyped(), UNO_QUERY_THROW );
301 Reference< XResultSetMetaData > xStatementMeta( xStatementMetaSupp->getMetaData(), UNO_SET_THROW );
302
303 sal_Int32 nColCount( xStatementMeta->getColumnCount() );
304 for ( sal_Int32 i = 1; i <= nColCount; ++i )
305 {
306 OFieldDescription aDesc;
307
308 aDesc.SetName( xStatementMeta->getColumnName( i ) );
309 aDesc.SetHelpText( xStatementMeta->getColumnLabel( i ) );
310 aDesc.SetTypeValue( xStatementMeta->getColumnType( i ) );
311 aDesc.SetTypeName( xStatementMeta->getColumnTypeName( i ) );
312 aDesc.SetPrecision( xStatementMeta->getPrecision( i ) );
313 aDesc.SetScale( xStatementMeta->getScale( i ) );
314 aDesc.SetIsNullable( xStatementMeta->isNullable( i ) );
315 aDesc.SetCurrency( xStatementMeta->isCurrency( i ) );
316 aDesc.SetAutoIncrement( xStatementMeta->isAutoIncrement( i ) );
317
318 m_aColumnInfo.push_back( aDesc );
319 }
320}
321
323{
324 if ( !m_xStatement.is() )
325 m_xStatement.set( m_xConnection->prepareStatement( getSelectStatement() ), UNO_SET_THROW );
326 return m_xStatement;
327}
328
330{
331 Sequence< OUString > aNames( m_aColumnInfo.size() );
332 std::transform(m_aColumnInfo.begin(), m_aColumnInfo.end(), aNames.getArray(),
333 [](const auto& elem) { return elem.GetName(); });
334
335 return aNames;
336}
337
339{
340 Sequence< OUString > aPKColNames;
341
342 try
343 {
345 Reference< XRow > xPKDescRow( xPKDesc, UNO_QUERY_THROW );
346 while ( xPKDesc->next() )
347 {
348 sal_Int32 len( aPKColNames.getLength() );
349 aPKColNames.realloc( len + 1 );
350 aPKColNames.getArray()[ len ] = xPKDescRow->getString( 4 ); // COLUMN_NAME
351 }
352 }
353 catch( const Exception& )
354 {
355 DBG_UNHANDLED_EXCEPTION("dbaccess");
356 }
357
358 return aPKColNames;
359}
360
362{
363 for (auto const& elem : m_aColumnInfo)
364 if ( elem.GetName() == _rColumnName )
365 return new OFieldDescription(elem);
366
367 return nullptr;
368}
369
371{
372 return "SELECT * FROM " +
373 ::dbtools::composeTableNameForSelect( m_xConnection, m_sTableCatalog, m_sTableSchema, m_sTableBareName );
374}
375
377{
378 return const_cast< NamedTableCopySource* >( this )->impl_ensureStatement_throw();
379}
380
381namespace {
382
383// DummyCopySource
384class DummyCopySource : public ICopyTableSourceObject
385{
386public:
387 DummyCopySource() { }
388
389 static const DummyCopySource& Instance();
390
391 // ICopyTableSourceObject overridables
392 virtual OUString getQualifiedObjectName() const override;
393 virtual bool isView() const override;
394 virtual void copyUISettingsTo( const css::uno::Reference< css::beans::XPropertySet >& _rxObject ) const override;
395 virtual void copyFilterAndSortingTo(const css::uno::Reference< css::sdbc::XConnection >& _xConnection, const css::uno::Reference< css::beans::XPropertySet >& _rxObject ) const override;
396 virtual css::uno::Sequence< OUString >
397 getColumnNames() const override;
398 virtual css::uno::Sequence< OUString >
399 getPrimaryKeyColumnNames() const override;
400 virtual OFieldDescription* createFieldDescription( const OUString& _rColumnName ) const override;
401 virtual OUString getSelectStatement() const override;
402 virtual ::utl::SharedUNOComponent< XPreparedStatement >
403 getPreparedSelectStatement() const override;
404};
405
406}
407
408const DummyCopySource& DummyCopySource::Instance()
409{
410 static DummyCopySource s_aTheInstance;
411 return s_aTheInstance;
412}
413
414OUString DummyCopySource::getQualifiedObjectName() const
415{
416 SAL_WARN("dbaccess.ui", "DummyCopySource::getQualifiedObjectName: not to be called!" );
417 return OUString();
418}
419
420bool DummyCopySource::isView() const
421{
422 SAL_WARN("dbaccess.ui", "DummyCopySource::isView: not to be called!" );
423 return false;
424}
425
426void DummyCopySource::copyUISettingsTo( const Reference< XPropertySet >& /*_rxObject*/ ) const
427{
428 // no support
429}
430
431void DummyCopySource::copyFilterAndSortingTo( const Reference< XConnection >& ,const Reference< XPropertySet >& /*_rxObject*/ ) const
432{
433}
434
435Sequence< OUString > DummyCopySource::getColumnNames() const
436{
437 return Sequence< OUString >();
438}
439
440Sequence< OUString > DummyCopySource::getPrimaryKeyColumnNames() const
441{
442 SAL_WARN("dbaccess.ui", "DummyCopySource::getPrimaryKeyColumnNames: not to be called!" );
443 return Sequence< OUString >();
444}
445
446OFieldDescription* DummyCopySource::createFieldDescription( const OUString& /*_rColumnName*/ ) const
447{
448 SAL_WARN("dbaccess.ui", "DummyCopySource::createFieldDescription: not to be called!" );
449 return nullptr;
450}
451
452OUString DummyCopySource::getSelectStatement() const
453{
454 SAL_WARN("dbaccess.ui", "DummyCopySource::getSelectStatement: not to be called!" );
455 return OUString();
456}
457
458::utl::SharedUNOComponent< XPreparedStatement > DummyCopySource::getPreparedSelectStatement() const
459{
460 SAL_WARN("dbaccess.ui", "DummyCopySource::getPreparedSelectStatement: not to be called!" );
461 return ::utl::SharedUNOComponent< XPreparedStatement >();
462}
463
464namespace
465{
466 bool lcl_canCreateViewFor_nothrow( const Reference< XConnection >& _rxConnection )
467 {
468 Reference< XViewsSupplier > xSup( _rxConnection, UNO_QUERY );
469 Reference< XDataDescriptorFactory > xViewFac;
470 if ( xSup.is() )
471 xViewFac.set( xSup->getViews(), UNO_QUERY );
472 return xViewFac.is();
473 }
474
475 bool lcl_sameConnection_throw( const Reference< XConnection >& _rxLHS, const Reference< XConnection >& _rxRHS )
476 {
477 Reference< XDatabaseMetaData > xMetaLHS( _rxLHS->getMetaData(), UNO_SET_THROW );
478 Reference< XDatabaseMetaData > xMetaRHS( _rxRHS->getMetaData(), UNO_SET_THROW );
479 return xMetaLHS->getURL() == xMetaRHS->getURL();
480 }
481}
482
483// OCopyTableWizard
484OCopyTableWizard::OCopyTableWizard(weld::Window* pParent, const OUString& _rDefaultName, sal_Int16 _nOperation,
485 const ICopyTableSourceObject& _rSourceObject, const Reference< XConnection >& _xSourceConnection,
486 const Reference< XConnection >& _xConnection, const Reference< XComponentContext >& _rxContext,
487 const Reference< XInteractionHandler>& _xInteractionHandler)
488 : vcl::RoadmapWizardMachine(pParent)
489 , m_mNameMapping(_xConnection->getMetaData().is() && _xConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers())
490 , m_xDestConnection( _xConnection )
491 , m_rSourceObject( _rSourceObject )
492 , m_xFormatter( getNumberFormatter( _xConnection, _rxContext ) )
493 , m_xContext(_rxContext)
494 , m_xInteractionHandler(_xInteractionHandler)
495 , m_sTypeNames(DBA_RES(STR_TABLEDESIGN_DBFIELDTYPES))
496 , m_nPageCount(0)
497 , m_bDeleteSourceColumns(true)
498 , m_bInterConnectionCopy( _xSourceConnection != _xConnection )
499 , m_sName( _rDefaultName )
500 , m_nOperation( _nOperation )
501 , m_ePressed( WIZARD_NONE )
502 , m_bCreatePrimaryKeyColumn(false)
503 , m_bUseHeaderLine(false)
504{
505 construct();
506
507 // extract table name
508 OUString sInitialTableName( _rDefaultName );
509 try
510 {
511 m_sSourceName = m_rSourceObject.getQualifiedObjectName();
512 OSL_ENSURE( !m_sSourceName.isEmpty(), "OCopyTableWizard::OCopyTableWizard: unable to retrieve the source object's name!" );
513
514 if ( sInitialTableName.isEmpty() )
515 sInitialTableName = m_sSourceName;
516
517 if ( m_sName.isEmpty() )
518 {
519 if ( _xSourceConnection == m_xDestConnection )
520 {
521 Reference< XTablesSupplier > xSup( m_xDestConnection, UNO_QUERY_THROW );
522 m_sName = ::dbtools::createUniqueName( xSup->getTables(), sInitialTableName, false );
523 }
524 else
525 m_sName = sInitialTableName;
526 }
527 }
528 catch ( const Exception& )
529 {
530 m_sName = sInitialTableName;
531 }
532
533 ::dbaui::fillTypeInfo( _xSourceConnection, m_sTypeNames, m_aTypeInfo, m_aTypeInfoIndex );
534 ::dbaui::fillTypeInfo( m_xDestConnection, m_sTypeNames, m_aDestTypeInfo, m_aDestTypeInfoIndex );
535 loadData( m_rSourceObject, m_vSourceColumns, m_vSourceVec );
536
537 bool bAllowViews = true;
538 // if the source is a, don't allow creating views
539 if ( m_rSourceObject.isView() )
540 bAllowViews = false;
541 // no views if the target connection does not support creating them
542 if ( !lcl_canCreateViewFor_nothrow( m_xDestConnection ) )
543 bAllowViews = false;
544 // no views if we're copying to a different database
545 if ( !lcl_sameConnection_throw( _xSourceConnection, m_xDestConnection ) )
546 bAllowViews = false;
547
548 if ( m_bInterConnectionCopy )
549 {
550 Reference< XDatabaseMetaData > xSrcMeta = _xSourceConnection->getMetaData();
551 OUString sCatalog;
552 OUString sSchema;
553 OUString sTable;
554 ::dbtools::qualifiedNameComponents( xSrcMeta,
555 m_sName,
556 sCatalog,
557 sSchema,
558 sTable,
559 ::dbtools::EComposeRule::InDataManipulation);
560
561 m_sName = ::dbtools::composeTableName(m_xDestConnection->getMetaData(),sCatalog,sSchema,sTable,false,::dbtools::EComposeRule::InTableDefinitions);
562 }
563
564 std::unique_ptr<OCopyTable> xPage1(new OCopyTable(CreatePageContainer(), this));
565 xPage1->disallowUseHeaderLine();
566 if ( !bAllowViews )
567 xPage1->disallowViews();
568 xPage1->setCreateStyleAction();
569 AddWizardPage(std::move(xPage1));
570
571 AddWizardPage( std::make_unique<OWizNameMatching>(CreatePageContainer(), this));
572 AddWizardPage( std::make_unique<OWizColumnSelect>(CreatePageContainer(), this));
573 AddWizardPage( std::make_unique<OWizNormalExtend>(CreatePageContainer(), this));
574 ActivatePage();
575
576 m_xAssistant->set_current_page(0);
577}
578
580{
581 OUString sIdent(OUString::number(m_nPageCount));
582 weld::Container* pPageContainer = m_xAssistant->append_page(sIdent);
583 return pPageContainer;
584}
585
586OCopyTableWizard::OCopyTableWizard( weld::Window* pParent, OUString _sDefaultName, sal_Int16 _nOperation,
587 ODatabaseExport::TColumns&& _rSourceColumns, const ODatabaseExport::TColumnVector& _rSourceColVec,
588 const Reference< XConnection >& _xConnection, const Reference< XNumberFormatter >& _xFormatter,
589 TypeSelectionPageFactory _pTypeSelectionPageFactory, SvStream& _rTypeSelectionPageArg, const Reference< XComponentContext >& _rxContext )
590 : vcl::RoadmapWizardMachine(pParent)
591 , m_vSourceColumns(std::move(_rSourceColumns))
592 , m_mNameMapping(_xConnection->getMetaData().is() && _xConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers())
593 , m_xDestConnection( _xConnection )
594 , m_rSourceObject( DummyCopySource::Instance() )
595 , m_xFormatter(_xFormatter)
596 , m_xContext(_rxContext)
597 , m_sTypeNames(DBA_RES(STR_TABLEDESIGN_DBFIELDTYPES))
598 , m_nPageCount(0)
599 , m_bDeleteSourceColumns(false)
600 , m_bInterConnectionCopy( false )
601 , m_sName(std::move(_sDefaultName))
602 , m_nOperation( _nOperation )
603 , m_ePressed( WIZARD_NONE )
604 , m_bCreatePrimaryKeyColumn(false)
605 , m_bUseHeaderLine(false)
606{
607 construct();
608 for (auto const& sourceCol : _rSourceColVec)
609 {
610 m_vSourceVec.emplace_back(m_vSourceColumns.find(sourceCol->first));
611 }
612
615
616 m_xInteractionHandler = InteractionHandler::createWithParent(m_xContext, nullptr);
617
618 std::unique_ptr<OCopyTable> xPage1(new OCopyTable(CreatePageContainer(), this));
619 xPage1->disallowViews();
620 xPage1->setCreateStyleAction();
621 AddWizardPage(std::move(xPage1));
622
623 AddWizardPage(std::make_unique<OWizNameMatching>(CreatePageContainer(), this));
624 AddWizardPage(std::make_unique<OWizColumnSelect>(CreatePageContainer(), this));
625 AddWizardPage((*_pTypeSelectionPageFactory)(CreatePageContainer(), this, _rTypeSelectionPageArg));
626
627 ActivatePage();
628
629 m_xAssistant->set_current_page(0);
630}
631
633{
634 m_xAssistant->set_size_request(700, 350);
635
636 m_xPrevPage->set_label(DBA_RES(STR_WIZ_PB_PREV));
637 m_xNextPage->set_label(DBA_RES(STR_WIZ_PB_NEXT));
638 m_xFinish->set_label(DBA_RES(STR_WIZ_PB_OK));
639
640 m_xHelp->show();
641 m_xCancel->show();
642 m_xPrevPage->show();
643 m_xNextPage->show();
644 m_xFinish->show();
645
646 m_xPrevPage->connect_clicked( LINK( this, OCopyTableWizard, ImplPrevHdl ) );
647 m_xNextPage->connect_clicked( LINK( this, OCopyTableWizard, ImplNextHdl ) );
648 m_xFinish->connect_clicked( LINK( this, OCopyTableWizard, ImplOKHdl ) );
649
650 m_xNextPage->grab_focus();
651
652 if (!m_vDestColumns.empty())
653 // source is a html or rtf table
654 m_xAssistant->change_default_widget(nullptr, m_xNextPage.get());
655 else
656 m_xAssistant->change_default_widget(nullptr, m_xFinish.get());
657
658 m_pTypeInfo = std::make_shared<OTypeInfo>();
659 m_pTypeInfo->aUIName = m_sTypeNames.getToken(TYPE_OTHER, ';');
660 m_bAddPKFirstTime = true;
661}
662
664{
666 clearColumns(m_vSourceColumns,m_vSourceVec);
667
668 clearColumns(m_vDestColumns,m_aDestVec);
669
670 // clear the type information
671 m_aTypeInfoIndex.clear();
672 m_aTypeInfo.clear();
673 m_aDestTypeInfoIndex.clear();
674 m_aDestTypeInfo.clear();
675}
676
677IMPL_LINK_NOARG(OCopyTableWizard, ImplPrevHdl, weld::Button&, void)
678{
679 m_ePressed = WIZARD_PREV;
680 if ( GetCurLevel() )
681 {
682 if ( getOperation() != CopyTableOperation::AppendData )
683 {
684 if(GetCurLevel() == 2)
685 ShowPage(GetCurLevel()-2);
686 else
687 ShowPrevPage();
688 }
689 else
690 ShowPrevPage();
691 }
692}
693
694IMPL_LINK_NOARG(OCopyTableWizard, ImplNextHdl, weld::Button&, void)
695{
696 m_ePressed = WIZARD_NEXT;
697 if ( GetCurLevel() < MAX_PAGES )
698 {
699 if ( getOperation() != CopyTableOperation::AppendData )
700 {
701 if(GetCurLevel() == 0)
702 ShowPage(GetCurLevel()+2);
703 else
704 ShowNextPage();
705 }
706 else
707 ShowNextPage();
708 }
709}
710
711bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos)
712{
713 bool bRet = true;
714 m_vColumnPositions.clear();
715 m_vColumnTypes.clear();
716
717 OSL_ENSURE( m_xDestConnection.is(), "OCopyTableWizard::CheckColumns: No connection!" );
718 // If database is able to process PrimaryKeys, set PrimaryKey
719 if ( m_xDestConnection.is() )
720 {
721 bool bPKeyAllowed = supportsPrimaryKey();
722
723 bool bContainsColumns = !m_vDestColumns.empty();
724
725 if ( bPKeyAllowed && shouldCreatePrimaryKey() )
726 {
727 // add extra column for the primary key
729 if ( pTypeInfo )
730 {
731 if ( m_bAddPKFirstTime )
732 {
733 // tdf#114955: since we chose to create a primary key
734 // be sure all other columns won't be in primary key
735 for (auto const& elem : m_vDestColumns)
736 elem.second->SetPrimaryKey(false);
737 OFieldDescription* pField = new OFieldDescription();
738 pField->SetName(m_aKeyName);
739 pField->FillFromTypeInfo(pTypeInfo,true,true);
740 pField->SetPrimaryKey(true);
741 m_bAddPKFirstTime = false;
742 insertColumn(0,pField);
743 }
744 m_vColumnPositions.emplace_back(1,1);
745 m_vColumnTypes.push_back(pTypeInfo->nType);
746 }
747 }
748
749 if ( bContainsColumns )
750 { // we have dest columns so look for the matching column
751 for (auto const& elemSource : m_vSourceVec)
752 {
753 ODatabaseExport::TColumns::const_iterator aDestIter = m_vDestColumns.find(m_mNameMapping[elemSource->first]);
754
755 if ( aDestIter != m_vDestColumns.end() )
756 {
757 ODatabaseExport::TColumnVector::const_iterator aFind = std::find(m_aDestVec.begin(),m_aDestVec.end(),aDestIter);
758 assert(aFind != m_aDestVec.end());
759 sal_Int32 nPos = (aFind - m_aDestVec.begin())+1;
760 m_vColumnPositions.emplace_back(nPos,nPos);
761 m_vColumnTypes.push_back((*aFind)->second->GetType());
762 }
763 else
764 {
766 m_vColumnTypes.push_back(0);
767 }
768 }
769 }
770 else
771 {
772 Reference< XDatabaseMetaData > xMetaData( m_xDestConnection->getMetaData() );
773 OUString sExtraChars = xMetaData->getExtraNameCharacters();
774 sal_Int32 nMaxNameLen = getMaxColumnNameLength();
775
776 _rnBreakPos=0;
777 for (auto const& elemSource : m_vSourceVec)
778 {
779 OFieldDescription* pField = new OFieldDescription(*elemSource->second);
780 pField->SetName(convertColumnName(TExportColumnFindFunctor(&m_vDestColumns),elemSource->first,sExtraChars,nMaxNameLen));
781 TOTypeInfoSP pType = convertType(elemSource->second->getSpecialTypeInfo(),bRet);
782 pField->SetType(pType);
783 if ( !bPKeyAllowed )
784 pField->SetPrimaryKey(false);
785
786 // now create a column
787 insertColumn(m_vDestColumns.size(),pField);
788 m_vColumnPositions.emplace_back(m_vDestColumns.size(),m_vDestColumns.size());
789 m_vColumnTypes.push_back(elemSource->second->GetType());
790 ++_rnBreakPos;
791 if (!bRet)
792 break;
793 }
794 }
795 }
796 return bRet;
797}
798
799IMPL_LINK_NOARG(OCopyTableWizard, ImplOKHdl, weld::Button&, void)
800{
801 m_ePressed = WIZARD_FINISH;
802 bool bFinish = DeactivatePage();
803
804 if(!bFinish)
805 return;
806
807 weld::WaitObject aWait(m_xAssistant.get());
808 switch(getOperation())
809 {
810 case CopyTableOperation::CopyDefinitionAndData:
811 case CopyTableOperation::CopyDefinitionOnly:
812 {
813 bool bOnFirstPage = GetCurLevel() == 0;
814 if ( bOnFirstPage )
815 {
816 // we came from the first page so we have to clear
817 // all column information already collected
818 clearDestColumns();
819 m_mNameMapping.clear();
820 }
821 sal_Int32 nBreakPos = 0;
822 bool bCheckOk = CheckColumns(nBreakPos);
823 if ( bOnFirstPage && !bCheckOk )
824 {
825 showColumnTypeNotSupported(m_vSourceVec[nBreakPos-1]->first);
826 OWizTypeSelect* pPage = static_cast<OWizTypeSelect*>(GetPage(3));
827 if ( pPage )
828 {
829 m_mNameMapping.clear();
830 pPage->setDisplayRow(nBreakPos);
831 ShowPage(3);
832 return;
833 }
834 }
835 if ( m_xDestConnection.is() )
836 {
837 if ( supportsPrimaryKey() )
838 {
839 bool noPrimaryKey = std::none_of(m_vDestColumns.begin(),m_vDestColumns.end(),
840 [] (const ODatabaseExport::TColumns::value_type& tCol) { return tCol.second->IsPrimaryKey(); });
841 if ( noPrimaryKey && m_xInteractionHandler.is() )
842 {
843
844 OUString sMsg(DBA_RES(STR_TABLEDESIGN_NO_PRIM_KEY));
845 SQLContext aError;
846 aError.Message = sMsg;
847 ::rtl::Reference xRequest( new ::comphelper::OInteractionRequest( Any( aError ) ) );
848 ::rtl::Reference xYes = new ::comphelper::OInteractionApprove;
849 xRequest->addContinuation( xYes );
850 xRequest->addContinuation( new ::comphelper::OInteractionDisapprove );
851 ::rtl::Reference< ::comphelper::OInteractionAbort > xAbort = new ::comphelper::OInteractionAbort;
852 xRequest->addContinuation( xAbort );
853
854 m_xInteractionHandler->handle( xRequest );
855
856 if ( xYes->wasSelected() )
857 {
858 OCopyTable* pPage = static_cast<OCopyTable*>(GetPage(0));
859 m_bCreatePrimaryKeyColumn = true;
860 m_aKeyName = pPage->GetKeyName();
861 if ( m_aKeyName.isEmpty() )
862 m_aKeyName = "ID";
863 m_aKeyName = createUniqueName( m_aKeyName );
864 sal_Int32 nBreakPos2 = 0;
865 CheckColumns(nBreakPos2);
866 }
867 else if ( xAbort->wasSelected() )
868 {
869 ShowPage(3);
870 return;
871 }
872 }
873 }
874 }
875 break;
876 }
877 case CopyTableOperation::AppendData:
878 case CopyTableOperation::CreateAsView:
879 break;
880 default:
881 {
882 SAL_WARN("dbaccess.ui", "OCopyTableWizard::ImplOKHdl: invalid creation style!");
883 }
884 }
885
886 m_xAssistant->response(RET_OK);
887}
888
889void OCopyTableWizard::setCreatePrimaryKey( bool _bDoCreate, const OUString& _rSuggestedName )
890{
891 m_bCreatePrimaryKeyColumn = _bDoCreate;
892 if ( !_rSuggestedName.isEmpty() )
893 m_aKeyName = _rSuggestedName;
894
895 OCopyTable* pSettingsPage = dynamic_cast< OCopyTable* >( GetPage( 0 ) );
896 OSL_ENSURE( pSettingsPage, "OCopyTableWizard::setCreatePrimaryKey: page should have been added in the ctor!" );
897 if ( pSettingsPage )
898 pSettingsPage->setCreatePrimaryKey( _bDoCreate, _rSuggestedName );
899}
900
902{
903 OWizardPage* pCurrent = static_cast<OWizardPage*>(GetPage(GetCurLevel()));
904 if (pCurrent)
905 {
906 bool bFirstTime = pCurrent->IsFirstTime();
907 if(bFirstTime)
908 pCurrent->Reset();
909
910 CheckButtons();
911
912 m_xAssistant->set_title(pCurrent->GetTitle());
913 }
914}
915
917{
918 if(GetCurLevel() == 0) // the first page has no back button
919 {
920 if(m_nPageCount > 1)
921 m_xNextPage->set_sensitive(true);
922 else
923 m_xNextPage->set_sensitive(false);
924
925 m_xPrevPage->set_sensitive(false);
926 }
927 else if(GetCurLevel() == m_nPageCount-1) // the last page has no next button
928 {
929 m_xNextPage->set_sensitive(false);
930 m_xPrevPage->set_sensitive(true);
931 }
932 else
933 {
934 m_xPrevPage->set_sensitive(true);
935 // next already has its state
936 }
937}
938
940{
941 m_xNextPage->set_sensitive(bEnable);
942}
943
945{
946 OWizardPage* pPage = static_cast<OWizardPage*>(GetPage(GetCurLevel()));
947 return pPage && pPage->LeavePage();
948}
949
950void OCopyTableWizard::AddWizardPage(std::unique_ptr<OWizardPage> xPage)
951{
952 AddPage(std::move(xPage));
953 ++m_nPageCount;
954}
955
957{
958 OSL_ENSURE(_pField,"FieldDescrioption is null!");
959 if ( !_pField )
960 return;
961
962 ODatabaseExport::TColumns::const_iterator aFind = m_vDestColumns.find(_pField->GetName());
963 if ( aFind != m_vDestColumns.end() )
964 {
965 delete aFind->second;
966 m_vDestColumns.erase(aFind);
967 }
968
969 m_aDestVec.insert(m_aDestVec.begin() + _nPos,
970 m_vDestColumns.emplace(_pField->GetName(),_pField).first);
971 m_mNameMapping[_pField->GetName()] = _pField->GetName();
972}
973
974void OCopyTableWizard::replaceColumn(sal_Int32 _nPos,OFieldDescription* _pField,const OUString& _sOldName)
975{
976 OSL_ENSURE(_pField,"FieldDescrioption is null!");
977 if ( _pField )
978 {
979 m_vDestColumns.erase(_sOldName);
980 OSL_ENSURE( m_vDestColumns.find(_pField->GetName()) == m_vDestColumns.end(),"Column with that name already exist!");
981
982 m_aDestVec[_nPos] = m_vDestColumns.emplace(_pField->GetName(),_pField).first;
983 }
984}
985
987{
988 for (auto const& column : _rColumns)
989 delete column.second;
990
991 _rColVector.clear();
992 _rColumns.clear();
993
994 OFieldDescription* pActFieldDescr = nullptr;
995 static constexpr OUStringLiteral sCreateParam(u"x");
996 // ReadOnly-Flag
997 // On drop no line must be editable.
998 // On add only empty lines must be editable.
999 // On Add and Drop all lines can be edited.
1000 Sequence< OUString > aColumns( _rSourceObject.getColumnNames() );
1001 const OUString* pColumn = aColumns.getConstArray();
1002 const OUString* pColumnEnd = pColumn + aColumns.getLength();
1003
1004 for ( ; pColumn != pColumnEnd; ++pColumn )
1005 {
1006 // get the properties of the column
1007 pActFieldDescr = _rSourceObject.createFieldDescription( *pColumn );
1008 OSL_ENSURE( pActFieldDescr, "OCopyTableWizard::loadData: illegal field description!" );
1009 if ( !pActFieldDescr )
1010 continue;
1011
1012 sal_Int32 nType = pActFieldDescr->GetType();
1013 sal_Int32 nScale = pActFieldDescr->GetScale();
1014 sal_Int32 nPrecision = pActFieldDescr->GetPrecision();
1015 bool bAutoIncrement = pActFieldDescr->IsAutoIncrement();
1016 OUString sTypeName = pActFieldDescr->GetTypeName();
1017
1018 // search for type
1019 bool bForce;
1020 TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,sCreateParam,nPrecision,nScale,bAutoIncrement,bForce);
1021 if ( !pTypeInfo )
1022 pTypeInfo = m_pTypeInfo;
1023
1024 pActFieldDescr->FillFromTypeInfo(pTypeInfo,true,false);
1025 _rColVector.emplace_back(_rColumns.emplace(pActFieldDescr->GetName(),pActFieldDescr).first);
1026 }
1027
1028 // determine which columns belong to the primary key
1029 Sequence< OUString > aPrimaryKeyColumns( _rSourceObject.getPrimaryKeyColumnNames() );
1030 const OUString* pKeyColName = aPrimaryKeyColumns.getConstArray();
1031 const OUString* pKeyColEnd = pKeyColName + aPrimaryKeyColumns.getLength();
1032
1033 for( ; pKeyColName != pKeyColEnd; ++pKeyColName )
1034 {
1035 ODatabaseExport::TColumns::const_iterator keyPos = _rColumns.find( *pKeyColName );
1036 if ( keyPos != _rColumns.end() )
1037 {
1038 keyPos->second->SetPrimaryKey( true );
1039 keyPos->second->SetIsNullable( ColumnValue::NO_NULLS );
1040 }
1041 }
1042}
1043
1045{
1046 clearColumns(m_vDestColumns,m_aDestVec);
1047 m_bAddPKFirstTime = true;
1048 m_mNameMapping.clear();
1049}
1050
1052{
1053 // now append the columns
1054 OSL_ENSURE(_rxColSup.is(),"No columns supplier");
1055 if(!_rxColSup.is())
1056 return;
1057 Reference<XNameAccess> xColumns = _rxColSup->getColumns();
1058 OSL_ENSURE(xColumns.is(),"No columns");
1059 Reference<XDataDescriptorFactory> xColumnFactory(xColumns,UNO_QUERY);
1060
1061 Reference<XAppend> xAppend(xColumns,UNO_QUERY);
1062 OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
1063
1064 for (auto const& elem : *_pVec)
1065 {
1066 OFieldDescription* pField = elem->second;
1067 if(!pField)
1068 continue;
1069
1071 if(pField->IsPrimaryKey() || !_bKeyColumns)
1072 xColumn = xColumnFactory->createDataDescriptor();
1073 if(xColumn.is())
1074 {
1075 if(!_bKeyColumns)
1077 else
1078 xColumn->setPropertyValue(PROPERTY_NAME,Any(pField->GetName()));
1079
1080 xAppend->appendByDescriptor(xColumn);
1081 xColumn = nullptr;
1082 // now only the settings are missing
1083 if(xColumns->hasByName(pField->GetName()))
1084 {
1085 xColumn.set(xColumns->getByName(pField->GetName()),UNO_QUERY);
1086 OSL_ENSURE(xColumn.is(),"OCopyTableWizard::appendColumns: Column is NULL!");
1087 if ( xColumn.is() )
1089 }
1090 else
1091 {
1092 SAL_WARN("dbaccess.ui", "OCopyTableWizard::appendColumns: invalid field name!");
1093 }
1094
1095 }
1096 }
1097}
1098
1100{
1101 if(!_rxSup.is())
1102 return; // the database doesn't support keys
1103 OSL_ENSURE(_rxSup.is(),"No XKeysSupplier!");
1104 Reference<XDataDescriptorFactory> xKeyFactory(_rxSup->getKeys(),UNO_QUERY);
1105 OSL_ENSURE(xKeyFactory.is(),"No XDataDescriptorFactory Interface!");
1106 if ( !xKeyFactory.is() )
1107 return;
1108 Reference<XAppend> xAppend(xKeyFactory,UNO_QUERY);
1109 OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
1110
1111 Reference<XPropertySet> xKey = xKeyFactory->createDataDescriptor();
1112 OSL_ENSURE(xKey.is(),"Key is null!");
1113 xKey->setPropertyValue(PROPERTY_TYPE,Any(KeyType::PRIMARY));
1114
1115 Reference<XColumnsSupplier> xColSup(xKey,UNO_QUERY);
1116 if(xColSup.is())
1117 {
1118 appendColumns(xColSup,_pVec,true);
1119 Reference<XNameAccess> xColumns = xColSup->getColumns();
1120 if(xColumns.is() && xColumns->getElementNames().hasElements())
1121 xAppend->appendByDescriptor(xKey);
1122 }
1123
1124}
1125
1127{
1128 OUString sCommand( m_rSourceObject.getSelectStatement() );
1129 OSL_ENSURE( !sCommand.isEmpty(), "OCopyTableWizard::createView: no statement in the source object!" );
1130 // there are legitimate cases in which getSelectStatement does not provide a statement,
1131 // but in all those cases, this method here should never be called.
1133}
1134
1136{
1137 if ( getOperation() == CopyTableOperation::AppendData )
1138 return getTable();
1139 else
1140 return createTable();
1141}
1142
1144{
1146
1149 if(xSup.is())
1150 xTables = xSup->getTables();
1151 if(xTables.is() && xTables->hasByName(m_sName))
1152 xTables->getByName(m_sName) >>= xTable;
1153
1154 return xTable;
1155}
1156
1158{
1160
1163 if(xSup.is())
1164 xTables = xSup->getTables();
1165 Reference<XDataDescriptorFactory> xFact(xTables,UNO_QUERY);
1166 OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!");
1167 if(!xFact.is())
1168 return nullptr;
1169
1170 xTable = xFact->createDataDescriptor();
1171 OSL_ENSURE(xTable.is(),"Could not create a new object!");
1172 if(!xTable.is())
1173 return nullptr;
1174
1175 OUString sCatalog,sSchema,sTable;
1176 Reference< XDatabaseMetaData> xMetaData = m_xDestConnection->getMetaData();
1177 ::dbtools::qualifiedNameComponents(xMetaData,
1178 m_sName,
1179 sCatalog,
1180 sSchema,
1181 sTable,
1182 ::dbtools::EComposeRule::InDataManipulation);
1183
1184 if ( sCatalog.isEmpty() && xMetaData->supportsCatalogsInTableDefinitions() )
1185 {
1186 sCatalog = m_xDestConnection->getCatalog();
1187 }
1188
1189 if ( sSchema.isEmpty() && xMetaData->supportsSchemasInTableDefinitions() )
1190 {
1191 // query of current schema is quite inconsistent. In case of some
1192 // DBMS's each user has their own schema.
1193 sSchema = xMetaData->getUserName();
1194 // In case of mysql it is not that simple
1195 if(xMetaData->getDatabaseProductName() == "MySQL")
1196 {
1197 Reference< XStatement > xSelect = m_xDestConnection->createStatement();
1198 Reference< XResultSet > xRs = xSelect->executeQuery("select database()");
1199 (void)xRs->next(); // first and only result
1200 Reference< XRow > xRow( xRs, UNO_QUERY_THROW );
1201 sSchema = xRow->getString(1);
1202 }
1203 }
1204
1205 xTable->setPropertyValue(PROPERTY_CATALOGNAME,Any(sCatalog));
1206 xTable->setPropertyValue(PROPERTY_SCHEMANAME,Any(sSchema));
1207 xTable->setPropertyValue(PROPERTY_NAME,Any(sTable));
1208
1209 Reference< XColumnsSupplier > xSuppDestinationColumns( xTable, UNO_QUERY );
1210 // now append the columns
1212 appendColumns( xSuppDestinationColumns, &rVec );
1213 // now append the primary key
1214 Reference<XKeysSupplier> xKeySup(xTable,UNO_QUERY);
1215 appendKey(xKeySup, &rVec);
1216
1217 Reference<XAppend> xAppend(xTables,UNO_QUERY);
1218 if(xAppend.is())
1219 xAppend->appendByDescriptor(xTable);
1220
1221 // xTable = NULL;
1222 // we need to reget the table because after appending it, it is no longer valid
1223 if(xTables->hasByName(m_sName))
1224 xTables->getByName(m_sName) >>= xTable;
1225 else
1226 {
1227 OUString sComposedName(
1228 ::dbtools::composeTableName( m_xDestConnection->getMetaData(), xTable, ::dbtools::EComposeRule::InDataManipulation, false ) );
1229 if(xTables->hasByName(sComposedName))
1230 {
1231 xTables->getByName(sComposedName) >>= xTable;
1233 }
1234 else
1235 xTable = nullptr;
1236 }
1237
1238 if(xTable.is())
1239 {
1240 xSuppDestinationColumns.set( xTable, UNO_QUERY_THROW );
1241 // insert new table name into table filter
1243
1244 // copy ui settings
1246 //copy filter and sorting
1248 // set column mappings
1249 Reference<XNameAccess> xNameAccess = xSuppDestinationColumns->getColumns();
1250 Sequence< OUString> aSeq = xNameAccess->getElementNames();
1251 const OUString* pIter = aSeq.getConstArray();
1252 const OUString* pEnd = pIter + aSeq.getLength();
1253
1254 for(sal_Int32 nNewPos=1;pIter != pEnd;++pIter,++nNewPos)
1255 {
1256 ODatabaseExport::TColumns::const_iterator aDestIter = m_vDestColumns.find(*pIter);
1257
1258 if ( aDestIter != m_vDestColumns.end() )
1259 {
1260 ODatabaseExport::TColumnVector::const_iterator aFind = std::find(m_aDestVec.begin(),m_aDestVec.end(),aDestIter);
1261 sal_Int32 nPos = (aFind - m_aDestVec.begin())+1;
1262
1263 ODatabaseExport::TPositions::iterator aPosFind = std::find_if(
1264 m_vColumnPositions.begin(),
1265 m_vColumnPositions.end(),
1266 [nPos] (const ODatabaseExport::TPositions::value_type& tPos) {
1267 return tPos.first == nPos;
1268 }
1269 );
1270
1271 if ( m_vColumnPositions.end() != aPosFind )
1272 {
1273 aPosFind->second = nNewPos;
1274 OSL_ENSURE( m_vColumnTypes.size() > o3tl::make_unsigned( aPosFind - m_vColumnPositions.begin() ),
1275 "Invalid index for vector!" );
1276 m_vColumnTypes[ aPosFind - m_vColumnPositions.begin() ] = (*aFind)->second->GetType();
1277 }
1278 }
1279 }
1280 }
1281
1282 return xTable;
1283}
1284
1286{
1287 OSL_PRECOND( _rxConnection.is(), "OCopyTableWizard::supportsPrimaryKey: invalid connection!" );
1288 if ( !_rxConnection.is() )
1289 return false;
1290
1291 ::dbtools::DatabaseMetaData aMetaData( _rxConnection );
1292 return aMetaData.supportsPrimaryKeys();
1293}
1294
1295bool OCopyTableWizard::supportsViews( const Reference< XConnection >& _rxConnection )
1296{
1297 OSL_PRECOND( _rxConnection.is(), "OCopyTableWizard::supportsViews: invalid connection!" );
1298 if ( !_rxConnection.is() )
1299 return false;
1300
1301 bool bSupportsViews( false );
1302 try
1303 {
1304 Reference< XDatabaseMetaData > xMetaData( _rxConnection->getMetaData(), UNO_SET_THROW );
1305 Reference< XViewsSupplier > xViewSups( _rxConnection, UNO_QUERY );
1306 bSupportsViews = xViewSups.is();
1307 if ( !bSupportsViews )
1308 {
1309 try
1310 {
1311 Reference< XResultSet > xRs( xMetaData->getTableTypes(), UNO_SET_THROW );
1312 Reference< XRow > xRow( xRs, UNO_QUERY_THROW );
1313 while ( xRs->next() )
1314 {
1315 OUString sValue = xRow->getString( 1 );
1316 if ( !xRow->wasNull() && sValue.equalsIgnoreAsciiCase("View") )
1317 {
1318 bSupportsViews = true;
1319 break;
1320 }
1321 }
1322 }
1323 catch( const SQLException& )
1324 {
1325 DBG_UNHANDLED_EXCEPTION("dbaccess");
1326 }
1327 }
1328 }
1329 catch( const Exception& )
1330 {
1331 DBG_UNHANDLED_EXCEPTION("dbaccess");
1332 }
1333 return bSupportsViews;
1334}
1335
1337{
1338 sal_Int32 nLen = 0;
1339 if ( m_xDestConnection.is() )
1340 {
1341 try
1342 {
1343 Reference< XDatabaseMetaData > xMetaData( m_xDestConnection->getMetaData(), UNO_SET_THROW );
1344 nLen = xMetaData->getMaxColumnNameLength();
1345 }
1346 catch(const Exception&)
1347 {
1348 DBG_UNHANDLED_EXCEPTION("dbaccess");
1349 }
1350 }
1351 return nLen;
1352}
1353
1354void OCopyTableWizard::setOperation( const sal_Int16 _nOperation )
1355{
1356 m_nOperation = _nOperation;
1357}
1358
1359
1361 const OUString& _sColumnName,
1362 std::u16string_view _sExtraChars,
1363 sal_Int32 _nMaxNameLen)
1364{
1365 OUString sAlias = _sColumnName;
1367 sAlias = ::dbtools::convertName2SQLName(_sColumnName,_sExtraChars);
1368 if((_nMaxNameLen && sAlias.getLength() > _nMaxNameLen) || _rCmpFunctor(sAlias))
1369 {
1370 sal_Int32 nDiff = 1;
1371 do
1372 {
1373 ++nDiff;
1374 if(_nMaxNameLen && sAlias.getLength() >= _nMaxNameLen)
1375 sAlias = sAlias.copy(0,sAlias.getLength() - (sAlias.getLength()-_nMaxNameLen+nDiff));
1376
1377 OUString sName(sAlias);
1378 sal_Int32 nPos = 1;
1379 sName += OUString::number(nPos);
1380
1381 while(_rCmpFunctor(sName))
1382 {
1383 sName = sAlias + OUString::number(++nPos);
1384 }
1385 sAlias = sName;
1386 // we have to check again, it could happen that the name is already too long
1387 }
1388 while(_nMaxNameLen && sAlias.getLength() > _nMaxNameLen);
1389 }
1390 OSL_ENSURE(m_mNameMapping.find(_sColumnName) == m_mNameMapping.end(),"name doubled!");
1391 m_mNameMapping[_sColumnName] = sAlias;
1392 return sAlias;
1393}
1394
1396{
1397 m_mNameMapping.erase(_sName);
1398}
1399
1400bool OCopyTableWizard::supportsType(sal_Int32 _nDataType, sal_Int32& _rNewDataType)
1401{
1402 bool bRet = m_aDestTypeInfo.find(_nDataType) != m_aDestTypeInfo.end();
1403 if ( bRet )
1404 _rNewDataType = _nDataType;
1405 return bRet;
1406}
1407
1409{
1411 // no need to convert if the source and destination connection are the same
1412 return _pType;
1413
1414 bool bForce;
1415 TOTypeInfoSP pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,_pType->nType,_pType->aTypeName,_pType->aCreateParams,_pType->nPrecision,_pType->nMaximumScale,_pType->bAutoIncrement,bForce);
1416 if ( !pType || bForce )
1417 { // no type found so we have to find the correct one ourself
1418 sal_Int32 nDefaultType = DataType::VARCHAR;
1419 switch(_pType->nType)
1420 {
1421 case DataType::TINYINT:
1422 if(supportsType(DataType::SMALLINT,nDefaultType))
1423 break;
1424 [[fallthrough]];
1425 case DataType::SMALLINT:
1426 if(supportsType(DataType::INTEGER,nDefaultType))
1427 break;
1428 [[fallthrough]];
1429 case DataType::INTEGER:
1430 if(supportsType(DataType::FLOAT,nDefaultType))
1431 break;
1432 [[fallthrough]];
1433 case DataType::FLOAT:
1434 if(supportsType(DataType::REAL,nDefaultType))
1435 break;
1436 [[fallthrough]];
1437 case DataType::DATE:
1438 case DataType::TIME:
1439 if( DataType::DATE == _pType->nType || DataType::TIME == _pType->nType )
1440 {
1441 if(supportsType(DataType::TIMESTAMP,nDefaultType))
1442 break;
1443 }
1444 [[fallthrough]];
1445 case DataType::TIMESTAMP:
1446 case DataType::REAL:
1447 case DataType::BIGINT:
1448 if ( supportsType(DataType::DOUBLE,nDefaultType) )
1449 break;
1450 [[fallthrough]];
1451 case DataType::DOUBLE:
1452 if ( supportsType(DataType::NUMERIC,nDefaultType) )
1453 break;
1454 [[fallthrough]];
1455 case DataType::NUMERIC:
1456 supportsType(DataType::DECIMAL,nDefaultType);
1457 break;
1458 case DataType::DECIMAL:
1459 if ( supportsType(DataType::NUMERIC,nDefaultType) )
1460 break;
1461 if ( supportsType(DataType::DOUBLE,nDefaultType) )
1462 break;
1463 break;
1464 case DataType::VARCHAR:
1465 if ( supportsType(DataType::LONGVARCHAR,nDefaultType) )
1466 break;
1467 break;
1468 case DataType::LONGVARCHAR:
1469 if ( supportsType(DataType::CLOB,nDefaultType) )
1470 break;
1471 break;
1472 case DataType::BINARY:
1473 if ( supportsType(DataType::VARBINARY,nDefaultType) )
1474 break;
1475 break;
1476 case DataType::VARBINARY:
1477 if ( supportsType(DataType::LONGVARBINARY,nDefaultType) )
1478 break;
1479 break;
1480 case DataType::LONGVARBINARY:
1481 if ( supportsType(DataType::BLOB,nDefaultType) )
1482 break;
1483 if ( supportsType(DataType::LONGVARCHAR,nDefaultType) )
1484 break;
1485 if ( supportsType(DataType::CLOB,nDefaultType) )
1486 break;
1487 break;
1488 default:
1489 nDefaultType = DataType::VARCHAR;
1490 }
1491 pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,nDefaultType,_pType->aTypeName,_pType->aCreateParams,_pType->nPrecision,_pType->nMaximumScale,_pType->bAutoIncrement,bForce);
1492 if ( !pType )
1493 {
1494 _bNotConvert = false;
1495 pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,DataType::VARCHAR,_pType->aTypeName,"x",50,0,false,bForce);
1496 if ( !pType )
1497 pType = m_pTypeInfo;
1498 }
1499 else if ( bForce )
1500 _bNotConvert = false;
1501 }
1502 return pType;
1503}
1504
1505OUString OCopyTableWizard::createUniqueName(const OUString& _sName)
1506{
1507 OUString sName = _sName;
1509 if ( aColumnNames.hasElements() )
1510 sName = ::dbtools::createUniqueName( aColumnNames, sName, false );
1511 else
1512 {
1513 if ( m_vSourceColumns.find(sName) != m_vSourceColumns.end())
1514 {
1515 sal_Int32 nPos = 0;
1516 while(m_vSourceColumns.find(sName) != m_vSourceColumns.end())
1517 {
1518 sName = _sName + OUString::number(++nPos);
1519 }
1520 }
1521 }
1522 return sName;
1523}
1524
1525void OCopyTableWizard::showColumnTypeNotSupported(std::u16string_view _rColumnName)
1526{
1527 OUString sMessage( DBA_RES( STR_UNKNOWN_TYPE_FOUND ) );
1528 sMessage = sMessage.replaceFirst("#1",_rColumnName);
1530}
1531
1532void OCopyTableWizard::showError(const OUString& _sErrorMessage)
1533{
1534 SQLExceptionInfo aInfo(_sErrorMessage);
1535 showError(aInfo.get());
1536}
1537
1538void OCopyTableWizard::showError(const Any& _aError)
1539{
1540 if ( _aError.hasValue() && m_xInteractionHandler.is() )
1541 {
1542 try
1543 {
1544 ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( _aError ) );
1545 m_xInteractionHandler->handle( xRequest );
1546 }
1547 catch( const Exception& )
1548 {
1549 DBG_UNHANDLED_EXCEPTION("dbaccess");
1550 }
1551 }
1552}
1553
1554/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define COLUMN_POSITION_NOT_FOUND
Definition: DExport.hxx:48
OptionalString sSchema
OptionalString sCatalog
OptionalString sComposedName
OptionalString sName
PropertiesInfo aProperties
#define MAX_PAGES
Definition: WCopyTable.cxx:75
OUString m_sTableName
interface to an object to copy to another DB, using the OCopyTableWizard
Definition: WCopyTable.hxx:101
virtual css::uno::Sequence< OUString > getPrimaryKeyColumnNames() const =0
retrieves the names of the primary keys of the to-be-copied object
virtual css::uno::Sequence< OUString > getColumnNames() const =0
retrieves the column names of the to-be-copied object
virtual void copyFilterAndSortingTo(const css::uno::Reference< css::sdbc::XConnection > &_xConnection, const css::uno::Reference< css::beans::XPropertySet > &_rxObject) const =0
copies the filter and sorting
virtual OUString getSelectStatement() const =0
returns the SELECT statement which can be used to retrieve the data of the to-be-copied object
virtual OFieldDescription * createFieldDescription(const OUString &_rColumnName) const =0
creates a OFieldDescription for the given column of the to-be-copied object
virtual void copyUISettingsTo(const css::uno::Reference< css::beans::XPropertySet > &_rxObject) const =0
copies the UI settings of the object to the given target object.
::utl::SharedUNOComponent< css::sdbc::XPreparedStatement > const & impl_ensureStatement_throw()
Definition: WCopyTable.cxx:322
css::uno::Reference< css::sdbc::XConnection > m_xConnection
Definition: WCopyTable.hxx:174
NamedTableCopySource(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, OUString _sTableName)
Definition: WCopyTable.cxx:253
virtual void copyFilterAndSortingTo(const css::uno::Reference< css::sdbc::XConnection > &_xConnection, const css::uno::Reference< css::beans::XPropertySet > &_rxObject) const override
copies the filter and sorting
Definition: WCopyTable.cxx:291
std::vector< OFieldDescription > m_aColumnInfo
Definition: WCopyTable.hxx:180
virtual css::uno::Sequence< OUString > getColumnNames() const override
retrieves the column names of the to-be-copied object
Definition: WCopyTable.cxx:329
virtual OFieldDescription * createFieldDescription(const OUString &_rColumnName) const override
creates a OFieldDescription for the given column of the to-be-copied object
Definition: WCopyTable.cxx:361
virtual ::utl::SharedUNOComponent< css::sdbc::XPreparedStatement > getPreparedSelectStatement() const override
returns the prepared statement which can be used to retrieve the data of the to-be-copied object
Definition: WCopyTable.cxx:376
::utl::SharedUNOComponent< css::sdbc::XPreparedStatement > m_xStatement
Definition: WCopyTable.hxx:181
virtual css::uno::Sequence< OUString > getPrimaryKeyColumnNames() const override
retrieves the names of the primary keys of the to-be-copied object
Definition: WCopyTable.cxx:338
virtual void copyUISettingsTo(const css::uno::Reference< css::beans::XPropertySet > &_rxObject) const override
copies the UI settings of the object to the given target object.
Definition: WCopyTable.cxx:286
virtual bool isView() const override
determines whether the object is a view
Definition: WCopyTable.cxx:267
virtual OUString getSelectStatement() const override
returns the SELECT statement which can be used to retrieve the data of the to-be-copied object
Definition: WCopyTable.cxx:370
virtual OUString getQualifiedObjectName() const override
retrieves the fully qualified name of the object to copy
Definition: WCopyTable.cxx:262
css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData
Definition: WCopyTable.hxx:175
OTypeInfoMap m_aTypeInfo
Definition: WCopyTable.hxx:236
ODatabaseExport::TColumnVector m_aDestVec
Definition: WCopyTable.hxx:232
const css::uno::Reference< css::uno::XComponentContext > & GetComponentContext() const
Definition: WCopyTable.hxx:375
virtual bool DeactivatePage() override
Definition: WCopyTable.cxx:944
static void appendKey(css::uno::Reference< css::sdbcx::XKeysSupplier > const &_rxSup, const ODatabaseExport::TColumnVector *_pVec)
const ICopyTableSourceObject & m_rSourceObject
Definition: WCopyTable.hxx:247
virtual ~OCopyTableWizard() override
Definition: WCopyTable.cxx:663
bool supportsPrimaryKey() const
Definition: WCopyTable.hxx:357
void EnableNextButton(bool bEnable)
Definition: WCopyTable.cxx:939
void replaceColumn(sal_Int32 _nPos, OFieldDescription *_pField, const OUString &_sOldName)
replaces a field description with another one.
Definition: WCopyTable.cxx:974
void AddWizardPage(std::unique_ptr< OWizardPage > xPage)
Definition: WCopyTable.cxx:950
void clearDestColumns()
clears the dest vectors
static void appendColumns(css::uno::Reference< css::sdbcx::XColumnsSupplier > const &_rxColSup, const ODatabaseExport::TColumnVector *_pVec, bool _bKeyColumns=false)
sal_Int16 getOperation() const
Definition: WCopyTable.hxx:394
void setOperation(const sal_Int16 _nOperation)
virtual void ActivatePage() override
Definition: WCopyTable.cxx:901
sal_uInt16 GetCurLevel() const
Definition: WCopyTable.hxx:292
bool supportsType(sal_Int32 _nDataType, sal_Int32 &_rNewDataType)
TOTypeInfoSP m_pTypeInfo
Definition: WCopyTable.hxx:262
const ODatabaseExport::TColumnVector & getDestVector() const
Definition: WCopyTable.hxx:380
ODatabaseExport::TPositions m_vColumnPositions
Definition: WCopyTable.hxx:242
std::vector< sal_Int32 > m_vColumnTypes
Definition: WCopyTable.hxx:243
ODatabaseExport::TColumnVector m_vSourceVec
Definition: WCopyTable.hxx:234
css::uno::Reference< css::beans::XPropertySet > getTable() const
css::uno::Reference< css::beans::XPropertySet > returnTable()
OTypeInfoMap m_aDestTypeInfo
Definition: WCopyTable.hxx:238
void insertColumn(sal_Int32 _nPos, OFieldDescription *_pField)
Definition: WCopyTable.cxx:956
css::uno::Reference< css::beans::XPropertySet > createView() const
OUString convertColumnName(const TColumnFindFunctor &_rCmpFunctor, const OUString &_sColumnName, std::u16string_view _sExtraChars, sal_Int32 _nMaxNameLen)
TNameMapping m_mNameMapping
Definition: WCopyTable.hxx:240
OUString createUniqueName(const OUString &_sName)
void showColumnTypeNotSupported(std::u16string_view _rColumnName)
css::uno::Reference< css::beans::XPropertySet > createTable()
bool shouldCreatePrimaryKey() const
returns whether a primary key should be created in the target database
Definition: WCopyTable.hxx:353
bool supportsViews() const
Definition: WCopyTable.hxx:360
css::uno::Reference< css::task::XInteractionHandler > m_xInteractionHandler
Definition: WCopyTable.hxx:251
void loadData(const ICopyTableSourceObject &_rSourceObject, ODatabaseExport::TColumns &_rColumns, ODatabaseExport::TColumnVector &_rColVector)
Definition: WCopyTable.cxx:986
std::vector< OTypeInfoMap::iterator > m_aTypeInfoIndex
Definition: WCopyTable.hxx:237
css::uno::Reference< css::sdbc::XConnection > m_xDestConnection
Definition: WCopyTable.hxx:245
TOTypeInfoSP convertType(const TOTypeInfoSP &_pType, bool &_bNotConvert)
void removeColumnNameFromNameMap(const OUString &_sName)
bool CheckColumns(sal_Int32 &_rnBreakPos)
Definition: WCopyTable.cxx:711
ODatabaseExport::TColumns m_vSourceColumns
Definition: WCopyTable.hxx:233
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: WCopyTable.hxx:250
void showError(const OUString &_sErrorMessage)
sal_Int32 getMaxColumnNameLength() const
OCopyTableWizard(weld::Window *pParent, const OUString &_rDefaultName, sal_Int16 _nOperation, const ICopyTableSourceObject &_rSourceObject, const css::uno::Reference< css::sdbc::XConnection > &_xSourceConnection, const css::uno::Reference< css::sdbc::XConnection > &_xConnection, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::task::XInteractionHandler > &_xInteractionHandler)
std::vector< OTypeInfoMap::iterator > m_aDestTypeInfoIndex
Definition: WCopyTable.hxx:239
void setCreatePrimaryKey(bool _bDoCreate, const OUString &_rSuggestedName)
Definition: WCopyTable.cxx:889
ODatabaseExport::TColumns m_vDestColumns
Definition: WCopyTable.hxx:231
weld::Container * CreatePageContainer()
Definition: WCopyTable.cxx:579
void setCreatePrimaryKey(bool _bDoCreate, const OUString &_rSuggestedName)
Definition: WCPage.cxx:284
std::map< OUString, OFieldDescription *, ::comphelper::UStringMixLess > TColumns
Definition: DExport.hxx:57
std::vector< TColumns::const_iterator > TColumnVector
Definition: DExport.hxx:58
void SetTypeValue(sal_Int32 _nType)
void SetHelpText(const OUString &_sHelptext)
void SetTypeName(const OUString &_sTypeName)
void SetPrecision(sal_Int32 _rPrecision)
void SetIsNullable(sal_Int32 _rIsNullable)
void SetPrimaryKey(bool _bPKey)
void SetType(const TOTypeInfoSP &_pType)
void SetAutoIncrement(bool _bAuto)
void SetName(const OUString &_rName)
void FillFromTypeInfo(const TOTypeInfoSP &_pType, bool _bForce, bool _bReset)
sal_Int32 GetPrecision() const
void SetCurrency(bool _bIsCurrency)
void SetScale(sal_Int32 _rScale)
void copyColumnSettingsTo(const css::uno::Reference< css::beans::XPropertySet > &_rxColumn)
copies the content of the field description into the column
virtual css::uno::Sequence< OUString > getColumnNames() const override
retrieves the column names of the to-be-copied object
Definition: WCopyTable.cxx:187
virtual OUString getQualifiedObjectName() const override
retrieves the fully qualified name of the object to copy
Definition: WCopyTable.cxx:104
virtual bool isView() const override
determines whether the object is a view
Definition: WCopyTable.cxx:115
virtual void copyFilterAndSortingTo(const css::uno::Reference< css::sdbc::XConnection > &_xConnection, const css::uno::Reference< css::beans::XPropertySet > &_rxObject) const override
copies the filter and sorting
Definition: WCopyTable.cxx:146
css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData
Definition: WCopyTable.hxx:144
virtual OUString getSelectStatement() const override
returns the SELECT statement which can be used to retrieve the data of the to-be-copied object
Definition: WCopyTable.cxx:207
css::uno::Reference< css::sdbc::XConnection > m_xConnection
Definition: WCopyTable.hxx:143
css::uno::Reference< css::container::XNameAccess > m_xObjectColumns
Definition: WCopyTable.hxx:147
css::uno::Reference< css::beans::XPropertySetInfo > m_xObjectPSI
Definition: WCopyTable.hxx:146
virtual ::utl::SharedUNOComponent< css::sdbc::XPreparedStatement > getPreparedSelectStatement() const override
returns the prepared statement which can be used to retrieve the data of the to-be-copied object
Definition: WCopyTable.cxx:243
virtual css::uno::Sequence< OUString > getPrimaryKeyColumnNames() const override
retrieves the names of the primary keys of the to-be-copied object
Definition: WCopyTable.cxx:192
virtual OFieldDescription * createFieldDescription(const OUString &_rColumnName) const override
creates a OFieldDescription for the given column of the to-be-copied object
Definition: WCopyTable.cxx:201
virtual void copyUISettingsTo(const css::uno::Reference< css::beans::XPropertySet > &_rxObject) const override
copies the UI settings of the object to the given target object.
Definition: WCopyTable.cxx:134
css::uno::Reference< css::beans::XPropertySet > m_xObject
Definition: WCopyTable.hxx:145
const css::uno::Any & get() const
bool set(const css::uno::BaseReference &_rRef, css::uno::UnoReference_Query _query)
std::unique_ptr< weld::Button > m_xNextPage
std::unique_ptr< weld::Button > m_xCancel
std::unique_ptr< weld::Button > m_xPrevPage
std::unique_ptr< weld::Button > m_xHelp
std::unique_ptr< weld::Button > m_xFinish
void AddPage(std::unique_ptr< BuilderPage > xPage)
BuilderPage * GetPage(WizardTypes::WizardState eState) const
std::unique_ptr< weld::Assistant > m_xAssistant
Reference< XComponentContext > m_xContext
sal_Int16 m_nOperation
SharedConnection m_xDestConnection
#define DBA_RES(id)
Reference< XInteractionHandler2 > m_xInteractionHandler
Definition: dbwizsetup.cxx:869
#define DBG_UNHANDLED_EXCEPTION(...)
OUString m_sName
float u
const char sQuote[]
Reference< XColumn > xColumn
bool bAutoIncrement
sal_uInt16 nPos
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
@ Exception
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
void fillTypeInfo(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, std::u16string_view _rsTypeNames, OTypeInfoMap &_rTypeInfoMap, std::vector< OTypeInfoMap::iterator > &_rTypeInfoIters)
fills a map and a vector with localized type names
css::uno::Reference< css::beans::XPropertySet > createView(const OUString &_sName, const css::uno::Reference< css::sdbc::XConnection > &_xConnection, const css::uno::Reference< css::beans::XPropertySet > &_xSourceObject)
creates a new view from a query or table
const sal_uInt16 TYPE_OTHER
Definition: TypeInfo.hxx:60
std::unique_ptr< OWizTypeSelect >(* TypeSelectionPageFactory)(weld::Container *, OCopyTableWizard *, SvStream &)
TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap &_rTypeInfo)
query for a type info which can be used to create a primary key column
Definition: UITools.cxx:1049
css::uno::Reference< css::util::XNumberFormatter > getNumberFormatter(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
creates a number formatter
void setColumnProperties(const css::uno::Reference< css::beans::XPropertySet > &_rxColumn, const OFieldDescription *_pFieldDesc)
TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap &_rTypeInfo, sal_Int32 _nType, const OUString &_sTypeName, const OUString &_sCreateParams, sal_Int32 _nPrecision, sal_Int32 _nScale, bool _bAutoIncrement, bool &_brForceToType)
return the most suitable typeinfo for a requested type
Definition: UITools.cxx:263
std::shared_ptr< OTypeInfo > TOTypeInfoSP
Definition: TypeInfo.hxx:99
bool isSQL92CheckEnabled(const css::uno::Reference< css::sdbc::XConnection > &_xConnection)
check if SQL92 name checking is enabled
bool appendToFilter(const css::uno::Reference< css::sdbc::XConnection > &xConnection, const OUString &rName, const css::uno::Reference< css::uno::XComponentContext > &rxContext, weld::Window *pParent)
append a name to tablefilter of a datasource
OUString createUniqueName(const Sequence< OUString > &_rNames, const OUString &_rBaseName, bool _bStartWithNumber)
Reference< XNameAccess > getPrimaryKeyColumns_throw(const Any &i_aTable)
int i
constexpr OUStringLiteral first
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
Reference< XConnection > m_xConnection
Definition: objectnames.cxx:79
QPRO_FUNC_TYPE nType
OUString sMessage
Definition: sqlmessage.cxx:159
constexpr OUStringLiteral PROPERTY_COMMAND(u"Command")
constexpr OUStringLiteral PROPERTY_TEXTCOLOR(u"TextColor")
constexpr OUStringLiteral PROPERTY_SCHEMANAME(u"SchemaName")
constexpr OUStringLiteral PROPERTY_APPLYFILTER(u"ApplyFilter")
constexpr OUStringLiteral PROPERTY_TEXTEMPHASIS(u"FontEmphasisMark")
constexpr OUStringLiteral PROPERTY_FILTER(u"Filter")
constexpr OUStringLiteral PROPERTY_FONT(u"FontDescriptor")
constexpr OUStringLiteral PROPERTY_CATALOGNAME(u"CatalogName")
constexpr OUStringLiteral PROPERTY_TEXTLINECOLOR(u"TextLineColor")
constexpr OUStringLiteral PROPERTY_TYPE(u"Type")
constexpr OUStringLiteral PROPERTY_NAME(u"Name")
constexpr OUStringLiteral PROPERTY_TEXTRELIEF(u"FontRelief")
constexpr OUStringLiteral PROPERTY_ROW_HEIGHT(u"RowHeight")
constexpr OUStringLiteral PROPERTY_ORDER(u"Order")
RET_OK
sal_Int32 _nPos