Files
libreoffice/dbaccess/source/ui/misc/WCPage.cxx
Michael Meeks e8b97a52c9 Merge remote-tracking branch 'origin/feature/vclptr'
Resolve several thousand lines of conflicts.

Conflicts:
	accessibility/source/extended/accessiblelistbox.cxx
	accessibility/source/standard/vclxaccessiblecombobox.cxx
	accessibility/source/standard/vclxaccessibledropdowncombobox.cxx
	accessibility/source/standard/vclxaccessibledropdownlistbox.cxx
	accessibility/source/standard/vclxaccessiblelistbox.cxx
	accessibility/source/standard/vclxaccessibletextfield.cxx
	basctl/source/basicide/basidesh.cxx
	cui/source/inc/chardlg.hxx
	cui/source/tabpages/tpbitmap.cxx
	dbaccess/source/ui/dlg/UserAdmin.cxx
	dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx
	extensions/source/propctrlr/propertyeditor.hxx
	extensions/source/scanner/sanedlg.cxx
	filter/source/pdf/impdialog.cxx
	include/sfx2/mgetempl.hxx
	include/sfx2/sidebar/SidebarToolBox.hxx
	include/sfx2/viewsh.hxx
	include/svtools/brwbox.hxx
	include/svtools/filectrl.hxx
	include/svtools/scrwin.hxx
	include/svx/dlgctrl.hxx
	include/svx/sidebar/Popup.hxx
	include/svx/sidebar/PopupContainer.hxx
	include/svx/sidebar/PopupControl.hxx
	include/svx/sidebar/SidebarDialControl.hxx
	include/svx/sidebar/ValueSetWithTextControl.hxx
	sc/source/ui/condformat/condformatdlgentry.cxx
	sc/source/ui/navipi/navipi.cxx
	sc/source/ui/sidebar/CellBorderStyleControl.hxx
	sd/source/ui/animations/CustomAnimationDialog.cxx
	sd/source/ui/inc/DrawViewShell.hxx
	sd/source/ui/inc/Ruler.hxx
	sd/source/ui/inc/SlideSorter.hxx
	sd/source/ui/inc/ViewTabBar.hxx
	sd/source/ui/inc/Window.hxx
	sd/source/ui/inc/morphdlg.hxx
	sd/source/ui/inc/sdpreslt.hxx
	sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx
	sd/source/ui/sidebar/LayoutMenu.hxx
	sd/source/ui/sidebar/MasterPagesSelector.hxx
	sd/source/ui/sidebar/NavigatorWrapper.hxx
	sd/source/ui/sidebar/PanelBase.hxx
	sd/source/ui/sidebar/RecentMasterPagesSelector.cxx
	sd/source/ui/sidebar/RecentMasterPagesSelector.hxx
	sd/source/ui/slideshow/showwindow.hxx
	sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx
	sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
	sd/source/ui/view/ViewShellBase.cxx
	sd/source/ui/view/drviewsa.cxx
	sfx2/source/appl/fileobj.hxx
	sfx2/source/appl/opengrf.cxx
	sfx2/source/control/thumbnailviewacc.hxx
	sfx2/source/dialog/securitypage.cxx
	sfx2/source/dialog/templdlg.cxx
	sfx2/source/doc/docinsert.cxx
	sfx2/source/doc/guisaveas.cxx
	sfx2/source/inc/alienwarn.hxx
	sfx2/source/sidebar/Deck.cxx
	sfx2/source/sidebar/Deck.hxx
	sfx2/source/sidebar/DeckTitleBar.cxx
	sfx2/source/sidebar/DeckTitleBar.hxx
	sfx2/source/sidebar/MenuButton.cxx
	sfx2/source/sidebar/MenuButton.hxx
	sfx2/source/sidebar/Panel.cxx
	sfx2/source/sidebar/Panel.hxx
	sfx2/source/sidebar/PanelTitleBar.hxx
	sfx2/source/sidebar/SidebarDockingWindow.hxx
	sfx2/source/sidebar/SidebarToolBox.cxx
	sfx2/source/sidebar/TabBar.hxx
	sfx2/source/sidebar/TabItem.cxx
	sfx2/source/sidebar/TabItem.hxx
	sfx2/source/sidebar/TitleBar.hxx
	sfx2/source/toolbox/imgmgr.cxx
	starmath/inc/edit.hxx
	starmath/inc/smmod.hxx
	starmath/qa/cppunit/test_starmath.cxx
	starmath/source/edit.cxx
	starmath/source/smmod.cxx
	svtools/source/brwbox/brwbox1.cxx
	svtools/source/brwbox/datwin.hxx
	svtools/source/contnr/fileview.cxx
	svtools/source/contnr/simptabl.cxx
	svtools/source/control/filectrl.cxx
	svtools/source/control/valueimp.hxx
	svx/inc/GalleryControl.hxx
	svx/source/dialog/dlgctrl.cxx
	svx/source/dialog/swframeexample.cxx
	svx/source/fmcomp/fmgridif.cxx
	svx/source/gallery2/GalleryControl.cxx
	svx/source/sidebar/EmptyPanel.hxx
	svx/source/sidebar/area/AreaPropertyPanel.hxx
	svx/source/sidebar/area/AreaTransparencyGradientControl.hxx
	svx/source/sidebar/graphic/GraphicPropertyPanel.hxx
	svx/source/sidebar/insert/InsertPropertyPanel.cxx
	svx/source/sidebar/insert/InsertPropertyPanel.hxx
	svx/source/sidebar/line/LinePropertyPanel.hxx
	svx/source/sidebar/line/LineWidthControl.cxx
	svx/source/sidebar/line/LineWidthControl.hxx
	svx/source/sidebar/line/LineWidthValueSet.hxx
	svx/source/sidebar/paragraph/ParaPropertyPanel.hxx
	svx/source/sidebar/possize/SidebarDialControl.cxx
	svx/source/sidebar/text/TextCharacterSpacingPopup.hxx
	svx/source/sidebar/text/TextPropertyPanel.hxx
	svx/source/sidebar/tools/PopupContainer.cxx
	svx/source/sidebar/tools/PopupControl.cxx
	svx/source/sidebar/tools/ValueSetWithTextControl.cxx
	svx/source/svdraw/svdfmtf.hxx
	svx/source/svdraw/svdibrow.cxx
	svx/source/tbxctrls/colrctrl.cxx
	svx/source/tbxctrls/tbcontrl.cxx
	sw/source/ui/dbui/mmaddressblockpage.cxx
	sw/source/ui/dialog/uiregionsw.cxx
	sw/source/ui/index/cnttab.cxx
	sw/source/uibase/inc/drpcps.hxx
	sw/source/uibase/sidebar/PageColumnControl.hxx
	sw/source/uibase/sidebar/PageMarginControl.hxx
	sw/source/uibase/sidebar/PageOrientationControl.hxx
	sw/source/uibase/sidebar/PagePropertyPanel.hxx
	sw/source/uibase/sidebar/PageSizeControl.hxx
	sw/source/uibase/uiview/view2.cxx
	sw/source/uibase/utlui/navipi.cxx
	vcl/inc/svdata.hxx
	vcl/source/control/combobox.cxx
	vcl/source/control/lstbox.cxx
	vcl/source/window/dockwin.cxx
	vcl/source/window/winproc.cxx

