22#include <core_resource.hxx>
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>
54#include <rtl/ustrbuf.hxx>
61using namespace ::
dbaui;
73namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
79 void clearColumns(ODatabaseExport::TColumns& _rColumns, ODatabaseExport::TColumnVector& _rColumnsVec)
81 for (
auto const& column : _rColumns)
90ICopyTableSourceObject::~ICopyTableSourceObject()
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 )
117 bool bIsView =
false;
122 OUString sObjectType;
124 bIsView = sObjectType ==
"VIEW";
136 const OUString aCopyProperties[] = {
139 for (
const auto & aCopyProperty : aCopyProperties)
142 _rxObject->setPropertyValue( aCopyProperty,
m_xObject->getPropertyValue( aCopyProperty ) );
150 ,std::pair< OUString, OUString >(
PROPERTY_ORDER,OUString(
" ORDER BY "))
156 const OUString sTargetName = ::dbtools::composeTableNameForSelect(_xConnection,_rxObject);
157 const OUString sTargetNameTemp = sTargetName +
".";
159 OUStringBuffer sStatement =
"SELECT * FROM " + sTargetName +
" WHERE 0=1";
161 for (
const std::pair<OUString,OUString> & aProperty :
aProperties)
163 if (
m_xObjectPSI->hasPropertyByName( aProperty.first ) )
166 m_xObject->getPropertyValue( aProperty.first ) >>= sFilter;
167 if ( !sFilter.isEmpty() )
169 sStatement.append(aProperty.second);
170 sFilter = sFilter.replaceFirst(sSourceName,sTargetNameTemp);
171 _rxObject->setPropertyValue( aProperty.first,
Any(sFilter) );
172 sStatement.append(sFilter);
177 _xConnection->createStatement()->executeQuery(sStatement.makeStringAndClear());
196 if ( xPrimaryKeyColumns.is() )
197 aKeyColNames = xPrimaryKeyColumns->getElementNames();
209 OUString sSelectStatement;
216 OUStringBuffer aSQL(
"SELECT " );
223 const OUString* pColumnName = aColumnNames.getConstArray();
224 const OUString* pEnd = pColumnName + aColumnNames.getLength();
225 for ( ; pColumnName != pEnd; )
227 aSQL.append( ::dbtools::quoteName(
sQuote, *pColumnName++ ) );
229 if ( pColumnName == pEnd )
237 sSelectStatement = aSQL.makeStringAndClear();
240 return sSelectStatement;
255 ,m_xMetaData( _rxConnection->getMetaData(), UNO_SET_THROW )
275 OSL_VERIFY( xTableDesc->next() );
276 sTableType = xTableDescRow->getString( 4 );
277 OSL_ENSURE( !xTableDescRow->wasNull(),
"NamedTableCopySource::isView: invalid table type!" );
283 return sTableType ==
"VIEW";
303 sal_Int32 nColCount( xStatementMeta->getColumnCount() );
304 for ( sal_Int32
i = 1;
i <= nColCount; ++
i )
308 aDesc.
SetName( xStatementMeta->getColumnName(
i ) );
309 aDesc.
SetHelpText( xStatementMeta->getColumnLabel(
i ) );
311 aDesc.
SetTypeName( xStatementMeta->getColumnTypeName(
i ) );
313 aDesc.
SetScale( xStatementMeta->getScale(
i ) );
333 [](
const auto& elem) { return elem.GetName(); });
346 while ( xPKDesc->next() )
348 sal_Int32 len( aPKColNames.getLength() );
349 aPKColNames.realloc( len + 1 );
350 aPKColNames.getArray()[ len ] = xPKDescRow->getString( 4 );
364 if ( elem.GetName() == _rColumnName )
372 return "SELECT * FROM " +
387 DummyCopySource() { }
389 static const DummyCopySource& Instance();
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;
408const DummyCopySource& DummyCopySource::Instance()
410 static DummyCopySource s_aTheInstance;
411 return s_aTheInstance;
414OUString DummyCopySource::getQualifiedObjectName()
const
416 SAL_WARN(
"dbaccess.ui",
"DummyCopySource::getQualifiedObjectName: not to be called!" );
420bool DummyCopySource::isView()
const
422 SAL_WARN(
"dbaccess.ui",
"DummyCopySource::isView: not to be called!" );
426void DummyCopySource::copyUISettingsTo(
const Reference< XPropertySet >& )
const
431void DummyCopySource::copyFilterAndSortingTo(
const Reference< XConnection >& ,
const Reference< XPropertySet >& )
const
435Sequence< OUString > DummyCopySource::getColumnNames()
const
437 return Sequence< OUString >();
440Sequence< OUString > DummyCopySource::getPrimaryKeyColumnNames()
const
442 SAL_WARN(
"dbaccess.ui",
"DummyCopySource::getPrimaryKeyColumnNames: not to be called!" );
443 return Sequence< OUString >();
446OFieldDescription* DummyCopySource::createFieldDescription(
const OUString& )
const
448 SAL_WARN(
"dbaccess.ui",
"DummyCopySource::createFieldDescription: not to be called!" );
452OUString DummyCopySource::getSelectStatement()
const
454 SAL_WARN(
"dbaccess.ui",
"DummyCopySource::getSelectStatement: not to be called!" );
460 SAL_WARN(
"dbaccess.ui",
"DummyCopySource::getPreparedSelectStatement: not to be called!" );
461 return ::utl::SharedUNOComponent< XPreparedStatement >();
466 bool lcl_canCreateViewFor_nothrow(
const Reference< XConnection >& _rxConnection )
468 Reference< XViewsSupplier > xSup( _rxConnection, UNO_QUERY );
469 Reference< XDataDescriptorFactory > xViewFac;
471 xViewFac.set( xSup->getViews(), UNO_QUERY );
472 return xViewFac.is();
475 bool lcl_sameConnection_throw(
const Reference< XConnection >& _rxLHS,
const Reference< XConnection >& _rxRHS )
477 Reference< XDatabaseMetaData > xMetaLHS( _rxLHS->getMetaData(), UNO_SET_THROW );
478 Reference< XDatabaseMetaData > xMetaRHS( _rxRHS->getMetaData(), UNO_SET_THROW );
479 return xMetaLHS->getURL() == xMetaRHS->getURL();
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())
491 , m_rSourceObject( _rSourceObject )
495 , m_sTypeNames(
DBA_RES(STR_TABLEDESIGN_DBFIELDTYPES))
497 , m_bDeleteSourceColumns(true)
498 , m_bInterConnectionCopy( _xSourceConnection != _xConnection )
501 , m_ePressed( WIZARD_NONE )
502 , m_bCreatePrimaryKeyColumn(false)
503 , m_bUseHeaderLine(false)
508 OUString sInitialTableName( _rDefaultName );
511 m_sSourceName = m_rSourceObject.getQualifiedObjectName();
512 OSL_ENSURE( !m_sSourceName.isEmpty(),
"OCopyTableWizard::OCopyTableWizard: unable to retrieve the source object's name!" );
514 if ( sInitialTableName.isEmpty() )
515 sInitialTableName = m_sSourceName;
522 m_sName = ::dbtools::createUniqueName( xSup->getTables(), sInitialTableName,
false );
528 catch (
const Exception& )
535 loadData( m_rSourceObject, m_vSourceColumns, m_vSourceVec );
537 bool bAllowViews =
true;
539 if ( m_rSourceObject.isView() )
548 if ( m_bInterConnectionCopy )
550 Reference< XDatabaseMetaData > xSrcMeta = _xSourceConnection->getMetaData();
554 ::dbtools::qualifiedNameComponents( xSrcMeta,
559 ::dbtools::EComposeRule::InDataManipulation);
564 std::unique_ptr<OCopyTable> xPage1(
new OCopyTable(CreatePageContainer(),
this));
565 xPage1->disallowUseHeaderLine();
567 xPage1->disallowViews();
568 xPage1->setCreateStyleAction();
569 AddWizardPage(std::move(xPage1));
571 AddWizardPage( std::make_unique<OWizNameMatching>(CreatePageContainer(),
this));
572 AddWizardPage( std::make_unique<OWizColumnSelect>(CreatePageContainer(),
this));
573 AddWizardPage( std::make_unique<OWizNormalExtend>(CreatePageContainer(),
this));
576 m_xAssistant->set_current_page(0);
583 return pPageContainer;
591 , m_vSourceColumns(
std::move(_rSourceColumns))
592 , m_mNameMapping(_xConnection->getMetaData().is() && _xConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers())
594 , m_rSourceObject( DummyCopySource::Instance() )
595 , m_xFormatter(_xFormatter)
597 , m_sTypeNames(
DBA_RES(STR_TABLEDESIGN_DBFIELDTYPES))
599 , m_bDeleteSourceColumns(false)
600 , m_bInterConnectionCopy( false )
603 , m_ePressed( WIZARD_NONE )
604 , m_bCreatePrimaryKeyColumn(false)
605 , m_bUseHeaderLine(false)
608 for (
auto const& sourceCol : _rSourceColVec)
619 xPage1->disallowViews();
620 xPage1->setCreateStyleAction();
679 m_ePressed = WIZARD_PREV;
682 if ( getOperation() != CopyTableOperation::AppendData )
684 if(GetCurLevel() == 2)
685 ShowPage(GetCurLevel()-2);
696 m_ePressed = WIZARD_NEXT;
699 if ( getOperation() != CopyTableOperation::AppendData )
701 if(GetCurLevel() == 0)
702 ShowPage(GetCurLevel()+2);
717 OSL_ENSURE(
m_xDestConnection.is(),
"OCopyTableWizard::CheckColumns: No connection!" );
736 elem.second->SetPrimaryKey(
false);
749 if ( bContainsColumns )
757 ODatabaseExport::TColumnVector::const_iterator aFind = std::find(
m_aDestVec.begin(),
m_aDestVec.end(),aDestIter);
773 OUString sExtraChars = xMetaData->getExtraNameCharacters();
801 m_ePressed = WIZARD_FINISH;
802 bool bFinish = DeactivatePage();
808 switch(getOperation())
810 case CopyTableOperation::CopyDefinitionAndData:
811 case CopyTableOperation::CopyDefinitionOnly:
813 bool bOnFirstPage = GetCurLevel() == 0;
819 m_mNameMapping.clear();
821 sal_Int32 nBreakPos = 0;
822 bool bCheckOk = CheckColumns(nBreakPos);
823 if ( bOnFirstPage && !bCheckOk )
825 showColumnTypeNotSupported(m_vSourceVec[nBreakPos-1]->
first);
826 OWizTypeSelect* pPage =
static_cast<OWizTypeSelect*
>(GetPage(3));
829 m_mNameMapping.clear();
830 pPage->setDisplayRow(nBreakPos);
837 if ( supportsPrimaryKey() )
839 bool noPrimaryKey = std::none_of(m_vDestColumns.begin(),m_vDestColumns.end(),
840 [] (
const ODatabaseExport::TColumns::value_type& tCol) { return tCol.second->IsPrimaryKey(); });
844 OUString sMsg(
DBA_RES(STR_TABLEDESIGN_NO_PRIM_KEY));
846 aError.Message = sMsg;
849 xRequest->addContinuation( xYes );
850 xRequest->addContinuation( new ::comphelper::OInteractionDisapprove );
852 xRequest->addContinuation( xAbort );
856 if ( xYes->wasSelected() )
858 OCopyTable* pPage =
static_cast<OCopyTable*
>(GetPage(0));
859 m_bCreatePrimaryKeyColumn =
true;
860 m_aKeyName = pPage->GetKeyName();
861 if ( m_aKeyName.isEmpty() )
864 sal_Int32 nBreakPos2 = 0;
865 CheckColumns(nBreakPos2);
867 else if ( xAbort->wasSelected() )
877 case CopyTableOperation::AppendData:
878 case CopyTableOperation::CreateAsView:
882 SAL_WARN(
"dbaccess.ui",
"OCopyTableWizard::ImplOKHdl: invalid creation style!");
886 m_xAssistant->response(
RET_OK);
892 if ( !_rSuggestedName.isEmpty() )
896 OSL_ENSURE( pSettingsPage,
"OCopyTableWizard::setCreatePrimaryKey: page should have been added in the ctor!" );
906 bool bFirstTime = pCurrent->IsFirstTime();
947 return pPage && pPage->LeavePage();
958 OSL_ENSURE(_pField,
"FieldDescrioption is null!");
965 delete aFind->second;
976 OSL_ENSURE(_pField,
"FieldDescrioption is null!");
988 for (
auto const& column : _rColumns)
989 delete column.second;
995 static constexpr OUStringLiteral sCreateParam(
u"x");
1001 const OUString* pColumn = aColumns.getConstArray();
1002 const OUString* pColumnEnd = pColumn + aColumns.getLength();
1004 for ( ; pColumn != pColumnEnd; ++pColumn )
1008 OSL_ENSURE( pActFieldDescr,
"OCopyTableWizard::loadData: illegal field description!" );
1009 if ( !pActFieldDescr )
1013 sal_Int32 nScale = pActFieldDescr->
GetScale();
1016 OUString sTypeName = pActFieldDescr->
GetTypeName();
1025 _rColVector.emplace_back(_rColumns.emplace(pActFieldDescr->
GetName(),pActFieldDescr).first);
1030 const OUString* pKeyColName = aPrimaryKeyColumns.getConstArray();
1031 const OUString* pKeyColEnd = pKeyColName + aPrimaryKeyColumns.getLength();
1033 for( ; pKeyColName != pKeyColEnd; ++pKeyColName )
1035 ODatabaseExport::TColumns::const_iterator keyPos = _rColumns.find( *pKeyColName );
1036 if ( keyPos != _rColumns.end() )
1038 keyPos->second->SetPrimaryKey(
true );
1039 keyPos->second->SetIsNullable( ColumnValue::NO_NULLS );
1054 OSL_ENSURE(_rxColSup.is(),
"No columns supplier");
1058 OSL_ENSURE(xColumns.is(),
"No columns");
1062 OSL_ENSURE(xAppend.is(),
"No XAppend Interface!");
1064 for (
auto const& elem : *_pVec)
1072 xColumn = xColumnFactory->createDataDescriptor();
1080 xAppend->appendByDescriptor(
xColumn);
1083 if(xColumns->hasByName(pField->
GetName()))
1086 OSL_ENSURE(
xColumn.is(),
"OCopyTableWizard::appendColumns: Column is NULL!");
1092 SAL_WARN(
"dbaccess.ui",
"OCopyTableWizard::appendColumns: invalid field name!");
1103 OSL_ENSURE(_rxSup.is(),
"No XKeysSupplier!");
1105 OSL_ENSURE(xKeyFactory.is(),
"No XDataDescriptorFactory Interface!");
1106 if ( !xKeyFactory.is() )
1109 OSL_ENSURE(xAppend.is(),
"No XAppend Interface!");
1112 OSL_ENSURE(xKey.is(),
"Key is null!");
1120 if(xColumns.is() && xColumns->getElementNames().hasElements())
1121 xAppend->appendByDescriptor(xKey);
1129 OSL_ENSURE( !sCommand.isEmpty(),
"OCopyTableWizard::createView: no statement in the source object!" );
1137 if (
getOperation() == CopyTableOperation::AppendData )
1150 xTables = xSup->getTables();
1151 if(xTables.is() && xTables->hasByName(
m_sName))
1152 xTables->getByName(
m_sName) >>= xTable;
1164 xTables = xSup->getTables();
1166 OSL_ENSURE(xFact.is(),
"No XDataDescriptorFactory available!");
1170 xTable = xFact->createDataDescriptor();
1171 OSL_ENSURE(xTable.is(),
"Could not create a new object!");
1177 ::dbtools::qualifiedNameComponents(xMetaData,
1182 ::dbtools::EComposeRule::InDataManipulation);
1184 if (
sCatalog.isEmpty() && xMetaData->supportsCatalogsInTableDefinitions() )
1189 if (
sSchema.isEmpty() && xMetaData->supportsSchemasInTableDefinitions() )
1193 sSchema = xMetaData->getUserName();
1195 if(xMetaData->getDatabaseProductName() ==
"MySQL")
1219 xAppend->appendByDescriptor(xTable);
1223 if(xTables->hasByName(
m_sName))
1224 xTables->getByName(
m_sName) >>= xTable;
1228 ::dbtools::composeTableName(
m_xDestConnection->getMetaData(), xTable, ::dbtools::EComposeRule::InDataManipulation,
false ) );
1240 xSuppDestinationColumns.set( xTable, UNO_QUERY_THROW );
1251 const OUString* pIter =
aSeq.getConstArray();
1252 const OUString* pEnd = pIter +
aSeq.getLength();
1254 for(sal_Int32 nNewPos=1;pIter != pEnd;++pIter,++nNewPos)
1256 ODatabaseExport::TColumns::const_iterator aDestIter =
m_vDestColumns.find(*pIter);
1260 ODatabaseExport::TColumnVector::const_iterator aFind = std::find(
m_aDestVec.begin(),
m_aDestVec.end(),aDestIter);
1263 ODatabaseExport::TPositions::iterator aPosFind = std::find_if(
1266 [
nPos] (
const ODatabaseExport::TPositions::value_type& tPos) {
1267 return tPos.first == nPos;
1273 aPosFind->second = nNewPos;
1275 "Invalid index for vector!" );
1287 OSL_PRECOND( _rxConnection.is(),
"OCopyTableWizard::supportsPrimaryKey: invalid connection!" );
1288 if ( !_rxConnection.is() )
1292 return aMetaData.supportsPrimaryKeys();
1297 OSL_PRECOND( _rxConnection.is(),
"OCopyTableWizard::supportsViews: invalid connection!" );
1298 if ( !_rxConnection.is() )
1301 bool bSupportsViews(
false );
1304 Reference< XDatabaseMetaData > xMetaData( _rxConnection->getMetaData(), UNO_SET_THROW );
1305 Reference< XViewsSupplier > xViewSups( _rxConnection, UNO_QUERY );
1306 bSupportsViews = xViewSups.is();
1307 if ( !bSupportsViews )
1311 Reference< XResultSet > xRs( xMetaData->getTableTypes(), UNO_SET_THROW );
1312 Reference< XRow > xRow( xRs, UNO_QUERY_THROW );
1313 while ( xRs->next() )
1315 OUString sValue = xRow->getString( 1 );
1316 if ( !xRow->wasNull() && sValue.equalsIgnoreAsciiCase(
"View") )
1318 bSupportsViews =
true;
1323 catch(
const SQLException& )
1329 catch(
const Exception& )
1333 return bSupportsViews;
1344 nLen = xMetaData->getMaxColumnNameLength();
1361 const OUString& _sColumnName,
1362 std::u16string_view _sExtraChars,
1363 sal_Int32 _nMaxNameLen)
1365 OUString sAlias = _sColumnName;
1367 sAlias = ::dbtools::convertName2SQLName(_sColumnName,_sExtraChars);
1368 if((_nMaxNameLen && sAlias.getLength() > _nMaxNameLen) || _rCmpFunctor(sAlias))
1370 sal_Int32 nDiff = 1;
1374 if(_nMaxNameLen && sAlias.getLength() >= _nMaxNameLen)
1375 sAlias = sAlias.copy(0,sAlias.getLength() - (sAlias.getLength()-_nMaxNameLen+nDiff));
1377 OUString
sName(sAlias);
1381 while(_rCmpFunctor(
sName))
1383 sName = sAlias + OUString::number(++
nPos);
1388 while(_nMaxNameLen && sAlias.getLength() > _nMaxNameLen);
1404 _rNewDataType = _nDataType;
1416 if ( !pType || bForce )
1418 sal_Int32 nDefaultType = DataType::VARCHAR;
1419 switch(_pType->nType)
1421 case DataType::TINYINT:
1425 case DataType::SMALLINT:
1429 case DataType::INTEGER:
1433 case DataType::FLOAT:
1437 case DataType::DATE:
1438 case DataType::TIME:
1439 if( DataType::DATE == _pType->nType || DataType::TIME == _pType->nType )
1445 case DataType::TIMESTAMP:
1446 case DataType::REAL:
1447 case DataType::BIGINT:
1451 case DataType::DOUBLE:
1455 case DataType::NUMERIC:
1458 case DataType::DECIMAL:
1464 case DataType::VARCHAR:
1465 if (
supportsType(DataType::LONGVARCHAR,nDefaultType) )
1468 case DataType::LONGVARCHAR:
1472 case DataType::BINARY:
1476 case DataType::VARBINARY:
1477 if (
supportsType(DataType::LONGVARBINARY,nDefaultType) )
1480 case DataType::LONGVARBINARY:
1483 if (
supportsType(DataType::LONGVARCHAR,nDefaultType) )
1489 nDefaultType = DataType::VARCHAR;
1494 _bNotConvert =
false;
1500 _bNotConvert =
false;
1507 OUString
sName = _sName;
1509 if ( aColumnNames.hasElements() )
1510 sName = ::dbtools::createUniqueName( aColumnNames,
sName,
false );
1518 sName = _sName + OUString::number(++
nPos);
1547 catch(
const Exception& )
#define COLUMN_POSITION_NOT_FOUND
OptionalString sComposedName
PropertiesInfo aProperties
interface to an object to copy to another DB, using the OCopyTableWizard
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()
css::uno::Reference< css::sdbc::XConnection > m_xConnection
void impl_ensureColumnInfo_throw()
NamedTableCopySource(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, OUString _sTableName)
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
std::vector< OFieldDescription > m_aColumnInfo
virtual css::uno::Sequence< OUString > getColumnNames() const override
retrieves the column names of the to-be-copied object
virtual OFieldDescription * createFieldDescription(const OUString &_rColumnName) const override
creates a OFieldDescription for the given column of the to-be-copied object
OUString m_sTableBareName
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
::utl::SharedUNOComponent< css::sdbc::XPreparedStatement > m_xStatement
virtual css::uno::Sequence< OUString > getPrimaryKeyColumnNames() const override
retrieves the names of the primary keys of the to-be-copied object
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.
virtual bool isView() const override
determines whether the object is a view
virtual OUString getSelectStatement() const override
returns the SELECT statement which can be used to retrieve the data of the to-be-copied object
virtual OUString getQualifiedObjectName() const override
retrieves the fully qualified name of the object to copy
css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData
ODatabaseExport::TColumnVector m_aDestVec
const css::uno::Reference< css::uno::XComponentContext > & GetComponentContext() const
virtual bool DeactivatePage() override
static void appendKey(css::uno::Reference< css::sdbcx::XKeysSupplier > const &_rxSup, const ODatabaseExport::TColumnVector *_pVec)
const ICopyTableSourceObject & m_rSourceObject
virtual ~OCopyTableWizard() override
bool supportsPrimaryKey() const
bool m_bCreatePrimaryKeyColumn
void EnableNextButton(bool bEnable)
void replaceColumn(sal_Int32 _nPos, OFieldDescription *_pField, const OUString &_sOldName)
replaces a field description with another one.
void AddWizardPage(std::unique_ptr< OWizardPage > xPage)
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
void setOperation(const sal_Int16 _nOperation)
virtual void ActivatePage() override
sal_uInt16 GetCurLevel() const
bool supportsType(sal_Int32 _nDataType, sal_Int32 &_rNewDataType)
const ODatabaseExport::TColumnVector & getDestVector() const
ODatabaseExport::TPositions m_vColumnPositions
std::vector< sal_Int32 > m_vColumnTypes
ODatabaseExport::TColumnVector m_vSourceVec
css::uno::Reference< css::beans::XPropertySet > getTable() const
css::uno::Reference< css::beans::XPropertySet > returnTable()
OTypeInfoMap m_aDestTypeInfo
void insertColumn(sal_Int32 _nPos, OFieldDescription *_pField)
bool m_bDeleteSourceColumns
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
OUString createUniqueName(const OUString &_sName)
void showColumnTypeNotSupported(std::u16string_view _rColumnName)
css::uno::Reference< css::beans::XPropertySet > createTable()
bool m_bInterConnectionCopy
bool shouldCreatePrimaryKey() const
returns whether a primary key should be created in the target database
bool supportsViews() const
css::uno::Reference< css::task::XInteractionHandler > m_xInteractionHandler
void loadData(const ICopyTableSourceObject &_rSourceObject, ODatabaseExport::TColumns &_rColumns, ODatabaseExport::TColumnVector &_rColVector)
std::vector< OTypeInfoMap::iterator > m_aTypeInfoIndex
css::uno::Reference< css::sdbc::XConnection > m_xDestConnection
TOTypeInfoSP convertType(const TOTypeInfoSP &_pType, bool &_bNotConvert)
void removeColumnNameFromNameMap(const OUString &_sName)
bool CheckColumns(sal_Int32 &_rnBreakPos)
ODatabaseExport::TColumns m_vSourceColumns
css::uno::Reference< css::uno::XComponentContext > m_xContext
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
void setCreatePrimaryKey(bool _bDoCreate, const OUString &_rSuggestedName)
ODatabaseExport::TColumns m_vDestColumns
weld::Container * CreatePageContainer()
void setCreatePrimaryKey(bool _bDoCreate, const OUString &_rSuggestedName)
std::map< OUString, OFieldDescription *, ::comphelper::UStringMixLess > TColumns
std::vector< TColumns::const_iterator > TColumnVector
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)
sal_Int32 GetScale() const
bool IsAutoIncrement() const
void SetAutoIncrement(bool _bAuto)
OUString GetTypeName() const
void SetName(const OUString &_rName)
bool IsPrimaryKey() const
sal_Int32 GetType() const
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
virtual OUString getQualifiedObjectName() const override
retrieves the fully qualified name of the object to copy
virtual bool isView() const override
determines whether the object is a view
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
css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData
virtual OUString getSelectStatement() const override
returns the SELECT statement which can be used to retrieve the data of the to-be-copied object
css::uno::Reference< css::sdbc::XConnection > m_xConnection
css::uno::Reference< css::container::XNameAccess > m_xObjectColumns
css::uno::Reference< css::beans::XPropertySetInfo > m_xObjectPSI
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
virtual css::uno::Sequence< OUString > getPrimaryKeyColumnNames() const override
retrieves the names of the primary keys of the to-be-copied object
virtual OFieldDescription * createFieldDescription(const OUString &_rColumnName) const override
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 override
copies the UI settings of the object to the given target object.
css::uno::Reference< css::beans::XPropertySet > m_xObject
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
SharedConnection m_xDestConnection
Reference< XInteractionHandler2 > m_xInteractionHandler
#define DBG_UNHANDLED_EXCEPTION(...)
#define LINK(Instance, Class, Member)
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
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
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
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
std::shared_ptr< OTypeInfo > TOTypeInfoSP
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
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
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")