25#include <core_resource.hxx>
26#include <com/sun/star/sdb/CommandType.hpp>
27#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
28#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
32using namespace ::
dbaui;
42namespace CopyTableOperation = css::sdb::application::CopyTableOperation;
45 :
OWizardPage(pPage, pWizard,
"dbaccess/ui/copytablepage.ui",
"CopyTablePage")
46 , m_bPKeyAllowed(false)
47 , m_bUseHeaderAllowed(true)
49 , m_xEdTableName(m_xBuilder->weld_entry(
"name"))
50 , m_xRB_DefData(m_xBuilder->weld_radio_button(
"defdata"))
51 , m_xRB_Def(m_xBuilder->weld_radio_button(
"def"))
52 , m_xRB_View(m_xBuilder->weld_radio_button(
"view"))
53 , m_xRB_AppendData(m_xBuilder->weld_radio_button(
"data"))
54 , m_xCB_UseHeaderLine(m_xBuilder->weld_check_button(
"firstline"))
55 , m_xCB_PrimaryColumn(m_xBuilder->weld_check_button(
"primarykey"))
56 , m_xFT_KeyName(m_xBuilder->weld_label(
"keynamelabel"))
57 , m_xEdKeyName(m_xBuilder->weld_entry(
"keyname"))
59 if ( m_pParent->m_xDestConnection.is() )
61 if (!m_pParent->supportsViews())
78 m_xEdKeyName->set_text(m_pParent->createUniqueName(
"ID"));
80 const sal_Int32 nMaxLen = m_pParent->getMaxColumnNameLength();
93 m_pParent->EnableNextButton(
true);
97 m_pParent->setOperation(CopyTableOperation::AppendData);
102 if (!rButton.get_active())
104 if (m_xRB_AppendData->get_active())
106 SetAppendDataRadio();
109 m_pParent->EnableNextButton(!m_xRB_View->get_active());
110 bool bKey = m_bPKeyAllowed && !m_xRB_View->get_active();
111 m_xFT_KeyName->set_sensitive(bKey && m_xCB_PrimaryColumn->get_active());
112 m_xEdKeyName->set_sensitive(bKey && m_xCB_PrimaryColumn->get_active());
113 m_xCB_PrimaryColumn->set_sensitive(bKey);
114 m_xCB_UseHeaderLine->set_sensitive(m_bUseHeaderAllowed && IsOptionDefData());
117 if( IsOptionDefData() )
118 m_pParent->setOperation( CopyTableOperation::CopyDefinitionAndData );
119 else if( IsOptionDef() )
120 m_pParent->setOperation( CopyTableOperation::CopyDefinitionOnly );
121 else if( IsOptionView() )
122 m_pParent->setOperation( CopyTableOperation::CreateAsView );
127 m_xEdKeyName->set_sensitive(m_xCB_PrimaryColumn->get_active());
128 m_xFT_KeyName->set_sensitive(m_xCB_PrimaryColumn->get_active());
134 m_pParent->m_aKeyName = m_pParent->m_bCreatePrimaryKeyColumn ?
m_xEdKeyName->get_text() : OUString();
138 if( m_pParent->getOperation() != CopyTableOperation::AppendData )
140 m_pParent->clearDestColumns();
145 aErrorInfo.
append( SQLExceptionInfo::TYPE::SQLContext,
DBA_RES( STR_SUGGEST_APPEND_TABLE_DATA ) );
146 m_pParent->showError(aErrorInfo.
get());
156 ::dbtools::qualifiedNameComponents( xMeta,
161 ::dbtools::EComposeRule::InDataManipulation);
162 sal_Int32 nMaxLength = xMeta->getMaxTableNameLength();
163 if ( nMaxLength && sTable.getLength() > nMaxLength )
165 m_pParent->showError(
DBA_RES(STR_INVALID_TABLE_NAME_LENGTH));
170 if ( m_pParent->m_bCreatePrimaryKeyColumn
171 && m_pParent->m_aKeyName != m_pParent->createUniqueName(m_pParent->m_aKeyName) )
173 m_pParent->showError(
DBA_RES(STR_WIZ_NAME_ALREADY_DEFINED) +
" " + m_pParent->m_aKeyName);
180 if ( m_pParent->getOperation() == CopyTableOperation::AppendData )
193 if ( CopyTableOperation::AppendData == m_pParent->getOperation() )
202 if(m_pParent->m_sName.isEmpty())
204 m_pParent->showError(
DBA_RES(STR_INVALID_TABLE_NAME));
213 m_pParent->GetOKButton().set_sensitive(
true);
221 return DBA_RES(STR_WIZ_TABLE_COPY);
226 m_bFirstTime =
false;
234 m_pParent->clearDestColumns();
239 xTables = xSup->getTables();
240 if (xTables.is() && xTables->hasByName(
m_xEdTableName->get_text()))
243 const sal_uInt32 nSrcSize = rSrcColumns.size();
250 m_pParent->loadData( aTableCopySource, m_pParent->m_vDestColumns, m_pParent->m_aDestVec );
252 const sal_uInt32 nMinSrcDestSize = std::min<sal_uInt32>(nSrcSize, rDestColumns.size());
254 for (
auto const& column : rDestColumns)
256 if (
i >= nMinSrcDestSize)
258 bool bNotConvert =
true;
259 m_pParent->m_vColumnPositions[
i] = ODatabaseExport::TPositions::value_type(
i+1,
i+1);
260 TOTypeInfoSP pTypeInfo = m_pParent->convertType(column->second->getSpecialTypeInfo(),bNotConvert);
263 m_pParent->showColumnTypeNotSupported(column->first);
268 m_pParent->m_vColumnTypes[
i] = pTypeInfo->nType;
270 m_pParent->m_vColumnTypes[
i] = DataType::VARCHAR;
278 m_pParent->showError(
DBA_RES(STR_INVALID_TABLE_NAME));
297 switch (m_pParent->getOperation())
299 case CopyTableOperation::CopyDefinitionAndData:
303 case CopyTableOperation::CopyDefinitionOnly:
307 case CopyTableOperation::AppendData:
311 case CopyTableOperation::CreateAsView:
#define COLUMN_POSITION_NOT_FOUND
void SetPageTitle(const OUString &rPageTitle)
class implementing the IObjectNameCheck interface, and checking a given name for being valid as eithe...
virtual bool isNameValid(const OUString &_rObjectName, ::dbtools::SQLExceptionInfo &_out_rErrorToDisplay) const override
determines whether a given object name is valid
std::unique_ptr< weld::RadioButton > m_xRB_AppendData
virtual ~OCopyTable() override
sal_Int16 m_nOldOperation
std::unique_ptr< weld::RadioButton > m_xRB_View
virtual bool LeavePage() override
std::unique_ptr< weld::Entry > m_xEdTableName
std::unique_ptr< weld::CheckButton > m_xCB_UseHeaderLine
void setCreateStyleAction()
void SetAppendDataRadio()
std::unique_ptr< weld::Label > m_xFT_KeyName
virtual void Activate() override
std::unique_ptr< weld::RadioButton > m_xRB_Def
virtual void Reset() override
void setCreatePrimaryKey(bool _bDoCreate, const OUString &_rSuggestedName)
std::unique_ptr< weld::RadioButton > m_xRB_DefData
std::unique_ptr< weld::Entry > m_xEdKeyName
std::unique_ptr< weld::CheckButton > m_xCB_PrimaryColumn
virtual OUString GetTitle() const override
std::vector< TColumns::const_iterator > TColumnVector
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
IMPL_LINK(OApplicationController, OnSelectContainer, void *, _pType, void)
std::shared_ptr< OTypeInfo > TOTypeInfoSP