Change-Id: I056cf3026ff17d65cca0b6e6588bda4a88fa8d95
2015-04-28 15:08:48 +01:00

370 lines
13 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "WCPage.hxx"
#include "WCopyTable.hxx"
#include "WColumnSelect.hxx"
#include "WExtendPages.hxx"
#include "defaultobjectnamecheck.hxx"
#include <tools/debug.hxx>
#include "dbaccess_helpid.hrc"
#include "dbu_misc.hrc"
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdb/CommandType.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
#include <vcl/msgbox.hxx>
#include <connectivity/dbexception.hxx>
#include <connectivity/dbtools.hxx>
#include "UITools.hxx"
#include "moduledbu.hxx"
#include <cppuhelper/exc_hlp.hxx>
using namespace ::dbaui;
using namespace ::dbtools;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
// Klasse OCopyTable
OCopyTable::OCopyTable(vcl::Window * pParent)
: OWizardPage(pParent, "CopyTablePage", "dbaccess/ui/copytablepage.ui")
, m_nOldOperation(0)
, m_pPage2(NULL)
, m_pPage3(NULL)
, m_bPKeyAllowed(false)
, m_bUseHeaderAllowed(true)
{
get(m_pEdTableName, "name");
get(m_pRB_DefData, "defdata");
get(m_pRB_Def, "def");
get(m_pRB_View, "view");
get(m_pRB_AppendData, "data");
get(m_pCB_UseHeaderLine, "firstline");
get(m_pCB_PrimaryColumn, "primarykey");
get(m_pFT_KeyName, "keynamelabel");
get(m_pEdKeyName, "keyname");
m_pEdTableName->SetMaxTextLen(EDIT_NOLIMIT);
if ( m_pParent->m_xDestConnection.is() )
{
if ( !m_pParent->supportsViews() )
m_pRB_View->Disable();
m_pCB_UseHeaderLine->Check(true);
m_bPKeyAllowed = m_pParent->supportsPrimaryKey();
m_pCB_PrimaryColumn->Enable(m_bPKeyAllowed);
m_pRB_AppendData->SetClickHdl( LINK( this, OCopyTable, AppendDataClickHdl ) );
m_pRB_DefData->SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
m_pRB_Def->SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
m_pRB_View->SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
m_pCB_PrimaryColumn->SetClickHdl(LINK( this, OCopyTable, KeyClickHdl ) );
m_pFT_KeyName->Enable(false);
m_pEdKeyName->Enable(false);
OUString sKeyName("ID");
sKeyName = m_pParent->createUniqueName(sKeyName);
m_pEdKeyName->SetText(sKeyName);
sal_Int32 nMaxLen = m_pParent->getMaxColumnNameLength();
m_pEdKeyName->SetMaxTextLen(nMaxLen ? nMaxLen : EDIT_NOLIMIT);
}
SetText(ModuleRes(STR_COPYTABLE_TITLE_COPY));
}
OCopyTable::~OCopyTable()
{
disposeOnce();
}
void OCopyTable::dispose()
{
m_pEdTableName.clear();
m_pRB_DefData.clear();
m_pRB_Def.clear();
m_pRB_View.clear();
m_pRB_AppendData.clear();
m_pCB_UseHeaderLine.clear();
m_pCB_PrimaryColumn.clear();
m_pFT_KeyName.clear();
m_pEdKeyName.clear();
m_pPage2.clear();
m_pPage3.clear();
OWizardPage::dispose();
}
IMPL_LINK( OCopyTable, AppendDataClickHdl, Button*, /*pButton*/ )
{
SetAppendDataRadio();
return 0;
}
void OCopyTable::SetAppendDataRadio()
{
m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,true);
m_pFT_KeyName->Enable(false);
m_pCB_PrimaryColumn->Enable(false);
m_pEdKeyName->Enable(false);
m_pParent->setOperation(CopyTableOperation::AppendData);
}
IMPL_LINK( OCopyTable, RadioChangeHdl, Button*, pButton )
{
m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,pButton != m_pRB_View);
bool bKey = m_bPKeyAllowed && pButton != m_pRB_View;
m_pFT_KeyName->Enable(bKey && m_pCB_PrimaryColumn->IsChecked());
m_pEdKeyName->Enable(bKey && m_pCB_PrimaryColumn->IsChecked());
m_pCB_PrimaryColumn->Enable(bKey);
m_pCB_UseHeaderLine->Enable(m_bUseHeaderAllowed && IsOptionDefData());
// set typ what to do
if( IsOptionDefData() )
m_pParent->setOperation( CopyTableOperation::CopyDefinitionAndData );
else if( IsOptionDef() )
m_pParent->setOperation( CopyTableOperation::CopyDefinitionOnly );
else if( IsOptionView() )
m_pParent->setOperation( CopyTableOperation::CreateAsView );
return 0;
}
IMPL_LINK( OCopyTable, KeyClickHdl, Button*, /*pButton*/ )
{
m_pEdKeyName->Enable(m_pCB_PrimaryColumn->IsChecked());
m_pFT_KeyName->Enable(m_pCB_PrimaryColumn->IsChecked());
return 0;
}
bool OCopyTable::LeavePage()
{
m_pParent->m_bCreatePrimaryKeyColumn = m_bPKeyAllowed && m_pCB_PrimaryColumn->IsEnabled() && m_pCB_PrimaryColumn->IsChecked();
m_pParent->m_aKeyName = m_pParent->m_bCreatePrimaryKeyColumn ? m_pEdKeyName->GetText() : OUString();
m_pParent->setUseHeaderLine( m_pCB_UseHeaderLine->IsChecked() );
// first check if the table already exists in the database
if( m_pParent->getOperation() != CopyTableOperation::AppendData )
{
m_pParent->clearDestColumns();
DynamicTableOrQueryNameCheck aNameCheck( m_pParent->m_xDestConnection, CommandType::TABLE );
SQLExceptionInfo aErrorInfo;
if ( !aNameCheck.isNameValid( m_pEdTableName->GetText(), aErrorInfo ) )
{
aErrorInfo.append( SQLExceptionInfo::SQL_CONTEXT, ModuleRes( STR_SUGGEST_APPEND_TABLE_DATA ) );
m_pParent->showError(aErrorInfo.get());
return false;
}
// have to check the length of the table name
Reference< XDatabaseMetaData > xMeta = m_pParent->m_xDestConnection->getMetaData();
OUString sCatalog;
OUString sSchema;
OUString sTable;
::dbtools::qualifiedNameComponents( xMeta,
m_pEdTableName->GetText(),
sCatalog,
sSchema,
sTable,
::dbtools::eInDataManipulation);
sal_Int32 nMaxLength = xMeta->getMaxTableNameLength();
if ( nMaxLength && sTable.getLength() > nMaxLength )
{
OUString sError(ModuleRes(STR_INVALID_TABLE_NAME_LENGTH));
m_pParent->showError(sError);
return false;
}
// now we have to check if the name of the primary key already exists
if ( m_pParent->m_bCreatePrimaryKeyColumn
&& m_pParent->m_aKeyName != m_pParent->createUniqueName(m_pParent->m_aKeyName) )
{
OUString aInfoString( ModuleRes(STR_WIZ_PKEY_ALREADY_DEFINED) );
aInfoString += " ";
aInfoString += m_pParent->m_aKeyName;
m_pParent->showError(aInfoString);
return false;
}
}
if ( m_pEdTableName->IsValueChangedFromSaved() )
{ // table exists and name has changed
if ( m_pParent->getOperation() == CopyTableOperation::AppendData )
{
if(!checkAppendData())
return false;
}
else if ( m_nOldOperation == CopyTableOperation::AppendData )
{
m_pEdTableName->SaveValue();
return LeavePage();
}
}
else
{ // table exist and is not new or doesn't exist and so on
if ( CopyTableOperation::AppendData == m_pParent->getOperation() )
{
if( !checkAppendData() )
return false;
}
}
m_pParent->m_sName = m_pEdTableName->GetText();
m_pEdTableName->SaveValue();
if(m_pParent->m_sName.isEmpty())
{
OUString sError(ModuleRes(STR_INVALID_TABLE_NAME));
m_pParent->showError(sError);
return false;
}
return true;
}
void OCopyTable::ActivatePage()
{
m_pParent->GetOKButton().Enable( true );
m_nOldOperation = m_pParent->getOperation();
m_pEdTableName->GrabFocus();
m_pCB_UseHeaderLine->Check(m_pParent->UseHeaderLine());
}
OUString OCopyTable::GetTitle() const
{
return ModuleRes(STR_WIZ_TABLE_COPY);
}
void OCopyTable::Reset()
{
m_bFirstTime = false;
m_pEdTableName->SetText( m_pParent->m_sName );
m_pEdTableName->SaveValue();
}
bool OCopyTable::checkAppendData()
{
m_pParent->clearDestColumns();
Reference< XPropertySet > xTable;
Reference< XTablesSupplier > xSup( m_pParent->m_xDestConnection, UNO_QUERY );
Reference<XNameAccess> xTables;
if(xSup.is())
xTables = xSup->getTables();
if(xTables.is() && xTables->hasByName(m_pEdTableName->GetText()))
{
const ODatabaseExport::TColumnVector& rSrcColumns = m_pParent->getSrcVector();
const sal_uInt32 nSrcSize = rSrcColumns.size();
m_pParent->m_vColumnPos.resize( nSrcSize, ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) );
m_pParent->m_vColumnTypes.resize( nSrcSize , COLUMN_POSITION_NOT_FOUND );
// set new destination
xTables->getByName( m_pEdTableName->GetText() ) >>= xTable;
ObjectCopySource aTableCopySource( m_pParent->m_xDestConnection, xTable );
m_pParent->loadData( aTableCopySource, m_pParent->m_vDestColumns, m_pParent->m_aDestVec );
const ODatabaseExport::TColumnVector& rDestColumns = m_pParent->getDestVector();
ODatabaseExport::TColumnVector::const_iterator aDestIter = rDestColumns.begin();
ODatabaseExport::TColumnVector::const_iterator aDestEnd = rDestColumns.end();
const sal_uInt32 nDestSize = rDestColumns.size();
sal_uInt32 i = 0;
for(sal_Int32 nPos = 1;aDestIter != aDestEnd && i < nDestSize && i < nSrcSize;++aDestIter,++nPos,++i)
{
bool bNotConvert = true;
m_pParent->m_vColumnPos[i] = ODatabaseExport::TPositions::value_type(nPos,nPos);
TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert);
if ( !bNotConvert )
{
m_pParent->showColumnTypeNotSupported((*aDestIter)->first);
return false;
}
if ( pTypeInfo.get() )
m_pParent->m_vColumnTypes[i] = pTypeInfo->nType;
else
m_pParent->m_vColumnTypes[i] = DataType::VARCHAR;
}
}
if ( !xTable.is() )
{
OUString sError(ModuleRes(STR_INVALID_TABLE_NAME));
m_pParent->showError(sError);
return false;
}
return true;
}
void OCopyTable::setCreatePrimaryKey( bool _bDoCreate, const OUString& _rSuggestedName )
{
bool bCreatePK = m_bPKeyAllowed && _bDoCreate;
m_pCB_PrimaryColumn->Check( bCreatePK );
m_pEdKeyName->SetText( _rSuggestedName );
m_pFT_KeyName->Enable( bCreatePK );
m_pEdKeyName->Enable( bCreatePK );
}
void OCopyTable::setCreateStyleAction()
{
// reselect the last action before
switch(m_pParent->getOperation())
{
case CopyTableOperation::CopyDefinitionAndData:
m_pRB_DefData->Check(true);
RadioChangeHdl(m_pRB_DefData);
break;
case CopyTableOperation::CopyDefinitionOnly:
m_pRB_Def->Check(true);
RadioChangeHdl(m_pRB_Def);
break;
case CopyTableOperation::AppendData:
m_pRB_AppendData->Check(true);
SetAppendDataRadio();
break;
case CopyTableOperation::CreateAsView:
if ( m_pRB_View->IsEnabled() )
{
m_pRB_View->Check(true);
RadioChangeHdl(m_pRB_View);
}
else
{
m_pRB_DefData->Check(true);
RadioChangeHdl(m_pRB_DefData);
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */