summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/misc
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/misc')
-rw-r--r--dbaccess/source/ui/misc/DExport.cxx904
-rw-r--r--dbaccess/source/ui/misc/HtmlReader.cxx598
-rw-r--r--dbaccess/source/ui/misc/ModuleHelper.cxx44
-rw-r--r--dbaccess/source/ui/misc/RowSetDrop.cxx273
-rw-r--r--dbaccess/source/ui/misc/RtfReader.cxx377
-rw-r--r--dbaccess/source/ui/misc/TableCopyHelper.cxx415
-rw-r--r--dbaccess/source/ui/misc/TokenWriter.cxx1161
-rw-r--r--dbaccess/source/ui/misc/ToolBoxHelper.cxx140
-rw-r--r--dbaccess/source/ui/misc/UITools.cxx1888
-rw-r--r--dbaccess/source/ui/misc/UpdateHelperImpl.hxx149
-rw-r--r--dbaccess/source/ui/misc/WCPage.cxx418
-rw-r--r--dbaccess/source/ui/misc/WColumnSelect.cxx452
-rw-r--r--dbaccess/source/ui/misc/WCopyTable.cxx1692
-rw-r--r--dbaccess/source/ui/misc/WExtendPages.cxx92
-rw-r--r--dbaccess/source/ui/misc/WNameMatch.cxx450
-rw-r--r--dbaccess/source/ui/misc/WTypeSelect.cxx510
-rw-r--r--dbaccess/source/ui/misc/WizardPages.hrc81
-rw-r--r--dbaccess/source/ui/misc/WizardPages.src658
-rw-r--r--dbaccess/source/ui/misc/asyncmodaldialog.cxx121
-rw-r--r--dbaccess/source/ui/misc/charsets.cxx196
-rw-r--r--dbaccess/source/ui/misc/controllerframe.cxx443
-rw-r--r--dbaccess/source/ui/misc/databaseobjectview.cxx344
-rw-r--r--dbaccess/source/ui/misc/datasourceconnector.cxx277
-rwxr-xr-xdbaccess/source/ui/misc/dbaundomanager.cxx395
-rw-r--r--dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx672
-rw-r--r--dbaccess/source/ui/misc/dbumiscres.hrc62
-rw-r--r--dbaccess/source/ui/misc/dbumiscres.src100
-rw-r--r--dbaccess/source/ui/misc/defaultobjectnamecheck.cxx232
-rw-r--r--dbaccess/source/ui/misc/dsmeta.cxx214
-rw-r--r--dbaccess/source/ui/misc/imageprovider.cxx261
-rw-r--r--dbaccess/source/ui/misc/indexcollection.cxx424
-rw-r--r--dbaccess/source/ui/misc/linkeddocuments.cxx476
-rw-r--r--dbaccess/source/ui/misc/makefile.mk88
-rw-r--r--dbaccess/source/ui/misc/moduledbu.cxx146
-rw-r--r--dbaccess/source/ui/misc/propertysetitem.cxx86
-rw-r--r--dbaccess/source/ui/misc/propertystorage.cxx136
-rwxr-xr-xdbaccess/source/ui/misc/singledoccontroller.cxx200
-rw-r--r--dbaccess/source/ui/misc/stringlistitem.cxx87
-rw-r--r--dbaccess/source/ui/misc/uiservices.cxx144
39 files changed, 15406 insertions, 0 deletions
diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx
new file mode 100644
index 000000000000..9e134b784ea1
--- /dev/null
+++ b/dbaccess/source/ui/misc/DExport.cxx
@@ -0,0 +1,904 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "DExport.hxx"
+#include "moduledbu.hxx"
+
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include "dbustrings.hrc"
+#include "dbu_misc.hrc"
+#include <connectivity/dbconversion.hxx>
+#include <sfx2/sfxhtml.hxx>
+#include <svl/numuno.hxx>
+#include <connectivity/dbtools.hxx>
+#include <comphelper/extract.hxx>
+#include "TypeInfo.hxx"
+#include "FieldDescriptions.hxx"
+#include "UITools.hxx"
+#include <unotools/configmgr.hxx>
+#include <memory>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <i18npool/mslangid.hxx>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include "WCopyTable.hxx"
+#include "WExtendPages.hxx"
+#include "WCPage.hxx"
+#include <unotools/syslocale.hxx>
+#include <svl/zforlist.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/FValue.hxx>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#include "sqlmessage.hxx"
+#include "UpdateHelperImpl.hxx"
+#include <vcl/msgbox.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace dbaui;
+using namespace utl;
+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::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::awt;
+
+namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
+
+// ==========================================================================
+// ODatabaseExport
+// ==========================================================================
+DBG_NAME(ODatabaseExport)
+ODatabaseExport::ODatabaseExport(sal_Int32 nRows,
+ const TPositions &_rColumnPositions,
+ const Reference< XNumberFormatter >& _rxNumberF,
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap,
+ sal_Bool _bAutoIncrementEnabled,
+ SvStream& _rInputStream)
+ :m_vColumns(_rColumnPositions)
+ ,m_aDestColumns(sal_True)
+ ,m_xFormatter(_rxNumberF)
+ ,m_xFactory(_rM)
+ ,m_pFormatter(NULL)
+ ,m_rInputStream( _rInputStream )
+ ,m_pTypeInfo()
+ ,m_pColumnList(pList)
+ ,m_pInfoMap(_pInfoMap)
+ ,m_nColumnPos(0)
+ ,m_nRows(1)
+ ,m_nRowCount(0)
+ ,m_nDefToken( gsl_getSystemTextEncoding() )
+ ,m_bError(sal_False)
+ ,m_bInTbl(sal_False)
+ ,m_bHead(sal_True)
+ ,m_bDontAskAgain(sal_False)
+ ,m_bIsAutoIncrement(_bAutoIncrementEnabled)
+ ,m_bFoundTable(sal_False)
+ ,m_bCheckOnly(sal_False)
+ ,m_bAppendFirstLine(false)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::ODatabaseExport" );
+ DBG_CTOR(ODatabaseExport,NULL);
+
+ m_nRows += nRows;
+ sal_Int32 nCount = 0;
+ for(sal_Int32 j=0;j < (sal_Int32)m_vColumns.size();++j)
+ if ( m_vColumns[j].first != COLUMN_POSITION_NOT_FOUND )
+ ++nCount;
+
+ m_vColumnSize.resize(nCount);
+ m_vNumberFormat.resize(nCount);
+ for(sal_Int32 i=0;i<nCount;++i)
+ {
+ m_vColumnSize[i] = 0;
+ m_vNumberFormat[i] = 0;
+ }
+
+ try
+ {
+ SvtSysLocale aSysLocale;
+ m_aLocale = aSysLocale.GetLocaleData().getLocale();
+ }
+ catch(Exception&)
+ {
+ }
+
+ SetColumnTypes(pList,_pInfoMap);
+}
+//---------------------------------------------------------------------------
+ODatabaseExport::ODatabaseExport(const SharedConnection& _rxConnection,
+ const Reference< XNumberFormatter >& _rxNumberF,
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap,
+ SvStream& _rInputStream)
+ :m_aDestColumns(_rxConnection->getMetaData().is() && _rxConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers() == sal_True)
+ ,m_xConnection(_rxConnection)
+ ,m_xFormatter(_rxNumberF)
+ ,m_xFactory(_rM)
+ ,m_pFormatter(NULL)
+ ,m_rInputStream( _rInputStream )
+ ,m_pTypeInfo()
+ ,m_pColumnList(NULL)
+ ,m_pInfoMap(NULL)
+ ,m_nColumnPos(0)
+ ,m_nRows(1)
+ ,m_nRowCount(0)
+ ,m_nDefToken( gsl_getSystemTextEncoding() )
+ ,m_bError(sal_False)
+ ,m_bInTbl(sal_False)
+ ,m_bHead(sal_True)
+ ,m_bDontAskAgain(sal_False)
+ ,m_bIsAutoIncrement(sal_False)
+ ,m_bFoundTable(sal_False)
+ ,m_bCheckOnly(sal_False)
+ ,m_bAppendFirstLine(false)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::ODatabaseExport" );
+ DBG_CTOR(ODatabaseExport,NULL);
+ try
+ {
+ SvtSysLocale aSysLocale;
+ m_aLocale = aSysLocale.GetLocaleData().getLocale();
+ }
+ catch(Exception&)
+ {
+ }
+
+ Reference<XTablesSupplier> xTablesSup(m_xConnection,UNO_QUERY);
+ if(xTablesSup.is())
+ m_xTables = xTablesSup->getTables();
+
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ Reference<XResultSet> xSet = xMeta.is() ? xMeta->getTypeInfo() : Reference<XResultSet>();
+ if(xSet.is())
+ {
+ ::connectivity::ORowSetValue aValue;
+ ::std::vector<sal_Int32> aTypes;
+ ::std::vector<sal_Bool> aNullable;
+ Reference<XResultSetMetaData> xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(xSet,UNO_QUERY_THROW)->getMetaData();
+ Reference<XRow> xRow(xSet,UNO_QUERY_THROW);
+ while(xSet->next())
+ {
+ if ( aTypes.empty() )
+ {
+ sal_Int32 nCount = xResultSetMetaData->getColumnCount();
+ if ( nCount < 1 )
+ nCount = 18;
+ aTypes.reserve(nCount+1);
+ aNullable.reserve(nCount+1);
+ aTypes.push_back(-1);
+ aNullable.push_back(sal_False);
+ for (sal_Int32 j = 1; j <= nCount ; ++j)
+ {
+ aNullable.push_back(xResultSetMetaData->isNullable(j) != ColumnValue::NO_NULLS );
+ aTypes.push_back(xResultSetMetaData->getColumnType(j));
+ }
+ }
+
+ sal_Int32 nPos = 1;
+ OSL_ENSURE((nPos) < static_cast<sal_Int32>(aTypes.size()),"aTypes: Illegal index for vector");
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ ::rtl::OUString sTypeName = aValue;
+ ++nPos;
+ OSL_ENSURE((nPos) < static_cast<sal_Int32>(aTypes.size()),"aTypes: Illegal index for vector");
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ sal_Int32 nType = aValue;
+ ++nPos;
+
+ if( nType == DataType::VARCHAR )
+ {
+ m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
+
+ m_pTypeInfo->aTypeName = sTypeName;
+ m_pTypeInfo->nType = nType;
+
+ OSL_ENSURE((nPos) < static_cast<sal_Int32>(aTypes.size()),"aTypes: Illegal index for vector");
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->nPrecision = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->aLiteralPrefix = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->aLiteralSuffix = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->aCreateParams = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->bNullable = (sal_Int32)aValue == ColumnValue::NULLABLE;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->bCaseSensitive = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->nSearchType = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->bUnsigned = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->bCurrency = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->bAutoIncrement = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->aLocalTypeName = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->nMinimumScale = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->nMaximumScale = aValue;
+
+ // check if values are less than zero like it happens in a oracle jdbc driver
+ if( m_pTypeInfo->nPrecision < 0)
+ m_pTypeInfo->nPrecision = 0;
+ if( m_pTypeInfo->nMinimumScale < 0)
+ m_pTypeInfo->nMinimumScale = 0;
+ if( m_pTypeInfo->nMaximumScale < 0)
+ m_pTypeInfo->nMaximumScale = 0;
+ break;
+ }
+ }
+ } // if(xSet.is())
+ if ( !m_pTypeInfo )
+ m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
+ SetColumnTypes(pList,_pInfoMap);
+}
+//---------------------------------------------------------------------------
+ODatabaseExport::~ODatabaseExport()
+{
+ DBG_DTOR(ODatabaseExport,NULL);
+ m_pFormatter = NULL;
+ ODatabaseExport::TColumns::iterator aIter = m_aDestColumns.begin();
+ ODatabaseExport::TColumns::iterator aEnd = m_aDestColumns.end();
+
+ for(;aIter != aEnd;++aIter)
+ delete aIter->second;
+ m_vDestVector.clear();
+ m_aDestColumns.clear();
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::insertValueIntoColumn()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::insertValueIntoColumn" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+ if(m_nColumnPos < sal_Int32(m_vDestVector.size()))
+ {
+ OFieldDescription* pField = m_vDestVector[m_nColumnPos]->second;
+ if(pField)
+ {
+ sal_Int32 nNewPos = m_bIsAutoIncrement ? m_nColumnPos+1 : m_nColumnPos;
+ OSL_ENSURE((nNewPos) < static_cast<sal_Int32>(m_vColumns.size()),"m_vColumns: Illegal index for vector");
+
+ if ( (nNewPos) < static_cast<sal_Int32>(m_vColumns.size() ) )
+ {
+ sal_Int32 nPos = m_vColumns[nNewPos].first;
+ if ( nPos != COLUMN_POSITION_NOT_FOUND )
+ {
+ // if(m_nDefToken != LANGUAGE_DONTKNOW) // falls Sprache anders als Systemsprache
+ // m_pNF->ChangeIntl((LanguageType)m_nDefToken);
+
+ if ( !m_sTextToken.Len() && pField->IsNullable() )
+ m_pUpdateHelper->updateNull(nPos,pField->GetType());
+ else
+ {
+ sal_Int32 nNumberFormat = 0;
+ double fOutNumber = 0.0;
+ OSL_ENSURE((nNewPos) < static_cast<sal_Int32>(m_vColumnTypes.size()),"Illegal index for vector");
+ if (m_vColumnTypes[nNewPos] != DataType::VARCHAR && m_vColumnTypes[nNewPos] != DataType::CHAR && m_vColumnTypes[nNewPos] != DataType::LONGVARCHAR )
+ {
+ RTL_LOGFILE_CONTEXT_TRACE( aLogger, "ODatabaseExport::insertValueIntoColumn != DataType::VARCHAR" );
+ ensureFormatter();
+ bool bNumberFormatError = false;
+ if ( m_pFormatter && m_sNumToken.Len() )
+ {
+ LanguageType eNumLang = LANGUAGE_NONE;
+ sal_uInt32 nNumberFormat2( nNumberFormat );
+ fOutNumber = SfxHTMLParser::GetTableDataOptionsValNum(nNumberFormat2,eNumLang,m_sTextToken,m_sNumToken,*m_pFormatter);
+ if ( eNumLang != LANGUAGE_NONE )
+ {
+ nNumberFormat2 = m_pFormatter->GetFormatForLanguageIfBuiltIn( nNumberFormat2, eNumLang );
+ m_pFormatter->IsNumberFormat( m_sTextToken, nNumberFormat2, fOutNumber );
+ }
+ nNumberFormat = static_cast<sal_Int32>(nNumberFormat2);
+ }
+ else
+ {
+ Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ Reference<XNumberFormatTypes> xNumType(xSupplier->getNumberFormats(),UNO_QUERY);
+ sal_Int16 nFormats[] = {
+ NumberFormat::DATETIME
+ ,NumberFormat::DATE
+ ,NumberFormat::TIME
+ ,NumberFormat::CURRENCY
+ ,NumberFormat::NUMBER
+ ,NumberFormat::LOGICAL
+ };
+ for (size_t i = 0; i < sizeof(nFormats)/sizeof(nFormats[0]); ++i)
+ {
+ try
+ {
+ nNumberFormat = m_xFormatter->detectNumberFormat(xNumType->getStandardFormat(nFormats[i],m_aLocale),m_sTextToken);
+ break;
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ try
+ {
+ fOutNumber = m_xFormatter->convertStringToNumber(nNumberFormat,m_sTextToken);
+ }
+ catch(Exception&)
+ {
+ bNumberFormatError = true;
+ m_pUpdateHelper->updateString(nPos,m_sTextToken);
+ }
+ }
+ if ( !bNumberFormatError )
+ {
+ try
+ {
+ Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ Reference< XNumberFormats > xFormats = xSupplier->getNumberFormats();
+ Reference<XPropertySet> xProp = xFormats->getByKey(nNumberFormat);
+ sal_Int16 nType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ switch(nType)
+ {
+ case NumberFormat::DATE:
+ m_pUpdateHelper->updateDate(nPos,::dbtools::DBTypeConversion::toDate(fOutNumber,m_aNullDate));
+ break;
+ case NumberFormat::DATETIME:
+ m_pUpdateHelper->updateTimestamp(nPos,::dbtools::DBTypeConversion::toDateTime(fOutNumber,m_aNullDate));
+ break;
+ case NumberFormat::TIME:
+ m_pUpdateHelper->updateTime(nPos,::dbtools::DBTypeConversion::toTime(fOutNumber));
+ break;
+ default:
+ m_pUpdateHelper->updateDouble(nPos,fOutNumber);
+ }
+ }
+ catch(Exception&)
+ {
+ m_pUpdateHelper->updateString(nPos,m_sTextToken);
+ }
+ }
+
+ }
+ else
+ m_pUpdateHelper->updateString(nPos,m_sTextToken);
+ }
+ }
+ }
+ eraseTokens();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Int16 ODatabaseExport::CheckString(const String& aCheckToken, sal_Int16 _nOldNumberFormat)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::CheckString" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+ double fOutNumber = 0.0;
+ sal_Int16 nNumberFormat = 0;
+
+ try
+ {
+ Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ Reference< XNumberFormats > xFormats = xSupplier->getNumberFormats();
+
+ ensureFormatter();
+ if ( m_pFormatter && m_sNumToken.Len() )
+ {
+ LanguageType eNumLang;
+ sal_uInt32 nFormatKey(0);
+ fOutNumber = SfxHTMLParser::GetTableDataOptionsValNum(nFormatKey,eNumLang,m_sTextToken,m_sNumToken,*m_pFormatter);
+ if ( eNumLang != LANGUAGE_NONE )
+ {
+ nFormatKey = m_pFormatter->GetFormatForLanguageIfBuiltIn( nFormatKey, eNumLang );
+ m_pFormatter->IsNumberFormat( m_sTextToken, nFormatKey, fOutNumber );
+ }
+ Reference<XPropertySet> xProp = xFormats->getByKey(nFormatKey);
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nNumberFormat;
+ }
+ else
+ {
+ Reference<XNumberFormatTypes> xNumType(xFormats,UNO_QUERY);
+ sal_Int32 nFormatKey = m_xFormatter->detectNumberFormat(xNumType->getStandardFormat(NumberFormat::ALL,m_aLocale),aCheckToken);
+ fOutNumber = m_xFormatter->convertStringToNumber(nFormatKey,aCheckToken);
+
+ Reference<XPropertySet> xProp = xFormats->getByKey(nFormatKey);
+ sal_Int16 nType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nType;
+
+ switch(nType)
+ {
+ case NumberFormat::ALL:
+ nNumberFormat = NumberFormat::ALL;
+ break;
+ case NumberFormat::DEFINED:
+ nNumberFormat = NumberFormat::TEXT;
+ break;
+ case NumberFormat::DATE:
+ switch(_nOldNumberFormat)
+ {
+ case NumberFormat::DATETIME:
+ case NumberFormat::TEXT:
+ case NumberFormat::DATE:
+ nNumberFormat = _nOldNumberFormat;
+ break;
+ case NumberFormat::ALL:
+ nNumberFormat = NumberFormat::DATE;
+ break;
+ default:
+ nNumberFormat = NumberFormat::TEXT;
+
+ }
+ break;
+ case NumberFormat::TIME:
+ switch(_nOldNumberFormat)
+ {
+ case NumberFormat::DATETIME:
+ case NumberFormat::TEXT:
+ case NumberFormat::TIME:
+ nNumberFormat = _nOldNumberFormat;
+ break;
+ case NumberFormat::ALL:
+ nNumberFormat = NumberFormat::TIME;
+ break;
+ default:
+ nNumberFormat = NumberFormat::TEXT;
+ break;
+ }
+ break;
+ case NumberFormat::CURRENCY:
+ switch(_nOldNumberFormat)
+ {
+ case NumberFormat::NUMBER:
+ nNumberFormat = NumberFormat::CURRENCY;
+ break;
+ case NumberFormat::CURRENCY:
+ nNumberFormat = _nOldNumberFormat;
+ break;
+ case NumberFormat::ALL:
+ nNumberFormat = NumberFormat::CURRENCY;
+ break;
+ default:
+ nNumberFormat = NumberFormat::TEXT;
+ break;
+ }
+ break;
+ case NumberFormat::NUMBER:
+ case NumberFormat::SCIENTIFIC:
+ case NumberFormat::FRACTION:
+ case NumberFormat::PERCENT:
+ switch(_nOldNumberFormat)
+ {
+ case NumberFormat::NUMBER:
+ nNumberFormat = _nOldNumberFormat;
+ break;
+ case NumberFormat::CURRENCY:
+ nNumberFormat = NumberFormat::CURRENCY;
+ break;
+ case NumberFormat::ALL:
+ nNumberFormat = nType;
+ break;
+ default:
+ nNumberFormat = NumberFormat::TEXT;
+ break;
+ }
+ break;
+ case NumberFormat::TEXT:
+ case NumberFormat::UNDEFINED:
+ case NumberFormat::LOGICAL:
+ nNumberFormat = NumberFormat::TEXT; // Text "uberschreibt alles
+ break;
+ case NumberFormat::DATETIME:
+ switch(_nOldNumberFormat)
+ {
+ case NumberFormat::DATETIME:
+ case NumberFormat::TEXT:
+ case NumberFormat::TIME:
+ nNumberFormat = _nOldNumberFormat;
+ break;
+ case NumberFormat::ALL:
+ nNumberFormat = NumberFormat::DATETIME;
+ break;
+ default:
+ nNumberFormat = NumberFormat::TEXT;
+ break;
+ }
+ break;
+ default:
+ OSL_ENSURE(0,"ODatabaseExport: Unbekanntes Format");
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ nNumberFormat = NumberFormat::TEXT; // Text "uberschreibt alles
+ }
+
+ return nNumberFormat;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::SetColumnTypes(const TColumnVector* _pList,const OTypeInfoMap* _pInfoMap)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::SetColumnTypes" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+ if(_pList && _pInfoMap)
+ {
+ OSL_ENSURE(m_vNumberFormat.size() == m_vColumnSize.size() && m_vColumnSize.size() == _pList->size(),"Illegal columns in list");
+ Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ Reference< XNumberFormats > xFormats = xSupplier->getNumberFormats();
+ TColumnVector::const_iterator aIter = _pList->begin();
+ TColumnVector::const_iterator aEnd = _pList->end();
+ for(sal_Int32 i= 0;aIter != aEnd && (i) < static_cast<sal_Int32>(m_vNumberFormat.size()) && (i) < static_cast<sal_Int32>(m_vColumnSize.size()) ;++aIter,++i)
+ {
+ sal_Int32 nDataType;
+ sal_Int32 nLength(0),nScale(0);
+ sal_Int16 nType = m_vNumberFormat[i] & ~NumberFormat::DEFINED;
+
+ switch ( nType )
+ {
+ case NumberFormat::ALL:
+ nDataType = DataType::DOUBLE;
+ break;
+ case NumberFormat::DEFINED:
+ nDataType = DataType::VARCHAR;
+ nLength = ((m_vColumnSize[i] % 10 ) ? m_vColumnSize[i]/ 10 + 1: m_vColumnSize[i]/ 10) * 10;
+ break;
+ case NumberFormat::DATE:
+ nDataType = DataType::DATE;
+ break;
+ case NumberFormat::TIME:
+ nDataType = DataType::TIME;
+ break;
+ case NumberFormat::DATETIME:
+ nDataType = DataType::TIMESTAMP;
+ break;
+ case NumberFormat::CURRENCY:
+ nDataType = DataType::NUMERIC;
+ nScale = 4;
+ nLength = 19;
+ break;
+ case NumberFormat::NUMBER:
+ case NumberFormat::SCIENTIFIC:
+ case NumberFormat::FRACTION:
+ case NumberFormat::PERCENT:
+ nDataType = DataType::DOUBLE;
+ break;
+ case NumberFormat::TEXT:
+ case NumberFormat::UNDEFINED:
+ case NumberFormat::LOGICAL:
+ default:
+ nDataType = DataType::VARCHAR;
+ nLength = ((m_vColumnSize[i] % 10 ) ? m_vColumnSize[i]/ 10 + 1: m_vColumnSize[i]/ 10) * 10;
+ break;
+ }
+ OTypeInfoMap::const_iterator aFind = _pInfoMap->find(nDataType);
+ if(aFind != _pInfoMap->end())
+ {
+ (*aIter)->second->SetType(aFind->second);
+ (*aIter)->second->SetPrecision(::std::min<sal_Int32>(aFind->second->nPrecision,nLength));
+ (*aIter)->second->SetScale(::std::min<sal_Int32>(aFind->second->nMaximumScale,nScale));
+
+ sal_Int32 nFormatKey = ::dbtools::getDefaultNumberFormat( nDataType,
+ (*aIter)->second->GetScale(),
+ (*aIter)->second->IsCurrency(),
+ Reference< XNumberFormatTypes>(xFormats,UNO_QUERY),
+ m_aLocale);
+
+ (*aIter)->second->SetFormatKey(nFormatKey);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::CreateDefaultColumn(const ::rtl::OUString& _rColumnName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::CreateDefaultColumn" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+ Reference< XDatabaseMetaData> xDestMetaData(m_xConnection->getMetaData());
+ sal_Int32 nMaxNameLen(xDestMetaData->getMaxColumnNameLength());
+ ::rtl::OUString aAlias = _rColumnName;
+ if ( isSQL92CheckEnabled(m_xConnection) )
+ aAlias = ::dbtools::convertName2SQLName(_rColumnName,xDestMetaData->getExtraNameCharacters());
+
+ if(nMaxNameLen && aAlias.getLength() > nMaxNameLen)
+ aAlias = aAlias.copy(0, ::std::min<sal_Int32>( nMaxNameLen-1, aAlias.getLength() ) );
+
+ ::rtl::OUString sName(aAlias);
+ if(m_aDestColumns.find(sName) != m_aDestColumns.end())
+ {
+ sal_Int32 nPos = 0;
+ sal_Int32 nCount = 2;
+ while(m_aDestColumns.find(sName) != m_aDestColumns.end())
+ {
+ sName = aAlias;
+ sName += ::rtl::OUString::valueOf(++nPos);
+ if(nMaxNameLen && sName.getLength() > nMaxNameLen)
+ {
+ aAlias = aAlias.copy(0,::std::min<sal_Int32>( nMaxNameLen-nCount, aAlias.getLength() ));
+ sName = aAlias;
+ sName += ::rtl::OUString::valueOf(nPos);
+ ++nCount;
+ }
+ }
+ }
+ aAlias = sName;
+ // now create a column
+ OFieldDescription* pField = new OFieldDescription();
+ pField->SetType(m_pTypeInfo);
+ pField->SetName(aAlias);
+ pField->SetPrecision(::std::min<sal_Int32>((sal_Int32)255,m_pTypeInfo->nPrecision));
+ pField->SetScale(0);
+ pField->SetIsNullable(ColumnValue::NULLABLE);
+ pField->SetAutoIncrement(sal_False);
+ pField->SetPrimaryKey(sal_False);
+ pField->SetCurrency(sal_False);
+
+ TColumns::iterator aFind = m_aDestColumns.find( aAlias );
+ if ( aFind != m_aDestColumns.end() )
+ {
+ delete aFind->second;
+ m_aDestColumns.erase(aFind);
+ }
+
+ m_vDestVector.push_back(m_aDestColumns.insert(TColumns::value_type(aAlias,pField)).first);
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseExport::createRowSet()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::createRowSet" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+ m_pUpdateHelper.reset(new OParameterUpdateHelper(createPreparedStatment(m_xConnection->getMetaData(),m_xTable,m_vColumns)));
+
+ return m_pUpdateHelper.get() != NULL;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseExport::executeWizard(const ::rtl::OUString& _rTableName,const Any& _aTextColor,const FontDescriptor& _rFont)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::executeWizard" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+
+ bool bHaveDefaultTable = ( m_sDefaultTableName.getLength() != 0 );
+ ::rtl::OUString sTableName( bHaveDefaultTable ? m_sDefaultTableName : _rTableName );
+ OCopyTableWizard aWizard(
+ NULL,
+ sTableName,
+ bHaveDefaultTable ? CopyTableOperation::AppendData : CopyTableOperation::CopyDefinitionAndData,
+ m_aDestColumns,
+ m_vDestVector,
+ m_xConnection,
+ m_xFormatter,
+ getTypeSelectionPageFactory(),
+ m_rInputStream,
+ m_xFactory
+ );
+
+ sal_Bool bError = sal_False;
+ try
+ {
+ if (aWizard.Execute())
+ {
+ switch(aWizard.getOperation())
+ {
+ case CopyTableOperation::CopyDefinitionAndData:
+ case CopyTableOperation::AppendData:
+ {
+ m_xTable = aWizard.createTable();
+ bError = !m_xTable.is();
+ if(m_xTable.is())
+ {
+ m_xTable->setPropertyValue(PROPERTY_FONT,makeAny(_rFont));
+ if(_aTextColor.hasValue())
+ m_xTable->setPropertyValue(PROPERTY_TEXTCOLOR,_aTextColor);
+ }
+ m_bIsAutoIncrement = aWizard.shouldCreatePrimaryKey();
+ m_vColumns = aWizard.GetColumnPositions();
+ m_vColumnTypes = aWizard.GetColumnTypes();
+ m_bAppendFirstLine = !aWizard.UseHeaderLine();
+ }
+ break;
+ default:
+ bError = sal_True; // there is no error but I have nothing more to do
+ }
+ }
+ else
+ bError = sal_True;
+
+ if(!bError)
+ bError = !createRowSet();
+ }
+ catch( const SQLException&)
+ {
+ ::dbaui::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), &aWizard, m_xFactory );
+ bError = sal_True;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return bError;
+}
+//---------------------------------------------------------------------------------
+void ODatabaseExport::showErrorDialog(const ::com::sun::star::sdbc::SQLException& e)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::showErrorDialog" );
+ if(!m_bDontAskAgain)
+ {
+ String aMsg(e.Message);
+ aMsg += '\n';
+ aMsg += String( ModuleRes( STR_QRY_CONTINUE ) );
+ OSQLWarningBox aBox( NULL, aMsg, WB_YES_NO | WB_DEF_NO );
+
+ if (aBox.Execute() == RET_YES)
+ m_bDontAskAgain = sal_True;
+ else
+ m_bError = sal_True;
+ } // if(!m_bDontAskAgain)
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::adjustFormat()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::adjustFormat" );
+ if ( m_sTextToken.Len() )
+ {
+ sal_Int32 nNewPos = m_bIsAutoIncrement ? m_nColumnPos+1 : m_nColumnPos;
+ OSL_ENSURE((nNewPos) < static_cast<sal_Int32>(m_vColumns.size()),"Illegal index for vector");
+ if ( (nNewPos) < static_cast<sal_Int32>(m_vColumns.size()) )
+ {
+ sal_Int32 nColPos = m_vColumns[nNewPos].first;
+ if( nColPos != sal::static_int_cast< long >(CONTAINER_ENTRY_NOTFOUND))
+ {
+ --nColPos;
+ OSL_ENSURE((nColPos) < static_cast<sal_Int32>(m_vNumberFormat.size()),"m_vFormatKey: Illegal index for vector");
+ OSL_ENSURE((nColPos) < static_cast<sal_Int32>(m_vColumnSize.size()),"m_vColumnSize: Illegal index for vector");
+ m_vNumberFormat[nColPos] = CheckString(m_sTextToken,m_vNumberFormat[nColPos]);
+ m_vColumnSize[nColPos] = ::std::max<sal_Int32>((sal_Int32)m_vColumnSize[nColPos],(sal_Int32)m_sTextToken.Len());
+ }
+ }
+ eraseTokens();
+ }
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::eraseTokens()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::eraseTokens" );
+ m_sTextToken.Erase();
+ m_sNumToken.Erase();
+ m_sValToken.Erase();
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::ensureFormatter()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::ensureFormatter" );
+ if ( !m_pFormatter )
+ {
+ Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
+ SvNumberFormatsSupplierObj* pSupplierImpl = (SvNumberFormatsSupplierObj*)sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+ m_pFormatter = pSupplierImpl ? pSupplierImpl->GetNumberFormatter() : NULL;
+ Reference<XPropertySet> xNumberFormatSettings = xSupplier->getNumberFormatSettings();
+ xNumberFormatSettings->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NullDate"))) >>= m_aNullDate;
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< XPreparedStatement > ODatabaseExport::createPreparedStatment( const Reference<XDatabaseMetaData>& _xMetaData
+ ,const Reference<XPropertySet>& _xDestTable
+ ,const TPositions& _rvColumns)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::createPreparedStatment" );
+ ::rtl::OUString aSql(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INSERT INTO ")));
+ ::rtl::OUString sComposedTableName = ::dbtools::composeTableName( _xMetaData, _xDestTable, ::dbtools::eInDataManipulation, false, false, true );
+
+ aSql += sComposedTableName;
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ( "));
+ // set values and column names
+ ::rtl::OUString aValues(RTL_CONSTASCII_USTRINGPARAM(" VALUES ( "));
+ static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,"));
+ static ::rtl::OUString aComma(RTL_CONSTASCII_USTRINGPARAM(","));
+
+ ::rtl::OUString aQuote;
+ if ( _xMetaData.is() )
+ aQuote = _xMetaData->getIdentifierQuoteString();
+
+ Reference<XColumnsSupplier> xDestColsSup(_xDestTable,UNO_QUERY_THROW);
+
+ // create sql string and set column types
+ Sequence< ::rtl::OUString> aDestColumnNames = xDestColsSup->getColumns()->getElementNames();
+ if ( aDestColumnNames.getLength() == 0 )
+ {
+ return Reference< XPreparedStatement > ();
+ }
+ const ::rtl::OUString* pIter = aDestColumnNames.getConstArray();
+ ::std::vector< ::rtl::OUString> aInsertList;
+ aInsertList.resize(aDestColumnNames.getLength()+1);
+ sal_Int32 i = 0;
+ for(sal_uInt32 j=0; j < aInsertList.size() ;++i,++j)
+ {
+ ODatabaseExport::TPositions::const_iterator aFind = ::std::find_if(_rvColumns.begin(),_rvColumns.end(),
+ ::std::compose1(::std::bind2nd(::std::equal_to<sal_Int32>(),i+1),::std::select2nd<ODatabaseExport::TPositions::value_type>()));
+ if ( _rvColumns.end() != aFind && aFind->second != sal::static_int_cast< long >(CONTAINER_ENTRY_NOTFOUND) && aFind->first != sal::static_int_cast< long >(CONTAINER_ENTRY_NOTFOUND) )
+ {
+ OSL_ENSURE((aFind->first) < static_cast<sal_Int32>(aInsertList.size()),"aInsertList: Illegal index for vector");
+ aInsertList[aFind->first] = ::dbtools::quoteName( aQuote,*(pIter+i));
+ }
+ }
+
+ i = 1;
+ // create the sql string
+ ::std::vector< ::rtl::OUString>::iterator aInsertEnd = aInsertList.end();
+ for (::std::vector< ::rtl::OUString>::iterator aInsertIter = aInsertList.begin(); aInsertIter != aInsertEnd; ++aInsertIter)
+ {
+ if ( aInsertIter->getLength() )
+ {
+ aSql += *aInsertIter;
+ aSql += aComma;
+ aValues += aPara;
+ }
+ }
+
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
+ aValues = aValues.replaceAt(aValues.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
+
+ aSql += aValues;
+ // now create,fill and execute the prepared statement
+ return Reference< XPreparedStatement >(_xMetaData->getConnection()->prepareStatement(aSql));
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/dbaccess/source/ui/misc/HtmlReader.cxx b/dbaccess/source/ui/misc/HtmlReader.cxx
new file mode 100644
index 000000000000..d787d19a3305
--- /dev/null
+++ b/dbaccess/source/ui/misc/HtmlReader.cxx
@@ -0,0 +1,598 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#include "HtmlReader.hxx"
+#include <connectivity/dbconversion.hxx>
+#include <connectivity/dbtools.hxx>
+#include <tools/tenccvt.hxx>
+#include <comphelper/extract.hxx>
+#include "dbu_misc.hrc"
+#include "dbustrings.hrc"
+#include <sfx2/sfxhtml.hxx>
+#include <tools/debug.hxx>
+#include <tools/tenccvt.hxx>
+#include "moduledbu.hxx"
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <svtools/htmltokn.h>
+#include <svtools/htmlkywd.hxx>
+#include <tools/color.hxx>
+#include "WCopyTable.hxx"
+#include "WExtendPages.hxx"
+#include "WNameMatch.hxx"
+#include "WColumnSelect.hxx"
+#include "QEnumTypes.hxx"
+#include "WCPage.hxx"
+#include <tools/inetmime.hxx>
+#include <svl/inettype.hxx>
+#include <rtl/tencinfo.h>
+#include "UITools.hxx"
+#include <vcl/svapp.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::awt;
+
+#define DBAUI_HTML_FONTSIZES 8 // wie Export, HTML-Options
+#define HTML_META_NONE 0
+#define HTML_META_AUTHOR 1
+#define HTML_META_DESCRIPTION 2
+#define HTML_META_KEYWORDS 3
+#define HTML_META_REFRESH 4
+#define HTML_META_CLASSIFICATION 5
+#define HTML_META_CREATED 6
+#define HTML_META_CHANGEDBY 7
+#define HTML_META_CHANGED 8
+#define HTML_META_GENERATOR 9
+#define HTML_META_SDFOOTNOTE 10
+#define HTML_META_SDENDNOTE 11
+#define HTML_META_CONTENT_TYPE 12
+
+// ==========================================================================
+DBG_NAME(OHTMLReader)
+// ==========================================================================
+// OHTMLReader
+// ==========================================================================
+OHTMLReader::OHTMLReader(SvStream& rIn,const SharedConnection& _rxConnection,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap)
+ :HTMLParser(rIn)
+ ,ODatabaseExport( _rxConnection, _rxNumberF, _rM, pList, _pInfoMap, rIn )
+ ,m_nTableCount(0)
+ ,m_nColumnWidth(87)
+ ,m_bMetaOptions(sal_False)
+ ,m_bSDNum(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::OHTMLReader" );
+ DBG_CTOR(OHTMLReader,NULL);
+ SetSrcEncoding( GetExtendedCompatibilityTextEncoding( RTL_TEXTENCODING_ISO_8859_1 ) );
+ // If the file starts with a BOM, switch to UCS2.
+ SetSwitchToUCS2( sal_True );
+}
+// ---------------------------------------------------------------------------
+OHTMLReader::OHTMLReader(SvStream& rIn,
+ sal_Int32 nRows,
+ const TPositions &_rColumnPositions,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap,
+ sal_Bool _bAutoIncrementEnabled)
+ :HTMLParser(rIn)
+ ,ODatabaseExport( nRows, _rColumnPositions, _rxNumberF, _rM, pList, _pInfoMap, _bAutoIncrementEnabled, rIn )
+ ,m_nTableCount(0)
+ ,m_nColumnWidth(87)
+ ,m_bMetaOptions(sal_False)
+ ,m_bSDNum(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::OHTMLReader" );
+ DBG_CTOR(OHTMLReader,NULL);
+ SetSrcEncoding( GetExtendedCompatibilityTextEncoding( RTL_TEXTENCODING_ISO_8859_1 ) );
+ // If the file starts with a BOM, switch to UCS2.
+ SetSwitchToUCS2( sal_True );
+}
+// ---------------------------------------------------------------------------
+OHTMLReader::~OHTMLReader()
+{
+ DBG_DTOR(OHTMLReader,NULL);
+}
+// ---------------------------------------------------------------------------
+SvParserState OHTMLReader::CallParser()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::CallParser" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ rInput.Seek(STREAM_SEEK_TO_BEGIN);
+ rInput.ResetError();
+ SvParserState eParseState = HTMLParser::CallParser();
+ SetColumnTypes(m_pColumnList,m_pInfoMap);
+ return m_bFoundTable ? eParseState : SVPAR_ERROR;
+}
+// -----------------------------------------------------------------------------
+void OHTMLReader::NextToken( int nToken )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::NextToken" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ if(m_bError || !m_nRows) // falls Fehler oder keine Rows mehr zur "Uberpr"ufung dann gleich zur"uck
+ return;
+ if ( nToken == HTML_META )
+ setTextEncoding();
+
+ if(m_xConnection.is()) // gibt an welcher CTOR gerufen wurde und damit, ob eine Tabelle erstellt werden soll
+ {
+ switch(nToken)
+ {
+ case HTML_TABLE_ON:
+ ++m_nTableCount;
+ { // es kann auch TD oder TH sein, wenn es vorher kein TABLE gab
+ const HTMLOptions* pHtmlOptions = GetOptions();
+ sal_Int16 nArrLen = pHtmlOptions->Count();
+ for ( sal_Int16 i = 0; i < nArrLen; i++ )
+ {
+ const HTMLOption* pOption = (*pHtmlOptions)[i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_WIDTH:
+ { // Prozent: von Dokumentbreite bzw. aeusserer Zelle
+ m_nColumnWidth = GetWidthPixel( pOption );
+ }
+ break;
+ }
+ }
+ }
+ case HTML_THEAD_ON:
+ case HTML_TBODY_ON:
+ {
+ sal_uInt32 nTell = rInput.Tell(); // verändert vielleicht die Position des Streams
+ if ( !m_xTable.is() )
+ {// erste Zeile als Header verwenden
+ m_bError = !CreateTable(nToken);
+ if ( m_bAppendFirstLine )
+ rInput.Seek(nTell);
+ }
+ }
+ break;
+ case HTML_TABLE_OFF:
+ if(!--m_nTableCount)
+ {
+ m_xTable = NULL;
+ }
+ break;
+ case HTML_TABLEROW_ON:
+ if ( m_pUpdateHelper.get() )
+ {
+ try
+ {
+ m_pUpdateHelper->moveToInsertRow(); // sonst neue Zeile anh"angen
+ }
+ catch(SQLException& e)
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ }
+ else
+ m_bError = sal_True;
+ break;
+ case HTML_TEXTTOKEN:
+ case HTML_SINGLECHAR:
+ if ( m_bInTbl ) //&& !m_bSDNum ) // wichtig, da wir sonst auch die Namen der Fonts bekommen
+ m_sTextToken += aToken;
+ break;
+ case HTML_PARABREAK_OFF:
+ m_sCurrent += m_sTextToken;
+ break;
+ case HTML_PARABREAK_ON:
+ m_sTextToken.Erase();
+ break;
+ case HTML_TABLEDATA_ON:
+ fetchOptions();
+ break;
+ case HTML_TABLEDATA_OFF:
+ {
+ if ( m_sCurrent.Len() )
+ m_sTextToken = m_sCurrent;
+ try
+ {
+ insertValueIntoColumn();
+ }
+ catch(SQLException& e)
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ m_sCurrent.Erase();
+ m_nColumnPos++;
+ eraseTokens();
+ m_bSDNum = m_bInTbl = sal_False;
+ }
+ break;
+ case HTML_TABLEROW_OFF:
+ if ( !m_pUpdateHelper.get() )
+ {
+ m_bError = sal_True;
+ break;
+ }
+ try
+ {
+ m_nRowCount++;
+ if (m_bIsAutoIncrement) // if bSetAutoIncrement then I have to set the autoincrement
+ m_pUpdateHelper->updateInt(1,m_nRowCount);
+ m_pUpdateHelper->insertRow();
+ }
+ catch(SQLException& e)
+ //////////////////////////////////////////////////////////////////////
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ m_nColumnPos = 0;
+ break;
+ }
+ }
+ else // Zweig nur f"ur Typpr"ufung g"ultig
+ {
+ switch(nToken)
+ {
+ case HTML_THEAD_ON:
+ case HTML_TBODY_ON:
+ // Der Spalten Kopf z"ahlt nicht mit
+ if(m_bHead)
+ {
+ do
+ {}
+ while(GetNextToken() != HTML_TABLEROW_OFF);
+ m_bHead = sal_False;
+ }
+ break;
+ case HTML_TABLEDATA_ON:
+ case HTML_TABLEHEADER_ON:
+ fetchOptions();
+ break;
+ case HTML_TEXTTOKEN:
+ case HTML_SINGLECHAR:
+ if ( m_bInTbl ) // && !m_bSDNum ) // wichtig, da wir sonst auch die Namen der Fonts bekommen
+ m_sTextToken += aToken;
+ break;
+ case HTML_PARABREAK_OFF:
+ m_sCurrent += m_sTextToken;
+ break;
+ case HTML_PARABREAK_ON:
+ m_sTextToken.Erase();
+ break;
+ case HTML_TABLEDATA_OFF:
+ if ( m_sCurrent.Len() )
+ m_sTextToken = m_sCurrent;
+ adjustFormat();
+ m_nColumnPos++;
+ m_bSDNum = m_bInTbl = sal_False;
+ m_sCurrent.Erase();
+ break;
+ case HTML_TABLEROW_OFF:
+ if ( m_sCurrent.Len() )
+ m_sTextToken = m_sCurrent;
+ adjustFormat();
+ m_nColumnPos = 0;
+ m_nRows--;
+ m_sCurrent.Erase();
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OHTMLReader::fetchOptions()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::fetchOptions" );
+ m_bInTbl = sal_True;
+ const HTMLOptions* options = GetOptions();
+ sal_Int16 nArrLen = options->Count();
+ for ( sal_Int16 i = 0; i < nArrLen; i++ )
+ {
+ const HTMLOption* pOption = (*options)[i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_SDVAL:
+ {
+ m_sValToken = pOption->GetString();
+ //m_sTextToken = pOption->GetString();
+ m_bSDNum = sal_True;
+ }
+ break;
+ case HTML_O_SDNUM:
+ m_sNumToken = pOption->GetString();
+ break;
+ }
+ }
+}
+//---------------------------------------------------------------------------------
+void OHTMLReader::TableDataOn(SvxCellHorJustify& eVal,int nToken)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::TableDataOn" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ sal_Bool bHorJustifyCenterTH = (nToken == HTML_TABLEHEADER_ON);
+ const HTMLOptions* pHtmlOptions = GetOptions();
+ sal_Int16 nArrLen = pHtmlOptions->Count();
+ for ( sal_Int16 i = 0; i < nArrLen; i++ )
+ {
+ const HTMLOption* pOption = (*pHtmlOptions)[i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ALIGN:
+ {
+ bHorJustifyCenterTH = sal_False;
+ const String& rOptVal = pOption->GetString();
+ if (rOptVal.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_right ))
+ eVal = SVX_HOR_JUSTIFY_RIGHT;
+ else if (rOptVal.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_center ))
+ eVal = SVX_HOR_JUSTIFY_CENTER;
+ else if (rOptVal.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_left ))
+ eVal = SVX_HOR_JUSTIFY_LEFT;
+ else
+ eVal = SVX_HOR_JUSTIFY_STANDARD;
+ }
+ break;
+ case HTML_O_WIDTH:
+ m_nWidth = GetWidthPixel( pOption );
+ break;
+ }
+ }
+}
+
+//---------------------------------------------------------------------------------
+void OHTMLReader::TableFontOn(FontDescriptor& _rFont,sal_Int32 &_rTextColor)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::TableFontOn" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ const HTMLOptions* pHtmlOptions = GetOptions();
+ sal_Int16 nArrLen = pHtmlOptions->Count();
+ for ( sal_Int16 i = 0; i < nArrLen; i++ )
+ {
+ const HTMLOption* pOption = (*pHtmlOptions)[i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_COLOR:
+ {
+ Color aColor;
+ pOption->GetColor( aColor );
+ _rTextColor = aColor.GetRGBColor();
+ }
+ break;
+ case HTML_O_FACE :
+ {
+ const String& rFace = pOption->GetString();
+ String aFontName;
+ xub_StrLen nPos = 0;
+ while( nPos != STRING_NOTFOUND )
+ { // Fontliste, VCL: Semikolon als Separator, HTML: Komma
+ String aFName = rFace.GetToken( 0, ',', nPos );
+ aFName.EraseTrailingChars().EraseLeadingChars();
+ if( aFontName.Len() )
+ aFontName += ';';
+ aFontName += aFName;
+ }
+ if ( aFontName.Len() )
+ _rFont.Name = ::rtl::OUString(aFontName);
+ }
+ break;
+ case HTML_O_SIZE :
+ {
+ sal_Int16 nSize = (sal_Int16) pOption->GetNumber();
+ if ( nSize == 0 )
+ nSize = 1;
+ else if ( nSize < DBAUI_HTML_FONTSIZES )
+ nSize = DBAUI_HTML_FONTSIZES;
+
+ _rFont.Height = nSize;
+ }
+ break;
+ }
+ }
+}
+// ---------------------------------------------------------------------------
+sal_Int16 OHTMLReader::GetWidthPixel( const HTMLOption* pOption )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::GetWidthPixel" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ const String& rOptVal = pOption->GetString();
+ if ( rOptVal.Search('%') != STRING_NOTFOUND )
+ { // Prozent
+ DBG_ASSERT( m_nColumnWidth, "WIDTH Option: m_nColumnWidth==0 und Width%" );
+ return (sal_Int16)((pOption->GetNumber() * m_nColumnWidth) / 100);
+ }
+ else
+ {
+ if ( rOptVal.Search('*') != STRING_NOTFOUND )
+ { // relativ zu was?!?
+//2do: ColArray aller relativen Werte sammeln und dann MakeCol
+ return 0;
+ }
+ else
+ return (sal_Int16)pOption->GetNumber(); // Pixel
+ }
+}
+// ---------------------------------------------------------------------------
+sal_Bool OHTMLReader::CreateTable(int nToken)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::CreateTable" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ String aTempName(ModuleRes(STR_TBL_TITLE));
+ aTempName = aTempName.GetToken(0,' ');
+ aTempName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTempName )));
+
+ int nTmpToken2 = nToken;
+ sal_Bool bCaption = sal_False;
+ sal_Bool bTableHeader = sal_False;
+ String aColumnName;
+ SvxCellHorJustify eVal;
+
+ String aTableName;
+ FontDescriptor aFont = ::dbaui::CreateFontDescriptor(Application::GetSettings().GetStyleSettings().GetAppFont());
+ sal_Int32 nTextColor = 0;
+ do
+ {
+ switch(nTmpToken2)
+ {
+ case HTML_TEXTTOKEN:
+ case HTML_SINGLECHAR:
+ if(bTableHeader)
+ aColumnName += aToken;
+ if(bCaption)
+ aTableName += aToken;
+ break;
+ case HTML_PARABREAK_OFF:
+ m_sCurrent += aColumnName;
+ break;
+ case HTML_PARABREAK_ON:
+ m_sTextToken.Erase();
+ break;
+ case HTML_TABLEDATA_ON:
+ // m_bAppendFirstLine = true;
+ // run through
+ case HTML_TABLEHEADER_ON:
+ TableDataOn(eVal,nTmpToken2);
+ bTableHeader = sal_True;
+ break;
+ case HTML_TABLEDATA_OFF:
+ // m_bAppendFirstLine = true;
+ // run through
+ case HTML_TABLEHEADER_OFF:
+ {
+ aColumnName.EraseLeadingChars();
+ aColumnName.EraseTrailingChars();
+ if (!aColumnName.Len() || m_bAppendFirstLine )
+ aColumnName = String(ModuleRes(STR_COLUMN_NAME));
+ else if ( m_sCurrent.Len() )
+ aColumnName = m_sCurrent;
+
+ aColumnName.EraseLeadingChars();
+ aColumnName.EraseTrailingChars();
+ CreateDefaultColumn(aColumnName);
+ aColumnName.Erase();
+ m_sCurrent.Erase();
+
+ eVal = SVX_HOR_JUSTIFY_STANDARD;
+ bTableHeader = sal_False;
+ }
+ break;
+
+ case HTML_TITLE_ON:
+ case HTML_CAPTION_ON:
+ bCaption = sal_True;
+ break;
+ case HTML_TITLE_OFF:
+ case HTML_CAPTION_OFF:
+ aTableName.EraseLeadingChars();
+ aTableName.EraseTrailingChars();
+ if(!aTableName.Len())
+ aTableName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTableName)));
+ else
+ aTableName = aTempName;
+ bCaption = sal_False;
+ break;
+ case HTML_FONT_ON:
+ TableFontOn(aFont,nTextColor);
+ break;
+ case HTML_BOLD_ON:
+ aFont.Weight = ::com::sun::star::awt::FontWeight::BOLD;
+ break;
+ case HTML_ITALIC_ON:
+ aFont.Slant = ::com::sun::star::awt::FontSlant_ITALIC;
+ break;
+ case HTML_UNDERLINE_ON:
+ aFont.Underline = ::com::sun::star::awt::FontUnderline::SINGLE;
+ break;
+ case HTML_STRIKE_ON:
+ aFont.Strikeout = ::com::sun::star::awt::FontStrikeout::SINGLE;
+ break;
+ }
+ }
+ while((nTmpToken2 = GetNextToken()) != HTML_TABLEROW_OFF);
+
+ if ( m_sCurrent.Len() )
+ aColumnName = m_sCurrent;
+ aColumnName.EraseLeadingChars();
+ aColumnName.EraseTrailingChars();
+ if(aColumnName.Len())
+ CreateDefaultColumn(aColumnName);
+
+ if ( m_vDestVector.empty() )
+ return sal_False;
+
+ if(!aTableName.Len())
+ aTableName = aTempName;
+
+ m_bInTbl = sal_False;
+ m_bFoundTable = sal_True;
+
+ if ( isCheckEnabled() )
+ return sal_True;
+
+ return !executeWizard(aTableName,makeAny(nTextColor),aFont) && m_xTable.is();
+}
+// -----------------------------------------------------------------------------
+void OHTMLReader::setTextEncoding()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::setTextEncoding" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ m_bMetaOptions = sal_True;
+ ParseMetaOptions(NULL, NULL);
+}
+
+// -----------------------------------------------------------------------------
+void OHTMLReader::release()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::release" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ ReleaseRef();
+}
+// -----------------------------------------------------------------------------
+TypeSelectionPageFactory OHTMLReader::getTypeSelectionPageFactory()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::getTypeSelectionPageFactory" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ return &OWizHTMLExtend::Create;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/misc/ModuleHelper.cxx b/dbaccess/source/ui/misc/ModuleHelper.cxx
new file mode 100644
index 000000000000..aa0f11256f59
--- /dev/null
+++ b/dbaccess/source/ui/misc/ModuleHelper.cxx
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ OModule& getGlobalDbuModule()
+ {
+ static OModule s_aModule("dbu");
+ return s_aModule;
+ }
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx
new file mode 100644
index 000000000000..47e9c7788478
--- /dev/null
+++ b/dbaccess/source/ui/misc/RowSetDrop.cxx
@@ -0,0 +1,273 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "TokenWriter.hxx"
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include "dbu_misc.hrc"
+#include "sqlmessage.hxx"
+#include <vcl/msgbox.hxx>
+#include "dbustrings.hrc"
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <functional>
+#include <rtl/logfile.hxx>
+
+using namespace dbaui;
+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::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::lang;
+// using namespace ::com::sun::star::sdbcx;
+
+// export data
+ORowSetImportExport::ORowSetImportExport( Window* _pParent,
+ const Reference< XResultSetUpdate >& _xResultSetUpdate,
+ const ::svx::ODataAccessDescriptor& _aDataDescriptor,
+ const Reference< XMultiServiceFactory >& _rM,
+ const String& rExchange
+ )
+ : ODatabaseImportExport(_aDataDescriptor,_rM,NULL,rExchange)
+ ,m_xTargetResultSetUpdate(_xResultSetUpdate)
+ ,m_xTargetRowUpdate(_xResultSetUpdate,UNO_QUERY)
+ ,m_pParent(_pParent)
+ ,m_bAlreadyAsked(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORowSetImportExport::ORowSetImportExport" );
+ OSL_ENSURE(_pParent,"Window can't be null!");
+}
+// -----------------------------------------------------------------------------
+void ORowSetImportExport::initialize()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORowSetImportExport::initialize" );
+ ODatabaseImportExport::initialize();
+ // do namemapping
+ Reference<XColumnLocate> xColumnLocate(m_xResultSet,UNO_QUERY);
+ OSL_ENSURE(xColumnLocate.is(),"The rowset normally should support this");
+
+ m_xTargetResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xTargetResultSetUpdate,UNO_QUERY)->getMetaData();
+ if(!m_xTargetResultSetMetaData.is() || !xColumnLocate.is() || !m_xResultSetMetaData.is() )
+ throw SQLException(String(ModuleRes(STR_UNEXPECTED_ERROR)),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any());
+
+ sal_Int32 nCount = m_xTargetResultSetMetaData->getColumnCount();
+ m_aColumnMapping.reserve(nCount);
+ m_aColumnTypes.reserve(nCount);
+ for (sal_Int32 i = 1;i <= nCount; ++i)
+ {
+ sal_Int32 nPos = -1; // -1 means column is autoincrement or doesn't exists
+ if(!m_xTargetResultSetMetaData->isAutoIncrement(i))
+ {
+ try
+ {
+ ::rtl::OUString sColumnName = m_xTargetResultSetMetaData->getColumnName(i);
+ nPos = xColumnLocate->findColumn(sColumnName);
+ }
+ catch(const SQLException&)
+ {
+ if(m_xTargetResultSetMetaData->isNullable(i))
+ nPos = 0; // column doesn't exists but we could set it to null
+ }
+ }
+
+ m_aColumnMapping.push_back(nPos);
+ if(nPos > 0)
+ m_aColumnTypes.push_back(m_xResultSetMetaData->getColumnType(nPos));
+ else
+ m_aColumnTypes.push_back(DataType::OTHER);
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetImportExport::Write()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORowSetImportExport::Write" );
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetImportExport::Read()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORowSetImportExport::Read" );
+ // check if there is any column to copy
+ if(::std::find_if(m_aColumnMapping.begin(),m_aColumnMapping.end(),
+ ::std::bind2nd(::std::greater<sal_Int32>(),0)) == m_aColumnMapping.end())
+ return sal_False;
+ sal_Int32 nCurrentRow = 0;
+ sal_Int32 nRowFilterIndex = 0;
+ sal_Bool bContinue = sal_True;
+ if(m_aSelection.getLength())
+ {
+ const Any* pBegin = m_aSelection.getConstArray();
+ const Any* pEnd = pBegin + m_aSelection.getLength();
+ for(;pBegin != pEnd && bContinue;++pBegin)
+ {
+ sal_Int32 nPos = -1;
+ *pBegin >>= nPos;
+ OSL_ENSURE(nPos != -1,"Invalid posiotion!");
+ bContinue = (m_xResultSet.is() && m_xResultSet->absolute(nPos) && insertNewRow());
+ }
+ }
+ else
+ {
+ Reference<XPropertySet> xProp(m_xResultSet,UNO_QUERY);
+ sal_Int32 nRowCount = 0;
+ if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISROWCOUNTFINAL) )
+ {
+ sal_Bool bFinal = sal_False;
+ xProp->getPropertyValue(PROPERTY_ISROWCOUNTFINAL) >>= bFinal;
+ if ( !bFinal )
+ m_xResultSet->afterLast();
+ xProp->getPropertyValue(PROPERTY_ROWCOUNT) >>= nRowCount;
+ }
+ if ( !nRowCount )
+ {
+ m_xResultSet->afterLast();
+ nRowCount = m_xResultSet->getRow();
+ }
+ OSL_ENSURE(nRowCount,"RowCount is 0!");
+ m_xResultSet->beforeFirst();
+ while(m_xResultSet.is() && m_xResultSet->next() && bContinue && nRowCount )
+ {
+ --nRowCount;
+ ++nCurrentRow;
+ if(!m_pRowMarker || m_pRowMarker[nRowFilterIndex] == nCurrentRow)
+ {
+ ++nRowFilterIndex;
+ bContinue = insertNewRow();
+ }
+ }
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetImportExport::insertNewRow()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORowSetImportExport::insertNewRow" );
+ try
+ {
+ m_xTargetResultSetUpdate->moveToInsertRow();
+ sal_Int32 i = 1;
+ ::std::vector<sal_Int32>::iterator aEnd = m_aColumnMapping.end();
+ for (::std::vector<sal_Int32>::iterator aIter = m_aColumnMapping.begin(); aIter != aEnd ;++aIter,++i )
+ {
+ if(*aIter > 0)
+ {
+ Any aValue;
+ switch(m_aColumnTypes[i-1])
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ aValue <<= m_xRow->getString(*aIter);
+ break;
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ aValue <<= m_xRow->getDouble(*aIter);
+ break;
+ case DataType::BIGINT:
+ aValue <<= m_xRow->getLong(*aIter);
+ break;
+ case DataType::FLOAT:
+ aValue <<= m_xRow->getFloat(*aIter);
+ break;
+ case DataType::DOUBLE:
+ aValue <<= m_xRow->getDouble(*aIter);
+ break;
+ case DataType::LONGVARCHAR:
+ aValue <<= m_xRow->getString(*aIter);
+ break;
+ case DataType::LONGVARBINARY:
+ aValue <<= m_xRow->getBytes(*aIter);
+ break;
+ case DataType::DATE:
+ aValue <<= m_xRow->getDate(*aIter);
+ break;
+ case DataType::TIME:
+ aValue <<= m_xRow->getTime(*aIter);
+ break;
+ case DataType::TIMESTAMP:
+ aValue <<= m_xRow->getTimestamp(*aIter);
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ aValue <<= m_xRow->getBoolean(*aIter);
+ break;
+ case DataType::TINYINT:
+ aValue <<= m_xRow->getByte(*aIter);
+ break;
+ case DataType::SMALLINT:
+ aValue <<= m_xRow->getShort(*aIter);
+ break;
+ case DataType::INTEGER:
+ aValue <<= m_xRow->getInt(*aIter);
+ break;
+ case DataType::REAL:
+ aValue <<= m_xRow->getDouble(*aIter);
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ aValue <<= m_xRow->getBytes(*aIter);
+ break;
+ case DataType::BLOB:
+ aValue <<= m_xRow->getBlob(*aIter);
+ break;
+ case DataType::CLOB:
+ aValue <<= m_xRow->getClob(*aIter);
+ break;
+ default:
+ OSL_ENSURE(0,"Unknown type");
+ }
+ if(m_xRow->wasNull())
+ m_xTargetRowUpdate->updateNull(i);
+ else
+ m_xTargetRowUpdate->updateObject(i,aValue);
+ }
+ else if(*aIter == 0)//now we have know that we to set this column to null
+ m_xTargetRowUpdate->updateNull(i);
+ }
+ m_xTargetResultSetUpdate->insertRow();
+ }
+ catch(const SQLException&)
+ {
+ if(!m_bAlreadyAsked)
+ {
+ String sAskIfContinue = String(ModuleRes(STR_ERROR_OCCURED_WHILE_COPYING));
+ OSQLWarningBox aDlg( m_pParent, sAskIfContinue, WB_YES_NO | WB_DEF_YES );
+ if(aDlg.Execute() == RET_YES)
+ m_bAlreadyAsked = sal_True;
+ else
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/dbaccess/source/ui/misc/RtfReader.cxx b/dbaccess/source/ui/misc/RtfReader.cxx
new file mode 100644
index 000000000000..6caa215c7543
--- /dev/null
+++ b/dbaccess/source/ui/misc/RtfReader.cxx
@@ -0,0 +1,377 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#include "RtfReader.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include "dbustrings.hrc"
+#include <svtools/rtftoken.h>
+#include "dbu_misc.hrc"
+#include <vcl/msgbox.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <connectivity/dbtools.hxx>
+#include <comphelper/extract.hxx>
+#include <tools/color.hxx>
+#include "WExtendPages.hxx"
+#include "moduledbu.hxx"
+#include "QEnumTypes.hxx"
+#include "UITools.hxx"
+#include <vcl/svapp.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::awt;
+
+DBG_NAME(ORTFReader)
+// ==========================================================================
+// ORTFReader
+// ==========================================================================
+ORTFReader::ORTFReader( SvStream& rIn,
+ const SharedConnection& _rxConnection,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap)
+ :SvRTFParser(rIn)
+ ,ODatabaseExport( _rxConnection, _rxNumberF, _rM, pList, _pInfoMap, rIn )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::ORTFReader" );
+ DBG_CTOR(ORTFReader,NULL);
+ m_bAppendFirstLine = false;
+}
+// ---------------------------------------------------------------------------
+ORTFReader::ORTFReader(SvStream& rIn,
+ sal_Int32 nRows,
+ const TPositions &_rColumnPositions,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap,
+ sal_Bool _bAutoIncrementEnabled)
+ :SvRTFParser(rIn)
+ ,ODatabaseExport( nRows, _rColumnPositions, _rxNumberF, _rM, pList, _pInfoMap, _bAutoIncrementEnabled, rIn )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::ORTFReader" );
+ DBG_CTOR(ORTFReader,NULL);
+ m_bAppendFirstLine = false;
+}
+// ---------------------------------------------------------------------------
+ORTFReader::~ORTFReader()
+{
+ DBG_DTOR(ORTFReader,NULL);
+}
+// ---------------------------------------------------------------------------
+SvParserState ORTFReader::CallParser()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::CallParser" );
+ DBG_CHKTHIS(ORTFReader,NULL);
+ rInput.Seek(STREAM_SEEK_TO_BEGIN);
+ rInput.ResetError();
+ SvParserState eParseState = SvRTFParser::CallParser();
+ SetColumnTypes(m_pColumnList,m_pInfoMap);
+ return m_bFoundTable ? eParseState : SVPAR_ERROR;
+}
+// ---------------------------------------------------------------------------
+void ORTFReader::NextToken( int nToken )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::NextToken" );
+ DBG_CHKTHIS(ORTFReader,NULL);
+ if(m_bError || !m_nRows) // falls Fehler oder keine Rows mehr zur "Uberpr"ufung dann gleich zur"uck
+ return;
+
+ if(m_xConnection.is()) // gibt an welcher CTOR gerufen wurde und damit, ob eine Tabelle erstellt werden soll
+ {
+ switch(nToken)
+ {
+ case RTF_COLORTBL:
+ {
+
+ int nTmpToken2 = GetNextToken();
+ sal_Bool bNext = sal_True;
+ do
+ {
+ Color aColor;
+ do
+ {
+ switch(nTmpToken2)
+ {
+ case RTF_RED: aColor.SetRed((sal_uInt8)nTokenValue); break;
+ case RTF_BLUE: aColor.SetBlue((sal_uInt8)nTokenValue); break;
+ case RTF_GREEN: aColor.SetGreen((sal_uInt8)nTokenValue); break;
+ default:
+ bNext = sal_False;
+ }
+ nTmpToken2 = GetNextToken();
+ }
+ while(aToken.GetChar(0) != ';' && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
+ m_vecColor.push_back(aColor.GetRGBColor());
+ nTmpToken2 = GetNextToken();
+ }
+ while(nTmpToken2 == RTF_RED && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
+ SkipToken();
+ }
+ break;
+
+ case RTF_DEFLANG:
+ case RTF_LANG: // Sprache abfragen
+ m_nDefToken = (rtl_TextEncoding)nTokenValue;
+ break;
+ case RTF_TROWD:
+ {
+ bool bInsertRow = true;
+ if ( !m_xTable.is() ) // erste Zeile als Header verwenden
+ {
+ sal_uInt32 nTell = rInput.Tell(); // verändert vielleicht die Position des Streams
+
+ m_bError = !CreateTable(nToken);
+ bInsertRow = m_bAppendFirstLine;
+ if ( m_bAppendFirstLine )
+ {
+ rInput.Seek(nTell);
+ rInput.ResetError();
+ }
+ }
+ if ( bInsertRow && !m_bError)
+ {
+ try
+ {
+ m_pUpdateHelper->moveToInsertRow(); // sonst neue Zeile anh"angen
+ }
+ catch(SQLException& e)
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ }
+ }
+ break;
+ case RTF_INTBL:
+ if(m_bInTbl)
+ {
+ eraseTokens();
+ }
+
+ m_bInTbl = sal_True; // jetzt befinden wir uns in einer Tabellenbeschreibung
+ break;
+ case RTF_TEXTTOKEN:
+ case RTF_SINGLECHAR:
+ if(m_bInTbl) // wichtig, da wir sonst auch die Namen der Fonts bekommen
+ m_sTextToken += aToken;
+ break;
+ case RTF_CELL:
+ {
+ try
+ {
+ insertValueIntoColumn();
+ }
+ catch(SQLException& e)
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ m_nColumnPos++;
+ eraseTokens();
+ }
+ break;
+ case RTF_ROW:
+ // es kann vorkommen, daß die letzte Celle nicht mit \cell abgeschlossen ist
+ try
+ {
+ insertValueIntoColumn();
+ m_nRowCount++;
+ if(m_bIsAutoIncrement) // if bSetAutoIncrement then I have to set the autoincrement
+ m_pUpdateHelper->updateInt(1,m_nRowCount);
+ m_pUpdateHelper->insertRow();
+ }
+ catch(SQLException& e)
+ //////////////////////////////////////////////////////////////////////
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ m_nColumnPos = 0;
+ break;
+ }
+ }
+ else // Zweig nur f"ur Typpr"ufung g"ultig
+ {
+ switch(nToken)
+ {
+ case RTF_TROWD:
+ // Der Spalten Kopf z"ahlt nicht mit
+ if(m_bHead)
+ {
+ do
+ {}
+ while(GetNextToken() != RTF_ROW && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
+ m_bHead = sal_False;
+ }
+ break;
+ case RTF_INTBL:
+ m_bInTbl = sal_True;
+ break;
+ case RTF_TEXTTOKEN:
+ case RTF_SINGLECHAR:
+ if(m_bInTbl)
+ m_sTextToken += aToken;
+ break;
+ case RTF_CELL:
+ adjustFormat();
+ m_nColumnPos++;
+ break;
+ case RTF_ROW:
+ adjustFormat();
+ m_nColumnPos = 0;
+ m_nRows--;
+ break;
+ }
+ }
+}
+// ---------------------------------------------------------------------------
+sal_Bool ORTFReader::CreateTable(int nToken)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::CreateTable" );
+ DBG_CHKTHIS(ORTFReader,NULL);
+ String aTableName(ModuleRes(STR_TBL_TITLE));
+ aTableName = aTableName.GetToken(0,' ');
+ aTableName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTableName)));
+
+ int nTmpToken2 = nToken;
+ String aColumnName;
+
+ FontDescriptor aFont = ::dbaui::CreateFontDescriptor(Application::GetSettings().GetStyleSettings().GetAppFont());
+ do
+ {
+ switch(nTmpToken2)
+ {
+ case RTF_UNKNOWNCONTROL:
+ case RTF_UNKNOWNDATA:
+ m_bInTbl = sal_False;
+ aColumnName.Erase();
+ break;
+ case RTF_INTBL:
+ if(m_bInTbl)
+ aColumnName.Erase();
+
+ m_bInTbl = sal_True;
+ break;
+ case RTF_TEXTTOKEN:
+ case RTF_SINGLECHAR:
+ if(m_bInTbl)
+ aColumnName += aToken;
+ break;
+ case RTF_CELL:
+ {
+ aColumnName.EraseLeadingChars();
+ aColumnName.EraseTrailingChars();
+ if (!aColumnName.Len() || m_bAppendFirstLine )
+ aColumnName = String(ModuleRes(STR_COLUMN_NAME));
+
+ CreateDefaultColumn(aColumnName);
+ aColumnName.Erase();
+ }
+ break;
+ case RTF_CF:
+ // if(nTokenValue < m_vecColor.size())
+ // m_xTable->setPropertyValue(PROPERTY_TEXTCOLOR,makeAny(m_vecColor[nTokenValue]));
+ break;
+ case RTF_B:
+ aFont.Weight = ::com::sun::star::awt::FontWeight::BOLD;
+ break;
+ case RTF_I:
+ aFont.Slant = ::com::sun::star::awt::FontSlant_ITALIC;
+ break;
+ case RTF_UL:
+ aFont.Underline = ::com::sun::star::awt::FontUnderline::SINGLE;
+ break;
+ case RTF_STRIKE:
+ aFont.Strikeout = ::com::sun::star::awt::FontStrikeout::SINGLE;
+ break;
+ }
+ }
+ while((nTmpToken2 = GetNextToken()) != RTF_TROWD && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
+
+ sal_Bool bOk = !m_vDestVector.empty();
+ if(bOk)
+ {
+ if ( aColumnName.Len() )
+ {
+ if ( m_bAppendFirstLine )
+ aColumnName = String(ModuleRes(STR_COLUMN_NAME));
+ CreateDefaultColumn(aColumnName);
+ }
+
+ m_bInTbl = sal_False;
+ m_bFoundTable = sal_True;
+
+ if ( isCheckEnabled() )
+ return sal_True;
+ Any aTextColor;
+ if(!m_vecColor.empty())
+ aTextColor <<= m_vecColor[0];
+
+ bOk = !executeWizard(aTableName,aTextColor,aFont) && m_xTable.is();
+ }
+ return bOk;
+}
+// -----------------------------------------------------------------------------
+void ORTFReader::release()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::release" );
+ DBG_CHKTHIS(ORTFReader,NULL);
+ ReleaseRef();
+}
+
+// -----------------------------------------------------------------------------
+TypeSelectionPageFactory ORTFReader::getTypeSelectionPageFactory()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::getTypeSelectionPageFactory" );
+ DBG_CHKTHIS(ORTFReader,NULL);
+ return &OWizRTFExtend::Create;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/dbaccess/source/ui/misc/TableCopyHelper.cxx b/dbaccess/source/ui/misc/TableCopyHelper.cxx
new file mode 100644
index 000000000000..cd03b3dab803
--- /dev/null
+++ b/dbaccess/source/ui/misc/TableCopyHelper.cxx
@@ -0,0 +1,415 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBUI_TABLECOPYHELPER_HXX
+#include "TableCopyHelper.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+#ifndef DBAUI_GENERICCONTROLLER_HXX
+#include "genericcontroller.hxx"
+#endif
+#ifndef DBAUI_WIZARD_CPAGE_HXX
+#include "WCPage.hxx"
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_COPYTABLEOPERATION_HPP_
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_COPYTABLEWIZARD_HPP_
+#include <com/sun/star/sdb/application/CopyTableWizard.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_DATAACCESSDESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdb/DataAccessDescriptorFactory.hpp>
+#endif
+
+#ifndef DBAUI_RTFREADER_HXX
+#include "RtfReader.hxx"
+#endif
+#ifndef DBAUI_HTMLREADER_HXX
+#include "HtmlReader.hxx"
+#endif
+#ifndef DBAUI_TOKENWRITER_HXX
+#include "TokenWriter.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef DBAUI_DATAVIEW_HXX
+#include "dataview.hxx"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef _UNOTOOLS_UCBHELPER_HXX
+#include <unotools/ucbhelper.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
+#include <comphelper/componentcontext.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
+#include <com/sun/star/sdbc/XParameters.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#endif
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#endif
+#ifndef _UNOTOOLS_TEMPFILE_HXX
+#include <unotools/tempfile.hxx>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+
+#ifndef DBAUI_DBEXCHANGE_HXX
+#include "dbexchange.hxx"
+#endif
+#include <rtl/logfile.hxx>
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+using namespace ::dbtools;
+using namespace ::svx;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdb::application;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::ucb;
+
+// -----------------------------------------------------------------------------
+OTableCopyHelper::OTableCopyHelper(OGenericUnoController* _pControler)
+ :m_pController(_pControler)
+{
+}
+
+// -----------------------------------------------------------------------------
+void OTableCopyHelper::insertTable( const ::rtl::OUString& i_rSourceDataSource, const Reference<XConnection>& i_rSourceConnection,
+ const ::rtl::OUString& i_rCommand, const sal_Int32 i_nCommandType,
+ const Reference< XResultSet >& i_rSourceRows, const Sequence< Any >& i_rSelection, const sal_Bool i_bBookmarkSelection,
+ const ::rtl::OUString& i_rDestDataSource, const Reference<XConnection>& i_rDestConnection)
+{
+ if ( CommandType::QUERY != i_nCommandType && CommandType::TABLE != i_nCommandType )
+ {
+ DBG_ERROR( "OTableCopyHelper::insertTable: invalid call (no supported format found)!" );
+ return;
+ }
+
+ try
+ {
+ Reference<XConnection> xSrcConnection( i_rSourceConnection );
+ if ( i_rSourceDataSource == i_rDestDataSource )
+ xSrcConnection = i_rDestConnection;
+
+ if ( !xSrcConnection.is() || !i_rDestConnection.is() )
+ {
+ OSL_ENSURE( false, "OTableCopyHelper::insertTable: no connection/s!" );
+ return;
+ }
+
+ ::comphelper::ComponentContext aContext( m_pController->getORB() );
+
+ Reference< XDataAccessDescriptorFactory > xFactory( DataAccessDescriptorFactory::get( aContext.getUNOContext() ) );
+
+ Reference< XPropertySet > xSource( xFactory->createDataAccessDescriptor(), UNO_SET_THROW );
+ xSource->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( i_nCommandType ) );
+ xSource->setPropertyValue( PROPERTY_COMMAND, makeAny( i_rCommand ) );
+ xSource->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xSrcConnection ) );
+ xSource->setPropertyValue( PROPERTY_RESULT_SET, makeAny( i_rSourceRows ) );
+ xSource->setPropertyValue( PROPERTY_SELECTION, makeAny( i_rSelection ) );
+ xSource->setPropertyValue( PROPERTY_BOOKMARK_SELECTION, makeAny( i_bBookmarkSelection ) );
+
+ Reference< XPropertySet > xDest( xFactory->createDataAccessDescriptor(), UNO_SET_THROW );
+ xDest->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( i_rDestConnection ) );
+
+ Reference< XCopyTableWizard > xWizard( CopyTableWizard::create( aContext.getUNOContext(), xSource, xDest ), UNO_SET_THROW );
+
+ ::rtl::OUString sTableNameForAppend( GetTableNameForAppend() );
+ xWizard->setDestinationTableName( GetTableNameForAppend() );
+
+ bool bAppendToExisting = ( sTableNameForAppend.getLength() != 0 );
+ xWizard->setOperation( bAppendToExisting ? CopyTableOperation::AppendData : CopyTableOperation::CopyDefinitionAndData );
+
+ xWizard->execute();
+ }
+ catch( const SQLException& )
+ {
+ m_pController->showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OTableCopyHelper::pasteTable( const ::svx::ODataAccessDescriptor& _rPasteData, const ::rtl::OUString& i_rDestDataSourceName,
+ const SharedConnection& i_rDestConnection )
+{
+ ::rtl::OUString sSrcDataSourceName = _rPasteData.getDataSource();
+
+ ::rtl::OUString sCommand;
+ _rPasteData[ daCommand ] >>= sCommand;
+
+ Reference<XConnection> xSrcConnection;
+ if ( _rPasteData.has(daConnection) )
+ {
+ OSL_VERIFY( _rPasteData[daConnection] >>= xSrcConnection );
+ }
+
+ Reference< XResultSet > xResultSet;
+ if ( _rPasteData.has(daCursor) )
+ {
+ OSL_VERIFY( _rPasteData[ daCursor ] >>= xResultSet );
+ }
+
+ Sequence< Any > aSelection;
+ if ( _rPasteData.has( daSelection ) )
+ {
+ OSL_VERIFY( _rPasteData[ daSelection ] >>= aSelection );
+ OSL_ENSURE( _rPasteData.has( daBookmarkSelection ), "OTableCopyHelper::pasteTable: you should specify BookmarkSelection, too, to be on the safe side!" );
+ }
+
+
+ sal_Bool bBookmarkSelection( sal_True );
+ if ( _rPasteData.has( daBookmarkSelection ) )
+ {
+ OSL_VERIFY( _rPasteData[ daBookmarkSelection ] >>= bBookmarkSelection );
+ }
+ OSL_ENSURE( bBookmarkSelection, "OTableCopyHelper::pasteTable: working with selection-indicies (instead of bookmarks) is error-prone, and thus deprecated!" );
+
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ if ( _rPasteData.has(daCommandType) )
+ _rPasteData[daCommandType] >>= nCommandType;
+
+ insertTable( sSrcDataSourceName, xSrcConnection, sCommand, nCommandType,
+ xResultSet, aSelection, bBookmarkSelection,
+ i_rDestDataSourceName, i_rDestConnection );
+}
+
+// -----------------------------------------------------------------------------
+void OTableCopyHelper::pasteTable( SotFormatStringId _nFormatId
+ ,const TransferableDataHelper& _rTransData
+ ,const ::rtl::OUString& i_rDestDataSource
+ ,const SharedConnection& _xConnection)
+{
+ if ( _nFormatId == SOT_FORMATSTR_ID_DBACCESS_TABLE || _nFormatId == SOT_FORMATSTR_ID_DBACCESS_QUERY )
+ {
+ if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(_rTransData.GetDataFlavorExVector()) )
+ {
+ ::svx::ODataAccessDescriptor aPasteData = ODataAccessObjectTransferable::extractObjectDescriptor(_rTransData);
+ pasteTable( aPasteData,i_rDestDataSource,_xConnection);
+ }
+ }
+ else if ( _rTransData.HasFormat(_nFormatId) )
+ {
+ try
+ {
+ DropDescriptor aTrans;
+ if ( _nFormatId != SOT_FORMAT_RTF )
+ const_cast<TransferableDataHelper&>(_rTransData).GetSotStorageStream(SOT_FORMATSTR_ID_HTML ,aTrans.aHtmlRtfStorage);
+ else
+ const_cast<TransferableDataHelper&>(_rTransData).GetSotStorageStream(SOT_FORMAT_RTF,aTrans.aHtmlRtfStorage);
+
+ aTrans.nType = E_TABLE;
+ aTrans.bHtml = SOT_FORMATSTR_ID_HTML == _nFormatId;
+ aTrans.sDefaultTableName = GetTableNameForAppend();
+ if ( !copyTagTable(aTrans,sal_False,_xConnection) )
+ m_pController->showError(SQLException(String(ModuleRes(STR_NO_TABLE_FORMAT_INSIDE)),*m_pController,::rtl::OUString::createFromAscii("S1000") ,0,Any()));
+ }
+ catch(const SQLException&)
+ {
+ m_pController->showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ else
+ m_pController->showError(SQLException(String(ModuleRes(STR_NO_TABLE_FORMAT_INSIDE)),*m_pController,::rtl::OUString::createFromAscii("S1000") ,0,Any()));
+}
+
+// -----------------------------------------------------------------------------
+void OTableCopyHelper::pasteTable( const TransferableDataHelper& _rTransData
+ ,const ::rtl::OUString& i_rDestDataSource
+ ,const SharedConnection& _xConnection)
+{
+ if ( _rTransData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_TABLE) || _rTransData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY) )
+ pasteTable( SOT_FORMATSTR_ID_DBACCESS_TABLE,_rTransData,i_rDestDataSource,_xConnection);
+ else if ( _rTransData.HasFormat(SOT_FORMATSTR_ID_HTML) )
+ pasteTable( SOT_FORMATSTR_ID_HTML,_rTransData,i_rDestDataSource,_xConnection);
+ else if ( _rTransData.HasFormat(SOT_FORMAT_RTF) )
+ pasteTable( SOT_FORMAT_RTF,_rTransData,i_rDestDataSource,_xConnection);
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OTableCopyHelper::copyTagTable(OTableCopyHelper::DropDescriptor& _rDesc, sal_Bool _bCheck,const SharedConnection& _xConnection)
+{
+ Reference<XEventListener> xEvt;
+ ODatabaseImportExport* pImport = NULL;
+ if ( _rDesc.bHtml )
+ pImport = new OHTMLImportExport(_xConnection,getNumberFormatter(_xConnection,m_pController->getORB()),m_pController->getORB());
+ else
+ pImport = new ORTFImportExport(_xConnection,getNumberFormatter(_xConnection,m_pController->getORB()),m_pController->getORB());
+
+ xEvt = pImport;
+ SvStream* pStream = (SvStream*)(SotStorageStream*)_rDesc.aHtmlRtfStorage;
+ if ( _bCheck )
+ pImport->enableCheckOnly();
+
+ //dyf add 20070601
+ //set the selected tablename
+ pImport->setSTableName(_rDesc.sDefaultTableName);
+ //dyf add end
+ pImport->setStream(pStream);
+ return pImport->Read();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableCopyHelper::isTableFormat(const TransferableDataHelper& _rClipboard) const
+{
+ sal_Bool bTableFormat = _rClipboard.HasFormat(SOT_FORMATSTR_ID_DBACCESS_TABLE)
+ || _rClipboard.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY)
+ || _rClipboard.HasFormat(SOT_FORMAT_RTF)
+ || _rClipboard.HasFormat(SOT_FORMATSTR_ID_HTML);
+
+ return bTableFormat;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableCopyHelper::copyTagTable(const TransferableDataHelper& _aDroppedData
+ ,DropDescriptor& _rAsyncDrop
+ ,const SharedConnection& _xConnection)
+{
+ sal_Bool bRet = sal_False;
+ sal_Bool bHtml = _aDroppedData.HasFormat(SOT_FORMATSTR_ID_HTML);
+ if ( bHtml || _aDroppedData.HasFormat(SOT_FORMAT_RTF) )
+ {
+ if ( bHtml )
+ const_cast<TransferableDataHelper&>(_aDroppedData).GetSotStorageStream(SOT_FORMATSTR_ID_HTML ,_rAsyncDrop.aHtmlRtfStorage);
+ else
+ const_cast<TransferableDataHelper&>(_aDroppedData).GetSotStorageStream(SOT_FORMAT_RTF,_rAsyncDrop.aHtmlRtfStorage);
+
+ _rAsyncDrop.bHtml = bHtml;
+ _rAsyncDrop.bError = !copyTagTable(_rAsyncDrop,sal_True,_xConnection);
+
+ bRet = ( !_rAsyncDrop.bError && _rAsyncDrop.aHtmlRtfStorage.Is() );
+ if ( bRet )
+ {
+ // now we need to copy the stream
+ ::utl::TempFile aTmp;
+ aTmp.EnableKillingFile(sal_False);
+ _rAsyncDrop.aUrl = aTmp.GetURL();
+ SotStorageStreamRef aNew = new SotStorageStream( aTmp.GetFileName() );
+ _rAsyncDrop.aHtmlRtfStorage->Seek(STREAM_SEEK_TO_BEGIN);
+ _rAsyncDrop.aHtmlRtfStorage->CopyTo( aNew );
+ aNew->Commit();
+ _rAsyncDrop.aHtmlRtfStorage = aNew;
+ }
+ else
+ _rAsyncDrop.aHtmlRtfStorage = NULL;
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void OTableCopyHelper::asyncCopyTagTable( DropDescriptor& _rDesc
+ ,const ::rtl::OUString& i_rDestDataSource
+ ,const SharedConnection& _xConnection)
+{
+ if ( _rDesc.aHtmlRtfStorage.Is() )
+ {
+ copyTagTable(_rDesc,sal_False,_xConnection);
+ _rDesc.aHtmlRtfStorage = NULL;
+ // we now have to delete the temp file created in executeDrop
+ INetURLObject aURL;
+ aURL.SetURL(_rDesc.aUrl);
+ ::utl::UCBContentHelper::Kill(aURL.GetMainURL(INetURLObject::NO_DECODE));
+ }
+ else if ( !_rDesc.bError )
+ pasteTable(_rDesc.aDroppedData,i_rDestDataSource,_xConnection);
+ else
+ m_pController->showError(SQLException(String(ModuleRes(STR_NO_TABLE_FORMAT_INSIDE)),*m_pController,::rtl::OUString::createFromAscii("S1000") ,0,Any()));
+}
+// -----------------------------------------------------------------------------
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx
new file mode 100644
index 000000000000..29750de1f00b
--- /dev/null
+++ b/dbaccess/source/ui/misc/TokenWriter.cxx
@@ -0,0 +1,1161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#include "TokenWriter.hxx"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include "RtfReader.hxx"
+#include "HtmlReader.hxx"
+#include "dbustrings.hrc"
+#include <connectivity/dbtools.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <svtools/htmlkywd.hxx>
+#include <svtools/rtfkeywd.hxx>
+#include <tools/color.hxx>
+#include <svtools/htmlout.hxx>
+#include <sfx2/frmhtmlw.hxx>
+#include <svl/numuno.hxx>
+#include <vcl/svapp.hxx>
+#include "UITools.hxx"
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/outdev.hxx>
+#include <svtools/rtfout.hxx>
+#include <svtools/htmlcfg.hxx>
+#include <connectivity/formattedcolumnvalue.hxx>
+#include <unotools/syslocale.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace dbaui;
+using namespace dbtools;
+using namespace svx;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::util;
+using ::com::sun::star::frame::XModel;
+
+#if defined(UNX)
+const char __FAR_DATA ODatabaseImportExport::sNewLine = '\012';
+#else
+const char __FAR_DATA ODatabaseImportExport::sNewLine[] = "\015\012";
+#endif
+
+const static char __FAR_DATA sMyBegComment[] = "<!-- ";
+const static char __FAR_DATA sMyEndComment[] = " -->";
+const static char __FAR_DATA sFontFamily[] = "font-family: ";
+const static char __FAR_DATA sFontSize[] = "font-size: ";
+
+#define SBA_FORMAT_SELECTION_COUNT 4
+#define CELL_X 1437
+
+DBG_NAME(ODatabaseImportExport)
+//======================================================================
+ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor& _aDataDescriptor,
+ const Reference< XMultiServiceFactory >& _rM,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const String& rExchange)
+ :m_bBookmarkSelection( sal_False )
+ ,m_xFormatter(_rxNumberF)
+ ,m_xFactory(_rM)
+ ,m_nCommandType(CommandType::TABLE)
+ ,m_bNeedToReInitialize(sal_False)
+ ,m_pReader(NULL)
+ ,m_pRowMarker(NULL)
+ ,m_bInInitialize(sal_False)
+ ,m_bCheckOnly(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::ODatabaseImportExport" );
+ DBG_CTOR(ODatabaseImportExport,NULL);
+
+ m_eDestEnc = osl_getThreadTextEncoding();
+
+ osl_incrementInterlockedCount( &m_refCount );
+ impl_initFromDescriptor( _aDataDescriptor, false );
+
+ xub_StrLen nCount = rExchange.GetTokenCount(char(11));
+ if( nCount > SBA_FORMAT_SELECTION_COUNT && rExchange.GetToken(4).Len())
+ {
+ m_pRowMarker = new sal_Int32[nCount-SBA_FORMAT_SELECTION_COUNT];
+ for(xub_StrLen i=SBA_FORMAT_SELECTION_COUNT;i<nCount;++i)
+ m_pRowMarker[i-SBA_FORMAT_SELECTION_COUNT] = rExchange.GetToken(i,char(11)).ToInt32();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -----------------------------------------------------------------------------
+// import data
+ODatabaseImportExport::ODatabaseImportExport( const ::dbtools::SharedConnection& _rxConnection,
+ const Reference< XNumberFormatter >& _rxNumberF, const Reference< XMultiServiceFactory >& _rM )
+ :m_bBookmarkSelection( sal_False )
+ ,m_xConnection(_rxConnection)
+ ,m_xFormatter(_rxNumberF)
+ ,m_xFactory(_rM)
+ ,m_nCommandType(::com::sun::star::sdb::CommandType::TABLE)
+ ,m_bNeedToReInitialize(sal_False)
+ ,m_pReader(NULL)
+ ,m_pRowMarker(NULL)
+ ,m_bInInitialize(sal_False)
+ ,m_bCheckOnly(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::ODatabaseImportExport" );
+ DBG_CTOR(ODatabaseImportExport,NULL);
+ m_eDestEnc = osl_getThreadTextEncoding();
+ try
+ {
+ SvtSysLocale aSysLocale;
+ m_aLocale = aSysLocale.GetLocaleData().getLocale();
+ }
+ catch(Exception&)
+ {
+ }
+}
+//-------------------------------------------------------------------
+ODatabaseImportExport::~ODatabaseImportExport()
+{
+ DBG_DTOR(ODatabaseImportExport,NULL);
+ acquire();
+
+ dispose();
+
+ if(m_pReader)
+ m_pReader->release();
+ delete m_pRowMarker;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseImportExport::dispose()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::disposing" );
+ DBG_CHKTHIS(ODatabaseImportExport,NULL);
+ // remove me as listener
+ Reference< XComponent > xComponent(m_xConnection, UNO_QUERY);
+ if (xComponent.is())
+ {
+ Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY);
+ xComponent->removeEventListener(xEvt);
+ }
+ m_xConnection.clear();
+
+ ::comphelper::disposeComponent(m_xRow);
+
+ m_xObject.clear();
+ m_xResultSetMetaData.clear();
+ m_xResultSet.clear();
+ m_xRow.clear();
+ m_xRowLocate.clear();
+ m_xFormatter.clear();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseImportExport::disposing( const EventObject& Source ) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::disposing" );
+ DBG_CHKTHIS(ODatabaseImportExport,NULL);
+ Reference<XConnection> xCon(Source.Source,UNO_QUERY);
+ if(m_xConnection.is() && m_xConnection == xCon)
+ {
+ m_xConnection.clear();
+ dispose();
+ m_bNeedToReInitialize = true;
+ //if(!m_bInInitialize)
+ // initialize();
+ }
+}
+// -----------------------------------------------------------------------------
+void ODatabaseImportExport::initialize( const ODataAccessDescriptor& _aDataDescriptor )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::initialize" );
+ impl_initFromDescriptor( _aDataDescriptor, true );
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseImportExport::impl_initFromDescriptor( const ODataAccessDescriptor& _aDataDescriptor, bool _bPlusDefaultInit)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initFromDescriptor" );
+ DBG_CHKTHIS(ODatabaseImportExport,NULL);
+ if ( !_bPlusDefaultInit )
+ {
+ m_sDataSourceName = _aDataDescriptor.getDataSource();
+ _aDataDescriptor[daCommandType] >>= m_nCommandType;
+ _aDataDescriptor[daCommand] >>= m_sName;
+ // some additonal information
+ if(_aDataDescriptor.has(daConnection))
+ {
+ Reference< XConnection > xPureConn( _aDataDescriptor[daConnection], UNO_QUERY );
+ m_xConnection.reset( xPureConn, SharedConnection::NoTakeOwnership );
+ Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY);
+ Reference< XComponent > xComponent(m_xConnection, UNO_QUERY);
+ if (xComponent.is() && xEvt.is())
+ xComponent->addEventListener(xEvt);
+ }
+
+ if ( _aDataDescriptor.has( daSelection ) )
+ _aDataDescriptor[ daSelection ] >>= m_aSelection;
+
+ if ( _aDataDescriptor.has( daBookmarkSelection ) )
+ _aDataDescriptor[ daBookmarkSelection ] >>= m_bBookmarkSelection;
+
+ if ( _aDataDescriptor.has( daCursor ) )
+ {
+ _aDataDescriptor[ daCursor ] >>= m_xResultSet;
+ m_xRowLocate.set( m_xResultSet, UNO_QUERY );
+ }
+
+ if ( m_aSelection.getLength() != 0 )
+ {
+ if ( !m_xResultSet.is() )
+ {
+ OSL_ENSURE( false, "ODatabaseImportExport::impl_initFromDescriptor: selection without result set is nonsense!" );
+ m_aSelection.realloc( 0 );
+ }
+ }
+
+ if ( m_aSelection.getLength() != 0 )
+ {
+ if ( m_bBookmarkSelection && !m_xRowLocate.is() )
+ {
+ OSL_ENSURE( false, "ODatabaseImportExport::impl_initFromDescriptor: no XRowLocate -> no bookmars!" );
+ m_aSelection.realloc( 0 );
+ }
+ }
+ }
+ else
+ initialize();
+
+ try
+ {
+ SvtSysLocale aSysLocale;
+ m_aLocale = aSysLocale.GetLocaleData().getLocale();
+ }
+ catch(Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+void ODatabaseImportExport::initialize()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::initialize" );
+ DBG_CHKTHIS(ODatabaseImportExport,NULL);
+ m_bInInitialize = sal_True;
+ m_bNeedToReInitialize = false;
+
+ if ( !m_xConnection.is() )
+ { // we need a connection
+ OSL_ENSURE(m_sDataSourceName.getLength(),"There must be a datsource name!");
+ Reference<XNameAccess> xDatabaseContext = Reference< XNameAccess >(m_xFactory->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
+ Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY);
+
+ Reference< XConnection > xConnection;
+ SQLExceptionInfo aInfo = ::dbaui::createConnection( m_sDataSourceName, xDatabaseContext, m_xFactory, xEvt, xConnection );
+ m_xConnection.reset( xConnection );
+
+ if(aInfo.isValid() && aInfo.getType() == SQLExceptionInfo::SQL_EXCEPTION)
+ throw *static_cast<const SQLException*>(aInfo);
+ }
+
+ Reference<XNameAccess> xNameAccess;
+ switch(m_nCommandType)
+ {
+ case CommandType::TABLE:
+ {
+ // only for tables
+ Reference<XTablesSupplier> xSup(m_xConnection,UNO_QUERY);
+ if(xSup.is())
+ xNameAccess = xSup->getTables();
+ }
+ break;
+ case CommandType::QUERY:
+ {
+ Reference<XQueriesSupplier> xSup(m_xConnection,UNO_QUERY);
+ if(xSup.is())
+ xNameAccess = xSup->getQueries();
+ }
+ break;
+ }
+ if(xNameAccess.is() && xNameAccess->hasByName(m_sName))
+ {
+ Reference<XPropertySet> xSourceObject;
+ xNameAccess->getByName(m_sName) >>= m_xObject;
+ }
+
+ if(m_xObject.is())
+ {
+ try
+ {
+ if(m_xObject->getPropertySetInfo()->hasPropertyByName(PROPERTY_FONT))
+ m_xObject->getPropertyValue(PROPERTY_FONT) >>= m_aFont;
+
+ // the result set may be already set with the datadescriptor
+ if ( !m_xResultSet.is() )
+ {
+ m_xResultSet.set( m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.sdb.RowSet" ) ), UNO_QUERY );
+ Reference< XPropertySet > xProp( m_xResultSet, UNO_QUERY_THROW );
+ xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( m_xConnection.getTyped() ) );
+ xProp->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( m_nCommandType ) );
+ xProp->setPropertyValue( PROPERTY_COMMAND, makeAny( m_sName ) );
+ Reference< XRowSet > xRowSet( xProp, UNO_QUERY );
+ xRowSet->execute();
+ }
+ impl_initializeRowMember_throw();
+ }
+ catch(Exception& )
+ {
+ m_xRow = NULL;
+ m_xResultSetMetaData = NULL;
+ ::comphelper::disposeComponent(m_xResultSet);
+ throw;
+ }
+ }
+ if ( !m_aFont.Name.getLength() )
+ {
+ Font aApplicationFont = OutputDevice::GetDefaultFont(
+ DEFAULTFONT_SANS_UNICODE,
+ Application::GetSettings().GetUILanguage(),
+ DEFAULTFONT_FLAGS_ONLYONE
+ );
+ m_aFont = VCLUnoHelper::CreateFontDescriptor( aApplicationFont );
+ }
+
+ m_bInInitialize = sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseImportExport::Write()
+{
+ if ( m_bNeedToReInitialize )
+ {
+ if ( !m_bInInitialize )
+ initialize();
+ } // if ( m_bNeedToReInitialize )
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseImportExport::Read()
+{
+ if ( m_bNeedToReInitialize )
+ {
+ if ( !m_bInInitialize )
+ initialize();
+ } // if ( m_bNeedToReInitialize )
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseImportExport::impl_initializeRowMember_throw()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initializeRowMember_throw" );
+ if ( !m_xRow.is() && m_xResultSet.is() )
+ {
+ m_xRow.set( m_xResultSet, UNO_QUERY );
+ m_xRowLocate.set( m_xResultSet, UNO_QUERY );
+ m_xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xRow,UNO_QUERY)->getMetaData();
+ Reference<XColumnsSupplier> xSup(m_xResultSet,UNO_QUERY_THROW);
+ m_xRowSetColumns.set(xSup->getColumns(),UNO_QUERY_THROW);
+ }
+}
+//======================================================================
+sal_Bool ORTFImportExport::Write()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFImportExport::Write" );
+ ODatabaseImportExport::Write();
+ (*m_pStream) << '{' << OOO_STRING_SVTOOLS_RTF_RTF;
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ANSI << ODatabaseImportExport::sNewLine;
+ rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252;
+
+ /*
+ // Access RTF Export Beispiel
+ {\rtf1\ansi
+ {\colortbl\red0\green0\blue0;\red255\green255\blue255;\red192\green192\blue192;}
+ {\fonttbl\f0\fcharset0\fnil MS Sans Serif;\f1\fcharset0\fnil Arial;\f2\fcharset0\fnil Arial;}
+ \trowd\trgaph40
+ \clbrdrl\brdrs\brdrcf0\clbrdrt\brdrs\brdrcf0\clbrdrb\brdrs\brdrcf0\clbrdrr\brdrs\brdrcf0\clshdng10000\clcfpat2\cellx1437
+ \clbrdrl\brdrs\brdrcf0\clbrdrt\brdrs\brdrcf0\clbrdrb\brdrs\brdrcf0\clbrdrr\brdrs\brdrcf0\clshdng10000\clcfpat2\cellx2874
+ {
+ \trrh-270\pard\intbl
+ {\qc\fs20\b\f1\cf0\cb2 text\cell}
+ \pard\intbl
+ {\qc\fs20\b\f1\cf0\cb2 datum\cell}
+ \pard\intbl\row
+ }
+ \trowd\trgaph40\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx1437\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874
+ {\trrh-270\pard\intbl
+ {\ql\fs20\f2\cf0\cb1 heute\cell}
+ \pard\intbl
+ {\qr\fs20\f2\cf0\cb1 10.11.98\cell}
+ \pard\intbl\row
+ }
+ \trowd\trgaph40\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx1437\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874
+ {\trrh-270\pard\intbl
+ {\ql\fs20\f2\cf0\cb1 morgen\cell}
+ \pard\intbl
+ {\qr\fs20\f2\cf0\cb1 11.11.98\cell}
+ \pard\intbl\row
+ }
+ \trowd\trgaph40\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx1437\clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874
+ {\trrh-270\pard\intbl
+ {\ql\fs20\f2\cf0\cb1 bruder\cell}
+ \pard\intbl
+ {\qr\fs20\f2\cf0\cb1 21.04.98\cell}
+ \pard\intbl\row
+ }
+ \trowd\trgaph40
+ \clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx
+ \clbrdrl\brdrs\brdrcf2\clbrdrt\brdrs\brdrcf2\clbrdrb\brdrs\brdrcf2\clbrdrr\brdrs\brdrcf2\clshdng10000\clcfpat1\cellx2874
+ {\trrh-270\pard\intbl
+ {\ql\fs20\f2\cf0\cb1 vater\cell}
+ \pard\intbl
+ {\qr\fs20\f2\cf0\cb1 28.06.98\cell}
+ \pard\intbl\row
+ }
+ }
+ */
+
+ sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
+ sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
+ sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
+ sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout );
+
+ sal_Int32 nColor = 0;
+ if(m_xObject.is())
+ m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
+ ::Color aColor(nColor);
+
+ ByteString aFonts(String(m_aFont.Name),eDestEnc);
+ if(!aFonts.Len())
+ {
+ String aName = Application::GetSettings().GetStyleSettings().GetAppFont().GetName();
+ aFonts = ByteString (aName,eDestEnc);
+ }
+ ::rtl::OString aFormat("\\fcharset0\\fnil ");
+ ByteString aFontNr;
+
+ (*m_pStream) << "{\\fonttbl";
+ xub_StrLen nTokenCount = aFonts.GetTokenCount();
+ for(xub_StrLen j=0;j<nTokenCount;++j)
+ {
+ (*m_pStream) << "\\f";
+ m_pStream->WriteNumber(j);
+ (*m_pStream) << aFormat;
+ (*m_pStream) << aFonts.GetToken(j).GetBuffer();
+ (*m_pStream) << ';';
+ }
+ (*m_pStream) << '}' ;
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ // write the rtf color table
+ (*m_pStream) << '{' << OOO_STRING_SVTOOLS_RTF_COLORTBL << OOO_STRING_SVTOOLS_RTF_RED;
+ m_pStream->WriteNumber(aColor.GetRed());
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_GREEN;
+ m_pStream->WriteNumber(aColor.GetGreen());
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_BLUE;
+ m_pStream->WriteNumber(aColor.GetBlue());
+
+ (*m_pStream) << ";\\red255\\green255\\blue255;\\red192\\green192\\blue192;}"
+ << ODatabaseImportExport::sNewLine;
+
+ ::rtl::OString aTRRH("\\trrh-270\\pard\\intbl");
+ ::rtl::OString aFS("\\fs20\\f0\\cf0\\cb2");
+ ::rtl::OString aCell1("\\clbrdrl\\brdrs\\brdrcf0\\clbrdrt\\brdrs\\brdrcf0\\clbrdrb\\brdrs\\brdrcf0\\clbrdrr\\brdrs\\brdrcf0\\clshdng10000\\clcfpat2\\cellx");
+
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH;
+ m_pStream->WriteNumber(40);
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+
+ if(m_xObject.is())
+ {
+ Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY);
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ Sequence< ::rtl::OUString> aNames(xColumns->getElementNames());
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+
+ sal_Int32 nCount = aNames.getLength();
+ sal_Bool bUseResultMetaData = sal_False;
+ if ( !nCount )
+ {
+ nCount = m_xResultSetMetaData->getColumnCount();
+ bUseResultMetaData = sal_True;
+ }
+
+ for( sal_Int32 i=1; i<=nCount; ++i )
+ {
+ (*m_pStream) << aCell1;
+ m_pStream->WriteNumber(i*CELL_X);
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ }
+
+ // Spaltenbeschreibung
+ (*m_pStream) << '{' << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << aTRRH;
+
+
+ ::rtl::OString* pHorzChar = new ::rtl::OString[nCount];
+
+ for ( sal_Int32 i=1; i <= nCount; ++i )
+ {
+ sal_Int32 nAlign = 0;
+ ::rtl::OUString sColumnName;
+ if ( bUseResultMetaData )
+ sColumnName = m_xResultSetMetaData->getColumnName(i);
+ else
+ {
+ sColumnName = *pIter;
+ Reference<XPropertySet> xColumn;
+ xColumns->getByName(sColumnName) >>= xColumn;
+ xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign;
+ ++pIter;
+ }
+
+ const char* pChar;
+ switch( nAlign )
+ {
+ case 1: pChar = OOO_STRING_SVTOOLS_RTF_QC; break;
+ case 2: pChar = OOO_STRING_SVTOOLS_RTF_QR; break;
+ case 0:
+ default:pChar = OOO_STRING_SVTOOLS_RTF_QL; break;
+ }
+
+ pHorzChar[i-1] = pChar; // um sp"ater nicht immer im ITEMSET zuw"uhlen
+
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << '{';
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_QC; // column header always centered
+
+ if ( bBold ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_B;
+ if ( bItalic ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_I;
+ if ( bUnderline ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_UL;
+ if ( bStrikeout ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_STRIKE;
+
+ (*m_pStream) << aFS;
+ (*m_pStream) << ' ';
+ RTFOutFuncs::Out_String(*m_pStream,sColumnName,eDestEnc);
+
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_CELL;
+ (*m_pStream) << '}';
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL;
+ }
+
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ROW;
+ (*m_pStream) << ODatabaseImportExport::sNewLine << '}';
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+
+ ::comphelper::ComponentContext aContext(m_xFactory);
+ Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
+ sal_Int32 k=1;
+ sal_Int32 kk=0;
+ if ( m_aSelection.getLength() )
+ {
+ const Any* pSelIter = m_aSelection.getConstArray();
+ const Any* pEnd = pSelIter + m_aSelection.getLength();
+
+ sal_Bool bContinue = sal_True;
+ for( ; pSelIter != pEnd && bContinue; ++pSelIter )
+ {
+ if ( m_bBookmarkSelection )
+ {
+ bContinue = m_xRowLocate->moveToBookmark( *pSelIter );
+ }
+ else
+ {
+ sal_Int32 nPos = -1;
+ OSL_VERIFY( *pSelIter >>= nPos );
+ bContinue = ( m_xResultSet->absolute( nPos ) );
+ }
+
+ if ( bContinue )
+ appendRow( pHorzChar, nCount, k, kk );
+ }
+ }
+ else
+ {
+ m_xResultSet->beforeFirst(); // set back before the first row
+ while(m_xResultSet->next())
+ {
+ appendRow(pHorzChar,nCount,k,kk);
+ }
+ }
+ delete [] pHorzChar;
+ }
+
+ (*m_pStream) << '}' << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << (sal_uInt8) 0;
+ return ((*m_pStream).GetError() == SVSTREAM_OK);
+}
+// -----------------------------------------------------------------------------
+void ORTFImportExport::appendRow(::rtl::OString* pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk)
+{
+ if(!m_pRowMarker || m_pRowMarker[kk] == k)
+ {
+ ++kk;
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH;
+ m_pStream->WriteNumber(40);
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+
+ static const ::rtl::OString aCell2("\\clbrdrl\\brdrs\\brdrcf2\\clbrdrt\\brdrs\\brdrcf2\\clbrdrb\\brdrs\\brdrcf2\\clbrdrr\\brdrs\\brdrcf2\\clshdng10000\\clcfpat1\\cellx");
+ static const ::rtl::OString aTRRH("\\trrh-270\\pard\\intbl");
+
+ for ( sal_Int32 i=1; i<=_nColumnCount; ++i )
+ {
+ (*m_pStream) << aCell2;
+ m_pStream->WriteNumber(i*CELL_X);
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ }
+
+ const sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
+ const sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
+ const sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
+ const sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout );
+ static const ::rtl::OString aFS2("\\fs20\\f1\\cf0\\cb1");
+ ::comphelper::ComponentContext aContext(m_xFactory);
+ Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
+
+ (*m_pStream) << '{';
+ (*m_pStream) << aTRRH;
+ for ( sal_Int32 i=1; i <= _nColumnCount; ++i )
+ {
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << '{';
+ (*m_pStream) << pHorzChar[i-1];
+
+ if ( bBold ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_B;
+ if ( bItalic ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_I;
+ if ( bUnderline ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_UL;
+ if ( bStrikeout ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_STRIKE;
+
+ (*m_pStream) << aFS2;
+ (*m_pStream) << ' ';
+
+ try
+ {
+ Reference<XPropertySet> xColumn(m_xRowSetColumns->getByIndex(i-1),UNO_QUERY_THROW);
+ dbtools::FormattedColumnValue aFormatedValue(aContext,xRowSet,xColumn);
+ ::rtl::OUString sValue = aFormatedValue.getFormattedValue();
+ // m_xRow->getString(i);
+ //if (!m_xRow->wasNull())
+ if ( sValue.getLength() )
+ RTFOutFuncs::Out_String(*m_pStream,sValue,m_eDestEnc);
+ }
+ catch (Exception&)
+ {
+ OSL_ENSURE(0,"RTF WRITE!");
+ }
+
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_CELL;
+ (*m_pStream) << '}';
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL;
+ }
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ROW << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << '}';
+ }
+ ++k;
+}
+//-------------------------------------------------------------------
+sal_Bool ORTFImportExport::Read()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFImportExport::Read" );
+ ODatabaseImportExport::Read();
+ SvParserState eState = SVPAR_ERROR;
+ if ( m_pStream )
+ {
+ m_pReader = new ORTFReader((*m_pStream),m_xConnection,m_xFormatter,m_xFactory);
+ ((ORTFReader*)m_pReader)->AddRef();
+ if ( isCheckEnabled() )
+ m_pReader->enableCheckOnly();
+ eState = ((ORTFReader*)m_pReader)->CallParser();
+ m_pReader->release();
+ m_pReader = NULL;
+ }
+
+ return eState != SVPAR_ERROR;
+}
+//-------------------------------------------------------------------
+//===================================================================
+const sal_Int16 __FAR_DATA OHTMLImportExport::nDefaultFontSize[SBA_HTML_FONTSIZES] =
+{
+ HTMLFONTSZ1_DFLT, HTMLFONTSZ2_DFLT, HTMLFONTSZ3_DFLT, HTMLFONTSZ4_DFLT,
+ HTMLFONTSZ5_DFLT, HTMLFONTSZ6_DFLT, HTMLFONTSZ7_DFLT
+};
+
+sal_Int16 OHTMLImportExport::nFontSize[SBA_HTML_FONTSIZES] = { 0 };
+
+const sal_Int16 OHTMLImportExport::nCellSpacing = 0;
+const char __FAR_DATA OHTMLImportExport::sIndentSource[nIndentMax+1] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
+
+//========================================================================
+// Makros fuer HTML-Export
+//========================================================================
+#define OUT_PROLOGUE() ((*m_pStream) << sHTML30_Prologue << ODatabaseImportExport::sNewLine << ODatabaseImportExport::sNewLine)
+#define TAG_ON( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag )
+#define TAG_OFF( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag, sal_False )
+#define OUT_STR( str ) HTMLOutFuncs::Out_String( (*m_pStream), str )
+#define OUT_LF() (*m_pStream) << ODatabaseImportExport::sNewLine << GetIndentStr()
+#define lcl_OUT_LF() (*m_pStream) << ODatabaseImportExport::sNewLine
+#define TAG_ON_LF( tag ) (TAG_ON( tag ) << ODatabaseImportExport::sNewLine << GetIndentStr())
+#define TAG_OFF_LF( tag ) (TAG_OFF( tag ) << ODatabaseImportExport::sNewLine << GetIndentStr())
+#define OUT_HR() TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_horzrule )
+#define OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << ODatabaseImportExport::sNewLine << GetIndentStr())
+#define lcl_OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << ODatabaseImportExport::sNewLine)
+
+//-------------------------------------------------------------------
+OHTMLImportExport::OHTMLImportExport(const ::svx::ODataAccessDescriptor& _aDataDescriptor,
+ const Reference< XMultiServiceFactory >& _rM,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const String& rExchange)
+ : ODatabaseImportExport(_aDataDescriptor,_rM,_rxNumberF,rExchange)
+ ,m_nIndent(0)
+#ifdef DBG_UTIL
+ ,m_bCheckFont(sal_False)
+#endif
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::OHTMLImportExport" );
+ // set HTML configuration
+ SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get();
+ m_eDestEnc = pHtmlOptions->GetTextEncoding();
+ strncpy( sIndent, sIndentSource ,std::min(sizeof(sIndent),sizeof(sIndentSource)));
+ sIndent[0] = 0;
+}
+//-------------------------------------------------------------------
+sal_Bool OHTMLImportExport::Write()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::Write" );
+ ODatabaseImportExport::Write();
+ if(m_xObject.is())
+ {
+ (*m_pStream) << '<' << OOO_STRING_SVTOOLS_HTML_doctype << ' ' << OOO_STRING_SVTOOLS_HTML_doctype32 << '>' << ODatabaseImportExport::sNewLine << ODatabaseImportExport::sNewLine;
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_html );
+ WriteHeader();
+ OUT_LF();
+ WriteBody();
+ OUT_LF();
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_html );
+
+ return ((*m_pStream).GetError() == SVSTREAM_OK);
+ }
+ return sal_False;
+}
+//-------------------------------------------------------------------
+sal_Bool OHTMLImportExport::Read()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::Read" );
+ ODatabaseImportExport::Read();
+ SvParserState eState = SVPAR_ERROR;
+ if ( m_pStream )
+ {
+ m_pReader = new OHTMLReader((*m_pStream),m_xConnection,m_xFormatter,m_xFactory);
+ ((OHTMLReader*)m_pReader)->AddRef();
+ if ( isCheckEnabled() )
+ m_pReader->enableCheckOnly();
+ //dyf add 20070601
+ m_pReader->SetTableName(m_sDefaultTableName);
+ //dyf add end
+ eState = ((OHTMLReader*)m_pReader)->CallParser();
+ m_pReader->release();
+ m_pReader = NULL;
+ }
+
+ return eState != SVPAR_ERROR;
+}
+//-------------------------------------------------------------------
+void OHTMLImportExport::WriteHeader()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteHeader" );
+ uno::Reference<document::XDocumentProperties> xDocProps(
+ m_xFactory->createInstance(::rtl::OUString::createFromAscii(
+ "com.sun.star.document.DocumentProperties")),
+ uno::UNO_QUERY);
+ if (xDocProps.is()) {
+ xDocProps->setTitle(m_sName);
+ }
+
+ IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_head );
+
+ SfxFrameHTMLWriter::Out_DocInfo( (*m_pStream), String(),
+ xDocProps, sIndent );
+ OUT_LF();
+ IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_head );
+}
+//-----------------------------------------------------------------------
+void OHTMLImportExport::WriteBody()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteBody" );
+
+ IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_style );
+
+ (*m_pStream) << sMyBegComment; OUT_LF();
+ (*m_pStream) << OOO_STRING_SVTOOLS_HTML_body << " { " << sFontFamily << '\"' << ::rtl::OString(m_aFont.Name,m_aFont.Name.getLength(), gsl_getSystemTextEncoding()) << '\"';
+ // TODO : think about the encoding of the font name
+ (*m_pStream) << "; " << sFontSize;
+ m_pStream->WriteNumber(m_aFont.Height);
+ (*m_pStream) << '}';
+
+ OUT_LF();
+ (*m_pStream) << sMyEndComment;
+ IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_style );
+ OUT_LF();
+
+ // default Textfarbe schwarz
+ (*m_pStream) << '<' << OOO_STRING_SVTOOLS_HTML_body << ' ' << OOO_STRING_SVTOOLS_HTML_O_text << '=';
+ sal_Int32 nColor = 0;
+ if(m_xObject.is())
+ m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
+ ::Color aColor(nColor);
+ HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
+
+ ::rtl::OString sOut( ' ' );
+ sOut = sOut + OOO_STRING_SVTOOLS_HTML_O_bgcolor;
+ sOut = sOut + "=";
+ (*m_pStream) << sOut;
+ HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
+
+ (*m_pStream) << '>'; OUT_LF();
+
+ WriteTables();
+
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_body );
+}
+//-----------------------------------------------------------------------
+void OHTMLImportExport::WriteTables()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteTables" );
+ ::rtl::OString aStrOut = OOO_STRING_SVTOOLS_HTML_table;
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_frame;
+ aStrOut = aStrOut + "=";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_TF_void;
+
+ Sequence< ::rtl::OUString> aNames;
+ Reference<XNameAccess> xColumns;
+ sal_Bool bUseResultMetaData = sal_False;
+ if(m_xObject.is())
+ {
+ Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY);
+ xColumns = xColSup->getColumns();
+ aNames = xColumns->getElementNames();
+ if ( !aNames.getLength() )
+ {
+ sal_Int32 nCount = m_xResultSetMetaData->getColumnCount();
+ aNames.realloc(nCount);
+ for (sal_Int32 i= 0; i < nCount; ++i)
+ aNames[i] = m_xResultSetMetaData->getColumnName(i+1);
+ bUseResultMetaData = sal_True;
+ }
+ }
+
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_align;
+ aStrOut = aStrOut + "=";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_AL_left;
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_cellspacing;
+ aStrOut = aStrOut + "=";
+ aStrOut = aStrOut + ::rtl::OString::valueOf((sal_Int32)nCellSpacing);
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_cols;
+ aStrOut = aStrOut + "=";
+ aStrOut = aStrOut + ::rtl::OString::valueOf(aNames.getLength());
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_border;
+ aStrOut = aStrOut + "=1";
+
+ IncIndent(1);
+ TAG_ON( aStrOut );
+
+ FontOn();
+
+ TAG_ON( OOO_STRING_SVTOOLS_HTML_caption );
+ TAG_ON( OOO_STRING_SVTOOLS_HTML_bold );
+
+ (*m_pStream) << ::rtl::OString(m_sName,m_sName.getLength(), gsl_getSystemTextEncoding());
+ // TODO : think about the encoding of the name
+ TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold );
+ TAG_OFF( OOO_STRING_SVTOOLS_HTML_caption );
+
+ FontOff();
+ OUT_LF();
+ // </FONT>
+
+ IncIndent(1);
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_thead );
+
+ IncIndent(1);
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+
+ if(m_xObject.is())
+ {
+ sal_Int32* pFormat = new sal_Int32[aNames.getLength()];
+
+ const char **pHorJustify = new const char*[aNames.getLength()];
+ sal_Int32 *pColWidth = new sal_Int32[aNames.getLength()];
+
+
+ sal_Int32 nHeight = 0;
+ m_xObject->getPropertyValue(PROPERTY_ROW_HEIGHT) >>= nHeight;
+
+ // 1. die Spaltenbeschreibung rauspusten
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+
+ for( sal_Int32 i=0;pIter != pEnd; ++pIter,++i )
+ {
+ sal_Int32 nAlign = 0;
+ pFormat[i] = 0;
+ pColWidth[i] = 100;
+ if ( !bUseResultMetaData )
+ {
+ Reference<XPropertySet> xColumn;
+ xColumns->getByName(*pIter) >>= xColumn;
+ xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign;
+ pFormat[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_FORMATKEY));
+ pColWidth[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_WIDTH));
+ }
+
+ switch( nAlign )
+ {
+ case 1: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_center; break;
+ case 2: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_right; break;
+ default: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_left; break;
+ }
+
+ if(i == aNames.getLength()-1)
+ IncIndent(-1);
+
+ WriteCell(pFormat[i],pColWidth[i],nHeight,pHorJustify[i],*pIter,OOO_STRING_SVTOOLS_HTML_tableheader);
+ }
+
+ IncIndent(-1);
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead );
+
+ IncIndent(1);
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody );
+
+ // 2. und jetzt die Daten
+ ::comphelper::ComponentContext aContext(m_xFactory);
+ Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
+ sal_Int32 j=1;
+ sal_Int32 kk=0;
+ m_xResultSet->beforeFirst(); // set back before the first row
+ while(m_xResultSet->next())
+ {
+ IncIndent(1);
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+
+ if(!m_pRowMarker || m_pRowMarker[kk] == j)
+ {
+ ++kk;
+ for(sal_Int32 i=1;i<=aNames.getLength();++i)
+ {
+ if(i == aNames.getLength())
+ IncIndent(-1);
+
+ String aValue;
+ try
+ {
+ Reference<XPropertySet> xColumn(m_xRowSetColumns->getByIndex(i-1),UNO_QUERY_THROW);
+ dbtools::FormattedColumnValue aFormatedValue(aContext,xRowSet,xColumn);
+ ::rtl::OUString sValue = aFormatedValue.getFormattedValue();
+ if (sValue.getLength())
+ {
+ aValue = sValue;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ WriteCell(pFormat[i-1],pColWidth[i-1],nHeight,pHorJustify[i-1],aValue,OOO_STRING_SVTOOLS_HTML_tabledata);
+ }
+ }
+ ++j;
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+ }
+
+ delete [] pFormat;
+ delete [] pHorJustify;
+ delete [] pColWidth;
+ }
+ else
+ {
+ IncIndent(-1);
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead );
+
+ IncIndent(1);
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody );
+ }
+
+ IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tbody );
+ IncIndent(-1); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_table );
+}
+//-----------------------------------------------------------------------
+void OHTMLImportExport::WriteCell( sal_Int32 nFormat,sal_Int32 nWidthPixel,sal_Int32 nHeightPixel,const char* pChar,
+ const String& rValue,const char* pHtmlTag)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteCell" );
+ ::rtl::OString aStrTD = pHtmlTag;
+
+ nWidthPixel = nWidthPixel ? nWidthPixel : 86;
+ nHeightPixel = nHeightPixel ? nHeightPixel : 17;
+
+ // trotz der <TABLE COLS=n> und <COL WIDTH=x> Angaben noetig,
+ // da die nicht von Netscape beachtet werden..
+ // Spaltenbreite
+ aStrTD = aStrTD + " ";
+ aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_width;
+ aStrTD = aStrTD + "=";
+ aStrTD = aStrTD + ::rtl::OString::valueOf((sal_Int32)nWidthPixel);
+ // Zeilenhoehe
+ aStrTD = aStrTD + " ";
+ aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_height;
+ aStrTD = aStrTD + "=";
+ aStrTD = aStrTD + ::rtl::OString::valueOf((sal_Int32)nHeightPixel);
+
+ aStrTD = aStrTD + " ";
+ aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_align;
+ aStrTD = aStrTD + "=";
+ aStrTD = aStrTD + pChar;
+
+ double fVal = 0.0;
+
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
+ SvNumberFormatter* pFormatter = pSupplierImpl ? pSupplierImpl->GetNumberFormatter() : NULL;
+ if(pFormatter)
+ {
+ try
+ {
+ fVal = m_xFormatter->convertStringToNumber(nFormat,rValue);
+ ByteString aTmpString(aStrTD);
+ HTMLOutFuncs::CreateTableDataOptionsValNum( aTmpString, sal_False, fVal,nFormat, *pFormatter );
+ }
+ catch(Exception&)
+ {
+ ByteString aTmpString(aStrTD);
+ HTMLOutFuncs::CreateTableDataOptionsValNum( aTmpString, sal_False, fVal,nFormat, *pFormatter );
+ }
+ }
+
+ TAG_ON( aStrTD );
+
+ FontOn();
+
+ sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
+ sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
+ sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
+ sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout );
+
+ if ( bBold ) TAG_ON( OOO_STRING_SVTOOLS_HTML_bold );
+ if ( bItalic ) TAG_ON( OOO_STRING_SVTOOLS_HTML_italic );
+ if ( bUnderline ) TAG_ON( OOO_STRING_SVTOOLS_HTML_underline );
+ if ( bStrikeout ) TAG_ON( OOO_STRING_SVTOOLS_HTML_strike );
+
+ if ( !rValue.Len() )
+ TAG_ON( OOO_STRING_SVTOOLS_HTML_linebreak ); // #42573# keine komplett leere Zelle
+ else
+ HTMLOutFuncs::Out_String( (*m_pStream), rValue ,m_eDestEnc);
+
+
+ if ( bStrikeout ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_strike );
+ if ( bUnderline ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_underline );
+ if ( bItalic ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_italic );
+ if ( bBold ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold );
+
+ FontOff();
+
+ TAG_OFF_LF( pHtmlTag );
+}
+//-----------------------------------------------------------------------
+void OHTMLImportExport::FontOn()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::FontOn" );
+#ifdef DBG_UTIL
+ m_bCheckFont = sal_True;
+#endif
+
+ // <FONT FACE="xxx">
+ ::rtl::OString aStrOut = "<";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_font;
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_face;
+ aStrOut = aStrOut + "=";
+ aStrOut = aStrOut + "\"";
+ aStrOut = aStrOut + ::rtl::OString(m_aFont.Name,m_aFont.Name.getLength(),gsl_getSystemTextEncoding());
+ // TODO : think about the encoding of the font name
+ aStrOut = aStrOut + "\"";
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_color;
+ aStrOut = aStrOut + "=";
+ (*m_pStream) << aStrOut;
+
+ sal_Int32 nColor = 0;
+ if(m_xObject.is())
+ m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
+ ::Color aColor(nColor);
+
+ HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
+ (*m_pStream) << ">";
+}
+//-----------------------------------------------------------------------
+inline void OHTMLImportExport::FontOff()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::FontOff" );
+ DBG_ASSERT(m_bCheckFont,"Kein FontOn() gerufen");
+ TAG_OFF( OOO_STRING_SVTOOLS_HTML_font );
+#ifdef DBG_UTIL
+ m_bCheckFont = sal_False;
+#endif
+}
+//-----------------------------------------------------------------------
+void OHTMLImportExport::IncIndent( sal_Int16 nVal )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::IncIndent" );
+ sIndent[m_nIndent] = '\t';
+ m_nIndent = m_nIndent + nVal;
+ if ( m_nIndent < 0 )
+ m_nIndent = 0;
+ else if ( m_nIndent > nIndentMax )
+ m_nIndent = nIndentMax;
+ sIndent[m_nIndent] = 0;
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/misc/ToolBoxHelper.cxx b/dbaccess/source/ui/misc/ToolBoxHelper.cxx
new file mode 100644
index 000000000000..ac5b5a957d4d
--- /dev/null
+++ b/dbaccess/source/ui/misc/ToolBoxHelper.cxx
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TOOLBOXHELPER_HXX
+#include "ToolBoxHelper.hxx"
+#endif
+#ifndef _SV_TOOLBOX_HXX
+#include <vcl/toolbox.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_MISCOPT_HXX
+#include <svtools/miscopt.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _SVTOOLS_IMGDEF_HXX
+#include <svtools/imgdef.hxx>
+#endif
+#include <vcl/event.hxx>
+
+namespace dbaui
+{
+ DBG_NAME(OToolBoxHelper)
+ OToolBoxHelper::OToolBoxHelper()
+ : m_bIsHiContrast(sal_False)
+ ,m_nSymbolsSize(-1 )
+ ,m_pToolBox(NULL)
+ {
+ DBG_CTOR(OToolBoxHelper,NULL);
+
+ OSL_ENSURE(m_nSymbolsSize != SvtMiscOptions().GetCurrentSymbolsSize(),"SymbolsSize should not be identical");
+ SvtMiscOptions().AddListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) );
+ Application::AddEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) );
+ }
+ // -----------------------------------------------------------------------------
+ OToolBoxHelper::~OToolBoxHelper()
+ {
+ SvtMiscOptions().RemoveListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) );
+ Application::RemoveEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) );
+ DBG_DTOR(OToolBoxHelper,NULL);
+ }
+
+ // -----------------------------------------------------------------------------
+ void OToolBoxHelper::checkImageList()
+ {
+ if ( m_pToolBox )
+ {
+ sal_Int16 nCurSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize();
+ if ( nCurSymbolsSize != m_nSymbolsSize ||
+ m_bIsHiContrast != m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ m_nSymbolsSize = nCurSymbolsSize;
+ m_bIsHiContrast = m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode();
+
+
+ m_pToolBox->SetImageList( getImageList(m_nSymbolsSize,m_bIsHiContrast) );
+ Size aTbOldSize = m_pToolBox->GetSizePixel();
+ adjustToolBoxSize(m_pToolBox);
+ Size aTbNewSize = m_pToolBox->GetSizePixel();
+ resizeControls(Size(aTbNewSize.Width() - aTbOldSize.Width(),
+ aTbNewSize.Height() - aTbOldSize.Height())
+ );
+ }
+ }
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK(OToolBoxHelper, ConfigOptionsChanged, SvtMiscOptions*, /*_pOptions*/)
+ {
+ if ( m_pToolBox )
+ {
+ SvtMiscOptions aOptions;
+ // check if imagelist changed
+ checkImageList();
+ if ( aOptions.GetToolboxStyle() != m_pToolBox->GetOutStyle() )
+ m_pToolBox->SetOutStyle(aOptions.GetToolboxStyle());
+ }
+
+ return 0L;
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK(OToolBoxHelper, SettingsChanged, VclWindowEvent*, _pEvt)
+ {
+ if ( m_pToolBox && _pEvt && _pEvt->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
+ {
+ DataChangedEvent* pData = reinterpret_cast<DataChangedEvent*>(_pEvt->GetData());
+ if ( pData && ((( pData->GetType() == DATACHANGED_SETTINGS ) ||
+ ( pData->GetType() == DATACHANGED_DISPLAY )) &&
+ ( pData->GetFlags() & SETTINGS_STYLE )))
+ // check if imagelist changed
+ checkImageList();
+ }
+
+ return 0L;
+ }
+ // -----------------------------------------------------------------------------
+ void OToolBoxHelper::setToolBox(ToolBox* _pTB)
+ {
+ sal_Bool bFirstTime = (m_pToolBox == NULL);
+ m_pToolBox = _pTB;
+ if ( m_pToolBox )
+ {
+ // m_bIsHiContrast = m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode();
+ ConfigOptionsChanged(NULL);
+ if ( bFirstTime )
+ adjustToolBoxSize(m_pToolBox);
+ }
+ }
+// -----------------------------------------------------------------------------
+} // namespace
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
new file mode 100644
index 000000000000..0b555662116e
--- /dev/null
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -0,0 +1,1888 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _SFX_DOCFILT_HACK_HXX
+#include <sfx2/docfilt.hxx>
+#endif
+#ifndef _DBACCESS_UI_CALLBACKS_HXX_
+#include "callbacks.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef DBAUI_DLGSAVE_HXX
+#include "dlgsave.hxx"
+#endif
+#ifndef DBAUI_DBTREELISTBOX_HXX
+#include "dbtreelistbox.hxx"
+#endif
+#ifndef DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
+#include "defaultobjectnamecheck.hxx"
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYANALYZER_HPP_
+#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#endif
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
+#include <com/sun/star/ucb/XContent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
+#include <com/sun/star/container/XIndexAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_
+#include <com/sun/star/ucb/InteractiveIOException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_IOERRORCODE_HPP_
+#include <com/sun/star/ucb/IOErrorCode.hpp>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
+#include <toolkit/awt/vclxwindow.hxx>
+#endif
+#ifndef _VCL_STDTEXT_HXX
+#include <vcl/stdtext.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
+#include <com/sun/star/container/XContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMECONTAINER_HPP_
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_
+#include <com/sun/star/awt/TextAlign.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_
+#include <com/sun/star/awt/FontWeight.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTRELIEF_HPP_
+#include <com/sun/star/awt/FontRelief.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_FONTWIDTH_HPP_
+#include <com/sun/star/awt/FontWidth.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef DBAUI_SBATTRDLG_HRC
+#include "dlgattr.hrc"
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
+#include <comphelper/componentcontext.hxx>
+#endif
+
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+
+#define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY
+#define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY
+//#define ITEMID_ORIENTATION SID_ATTR_ALIGN_ORIENTATION
+#define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK
+#define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN
+#define ITEMID_NUMBERINFO SID_ATTR_NUMBERFORMAT_INFO
+
+#ifndef _SFXITEMPOOL_HXX
+#include <svl/itempool.hxx>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _SFXITEMSET_HXX //autogen wg. SfxItemSet
+#include <svl/itemset.hxx>
+#endif
+#ifndef DBACCESS_SBA_GRID_HRC
+#include "sbagrid.hrc"
+#endif
+#ifndef _SFXRNGITEM_HXX
+#include <svl/rngitem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svl/intitem.hxx>
+#endif
+#ifndef _SVX_ALGITEM_HXX
+#include <svx/algitem.hxx>
+#endif
+#ifndef _SVX_NUMINF_HXX
+#include <svx/numinf.hxx>
+#endif
+#define _ZFORLIST_DECLARE_TABLE
+#ifndef _SVX_NUMINF_HXX
+#include <svx/numinf.hxx>
+#endif
+#ifndef _ZFORLIST_HXX
+#include <svl/zforlist.hxx>
+#endif
+#ifndef DBAUI_SBATTRDLG_HXX
+#include "dlgattr.hxx"
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
+#include <com/sun/star/container/XChild.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
+#include <com/sun/star/util/NumberFormat.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
+#include <com/sun/star/util/URL.hpp>
+#endif
+#ifndef _SV_TOOLBOX_HXX
+#include <vcl/toolbox.hxx>
+#endif
+#ifndef _DBAUI_DLGSIZE_HXX
+#include "dlgsize.hxx"
+#endif
+#ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
+#include <svtools/editbrowsebox.hxx>
+#endif
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_HELPOPT_HXX
+#include <svtools/helpopt.hxx>
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _NUMUNO_HXX
+#include <svl/numuno.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
+#include <unotools/pathoptions.hxx>
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX_
+#include <svl/filenotation.hxx>
+#endif
+#ifndef _SVT_FILEVIEW_HXX
+#include <svtools/fileview.hxx>
+#endif
+#ifndef _CONNECTIVITY_FILE_VALUE_HXX_
+#include <connectivity/FValue.hxx>
+#endif
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+using namespace ::dbtools;
+using namespace ::comphelper;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::svt;
+using ::com::sun::star::ucb::InteractiveIOException;
+using ::com::sun::star::ucb::IOErrorCode_NO_FILE;
+using ::com::sun::star::ucb::IOErrorCode_NOT_EXISTING;
+using ::com::sun::star::frame::XModel;
+
+// -----------------------------------------------------------------------------
+SQLExceptionInfo createConnection( const ::rtl::OUString& _rsDataSourceName,
+ const Reference< ::com::sun::star::container::XNameAccess >& _xDatabaseContext,
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF,
+ Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
+ Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection )
+{
+ Reference<XPropertySet> xProp;
+ try
+ {
+ xProp.set(_xDatabaseContext->getByName(_rsDataSourceName),UNO_QUERY);
+ }
+ catch(Exception&)
+ {
+ }
+ SQLExceptionInfo aInfo;
+
+ return createConnection(xProp,_rMF,_rEvtLst,_rOUTConnection);
+}
+// -----------------------------------------------------------------------------
+SQLExceptionInfo createConnection( const Reference< ::com::sun::star::beans::XPropertySet>& _xDataSource,
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF,
+ Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
+ Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection )
+{
+ SQLExceptionInfo aInfo;
+ if ( !_xDataSource.is() )
+ {
+ OSL_ENSURE(0,"createConnection: coult not retrieve the data source!");
+ return aInfo;
+ }
+
+ ::rtl::OUString sPwd, sUser;
+ sal_Bool bPwdReq = sal_False;
+ try
+ {
+ _xDataSource->getPropertyValue(PROPERTY_PASSWORD) >>= sPwd;
+ bPwdReq = ::cppu::any2bool(_xDataSource->getPropertyValue(PROPERTY_ISPASSWORDREQUIRED));
+ _xDataSource->getPropertyValue(PROPERTY_USER) >>= sUser;
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"createConnection: error while retrieving data source properties!");
+ }
+
+
+ try
+ {
+ if(bPwdReq && !sPwd.getLength())
+ { // password required, but empty -> connect using an interaction handler
+ Reference<XCompletedConnection> xConnectionCompletion(_xDataSource, UNO_QUERY);
+ if (!xConnectionCompletion.is())
+ {
+ OSL_ENSURE(0,"createConnection: missing an interface ... need an error message here!");
+ }
+ else
+ { // instantiate the default SDB interaction handler
+ Reference< XInteractionHandler > xHandler(_rMF->createInstance(SERVICE_TASK_INTERACTION_HANDLER), UNO_QUERY);
+ if (!xHandler.is())
+ {
+ OSL_ENSURE(sal_False, "createConnection: could not instantiate an interaction handler!");
+ // ShowServiceNotAvailableError(NULL, String(SERVICE_TASK_INTERACTION_HANDLER), sal_True);
+ // TODO: a real parent!
+ }
+ else
+ _rOUTConnection = xConnectionCompletion->connectWithCompletion(xHandler);
+ }
+ }
+ else
+ {
+ Reference<XDataSource> xDataSource(_xDataSource,UNO_QUERY);
+ _rOUTConnection = xDataSource->getConnection(sUser, sPwd);
+ }
+ // be notified when connection is in disposing
+ Reference< XComponent > xComponent(_rOUTConnection, UNO_QUERY);
+ if (xComponent.is() && _rEvtLst.is())
+ xComponent->addEventListener(_rEvtLst);
+ }
+ catch(SQLContext& e) { aInfo = SQLExceptionInfo(e); }
+ catch(SQLWarning& e) { aInfo = SQLExceptionInfo(e); }
+ catch(SQLException& e) { aInfo = SQLExceptionInfo(e); }
+ catch(Exception&) { OSL_ENSURE(0,"SbaTableQueryBrowser::OnExpandEntry: could not connect - unknown exception!"); }
+
+ // showError(aInfo);
+
+ return aInfo;
+}
+// -----------------------------------------------------------------------------
+Reference< XDataSource > getDataSourceByName( const ::rtl::OUString& _rDataSourceName,
+ Window* _pErrorMessageParent, Reference< XMultiServiceFactory > _rxORB, ::dbtools::SQLExceptionInfo* _pErrorInfo )
+{
+ ::comphelper::ComponentContext aContext( _rxORB );
+ Reference< XNameAccess > xDatabaseContext( aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW );
+
+ Reference< XDataSource > xDatasource;
+ Any aError;
+ SQLExceptionInfo aSQLError;
+ try
+ {
+ xDatabaseContext->getByName( _rDataSourceName ) >>= xDatasource;
+ }
+ catch(const WrappedTargetException& e)
+ {
+ InteractiveIOException aIOException;
+ if ( ( e.TargetException >>= aIOException )
+ && ( ( aIOException.Code == IOErrorCode_NO_FILE )
+ || ( aIOException.Code == IOErrorCode_NOT_EXISTING )
+ )
+ )
+ {
+ String sErrorMessage = String( ModuleRes( STR_FILE_DOES_NOT_EXIST ) );
+ OFileNotation aTransformer( e.Message );
+ sErrorMessage.SearchAndReplaceAscii( "$file$", aTransformer.get( OFileNotation::N_SYSTEM ) );
+ aSQLError = SQLExceptionInfo( sErrorMessage ).get();
+ }
+ else
+ {
+ aSQLError = SQLExceptionInfo( e.TargetException );
+ if ( !aSQLError.isValid() )
+ aError = e.TargetException;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( xDatasource.is() )
+ return xDatasource;
+
+ if ( aSQLError.isValid() )
+ {
+ if ( _pErrorInfo )
+ {
+ *_pErrorInfo = aSQLError;
+ }
+ else
+ {
+ showError( aSQLError, _pErrorMessageParent, _rxORB );
+ }
+ }
+
+ return Reference<XDataSource>();
+}
+// -----------------------------------------------------------------------------
+Reference< XInterface > getDataSourceOrModel(const Reference< XInterface >& _xObject)
+{
+ Reference< XInterface > xRet;
+ Reference<XDocumentDataSource> xDocumentDataSource(_xObject,UNO_QUERY);
+ if ( xDocumentDataSource.is() )
+ xRet = xDocumentDataSource->getDatabaseDocument();
+
+ if ( !xRet.is() )
+ {
+ Reference<XOfficeDatabaseDocument> xOfficeDoc(_xObject,UNO_QUERY);
+ if ( xOfficeDoc.is() )
+ xRet = xOfficeDoc->getDataSource();
+ }
+
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+void showError(const SQLExceptionInfo& _rInfo,Window* _pParent,const Reference< XMultiServiceFactory >& _xFactory)
+{
+ OSL_ENSURE(_pParent,"showError: Parent window must be NOT NULL!");
+ ::dbtools::showError(_rInfo,VCLUnoHelper::GetInterface(_pParent),_xFactory);
+}
+
+// -----------------------------------------------------------------------------
+::std::vector< Reference<XNameAccess> > getKeyColumns(const Reference<XIndexAccess >& _rxKeys,
+ sal_Int32 _nKeyType)
+{
+ // use keys and indexes for excat postioning
+ // first the keys
+ ::std::vector< Reference<XNameAccess> > vRet;
+ if(_rxKeys.is())
+ {
+ Reference<XPropertySet> xProp;
+ for(sal_Int32 i=0;i< _rxKeys->getCount();++i)
+ {
+ _rxKeys->getByIndex(i) >>= xProp;
+ sal_Int32 nKeyType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+ if(_nKeyType == nKeyType)
+ {
+ Reference<XColumnsSupplier> xKeyColsSup(xProp,UNO_QUERY);
+ OSL_ENSURE(xKeyColsSup.is(),"Columnsupplier is null!");
+ vRet.push_back(xKeyColsSup->getColumns());
+ }
+ }
+ }
+
+ return vRet;
+}
+// -----------------------------------------------------------------------------
+
+TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
+ sal_Int32 _nType,
+ const ::rtl::OUString& _sTypeName,
+ const ::rtl::OUString& _sCreateParams,
+ sal_Int32 _nPrecision,
+ sal_Int32 _nScale,
+ sal_Bool _bAutoIncrement,
+ sal_Bool& _brForceToType)
+{
+ TOTypeInfoSP pTypeInfo;
+ _brForceToType = sal_False;
+ // search for type
+ ::std::pair<OTypeInfoMap::const_iterator, OTypeInfoMap::const_iterator> aPair = _rTypeInfo.equal_range(_nType);
+ OTypeInfoMap::const_iterator aIter = aPair.first;
+ if(aIter != _rTypeInfo.end()) // compare with end is correct here
+ {
+ for(;aIter != aPair.second;++aIter)
+ {
+ // search the best matching type
+ #ifdef DBG_UTIL
+ ::rtl::OUString sDBTypeName = aIter->second->aTypeName; (void)sDBTypeName;
+ sal_Int32 nDBTypePrecision = aIter->second->nPrecision; (void)nDBTypePrecision;
+ sal_Int32 nDBTypeScale = aIter->second->nMaximumScale; (void)nDBTypeScale;
+ sal_Bool bDBAutoIncrement = aIter->second->bAutoIncrement; (void)bDBAutoIncrement;
+ #endif
+ if ( (
+ !_sTypeName.getLength()
+ || (aIter->second->aTypeName.equalsIgnoreAsciiCase(_sTypeName))
+ )
+ && (
+ (
+ !aIter->second->aCreateParams.getLength()
+ && !_sCreateParams.getLength()
+ )
+ || (
+ (aIter->second->nPrecision >= _nPrecision)
+ && (aIter->second->nMaximumScale >= _nScale)
+ && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
+ )
+ )
+ )
+ break;
+ }
+
+ if (aIter == aPair.second)
+ {
+ for(aIter = aPair.first; aIter != aPair.second; ++aIter)
+ {
+ sal_Int32 nPrec = aIter->second->nPrecision;
+ sal_Int32 nScale = aIter->second->nMaximumScale;
+ // search the best matching type (now comparing the local names)
+ if ( (aIter->second->aLocalTypeName.equalsIgnoreAsciiCase(_sTypeName))
+ && (nPrec >= _nPrecision)
+ && (nScale >= _nScale)
+ && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
+ )
+ {
+ OSL_ENSURE(sal_False,
+ ( ::rtl::OString("getTypeInfoFromType: assuming column type ")
+ += ::rtl::OString(aIter->second->aTypeName.getStr(), aIter->second->aTypeName.getLength(), gsl_getSystemTextEncoding())
+ += ::rtl::OString("\" (expected type name ")
+ += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding())
+ += ::rtl::OString(" matches the type's local name).")).getStr());
+ break;
+ }
+ }
+ }
+
+ if (aIter == aPair.second)
+ { // no match for the names, no match for the local names
+ // -> drop the precision and the scale restriction, accept any type with the property
+ // type id (nType)
+
+ //OSL_ENSURE(sal_False,
+ // ( ::rtl::OString("getTypeInfoFromType: did not find a matching type")
+ // += ::rtl::OString(" (expected type name: ")
+ // += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding())
+ // += ::rtl::OString(")! Defaulting to the first matching type.")).getStr());
+ for(aIter = aPair.first; aIter != aPair.second; ++aIter)
+ {
+ // search the best matching type (now comparing the local names)
+#ifdef DBG_UTIL
+ ::rtl::OUString sDBTypeName = aIter->second->aTypeName;
+#endif
+ sal_Int32 nPrec = aIter->second->nPrecision;
+ sal_Int32 nScale = aIter->second->nMaximumScale;
+ if ( (nPrec >= _nPrecision)
+ && (nScale >= _nScale)
+ && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
+ )
+ break;
+ }
+ }
+ if (aIter == aPair.second)
+ {
+ if ( _bAutoIncrement )
+ {
+ for(aIter = aPair.first; aIter != aPair.second; ++aIter)
+ {
+ // search the best matching type (now comparing the local names)
+#ifdef DBG_UTIL
+ ::rtl::OUString sDBTypeName = aIter->second->aTypeName;
+#endif
+ sal_Int32 nScale = aIter->second->nMaximumScale;
+ if ( (nScale >= _nScale)
+ && (aIter->second->bAutoIncrement == _bAutoIncrement)
+ )
+ break;
+ }
+ if ( aIter == aPair.second )
+ {
+ // try it without the auto increment flag
+ pTypeInfo = getTypeInfoFromType(_rTypeInfo,
+ _nType,
+ _sTypeName,
+ _sCreateParams,
+ _nPrecision,
+ _nScale,
+ sal_False,
+ _brForceToType);
+ }
+ else
+ pTypeInfo = aIter->second;
+ }
+ else
+ {
+ pTypeInfo = aPair.first->second;
+ _brForceToType = sal_True;
+ }
+ }
+ else
+ pTypeInfo = aIter->second;
+ }
+ else
+ {
+ ::comphelper::TStringMixEqualFunctor aCase(sal_False);
+ // search for typeinfo where the typename is equal _sTypeName
+ OTypeInfoMap::const_iterator typeInfoLoop = _rTypeInfo.begin();
+ OTypeInfoMap::const_iterator typeInfoEnd = _rTypeInfo.end();
+ for (; typeInfoLoop != typeInfoEnd; ++typeInfoLoop)
+ {
+ if ( aCase( typeInfoLoop->second->getDBName() , _sTypeName ) )
+ {
+ pTypeInfo = typeInfoLoop->second;
+ break;
+ }
+ }
+ }
+
+ OSL_ENSURE(pTypeInfo, "getTypeInfoFromType: no type info found for this type!");
+ return pTypeInfo;
+}
+// -----------------------------------------------------------------------------
+void fillTypeInfo( const Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection,
+ const String& _rsTypeNames,
+ OTypeInfoMap& _rTypeInfoMap,
+ ::std::vector<OTypeInfoMap::iterator>& _rTypeInfoIters)
+{
+ if(!_rxConnection.is())
+ return;
+ Reference< XResultSet> xRs = _rxConnection->getMetaData ()->getTypeInfo ();
+ Reference< XRow> xRow(xRs,UNO_QUERY);
+ // Information for a single SQL type
+ if(xRs.is())
+ {
+ static const ::rtl::OUString aB1 = ::rtl::OUString::createFromAscii(" [ ");
+ static const ::rtl::OUString aB2 = ::rtl::OUString::createFromAscii(" ]");
+ Reference<XResultSetMetaData> xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(xRs,UNO_QUERY)->getMetaData();
+ ::connectivity::ORowSetValue aValue;
+ ::std::vector<sal_Int32> aTypes;
+ ::std::vector<sal_Bool> aNullable;
+ // Loop on the result set until we reach end of file
+ while (xRs->next())
+ {
+ TOTypeInfoSP pInfo(new OTypeInfo());
+ sal_Int32 nPos = 1;
+ if ( aTypes.empty() )
+ {
+ sal_Int32 nCount = xResultSetMetaData->getColumnCount();
+ if ( nCount < 1 )
+ nCount = 18;
+ aTypes.reserve(nCount+1);
+ aTypes.push_back(-1);
+ aNullable.push_back(sal_False);
+ for (sal_Int32 j = 1; j <= nCount ; ++j)
+ {
+ aTypes.push_back(xResultSetMetaData->getColumnType(j));
+ aNullable.push_back(xResultSetMetaData->isNullable(j) != ColumnValue::NO_NULLS);
+ }
+ }
+
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->aTypeName = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->nType = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->nPrecision = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->aLiteralPrefix = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->aLiteralSuffix = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->aCreateParams = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->bNullable = (sal_Int32)aValue == ColumnValue::NULLABLE;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->bCaseSensitive = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->nSearchType = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->bUnsigned = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->bCurrency = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->bAutoIncrement = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->aLocalTypeName = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->nMinimumScale = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->nMaximumScale = aValue;
+ nPos = 18;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+
+ // check if values are less than zero like it happens in a oracle jdbc driver
+ if( pInfo->nPrecision < 0)
+ pInfo->nPrecision = 0;
+ if( pInfo->nMinimumScale < 0)
+ pInfo->nMinimumScale = 0;
+ if( pInfo->nMaximumScale < 0)
+ pInfo->nMaximumScale = 0;
+
+ String aName;
+ switch(pInfo->nType)
+ {
+ case DataType::CHAR:
+ aName = _rsTypeNames.GetToken(TYPE_CHAR);
+ break;
+ case DataType::VARCHAR:
+ aName = _rsTypeNames.GetToken(TYPE_TEXT);
+ break;
+ case DataType::DECIMAL:
+ aName = _rsTypeNames.GetToken(TYPE_DECIMAL);
+ break;
+ case DataType::NUMERIC:
+ aName = _rsTypeNames.GetToken(TYPE_NUMERIC);
+ break;
+ case DataType::BIGINT:
+ aName = _rsTypeNames.GetToken(TYPE_BIGINT);
+ break;
+ case DataType::FLOAT:
+ aName = _rsTypeNames.GetToken(TYPE_FLOAT);
+ break;
+ case DataType::DOUBLE:
+ aName = _rsTypeNames.GetToken(TYPE_DOUBLE);
+ break;
+ case DataType::LONGVARCHAR:
+ aName = _rsTypeNames.GetToken(TYPE_MEMO);
+ break;
+ case DataType::LONGVARBINARY:
+ aName = _rsTypeNames.GetToken(TYPE_IMAGE);
+ break;
+ case DataType::DATE:
+ aName = _rsTypeNames.GetToken(TYPE_DATE);
+ break;
+ case DataType::TIME:
+ aName = _rsTypeNames.GetToken(TYPE_TIME);
+ break;
+ case DataType::TIMESTAMP:
+ aName = _rsTypeNames.GetToken(TYPE_DATETIME);
+ break;
+ case DataType::BIT:
+ if ( pInfo->aCreateParams.getLength() )
+ {
+ aName = _rsTypeNames.GetToken(TYPE_BIT);
+ break;
+ }
+ // run through
+ case DataType::BOOLEAN:
+ aName = _rsTypeNames.GetToken(TYPE_BOOL);
+ break;
+ case DataType::TINYINT:
+ aName = _rsTypeNames.GetToken(TYPE_TINYINT);
+ break;
+ case DataType::SMALLINT:
+ aName = _rsTypeNames.GetToken(TYPE_SMALLINT);
+ break;
+ case DataType::INTEGER:
+ aName = _rsTypeNames.GetToken(TYPE_INTEGER);
+ break;
+ case DataType::REAL:
+ aName = _rsTypeNames.GetToken(TYPE_REAL);
+ break;
+ case DataType::BINARY:
+ aName = _rsTypeNames.GetToken(TYPE_BINARY);
+ break;
+ case DataType::VARBINARY:
+ aName = _rsTypeNames.GetToken(TYPE_VARBINARY);
+ break;
+ case DataType::SQLNULL:
+ aName = _rsTypeNames.GetToken(TYPE_SQLNULL);
+ break;
+ case DataType::OBJECT:
+ aName = _rsTypeNames.GetToken(TYPE_OBJECT);
+ break;
+ case DataType::DISTINCT:
+ aName = _rsTypeNames.GetToken(TYPE_DISTINCT);
+ break;
+ case DataType::STRUCT:
+ aName = _rsTypeNames.GetToken(TYPE_STRUCT);
+ break;
+ case DataType::ARRAY:
+ aName = _rsTypeNames.GetToken(TYPE_ARRAY);
+ break;
+ case DataType::BLOB:
+ aName = _rsTypeNames.GetToken(TYPE_BLOB);
+ break;
+ case DataType::CLOB:
+ aName = _rsTypeNames.GetToken(TYPE_CLOB);
+ break;
+ case DataType::REF:
+ aName = _rsTypeNames.GetToken(TYPE_REF);
+ break;
+ case DataType::OTHER:
+ aName = _rsTypeNames.GetToken(TYPE_OTHER);
+ break;
+ }
+ if ( aName.Len() )
+ {
+ pInfo->aUIName = aName.GetBuffer();
+ pInfo->aUIName += aB1;
+ }
+ pInfo->aUIName += pInfo->aTypeName;
+ if ( aName.Len() )
+ pInfo->aUIName += aB2;
+ // Now that we have the type info, save it in the multimap
+ _rTypeInfoMap.insert(OTypeInfoMap::value_type(pInfo->nType,pInfo));
+ }
+ // for a faster index access
+ _rTypeInfoIters.reserve(_rTypeInfoMap.size());
+
+ OTypeInfoMap::iterator aIter = _rTypeInfoMap.begin();
+ OTypeInfoMap::iterator aEnd = _rTypeInfoMap.end();
+ for(;aIter != aEnd;++aIter)
+ _rTypeInfoIters.push_back(aIter);
+
+ // Close the result set/statement.
+
+ ::comphelper::disposeComponent(xRs);
+ }
+}
+// -----------------------------------------------------------------------------
+void setColumnProperties(const Reference<XPropertySet>& _rxColumn,const OFieldDescription* _pFieldDesc)
+{
+ _rxColumn->setPropertyValue(PROPERTY_NAME,makeAny(_pFieldDesc->GetName()));
+ _rxColumn->setPropertyValue(PROPERTY_TYPENAME,makeAny(_pFieldDesc->getTypeInfo()->aTypeName));
+ _rxColumn->setPropertyValue(PROPERTY_TYPE,makeAny(_pFieldDesc->GetType()));
+ _rxColumn->setPropertyValue(PROPERTY_PRECISION,makeAny(_pFieldDesc->GetPrecision()));
+ _rxColumn->setPropertyValue(PROPERTY_SCALE,makeAny(_pFieldDesc->GetScale()));
+ _rxColumn->setPropertyValue(PROPERTY_ISNULLABLE, makeAny(_pFieldDesc->GetIsNullable()));
+ _rxColumn->setPropertyValue(PROPERTY_ISAUTOINCREMENT,::cppu::bool2any(_pFieldDesc->IsAutoIncrement()));
+ _rxColumn->setPropertyValue(PROPERTY_DESCRIPTION,makeAny(_pFieldDesc->GetDescription()));
+ if ( _rxColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISCURRENCY) && _pFieldDesc->IsCurrency() )
+ _rxColumn->setPropertyValue(PROPERTY_ISCURRENCY,::cppu::bool2any(_pFieldDesc->IsCurrency()));
+ // set autoincrement value when available
+ // and only set when the entry is not empty, that lets the value in the column untouched
+ if ( _pFieldDesc->IsAutoIncrement() && _pFieldDesc->GetAutoIncrementValue().getLength() && _rxColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) )
+ _rxColumn->setPropertyValue(PROPERTY_AUTOINCREMENTCREATION,makeAny(_pFieldDesc->GetAutoIncrementValue()));
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString createDefaultName(const Reference< XDatabaseMetaData>& _xMetaData,const Reference<XNameAccess>& _xTables,const ::rtl::OUString& _sName)
+{
+ OSL_ENSURE(_xMetaData.is(),"No MetaData!");
+ ::rtl::OUString sDefaultName = _sName;
+ try
+ {
+ ::rtl::OUString sCatalog,sSchema,sCompsedName;
+ if(_xMetaData->supportsCatalogsInTableDefinitions())
+ {
+ try
+ {
+ Reference< XConnection> xCon = _xMetaData->getConnection();
+ if ( xCon.is() )
+ sCatalog = xCon->getCatalog();
+ if ( !sCatalog.getLength() )
+ {
+ Reference<XResultSet> xRes = _xMetaData->getCatalogs();
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ while(xRes.is() && xRes->next())
+ {
+ sCatalog = xRow->getString(1);
+ if(!xRow->wasNull())
+ break;
+ }
+ }
+ }
+ catch(const SQLException&)
+ {
+ }
+ }
+ if(_xMetaData->supportsSchemasInTableDefinitions())
+ {
+ sSchema = _xMetaData->getUserName();
+ }
+ sCompsedName = ::dbtools::composeTableName( _xMetaData, sCatalog, sSchema, _sName, sal_False, ::dbtools::eInDataManipulation );
+ sDefaultName = ::dbtools::createUniqueName(_xTables,sCompsedName);
+ }
+ catch(const SQLException&)
+ {
+ }
+ return sDefaultName;
+}
+// -----------------------------------------------------------------------------
+sal_Bool checkDataSourceAvailable(const ::rtl::OUString& _sDataSourceName,const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB)
+{
+ sal_Bool bRet = sal_False;
+ Reference< XNameAccess > xDataBaseContext(_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
+ if ( xDataBaseContext.is() )
+ {
+ bRet = xDataBaseContext->hasByName(_sDataSourceName);
+ if ( !bRet )
+ { // try if this one is a URL
+ try
+ {
+ bRet = xDataBaseContext->getByName(_sDataSourceName).hasValue();
+ }
+ catch(Exception)
+ {
+ }
+ }
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 mapTextAllign(const SvxCellHorJustify& _eAlignment)
+{
+ sal_Int32 nAlignment = com::sun::star::awt::TextAlign::LEFT;
+ switch (_eAlignment)
+ {
+ case SVX_HOR_JUSTIFY_STANDARD:
+ case SVX_HOR_JUSTIFY_LEFT: nAlignment = ::com::sun::star::awt::TextAlign::LEFT; break;
+ case SVX_HOR_JUSTIFY_CENTER: nAlignment = ::com::sun::star::awt::TextAlign::CENTER; break;
+ case SVX_HOR_JUSTIFY_RIGHT: nAlignment = ::com::sun::star::awt::TextAlign::RIGHT; break;
+ default:
+ OSL_ENSURE(0,"Invalid TextAlign!");
+ }
+ return nAlignment;
+}
+// -----------------------------------------------------------------------------
+SvxCellHorJustify mapTextJustify(const sal_Int32& _nAlignment)
+{
+ SvxCellHorJustify eJustify = SVX_HOR_JUSTIFY_LEFT;
+ switch (_nAlignment)
+ {
+ case ::com::sun::star::awt::TextAlign::LEFT : eJustify = SVX_HOR_JUSTIFY_LEFT; break;
+ case ::com::sun::star::awt::TextAlign::CENTER : eJustify = SVX_HOR_JUSTIFY_CENTER; break;
+ case ::com::sun::star::awt::TextAlign::RIGHT : eJustify = SVX_HOR_JUSTIFY_RIGHT; break;
+ default:
+ OSL_ENSURE(0,"Invalid TextAlign!");
+ }
+ return eJustify;
+}
+// -----------------------------------------------------------------------------
+float ConvertFontWeight( ::FontWeight eWeight )
+{
+ if( eWeight == WEIGHT_DONTKNOW )
+ return ::com::sun::star::awt::FontWeight::DONTKNOW;
+ else if( eWeight == WEIGHT_THIN )
+ return ::com::sun::star::awt::FontWeight::THIN;
+ else if( eWeight == WEIGHT_ULTRALIGHT )
+ return ::com::sun::star::awt::FontWeight::ULTRALIGHT;
+ else if( eWeight == WEIGHT_LIGHT )
+ return ::com::sun::star::awt::FontWeight::LIGHT;
+ else if( eWeight == WEIGHT_SEMILIGHT )
+ return ::com::sun::star::awt::FontWeight::SEMILIGHT;
+ else if( ( eWeight == WEIGHT_NORMAL ) || ( eWeight == WEIGHT_MEDIUM ) )
+ return ::com::sun::star::awt::FontWeight::NORMAL;
+ else if( eWeight == WEIGHT_SEMIBOLD )
+ return ::com::sun::star::awt::FontWeight::SEMIBOLD;
+ else if( eWeight == WEIGHT_BOLD )
+ return ::com::sun::star::awt::FontWeight::BOLD;
+ else if( eWeight == WEIGHT_ULTRABOLD )
+ return ::com::sun::star::awt::FontWeight::ULTRABOLD;
+ else if( eWeight == WEIGHT_BLACK )
+ return ::com::sun::star::awt::FontWeight::BLACK;
+
+ OSL_ENSURE(0, "Unknown FontWeigth" );
+ return ::com::sun::star::awt::FontWeight::DONTKNOW;
+}
+// -----------------------------------------------------------------------------
+float ConvertFontWidth( ::FontWidth eWidth )
+{
+ if( eWidth == WIDTH_DONTKNOW )
+ return ::com::sun::star::awt::FontWidth::DONTKNOW;
+ else if( eWidth == WIDTH_ULTRA_CONDENSED )
+ return ::com::sun::star::awt::FontWidth::ULTRACONDENSED;
+ else if( eWidth == WIDTH_EXTRA_CONDENSED )
+ return ::com::sun::star::awt::FontWidth::EXTRACONDENSED;
+ else if( eWidth == WIDTH_CONDENSED )
+ return ::com::sun::star::awt::FontWidth::CONDENSED;
+ else if( eWidth == WIDTH_SEMI_CONDENSED )
+ return ::com::sun::star::awt::FontWidth::SEMICONDENSED;
+ else if( eWidth == WIDTH_NORMAL )
+ return ::com::sun::star::awt::FontWidth::NORMAL;
+ else if( eWidth == WIDTH_SEMI_EXPANDED )
+ return ::com::sun::star::awt::FontWidth::SEMIEXPANDED;
+ else if( eWidth == WIDTH_EXPANDED )
+ return ::com::sun::star::awt::FontWidth::EXPANDED;
+ else if( eWidth == WIDTH_EXTRA_EXPANDED )
+ return ::com::sun::star::awt::FontWidth::EXTRAEXPANDED;
+ else if( eWidth == WIDTH_ULTRA_EXPANDED )
+ return ::com::sun::star::awt::FontWidth::ULTRAEXPANDED;
+
+ OSL_ENSURE(0, "Unknown FontWidth" );
+ return ::com::sun::star::awt::FontWidth::DONTKNOW;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::awt::FontDescriptor CreateFontDescriptor( const Font& rFont )
+{
+ ::com::sun::star::awt::FontDescriptor aFD;
+ aFD.Name = rFont.GetName();
+ aFD.StyleName = rFont.GetStyleName();
+ aFD.Height = (sal_Int16)rFont.GetSize().Height();
+ aFD.Width = (sal_Int16)rFont.GetSize().Width();
+ aFD.Family = sal::static_int_cast< sal_Int16 >(rFont.GetFamily());
+ aFD.CharSet = rFont.GetCharSet();
+ aFD.Pitch = sal::static_int_cast< sal_Int16 >(rFont.GetPitch());
+ aFD.CharacterWidth = ConvertFontWidth( rFont.GetWidthType() );
+ aFD.Weight = ConvertFontWeight( rFont.GetWeight() );
+ aFD.Slant = (::com::sun::star::awt::FontSlant)rFont.GetItalic();
+ aFD.Underline = sal::static_int_cast< sal_Int16 >(
+ rFont.GetUnderline());
+ aFD.Strikeout = sal::static_int_cast< sal_Int16 >(
+ rFont.GetStrikeout());
+ aFD.Orientation = rFont.GetOrientation();
+ aFD.Kerning = rFont.IsKerning();
+ aFD.WordLineMode = rFont.IsWordLineMode();
+ aFD.Type = 0; // ??? => Nur an Metric...
+ return aFD;
+}
+// -----------------------------------------------------------------------------
+void callColumnFormatDialog(const Reference<XPropertySet>& xAffectedCol,
+ const Reference<XPropertySet>& xField,
+ SvNumberFormatter* _pFormatter,
+ Window* _pParent)
+{
+ if (xAffectedCol.is() && xField.is())
+ {
+ try
+ {
+ Reference< XPropertySetInfo > xInfo = xAffectedCol->getPropertySetInfo();
+ sal_Bool bHasFormat = xInfo->hasPropertyByName(PROPERTY_FORMATKEY);
+ sal_Int32 nDataType = ::comphelper::getINT32(xField->getPropertyValue(PROPERTY_TYPE));
+
+ SvxCellHorJustify eJustify(SVX_HOR_JUSTIFY_STANDARD);
+ Any aAlignment = xAffectedCol->getPropertyValue(PROPERTY_ALIGN);
+ if (aAlignment.hasValue())
+ eJustify = dbaui::mapTextJustify(::comphelper::getINT16(aAlignment));
+ sal_Int32 nFormatKey = 0;
+ if ( bHasFormat )
+ nFormatKey = ::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY));
+
+ sal_uInt16 nFlags = 0;
+ if(callColumnFormatDialog(_pParent,_pFormatter,nDataType,nFormatKey,eJustify,nFlags,bHasFormat))
+ {
+ xAffectedCol->setPropertyValue(PROPERTY_ALIGN, makeAny((sal_Int16)dbaui::mapTextAllign(eJustify)));
+ if (nFlags & TP_ATTR_NUMBER)
+ xAffectedCol->setPropertyValue(PROPERTY_FORMATKEY, makeAny(nFormatKey));
+
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool callColumnFormatDialog(Window* _pParent,
+ SvNumberFormatter* _pFormatter,
+ sal_Int32 _nDataType,
+ sal_Int32& _nFormatKey,
+ SvxCellHorJustify& _eJustify,
+ sal_uInt16& _nFlags,
+ sal_Bool _bHasFormat)
+{
+ sal_Bool bRet = sal_False;
+ // the allowed format changes depend of the type of the field ...
+ _nFlags = TP_ATTR_ALIGN;
+
+ if (_bHasFormat)
+ _nFlags |= TP_ATTR_NUMBER;
+
+ // ------------
+ // UNO->ItemSet
+ static SfxItemInfo aItemInfos[] =
+ {
+ { 0, 0 },
+ { SID_ATTR_NUMBERFORMAT_VALUE, SFX_ITEM_POOLABLE },
+ { SID_ATTR_ALIGN_HOR_JUSTIFY, SFX_ITEM_POOLABLE },
+ { SID_ATTR_NUMBERFORMAT_ONE_AREA, SFX_ITEM_POOLABLE },
+ { SID_ATTR_NUMBERFORMAT_INFO, SFX_ITEM_POOLABLE }
+ };
+ static sal_uInt16 aAttrMap[] =
+ {
+ SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY,
+ SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA,
+ SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
+ 0
+ };
+
+ SfxPoolItem* pDefaults[] =
+ {
+ new SfxRangeItem(SBA_DEF_RANGEFORMAT, SBA_DEF_FMTVALUE, SBA_ATTR_ALIGN_HOR_JUSTIFY),
+ new SfxUInt32Item(SBA_DEF_FMTVALUE),
+ new SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, SBA_ATTR_ALIGN_HOR_JUSTIFY),
+ new SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_False),
+ new SvxNumberInfoItem(SID_ATTR_NUMBERFORMAT_INFO)
+ };
+
+ SfxItemPool* pPool = new SfxItemPool(String::CreateFromAscii("GridBrowserProperties"), SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, aItemInfos, pDefaults);
+ pPool->SetDefaultMetric( SFX_MAPUNIT_TWIP ); // ripped, don't understand why
+ pPool->FreezeIdRanges(); // the same
+
+ SfxItemSet* pFormatDescriptor = new SfxItemSet(*pPool, aAttrMap);
+ // fill it
+ pFormatDescriptor->Put(SvxHorJustifyItem(_eJustify, SBA_ATTR_ALIGN_HOR_JUSTIFY));
+ sal_Bool bText = sal_False;
+ if (_bHasFormat)
+ {
+ // if the col is bound to a text field we have to disallow all non-text formats
+ if ((DataType::CHAR == _nDataType) || (DataType::VARCHAR == _nDataType) || (DataType::LONGVARCHAR == _nDataType) || (DataType::CLOB == _nDataType))
+ {
+ bText = sal_True;
+ pFormatDescriptor->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_True));
+ if (!_pFormatter->IsTextFormat(_nFormatKey))
+ // text fields can only have text formats
+ _nFormatKey = _pFormatter->GetStandardFormat(NUMBERFORMAT_TEXT,_pParent->GetSettings().GetLanguage());
+ }
+
+ pFormatDescriptor->Put(SfxUInt32Item(SBA_DEF_FMTVALUE, _nFormatKey));
+ }
+
+ if (!bText)
+ {
+ double dPreviewVal = 1234.56789;
+ SvxNumberInfoItem aFormatter(_pFormatter, dPreviewVal, SID_ATTR_NUMBERFORMAT_INFO);
+ pFormatDescriptor->Put(aFormatter);
+ }
+
+ { // want the dialog to be destroyed before our set
+ SbaSbAttrDlg aDlg(_pParent, pFormatDescriptor, _pFormatter, _nFlags);
+ if (RET_OK == aDlg.Execute())
+ {
+ // ------------
+ // ItemSet->UNO
+ // UNO-properties
+ const SfxItemSet* pSet = aDlg.GetExampleSet();
+ // (of course we could put the modified items directly into the column, but then the UNO-model
+ // won't reflect these changes, and why do we have a model, then ?)
+
+ // horizontal justify
+ SFX_ITEMSET_GET(*pSet, pHorJustify, SvxHorJustifyItem, SBA_ATTR_ALIGN_HOR_JUSTIFY, sal_True);
+
+ _eJustify = (SvxCellHorJustify)pHorJustify->GetValue();
+
+ // format key
+ if (_nFlags & TP_ATTR_NUMBER)
+ {
+ SFX_ITEMSET_GET(*pSet, pFormat, SfxUInt32Item, SBA_DEF_FMTVALUE, sal_True);
+ _nFormatKey = (sal_Int32)pFormat->GetValue();
+ }
+ bRet = sal_True;
+ }
+ // deleted formats
+ const SfxItemSet* pResult = aDlg.GetOutputItemSet();
+ if (pResult)
+ {
+ const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
+ const SvxNumberInfoItem* pInfoItem = static_cast<const SvxNumberInfoItem*>(pItem);
+ if (pInfoItem && pInfoItem->GetDelCount())
+ {
+ const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray();
+
+ for (sal_uInt16 i=0; i< pInfoItem->GetDelCount(); ++i, ++pDeletedKeys)
+ _pFormatter->DeleteEntry(*pDeletedKeys);
+ }
+ }
+ }
+
+ delete pFormatDescriptor;
+ SfxItemPool::Free(pPool);
+ for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
+ delete pDefaults[i];
+
+ return bRet;
+}
+
+//------------------------------------------------------------------------------
+const SfxFilter* getStandardDatabaseFilter()
+{
+ static const String s_sDatabaseType = String::CreateFromAscii("StarOffice XML (Base)");
+ const SfxFilter* pFilter = SfxFilter::GetFilterByName( s_sDatabaseType);
+ OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
+ return pFilter;
+}
+
+
+// -----------------------------------------------------------------------------
+sal_Bool appendToFilter(const Reference<XConnection>& _xConnection,
+ const ::rtl::OUString& _sName,
+ const Reference< XMultiServiceFactory >& _xFactory,
+ Window* _pParent)
+{
+ sal_Bool bRet = sal_False;
+ Reference< XChild> xChild(_xConnection,UNO_QUERY);
+ if(xChild.is())
+ {
+ Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY);
+ if(xProp.is())
+ {
+ Sequence< ::rtl::OUString > aFilter;
+ xProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= aFilter;
+ // first check if we have something like SCHEMA.%
+ sal_Bool bHasToInsert = sal_True;
+ static ::rtl::OUString sPattern = ::rtl::OUString::createFromAscii("%");
+ const ::rtl::OUString* pBegin = aFilter.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aFilter.getLength();
+ for (;pBegin != pEnd; ++pBegin)
+ {
+ if(pBegin->indexOf('%') != -1)
+ {
+ sal_Int32 nLen;
+ if((nLen = pBegin->lastIndexOf('.')) != -1 && !pBegin->compareTo(_sName,nLen))
+ bHasToInsert = sal_False;
+ else if(pBegin->getLength() == 1)
+ bHasToInsert = sal_False;
+ }
+ }
+
+ bRet = sal_True;
+ if(bHasToInsert)
+ {
+ if(! ::dbaui::checkDataSourceAvailable(::comphelper::getString(xProp->getPropertyValue(PROPERTY_NAME)),_xFactory))
+ {
+ String aMessage(ModuleRes(STR_TABLEDESIGN_DATASOURCE_DELETED));
+ OSQLWarningBox( _pParent, aMessage ).Execute();
+ bRet = sal_False;
+ }
+ else
+ {
+ aFilter.realloc(aFilter.getLength()+1);
+ aFilter.getArray()[aFilter.getLength()-1] = _sName;
+ xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aFilter));
+ }
+ }
+ }
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void notifySystemWindow(Window* _pWindow,Window* _pToRegister, ::comphelper::mem_fun1_t<TaskPaneList,Window*> _rMemFunc)
+{
+ OSL_ENSURE(_pWindow,"Window can not be null!");
+ SystemWindow* pSystemWindow = _pWindow ? _pWindow->GetSystemWindow() : NULL;
+ if ( pSystemWindow )
+ {
+ _rMemFunc( pSystemWindow->GetTaskPaneList(), _pToRegister );
+ }
+}
+// -----------------------------------------------------------------------------
+void adjustToolBoxSize(ToolBox* _pToolBox)
+{
+ // adjust the toolbox size, otherwise large bitmaps don't fit into
+ Size aOldSize = _pToolBox->GetSizePixel();
+ Size aSize = _pToolBox->CalcWindowSizePixel();
+ if ( !aSize.Width() )
+ aSize.Width() = aOldSize.Width();
+ else if ( !aSize.Height() )
+ aSize.Height() = aOldSize.Height();
+
+ Size aTbSize = _pToolBox->GetSizePixel();
+ if ( (aSize.Width() && aSize.Width() != aTbSize.Width()) ||
+ (aSize.Height() && aSize.Height() != aTbSize.Height()) )
+ {
+ _pToolBox->SetPosSizePixel( _pToolBox->GetPosPixel(), aSize );
+ _pToolBox->Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool isHiContrast(Window* _pWindow)
+{
+ OSL_ENSURE(_pWindow,"Window must be not null!");
+ Window* pIter = _pWindow;
+ // while( pIter && pIter->GetBackground().GetColor().GetColor() == COL_TRANSPARENT )
+ while( pIter )
+ {
+ if ( pIter->GetBackground().GetColor().GetColor() == COL_TRANSPARENT )
+ pIter = pIter->GetParent();
+ else
+ break;
+ }
+ return pIter && pIter->GetSettings().GetStyleSettings().GetHighContrastMode();
+}
+
+// -----------------------------------------------------------------------------
+void adjustBrowseBoxColumnWidth( ::svt::EditBrowseBox* _pBox, sal_uInt16 _nColId )
+{
+ sal_Int32 nColSize = -1;
+ sal_uInt32 nDefaultWidth = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) );
+ if ( nDefaultWidth != _pBox->GetColumnWidth( _nColId ) )
+ {
+ Size aSizeMM = _pBox->PixelToLogic( Size( _pBox->GetColumnWidth( _nColId ), 0 ), MapMode( MAP_MM ) );
+ nColSize = aSizeMM.Width() * 10;
+ }
+
+ Size aDefaultMM = _pBox->PixelToLogic( Size( nDefaultWidth, 0 ), MapMode( MAP_MM ) );
+
+ DlgSize aColumnSizeDlg( _pBox, nColSize, sal_False, aDefaultMM.Width() * 10 );
+ if ( aColumnSizeDlg.Execute() )
+ {
+ sal_Int32 nValue = aColumnSizeDlg.GetValue();
+ if ( -1 == nValue )
+ { // default width
+ nValue = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) );
+ }
+ else
+ {
+ Size aSizeMM( nValue / 10, 0 );
+ nValue = _pBox->LogicToPixel( aSizeMM, MapMode( MAP_MM ) ).Width();
+ }
+ _pBox->SetColumnWidth( _nColId, nValue );
+ }
+}
+// -----------------------------------------------------------------------------
+// check if SQL92 name checking is enabled
+sal_Bool isSQL92CheckEnabled(const Reference<XConnection>& _xConnection)
+{
+ return ::dbtools::getBooleanDataSourceSetting( _xConnection, PROPERTY_ENABLESQL92CHECK );
+}
+// -----------------------------------------------------------------------------
+sal_Bool isAppendTableAliasEnabled(const Reference<XConnection>& _xConnection)
+{
+ return ::dbtools::getBooleanDataSourceSetting( _xConnection, INFO_APPEND_TABLE_ALIAS );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool generateAsBeforeTableAlias(const Reference<XConnection>& _xConnection)
+{
+ return ::dbtools::getBooleanDataSourceSetting( _xConnection, INFO_AS_BEFORE_CORRELATION_NAME );
+}
+
+// -----------------------------------------------------------------------------
+void fillAutoIncrementValue(const Reference<XPropertySet>& _xDatasource,
+ sal_Bool& _rAutoIncrementValueEnabled,
+ ::rtl::OUString& _rsAutoIncrementValue)
+{
+ if ( _xDatasource.is() )
+ {
+ OSL_ENSURE(_xDatasource->getPropertySetInfo()->hasPropertyByName(PROPERTY_INFO),"NO datasource supplied!");
+ Sequence<PropertyValue> aInfo;
+ _xDatasource->getPropertyValue(PROPERTY_INFO) >>= aInfo;
+
+ // search the right propertyvalue
+ const PropertyValue* pValue =::std::find_if(aInfo.getConstArray(),
+ aInfo.getConstArray() + aInfo.getLength(),
+ ::std::bind2nd(TPropertyValueEqualFunctor(),PROPERTY_AUTOINCREMENTCREATION));
+ if ( pValue && pValue != (aInfo.getConstArray() + aInfo.getLength()) )
+ pValue->Value >>= _rsAutoIncrementValue;
+ pValue =::std::find_if(aInfo.getConstArray(),
+ aInfo.getConstArray() + aInfo.getLength(),
+ ::std::bind2nd(TPropertyValueEqualFunctor(),::rtl::OUString::createFromAscii("IsAutoRetrievingEnabled") ));
+ if ( pValue && pValue != (aInfo.getConstArray() + aInfo.getLength()) )
+ pValue->Value >>= _rAutoIncrementValueEnabled;
+ }
+}
+// -----------------------------------------------------------------------------
+void fillAutoIncrementValue(const Reference<XConnection>& _xConnection,
+ sal_Bool& _rAutoIncrementValueEnabled,
+ ::rtl::OUString& _rsAutoIncrementValue)
+{
+ Reference< XChild> xChild(_xConnection,UNO_QUERY);
+ if(xChild.is())
+ {
+ Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY);
+ fillAutoIncrementValue(xProp,_rAutoIncrementValueEnabled,_rsAutoIncrementValue);
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString getStrippedDatabaseName(const Reference<XPropertySet>& _xDataSource,::rtl::OUString& _rsDatabaseName)
+{
+ if ( !_rsDatabaseName.getLength() && _xDataSource.is() )
+ {
+ try
+ {
+ _xDataSource->getPropertyValue(PROPERTY_NAME) >>= _rsDatabaseName;
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ ::rtl::OUString sName = _rsDatabaseName;
+ INetURLObject aURL(sName);
+ if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ sName = aURL.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS);
+ return sName;
+}
+// -----------------------------------------------------------------------------
+ void AppendConfigToken( ::rtl::OUString& _rURL, sal_Bool _bQuestionMark )
+ {
+ Any aLocale =
+ ::utl::ConfigManager::GetConfigManager()->GetDirectConfigProperty( ::utl::ConfigManager::LOCALE );
+ ::rtl::OUString sLocaleStr;
+ if ( !( aLocale >>= sLocaleStr ) )
+ // fallback is english
+ sLocaleStr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en"));
+
+ // query part exists?
+ if ( _bQuestionMark )
+ // no, so start with '?'
+ _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("?"));
+ else
+ // yes, so only append with '&'
+ _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&"));
+
+ // set parameters
+ _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Language="));
+ _rURL += sLocaleStr;
+ _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&System="));
+ _rURL += SvtHelpOptions().GetSystem();
+ }
+
+namespace
+{
+ // -----------------------------------------------------------------------
+
+ sal_Bool GetHelpAnchor_Impl( const ::rtl::OUString& _rURL, ::rtl::OUString& _rAnchor )
+ {
+ sal_Bool bRet = sal_False;
+ ::rtl::OUString sAnchor;
+
+ try
+ {
+ ::ucbhelper::Content aCnt( INetURLObject( _rURL ).GetMainURL( INetURLObject::NO_DECODE ),
+ Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
+ if ( ( aCnt.getPropertyValue( ::rtl::OUString::createFromAscii( "AnchorName" ) ) >>= sAnchor ) )
+ {
+
+ if ( sAnchor.getLength() > 0 )
+ {
+ _rAnchor = sAnchor;
+ bRet = sal_True;
+ }
+ }
+ else
+ {
+ DBG_ERRORFILE( "Property 'AnchorName' is missing" );
+ }
+ }
+ catch( Exception& )
+ {
+ }
+
+ return bRet;
+ }
+// .........................................................................
+} // annonymous
+// .........................................................................
+// -----------------------------------------------------------------------------
+::com::sun::star::util::URL createHelpAgentURL(const ::rtl::OUString& _sModuleName, const rtl::OString& sHelpId)
+{
+ ::com::sun::star::util::URL aURL;
+ aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.help://" ) );
+ aURL.Complete += _sModuleName;
+ aURL.Complete += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+ aURL.Complete += ::rtl::OUString(sHelpId, sHelpId.getLength(), RTL_TEXTENCODING_UTF8);
+
+ ::rtl::OUString sAnchor;
+ ::rtl::OUString sTempURL = aURL.Complete;
+ AppendConfigToken( sTempURL, sal_True );
+ sal_Bool bHasAnchor = GetHelpAnchor_Impl( sTempURL, sAnchor );
+ AppendConfigToken(aURL.Complete,sal_True);
+ if ( bHasAnchor )
+ {
+ aURL.Complete += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("#"));
+ aURL.Complete += sAnchor;
+ }
+ return aURL;
+}
+// -----------------------------------------------------------------------------
+void setEvalDateFormatForFormatter(Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter)
+{
+ OSL_ENSURE( _rxFormatter.is(),"setEvalDateFormatForFormatter: Formatter is NULL!");
+ if ( _rxFormatter.is() )
+ {
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = _rxFormatter->getNumberFormatsSupplier();
+
+ Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
+ SvNumberFormatsSupplierObj* pSupplierImpl = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+ OSL_ENSURE(pSupplierImpl,"No Supplier!");
+
+ if ( pSupplierImpl )
+ {
+ SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter();
+ pFormatter->SetEvalDateFormat(NF_EVALDATEFORMAT_FORMAT);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap& _rTypeInfo)
+{
+ TOTypeInfoSP pTypeInfo;
+ // first we search for a type which supports autoIncrement
+ OTypeInfoMap::const_iterator aIter = _rTypeInfo.begin();
+ OTypeInfoMap::const_iterator aEnd = _rTypeInfo.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ // OJ: we don't want to set an autoincrement column to be key
+ // because we don't have the possiblity to know how to create
+ // such auto increment column later on
+ // so until we know how to do it, we create a column without autoincrement
+ // if ( !aIter->second->bAutoIncrement )
+ { // therefor we have searched
+ if ( aIter->second->nType == DataType::INTEGER )
+ {
+ pTypeInfo = aIter->second; // alternative
+ break;
+ }
+ else if ( !pTypeInfo.get() && aIter->second->nType == DataType::DOUBLE )
+ pTypeInfo = aIter->second; // alternative
+ else if ( !pTypeInfo.get() && aIter->second->nType == DataType::REAL )
+ pTypeInfo = aIter->second; // alternative
+ }
+ }
+ if ( !pTypeInfo.get() ) // just a fallback
+ pTypeInfo = queryTypeInfoByType(DataType::VARCHAR,_rTypeInfo);
+
+ OSL_ENSURE(pTypeInfo.get(),"checkColumns: cann't find a type which is useable as a key!");
+ return pTypeInfo;
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rTypeInfo)
+{
+ OTypeInfoMap::const_iterator aIter = _rTypeInfo.find(_nDataType);
+ if(aIter != _rTypeInfo.end())
+ return aIter->second;
+ // fall back if the type is unknown
+ TOTypeInfoSP pTypeInfo;
+ switch(_nDataType)
+ {
+ case DataType::TINYINT:
+ if( pTypeInfo = queryTypeInfoByType(DataType::SMALLINT,_rTypeInfo))
+ break;
+ // run through
+ case DataType::SMALLINT:
+ if( pTypeInfo = queryTypeInfoByType(DataType::INTEGER,_rTypeInfo))
+ break;
+ // run through
+ case DataType::INTEGER:
+ if( pTypeInfo = queryTypeInfoByType(DataType::FLOAT,_rTypeInfo))
+ break;
+ // run through
+ case DataType::FLOAT:
+ if( pTypeInfo = queryTypeInfoByType(DataType::REAL,_rTypeInfo))
+ break;
+ // run through
+ case DataType::DATE:
+ case DataType::TIME:
+ if( DataType::DATE == _nDataType || DataType::TIME == _nDataType )
+ {
+ if( pTypeInfo = queryTypeInfoByType(DataType::TIMESTAMP,_rTypeInfo))
+ break;
+ }
+ // run through
+ case DataType::TIMESTAMP:
+ case DataType::REAL:
+ case DataType::BIGINT:
+ if ( pTypeInfo = queryTypeInfoByType(DataType::DOUBLE,_rTypeInfo) )
+ break;
+ // run through
+ case DataType::DOUBLE:
+ if ( pTypeInfo = queryTypeInfoByType(DataType::NUMERIC,_rTypeInfo) )
+ break;
+ // run through
+ case DataType::NUMERIC:
+ pTypeInfo = queryTypeInfoByType(DataType::DECIMAL,_rTypeInfo);
+ break;
+ case DataType::DECIMAL:
+ if ( pTypeInfo = queryTypeInfoByType(DataType::NUMERIC,_rTypeInfo) )
+ break;
+ if ( pTypeInfo = queryTypeInfoByType(DataType::DOUBLE,_rTypeInfo) )
+ break;
+ break;
+ case DataType::VARCHAR:
+ if ( pTypeInfo = queryTypeInfoByType(DataType::LONGVARCHAR,_rTypeInfo) )
+ break;
+ break;
+ case DataType::LONGVARCHAR:
+ if ( pTypeInfo = queryTypeInfoByType(DataType::CLOB,_rTypeInfo) )
+ break;
+ break;
+ default:
+ ;
+ } // switch(_nDataType)
+ if ( !pTypeInfo )
+ {
+ ::rtl::OUString sCreate(RTL_CONSTASCII_USTRINGPARAM("x")),sTypeName;
+ sal_Bool bForce = sal_True;
+ pTypeInfo = ::dbaui::getTypeInfoFromType(_rTypeInfo,DataType::VARCHAR,sTypeName,sCreate,50,0,sal_False,bForce);
+ } // if ( !pTypeInfo )
+ OSL_ENSURE(pTypeInfo,"Wrong DataType supplied!");
+ return pTypeInfo;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 askForUserAction(Window* _pParent,sal_uInt16 _nTitle,sal_uInt16 _nText,sal_Bool _bAll,const ::rtl::OUString& _sName)
+{
+ vos::OGuard aGuard( Application::GetSolarMutex() );
+ String aMsg = String(ModuleRes(_nText));
+ aMsg.SearchAndReplace(String::CreateFromAscii("%1"),String(_sName));
+ OSQLMessageBox aAsk(_pParent,String(ModuleRes(_nTitle )),aMsg,WB_YES_NO | WB_DEF_YES,OSQLMessageBox::Query);
+ if ( _bAll )
+ {
+ aAsk.AddButton(String(ModuleRes(STR_BUTTON_TEXT_ALL)), RET_ALL, 0);
+ aAsk.GetPushButton(RET_ALL)->SetHelpId(HID_CONFIRM_DROP_BUTTON_ALL);
+ }
+ return aAsk.Execute();
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ static ::rtl::OUString lcl_createSDBCLevelStatement( const ::rtl::OUString& _rStatement, const Reference< XConnection >& _rxConnection )
+ {
+ ::rtl::OUString sSDBCLevelStatement( _rStatement );
+ try
+ {
+ Reference< XMultiServiceFactory > xAnalyzerFactory( _rxConnection, UNO_QUERY_THROW );
+ Reference< XSingleSelectQueryAnalyzer > xAnalyzer( xAnalyzerFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
+ xAnalyzer->setQuery( _rStatement );
+ sSDBCLevelStatement = xAnalyzer->getQueryWithSubstitution();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sSDBCLevelStatement;
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > createView( const ::rtl::OUString& _rName, const Reference< XConnection >& _rxConnection,
+ const ::rtl::OUString& _rCommand )
+{
+ Reference<XViewsSupplier> xSup(_rxConnection,UNO_QUERY);
+ Reference< XNameAccess > xViews;
+ if(xSup.is())
+ xViews = xSup->getViews();
+ Reference<XDataDescriptorFactory> xFact(xViews,UNO_QUERY);
+ OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!");
+ if(!xFact.is())
+ return NULL;
+
+ Reference<XPropertySet> xView = xFact->createDataDescriptor();
+ if ( !xView.is() )
+ return NULL;
+
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(_rxConnection->getMetaData(),
+ _rName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+
+ xView->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog));
+ xView->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema));
+ xView->setPropertyValue(PROPERTY_NAME,makeAny(sTable));
+
+ xView->setPropertyValue( PROPERTY_COMMAND, makeAny( _rCommand ) );
+
+ Reference<XAppend> xAppend(xViews,UNO_QUERY);
+ if(xAppend.is())
+ xAppend->appendByDescriptor(xView);
+
+ xView = NULL;
+ // we need to reget the view because after appending it it is no longer valid
+ // but this time it isn't a view object it is a table object with type "VIEW"
+ Reference<XTablesSupplier> xTabSup(_rxConnection,UNO_QUERY);
+ Reference< XNameAccess > xTables;
+ if ( xTabSup.is() )
+ {
+ xTables = xTabSup->getTables();
+ if ( xTables.is() && xTables->hasByName( _rName ) )
+ xTables->getByName( _rName ) >>= xView;
+ }
+
+ return xView;
+}
+
+// -----------------------------------------------------------------------------
+Reference<XPropertySet> createView( const ::rtl::OUString& _rName, const Reference< XConnection >& _rxConnection
+ ,const Reference<XPropertySet>& _rxSourceObject)
+{
+ ::rtl::OUString sCommand;
+ Reference< XPropertySetInfo > xPSI( _rxSourceObject->getPropertySetInfo(), UNO_SET_THROW );
+ if ( xPSI->hasPropertyByName( PROPERTY_COMMAND ) )
+ {
+ _rxSourceObject->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
+
+ sal_Bool bEscapeProcessing( sal_False );
+ OSL_VERIFY( _rxSourceObject->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bEscapeProcessing );
+ if ( bEscapeProcessing )
+ sCommand = lcl_createSDBCLevelStatement( sCommand, _rxConnection );
+ }
+ else
+ {
+ sCommand = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SELECT * FROM " ) );
+ sCommand += composeTableNameForSelect( _rxConnection, _rxSourceObject );
+ }
+ return createView( _rName, _rxConnection, sCommand );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool insertHierachyElement( Window* _pParent, const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference<XHierarchicalNameContainer>& _xNames,
+ const String& _sParentFolder,
+ sal_Bool _bForm,
+ sal_Bool _bCollection,
+ const Reference<XContent>& _xContent,
+ sal_Bool _bMove)
+{
+ OSL_ENSURE( _xNames.is(), "insertHierachyElement: illegal name container!" );
+ if ( !_xNames.is() )
+ return sal_False;
+
+ Reference<XNameAccess> xNameAccess( _xNames, UNO_QUERY );
+ ::rtl::OUString sName = _sParentFolder;
+ if ( _xNames->hasByHierarchicalName(sName) )
+ {
+ Reference<XChild> xChild(_xNames->getByHierarchicalName(sName),UNO_QUERY);
+ xNameAccess.set(xChild,UNO_QUERY);
+ if ( !xNameAccess.is() && xChild.is() )
+ xNameAccess.set(xChild->getParent(),UNO_QUERY);
+ }
+
+ OSL_ENSURE( xNameAccess.is(), "insertHierachyElement: could not find the proper name container!" );
+ if ( !xNameAccess.is() )
+ return sal_False;
+
+ ::rtl::OUString sNewName;
+ Reference<XPropertySet> xProp(_xContent,UNO_QUERY);
+ if ( xProp.is() )
+ xProp->getPropertyValue(PROPERTY_NAME) >>= sNewName;
+
+ if ( !_bMove || !sNewName.getLength() )
+ {
+ String sTargetName,sLabel;
+ if ( !sNewName.getLength() || xNameAccess->hasByName(sNewName) )
+ {
+ if ( sNewName.getLength() )
+ sTargetName = sNewName;
+ else
+ sTargetName = String(ModuleRes( _bCollection ? STR_NEW_FOLDER : ((_bForm) ? RID_STR_FORM : RID_STR_REPORT)));
+ sLabel = String(ModuleRes( _bCollection ? STR_FOLDER_LABEL : ((_bForm) ? STR_FRM_LABEL : STR_RPT_LABEL)));
+ sTargetName = ::dbtools::createUniqueName(xNameAccess,sTargetName);
+
+
+ // here we have everything needed to create a new query object ...
+ HierarchicalNameCheck aNameChecker( _xNames.get(), sName );
+ // ... ehm, except a new name
+ OSaveAsDlg aAskForName( _pParent,
+ _rxORB,
+ sTargetName,
+ sLabel,
+ aNameChecker,
+ SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS);
+ if ( RET_OK != aAskForName.Execute() )
+ // cancelled by the user
+ return sal_False;
+
+ sNewName = aAskForName.getName();
+ }
+ }
+ else if ( xNameAccess->hasByName(sNewName) )
+ {
+ String sError(ModuleRes(STR_NAME_ALREADY_EXISTS));
+ sError.SearchAndReplaceAscii("#",sNewName);
+ throw SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any());
+ }
+
+ try
+ {
+ Reference<XMultiServiceFactory> xORB( xNameAccess, UNO_QUERY_THROW );
+ Sequence< Any > aArguments(3);
+ PropertyValue aValue;
+ // set as folder
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
+ aValue.Value <<= sNewName;
+ aArguments[0] <<= aValue;
+ //parent
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
+ aValue.Value <<= xNameAccess;
+ aArguments[1] <<= aValue;
+
+ aValue.Name = PROPERTY_EMBEDDEDOBJECT;
+ aValue.Value <<= _xContent;
+ aArguments[2] <<= aValue;
+
+ ::rtl::OUString sServiceName(_bCollection ? ((_bForm) ? SERVICE_NAME_FORM_COLLECTION : SERVICE_NAME_REPORT_COLLECTION) : SERVICE_SDB_DOCUMENTDEFINITION);
+
+ Reference<XContent > xNew( xORB->createInstanceWithArguments( sServiceName, aArguments ), UNO_QUERY_THROW );
+ Reference< XNameContainer > xNameContainer( xNameAccess, UNO_QUERY_THROW );
+ xNameContainer->insertByName( sNewName, makeAny( xNew ) );
+ }
+ catch( const IllegalArgumentException& e )
+ {
+ ::dbtools::throwGenericSQLException( e.Message, e.Context );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return sal_False;
+ }
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+Reference< XNumberFormatter > getNumberFormatter(const Reference< XConnection >& _rxConnection,const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF )
+{
+ // ---------------------------------------------------------------
+ // create a formatter working with the connections format supplier
+ Reference< XNumberFormatter > xFormatter;
+
+ try
+ {
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(_rxConnection, sal_True,_rMF));
+
+ if ( xSupplier.is() )
+ {
+ // create a new formatter
+ xFormatter = Reference< ::com::sun::star::util::XNumberFormatter > (
+ _rMF->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY);
+ if ( xFormatter.is() )
+ xFormatter->attachNumberFormatsSupplier(xSupplier);
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xFormatter;
+}
+
+
+// .........................................................................
+} // dbaui
+// .........................................................................
diff --git a/dbaccess/source/ui/misc/UpdateHelperImpl.hxx b/dbaccess/source/ui/misc/UpdateHelperImpl.hxx
new file mode 100644
index 000000000000..ab48101d672a
--- /dev/null
+++ b/dbaccess/source/ui/misc/UpdateHelperImpl.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef DBAUI_UPDATEHELPERIMPL_HXX
+#define DBAUI_UPDATEHELPERIMPL_HXX
+
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include "IUpdateHelper.hxx"
+#include <rtl/logfile.hxx>
+
+namespace dbaui
+{
+ class ORowUpdateHelper : public IUpdateHelper
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xRowUpdate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xResultSetUpdate; //
+ public:
+ ORowUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _xRowSet)
+ :m_xRowUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY)
+ ,m_xResultSetUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY)
+ {
+ }
+ virtual ~ORowUpdateHelper() {}
+ virtual void updateString(sal_Int32 _nPos, const ::rtl::OUString& _sValue)
+ {
+ m_xRowUpdate->updateString(_nPos, _sValue);
+ }
+ virtual void updateDouble(sal_Int32 _nPos,const double& _nValue)
+ {
+ m_xRowUpdate->updateDouble(_nPos, _nValue);
+ }
+ virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue)
+ {
+ m_xRowUpdate->updateDate(_nPos, _nValue);
+ }
+ virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue)
+ {
+ m_xRowUpdate->updateTime(_nPos, _nValue);
+ }
+ virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue)
+ {
+ m_xRowUpdate->updateTimestamp(_nPos, _nValue);
+ }
+ virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue)
+ {
+ m_xRowUpdate->updateInt(_nPos, _nValue);
+ }
+ virtual void updateNull(sal_Int32 _nPos, ::sal_Int32)
+ {
+ m_xRowUpdate->updateNull(_nPos);
+ }
+ virtual void moveToInsertRow()
+ {
+ m_xResultSetUpdate->moveToInsertRow();
+ }
+ virtual void insertRow()
+ {
+ m_xResultSetUpdate->insertRow();
+ }
+ };
+
+ class OParameterUpdateHelper : public IUpdateHelper
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > m_xPrepared;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters > m_xParameters;
+
+ public:
+ OParameterUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement >& _xPrepared)
+ :m_xPrepared(_xPrepared)
+ ,m_xParameters(_xPrepared,::com::sun::star::uno::UNO_QUERY)
+ {
+ }
+ virtual ~OParameterUpdateHelper() {}
+ virtual void updateString(sal_Int32 _nPos, const ::rtl::OUString& _sValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateString" );
+ m_xParameters->setString(_nPos, _sValue);
+ }
+ virtual void updateDouble(sal_Int32 _nPos,const double& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
+ m_xParameters->setDouble(_nPos, _nValue);
+ }
+ virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
+ m_xParameters->setDate(_nPos, _nValue);
+ }
+ virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
+ m_xParameters->setTime(_nPos, _nValue);
+ }
+ virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
+ m_xParameters->setTimestamp(_nPos, _nValue);
+ }
+ virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateInt" );
+ m_xParameters->setInt(_nPos, _nValue);
+ }
+ virtual void updateNull(sal_Int32 _nPos, ::sal_Int32 sqlType)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateNull" );
+ m_xParameters->setNull(_nPos,sqlType);
+ }
+ virtual void moveToInsertRow()
+ {
+ }
+ virtual void insertRow()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::insertRow" );
+ m_xPrepared->executeUpdate();
+ }
+ };
+}
+
+#endif // DBAUI_UPDATEHELPERIMPL_HXX
+
diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx
new file mode 100644
index 000000000000..6dc59632ef4d
--- /dev/null
+++ b/dbaccess/source/ui/misc/WCPage.cxx
@@ -0,0 +1,418 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "WCPage.hxx"
+#include "WCopyTable.hxx"
+
+#ifndef DBACCESS_SOURCE_UI_MISC_DEFAULTOBJECTNAMECHECK_HXX
+#include "defaultobjectnamecheck.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#include "WizardPages.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_COPYTABLEOPERATION_HPP_
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+
+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
+//========================================================================
+DBG_NAME(OCopyTable)
+//------------------------------------------------------------------------
+OCopyTable::OCopyTable( Window * pParent )
+ :OWizardPage( pParent, ModuleRes(TAB_WIZ_COPYTABLE) )
+ ,m_ftTableName( this, ModuleRes( FT_TABLENAME ) )
+ ,m_edTableName( this, ModuleRes( ET_TABLENAME ) )
+ ,m_aFL_Options( this, ModuleRes( FL_OPTIONS ) )
+ ,m_aRB_DefData( this, ModuleRes( RB_DEFDATA ) )
+ ,m_aRB_Def( this, ModuleRes( RB_DEF ) )
+ ,m_aRB_View( this, ModuleRes( RB_VIEW ) )
+ ,m_aRB_AppendData( this, ModuleRes( RB_APPENDDATA ) )
+ ,m_aCB_UseHeaderLine( this, ModuleRes( CB_USEHEADERLINE ) )
+ ,m_aCB_PrimaryColumn( this, ModuleRes( CB_PRIMARY_COLUMN ) )
+ ,m_aFT_KeyName( this, ModuleRes( FT_KEYNAME ) )
+ ,m_edKeyName( this, ModuleRes( ET_KEYNAME ) )
+ ,m_pPage2(NULL)
+ ,m_pPage3(NULL)
+ ,m_bUseHeaderAllowed(sal_True)
+{
+ DBG_CTOR(OCopyTable,NULL);
+
+ m_edTableName.SetMaxTextLen( EDIT_NOLIMIT );
+
+ if ( m_pParent->m_xDestConnection.is() )
+ {
+ if ( !m_pParent->supportsViews() )
+ m_aRB_View.Disable();
+
+ m_aCB_UseHeaderLine.Check(sal_True);
+ m_bPKeyAllowed = m_pParent->supportsPrimaryKey();
+
+ m_aCB_PrimaryColumn.Enable(m_bPKeyAllowed);
+
+ m_aRB_AppendData.SetClickHdl( LINK( this, OCopyTable, AppendDataClickHdl ) );
+
+ m_aRB_DefData.SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
+ m_aRB_Def.SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
+ m_aRB_View.SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
+
+ m_aCB_PrimaryColumn.SetClickHdl(LINK( this, OCopyTable, KeyClickHdl ) );
+
+ m_aFT_KeyName.Enable(sal_False);
+ m_edKeyName.Enable(sal_False);
+ ::rtl::OUString sKeyName(RTL_CONSTASCII_USTRINGPARAM("ID"));
+ sKeyName = m_pParent->createUniqueName(sKeyName);
+ m_edKeyName.SetText(sKeyName);
+
+ sal_Int32 nMaxLen = m_pParent->getMaxColumnNameLength();
+ m_edKeyName.SetMaxTextLen(nMaxLen ? (xub_StrLen)nMaxLen : EDIT_NOLIMIT);
+ }
+
+ FreeResource();
+
+ SetText(String(ModuleRes(STR_COPYTABLE_TITLE_COPY)));
+}
+
+//------------------------------------------------------------------------
+OCopyTable::~OCopyTable()
+{
+ DBG_DTOR(OCopyTable,NULL);
+}
+//------------------------------------------------------------------------
+IMPL_LINK( OCopyTable, AppendDataClickHdl, Button*, /*pButton*/ )
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+
+ SetAppendDataRadio();
+ return 0;
+}
+//--------dyf ADD
+void OCopyTable::SetAppendDataRadio()
+{
+ m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,sal_True);
+ m_aFT_KeyName.Enable(sal_False);
+ m_aCB_PrimaryColumn.Enable(sal_False);
+ m_edKeyName.Enable(sal_False);
+ m_pParent->setOperation(CopyTableOperation::AppendData);
+}
+
+//--------add end
+//------------------------------------------------------------------------
+IMPL_LINK( OCopyTable, RadioChangeHdl, Button*, pButton )
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,pButton != &m_aRB_View);
+ sal_Bool bKey = m_bPKeyAllowed && pButton != &m_aRB_View;
+ m_aFT_KeyName.Enable(bKey && m_aCB_PrimaryColumn.IsChecked());
+ m_edKeyName.Enable(bKey && m_aCB_PrimaryColumn.IsChecked());
+ m_aCB_PrimaryColumn.Enable(bKey);
+ m_aCB_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*/ )
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ m_edKeyName.Enable(m_aCB_PrimaryColumn.IsChecked());
+ m_aFT_KeyName.Enable(m_aCB_PrimaryColumn.IsChecked());
+ return 0;
+}
+//------------------------------------------------------------------------
+sal_Bool OCopyTable::LeavePage()
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ m_pParent->m_bCreatePrimaryKeyColumn = (m_bPKeyAllowed && m_aCB_PrimaryColumn.IsEnabled()) ? m_aCB_PrimaryColumn.IsChecked() : sal_False;
+ m_pParent->m_aKeyName = m_pParent->m_bCreatePrimaryKeyColumn ? m_edKeyName.GetText() : String();
+ m_pParent->setUseHeaderLine( m_aCB_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_edTableName.GetText(), aErrorInfo ) )
+ {
+ aErrorInfo.append( SQLExceptionInfo::SQL_CONTEXT, String( ModuleRes( STR_SUGGEST_APPEND_TABLE_DATA ) ) );
+ m_pParent->showError(aErrorInfo.get());
+
+ return sal_False;
+ }
+
+ // have to check the length of the table name
+ Reference< XDatabaseMetaData > xMeta = m_pParent->m_xDestConnection->getMetaData();
+ ::rtl::OUString sCatalog;
+ ::rtl::OUString sSchema;
+ ::rtl::OUString sTable;
+ ::dbtools::qualifiedNameComponents( xMeta,
+ m_edTableName.GetText(),
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+ sal_Int32 nMaxLength = xMeta->getMaxTableNameLength();
+ if ( nMaxLength && sTable.getLength() > nMaxLength )
+ {
+ String sError(ModuleRes(STR_INVALID_TABLE_NAME_LENGTH));
+ m_pParent->showError(sError);
+ return sal_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) )
+ {
+ String aInfoString( ModuleRes(STR_WIZ_PKEY_ALREADY_DEFINED) );
+ aInfoString += String(' ');
+ aInfoString += String(m_pParent->m_aKeyName);
+ m_pParent->showError(aInfoString);
+ return sal_False;
+ }
+ }
+
+ if ( !m_edTableName.GetSavedValue().Equals(m_edTableName.GetText()) )
+ { // table exists and name has changed
+ if ( m_pParent->getOperation() == CopyTableOperation::AppendData )
+ {
+ if(!checkAppendData())
+ return sal_False;
+ }
+ else if ( m_nOldOperation == CopyTableOperation::AppendData )
+ {
+ m_edTableName.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 sal_False;
+ }
+ }
+ m_pParent->m_sName = m_edTableName.GetText();
+ m_edTableName.SaveValue();
+
+ if(!m_pParent->m_sName.getLength())
+ {
+ String sError(ModuleRes(STR_INVALID_TABLE_NAME));
+ m_pParent->showError(sError);
+ return sal_False;
+ }
+
+ return sal_True;
+}
+//------------------------------------------------------------------------
+void OCopyTable::ActivatePage()
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ m_pParent->GetOKButton().Enable( sal_True );
+ m_nOldOperation = m_pParent->getOperation();
+ m_edTableName.GrabFocus();
+ m_aCB_UseHeaderLine.Check(m_pParent->UseHeaderLine());
+}
+//------------------------------------------------------------------------
+String OCopyTable::GetTitle() const
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ return String(ModuleRes(STR_WIZ_TABLE_COPY));
+}
+//------------------------------------------------------------------------
+void OCopyTable::Reset()
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ m_bFirstTime = sal_False;
+
+ m_edTableName.SetText( m_pParent->m_sName );
+ m_edTableName.SaveValue();
+}
+//------------------------------------------------------------------------
+sal_Bool OCopyTable::checkAppendData()
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ 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_edTableName.GetText()))
+ {
+ const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector();
+ const sal_uInt32 nSrcSize = pSrcColumns->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_edTableName.GetText() ) >>= xTable;
+ ObjectCopySource aTableCopySource( m_pParent->m_xDestConnection, xTable );
+ m_pParent->loadData( aTableCopySource, m_pParent->m_vDestColumns, m_pParent->m_aDestVec );
+ // #90027#
+ const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector();
+ ODatabaseExport::TColumnVector::const_iterator aDestIter = pDestColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aDestEnd = pDestColumns->end();
+ const sal_uInt32 nDestSize = pDestColumns->size();
+ sal_Bool bNotConvert;
+ sal_uInt32 i = 0;
+ for(sal_Int32 nPos = 1;aDestIter != aDestEnd && i < nDestSize && i < nSrcSize;++aDestIter,++nPos,++i)
+ {
+ bNotConvert = sal_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 sal_False;
+ }
+
+ if ( pTypeInfo.get() )
+ m_pParent->m_vColumnTypes[i] = pTypeInfo->nType;
+ else
+ m_pParent->m_vColumnTypes[i] = DataType::VARCHAR;
+ }
+
+ }
+
+ if ( !xTable.is() )
+ {
+ String sError(ModuleRes(STR_INVALID_TABLE_NAME));
+ m_pParent->showError(sError);
+ return sal_False;
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void OCopyTable::setCreatePrimaryKey( bool _bDoCreate, const ::rtl::OUString& _rSuggestedName )
+{
+ bool bCreatePK = m_bPKeyAllowed && _bDoCreate;
+ m_aCB_PrimaryColumn.Check( bCreatePK );
+ m_edKeyName.SetText( _rSuggestedName );
+
+ m_aFT_KeyName.Enable( bCreatePK );
+ m_edKeyName.Enable( bCreatePK );
+}
+
+// -----------------------------------------------------------------------------
+//---dyf add 2006/7/10
+void OCopyTable::setCreateStyleAction()
+{
+ // reselect the last action before
+ switch(m_pParent->getOperation())
+ {
+ case CopyTableOperation::CopyDefinitionAndData:
+ m_aRB_DefData.Check(sal_True);
+ RadioChangeHdl(&m_aRB_DefData);
+ break;
+ case CopyTableOperation::CopyDefinitionOnly:
+ m_aRB_Def.Check(sal_True);
+ RadioChangeHdl(&m_aRB_Def);
+ break;
+ case CopyTableOperation::AppendData:
+ m_aRB_AppendData.Check(sal_True);
+ SetAppendDataRadio();
+ break;
+ case CopyTableOperation::CreateAsView:
+ if ( m_aRB_View.IsEnabled() )
+ {
+ m_aRB_View.Check(sal_True);
+ RadioChangeHdl(&m_aRB_View);
+ }
+ else
+ {
+ m_aRB_DefData.Check(sal_True);
+ RadioChangeHdl(&m_aRB_DefData);
+ }
+ }
+}
+//---add end
diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx
new file mode 100644
index 000000000000..b4736d216681
--- /dev/null
+++ b/dbaccess/source/ui/misc/WColumnSelect.cxx
@@ -0,0 +1,452 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_WIZ_COLUMNSELECT_HXX
+#include "WColumnSelect.hxx"
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#include "WizardPages.hrc"
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_COPYTABLEOPERATION_HPP_
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#include <functional>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace dbaui;
+
+namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
+
+// -----------------------------------------------------------------------
+String OWizColumnSelect::GetTitle() const { return String(ModuleRes(STR_WIZ_COLUMN_SELECT_TITEL)); }
+// -----------------------------------------------------------------------------
+OWizardPage::OWizardPage( Window* pParent, const ResId& rResId )
+ : TabPage(pParent,rResId)
+ ,m_pParent(static_cast<OCopyTableWizard*>(pParent))
+ ,m_bFirstTime(sal_True)
+{
+}
+//========================================================================
+// OWizColumnSelect
+DBG_NAME(OWizColumnSelect);
+//========================================================================
+OWizColumnSelect::OWizColumnSelect( Window* pParent)
+ :OWizardPage( pParent, ModuleRes( TAB_WIZ_COLUMN_SELECT ))
+ ,m_flColumns( this, ModuleRes( FL_COLUMN_SELECT ) )
+ ,m_lbOrgColumnNames( this, ModuleRes( LB_ORG_COLUMN_NAMES ) )
+ ,m_ibColumn_RH( this, ModuleRes( IB_COLUMN_RH ) )
+ ,m_ibColumns_RH( this, ModuleRes( IB_COLUMNS_RH ) )
+ ,m_ibColumn_LH( this, ModuleRes( IB_COLUMN_LH ) )
+ ,m_ibColumns_LH( this, ModuleRes( IB_COLUMNS_LH ) )
+ ,m_lbNewColumnNames( this, ModuleRes( LB_NEW_COLUMN_NAMES ) )
+{
+ DBG_CTOR(OWizColumnSelect,NULL);
+ m_ibColumn_RH.SetClickHdl(LINK(this,OWizColumnSelect,ButtonClickHdl));
+ m_ibColumn_LH.SetClickHdl(LINK(this,OWizColumnSelect,ButtonClickHdl));
+ m_ibColumns_RH.SetClickHdl(LINK(this,OWizColumnSelect,ButtonClickHdl));
+ m_ibColumns_LH.SetClickHdl(LINK(this,OWizColumnSelect,ButtonClickHdl));
+
+ m_lbOrgColumnNames.EnableMultiSelection(sal_True);
+ m_lbNewColumnNames.EnableMultiSelection(sal_True);
+
+ m_lbOrgColumnNames.SetDoubleClickHdl(LINK(this,OWizColumnSelect,ListDoubleClickHdl));
+ m_lbNewColumnNames.SetDoubleClickHdl(LINK(this,OWizColumnSelect,ListDoubleClickHdl));
+ FreeResource();
+}
+// -----------------------------------------------------------------------
+OWizColumnSelect::~OWizColumnSelect()
+{
+ DBG_DTOR(OWizColumnSelect,NULL);
+ while ( m_lbNewColumnNames.GetEntryCount() )
+ {
+ void* pData = m_lbNewColumnNames.GetEntryData(0);
+ if ( pData )
+ delete static_cast<OFieldDescription*>(pData);
+
+ m_lbNewColumnNames.RemoveEntry(0);
+ }
+ m_lbNewColumnNames.Clear();
+}
+
+// -----------------------------------------------------------------------
+void OWizColumnSelect::Reset()
+{
+ // urspr"unglichen zustand wiederherstellen
+ DBG_CHKTHIS(OWizColumnSelect,NULL);
+
+ clearListBox(m_lbOrgColumnNames);
+ clearListBox(m_lbNewColumnNames);
+ m_pParent->m_mNameMapping.clear();
+
+ // insert the source columns in the left listbox
+ const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector();
+ ODatabaseExport::TColumnVector::const_iterator aIter = pSrcColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = pSrcColumns->end();
+
+ for(;aIter != aEnd;++aIter)
+ {
+ sal_uInt16 nPos = m_lbOrgColumnNames.InsertEntry((*aIter)->first);
+ m_lbOrgColumnNames.SetEntryData(nPos,(*aIter)->second);
+ }
+
+ // m_pParent->clearDestColumns();
+
+ if(m_lbOrgColumnNames.GetEntryCount())
+ m_lbOrgColumnNames.SelectEntryPos(0);
+
+ m_bFirstTime = sal_False;
+}
+// -----------------------------------------------------------------------
+void OWizColumnSelect::ActivatePage( )
+{
+ DBG_CHKTHIS(OWizColumnSelect,NULL);
+ // if there are no dest columns reset the left side with the origibnal columns
+ if(m_pParent->getDestColumns()->size() == 0)
+ Reset();
+
+ clearListBox(m_lbNewColumnNames);
+
+ const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector();
+
+ ODatabaseExport::TColumnVector::const_iterator aIter = pDestColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = pDestColumns->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ sal_uInt16 nPos = m_lbNewColumnNames.InsertEntry((*aIter)->first);
+ m_lbNewColumnNames.SetEntryData(nPos,new OFieldDescription(*((*aIter)->second)));
+ m_lbOrgColumnNames.RemoveEntry((*aIter)->first);
+ }
+ m_pParent->GetOKButton().Enable(m_lbNewColumnNames.GetEntryCount() != 0);
+ m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,m_lbNewColumnNames.GetEntryCount() && m_pParent->getOperation() != CopyTableOperation::AppendData);
+ m_ibColumns_RH.GrabFocus();
+}
+// -----------------------------------------------------------------------
+sal_Bool OWizColumnSelect::LeavePage()
+{
+ DBG_CHKTHIS(OWizColumnSelect,NULL);
+
+ // m_pParent->getColumns()->clear();
+ m_pParent->clearDestColumns();
+
+ for(sal_uInt16 i=0 ; i< m_lbNewColumnNames.GetEntryCount();++i)
+ {
+ OFieldDescription* pField = static_cast<OFieldDescription*>(m_lbNewColumnNames.GetEntryData(i));
+ OSL_ENSURE(pField,"The field information can not be null!");
+ m_pParent->insertColumn(i,pField);
+ }
+
+ clearListBox(m_lbNewColumnNames);
+
+
+ if ( m_pParent->GetPressedButton() == OCopyTableWizard::WIZARD_NEXT
+ || m_pParent->GetPressedButton() == OCopyTableWizard::WIZARD_FINISH
+ )
+ return m_pParent->getDestColumns()->size() != 0;
+ else
+ return sal_True;
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OWizColumnSelect, ButtonClickHdl, Button *, pButton )
+{
+ MultiListBox *pLeft = NULL;
+ MultiListBox *pRight = NULL;
+ sal_Bool bAll = sal_False;
+
+ if(pButton == &m_ibColumn_RH)
+ {
+ pLeft = &m_lbOrgColumnNames;
+ pRight = &m_lbNewColumnNames;
+ }
+ else if(pButton == &m_ibColumn_LH)
+ {
+ pLeft = &m_lbNewColumnNames;
+ pRight = &m_lbOrgColumnNames;
+ }
+ else if(pButton == &m_ibColumns_RH)
+ {
+ pLeft = &m_lbOrgColumnNames;
+ pRight = &m_lbNewColumnNames;
+ bAll = sal_True;
+ }
+ else if(pButton == &m_ibColumns_LH)
+ {
+ pLeft = &m_lbNewColumnNames;
+ pRight = &m_lbOrgColumnNames;
+ bAll = sal_True;
+ }
+ // else ????
+
+ Reference< XDatabaseMetaData > xMetaData( m_pParent->m_xDestConnection->getMetaData() );
+ ::rtl::OUString sExtraChars = xMetaData->getExtraNameCharacters();
+ sal_Int32 nMaxNameLen = m_pParent->getMaxColumnNameLength();
+
+ ::comphelper::TStringMixEqualFunctor aCase(xMetaData->supportsMixedCaseQuotedIdentifiers());
+ ::std::vector< ::rtl::OUString> aRightColumns;
+ fillColumns(pRight,aRightColumns);
+
+ String aColumnName;
+ if(!bAll)
+ {
+ for(sal_uInt16 i=0; i < pLeft->GetSelectEntryCount(); ++i)
+ moveColumn(pRight,pLeft,aRightColumns,pLeft->GetSelectEntry(i),sExtraChars,nMaxNameLen,aCase);
+
+ for(sal_uInt16 j=pLeft->GetSelectEntryCount(); j ; --j)
+ pLeft->RemoveEntry(pLeft->GetSelectEntry(j-1));
+ }
+ else
+ {
+ sal_uInt16 nEntries = pLeft->GetEntryCount();
+ for(sal_uInt16 i=0; i < nEntries; ++i)
+ moveColumn(pRight,pLeft,aRightColumns,pLeft->GetEntry(i),sExtraChars,nMaxNameLen,aCase);
+ for(sal_uInt16 j=pLeft->GetEntryCount(); j ; --j)
+ pLeft->RemoveEntry(j-1);
+ }
+
+ enableButtons();
+
+ if(m_lbOrgColumnNames.GetEntryCount())
+ m_lbOrgColumnNames.SelectEntryPos(0);
+
+ return 0;
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OWizColumnSelect, ListDoubleClickHdl, MultiListBox *, pListBox )
+{
+ MultiListBox *pLeft,*pRight;
+ if(pListBox == &m_lbOrgColumnNames)
+ {
+ pLeft = &m_lbOrgColumnNames;
+ pRight = &m_lbNewColumnNames;
+ }
+ else
+ {
+ pRight = &m_lbOrgColumnNames;
+ pLeft = &m_lbNewColumnNames;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Datenbank PrimaryKeys verarbeiten kann, PrimaryKey anlegen
+ Reference< XDatabaseMetaData > xMetaData( m_pParent->m_xDestConnection->getMetaData() );
+ ::rtl::OUString sExtraChars = xMetaData->getExtraNameCharacters();
+ sal_Int32 nMaxNameLen = m_pParent->getMaxColumnNameLength();
+
+ ::comphelper::TStringMixEqualFunctor aCase(xMetaData->supportsMixedCaseQuotedIdentifiers());
+ ::std::vector< ::rtl::OUString> aRightColumns;
+ fillColumns(pRight,aRightColumns);
+
+ String aColumnName;
+ for(sal_uInt16 i=0; i < pLeft->GetSelectEntryCount(); ++i)
+ moveColumn(pRight,pLeft,aRightColumns,pLeft->GetSelectEntry(i),sExtraChars,nMaxNameLen,aCase);
+ for(sal_uInt16 j=pLeft->GetSelectEntryCount(); j ; --j)
+ pLeft->RemoveEntry(pLeft->GetSelectEntry(j-1));
+
+ enableButtons();
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void OWizColumnSelect::clearListBox(MultiListBox& _rListBox)
+{
+ while(_rListBox.GetEntryCount())
+ _rListBox.RemoveEntry(0);
+ _rListBox.Clear();
+}
+// -----------------------------------------------------------------------------
+void OWizColumnSelect::fillColumns(ListBox* pRight,::std::vector< ::rtl::OUString> &_rRightColumns)
+{
+ sal_uInt16 nCount = pRight->GetEntryCount();
+ _rRightColumns.reserve(nCount);
+ for(sal_uInt16 i=0; i < nCount;++i)
+ _rRightColumns.push_back(pRight->GetEntry(i));
+}
+// -----------------------------------------------------------------------------
+void OWizColumnSelect::createNewColumn( ListBox* _pListbox,
+ OFieldDescription* _pSrcField,
+ ::std::vector< ::rtl::OUString>& _rRightColumns,
+ const ::rtl::OUString& _sColumnName,
+ const ::rtl::OUString& _sExtraChars,
+ sal_Int32 _nMaxNameLen,
+ const ::comphelper::TStringMixEqualFunctor& _aCase)
+{
+ ::rtl::OUString sConvertedName = m_pParent->convertColumnName(TMultiListBoxEntryFindFunctor(&_rRightColumns,_aCase),
+ _sColumnName,
+ _sExtraChars,
+ _nMaxNameLen);
+ OFieldDescription* pNewField = new OFieldDescription(*_pSrcField);
+ pNewField->SetName(sConvertedName);
+ sal_Bool bNotConvert = sal_True;
+ pNewField->SetType(m_pParent->convertType(_pSrcField->getSpecialTypeInfo(),bNotConvert));
+ if ( !m_pParent->supportsPrimaryKey() )
+ pNewField->SetPrimaryKey(sal_False);
+
+ _pListbox->SetEntryData(_pListbox->InsertEntry(sConvertedName),pNewField);
+ _rRightColumns.push_back(sConvertedName);
+
+ if ( !bNotConvert )
+ m_pParent->showColumnTypeNotSupported(sConvertedName);
+}
+// -----------------------------------------------------------------------------
+void OWizColumnSelect::moveColumn( ListBox* _pRight,
+ ListBox* _pLeft,
+ ::std::vector< ::rtl::OUString>& _rRightColumns,
+ const ::rtl::OUString& _sColumnName,
+ const ::rtl::OUString& _sExtraChars,
+ sal_Int32 _nMaxNameLen,
+ const ::comphelper::TStringMixEqualFunctor& _aCase)
+{
+ if(_pRight == &m_lbNewColumnNames)
+ {
+ // we copy the column into the new format for the dest
+ OFieldDescription* pSrcField = static_cast<OFieldDescription*>(_pLeft->GetEntryData(_pLeft->GetEntryPos(String(_sColumnName))));
+ createNewColumn(_pRight,pSrcField,_rRightColumns,_sColumnName,_sExtraChars,_nMaxNameLen,_aCase);
+ }
+ else
+ {
+ // find the new column in the dest name mapping to obtain the old column
+ OCopyTableWizard::TNameMapping::iterator aIter = ::std::find_if(m_pParent->m_mNameMapping.begin(),m_pParent->m_mNameMapping.end(),
+ ::std::compose1(
+ ::std::bind2nd(_aCase, _sColumnName),
+ ::std::select2nd<OCopyTableWizard::TNameMapping::value_type>())
+ );
+
+ DBG_ASSERT(aIter != m_pParent->m_mNameMapping.end(),"Column must be defined");
+ if ( aIter == m_pParent->m_mNameMapping.end() )
+ return; // do nothing
+ const ODatabaseExport::TColumns* pSrcColumns = m_pParent->getSourceColumns();
+ ODatabaseExport::TColumns::const_iterator aSrcIter = pSrcColumns->find((*aIter).first);
+ if ( aSrcIter != pSrcColumns->end() )
+ {
+ // we need also the old position of this column to insert it back on that position again
+ const ODatabaseExport::TColumnVector* pSrcVector = m_pParent->getSrcVector();
+ ODatabaseExport::TColumnVector::const_iterator aPos = ::std::find(pSrcVector->begin(),pSrcVector->end(),aSrcIter);
+ OSL_ENSURE( aPos != pSrcVector->end(),"Invalid position for the iterator here!");
+ ODatabaseExport::TColumnVector::size_type nPos = (aPos - pSrcVector->begin()) - adjustColumnPosition(_pLeft, _sColumnName, (aPos - pSrcVector->begin()), _aCase);
+
+ _pRight->SetEntryData( _pRight->InsertEntry( (*aIter).first, sal::static_int_cast< sal_uInt16 >(nPos)),aSrcIter->second );
+ _rRightColumns.push_back((*aIter).first);
+ m_pParent->removeColumnNameFromNameMap(_sColumnName);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+// Simply returning fields back to their original position is
+// not enough. We need to take into acccount what fields have
+// been removed earlier and adjust accordingly. Based on the
+// algorithm employed in moveColumn().
+sal_uInt16 OWizColumnSelect::adjustColumnPosition( ListBox* _pLeft,
+ const ::rtl::OUString& _sColumnName,
+ ODatabaseExport::TColumnVector::size_type nCurrentPos,
+ const ::comphelper::TStringMixEqualFunctor& _aCase)
+{
+ sal_uInt16 nAdjustedPos = 0;
+
+ // if returning all entries to their original position,
+ // then there is no need to adjust the positions.
+ if (m_ibColumns_LH.HasFocus())
+ return nAdjustedPos;
+
+ sal_uInt16 nCount = _pLeft->GetEntryCount();
+ ::rtl::OUString sColumnString;
+ for(sal_uInt16 i=0; i < nCount; ++i)
+ {
+ sColumnString = _pLeft->GetEntry(i);
+ if(_sColumnName != sColumnString)
+ {
+ // find the new column in the dest name mapping to obtain the old column
+ OCopyTableWizard::TNameMapping::iterator aIter = ::std::find_if(m_pParent->m_mNameMapping.begin(),m_pParent->m_mNameMapping.end(),
+ ::std::compose1(
+ ::std::bind2nd(_aCase, sColumnString),
+ ::std::select2nd<OCopyTableWizard::TNameMapping::value_type>())
+ );
+
+ DBG_ASSERT(aIter != m_pParent->m_mNameMapping.end(),"Column must be defined");
+ const ODatabaseExport::TColumns* pSrcColumns = m_pParent->getSourceColumns();
+ ODatabaseExport::TColumns::const_iterator aSrcIter = pSrcColumns->find((*aIter).first);
+ if ( aSrcIter != pSrcColumns->end() )
+ {
+ // we need also the old position of this column to insert it back on that position again
+ const ODatabaseExport::TColumnVector* pSrcVector = m_pParent->getSrcVector();
+ ODatabaseExport::TColumnVector::const_iterator aPos = ::std::find(pSrcVector->begin(),pSrcVector->end(),aSrcIter);
+ ODatabaseExport::TColumnVector::size_type nPos = aPos - pSrcVector->begin();
+ if( nPos < nCurrentPos)
+ {
+ nAdjustedPos++;
+ }
+ }
+ }
+ }
+
+ return nAdjustedPos;
+}
+// -----------------------------------------------------------------------------
+void OWizColumnSelect::enableButtons()
+{
+ sal_Bool bEntries = m_lbNewColumnNames.GetEntryCount() != 0;
+ if(!bEntries)
+ m_pParent->m_mNameMapping.clear();
+
+ m_pParent->GetOKButton().Enable(bEntries);
+ m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,bEntries && m_pParent->getOperation() != CopyTableOperation::AppendData);
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
new file mode 100644
index 000000000000..4926a5f6aba6
--- /dev/null
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -0,0 +1,1692 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "dbu_misc.hrc"
+#include "dbustrings.hrc"
+#include "moduledbu.hxx"
+#include "sqlmessage.hxx"
+#include "UITools.hxx"
+#include "WColumnSelect.hxx"
+#include "WCopyTable.hxx"
+#include "WCPage.hxx"
+#include "WExtendPages.hxx"
+#include "WizardPages.hrc"
+#include "WNameMatch.hxx"
+#include "WTypeSelect.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/interaction.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbmetadata.hxx>
+#include <connectivity/dbexception.hxx>
+
+#include <rtl/logfile.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/lstbox.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/waitobj.hxx>
+
+#include <functional>
+
+using namespace ::dbaui;
+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;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::task;
+using namespace dbtools;
+
+namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
+
+#define MAX_PAGES 4 // max. Pages die angezeigt werden
+
+DBG_NAME(OCopyTableWizard)
+namespace
+{
+ //....................................................................
+ void clearColumns(ODatabaseExport::TColumns& _rColumns, ODatabaseExport::TColumnVector& _rColumnsVec)
+ {
+ ODatabaseExport::TColumns::iterator aIter = _rColumns.begin();
+ ODatabaseExport::TColumns::iterator aEnd = _rColumns.end();
+
+ for(;aIter != aEnd;++aIter)
+ delete aIter->second;
+
+ _rColumnsVec.clear();
+ _rColumns.clear();
+ }
+}
+
+//========================================================================
+//= ICopyTableSourceObject
+//========================================================================
+//------------------------------------------------------------------------
+ICopyTableSourceObject::~ICopyTableSourceObject()
+{
+}
+
+//========================================================================
+//= ObjectCopySource
+//========================================================================
+//------------------------------------------------------------------------
+ObjectCopySource::ObjectCopySource( const Reference< XConnection >& _rxConnection, const Reference< XPropertySet >& _rxObject )
+ :m_xConnection( _rxConnection, UNO_SET_THROW )
+ ,m_xMetaData( _rxConnection->getMetaData(), UNO_SET_THROW )
+ ,m_xObject( _rxObject, UNO_SET_THROW )
+ ,m_xObjectPSI( _rxObject->getPropertySetInfo(), UNO_SET_THROW )
+ ,m_xObjectColumns( Reference< XColumnsSupplier >( _rxObject, UNO_QUERY_THROW )->getColumns(), UNO_SET_THROW )
+{
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString ObjectCopySource::getQualifiedObjectName() const
+{
+ ::rtl::OUString sName;
+
+ if ( !m_xObjectPSI->hasPropertyByName( PROPERTY_COMMAND ) )
+ sName = ::dbtools::composeTableName( m_xMetaData, m_xObject, ::dbtools::eInDataManipulation, false, false, false );
+ else
+ m_xObject->getPropertyValue( PROPERTY_NAME ) >>= sName;
+ return sName;
+}
+
+//------------------------------------------------------------------------
+bool ObjectCopySource::isView() const
+{
+ bool bIsView = false;
+ try
+ {
+ if ( m_xObjectPSI->hasPropertyByName( PROPERTY_TYPE ) )
+ {
+ ::rtl::OUString sObjectType;
+ OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_TYPE ) >>= sObjectType );
+ bIsView = sObjectType.equalsAscii( "VIEW" );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bIsView;
+}
+
+//------------------------------------------------------------------------
+void ObjectCopySource::copyUISettingsTo( const Reference< XPropertySet >& _rxObject ) const
+{
+ const ::rtl::OUString aCopyProperties[] = {
+ PROPERTY_FONT, PROPERTY_ROW_HEIGHT, PROPERTY_TEXTCOLOR,PROPERTY_TEXTLINECOLOR,PROPERTY_TEXTEMPHASIS,PROPERTY_TEXTRELIEF
+ };
+ for ( size_t i=0; i < sizeof( aCopyProperties ) / sizeof( aCopyProperties[0] ); ++i )
+ {
+ if ( m_xObjectPSI->hasPropertyByName( aCopyProperties[i] ) )
+ _rxObject->setPropertyValue( aCopyProperties[i], m_xObject->getPropertyValue( aCopyProperties[i] ) );
+ }
+}
+//------------------------------------------------------------------------
+void ObjectCopySource::copyFilterAndSortingTo( const Reference< XConnection >& _xConnection,const Reference< XPropertySet >& _rxObject ) const
+{
+ ::std::pair< ::rtl::OUString, ::rtl::OUString > aProperties[] = {
+ ::std::pair< ::rtl::OUString, ::rtl::OUString >(PROPERTY_FILTER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" AND ")))
+ ,::std::pair< ::rtl::OUString, ::rtl::OUString >(PROPERTY_ORDER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ORDER BY ")))
+ };
+
+ size_t i = 0;
+
+ try
+ {
+ const String sSourceName = (::dbtools::composeTableNameForSelect(m_xConnection,m_xObject) + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")));
+ const ::rtl::OUString sTargetName = ::dbtools::composeTableNameForSelect(_xConnection,_rxObject);
+ const String sTargetNameTemp = (sTargetName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")));
+
+ ::rtl::OUString sStatement(RTL_CONSTASCII_USTRINGPARAM("SELECT * FROM "));
+ sStatement += sTargetName;
+ sStatement += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE 0=1"));
+
+
+ for ( i=0; i < sizeof( aProperties ) / sizeof( aProperties[0] ); ++i )
+ {
+ if ( m_xObjectPSI->hasPropertyByName( aProperties[i].first ) )
+ {
+ ::rtl::OUString sFilter;
+ m_xObject->getPropertyValue( aProperties[i].first ) >>= sFilter;
+ if ( sFilter.getLength() )
+ {
+ sStatement += aProperties[i].second;
+ String sReplace = sFilter;
+ sReplace.SearchAndReplace(sSourceName,sTargetNameTemp);
+ sFilter = sReplace;
+ _rxObject->setPropertyValue( aProperties[i].first, makeAny(sFilter) );
+ sStatement += sFilter;
+ }
+ }
+ }
+
+ _xConnection->createStatement()->executeQuery(sStatement);
+
+ if ( m_xObjectPSI->hasPropertyByName( PROPERTY_APPLYFILTER ) )
+ _rxObject->setPropertyValue( PROPERTY_APPLYFILTER, m_xObject->getPropertyValue( PROPERTY_APPLYFILTER ) );
+ }
+ catch(Exception&)
+ {
+ }
+}
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ObjectCopySource::getColumnNames() const
+{
+ return m_xObjectColumns->getElementNames();
+}
+
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ObjectCopySource::getPrimaryKeyColumnNames() const
+{
+ const Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(m_xObject);
+ Sequence< ::rtl::OUString > aKeyColNames;
+ if ( xPrimaryKeyColumns.is() )
+ aKeyColNames = xPrimaryKeyColumns->getElementNames();
+ return aKeyColNames;
+}
+
+//------------------------------------------------------------------------
+OFieldDescription* ObjectCopySource::createFieldDescription( const ::rtl::OUString& _rColumnName ) const
+{
+ Reference< XPropertySet > xColumn( m_xObjectColumns->getByName( _rColumnName ), UNO_QUERY_THROW );
+ return new OFieldDescription( xColumn );
+}
+//------------------------------------------------------------------------
+::rtl::OUString ObjectCopySource::getSelectStatement() const
+{
+ ::rtl::OUString sSelectStatement;
+ if ( m_xObjectPSI->hasPropertyByName( PROPERTY_COMMAND ) )
+ { // query
+ OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_COMMAND ) >>= sSelectStatement );
+ }
+ else
+ { // table
+ ::rtl::OUStringBuffer aSQL;
+ aSQL.appendAscii( "SELECT " );
+
+ // we need to create the sql stmt with column names
+ // otherwise it is possible that names don't match
+ const ::rtl::OUString sQuote = m_xMetaData->getIdentifierQuoteString();
+
+ Sequence< ::rtl::OUString > aColumnNames = getColumnNames();
+ const ::rtl::OUString* pColumnName = aColumnNames.getConstArray();
+ const ::rtl::OUString* pEnd = pColumnName + aColumnNames.getLength();
+ for ( ; pColumnName != pEnd; )
+ {
+ aSQL.append( ::dbtools::quoteName( sQuote, *pColumnName++ ) );
+
+ if ( pColumnName == pEnd )
+ aSQL.appendAscii( " " );
+ else
+ aSQL.appendAscii( ", " );
+ }
+
+ aSQL.appendAscii( "FROM " );
+ aSQL.append( ::dbtools::composeTableNameForSelect( m_xConnection, m_xObject ) );
+
+ sSelectStatement = aSQL.makeStringAndClear();
+ }
+
+ return sSelectStatement;
+}
+
+//------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > ObjectCopySource::getPreparedSelectStatement() const
+{
+ ::utl::SharedUNOComponent< XPreparedStatement > xStatement(
+ m_xConnection->prepareStatement( getSelectStatement() ),
+ ::utl::SharedUNOComponent< XPreparedStatement >::TakeOwnership
+ );
+ return xStatement;
+}
+
+//========================================================================
+//= NamedTableCopySource
+//========================================================================
+//------------------------------------------------------------------------
+NamedTableCopySource::NamedTableCopySource( const Reference< XConnection >& _rxConnection, const ::rtl::OUString& _rTableName )
+ :m_xConnection( _rxConnection, UNO_SET_THROW )
+ ,m_xMetaData( _rxConnection->getMetaData(), UNO_SET_THROW )
+ ,m_sTableName( _rTableName )
+ ,m_aColumnInfo()
+{
+ ::dbtools::qualifiedNameComponents( m_xMetaData, m_sTableName, m_sTableCatalog, m_sTableSchema, m_sTableBareName, ::dbtools::eComplete );
+ impl_ensureColumnInfo_throw();
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString NamedTableCopySource::getQualifiedObjectName() const
+{
+ return m_sTableName;
+}
+
+//------------------------------------------------------------------------
+bool NamedTableCopySource::isView() const
+{
+ ::rtl::OUString sTableType;
+ try
+ {
+ Reference< XResultSet > xTableDesc( m_xMetaData->getTables( makeAny( m_sTableCatalog ), m_sTableSchema, m_sTableBareName,
+ Sequence< ::rtl::OUString >() ) );
+ Reference< XRow > xTableDescRow( xTableDesc, UNO_QUERY_THROW );
+ OSL_VERIFY( xTableDesc->next() );
+ sTableType = xTableDescRow->getString( 4 );
+ OSL_ENSURE( !xTableDescRow->wasNull(), "NamedTableCopySource::isView: invalid table type!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sTableType.equalsAscii( "VIEW" );
+}
+
+//------------------------------------------------------------------------
+void NamedTableCopySource::copyUISettingsTo( const Reference< XPropertySet >& /*_rxObject*/ ) const
+{
+ // not supported: we do not have UI settings to copy
+}
+// -----------------------------------------------------------------------------
+void NamedTableCopySource::copyFilterAndSortingTo( const Reference< XConnection >& ,const Reference< XPropertySet >& /*_rxObject*/ ) const
+{
+}
+//------------------------------------------------------------------------
+void NamedTableCopySource::impl_ensureColumnInfo_throw()
+{
+ if ( !m_aColumnInfo.empty() )
+ return;
+
+ Reference< XResultSetMetaDataSupplier > xStatementMetaSupp( impl_ensureStatement_throw().getTyped(), UNO_QUERY_THROW );
+ Reference< XResultSetMetaData > xStatementMeta( xStatementMetaSupp->getMetaData(), UNO_SET_THROW );
+
+ sal_Int32 nColCount( xStatementMeta->getColumnCount() );
+ for ( sal_Int32 i = 1; i <= nColCount; ++i )
+ {
+ OFieldDescription aDesc;
+
+ aDesc.SetName( xStatementMeta->getColumnName( i ) );
+ aDesc.SetHelpText( xStatementMeta->getColumnLabel( i ) );
+ aDesc.SetTypeValue( xStatementMeta->getColumnType( i ) );
+ aDesc.SetTypeName( xStatementMeta->getColumnTypeName( i ) );
+ aDesc.SetPrecision( xStatementMeta->getPrecision( i ) );
+ aDesc.SetScale( xStatementMeta->getScale( i ) );
+ aDesc.SetIsNullable( xStatementMeta->isNullable( i ) );
+ aDesc.SetCurrency( xStatementMeta->isCurrency( i ) );
+ aDesc.SetAutoIncrement( xStatementMeta->isAutoIncrement( i ) );
+
+ m_aColumnInfo.push_back( aDesc );
+ }
+}
+
+//------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > NamedTableCopySource::impl_ensureStatement_throw()
+{
+ if ( !m_xStatement.is() )
+ m_xStatement.set( m_xConnection->prepareStatement( getSelectStatement() ), UNO_SET_THROW );
+ return m_xStatement;
+}
+
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > NamedTableCopySource::getColumnNames() const
+{
+ Sequence< ::rtl::OUString > aNames( m_aColumnInfo.size() );
+ for ( ::std::vector< OFieldDescription >::const_iterator col = m_aColumnInfo.begin();
+ col != m_aColumnInfo.end();
+ ++col
+ )
+ aNames[ col - m_aColumnInfo.begin() ] = col->GetName();
+
+ return aNames;
+}
+
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > NamedTableCopySource::getPrimaryKeyColumnNames() const
+{
+ Sequence< ::rtl::OUString > aPKColNames;
+
+ try
+ {
+ Reference< XResultSet > xPKDesc( m_xMetaData->getPrimaryKeys( makeAny( m_sTableCatalog ), m_sTableSchema, m_sTableBareName ) );
+ Reference< XRow > xPKDescRow( xPKDesc, UNO_QUERY_THROW );
+ while ( xPKDesc->next() )
+ {
+ sal_Int32 len( aPKColNames.getLength() );
+ aPKColNames.realloc( len + 1 );
+ aPKColNames[ len ] = xPKDescRow->getString( 4 ); // COLUMN_NAME
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return aPKColNames;
+}
+
+//------------------------------------------------------------------------
+OFieldDescription* NamedTableCopySource::createFieldDescription( const ::rtl::OUString& _rColumnName ) const
+{
+ for ( ::std::vector< OFieldDescription >::const_iterator col = m_aColumnInfo.begin();
+ col != m_aColumnInfo.end();
+ ++col
+ )
+ if ( col->GetName() == _rColumnName )
+ return new OFieldDescription( *col );
+
+ return NULL;
+}
+//------------------------------------------------------------------------
+::rtl::OUString NamedTableCopySource::getSelectStatement() const
+{
+ ::rtl::OUStringBuffer aSQL;
+ aSQL.appendAscii( "SELECT * FROM " );
+
+ aSQL.append( ::dbtools::composeTableNameForSelect( m_xConnection, m_sTableCatalog, m_sTableSchema, m_sTableBareName ) );
+
+ return aSQL.makeStringAndClear();
+}
+
+//------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > NamedTableCopySource::getPreparedSelectStatement() const
+{
+ return const_cast< NamedTableCopySource* >( this )->impl_ensureStatement_throw();
+}
+
+// ========================================================
+// DummyCopySource
+// ========================================================
+class DummyCopySource : public ICopyTableSourceObject
+{
+public:
+ DummyCopySource() { }
+
+ static const DummyCopySource& Instance();
+
+ // ICopyTableSourceObject overridables
+ virtual ::rtl::OUString getQualifiedObjectName() const;
+ virtual bool isView() const;
+ virtual void copyUISettingsTo( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
+ virtual void copyFilterAndSortingTo(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getColumnNames() const;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getPrimaryKeyColumnNames() const;
+ virtual OFieldDescription* createFieldDescription( const ::rtl::OUString& _rColumnName ) const;
+ virtual ::rtl::OUString getSelectStatement() const;
+ virtual ::utl::SharedUNOComponent< XPreparedStatement >
+ getPreparedSelectStatement() const;
+};
+
+//------------------------------------------------------------------------
+const DummyCopySource& DummyCopySource::Instance()
+{
+ static DummyCopySource s_aTheInstance;
+ return s_aTheInstance;
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString DummyCopySource::getQualifiedObjectName() const
+{
+ OSL_ENSURE( false, "DummyCopySource::getQualifiedObjectName: not to be called!" );
+ return ::rtl::OUString();
+}
+
+//------------------------------------------------------------------------
+bool DummyCopySource::isView() const
+{
+ OSL_ENSURE( false, "DummyCopySource::isView: not to be called!" );
+ return false;
+}
+
+//------------------------------------------------------------------------
+void DummyCopySource::copyUISettingsTo( const Reference< XPropertySet >& /*_rxObject*/ ) const
+{
+ // no support
+}
+// -----------------------------------------------------------------------------
+void DummyCopySource::copyFilterAndSortingTo( const Reference< XConnection >& ,const Reference< XPropertySet >& /*_rxObject*/ ) const
+{
+}
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > DummyCopySource::getColumnNames() const
+{
+ return Sequence< ::rtl::OUString >();
+}
+
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > DummyCopySource::getPrimaryKeyColumnNames() const
+{
+ OSL_ENSURE( false, "DummyCopySource::getPrimaryKeyColumnNames: not to be called!" );
+ return Sequence< ::rtl::OUString >();
+}
+
+//------------------------------------------------------------------------
+OFieldDescription* DummyCopySource::createFieldDescription( const ::rtl::OUString& /*_rColumnName*/ ) const
+{
+ OSL_ENSURE( false, "DummyCopySource::createFieldDescription: not to be called!" );
+ return NULL;
+}
+//------------------------------------------------------------------------
+::rtl::OUString DummyCopySource::getSelectStatement() const
+{
+ OSL_ENSURE( false, "DummyCopySource::getSelectStatement: not to be called!" );
+ return ::rtl::OUString();
+}
+
+//------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > DummyCopySource::getPreparedSelectStatement() const
+{
+ OSL_ENSURE( false, "DummyCopySource::getPreparedSelectStatement: not to be called!" );
+ return ::utl::SharedUNOComponent< XPreparedStatement >();
+}
+
+//------------------------------------------------------------------------
+namespace
+{
+ bool lcl_canCreateViewFor_nothrow( const Reference< XConnection >& _rxConnection )
+ {
+ Reference< XViewsSupplier > xSup( _rxConnection, UNO_QUERY );
+ Reference< XDataDescriptorFactory > xViewFac;
+ if ( xSup.is() )
+ xViewFac.set( xSup->getViews(), UNO_QUERY );
+ return xViewFac.is();
+ }
+
+ bool lcl_sameConnection_throw( const Reference< XConnection >& _rxLHS, const Reference< XConnection >& _rxRHS )
+ {
+ Reference< XDatabaseMetaData > xMetaLHS( _rxLHS->getMetaData(), UNO_QUERY_THROW );
+ Reference< XDatabaseMetaData > xMetaRHS( _rxRHS->getMetaData(), UNO_QUERY_THROW );
+ return xMetaLHS->getURL().equals( xMetaRHS->getURL() );
+ }
+}
+
+//========================================================================
+//= OCopyTableWizard
+//========================================================================
+//------------------------------------------------------------------------
+OCopyTableWizard::OCopyTableWizard( Window * pParent, const ::rtl::OUString& _rDefaultName, sal_Int16 _nOperation,
+ const ICopyTableSourceObject& _rSourceObject, const Reference< XConnection >& _xSourceConnection,
+ const Reference< XConnection >& _xConnection, const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XInteractionHandler>& _xInteractionHandler)
+ : WizardDialog( pParent, ModuleRes(WIZ_RTFCOPYTABLE))
+ ,m_pbHelp( this , ModuleRes(PB_HELP))
+ ,m_pbCancel( this , ModuleRes(PB_CANCEL))
+ ,m_pbPrev( this , ModuleRes(PB_PREV))
+ ,m_pbNext( this , ModuleRes(PB_NEXT))
+ ,m_pbFinish( this , ModuleRes(PB_OK))
+ ,m_mNameMapping(_xConnection->getMetaData().is() && _xConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers())
+ ,m_xDestConnection( _xConnection )
+ ,m_rSourceObject( _rSourceObject )
+ ,m_xFormatter( getNumberFormatter( _xConnection, _rxORB ) )
+ ,m_xFactory(_rxORB)
+ ,m_xInteractionHandler(_xInteractionHandler)
+ ,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
+ ,m_nPageCount(0)
+ ,m_bDeleteSourceColumns(sal_True)
+ ,m_bInterConnectionCopy( _xSourceConnection != _xConnection )
+ ,m_sName( _rDefaultName )
+ ,m_nOperation( _nOperation )
+ ,m_ePressed( WIZARD_NONE )
+ ,m_bCreatePrimaryKeyColumn(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::OCopyTableWizard" );
+ DBG_CTOR(OCopyTableWizard,NULL);
+ construct();
+
+ // extract table name
+ ::rtl::OUString sInitialTableName( _rDefaultName );
+ try
+ {
+ m_sSourceName = m_rSourceObject.getQualifiedObjectName();
+ OSL_ENSURE( m_sSourceName.getLength() > 0, "OCopyTableWizard::OCopyTableWizard: unable to retrieve the source object's name!" );
+
+ if ( !sInitialTableName.getLength() )
+ sInitialTableName = m_sSourceName;
+
+ if ( !m_sName.getLength() )
+ {
+ if ( _xSourceConnection == m_xDestConnection )
+ {
+ Reference< XTablesSupplier > xSup( m_xDestConnection, UNO_QUERY_THROW );
+ m_sName = ::dbtools::createUniqueName( xSup->getTables(), sInitialTableName, sal_False );
+ }
+ else
+ m_sName = sInitialTableName;
+ }
+ }
+ catch ( const Exception& )
+ {
+ m_sName = sInitialTableName;
+ }
+
+ ::dbaui::fillTypeInfo( _xSourceConnection, m_sTypeNames, m_aTypeInfo, m_aTypeInfoIndex );
+ ::dbaui::fillTypeInfo( m_xDestConnection, m_sTypeNames, m_aDestTypeInfo, m_aDestTypeInfoIndex );
+ impl_loadSourceData();
+
+ bool bAllowViews = true;
+ // if the source is a, don't allow creating views #100644# (oj)
+ // (fs: Hmm? A SELECT * FROM <view> would be created, where #100644# claims this is nonsense. Why?
+ if ( m_rSourceObject.isView() )
+ bAllowViews = false;
+ // no views if the target connection does not support creating them
+ if ( !lcl_canCreateViewFor_nothrow( m_xDestConnection ) )
+ bAllowViews = false;
+ // no views if we're copying to a different database
+ if ( !lcl_sameConnection_throw( _xSourceConnection, m_xDestConnection ) )
+ bAllowViews = false;
+
+ if ( m_bInterConnectionCopy )
+ {
+ Reference< XDatabaseMetaData > xSrcMeta = _xSourceConnection->getMetaData();
+ ::rtl::OUString sCatalog;
+ ::rtl::OUString sSchema;
+ ::rtl::OUString sTable;
+ ::dbtools::qualifiedNameComponents( xSrcMeta,
+ m_sName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+
+ m_sName = ::dbtools::composeTableName(m_xDestConnection->getMetaData(),sCatalog,sSchema,sTable,sal_False,::dbtools::eInTableDefinitions);
+ }
+
+ OCopyTable* pPage1( new OCopyTable( this ) );
+ pPage1->disallowUseHeaderLine();
+ if ( !bAllowViews )
+ pPage1->disallowViews();
+ pPage1->setCreateStyleAction();
+ AddWizardPage(pPage1);
+
+ AddWizardPage( new OWizNameMatching( this ) );
+ AddWizardPage( new OWizColumnSelect( this ) );
+ AddWizardPage( new OWizNormalExtend( this ) );
+ ActivatePage();
+}
+
+// -----------------------------------------------------------------------------
+OCopyTableWizard::OCopyTableWizard( Window* pParent, const ::rtl::OUString& _rDefaultName, sal_Int16 _nOperation,
+ const ODatabaseExport::TColumns& _rSourceColumns, const ODatabaseExport::TColumnVector& _rSourceColVec,
+ const Reference< XConnection >& _xConnection, const Reference< XNumberFormatter >& _xFormatter,
+ TypeSelectionPageFactory _pTypeSelectionPageFactory, SvStream& _rTypeSelectionPageArg, const Reference< XMultiServiceFactory >& _rM )
+ :WizardDialog( pParent, ModuleRes(WIZ_RTFCOPYTABLE))
+ ,m_vSourceColumns(_rSourceColumns)
+ ,m_pbHelp( this , ModuleRes(PB_HELP))
+ ,m_pbCancel( this , ModuleRes(PB_CANCEL))
+ ,m_pbPrev( this , ModuleRes(PB_PREV))
+ ,m_pbNext( this , ModuleRes(PB_NEXT))
+ ,m_pbFinish( this , ModuleRes(PB_OK))
+ ,m_mNameMapping(_xConnection->getMetaData().is() && _xConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers())
+ ,m_xDestConnection( _xConnection )
+ ,m_rSourceObject( DummyCopySource::Instance() )
+ ,m_xFormatter(_xFormatter)
+ ,m_xFactory(_rM)
+ ,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
+ ,m_nPageCount(0)
+ ,m_bDeleteSourceColumns(sal_False)
+ ,m_bInterConnectionCopy( false )
+ ,m_sName(_rDefaultName)
+ ,m_nOperation( _nOperation )
+ ,m_ePressed( WIZARD_NONE )
+ ,m_bCreatePrimaryKeyColumn(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::OCopyTableWizard" );
+ DBG_CTOR(OCopyTableWizard,NULL);
+ construct();
+ ODatabaseExport::TColumnVector::const_iterator aIter = _rSourceColVec.begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = _rSourceColVec.end();
+ for (; aIter != aEnd ; ++aIter)
+ {
+ m_vSourceVec.push_back(m_vSourceColumns.find((*aIter)->first));
+ }
+
+ ::dbaui::fillTypeInfo( _xConnection, m_sTypeNames, m_aTypeInfo, m_aTypeInfoIndex );
+ ::dbaui::fillTypeInfo( _xConnection, m_sTypeNames, m_aDestTypeInfo, m_aDestTypeInfoIndex );
+
+ m_xInteractionHandler.set( m_xFactory->createInstance( SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY);
+
+ OCopyTable* pPage1( new OCopyTable( this ) );
+ pPage1->disallowViews();
+ pPage1->setCreateStyleAction();
+ AddWizardPage( pPage1 );
+
+ AddWizardPage( new OWizNameMatching( this ) );
+ AddWizardPage( new OWizColumnSelect( this ) );
+ AddWizardPage( (*_pTypeSelectionPageFactory)( this, _rTypeSelectionPageArg ) );
+
+ ActivatePage();
+}
+
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::construct()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::construct" );
+ AddButton( &m_pbHelp, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ AddButton( &m_pbCancel, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ AddButton( &m_pbPrev );
+ AddButton( &m_pbNext, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ AddButton( &m_pbFinish );
+
+ m_pbPrev.SetClickHdl( LINK( this, OCopyTableWizard, ImplPrevHdl ) );
+ m_pbNext.SetClickHdl( LINK( this, OCopyTableWizard, ImplNextHdl ) );
+ m_pbFinish.SetClickHdl( LINK( this, OCopyTableWizard, ImplOKHdl ) );
+
+ SetActivatePageHdl( LINK( this, OCopyTableWizard, ImplActivateHdl ) );
+
+ SetPrevButton( &m_pbPrev );
+ SetNextButton( &m_pbNext );
+
+ ShowButtonFixedLine( sal_True );
+
+ m_pbNext.GrabFocus();
+
+ if (m_vDestColumns.size())
+ // source is a html or rtf table
+ m_pbNext.SetStyle(m_pbFinish.GetStyle() | WB_DEFBUTTON);
+ else
+ m_pbFinish.SetStyle(m_pbFinish.GetStyle() | WB_DEFBUTTON);
+
+ FreeResource();
+
+ m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
+ m_pTypeInfo->aUIName = m_sTypeNames.GetToken(TYPE_OTHER);
+ m_bAddPKFirstTime = sal_True;
+}
+//------------------------------------------------------------------------
+OCopyTableWizard::~OCopyTableWizard()
+{
+ DBG_DTOR(OCopyTableWizard,NULL);
+ for ( ;; )
+ {
+ TabPage *pPage = GetPage(0);
+ if ( pPage == NULL )
+ break;
+ RemovePage( pPage );
+ delete pPage;
+ }
+
+ if ( m_bDeleteSourceColumns )
+ clearColumns(m_vSourceColumns,m_vSourceVec);
+
+ clearColumns(m_vDestColumns,m_aDestVec);
+
+ // clear the type information
+ m_aTypeInfoIndex.clear();
+ m_aTypeInfo.clear();
+ m_aDestTypeInfoIndex.clear();
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OCopyTableWizard, ImplPrevHdl, PushButton*, EMPTYARG )
+{
+ m_ePressed = WIZARD_PREV;
+ if ( GetCurLevel() )
+ {
+ if ( getOperation() != CopyTableOperation::AppendData )
+ {
+ if(GetCurLevel() == 2)
+ ShowPage(GetCurLevel()-2);
+ else
+ ShowPrevPage();
+ }
+ else
+ ShowPrevPage();
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( OCopyTableWizard, ImplNextHdl, PushButton*, EMPTYARG )
+{
+ m_ePressed = WIZARD_NEXT;
+ if ( GetCurLevel() < MAX_PAGES )
+ {
+ if ( getOperation() != CopyTableOperation::AppendData )
+ {
+ if(GetCurLevel() == 0)
+ ShowPage(GetCurLevel()+2);
+ else
+ ShowNextPage();
+ }
+ else
+ ShowNextPage();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------
+sal_Bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::CheckColumns" );
+ sal_Bool bRet = sal_True;
+ m_vColumnPos.clear();
+ m_vColumnTypes.clear();
+
+ OSL_ENSURE( m_xDestConnection.is(), "OCopyTableWizard::CheckColumns: No connection!" );
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Datenbank PrimaryKeys verarbeiten kann, PrimaryKey anlegen
+ if ( m_xDestConnection.is() )
+ {
+ sal_Bool bPKeyAllowed = supportsPrimaryKey();
+
+ sal_Bool bContainsColumns = !m_vDestColumns.empty();
+
+ if ( bPKeyAllowed && shouldCreatePrimaryKey() )
+ {
+ // add extra column for the primary key
+ TOTypeInfoSP pTypeInfo = queryPrimaryKeyType(m_aDestTypeInfo);
+ if ( pTypeInfo.get() )
+ {
+ if ( m_bAddPKFirstTime )
+ {
+ OFieldDescription* pField = new OFieldDescription();
+ pField->SetName(m_aKeyName);
+ pField->FillFromTypeInfo(pTypeInfo,sal_True,sal_True);
+ pField->SetPrimaryKey(sal_True);
+ m_bAddPKFirstTime = sal_False;
+ insertColumn(0,pField);
+ }
+ m_vColumnPos.push_back(ODatabaseExport::TPositions::value_type(1,1));
+ m_vColumnTypes.push_back(pTypeInfo->nType);
+ }
+ }
+
+ if ( bContainsColumns )
+ { // we have dest columns so look for the matching column
+ ODatabaseExport::TColumnVector::const_iterator aSrcIter = m_vSourceVec.begin();
+ ODatabaseExport::TColumnVector::const_iterator aSrcEnd = m_vSourceVec.end();
+ for(;aSrcIter != aSrcEnd;++aSrcIter)
+ {
+ ODatabaseExport::TColumns::iterator aDestIter = m_vDestColumns.find(m_mNameMapping[(*aSrcIter)->first]);
+
+ if ( aDestIter != m_vDestColumns.end() )
+ {
+ ODatabaseExport::TColumnVector::const_iterator aFind = ::std::find(m_aDestVec.begin(),m_aDestVec.end(),aDestIter);
+ sal_Int32 nPos = (aFind - m_aDestVec.begin())+1;
+ m_vColumnPos.push_back(ODatabaseExport::TPositions::value_type(nPos,nPos));
+ m_vColumnTypes.push_back((*aFind)->second->GetType());
+ }
+ else
+ {
+ m_vColumnPos.push_back( ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) );
+ m_vColumnTypes.push_back(0);
+ }
+ }
+ }
+ else
+ {
+ Reference< XDatabaseMetaData > xMetaData( m_xDestConnection->getMetaData() );
+ ::rtl::OUString sExtraChars = xMetaData->getExtraNameCharacters();
+ sal_Int32 nMaxNameLen = getMaxColumnNameLength();
+
+ ODatabaseExport::TColumnVector::const_iterator aSrcIter = m_vSourceVec.begin();
+ ODatabaseExport::TColumnVector::const_iterator aSrcEnd = m_vSourceVec.end();
+ for(_rnBreakPos=0;aSrcIter != aSrcEnd && bRet ;++aSrcIter,++_rnBreakPos)
+ {
+ OFieldDescription* pField = new OFieldDescription(*(*aSrcIter)->second);
+ pField->SetName(convertColumnName(TExportColumnFindFunctor(&m_vDestColumns),(*aSrcIter)->first,sExtraChars,nMaxNameLen));
+ TOTypeInfoSP pType = convertType((*aSrcIter)->second->getSpecialTypeInfo(),bRet);
+ pField->SetType(pType);
+ if ( !bPKeyAllowed )
+ pField->SetPrimaryKey(sal_False);
+
+ // now create a column
+ insertColumn(m_vDestColumns.size(),pField);
+ m_vColumnPos.push_back(ODatabaseExport::TPositions::value_type(m_vDestColumns.size(),m_vDestColumns.size()));
+ m_vColumnTypes.push_back((*aSrcIter)->second->GetType());
+ }
+ }
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OCopyTableWizard, ImplOKHdl, OKButton*, EMPTYARG )
+{
+ m_ePressed = WIZARD_FINISH;
+ sal_Bool bFinish = DeactivatePage() != 0;
+
+ if(bFinish)
+ {
+ WaitObject aWait(this);
+ switch(getOperation())
+ {
+ case CopyTableOperation::CopyDefinitionAndData:
+ case CopyTableOperation::CopyDefinitionOnly:
+ {
+ sal_Bool bOnFirstPage = GetCurLevel() == 0;
+ if ( bOnFirstPage )
+ {
+ // we came from the first page so we have to clear
+ // all column information already collected
+ clearDestColumns();
+ m_mNameMapping.clear();
+ }
+ sal_Int32 nBreakPos = 0;
+ sal_Bool bCheckOk = CheckColumns(nBreakPos);
+ if ( bOnFirstPage && !bCheckOk )
+ {
+ showColumnTypeNotSupported(m_vSourceVec[nBreakPos-1]->first);
+ OWizTypeSelect* pPage = static_cast<OWizTypeSelect*>(GetPage(3));
+ if ( pPage )
+ {
+ m_mNameMapping.clear();
+ pPage->setDisplayRow(nBreakPos);
+ ShowPage(3);
+ return 0;
+ }
+ }
+ if ( m_xDestConnection.is() )
+ {
+ if ( supportsPrimaryKey() )
+ {
+ ODatabaseExport::TColumns::iterator aFind = ::std::find_if(m_vDestColumns.begin(),m_vDestColumns.end()
+ ,::std::compose1(::std::mem_fun(&OFieldDescription::IsPrimaryKey),::std::select2nd<ODatabaseExport::TColumns::value_type>()));
+ if ( aFind == m_vDestColumns.end() && m_xInteractionHandler.is() )
+ {
+
+ String sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD));
+ String sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY));
+ SQLContext aError;
+ aError.Message = sMsg;
+ ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( makeAny( aError ) ) );
+ ::rtl::Reference< ::comphelper::OInteractionApprove > xYes = new ::comphelper::OInteractionApprove;
+ xRequest->addContinuation( xYes.get() );
+ xRequest->addContinuation( new ::comphelper::OInteractionDisapprove );
+ ::rtl::Reference< ::comphelper::OInteractionAbort > xAbort = new ::comphelper::OInteractionAbort;
+ xRequest->addContinuation( xAbort.get() );
+
+ m_xInteractionHandler->handle( xRequest.get() );
+
+ if ( xYes->wasSelected() )
+ {
+ OCopyTable* pPage = static_cast<OCopyTable*>(GetPage(0));
+ m_bCreatePrimaryKeyColumn = sal_True;
+ m_aKeyName = pPage->GetKeyName();
+ if ( !m_aKeyName.getLength() )
+ m_aKeyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) );
+ m_aKeyName = createUniqueName( m_aKeyName );
+ sal_Int32 nBreakPos2 = 0;
+ CheckColumns(nBreakPos2);
+ }
+ else if ( xAbort->wasSelected() )
+ {
+ ShowPage(3);
+ return 0;
+ }
+ }
+ }
+ }
+ break;
+ }
+ case CopyTableOperation::AppendData:
+ case CopyTableOperation::CreateAsView:
+ break;
+ default:
+ {
+ OSL_ENSURE(sal_False, "OCopyTableWizard::ImplOKHdl: invalid creation style!");
+ }
+ }
+
+ EndDialog(RET_OK);
+ }
+ return bFinish;
+}
+//------------------------------------------------------------------------
+sal_Bool OCopyTableWizard::shouldCreatePrimaryKey() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::shouldCreatePrimaryKey" );
+ return m_bCreatePrimaryKeyColumn;
+}
+
+// -----------------------------------------------------------------------
+void OCopyTableWizard::setCreatePrimaryKey( bool _bDoCreate, const ::rtl::OUString& _rSuggestedName )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::setCreatePrimaryKey" );
+ m_bCreatePrimaryKeyColumn = _bDoCreate;
+ if ( _rSuggestedName.getLength() )
+ m_aKeyName = _rSuggestedName;
+
+ OCopyTable* pSettingsPage = dynamic_cast< OCopyTable* >( GetPage( 0 ) );
+ OSL_ENSURE( pSettingsPage, "OCopyTableWizard::setCreatePrimaryKey: page should have been added in the ctor!" );
+ if ( pSettingsPage )
+ pSettingsPage->setCreatePrimaryKey( _bDoCreate, _rSuggestedName );
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( OCopyTableWizard, ImplActivateHdl, WizardDialog*, EMPTYARG )
+{
+ OWizardPage* pCurrent = (OWizardPage*)GetPage(GetCurLevel());
+ if(pCurrent)
+ {
+ sal_Bool bFirstTime = pCurrent->IsFirstTime();
+ if(bFirstTime)
+ pCurrent->Reset();
+
+ CheckButtons();
+
+ SetText(pCurrent->GetTitle());
+
+ Invalidate();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------
+void OCopyTableWizard::CheckButtons()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::CheckButtons" );
+ if(GetCurLevel() == 0) // erste Seite hat kein PrevButton
+ {
+ if(m_nPageCount > 1)
+ m_pbNext.Enable(sal_True);
+ else
+ m_pbNext.Enable(sal_False);
+
+ m_pbPrev.Enable(sal_False);
+ }
+ else if(GetCurLevel() == m_nPageCount-1) // letzte Seite hat keinen Next Button
+ {
+ m_pbNext.Enable(sal_False);
+ m_pbPrev.Enable(sal_True);
+ }
+ else
+ {
+ m_pbPrev.Enable(sal_True);
+ // next has already his state
+ }
+}
+// -----------------------------------------------------------------------
+void OCopyTableWizard::EnableButton(Wizard_Button_Style eStyle,sal_Bool bEnable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::EnableButton" );
+// CheckButtons();
+ Button* pButton;
+ if(eStyle == WIZARD_NEXT)
+ pButton = &m_pbNext;
+ else if(eStyle == WIZARD_PREV)
+ pButton = &m_pbPrev;
+ else
+ pButton = &m_pbFinish;
+ pButton->Enable(bEnable);
+
+}
+// -----------------------------------------------------------------------
+long OCopyTableWizard::DeactivatePage()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::DeactivatePage" );
+ OWizardPage* pPage = (OWizardPage*)GetPage(GetCurLevel());
+ return pPage ? pPage->LeavePage() : sal_False;
+}
+// -----------------------------------------------------------------------
+void OCopyTableWizard::AddWizardPage(OWizardPage* pPage)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::AddWizardPage" );
+ AddPage(pPage);
+ ++m_nPageCount;
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::insertColumn(sal_Int32 _nPos,OFieldDescription* _pField)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::insertColumn" );
+ OSL_ENSURE(_pField,"FieldDescrioption is null!");
+ if ( _pField )
+ {
+ ODatabaseExport::TColumns::iterator aFind = m_vDestColumns.find(_pField->GetName());
+ if ( aFind != m_vDestColumns.end() )
+ {
+ delete aFind->second;
+ m_vDestColumns.erase(aFind);
+ }
+
+ m_aDestVec.insert(m_aDestVec.begin() + _nPos,
+ m_vDestColumns.insert(ODatabaseExport::TColumns::value_type(_pField->GetName(),_pField)).first);
+ m_mNameMapping[_pField->GetName()] = _pField->GetName();
+ }
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::replaceColumn(sal_Int32 _nPos,OFieldDescription* _pField,const ::rtl::OUString& _sOldName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::replaceColumn" );
+ OSL_ENSURE(_pField,"FieldDescrioption is null!");
+ if ( _pField )
+ {
+ m_vDestColumns.erase(_sOldName);
+ OSL_ENSURE( m_vDestColumns.find(_pField->GetName()) == m_vDestColumns.end(),"Column with that name already exist!");
+
+ m_aDestVec[_nPos] =
+ m_vDestColumns.insert(ODatabaseExport::TColumns::value_type(_pField->GetName(),_pField)).first;
+ }
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::impl_loadSourceData()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::impl_loadSourceData" );
+ loadData( m_rSourceObject, m_vSourceColumns, m_vSourceVec );
+}
+
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::loadData( const ICopyTableSourceObject& _rSourceObject, ODatabaseExport::TColumns& _rColumns, ODatabaseExport::TColumnVector& _rColVector )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::loadData" );
+ ODatabaseExport::TColumns::iterator colEnd = _rColumns.end();
+ for ( ODatabaseExport::TColumns::iterator col = _rColumns.begin(); col != colEnd; ++col )
+ delete col->second;
+
+ _rColVector.clear();
+ _rColumns.clear();
+
+ OFieldDescription* pActFieldDescr = NULL;
+ String aType;
+ ::rtl::OUString sCreateParam(RTL_CONSTASCII_USTRINGPARAM("x"));
+ //////////////////////////////////////////////////////////////////////
+ // ReadOnly-Flag
+ // Bei Drop darf keine Zeile editierbar sein.
+ // Bei Add duerfen nur die leeren Zeilen editierbar sein.
+ // Bei Add und Drop koennen alle Zeilen editiert werden.
+ Sequence< ::rtl::OUString > aColumns( _rSourceObject.getColumnNames() );
+ const ::rtl::OUString* pColumn = aColumns.getConstArray();
+ const ::rtl::OUString* pColumnEnd = pColumn + aColumns.getLength();
+
+ for ( ; pColumn != pColumnEnd; ++pColumn )
+ {
+ // get the properties of the column
+ pActFieldDescr = _rSourceObject.createFieldDescription( *pColumn );
+ OSL_ENSURE( pActFieldDescr, "OCopyTableWizard::loadData: illegal field description!" );
+ if ( !pActFieldDescr )
+ continue;
+
+ sal_Int32 nType = pActFieldDescr->GetType();
+ sal_Int32 nScale = pActFieldDescr->GetScale();
+ sal_Int32 nPrecision = pActFieldDescr->GetPrecision();
+ sal_Bool bAutoIncrement = pActFieldDescr->IsAutoIncrement();
+ ::rtl::OUString sTypeName = pActFieldDescr->GetTypeName();
+
+ // search for type
+ sal_Bool bForce;
+ TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,sCreateParam,nPrecision,nScale,bAutoIncrement,bForce);
+ if ( !pTypeInfo.get() )
+ pTypeInfo = m_pTypeInfo;
+
+ pActFieldDescr->FillFromTypeInfo(pTypeInfo,sal_True,sal_False);
+ _rColVector.push_back(_rColumns.insert(ODatabaseExport::TColumns::value_type(pActFieldDescr->GetName(),pActFieldDescr)).first);
+ }
+
+ // determine which coumns belong to the primary key
+ Sequence< ::rtl::OUString > aPrimaryKeyColumns( _rSourceObject.getPrimaryKeyColumnNames() );
+ const ::rtl::OUString* pKeyColName = aPrimaryKeyColumns.getConstArray();
+ const ::rtl::OUString* pKeyColEnd = pKeyColName + aPrimaryKeyColumns.getLength();
+
+ for( ; pKeyColName != pKeyColEnd; ++pKeyColName )
+ {
+ ODatabaseExport::TColumns::iterator keyPos = _rColumns.find( *pKeyColName );
+ if ( keyPos != _rColumns.end() )
+ {
+ keyPos->second->SetPrimaryKey( sal_True );
+ keyPos->second->SetIsNullable( ColumnValue::NO_NULLS );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::clearDestColumns()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::clearDestColumns" );
+ clearColumns(m_vDestColumns,m_aDestVec);
+ m_bAddPKFirstTime = sal_True;
+ m_mNameMapping.clear();
+}
+
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::appendColumns( Reference<XColumnsSupplier>& _rxColSup, const ODatabaseExport::TColumnVector* _pVec, sal_Bool _bKeyColumns) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::appendColumns" );
+ // now append the columns
+ OSL_ENSURE(_rxColSup.is(),"No columns supplier");
+ if(!_rxColSup.is())
+ return;
+ Reference<XNameAccess> xColumns = _rxColSup->getColumns();
+ OSL_ENSURE(xColumns.is(),"No columns");
+ Reference<XDataDescriptorFactory> xColumnFactory(xColumns,UNO_QUERY);
+
+ Reference<XAppend> xAppend(xColumns,UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
+
+ ODatabaseExport::TColumnVector::const_iterator aIter = _pVec->begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = _pVec->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OFieldDescription* pField = (*aIter)->second;
+ if(!pField)
+ continue;
+
+ Reference<XPropertySet> xColumn;
+ if(pField->IsPrimaryKey() || !_bKeyColumns)
+ xColumn = xColumnFactory->createDataDescriptor();
+ if(xColumn.is())
+ {
+ if(!_bKeyColumns)
+ dbaui::setColumnProperties(xColumn,pField);
+ else
+ xColumn->setPropertyValue(PROPERTY_NAME,makeAny(pField->GetName()));
+
+ xAppend->appendByDescriptor(xColumn);
+ xColumn = NULL;
+ // now only the settings are missing
+ if(xColumns->hasByName(pField->GetName()))
+ {
+ xColumn.set(xColumns->getByName(pField->GetName()),UNO_QUERY);
+ OSL_ENSURE(xColumn.is(),"OCopyTableWizard::appendColumns: Column is NULL!");
+ if ( xColumn.is() )
+ pField->copyColumnSettingsTo(xColumn);
+ }
+ else
+ {
+ OSL_ENSURE(sal_False, "OCopyTableWizard::appendColumns: invalid field name!");
+ }
+
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::appendKey( Reference<XKeysSupplier>& _rxSup, const ODatabaseExport::TColumnVector* _pVec) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::appendKey" );
+ if(!_rxSup.is())
+ return; // the database doesn't support keys
+ OSL_ENSURE(_rxSup.is(),"No XKeysSupplier!");
+ Reference<XDataDescriptorFactory> xKeyFactory(_rxSup->getKeys(),UNO_QUERY);
+ OSL_ENSURE(xKeyFactory.is(),"No XDataDescriptorFactory Interface!");
+ if ( !xKeyFactory.is() )
+ return;
+ Reference<XAppend> xAppend(xKeyFactory,UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
+
+ Reference<XPropertySet> xKey = xKeyFactory->createDataDescriptor();
+ OSL_ENSURE(xKey.is(),"Key is null!");
+ xKey->setPropertyValue(PROPERTY_TYPE,makeAny(KeyType::PRIMARY));
+
+ Reference<XColumnsSupplier> xColSup(xKey,UNO_QUERY);
+ if(xColSup.is())
+ {
+ appendColumns(xColSup,_pVec,sal_True);
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ if(xColumns.is() && xColumns->getElementNames().getLength())
+ xAppend->appendByDescriptor(xKey);
+ }
+
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OCopyTableWizard::createView() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::createView" );
+ ::rtl::OUString sCommand( m_rSourceObject.getSelectStatement() );
+ OSL_ENSURE( sCommand.getLength(), "OCopyTableWizard::createView: no statement in the source object!" );
+ // there are legitimate cases in which getSelectStatement does not provide a statement,
+ // but in all those cases, this method here should never be called.
+ return ::dbaui::createView( m_sName, m_xDestConnection, sCommand );
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OCopyTableWizard::createTable()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::createTable" );
+ Reference< XPropertySet > xTable;
+
+ Reference<XTablesSupplier> xSup( m_xDestConnection, UNO_QUERY );
+ Reference< XNameAccess > xTables;
+ if(xSup.is())
+ xTables = xSup->getTables();
+ if ( getOperation() != CopyTableOperation::AppendData )
+ {
+ Reference<XDataDescriptorFactory> xFact(xTables,UNO_QUERY);
+ OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!");
+ if(!xFact.is())
+ return NULL;
+
+ xTable = xFact->createDataDescriptor();
+ OSL_ENSURE(xTable.is(),"Could not create a new object!");
+ if(!xTable.is())
+ return NULL;
+
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ Reference< XDatabaseMetaData> xMetaData = m_xDestConnection->getMetaData();
+ ::dbtools::qualifiedNameComponents(xMetaData,
+ m_sName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+
+ if ( !sCatalog.getLength() && xMetaData->supportsCatalogsInTableDefinitions() )
+ {
+ sCatalog = m_xDestConnection->getCatalog();
+ }
+
+ if ( !sSchema.getLength() && xMetaData->supportsSchemasInTableDefinitions() )
+ {
+ sSchema = xMetaData->getUserName();
+ }
+
+ xTable->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog));
+ xTable->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema));
+ xTable->setPropertyValue(PROPERTY_NAME,makeAny(sTable));
+
+ Reference< XColumnsSupplier > xSuppDestinationColumns( xTable, UNO_QUERY );
+ // now append the columns
+ const ODatabaseExport::TColumnVector* pVec = getDestVector();
+ appendColumns( xSuppDestinationColumns, pVec );
+ // now append the primary key
+ Reference<XKeysSupplier> xKeySup(xTable,UNO_QUERY);
+ appendKey(xKeySup,pVec);
+
+ Reference<XAppend> xAppend(xTables,UNO_QUERY);
+ if(xAppend.is())
+ xAppend->appendByDescriptor(xTable);
+
+ // xTable = NULL;
+ // we need to reget the table because after appending it it is no longer valid
+ if(xTables->hasByName(m_sName))
+ xTables->getByName(m_sName) >>= xTable;
+ else
+ {
+ ::rtl::OUString sComposedName(
+ ::dbtools::composeTableName( m_xDestConnection->getMetaData(), xTable, ::dbtools::eInDataManipulation, false, false, false ) );
+ if(xTables->hasByName(sComposedName))
+ {
+ xTables->getByName(sComposedName) >>= xTable;
+ m_sName = sComposedName;
+ }
+ else
+ xTable = NULL;
+ }
+ if(xTable.is())
+ {
+ xSuppDestinationColumns.set( xTable, UNO_QUERY_THROW );
+ // insert new table name into table filter
+ ::dbaui::appendToFilter( m_xDestConnection, m_sName, GetFactory(), this );
+
+ // copy ui settings
+ m_rSourceObject.copyUISettingsTo( xTable );
+ //copy filter and sorting
+ m_rSourceObject.copyFilterAndSortingTo(m_xDestConnection,xTable);
+ // set column mappings
+ Reference<XNameAccess> xNameAccess = xSuppDestinationColumns->getColumns();
+ Sequence< ::rtl::OUString> aSeq = xNameAccess->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+
+ ::std::vector<int> aAlreadyFound(m_vColumnPos.size(),0);
+
+ for(sal_Int32 nNewPos=1;pIter != pEnd;++pIter,++nNewPos)
+ {
+ ODatabaseExport::TColumns::const_iterator aDestIter = m_vDestColumns.find(*pIter);
+
+ if ( aDestIter != m_vDestColumns.end() )
+ {
+ ODatabaseExport::TColumnVector::const_iterator aFind = ::std::find(m_aDestVec.begin(),m_aDestVec.end(),aDestIter);
+ sal_Int32 nPos = (aFind - m_aDestVec.begin())+1;
+
+ ODatabaseExport::TPositions::iterator aPosFind = ::std::find_if(
+ m_vColumnPos.begin(),
+ m_vColumnPos.end(),
+ ::std::compose1( ::std::bind2nd( ::std::equal_to< sal_Int32 >(), nPos ),
+ ::std::select1st< ODatabaseExport::TPositions::value_type >()
+ )
+ );
+
+ if ( m_vColumnPos.end() != aPosFind )
+ {
+ aPosFind->second = nNewPos;
+ OSL_ENSURE( m_vColumnTypes.size() > size_t( aPosFind - m_vColumnPos.begin() ),
+ "Invalid index for vector!" );
+ m_vColumnTypes[ aPosFind - m_vColumnPos.begin() ] = (*aFind)->second->GetType();
+ }
+ }
+ }
+ }
+ }
+ else if(xTables.is() && xTables->hasByName(m_sName))
+ xTables->getByName(m_sName) >>= xTable;
+
+ return xTable;
+}
+
+// -----------------------------------------------------------------------------
+bool OCopyTableWizard::supportsPrimaryKey( const Reference< XConnection >& _rxConnection )
+{
+ OSL_PRECOND( _rxConnection.is(), "OCopyTableWizard::supportsPrimaryKey: invalid connection!" );
+ if ( !_rxConnection.is() )
+ return false;
+
+ ::dbtools::DatabaseMetaData aMetaData( _rxConnection );
+ return aMetaData.supportsPrimaryKeys();
+}
+
+// -----------------------------------------------------------------------------
+bool OCopyTableWizard::supportsViews( const Reference< XConnection >& _rxConnection )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::supportsViews" );
+ OSL_PRECOND( _rxConnection.is(), "OCopyTableWizard::supportsViews: invalid connection!" );
+ if ( !_rxConnection.is() )
+ return false;
+
+ bool bSupportsViews( false );
+ try
+ {
+ Reference< XDatabaseMetaData > xMetaData( _rxConnection->getMetaData(), UNO_SET_THROW );
+ Reference< XViewsSupplier > xViewSups( _rxConnection, UNO_QUERY );
+ bSupportsViews = xViewSups.is();
+ if ( !bSupportsViews )
+ {
+ try
+ {
+ Reference< XResultSet > xRs( xMetaData->getTableTypes(), UNO_SET_THROW );
+ Reference< XRow > xRow( xRs, UNO_QUERY_THROW );
+ while ( xRs->next() )
+ {
+ ::rtl::OUString sValue = xRow->getString( 1 );
+ if ( !xRow->wasNull() && sValue.equalsIgnoreAsciiCaseAscii( "View" ) )
+ {
+ bSupportsViews = true;
+ break;
+ }
+ }
+ }
+ catch( const SQLException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bSupportsViews;
+}
+
+// -----------------------------------------------------------------------------
+sal_Int32 OCopyTableWizard::getMaxColumnNameLength() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::getMaxColumnNameLength" );
+ sal_Int32 nLen = 0;
+ if ( m_xDestConnection.is() )
+ {
+ try
+ {
+ Reference< XDatabaseMetaData > xMetaData( m_xDestConnection->getMetaData(), UNO_SET_THROW );
+ nLen = xMetaData->getMaxColumnNameLength();
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return nLen;
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::setOperation( const sal_Int16 _nOperation )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::setOperation" );
+ m_nOperation = _nOperation;
+}
+// -----------------------------------------------------------------------------
+sal_Int16 OCopyTableWizard::getOperation() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::getOperation" );
+ return m_nOperation;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OCopyTableWizard::convertColumnName(const TColumnFindFunctor& _rCmpFunctor,
+ const ::rtl::OUString& _sColumnName,
+ const ::rtl::OUString& _sExtraChars,
+ sal_Int32 _nMaxNameLen)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::convertColumnName" );
+ ::rtl::OUString sAlias = _sColumnName;
+ if ( isSQL92CheckEnabled( m_xDestConnection ) )
+ sAlias = ::dbtools::convertName2SQLName(_sColumnName,_sExtraChars);
+ if((_nMaxNameLen && sAlias.getLength() > _nMaxNameLen) || _rCmpFunctor(sAlias))
+ {
+ sal_Int32 nDiff = 1;
+ do
+ {
+ ++nDiff;
+ if(_nMaxNameLen && sAlias.getLength() >= _nMaxNameLen)
+ sAlias = sAlias.copy(0,sAlias.getLength() - (sAlias.getLength()-_nMaxNameLen+nDiff));
+
+ ::rtl::OUString sName(sAlias);
+ sal_Int32 nPos = 1;
+ sName += ::rtl::OUString::valueOf(nPos);
+
+ while(_rCmpFunctor(sName))
+ {
+ sName = sAlias;
+ sName += ::rtl::OUString::valueOf(++nPos);
+ }
+ sAlias = sName;
+ // we have to check again, it could happen that the name is already to long
+ }
+ while(_nMaxNameLen && sAlias.getLength() > _nMaxNameLen);
+ }
+ OSL_ENSURE(m_mNameMapping.find(_sColumnName) == m_mNameMapping.end(),"name doubled!");
+ m_mNameMapping[_sColumnName] = sAlias;
+ return sAlias;
+}
+
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::removeColumnNameFromNameMap(const ::rtl::OUString& _sName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::removeColumnNameFromNameMap" );
+ m_mNameMapping.erase(_sName);
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OCopyTableWizard::supportsType(sal_Int32 _nDataType,sal_Int32& _rNewDataType)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::supportsType" );
+ sal_Bool bRet = m_aDestTypeInfo.find(_nDataType) != m_aDestTypeInfo.end();
+ if ( bRet )
+ _rNewDataType = _nDataType;
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OCopyTableWizard::convertType(const TOTypeInfoSP& _pType,sal_Bool& _bNotConvert)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::convertType" );
+ if ( !m_bInterConnectionCopy )
+ // no need to convert if the source and destination connection are the same
+ return _pType;
+
+ sal_Bool bForce;
+ TOTypeInfoSP pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,_pType->nType,_pType->aTypeName,_pType->aCreateParams,_pType->nPrecision,_pType->nMaximumScale,_pType->bAutoIncrement,bForce);
+ if ( !pType.get() || bForce )
+ { // no type found so we have to find the correct one ourself
+ sal_Int32 nDefaultType = DataType::VARCHAR;
+ switch(_pType->nType)
+ {
+ case DataType::TINYINT:
+ if(supportsType(DataType::SMALLINT,nDefaultType))
+ break;
+ // run through
+ case DataType::SMALLINT:
+ if(supportsType(DataType::INTEGER,nDefaultType))
+ break;
+ // run through
+ case DataType::INTEGER:
+ if(supportsType(DataType::FLOAT,nDefaultType))
+ break;
+ // run through
+ case DataType::FLOAT:
+ if(supportsType(DataType::REAL,nDefaultType))
+ break;
+ // run through
+ case DataType::DATE:
+ case DataType::TIME:
+ if( DataType::DATE == _pType->nType || DataType::TIME == _pType->nType )
+ {
+ if(supportsType(DataType::TIMESTAMP,nDefaultType))
+ break;
+ }
+ // run through
+ case DataType::TIMESTAMP:
+ case DataType::REAL:
+ case DataType::BIGINT:
+ if ( supportsType(DataType::DOUBLE,nDefaultType) )
+ break;
+ // run through
+ case DataType::DOUBLE:
+ if ( supportsType(DataType::NUMERIC,nDefaultType) )
+ break;
+ // run through
+ case DataType::NUMERIC:
+ supportsType(DataType::DECIMAL,nDefaultType);
+ break;
+ case DataType::DECIMAL:
+ if ( supportsType(DataType::NUMERIC,nDefaultType) )
+ break;
+ if ( supportsType(DataType::DOUBLE,nDefaultType) )
+ break;
+ break;
+ case DataType::VARCHAR:
+ if ( supportsType(DataType::LONGVARCHAR,nDefaultType) )
+ break;
+ break;
+ case DataType::LONGVARCHAR:
+ if ( supportsType(DataType::CLOB,nDefaultType) )
+ break;
+ break;
+ case DataType::BINARY:
+ if ( supportsType(DataType::VARBINARY,nDefaultType) )
+ break;
+ break;
+ case DataType::VARBINARY:
+ if ( supportsType(DataType::LONGVARBINARY,nDefaultType) )
+ break;
+ break;
+ case DataType::LONGVARBINARY:
+ if ( supportsType(DataType::BLOB,nDefaultType) )
+ break;
+ if ( supportsType(DataType::LONGVARCHAR,nDefaultType) )
+ break;
+ if ( supportsType(DataType::CLOB,nDefaultType) )
+ break;
+ break;
+ default:
+ nDefaultType = DataType::VARCHAR;
+ }
+ pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,nDefaultType,_pType->aTypeName,_pType->aCreateParams,_pType->nPrecision,_pType->nMaximumScale,_pType->bAutoIncrement,bForce);
+ if ( !pType.get() )
+ {
+ _bNotConvert = sal_False;
+ ::rtl::OUString sCreate(RTL_CONSTASCII_USTRINGPARAM("x"));
+ pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,DataType::VARCHAR,_pType->aTypeName,sCreate,50,0,sal_False,bForce);
+ if ( !pType.get() )
+ pType = m_pTypeInfo;
+ }
+ else if ( bForce )
+ _bNotConvert = sal_False;
+ }
+ return pType;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OCopyTableWizard::createUniqueName(const ::rtl::OUString& _sName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::createUniqueName" );
+ ::rtl::OUString sName = _sName;
+ Sequence< ::rtl::OUString > aColumnNames( m_rSourceObject.getColumnNames() );
+ if ( aColumnNames.getLength() )
+ sName = ::dbtools::createUniqueName( aColumnNames, sName, sal_False );
+ else
+ {
+ if ( m_vSourceColumns.find(sName) != m_vSourceColumns.end())
+ {
+ sal_Int32 nPos = 0;
+ while(m_vSourceColumns.find(sName) != m_vSourceColumns.end())
+ {
+ sName = _sName;
+ sName += ::rtl::OUString::valueOf(++nPos);
+ }
+ }
+ }
+ return sName;
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::showColumnTypeNotSupported(const ::rtl::OUString& _rColumnName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::showColumnTypeNotSupported" );
+ String sMessage( ModuleRes( STR_UNKNOWN_TYPE_FOUND ) );
+ sMessage.SearchAndReplaceAscii("#1",_rColumnName);
+ showError(sMessage);
+}
+//-------------------------------------------------------------------------------
+void OCopyTableWizard::showError(const ::rtl::OUString& _sErrorMesage)
+{
+ SQLExceptionInfo aInfo(_sErrorMesage);
+ showError(aInfo.get());
+}
+//-------------------------------------------------------------------------------
+void OCopyTableWizard::showError(const Any& _aError)
+{
+ if ( _aError.hasValue() && m_xInteractionHandler.is() )
+ {
+ try
+ {
+ ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( _aError ) );
+ m_xInteractionHandler->handle( xRequest.get() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+
diff --git a/dbaccess/source/ui/misc/WExtendPages.cxx b/dbaccess/source/ui/misc/WExtendPages.cxx
new file mode 100644
index 000000000000..23a63ef2a6d4
--- /dev/null
+++ b/dbaccess/source/ui/misc/WExtendPages.cxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_WIZ_EXTENDPAGES_HXX
+#include "WExtendPages.hxx"
+#endif
+#ifndef DBAUI_RTFREADER_HXX
+#include "RtfReader.hxx"
+#endif
+#ifndef DBAUI_HTMLREADER_HXX
+#include "HtmlReader.hxx"
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+
+using namespace dbaui;
+//========================================================================
+SvParser* OWizHTMLExtend::createReader(sal_Int32 _nRows)
+{
+ return new OHTMLReader(*m_pParserStream,
+ _nRows,
+ m_pParent->GetColumnPositions(),
+ m_pParent->GetFormatter(),
+ m_pParent->GetFactory(),
+ m_pParent->getDestVector(),
+ m_pParent->getTypeInfo(),
+ m_pParent->shouldCreatePrimaryKey());
+}
+//========================================================================
+SvParser* OWizRTFExtend::createReader(sal_Int32 _nRows)
+{
+ return new ORTFReader(*m_pParserStream,
+ _nRows,
+ m_pParent->GetColumnPositions(),
+ m_pParent->GetFormatter(),
+ m_pParent->GetFactory(),
+ m_pParent->getDestVector(),
+ m_pParent->getTypeInfo(),
+ m_pParent->shouldCreatePrimaryKey());
+}
+//========================================================================
+OWizNormalExtend::OWizNormalExtend(Window* pParent) : OWizTypeSelect( pParent )
+{
+ EnableAuto(sal_False);
+ Size aflSize( m_flColumns.GetSizePixel() );
+ Point aPos(m_flColumns.GetPosPixel());
+
+ m_flColumns.SetPosSizePixel(aPos, aflSize );
+
+ sal_Int32 nHeight = m_lbColumnNames.GetSizePixel().Height() +6;
+ aPos = m_aTypeControl.GetPosPixel();
+ Size aNewSize(m_aTypeControl.GetSizePixel().Width(),nHeight - aPos.Y()-6);
+
+ aflSize = m_aTypeControl.GetSizePixel();
+ m_aTypeControl.SetPosSizePixel(aPos,aNewSize);
+}
+// -----------------------------------------------------------------------------
+SvParser* OWizNormalExtend::createReader(sal_Int32 /*_nRows*/)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx
new file mode 100644
index 000000000000..9c475971a8d2
--- /dev/null
+++ b/dbaccess/source/ui/misc/WNameMatch.cxx
@@ -0,0 +1,450 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_WIZ_NAMEMATCHING_HXX
+#include "WNameMatch.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#include "WizardPages.hrc"
+#endif
+#ifndef _SV_SCRBAR_HXX
+#include <vcl/scrbar.hxx>
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+
+using namespace ::dbaui;
+//========================================================================
+// OWizColumnSelect
+DBG_NAME(OWizNameMatching)
+//========================================================================
+OWizNameMatching::OWizNameMatching( Window* pParent)
+ :OWizardPage( pParent, ModuleRes( TAB_WIZ_NAME_MATCHING ) )
+ ,m_FT_TABLE_LEFT( this, ModuleRes( FT_TABLE_LEFT ) )
+ ,m_FT_TABLE_RIGHT( this, ModuleRes( FT_TABLE_RIGHT ) )
+ ,m_CTRL_LEFT( this, ModuleRes( CTRL_LEFT ) )
+ ,m_CTRL_RIGHT( this, ModuleRes( CTRL_RIGHT ) )
+ ,m_ibColumn_up( this, ModuleRes( IB_COLUMN_UP ) )
+ ,m_ibColumn_down( this, ModuleRes( IB_COLUMN_DOWN ) )
+ ,m_ibColumn_up_right( this, ModuleRes( IB_COLUMN_UP_RIGHT ) )
+ ,m_ibColumn_down_right( this, ModuleRes( IB_COLUMN_DOWN_RIGHT ) )
+ ,m_pbAll( this, ModuleRes( PB_ALL ) )
+ ,m_pbNone( this, ModuleRes( PB_NONE ) )
+
+{
+ DBG_CTOR(OWizNameMatching,NULL);
+
+ m_ibColumn_up.SetClickHdl(LINK(this,OWizNameMatching,ButtonClickHdl));
+ m_ibColumn_down.SetClickHdl(LINK(this,OWizNameMatching,ButtonClickHdl));
+
+ m_ibColumn_up_right.SetClickHdl(LINK(this,OWizNameMatching,RightButtonClickHdl));
+ m_ibColumn_down_right.SetClickHdl(LINK(this,OWizNameMatching,RightButtonClickHdl));
+
+ m_pbAll.SetClickHdl(LINK(this,OWizNameMatching,AllNoneClickHdl));
+ m_pbNone.SetClickHdl(LINK(this,OWizNameMatching,AllNoneClickHdl));
+
+ m_CTRL_LEFT.SetSelectHdl(LINK(this,OWizNameMatching,TableListClickHdl));
+ m_CTRL_RIGHT.SetSelectHdl(LINK(this,OWizNameMatching,TableListRightSelectHdl));
+ m_CTRL_RIGHT.EnableCheckButton( NULL );
+
+ m_CTRL_LEFT.SetStyle( m_CTRL_LEFT.GetStyle() | WB_FORCE_MAKEVISIBLE );
+ m_CTRL_RIGHT.SetStyle( m_CTRL_RIGHT.GetStyle() | WB_FORCE_MAKEVISIBLE );
+
+ m_sSourceText = m_FT_TABLE_LEFT.GetText();
+ m_sSourceText.AppendAscii("\n");
+ m_sDestText = m_FT_TABLE_RIGHT.GetText();
+ m_sDestText.AppendAscii("\n");
+
+ // set hiContrast
+ m_ibColumn_up.SetModeImage(ModuleRes(IMG_SORTUP_H),BMP_COLOR_HIGHCONTRAST);
+ m_ibColumn_down.SetModeImage(ModuleRes(IMG_SORTDOWN_H),BMP_COLOR_HIGHCONTRAST);
+ m_ibColumn_up_right.SetModeImage(ModuleRes(IMG_SORTUP_H),BMP_COLOR_HIGHCONTRAST);
+ m_ibColumn_down_right.SetModeImage(ModuleRes(IMG_SORTDOWN_H),BMP_COLOR_HIGHCONTRAST);
+
+ FreeResource();
+}
+// -----------------------------------------------------------------------
+OWizNameMatching::~OWizNameMatching()
+{
+ DBG_DTOR(OWizNameMatching,NULL);
+}
+
+// -----------------------------------------------------------------------
+void OWizNameMatching::Reset()
+{
+ // urspr"unglichen zustand wiederherstellen
+ DBG_CHKTHIS(OWizNameMatching,NULL);
+ // the left tree contains bitmaps so i need to resize the right one
+ if(m_bFirstTime)
+ {
+ m_CTRL_RIGHT.SetReadOnly(); // sets autoinc to readonly
+ m_CTRL_RIGHT.SetEntryHeight(m_CTRL_LEFT.GetEntryHeight());
+ m_CTRL_RIGHT.SetIndent(m_CTRL_LEFT.GetIndent());
+ m_CTRL_RIGHT.SetSpaceBetweenEntries(m_CTRL_LEFT.GetSpaceBetweenEntries());
+
+ m_bFirstTime = sal_False;
+ }
+
+ // m_CTRL_LEFT.Clear();
+}
+// -----------------------------------------------------------------------
+void OWizNameMatching::ActivatePage( )
+{
+ DBG_CHKTHIS(OWizNameMatching,NULL);
+
+ // set source table name
+ String aName = m_sSourceText;
+ aName += String(m_pParent->m_sSourceName);
+
+ m_FT_TABLE_LEFT.SetText(aName);
+
+ // set dest table name
+ aName = m_sDestText;
+ aName += String(m_pParent->m_sName);
+ m_FT_TABLE_RIGHT.SetText(aName);
+
+
+ m_CTRL_LEFT.FillListBox(*m_pParent->getSrcVector());
+ m_CTRL_RIGHT.FillListBox(*m_pParent->getDestVector());
+
+ m_ibColumn_up.Enable( m_CTRL_LEFT.GetEntryCount() > 1 );
+ m_ibColumn_down.Enable( m_CTRL_LEFT.GetEntryCount() > 1 );
+
+ m_ibColumn_up_right.Enable( m_CTRL_RIGHT.GetEntryCount() > 1 );
+ m_ibColumn_down_right.Enable( m_CTRL_RIGHT.GetEntryCount() > 1 );
+
+
+ m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,sal_False);
+ m_CTRL_LEFT.GrabFocus();
+}
+// -----------------------------------------------------------------------
+sal_Bool OWizNameMatching::LeavePage()
+{
+ DBG_CHKTHIS(OWizNameMatching,NULL);
+
+ const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector();
+
+ m_pParent->m_vColumnPos.clear();
+ m_pParent->m_vColumnTypes.clear();
+ m_pParent->m_vColumnPos.resize( pSrcColumns->size(), ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) );
+ m_pParent->m_vColumnTypes.resize( pSrcColumns->size(), COLUMN_POSITION_NOT_FOUND );
+
+
+ sal_Int32 nParamPos = 0;
+ SvLBoxEntry* pLeftEntry = m_CTRL_LEFT.GetModel()->First();
+ SvLBoxEntry* pRightEntry = m_CTRL_RIGHT.GetModel()->First();
+ while(pLeftEntry && pRightEntry)
+ {
+ OFieldDescription* pSrcField = static_cast<OFieldDescription*>(pLeftEntry->GetUserData());
+ DBG_ASSERT(pSrcField,"OWizNameMatching: OColumn can not be null!");
+
+ ODatabaseExport::TColumnVector::const_iterator aSrcIter = pSrcColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aSrcEnd = pSrcColumns->end();
+ for(;aSrcIter != aSrcEnd && (*aSrcIter)->second != pSrcField;++aSrcIter)
+ ;
+ const sal_Int32 nPos = ::std::distance(pSrcColumns->begin(),aSrcIter);
+
+ // sal_Int32 nPos = m_CTRL_LEFT.GetModel()->GetAbsPos(pLeftEntry);
+ if(m_CTRL_LEFT.GetCheckButtonState(pLeftEntry) == SV_BUTTON_CHECKED)
+ {
+ OFieldDescription* pDestField = static_cast<OFieldDescription*>(pRightEntry->GetUserData());
+ DBG_ASSERT(pDestField,"OWizNameMatching: OColumn can not be null!");
+ const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector();
+ ODatabaseExport::TColumnVector::const_iterator aDestIter = pDestColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aDestEnd = pDestColumns->end();
+
+ for(;aDestIter != aDestEnd && (*aDestIter)->second != pDestField;++aDestIter)
+ ;
+
+ OSL_ENSURE((nPos) < static_cast<sal_Int32>(m_pParent->m_vColumnPos.size()),"m_pParent->m_vColumnPos: Illegal index for vector");
+ m_pParent->m_vColumnPos[nPos].first = ++nParamPos;
+ m_pParent->m_vColumnPos[nPos].second = ::std::distance(pDestColumns->begin(),aDestIter) + 1;
+ sal_Bool bNotConvert = sal_True;
+ TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert);
+ sal_Int32 nType = ::com::sun::star::sdbc::DataType::VARCHAR;
+ if ( pTypeInfo.get() )
+ nType = pTypeInfo->nType;
+ m_pParent->m_vColumnTypes[nPos] = nType;
+ }
+ else
+ {
+ m_pParent->m_vColumnPos[nPos].first = COLUMN_POSITION_NOT_FOUND;
+ m_pParent->m_vColumnPos[nPos].second = COLUMN_POSITION_NOT_FOUND;
+ }
+
+ pLeftEntry = m_CTRL_LEFT.GetModel()->Next(pLeftEntry);
+ pRightEntry = m_CTRL_RIGHT.GetModel()->Next(pRightEntry);
+ }
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------
+String OWizNameMatching::GetTitle() const { return String(ModuleRes(STR_WIZ_NAME_MATCHING_TITEL)); }
+// -----------------------------------------------------------------------
+IMPL_LINK( OWizNameMatching, ButtonClickHdl, Button *, pButton )
+{
+ SvLBoxEntry* pEntry = m_CTRL_LEFT.FirstSelected();
+ if ( pEntry )
+ {
+ sal_Int32 nPos = m_CTRL_LEFT.GetModel()->GetAbsPos(pEntry);
+ if(pButton == &m_ibColumn_up && nPos)
+ --nPos;
+ else if(pButton == &m_ibColumn_down)
+ nPos += 2;
+
+ m_CTRL_LEFT.ModelIsMoving(pEntry,NULL,nPos);
+ m_CTRL_LEFT.GetModel()->Move(pEntry,NULL,nPos);
+ m_CTRL_LEFT.ModelHasMoved(pEntry);
+
+ long nThumbPos = m_CTRL_LEFT.GetVScroll()->GetThumbPos();
+ long nVisibleSize = m_CTRL_LEFT.GetVScroll()->GetVisibleSize();
+
+ if(pButton == &m_ibColumn_down && (nThumbPos+nVisibleSize+1) < nPos)
+ {
+ m_CTRL_LEFT.GetVScroll()->DoScrollAction(SCROLL_LINEDOWN);
+ // m_CTRL_LEFT.MakeVisible(pEntry,sal_True);
+ }
+
+ TableListClickHdl(&m_CTRL_LEFT);
+ }
+
+
+ return 0;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OWizNameMatching, RightButtonClickHdl, Button *, pButton )
+{
+ SvLBoxEntry* pEntry = m_CTRL_RIGHT.FirstSelected();
+ if ( pEntry )
+ {
+ sal_Int32 nPos = m_CTRL_RIGHT.GetModel()->GetAbsPos(pEntry);
+ if(pButton == &m_ibColumn_up_right && nPos)
+ --nPos;
+ else if(pButton == &m_ibColumn_down_right)
+ nPos += 2;
+
+ m_CTRL_RIGHT.ModelIsMoving(pEntry,NULL,nPos);
+ m_CTRL_RIGHT.GetModel()->Move(pEntry,NULL,nPos);
+ m_CTRL_RIGHT.ModelHasMoved(pEntry);
+ long nThumbPos = m_CTRL_RIGHT.GetVScroll()->GetThumbPos();
+ long nVisibleSize = m_CTRL_RIGHT.GetVScroll()->GetVisibleSize();
+
+ if(pButton == &m_ibColumn_down_right && (nThumbPos+nVisibleSize+1) < nPos)
+ m_CTRL_RIGHT.GetVScroll()->DoScrollAction(SCROLL_LINEDOWN);
+ TableListRightSelectHdl(&m_CTRL_RIGHT);
+ }
+ return 0;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OWizNameMatching, TableListClickHdl, void*, /*NOTINTERESTEDIN*/ )
+{
+ SvLBoxEntry* pEntry = m_CTRL_LEFT.FirstSelected();
+ if(pEntry)
+ {
+ sal_uLong nPos = m_CTRL_LEFT.GetModel()->GetAbsPos(pEntry);
+ SvLBoxEntry* pOldEntry = m_CTRL_RIGHT.FirstSelected();
+ if(pOldEntry && nPos != m_CTRL_RIGHT.GetModel()->GetAbsPos(pOldEntry))
+ {
+ if(pOldEntry)
+ m_CTRL_RIGHT.Select(pOldEntry,sal_False);
+ pOldEntry = m_CTRL_RIGHT.GetEntry(nPos);
+ if(pOldEntry)
+ {
+ sal_uLong nNewPos = m_CTRL_LEFT.GetModel()->GetAbsPos(m_CTRL_LEFT.GetFirstEntryInView());
+ if ( nNewPos - nPos == 1 )
+ --nNewPos;
+ m_CTRL_RIGHT.MakeVisible(m_CTRL_RIGHT.GetEntry(nNewPos),sal_True);
+ m_CTRL_RIGHT.Select(pOldEntry,sal_True);
+ }
+ }
+ else if(!pOldEntry)
+ {
+ pOldEntry = m_CTRL_RIGHT.GetEntry(nPos);
+ if(pOldEntry)
+ {
+ m_CTRL_RIGHT.Select(pOldEntry,sal_True);
+ }
+ }
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OWizNameMatching, TableListRightSelectHdl, void*, /*NOTINTERESTEDIN*/ )
+{
+ SvLBoxEntry* pEntry = m_CTRL_RIGHT.FirstSelected();
+ if(pEntry)
+ {
+ sal_uLong nPos = m_CTRL_RIGHT.GetModel()->GetAbsPos(pEntry);
+ SvLBoxEntry* pOldEntry = m_CTRL_LEFT.FirstSelected();
+ if(pOldEntry && nPos != m_CTRL_LEFT.GetModel()->GetAbsPos(pOldEntry))
+ {
+ if(pOldEntry)
+ m_CTRL_LEFT.Select(pOldEntry,sal_False);
+ pOldEntry = m_CTRL_LEFT.GetEntry(nPos);
+ if(pOldEntry)
+ {
+ sal_uLong nNewPos = m_CTRL_RIGHT.GetModel()->GetAbsPos(m_CTRL_RIGHT.GetFirstEntryInView());
+ if ( nNewPos - nPos == 1 )
+ nNewPos--;
+ m_CTRL_LEFT.MakeVisible(m_CTRL_LEFT.GetEntry(nNewPos),sal_True);
+ m_CTRL_LEFT.Select(pOldEntry,sal_True);
+ }
+ }
+ else if(!pOldEntry)
+ {
+ pOldEntry = m_CTRL_LEFT.GetEntry(nPos);
+ if(pOldEntry)
+ {
+ m_CTRL_LEFT.Select(pOldEntry,sal_True);
+ }
+ }
+ }
+
+ return 0;
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OWizNameMatching, AllNoneClickHdl, Button *, pButton )
+{
+ sal_Bool bAll = pButton == &m_pbAll;
+ SvLBoxEntry* pEntry = m_CTRL_LEFT.First();
+ while(pEntry)
+ {
+ m_CTRL_LEFT.SetCheckButtonState( pEntry, bAll ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED);
+ pEntry = m_CTRL_LEFT.Next(pEntry);
+ }
+
+ return 0;
+}
+// -----------------------------------------------------------------------
+//========================================================================
+// class OColumnString
+//========================================================================
+class OColumnString : public SvLBoxString
+{
+ sal_Bool m_bReadOnly;
+public:
+ OColumnString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& rStr,sal_Bool _RO)
+ :SvLBoxString(pEntry,nFlags,rStr)
+ ,m_bReadOnly(_RO)
+ {
+ }
+
+ virtual void Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry);
+ //virtual void InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData);
+};
+
+
+
+//------------------------------------------------------------------------
+/*
+void OColumnString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData)
+{
+ SvLBoxString::InitViewData(pView,pEntry,pViewData);
+}
+*/
+//------------------------------------------------------------------------
+void OColumnString::Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 /*nFlags*/, SvLBoxEntry* /*pEntry*/ )
+{
+ if(m_bReadOnly)
+ {
+ const StyleSettings& rStyleSettings = rDev.GetSettings().GetStyleSettings();
+ rDev.SetTextColor( rStyleSettings.GetDisableColor() );
+ rDev.SetTextFillColor( rStyleSettings.GetFieldColor() );
+ }
+ rDev.DrawText( rPos, GetText() );
+}
+//========================================================================
+OColumnTreeBox::OColumnTreeBox( Window* pParent, const ResId& rResId )
+ : OMarkableTreeListBox(pParent,NULL,rResId)
+{
+ SetDragDropMode( 0 );
+ EnableInplaceEditing( sal_False );
+ SetStyle(GetStyle() | WB_BORDER | WB_HASBUTTONS | WB_HSCROLL);
+ SetSelectionMode( SINGLE_SELECTION );
+}
+//------------------------------------------------------------------------
+void OColumnTreeBox::InitEntry(SvLBoxEntry* pEntry, const String& rStr, const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind)
+{
+ DBTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
+ SvLBoxString* pString = new OColumnString(pEntry, 0, rStr,sal_False);
+ if (pString)
+ pEntry->ReplaceItem( pString, pEntry->ItemCount() - 1 );
+}
+//------------------------------------------------------------------------
+sal_Bool OColumnTreeBox::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
+{
+ if(bSelect)
+ {
+ OFieldDescription* pColumn = static_cast<OFieldDescription*>(pEntry->GetUserData());
+ if(!(pColumn->IsAutoIncrement() && m_bReadOnly))
+ bSelect = DBTreeListBox::Select( pEntry,bSelect );
+ }
+ else
+ bSelect = DBTreeListBox::Select( pEntry,bSelect );
+ return bSelect;
+}
+//------------------------------------------------------------------------
+void OColumnTreeBox::FillListBox( const ODatabaseExport::TColumnVector& _rList)
+{
+ Clear();
+ ODatabaseExport::TColumnVector::const_iterator aIter = _rList.begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = _rList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ SvLBoxEntry* pEntry = InsertEntry((*aIter)->first,0,sal_False,LIST_APPEND,(*aIter)->second);
+ SvButtonState eState = !(m_bReadOnly && (*aIter)->second->IsAutoIncrement()) ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED;
+ SetCheckButtonState( pEntry, eState );
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
diff --git a/dbaccess/source/ui/misc/WTypeSelect.cxx b/dbaccess/source/ui/misc/WTypeSelect.cxx
new file mode 100644
index 000000000000..379236321a05
--- /dev/null
+++ b/dbaccess/source/ui/misc/WTypeSelect.cxx
@@ -0,0 +1,510 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_WIZ_TYPESELECT_HXX
+#include "WTypeSelect.hxx"
+#endif
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#include "WizardPages.hrc"
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#include "FieldDescriptions.hxx"
+#endif
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#include "WCopyTable.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef _STREAM_HXX
+#include <tools/stream.hxx>
+#endif
+#ifndef _SVPARSER_HXX
+#include <svtools/svparser.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#include "sqlmessage.hxx"
+#endif
+#ifndef DBAUI_FIELDCONTROLS_HXX
+#include "FieldControls.hxx"
+#endif
+
+#include "dbaccess_slotid.hrc"
+
+using namespace ::dbaui;
+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::sdbc;
+// using namespace ::com::sun::star::sdbcx;
+
+//========================================================================
+// OWizTypeSelectControl
+DBG_NAME(OWizTypeSelectControl)
+//========================================================================
+OWizTypeSelectControl::OWizTypeSelectControl(Window* pParent, const ResId& rResId,OTableDesignHelpBar* pHelpBar)
+ : OFieldDescControl(pParent,rResId,pHelpBar)
+{
+ DBG_CTOR(OWizTypeSelectControl,NULL);
+
+}
+// -----------------------------------------------------------------------------
+OWizTypeSelectControl::~OWizTypeSelectControl()
+{
+
+ DBG_DTOR(OWizTypeSelectControl,NULL);
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelectControl::ActivateAggregate( EControlType eType )
+{
+ switch(eType )
+ {
+ case tpFormat:
+ case tpDefault:
+ case tpAutoIncrement:
+ case tpAutoIncrementValue:
+ break;
+ default:
+ OFieldDescControl::ActivateAggregate( eType );
+ }
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelectControl::DeactivateAggregate( EControlType eType )
+{
+ switch(eType )
+ {
+ case tpFormat:
+ case tpDefault:
+ case tpAutoIncrement:
+ case tpAutoIncrementValue:
+ break;
+ default:
+ OFieldDescControl::DeactivateAggregate( eType );
+ }
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelectControl::CellModified(long nRow, sal_uInt16 nColId )
+{
+ DBG_ASSERT(nRow == -1,"nRow muss -1 sein!");
+ (void)nRow;
+
+ MultiListBox &aListBox = ((OWizTypeSelect*)GetParent())->m_lbColumnNames;
+
+ OFieldDescription* pCurFieldDescr = getCurrentFieldDescData();
+
+ sal_uInt16 nPos = aListBox.GetEntryPos( String( pCurFieldDescr->GetName() ) );
+ pCurFieldDescr = static_cast< OFieldDescription* >( aListBox.GetEntryData( nPos ) );
+ OSL_ENSURE( pCurFieldDescr, "OWizTypeSelectControl::CellModified: Columnname/type not found in the listbox!" );
+ if ( !pCurFieldDescr )
+ return;
+ setCurrentFieldDescData( pCurFieldDescr );
+
+ ::rtl::OUString sName = pCurFieldDescr->GetName();
+ ::rtl::OUString sNewName;
+ const OPropColumnEditCtrl* pColumnName = getColumnCtrl();
+ if ( pColumnName )
+ sNewName = pColumnName->GetText();
+
+ switch(nColId)
+ {
+ case FIELD_PRPOERTY_COLUMNNAME:
+ {
+ OCopyTableWizard* pWiz = static_cast<OCopyTableWizard*>(GetParent()->GetParent());
+ // first we have to check if this name already exists
+ sal_Bool bDoubleName = sal_False;
+ sal_Bool bCase = sal_True;
+ if ( getMetaData().is() && !getMetaData()->supportsMixedCaseQuotedIdentifiers() )
+ {
+ bCase = sal_False;
+ sal_uInt16 nCount = aListBox.GetEntryCount();
+ for (sal_uInt16 i=0 ; !bDoubleName && i < nCount ; ++i)
+ {
+ ::rtl::OUString sEntry(aListBox.GetEntry(i));
+ bDoubleName = sNewName.equalsIgnoreAsciiCase(sEntry);
+ }
+ if ( !bDoubleName && pWiz->shouldCreatePrimaryKey() )
+ bDoubleName = sNewName.equalsIgnoreAsciiCase(pWiz->getPrimaryKeyName());
+
+ }
+ else
+ bDoubleName = ((aListBox.GetEntryPos(String(sNewName)) != LISTBOX_ENTRY_NOTFOUND)
+ || ( pWiz->shouldCreatePrimaryKey()
+ && pWiz->getPrimaryKeyName() == sNewName) );
+
+ if ( bDoubleName )
+ {
+ String strMessage = String(ModuleRes(STR_TABLEDESIGN_DUPLICATE_NAME));
+ strMessage.SearchAndReplaceAscii("$column$", sNewName);
+ pWiz->showError(strMessage);
+ pCurFieldDescr->SetName(sName);
+ DisplayData(pCurFieldDescr);
+ static_cast<OWizTypeSelect*>(GetParent())->setDuplicateName(sal_True);
+ return;
+ }
+
+ ::rtl::OUString sOldName = pCurFieldDescr->GetName();
+ pCurFieldDescr->SetName(sNewName);
+ static_cast<OWizTypeSelect*>(GetParent())->setDuplicateName(sal_False);
+
+ // now we change the name
+ OCopyTableWizard::TNameMapping::iterator aIter = pWiz->m_mNameMapping.begin();
+ OCopyTableWizard::TNameMapping::iterator aEnd = pWiz->m_mNameMapping.end();
+
+ ::comphelper::UStringMixEqual aCase(bCase);
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( aCase(aIter->second,sName) )
+ {
+ aIter->second = sNewName;
+ break;
+ }
+ }
+
+ aListBox.RemoveEntry(nPos);
+ aListBox.InsertEntry(pCurFieldDescr->GetName(),nPos);
+ aListBox.SetEntryData(nPos,pCurFieldDescr);
+
+ pWiz->replaceColumn(nPos,pCurFieldDescr,sOldName);
+ }
+ break;
+ }
+ saveCurrentFieldDescData();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::lang::Locale OWizTypeSelectControl::GetLocale() const
+{
+ return static_cast<OWizTypeSelect*>(GetParent())->m_pParent->GetLocale();
+}
+// -----------------------------------------------------------------------------
+Reference< XNumberFormatter > OWizTypeSelectControl::GetFormatter() const
+{
+ return static_cast<OWizTypeSelect*>(GetParent())->m_pParent->GetFormatter();
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OWizTypeSelectControl::getTypeInfo(sal_Int32 _nPos)
+{
+ return static_cast<OWizTypeSelect*>(GetParent())->m_pParent->getDestTypeInfo(_nPos);
+}
+// -----------------------------------------------------------------------------
+const OTypeInfoMap* OWizTypeSelectControl::getTypeInfo() const
+{
+ return static_cast<OWizTypeSelect*>(GetParent())->m_pParent->getDestTypeInfo();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> OWizTypeSelectControl::getMetaData()
+{
+ return ((OWizTypeSelect*)GetParent())->m_pParent->m_xDestConnection->getMetaData();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> OWizTypeSelectControl::getConnection()
+{
+ return ((OWizTypeSelect*)GetParent())->m_pParent->m_xDestConnection;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OWizTypeSelectControl::isAutoIncrementValueEnabled() const
+{
+ return ((OWizTypeSelect*)GetParent())->m_bAutoIncrementEnabled;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OWizTypeSelectControl::getAutoIncrementValue() const
+{
+ return ((OWizTypeSelect*)GetParent())->m_sAutoIncrementValue;
+}
+// -----------------------------------------------------------------------------
+
+//========================================================================
+DBG_NAME(OWizTypeSelect);
+#define IMG_PRIMARY_KEY 1
+//========================================================================
+OWizTypeSelect::OWizTypeSelect( Window* pParent, SvStream* _pStream )
+ :OWizardPage( pParent, ModuleRes( TAB_WIZ_TYPE_SELECT ))
+ ,m_lbColumnNames( this, ModuleRes( LB_NEW_COLUMN_NAMES ) )
+ ,m_flColumns( this, ModuleRes( FL_COLUMN_NAME ) )
+ ,m_aTypeControl( this, ModuleRes( CONTROL_CONTAINER ))
+ ,m_flAutoType( this, ModuleRes( FL_AUTO_TYPE ) )
+ ,m_ftAuto( this, ModuleRes( FT_AUTO ) )
+ ,m_etAuto( this, ModuleRes( ET_AUTO ) )
+ ,m_pbAuto( this, ModuleRes( PB_AUTO ) )
+ ,m_pParserStream( _pStream )
+ ,m_nDisplayRow(0)
+ ,m_bAutoIncrementEnabled(sal_False)
+ ,m_bDuplicateName(sal_False)
+{
+ DBG_CTOR(OWizTypeSelect,NULL);
+ m_lbColumnNames.SetSelectHdl(LINK(this,OWizTypeSelect,ColumnSelectHdl));
+
+ ModuleRes aModuleRes(isHiContrast(&m_lbColumnNames) ? IMG_JOINS_H : IMG_JOINS);
+ ImageList aImageList(aModuleRes);
+ m_imgPKey = aImageList.GetImage(IMG_PRIMARY_KEY);
+
+ m_aTypeControl.Show();
+ m_aTypeControl.Init();
+ m_etAuto.SetText(String::CreateFromAscii("10"));
+ m_etAuto.SetDecimalDigits(0);
+ m_pbAuto.SetClickHdl(LINK(this,OWizTypeSelect,ButtonClickHdl));
+ m_lbColumnNames.EnableMultiSelection(sal_True);
+
+ try
+ {
+ m_lbColumnNames.SetPKey( m_pParent->supportsPrimaryKey() );
+ ::dbaui::fillAutoIncrementValue( m_pParent->m_xDestConnection, m_bAutoIncrementEnabled, m_sAutoIncrementValue );
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ FreeResource();
+}
+// -----------------------------------------------------------------------
+OWizTypeSelect::~OWizTypeSelect()
+{
+ DBG_DTOR(OWizTypeSelect,NULL);
+}
+// -----------------------------------------------------------------------------
+String OWizTypeSelect::GetTitle() const
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ return String(ModuleRes(STR_WIZ_TYPE_SELECT_TITEL));
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelect::Resize()
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OWizTypeSelect, ColumnSelectHdl, MultiListBox *, /*pListBox*/ )
+{
+ String aColumnName( m_lbColumnNames.GetSelectEntry() );
+
+ OFieldDescription* pField = static_cast<OFieldDescription*>(m_lbColumnNames.GetEntryData(m_lbColumnNames.GetEntryPos(aColumnName)));
+ if(pField)
+ m_aTypeControl.DisplayData(pField);
+
+ m_aTypeControl.Enable(m_lbColumnNames.GetSelectEntryCount() == 1 );
+ return 0;
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelect::Reset()
+{
+ // urspr"unglichen zustand wiederherstellen
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+
+ while(m_lbColumnNames.GetEntryCount())
+ m_lbColumnNames.RemoveEntry(0);
+ m_lbColumnNames.Clear();
+ sal_Int32 nBreakPos;
+ m_pParent->CheckColumns(nBreakPos);
+
+ const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector();
+ ODatabaseExport::TColumnVector::const_iterator aIter = pDestColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = pDestColumns->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ sal_uInt16 nPos;
+ if((*aIter)->second->IsPrimaryKey())
+ nPos = m_lbColumnNames.InsertEntry((*aIter)->first, m_imgPKey );
+ else
+ nPos = m_lbColumnNames.InsertEntry((*aIter)->first);
+ m_lbColumnNames.SetEntryData(nPos,(*aIter)->second);
+ }
+ m_bFirstTime = sal_False;
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelect::ActivatePage( )
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ sal_Bool bOldFirstTime = m_bFirstTime;
+ Reset();
+ m_bFirstTime = bOldFirstTime;
+
+ m_lbColumnNames.SelectEntryPos(static_cast<sal_uInt16>(m_nDisplayRow));
+ m_nDisplayRow = 0;
+ m_lbColumnNames.GetSelectHdl().Call(&m_lbColumnNames);
+}
+// -----------------------------------------------------------------------
+sal_Bool OWizTypeSelect::LeavePage()
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ String aColumnName( m_lbColumnNames.GetSelectEntry() );
+
+ sal_Bool bDuplicateName = sal_False;
+ OFieldDescription* pField = static_cast<OFieldDescription*>(m_lbColumnNames.GetEntryData(m_lbColumnNames.GetEntryPos(aColumnName)));
+ if ( pField )
+ {
+ m_aTypeControl.SaveData(pField);
+ bDuplicateName = m_bDuplicateName;
+ }
+ return !bDuplicateName;
+}
+//------------------------------------------------------------------------------
+void OWizTypeSelect::EnableAuto(sal_Bool bEnable)
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ m_ftAuto.Show(bEnable);
+ m_etAuto.Show(bEnable);
+ m_pbAuto.Show(bEnable);
+ m_flAutoType.Show(bEnable);
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OWizTypeSelect, ButtonClickHdl, Button *, /*pButton*/ )
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ sal_Int32 nBreakPos;
+ m_pParent->CheckColumns(nBreakPos);
+ fillColumnList(m_etAuto.GetText().ToInt32());
+
+ ActivatePage();
+
+ return 0;
+}
+//------------------------------------------------------------------------
+sal_Bool OWizTypeSelectList::IsPrimaryKeyAllowed() const
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ sal_uInt16 nCount = GetSelectEntryCount();
+ sal_uInt16 j;
+
+ for( j = 0; m_bPKey && j < nCount; ++j )
+ {
+ OFieldDescription* pField = static_cast<OFieldDescription*>(GetEntryData(GetSelectEntryPos(j)));
+ if(!pField || pField->getTypeInfo()->nSearchType == ColumnSearch::NONE)
+ break;
+ }
+ return j == nCount;
+}
+// -----------------------------------------------------------------------------
+void OWizTypeSelectList::setPrimaryKey(OFieldDescription* _pFieldDescr,sal_uInt16 _nPos,sal_Bool _bSet)
+{
+ String sColumnName = GetEntry(_nPos);
+ RemoveEntry(_nPos);
+ _pFieldDescr->SetPrimaryKey(_bSet);
+ if( _bSet )
+ InsertEntry(sColumnName,((OWizTypeSelect*)GetParent())->m_imgPKey,_nPos);
+ else if( _pFieldDescr->getTypeInfo()->bNullable )
+ {
+ _pFieldDescr->SetControlDefault(Any());
+ InsertEntry(sColumnName,_nPos);
+ }
+ SetEntryData(_nPos,_pFieldDescr);
+}
+//------------------------------------------------------------------------
+long OWizTypeSelectList::PreNotify( NotifyEvent& rEvt )
+{
+ long nDone = 0;
+ switch( rEvt.GetType() )
+ {
+ case EVENT_MOUSEBUTTONDOWN:
+ {
+ const MouseEvent* pMEvt = rEvt.GetMouseEvent();
+ if(pMEvt->IsRight() && !pMEvt->GetModifier())
+ nDone = 1;
+ }
+ break;
+ case EVENT_COMMAND:
+ {
+ if(!IsPrimaryKeyAllowed())
+ break;
+
+ const CommandEvent* pComEvt = rEvt.GetCommandEvent();
+ if(pComEvt->GetCommand() != COMMAND_CONTEXTMENU)
+ break;
+ // die Stelle, an der geklickt wurde
+ Point ptWhere(0,0);
+ if (pComEvt->IsMouseEvent())
+ ptWhere = pComEvt->GetMousePosPixel();
+
+ PopupMenu aContextMenu(ModuleRes(RID_SBA_RTF_PKEYPOPUP));
+ switch( aContextMenu.Execute( this, ptWhere ) )
+ {
+ case SID_TABLEDESIGN_TABED_PRIMARYKEY:
+ {
+ String sColumnName;
+ sal_uInt16 nCount = GetEntryCount();
+ for(sal_uInt16 j = 0 ; j < nCount ; ++j)
+ {
+ OFieldDescription* pFieldDescr = static_cast<OFieldDescription*>(GetEntryData(j));
+ if( pFieldDescr )
+ {
+ if(pFieldDescr->IsPrimaryKey() && !IsEntryPosSelected(j))
+ setPrimaryKey(pFieldDescr,j);
+ else if(IsEntryPosSelected(j))
+ {
+ setPrimaryKey(pFieldDescr,j,!pFieldDescr->IsPrimaryKey());
+ SelectEntryPos(j);
+ }
+ }
+ }
+ GetSelectHdl().Call(this);
+ }
+ break;
+ }
+ nDone = 1;
+ }
+ break;
+ }
+ return nDone ? nDone : MultiListBox::PreNotify(rEvt);
+}
+// -----------------------------------------------------------------------------
+void OWizTypeSelect::fillColumnList(sal_uInt32 nRows)
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ if(m_pParserStream)
+ {
+ sal_uInt32 nTell = m_pParserStream->Tell(); // verändert vielleicht die Position des Streams
+
+ SvParser *pReader = createReader(nRows);
+ if(pReader)
+ {
+ pReader->AddRef();
+ pReader->CallParser();
+ pReader->ReleaseRef();
+ }
+ m_pParserStream->Seek(nTell);
+ }
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/dbaccess/source/ui/misc/WizardPages.hrc b/dbaccess/source/ui/misc/WizardPages.hrc
new file mode 100644
index 000000000000..224071b529ec
--- /dev/null
+++ b/dbaccess/source/ui/misc/WizardPages.hrc
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#define DBAUI_WIZARD_PAGES_HRC
+
+
+#define LB_ORG_COLUMN_NAMES 1
+#define LB_NEW_COLUMN_NAMES 2
+
+#define IB_COLUMN_RH 1
+#define IB_COLUMN_LH 2
+#define IB_COLUMNS_RH 3
+#define IB_COLUMNS_LH 4
+#define PB_AUTO 5
+#define PB_OK 6
+#define PB_CANCEL 7
+#define PB_HELP 8
+#define PB_NEXT 9
+#define PB_PREV 10
+#define PB_UNDO 11
+#define IB_COLUMN_UP 12
+#define IB_COLUMN_DOWN 13
+#define IB_COLUMN_UP_RIGHT 14
+#define IB_COLUMN_DOWN_RIGHT 15
+#define PB_ALL 16
+#define PB_NONE 17
+
+#define ET_AUTO 1
+#define ET_TABLENAME 2
+#define ET_KEYNAME 3
+
+#define FT_AUTO 1
+#define FT_TABLE_LEFT 2
+#define FT_TABLE_RIGHT 3
+#define FT_TABLENAME 4
+#define FT_KEYNAME 5
+
+#define FL_COLUMN_SELECT 1
+#define FL_COLUMN_NAME 2
+#define FL_AUTO_TYPE 3
+#define FL_OPTIONS 5
+
+#define RB_DEFDATA 1
+#define RB_DEF 2
+#define RB_VIEW 3
+#define RB_APPENDDATA 4
+#define CB_PRIMARY_COLUMN 5
+#define CB_USEHEADERLINE 6
+
+#define CONTROL_CONTAINER 1
+// controls
+#define CTRL_LEFT 1
+#define CTRL_RIGHT 2
+
+#endif // DBAUI_WIZARD_PAGES_HRC
+
+
diff --git a/dbaccess/source/ui/misc/WizardPages.src b/dbaccess/source/ui/misc/WizardPages.src
new file mode 100644
index 000000000000..d9c9772d2a41
--- /dev/null
+++ b/dbaccess/source/ui/misc/WizardPages.src
@@ -0,0 +1,658 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#include "WizardPages.hrc"
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+#include "dbaccess_slotid.hrc"
+
+#define WINDOW_SIZE_X 276
+#define WINDOW_SIZE_Y 185
+
+#define WINDOW_BORDER_X 12
+#define WINDOW_BORDER_Y 14
+
+#define BUTTON_SIZE_X 50
+#define BUTTON_SIZE_Y 14
+
+String STR_WIZ_COLUMN_SELECT_TITEL
+{
+ Text [ en-US ] = "Apply columns";
+};
+
+String STR_WIZ_TYPE_SELECT_TITEL
+{
+ Text [ en-US ] = "Type formatting";
+};
+
+String STR_WIZ_PKEY_ALREADY_DEFINED
+{
+ Text [ en-US ] = "The following fields have already been set as primary keys:\n";
+};
+
+String STR_WIZ_NAME_MATCHING_TITEL
+{
+ Text [ en-US ] = "Assign columns" ;
+};
+
+ModalDialog WIZ_RTFCOPYTABLE
+{
+ HelpID = "dbaccess:ModalDialog:WIZ_RTFCOPYTABLE";
+
+ Text [ en-US ] = "Copy RTF Table" ;
+
+
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE;
+
+ HelpButton PB_HELP
+ {
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ Text [ en-US ] = "~Help";
+ };
+ CancelButton PB_CANCEL
+ {
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ Text [ en-US ] = "~Cancel";
+ };
+ PushButton PB_PREV
+ {
+ HelpID = "dbaccess:PushButton:WIZ_RTFCOPYTABLE:PB_PREV";
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ Text [ en-US ] = "< ~Back";
+ };
+ PushButton PB_NEXT
+ {
+ HelpID = "dbaccess:PushButton:WIZ_RTFCOPYTABLE:PB_NEXT";
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ Text [ en-US ] = "~Next>";
+ };
+ OKButton PB_OK
+ {
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ Text [ en-US ] = "C~reate";
+ };
+
+};
+
+//==================================================================
+ // TAB_WIZ_COLUMN_SELECT
+ //==================================================================
+TabPage TAB_WIZ_COLUMN_SELECT
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ HelpId = HID_TAB_WIZ_COLUMN_SELECT;
+ Hide = TRUE;
+
+ FixedLine FL_COLUMN_SELECT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 12 , 8 ) ;
+ Text [ en-US ] = "Existing columns" ;
+ };
+
+ MultiListBox LB_ORG_COLUMN_NAMES
+ {
+ HelpID = "dbaccess:MultiListBox:TAB_WIZ_COLUMN_SELECT:LB_ORG_COLUMN_NAMES";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X , WINDOW_BORDER_Y ) ;
+ Size = MAP_APPFONT ( 95 , WINDOW_SIZE_Y - 23 ) ;
+ TabStop = TRUE ;
+ HScroll = TRUE;
+ VScroll = TRUE;
+ AutoHScroll = TRUE;
+ SimpleMode = TRUE;
+ Sort = FALSE;
+ };
+ ImageButton IB_COLUMN_RH
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_COLUMN_SELECT:IB_COLUMN_RH";
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X + 116 , WINDOW_BORDER_Y + 25 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "one_right.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+ ImageButton IB_COLUMNS_RH
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_COLUMN_SELECT:IB_COLUMNS_RH";
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X + 116 , WINDOW_BORDER_Y + 45 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE;
+ DefButton = TRUE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "all_right.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+ ImageButton IB_COLUMN_LH
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_COLUMN_SELECT:IB_COLUMN_LH";
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X + 116 , WINDOW_BORDER_Y + 65) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "one_left.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+ ImageButton IB_COLUMNS_LH
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_COLUMN_SELECT:IB_COLUMNS_LH";
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X + 116 , WINDOW_BORDER_Y + 85) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "all_left.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+
+ MultiListBox LB_NEW_COLUMN_NAMES
+ {
+ HelpID = "dbaccess:MultiListBox:TAB_WIZ_COLUMN_SELECT:LB_NEW_COLUMN_NAMES";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X + 157, WINDOW_BORDER_Y) ;
+ Size = MAP_APPFONT ( 95 , WINDOW_SIZE_Y - 23 ) ;
+ TabStop = TRUE ;
+ HScroll = TRUE;
+ VScroll = TRUE;
+ AutoHScroll = TRUE;
+ SimpleMode = TRUE;
+ Sort = FALSE;
+ };
+};
+
+//==================================================================
+ // TAB_WIZ_TYPE_SELECT
+ //==================================================================
+TabPage TAB_WIZ_TYPE_SELECT
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ HelpId = HID_TAB_WIZ_TYPE_SELECT;
+ Hide = TRUE;
+
+ MultiListBox LB_NEW_COLUMN_NAMES
+ {
+ HelpID = "dbaccess:MultiListBox:TAB_WIZ_TYPE_SELECT:LB_NEW_COLUMN_NAMES";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 87 , WINDOW_SIZE_Y - 12 ) ;
+ TabStop = TRUE ;
+ HScroll = TRUE;
+ VScroll = TRUE;
+ AutoHScroll = TRUE;
+ SimpleMode = TRUE;
+ };
+
+ FixedLine FL_COLUMN_NAME
+ {
+ Pos = MAP_APPFONT ( 99 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 105, 8 ) ;
+ Text [ en-US ] = "Column information" ;
+ };
+
+ TabPage CONTROL_CONTAINER
+ {
+ HelpID = "dbaccess:TabPage:CONTROL_CONTAINER";
+ Pos = MAP_APPFONT ( 102 , WINDOW_BORDER_Y ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 111, WINDOW_SIZE_Y - WINDOW_BORDER_Y - 67 );
+ SVLook = TRUE;
+ DialogControl = TRUE;
+ };
+
+ FixedLine FL_AUTO_TYPE
+ {
+ Pos = MAP_APPFONT ( 99 , WINDOW_SIZE_Y - WINDOW_BORDER_Y - 41 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 105, 8 ) ;
+ Text [ en-US ] = "Automatic type recognition" ;
+ };
+
+ FixedText FT_AUTO
+ {
+ Pos = MAP_APPFONT ( 105 , WINDOW_SIZE_Y - WINDOW_BORDER_Y - 28 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "Lines (ma~x)";
+ };
+
+ NumericField ET_AUTO
+ {
+ HelpID = "dbaccess:NumericField:TAB_WIZ_TYPE_SELECT:ET_AUTO";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 151 , WINDOW_SIZE_Y - WINDOW_BORDER_Y - 29) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ };
+
+ PushButton PB_AUTO
+ {
+ HelpID = "dbaccess:PushButton:TAB_WIZ_TYPE_SELECT:PB_AUTO";
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X - 62 , WINDOW_SIZE_Y - WINDOW_BORDER_Y - 30 ) ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ TabStop = TRUE ;
+ Text = "~Auto" ;
+ };
+};
+
+Menu RID_SBA_RTF_PKEYPOPUP
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_TABLEDESIGN_TABED_PRIMARYKEY ;
+ HelpID = HID_TABLEDESIGN_TABED_PRIMARYKEY ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Primary Key" ;
+ };
+ };
+};
+//==================================================================
+ // TAB_WIZ_NAME_MATCHING
+ //==================================================================
+TabPage TAB_WIZ_NAME_MATCHING
+{
+ HelpID = "dbaccess:TabPage:TAB_WIZ_NAME_MATCHING";
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ Hide = TRUE;
+
+ FixedText FT_TABLE_LEFT
+ {
+ Pos = MAP_APPFONT ( 52 , 6 ) ;
+ Size = MAP_APPFONT ( 75 , 20) ;
+ Text [ en-US ] = "Source table: \n";
+ };
+
+ FixedText FT_TABLE_RIGHT
+ {
+ Pos = MAP_APPFONT ( 144, 6 ) ;
+ Size = MAP_APPFONT ( 75 , 20) ;
+ Text [ en-US ] = "Destination table: \n";
+ };
+
+ Control CTRL_LEFT
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT ( 52, 28) ;
+ Size = MAP_APPFONT ( 82 , WINDOW_SIZE_Y - 34 ) ;
+ TabStop = TRUE;
+ HelpId = HID_TAB_NAMEMATCHING_COLS_AVAIL;
+ /*DialogControl = TRUE;*/
+ };
+
+ Control CTRL_RIGHT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 144, 28) ;
+ Size = MAP_APPFONT ( 82 , WINDOW_SIZE_Y - 34 ) ;
+ TabStop = TRUE;
+ HelpId = HID_TAB_NAMEMATCHING_COLS_ASSIGN;
+ /*DialogControl = TRUE;*/
+ };
+
+ ImageButton IB_COLUMN_UP
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_NAME_MATCHING:IB_COLUMN_UP";
+ Pos = MAP_APPFONT ( 19 , 45 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE;
+ DefButton = TRUE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "sortup.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_COLUMN_DOWN
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_NAME_MATCHING:IB_COLUMN_DOWN";
+ Pos = MAP_APPFONT ( 19 , 63 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "sortdown.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_COLUMN_UP_RIGHT
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_NAME_MATCHING:IB_COLUMN_UP_RIGHT";
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X - 33, 45 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE;
+ DefButton = TRUE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "sortup.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_COLUMN_DOWN_RIGHT
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_NAME_MATCHING:IB_COLUMN_DOWN_RIGHT";
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X - 33, 63) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "sortdown.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+
+ PushButton PB_ALL
+ {
+ HelpID = "dbaccess:PushButton:TAB_WIZ_NAME_MATCHING:PB_ALL";
+ Pos = MAP_APPFONT ( 6, 83) ;
+ Size = MAP_APPFONT ( 40 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~All" ;
+ };
+
+ PushButton PB_NONE
+ {
+ HelpID = "dbaccess:PushButton:TAB_WIZ_NAME_MATCHING:PB_NONE";
+ Pos = MAP_APPFONT ( 6, 103) ;
+ Size = MAP_APPFONT ( 40 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Non~e" ;
+ };
+};
+TabPage TAB_WIZ_COPYTABLE
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X, WINDOW_SIZE_Y ) ;
+
+ HelpId = HID_TAB_WIZ_COPYTABLE;
+ Hide = TRUE;
+
+ FixedText FT_TABLENAME
+ {
+ Pos = MAP_APPFONT ( 12 , 11) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Ta~ble name";
+ };
+
+ Edit ET_TABLENAME
+ {
+ HelpId = HID_TAB_WIZ_TABLENAME_EDIT;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 9) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 92 , 12 ) ;
+ TabStop = TRUE ;
+ };
+
+ FixedLine FL_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 24 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 12 , 8 ) ;
+ Text [ en-US ] = "Options" ;
+ };
+ RadioButton RB_DEFDATA
+ {
+ HelpID = "dbaccess:RadioButton:TAB_WIZ_COPYTABLE:RB_DEFDATA";
+ Pos = MAP_APPFONT ( 12 , 35 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "De~finition and data" ;
+ };
+ RadioButton RB_DEF
+ {
+ HelpID = "dbaccess:RadioButton:TAB_WIZ_COPYTABLE:RB_DEF";
+ Pos = MAP_APPFONT ( 12, 49 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "Def~inition" ;
+ };
+
+ RadioButton RB_VIEW
+ {
+ HelpID = "dbaccess:RadioButton:TAB_WIZ_COPYTABLE:RB_VIEW";
+ Pos = MAP_APPFONT ( 12, 63 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "A~s table view";
+ };
+
+ RadioButton RB_APPENDDATA
+ {
+ HelpID = "dbaccess:RadioButton:TAB_WIZ_COPYTABLE:RB_APPENDDATA";
+ Pos = MAP_APPFONT ( 12, 77 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "Append ~data" ;
+ };
+
+ CheckBox CB_USEHEADERLINE
+ {
+ HelpID = "dbaccess:CheckBox:TAB_WIZ_COPYTABLE:CB_USEHEADERLINE";
+ Pos = MAP_APPFONT ( 12, 93 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 18, 10 ) ;
+ Text [ en-US ] = "Use first ~line as column names" ;
+ };
+
+ CheckBox CB_PRIMARY_COLUMN
+ {
+ HelpID = "dbaccess:CheckBox:TAB_WIZ_COPYTABLE:CB_PRIMARY_COLUMN";
+ Pos = MAP_APPFONT ( 12, 107 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+ Text [ en-US ] = "Crea~te primary key";
+ };
+ FixedText FT_KEYNAME
+ {
+ Pos = MAP_APPFONT ( 21 , 122 ) ;
+ Size = MAP_APPFONT ( 39 , 8 ) ;
+ Text [ en-US ] = "Name";
+ };
+
+ Edit ET_KEYNAME
+ {
+ HelpID = "dbaccess:Edit:TAB_WIZ_COPYTABLE:ET_KEYNAME";
+ Pos = MAP_APPFONT ( 80, 120 ) ;
+ Size = MAP_APPFONT ( 65 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+};
+
+String STR_WIZ_TABLE_COPY
+{
+ Text [ en-US ] = "Copy table" ;
+};
+
+String STR_COPYTABLE_TITLE_COPY
+{
+ Text [ en-US ] = "Copy table" ;
+};
+
+String STR_INVALID_TABLE_NAME
+{
+ Text [ en-US ] = "This table name is not valid in the current database.";
+};
+String STR_SUGGEST_APPEND_TABLE_DATA
+{
+ Text [ en-US ] = "Choose the option 'Append data' on the first page to append data to an existing table.";
+};
+
+String STR_INVALID_TABLE_NAME_LENGTH
+{
+ Text [ en-US ] = "Please change the table name. It is too long.";
+};
+
+Image IMG_SORTUP_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "sortup_h.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+};
+
+Image IMG_SORTDOWN_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "sortdown_h.bmp" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dbaccess/source/ui/misc/asyncmodaldialog.cxx b/dbaccess/source/ui/misc/asyncmodaldialog.cxx
new file mode 100644
index 000000000000..d7a66c71d33e
--- /dev/null
+++ b/dbaccess/source/ui/misc/asyncmodaldialog.cxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_ASYNCMODALDIALOG_HXX
+#include "asyncmodaldialog.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::ui::dialogs::XExecutableDialog;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::Exception;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= AsyncDialogExecutor
+ //====================================================================
+ class DialogExecutor_Impl
+ {
+ Reference< XExecutableDialog > m_xDialog;
+
+ public:
+ DialogExecutor_Impl( const Reference< XExecutableDialog >& _rxDialog )
+ :m_xDialog( _rxDialog )
+ {
+ }
+
+ void execute()
+ {
+ Application::PostUserEvent( LINK( this, DialogExecutor_Impl, onExecute ) );
+ }
+
+ protected:
+ ~DialogExecutor_Impl()
+ {
+ }
+
+ private:
+ DECL_LINK( onExecute, void* );
+ };
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( DialogExecutor_Impl, onExecute, void*, /* _notInterestedIn */ )
+ {
+ try
+ {
+ m_xDialog->execute();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ delete this;
+ return 0L;
+ }
+
+ //====================================================================
+ //= AsyncDialogExecutor
+ //====================================================================
+ //--------------------------------------------------------------------
+ void AsyncDialogExecutor::executeModalDialogAsync( const Reference< XExecutableDialog >& _rxDialog )
+ {
+ if ( !_rxDialog.is() )
+ throw IllegalArgumentException();
+
+
+ DialogExecutor_Impl* pExecutor = new DialogExecutor_Impl( _rxDialog );
+ pExecutor->execute();
+ // will delete itself
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/charsets.cxx b/dbaccess/source/ui/misc/charsets.cxx
new file mode 100644
index 000000000000..79cf5ff1b1d2
--- /dev/null
+++ b/dbaccess/source/ui/misc/charsets.cxx
@@ -0,0 +1,196 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_CHARSETS_HXX_
+#include "charsets.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef _RTL_TENCINFO_H
+#include <rtl/tencinfo.h>
+#endif
+#ifndef _TOOLS_RCID_H
+#include <tools/rcid.h>
+#endif
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#include "localresaccess.hxx"
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ using namespace ::dbtools;
+
+ //=========================================================================
+ //= OCharsetDisplay
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::OCharsetDisplay()
+ :OCharsetMap()
+ ,SvxTextEncodingTable()
+ {
+ {
+ LocalResourceAccess aCharsetStrings( RSC_CHARSETS, RSC_RESOURCE );
+ m_aSystemDisplayName = String( ModuleRes( 1 ) );
+ }
+ }
+
+ //-------------------------------------------------------------------------
+ sal_Bool OCharsetDisplay::approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const
+ {
+ if ( !OCharsetMap::approveEncoding( _eEncoding, _rInfo ) )
+ return sal_False;
+
+ if ( RTL_TEXTENCODING_DONTKNOW == _eEncoding )
+ return sal_True;
+
+ return 0 != GetTextString( _eEncoding ).Len();
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::const_iterator OCharsetDisplay::begin() const
+ {
+ return const_iterator( this, OCharsetMap::begin() );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::const_iterator OCharsetDisplay::end() const
+ {
+ return const_iterator( this, OCharsetMap::end() );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::const_iterator OCharsetDisplay::findEncoding(const rtl_TextEncoding _eEncoding) const
+ {
+ OCharsetMap::const_iterator aBaseIter = OCharsetMap::find(_eEncoding);
+ return const_iterator( this, aBaseIter );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::const_iterator OCharsetDisplay::findIanaName(const ::rtl::OUString& _rIanaName) const
+ {
+ OCharsetMap::const_iterator aBaseIter = OCharsetMap::find(_rIanaName, OCharsetMap::IANA());
+ return const_iterator( this, aBaseIter );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::const_iterator OCharsetDisplay::findDisplayName(const ::rtl::OUString& _rDisplayName) const
+ {
+ rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW;
+ if ( _rDisplayName != m_aSystemDisplayName )
+ {
+ eEncoding = GetTextEncoding( _rDisplayName );
+ OSL_ENSURE( RTL_TEXTENCODING_DONTKNOW != eEncoding,
+ "OCharsetDisplay::find: non-empty display name, but DONTKNOW!" );
+ }
+ return const_iterator( this, OCharsetMap::find( eEncoding ) );
+ }
+
+ //=========================================================================
+ //= CharsetDisplayDerefHelper
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ CharsetDisplayDerefHelper::CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper& _rSource)
+ :CharsetDisplayDerefHelper_Base(_rSource)
+ ,m_sDisplayName(m_sDisplayName)
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ CharsetDisplayDerefHelper::CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper_Base& _rBase, const ::rtl::OUString& _rDisplayName)
+ :CharsetDisplayDerefHelper_Base(_rBase)
+ ,m_sDisplayName(_rDisplayName)
+ {
+ DBG_ASSERT( m_sDisplayName.getLength(), "CharsetDisplayDerefHelper::CharsetDisplayDerefHelper: invalid display name!" );
+ }
+
+ //=========================================================================
+ //= OCharsetDisplay::ExtendedCharsetIterator
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator( const OCharsetDisplay* _pContainer, const base_iterator& _rPosition )
+ :m_pContainer(_pContainer)
+ ,m_aPosition(_rPosition)
+ {
+ DBG_ASSERT(m_pContainer, "OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator : invalid container!");
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator(const ExtendedCharsetIterator& _rSource)
+ :m_pContainer( _rSource.m_pContainer )
+ ,m_aPosition( _rSource.m_aPosition )
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ CharsetDisplayDerefHelper OCharsetDisplay::ExtendedCharsetIterator::operator*() const
+ {
+ DBG_ASSERT( m_aPosition != m_pContainer->OCharsetDisplay_Base::end(), "OCharsetDisplay::ExtendedCharsetIterator::operator* : invalid position!");
+
+ rtl_TextEncoding eEncoding = (*m_aPosition).getEncoding();
+ return CharsetDisplayDerefHelper(
+ *m_aPosition,
+ RTL_TEXTENCODING_DONTKNOW == eEncoding ? m_pContainer->m_aSystemDisplayName : (::rtl::OUString)m_pContainer->GetTextString( eEncoding )
+ );
+ }
+
+ //-------------------------------------------------------------------------
+ const OCharsetDisplay::ExtendedCharsetIterator& OCharsetDisplay::ExtendedCharsetIterator::operator++()
+ {
+ DBG_ASSERT( m_aPosition != m_pContainer->OCharsetDisplay_Base::end(), "OCharsetDisplay::ExtendedCharsetIterator::operator++ : invalid position!");
+ if ( m_aPosition != m_pContainer->OCharsetDisplay_Base::end() )
+ ++m_aPosition;
+ return *this;
+ }
+
+ //-------------------------------------------------------------------------
+ const OCharsetDisplay::ExtendedCharsetIterator& OCharsetDisplay::ExtendedCharsetIterator::operator--()
+ {
+ DBG_ASSERT( m_aPosition != m_pContainer->OCharsetDisplay_Base::begin(), "OCharsetDisplay::ExtendedCharsetIterator::operator-- : invalid position!");
+ if ( m_aPosition != m_pContainer->OCharsetDisplay_Base::begin() )
+ --m_aPosition;
+ return *this;
+ }
+
+ //-------------------------------------------------------------------------
+ bool operator==(const OCharsetDisplay::ExtendedCharsetIterator& lhs, const OCharsetDisplay::ExtendedCharsetIterator& rhs)
+ {
+ return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_aPosition == rhs.m_aPosition);
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/misc/controllerframe.cxx b/dbaccess/source/ui/misc/controllerframe.cxx
new file mode 100644
index 000000000000..7bba70667b8c
--- /dev/null
+++ b/dbaccess/source/ui/misc/controllerframe.cxx
@@ -0,0 +1,443 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "controllerframe.hxx"
+#include "IController.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/awt/XTopWindow.hpp>
+#include <com/sun/star/awt/XWindow2.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
+#include <com/sun/star/frame/XController2.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ref.hxx>
+#include <sfx2/objsh.hxx>
+#include <tools/diagnose_ex.h>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/window.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::frame::FrameAction;
+ using ::com::sun::star::frame::FrameAction_FRAME_ACTIVATED;
+ using ::com::sun::star::frame::FrameAction_FRAME_UI_ACTIVATED;
+ using ::com::sun::star::frame::FrameAction_FRAME_DEACTIVATING;
+ using ::com::sun::star::frame::FrameAction_FRAME_UI_DEACTIVATING;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::frame::XController2;
+ using ::com::sun::star::frame::XFramesSupplier;
+ using ::com::sun::star::sdb::XOfficeDatabaseDocument;
+ using ::com::sun::star::awt::XTopWindow;
+ using ::com::sun::star::awt::XTopWindowListener;
+ using ::com::sun::star::awt::XWindow2;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::document::XDocumentEventBroadcaster;
+ using ::com::sun::star::awt::XWindow;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= FrameWindowActivationListener
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < XTopWindowListener
+ > FrameWindowActivationListener_Base;
+ class FrameWindowActivationListener : public FrameWindowActivationListener_Base
+ {
+ public:
+ FrameWindowActivationListener( ControllerFrame_Data& _rData );
+
+ void dispose();
+
+ protected:
+ ~FrameWindowActivationListener();
+
+ // XTopWindowListener
+ virtual void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ void impl_checkDisposed_throw() const;
+ void impl_registerOnFrameContainerWindow_nothrow( bool _bRegister );
+
+ private:
+ ControllerFrame_Data* m_pData;
+ };
+
+ //====================================================================
+ //= ControllerFrame_Data
+ //====================================================================
+ struct ControllerFrame_Data
+ {
+ ControllerFrame_Data( IController& _rController )
+ :m_rController( _rController )
+ ,m_xFrame()
+ ,m_xDocEventBroadcaster()
+ ,m_pListener()
+ ,m_bActive( false )
+ ,m_bIsTopLevelDocumentWindow( false )
+ {
+ }
+
+ IController& m_rController;
+ Reference< XFrame > m_xFrame;
+ Reference< XDocumentEventBroadcaster > m_xDocEventBroadcaster;
+ ::rtl::Reference< FrameWindowActivationListener > m_pListener;
+ bool m_bActive;
+ bool m_bIsTopLevelDocumentWindow;
+ };
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ //--------------------------------------------------------------------
+ static void lcl_setFrame_nothrow( ControllerFrame_Data& _rData, const Reference< XFrame >& _rxFrame )
+ {
+ // release old listener
+ if ( _rData.m_pListener.get() )
+ {
+ _rData.m_pListener->dispose();
+ _rData.m_pListener = NULL;
+ }
+
+ // remember new frame
+ _rData.m_xFrame = _rxFrame;
+
+ // create new listener
+ if ( _rData.m_xFrame.is() )
+ _rData.m_pListener = new FrameWindowActivationListener( _rData );
+
+ // at this point in time, we can assume the controller also has a model set, if it supports models
+ try
+ {
+ Reference< XController > xController( _rData.m_rController.getXController(), UNO_SET_THROW );
+ Reference< XModel > xModel( xController->getModel() );
+ if ( xModel.is() )
+ _rData.m_xDocEventBroadcaster.set( xModel, UNO_QUERY );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ static bool lcl_isActive_nothrow( const Reference< XFrame >& _rxFrame )
+ {
+ bool bIsActive = false;
+ try
+ {
+ if ( _rxFrame.is() )
+ {
+ Reference< XWindow2 > xWindow( _rxFrame->getContainerWindow(), UNO_QUERY_THROW );
+ bIsActive = xWindow->isActive();
+ }
+
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bIsActive;
+ }
+
+ //--------------------------------------------------------------------
+ /** updates various global and local states with a new active component
+
+ In particular, the following are updated
+ * the global working document (aka Basic's ThisComponent in the application
+ Basic), with our controller's model, or the controller itself if there is no such
+ model.
+ */
+ static void lcl_updateActiveComponents_nothrow( const ControllerFrame_Data& _rData )
+ {
+ try
+ {
+ Reference< XController > xCompController( _rData.m_rController.getXController() );
+ OSL_ENSURE( xCompController.is(), "lcl_updateActiveComponents_nothrow: can't do anything without a controller!" );
+ if ( !xCompController.is() )
+ return;
+
+ if ( _rData.m_bActive && _rData.m_bIsTopLevelDocumentWindow )
+ {
+ // set the "current component" at the SfxObjectShell
+ Reference< XModel > xModel( xCompController->getModel() );
+ Reference< XInterface > xCurrentComponent;
+ if ( xModel.is() )
+ xCurrentComponent = xModel;
+ else
+ xCurrentComponent = xCompController;
+ SfxObjectShell::SetCurrentComponent( xCurrentComponent );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ /** broadcasts the OnFocus resp. OnUnfocus event
+ */
+ static void lcl_notifyFocusChange_nothrow( ControllerFrame_Data& _rData, bool _bActive )
+ {
+ try
+ {
+ if ( _rData.m_xDocEventBroadcaster.is() )
+ {
+ ::rtl::OUString sEventName( ::rtl::OUString::createFromAscii( _bActive ? "OnFocus" : "OnUnfocus" ) );
+ Reference< XController2 > xController( _rData.m_rController.getXController(), UNO_QUERY_THROW );
+ _rData.m_xDocEventBroadcaster->notifyDocumentEvent( sEventName, xController, Any() );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ static void lcl_updateActive_nothrow( ControllerFrame_Data& _rData, bool _bActive )
+ {
+ if ( _rData.m_bActive == _bActive )
+ return;
+ _rData.m_bActive = _bActive;
+
+ lcl_updateActiveComponents_nothrow( _rData );
+ lcl_notifyFocusChange_nothrow( _rData, _bActive );
+ }
+
+ //--------------------------------------------------------------------
+ FrameWindowActivationListener::FrameWindowActivationListener( ControllerFrame_Data& _rData )
+ :m_pData( &_rData )
+ {
+ impl_registerOnFrameContainerWindow_nothrow( true );
+ }
+
+ //--------------------------------------------------------------------
+ FrameWindowActivationListener::~FrameWindowActivationListener()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void FrameWindowActivationListener::dispose()
+ {
+ impl_registerOnFrameContainerWindow_nothrow( false );
+ m_pData = NULL;
+ }
+
+ //--------------------------------------------------------------------
+ void FrameWindowActivationListener::impl_registerOnFrameContainerWindow_nothrow( bool _bRegister )
+ {
+ OSL_ENSURE( m_pData && m_pData->m_xFrame.is(), "FrameWindowActivationListener::impl_registerOnFrameContainerWindow_nothrow: no frame!" );
+ if ( !m_pData || !m_pData->m_xFrame.is() )
+ return;
+
+ try
+ {
+ void ( SAL_CALL XTopWindow::*pListenerAction )( const Reference< XTopWindowListener >& ) =
+ _bRegister ? &XTopWindow::addTopWindowListener : &XTopWindow::removeTopWindowListener;
+
+ const Reference< XWindow > xContainerWindow( m_pData->m_xFrame->getContainerWindow(), UNO_SET_THROW );
+ if ( _bRegister )
+ {
+ const Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
+ ENSURE_OR_THROW( pContainerWindow, "no Window implementation for the frame's container window!" );
+
+ /*const Window* pContainerParentWindow = pContainerWindow->GetParent();
+ if ( pContainerParentWindow && ( pContainerParentWindow->GetType() == WINDOW_BORDERWINDOW ) )
+ pContainerParentWindow = pContainerParentWindow->GetParent();
+ m_pData->m_bIsTopLevelDocumentWindow = ( pContainerParentWindow == NULL );*/
+
+ m_pData->m_bIsTopLevelDocumentWindow = ( pContainerWindow->GetExtendedStyle() & WB_EXT_DOCUMENT ) != 0;
+ }
+
+ const Reference< XTopWindow > xFrameContainer( xContainerWindow, UNO_QUERY );
+ if ( xFrameContainer.is() )
+ (xFrameContainer.get()->*pListenerAction)( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void FrameWindowActivationListener::impl_checkDisposed_throw() const
+ {
+ if ( !m_pData )
+ throw DisposedException( ::rtl::OUString(), *const_cast< FrameWindowActivationListener* >( this ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowOpened( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowClosing( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowClosed( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowMinimized( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowNormalized( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowActivated( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ impl_checkDisposed_throw();
+ lcl_updateActive_nothrow( *m_pData, true );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowDeactivated( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ impl_checkDisposed_throw();
+ lcl_updateActive_nothrow( *m_pData, false );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::disposing( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ dispose();
+ }
+
+ //====================================================================
+ //= ControllerFrame
+ //====================================================================
+ //--------------------------------------------------------------------
+ ControllerFrame::ControllerFrame( IController& _rController )
+ :m_pData( new ControllerFrame_Data( _rController ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ControllerFrame::~ControllerFrame()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ const Reference< XFrame >& ControllerFrame::attachFrame( const Reference< XFrame >& _rxFrame )
+ {
+ // set new frame, including listener handling
+ lcl_setFrame_nothrow( *m_pData, _rxFrame );
+
+ // determine whether we're active
+ m_pData->m_bActive = lcl_isActive_nothrow( m_pData->m_xFrame );
+
+ // update active component
+ if ( m_pData->m_bActive )
+ {
+ lcl_updateActiveComponents_nothrow( *m_pData );
+ lcl_notifyFocusChange_nothrow( *m_pData, true );
+ }
+
+ return m_pData->m_xFrame;
+ }
+
+ //--------------------------------------------------------------------
+ const Reference< XFrame >& ControllerFrame::getFrame() const
+ {
+ return m_pData->m_xFrame;
+ }
+
+ //--------------------------------------------------------------------
+ bool ControllerFrame::isActive() const
+ {
+ return m_pData->m_bActive;
+ }
+
+ //--------------------------------------------------------------------
+ void ControllerFrame::frameAction( FrameAction _eAction )
+ {
+ bool bActive = m_pData->m_bActive;
+
+ switch ( _eAction )
+ {
+ case FrameAction_FRAME_ACTIVATED:
+ case FrameAction_FRAME_UI_ACTIVATED:
+ bActive = true;
+ break;
+
+ case FrameAction_FRAME_DEACTIVATING:
+ case FrameAction_FRAME_UI_DEACTIVATING:
+ bActive = false;
+ break;
+
+ default:
+ break;
+ }
+
+ lcl_updateActive_nothrow( *m_pData, bActive );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
diff --git a/dbaccess/source/ui/misc/databaseobjectview.cxx b/dbaccess/source/ui/misc/databaseobjectview.cxx
new file mode 100644
index 000000000000..68f702b11d75
--- /dev/null
+++ b/dbaccess/source/ui/misc/databaseobjectview.cxx
@@ -0,0 +1,344 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "databaseobjectview.hxx"
+#include "dbustrings.hrc"
+#include "asyncmodaldialog.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XFrames.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/application/XTableUIProvider.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/sequence.hxx>
+#include <connectivity/dbtools.hxx>
+#include <osl/diagnose.h>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/window.hxx>
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdb::application;
+ using namespace ::com::sun::star::ui::dialogs;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::awt;
+
+ //======================================================================
+ //= DatabaseObjectView
+ //======================================================================
+ DatabaseObjectView::DatabaseObjectView( const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XDatabaseDocumentUI >& _rxApplication,
+ const Reference< XFrame >& _rxParentFrame,
+ const ::rtl::OUString& _rComponentURL )
+ :m_xORB ( _rxORB )
+ ,m_xParentFrame ( _rxParentFrame )
+ ,m_xFrameLoader ( )
+ ,m_xApplication ( _rxApplication )
+ ,m_sComponentURL ( _rComponentURL )
+ {
+ OSL_ENSURE( m_xORB.is(), "DatabaseObjectView::DatabaseObjectView: invalid service factory!" );
+ OSL_ENSURE( m_xApplication.is(), "DatabaseObjectView::DatabaseObjectView: invalid connection!" );
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XConnection > DatabaseObjectView::getConnection() const
+ {
+ Reference< XConnection > xConnection;
+ if ( m_xApplication.is() )
+ xConnection = m_xApplication->getActiveConnection();
+ return xConnection;
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XComponent > DatabaseObjectView::createNew( const Reference< XDataSource >& _xDataSource, const ::comphelper::NamedValueCollection& i_rDispatchArgs )
+ {
+ return doCreateView( makeAny( _xDataSource ), ::rtl::OUString(), i_rDispatchArgs );
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XComponent > DatabaseObjectView::openExisting( const Any& _rDataSource, const ::rtl::OUString& _rName,
+ const ::comphelper::NamedValueCollection& i_rDispatchArgs )
+ {
+ return doCreateView( _rDataSource, _rName, i_rDispatchArgs );
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XComponent > DatabaseObjectView::doCreateView( const Any& _rDataSource, const ::rtl::OUString& _rObjectName,
+ const ::comphelper::NamedValueCollection& i_rCreationArgs )
+ {
+ ::comphelper::NamedValueCollection aDispatchArgs;
+
+ aDispatchArgs.merge( i_rCreationArgs, false ); // false => do not overwrite
+ fillDispatchArgs( aDispatchArgs, _rDataSource, _rObjectName );
+ aDispatchArgs.merge( i_rCreationArgs, true ); // true => do overwrite
+
+ return doDispatch( aDispatchArgs );
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XComponent > DatabaseObjectView::doDispatch( const ::comphelper::NamedValueCollection& i_rDispatchArgs )
+ {
+ Reference< XComponent > xReturn;
+ if ( m_xORB.is() )
+ {
+ try
+ {
+ // if we have no externally provided frame, create one
+ if ( !m_xFrameLoader.is() )
+ {
+ Reference< XSingleServiceFactory > xFact(m_xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.TaskCreator")), UNO_QUERY_THROW);
+ Sequence< Any > lArgs(2);
+ NamedValue aProp;
+ sal_Int32 nArg = 0;
+
+ aProp.Name = ::rtl::OUString::createFromAscii("ParentFrame");
+ aProp.Value <<= m_xParentFrame;
+ lArgs[nArg++] <<= aProp;
+
+ aProp.Name = ::rtl::OUString::createFromAscii("TopWindow");
+ aProp.Value <<= sal_True;
+ lArgs[nArg++] <<= aProp;
+
+ m_xFrameLoader.set(xFact->createInstanceWithArguments(lArgs), UNO_QUERY_THROW);
+
+ // everything we load can be considered a "top level document", so set the respective bit at the window.
+ // This, amongst other things, triggers that the component in this task participates in the
+ // "ThisComponent"-game for the global application Basic.
+ const Reference< XFrame > xFrame( m_xFrameLoader, UNO_QUERY_THROW );
+ const Reference< XWindow > xFrameWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
+ Window* pContainerWindow = VCLUnoHelper::GetWindow( xFrameWindow );
+ ENSURE_OR_THROW( pContainerWindow, "no implementation access to the frame's container window!" );
+ pContainerWindow->SetExtendedStyle( pContainerWindow->GetExtendedStyle() | WB_EXT_DOCUMENT );
+ }
+
+ Reference< XComponentLoader > xFrameLoader( m_xFrameLoader, UNO_QUERY_THROW );
+ xReturn = xFrameLoader->loadComponentFromURL(
+ m_sComponentURL,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_self")),
+ 0,
+ i_rDispatchArgs.getPropertyValues()
+ );
+
+ if ( !xReturn.is() )
+ xReturn.set( m_xFrameLoader, UNO_QUERY );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return xReturn;
+ }
+
+ //----------------------------------------------------------------------
+ void DatabaseObjectView::fillDispatchArgs(
+ ::comphelper::NamedValueCollection& i_rDispatchArgs,
+ const Any& _aDataSource,
+ const ::rtl::OUString& /* _rName */
+ )
+ {
+ ::rtl::OUString sDataSource;
+ Reference<XDataSource> xDataSource;
+ if ( _aDataSource >>= sDataSource )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_DATASOURCENAME, sDataSource );
+ }
+ else if ( _aDataSource >>= xDataSource )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_DATASOURCE, xDataSource );
+ }
+
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, getConnection() );
+ }
+
+ //======================================================================
+ //= QueryDesigner
+ //======================================================================
+ //----------------------------------------------------------------------
+ QueryDesigner::QueryDesigner( const Reference< XMultiServiceFactory >& _rxORB, const Reference< XDatabaseDocumentUI >& _rxApplication,
+ const Reference< XFrame >& _rxParentFrame, bool _bCreateView )
+ :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame, _bCreateView ? URL_COMPONENT_VIEWDESIGN : URL_COMPONENT_QUERYDESIGN )
+ ,m_nCommandType( _bCreateView ? CommandType::TABLE : CommandType::QUERY )
+ {
+ }
+
+ //----------------------------------------------------------------------
+ void QueryDesigner::fillDispatchArgs( ::comphelper::NamedValueCollection& i_rDispatchArgs, const Any& _aDataSource,
+ const ::rtl::OUString& _rObjectName )
+ {
+ DatabaseObjectView::fillDispatchArgs( i_rDispatchArgs, _aDataSource, _rObjectName );
+
+ const bool bIncludeQueryName = 0 != _rObjectName.getLength();
+ const bool bGraphicalDesign = i_rDispatchArgs.getOrDefault( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, sal_True );
+ const bool bEditViewAsSQLCommand = ( m_nCommandType == CommandType::TABLE ) && !bGraphicalDesign;
+
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND_TYPE, m_nCommandType );
+
+ if ( bIncludeQueryName )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND, _rObjectName );
+ }
+
+ if ( bEditViewAsSQLCommand )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING, sal_False );
+ }
+ }
+
+ //======================================================================
+ //= TableDesigner
+ //======================================================================
+ //----------------------------------------------------------------------
+ TableDesigner::TableDesigner( const Reference< XMultiServiceFactory >& _rxORB, const Reference< XDatabaseDocumentUI >& _rxApplication, const Reference< XFrame >& _rxParentFrame )
+ :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame, static_cast< ::rtl::OUString >( URL_COMPONENT_TABLEDESIGN ) )
+ {
+ }
+
+ //----------------------------------------------------------------------
+ void TableDesigner::fillDispatchArgs( ::comphelper::NamedValueCollection& i_rDispatchArgs, const Any& _aDataSource,
+ const ::rtl::OUString& _rObjectName )
+ {
+ DatabaseObjectView::fillDispatchArgs( i_rDispatchArgs, _aDataSource, _rObjectName );
+
+ if ( 0 != _rObjectName.getLength() )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_CURRENTTABLE, _rObjectName );
+ }
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XComponent > TableDesigner::doCreateView( const Any& _rDataSource, const ::rtl::OUString& _rObjectName,
+ const ::comphelper::NamedValueCollection& i_rCreationArgs )
+ {
+ bool bIsNewDesign = ( _rObjectName.getLength() == 0 );
+
+ // let's see whether the connection can provide a dedicated table desginer
+ Reference< XInterface > xDesigner;
+ if ( !bIsNewDesign )
+ xDesigner = impl_getConnectionProvidedDesigner_nothrow( _rObjectName );
+
+ if ( !xDesigner.is() )
+ return DatabaseObjectView::doCreateView( _rDataSource, _rObjectName, i_rCreationArgs );
+
+ // try whether the designer is a dialog
+ Reference< XExecutableDialog > xDialog( xDesigner, UNO_QUERY_THROW );
+ if ( xDialog.is() )
+ {
+ try { AsyncDialogExecutor::executeModalDialogAsync( xDialog ); }
+ catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+ return NULL;
+ }
+
+ Reference< XComponent > xDesignerComponent( xDesigner, UNO_QUERY );
+ OSL_ENSURE( xDesignerComponent.is(), "TableDesigner::doCreateView: a designer which is no dialog and no component?" );
+ return xDesignerComponent;
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XInterface > TableDesigner::impl_getConnectionProvidedDesigner_nothrow( const ::rtl::OUString& _rTableName )
+ {
+ Reference< XInterface > xDesigner;
+ try
+ {
+ Reference< XTableUIProvider > xTableUIProv( getConnection(), UNO_QUERY );
+ if ( xTableUIProv.is() )
+ xDesigner = xTableUIProv->getTableEditor( getApplicationUI(), _rTableName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xDesigner;
+ }
+
+ //======================================================================
+ //= ResultSetBrowser
+ //======================================================================
+ //----------------------------------------------------------------------
+ ResultSetBrowser::ResultSetBrowser( const Reference< XMultiServiceFactory >& _rxORB, const Reference< XDatabaseDocumentUI >& _rxApplication, const Reference< XFrame >& _rxParentFrame,
+ sal_Bool _bTable )
+ :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame, static_cast < ::rtl::OUString >( URL_COMPONENT_DATASOURCEBROWSER ) )
+ ,m_bTable(_bTable)
+ {
+ }
+
+ //----------------------------------------------------------------------
+ void ResultSetBrowser::fillDispatchArgs( ::comphelper::NamedValueCollection& i_rDispatchArgs, const Any& _aDataSource,
+ const ::rtl::OUString& _rQualifiedName)
+ {
+ DatabaseObjectView::fillDispatchArgs( i_rDispatchArgs, _aDataSource, _rQualifiedName );
+ OSL_ENSURE( 0 != _rQualifiedName.getLength(),"A Table name must be set");
+ ::rtl::OUString sCatalog;
+ ::rtl::OUString sSchema;
+ ::rtl::OUString sTable;
+ if ( m_bTable )
+ ::dbtools::qualifiedNameComponents( getConnection()->getMetaData(), _rQualifiedName, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
+
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND_TYPE, (m_bTable ? CommandType::TABLE : CommandType::QUERY) );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND, _rQualifiedName );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_ENABLE_BROWSER, sal_False );
+
+ if ( m_bTable )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_UPDATE_CATALOGNAME, sCatalog );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_UPDATE_SCHEMANAME, sSchema );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_UPDATE_TABLENAME, sTable );
+ }
+ }
+
+ //======================================================================
+ //= RelationDesigner
+ //======================================================================
+ //----------------------------------------------------------------------
+ RelationDesigner::RelationDesigner( const Reference< XMultiServiceFactory >& _rxORB, const Reference< XDatabaseDocumentUI >& _rxApplication, const Reference< XFrame >& _rxParentFrame )
+ :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame, static_cast< ::rtl::OUString >( URL_COMPONENT_RELATIONDESIGN ) )
+ {
+ }
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
+
diff --git a/dbaccess/source/ui/misc/datasourceconnector.cxx b/dbaccess/source/ui/misc/datasourceconnector.cxx
new file mode 100644
index 000000000000..4c4a9be58d52
--- /dev/null
+++ b/dbaccess/source/ui/misc/datasourceconnector.cxx
@@ -0,0 +1,277 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
+#include "datasourceconnector.hxx"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#endif
+#ifndef _OSL_THREAD_H_
+#include <osl/thread.h>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
+#include <comphelper/namedvaluecollection.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _VCL_STDTEXT_HXX
+#include <vcl/stdtext.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX
+#include <svl/filenotation.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#include "moduledbu.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::frame;
+ using namespace ::dbtools;
+ using ::svt::OFileNotation;
+
+ //=====================================================================
+ //= ODatasourceConnector
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ODatasourceConnector::ODatasourceConnector(const Reference< XMultiServiceFactory >& _rxORB, Window* _pMessageParent)
+ :m_pErrorMessageParent(_pMessageParent)
+ ,m_xORB(_rxORB)
+ {
+ }
+
+ //---------------------------------------------------------------------
+ ODatasourceConnector::ODatasourceConnector( const Reference< XMultiServiceFactory >& _rxORB, Window* _pMessageParent,
+ const ::rtl::OUString& _rContextInformation )
+ :m_pErrorMessageParent(_pMessageParent)
+ ,m_xORB(_rxORB)
+ ,m_sContextInformation( _rContextInformation )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XConnection > ODatasourceConnector::connect( const ::rtl::OUString& _rDataSourceName,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo ) const
+ {
+ Reference< XConnection > xConnection;
+
+ OSL_ENSURE(isValid(), "ODatasourceConnector::connect: invalid object!");
+ if (!isValid())
+ return xConnection;
+
+ // get the data source
+ Reference< XDataSource > xDatasource(
+ getDataSourceByName( _rDataSourceName, m_pErrorMessageParent, m_xORB, _pErrorInfo ),
+ UNO_QUERY
+ );
+
+ if ( xDatasource.is() )
+ xConnection = connect( xDatasource, _pErrorInfo );
+ return xConnection;
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XConnection > ODatasourceConnector::connect(const Reference< XDataSource>& _xDataSource,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo ) const
+ {
+ Reference< XConnection > xConnection;
+
+ OSL_ENSURE( isValid() && _xDataSource.is(), "ODatasourceConnector::connect: invalid object or argument!" );
+ if ( !isValid() || !_xDataSource.is() )
+ return xConnection;
+
+ // get user/password
+ ::rtl::OUString sPassword, sUser;
+ sal_Bool bPwdRequired = sal_False;
+ Reference<XPropertySet> xProp(_xDataSource,UNO_QUERY);
+ try
+ {
+ xProp->getPropertyValue(PROPERTY_PASSWORD) >>= sPassword;
+ xProp->getPropertyValue(PROPERTY_ISPASSWORDREQUIRED) >>= bPwdRequired;
+ xProp->getPropertyValue(PROPERTY_USER) >>= sUser;
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // try to connect
+ SQLExceptionInfo aInfo;
+ try
+ {
+ if (bPwdRequired && !sPassword.getLength())
+ { // password required, but empty -> connect using an interaction handler
+ Reference< XCompletedConnection > xConnectionCompletion( _xDataSource, UNO_QUERY_THROW );
+
+ Reference< XModel > xModel( getDataSourceOrModel( _xDataSource ), UNO_QUERY_THROW );
+ ::comphelper::NamedValueCollection aArgs( xModel->getArgs() );
+ Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) );
+
+ if ( !xHandler.is() )
+ {
+ // instantiate the default SDB interaction handler
+ xHandler = Reference< XInteractionHandler >( m_xORB->createInstance( SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY );
+ if ( !xHandler.is() )
+ ShowServiceNotAvailableError(m_pErrorMessageParent, (::rtl::OUString)SERVICE_TASK_INTERACTION_HANDLER, sal_True);
+ }
+
+ if ( xHandler.is() )
+ {
+ xConnection = xConnectionCompletion->connectWithCompletion(xHandler);
+ }
+ }
+ else
+ {
+ xConnection = _xDataSource->getConnection(sUser, sPassword);
+ }
+ }
+ catch( const SQLException& )
+ {
+ aInfo = ::cppu::getCaughtException();
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( !aInfo.isValid() )
+ {
+ // there was no error during connecting, but perhaps a warning?
+ Reference< XWarningsSupplier > xConnectionWarnings( xConnection, UNO_QUERY );
+ if ( xConnectionWarnings.is() )
+ {
+ try
+ {
+ Any aWarnings( xConnectionWarnings->getWarnings() );
+ if ( aWarnings.hasValue() )
+ {
+ String sMessage( ModuleRes( STR_WARNINGS_DURING_CONNECT ) );
+ sMessage.SearchAndReplaceAscii( "$buttontext$", Button::GetStandardText( BUTTON_MORE ) );
+ sMessage = OutputDevice::GetNonMnemonicString( sMessage );
+
+ SQLWarning aContext;
+ aContext.Message = sMessage;
+ aContext.NextException = aWarnings;
+ aInfo = aContext;
+ }
+ xConnectionWarnings->clearWarnings();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ else
+ {
+ if ( m_sContextInformation.getLength() )
+ {
+ SQLException aError;
+ aError.Message = m_sContextInformation;
+ aError.NextException = aInfo.get();
+
+ aInfo = aError;
+ }
+ }
+
+ // was there an error?
+ if ( aInfo.isValid() )
+ {
+ if ( _pErrorInfo )
+ {
+ *_pErrorInfo = aInfo;
+ }
+ else
+ {
+ showError( aInfo, m_pErrorMessageParent, m_xORB );
+ }
+ }
+ return xConnection;
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/misc/dbaundomanager.cxx b/dbaccess/source/ui/misc/dbaundomanager.cxx
new file mode 100755
index 000000000000..1e60a027a693
--- /dev/null
+++ b/dbaccess/source/ui/misc/dbaundomanager.cxx
@@ -0,0 +1,395 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_dbaccess.hxx"
+
+#include "dbaundomanager.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/DisposedException.hpp>
+/** === end UNO includes === **/
+
+#include <svl/undo.hxx>
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+#include <framework/undomanagerhelper.hxx>
+
+//......................................................................................................................
+namespace dbaui
+{
+//......................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::document::XUndoManager;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::document::UndoContextNotClosedException;
+ using ::com::sun::star::document::UndoFailedException;
+ using ::com::sun::star::document::EmptyUndoStackException;
+ using ::com::sun::star::util::InvalidStateException;
+ using ::com::sun::star::document::XUndoAction;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::document::XUndoManagerListener;
+ using ::com::sun::star::util::NotLockedException;
+ using ::com::sun::star::lang::NoSupportException;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= UndoManager_Impl
+ //==================================================================================================================
+ struct UndoManager_Impl : public ::framework::IUndoManagerImplementation
+ {
+ UndoManager_Impl( UndoManager& i_antiImpl, ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ :rAntiImpl( i_antiImpl )
+ ,rParent( i_parent )
+ ,rMutex( i_mutex )
+ ,bDisposed( false )
+ ,aUndoManager()
+ ,aUndoHelper( *this )
+ {
+ }
+
+ virtual ~UndoManager_Impl()
+ {
+ }
+
+ UndoManager& rAntiImpl;
+ ::cppu::OWeakObject& rParent;
+ ::osl::Mutex& rMutex;
+ bool bDisposed;
+ SfxUndoManager aUndoManager;
+ ::framework::UndoManagerHelper aUndoHelper;
+
+ // IUndoManagerImplementation
+ virtual ::svl::IUndoManager& getImplUndoManager();
+ virtual Reference< XUndoManager > getThis();
+ };
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::svl::IUndoManager& UndoManager_Impl::getImplUndoManager()
+ {
+ return aUndoManager;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XUndoManager > UndoManager_Impl::getThis()
+ {
+ return static_cast< XUndoManager* >( &rAntiImpl );
+ }
+
+ //==============================================================================================================
+ //= OslMutexFacade
+ //==============================================================================================================
+ class OslMutexFacade : public ::framework::IMutex
+ {
+ public:
+ OslMutexFacade( ::osl::Mutex& i_mutex )
+ :m_rMutex( i_mutex )
+ {
+ }
+
+ virtual void acquire();
+ virtual void release();
+
+ private:
+ ::osl::Mutex& m_rMutex;
+ };
+
+ //--------------------------------------------------------------------------------------------------------------
+ void OslMutexFacade::acquire()
+ {
+ m_rMutex.acquire();
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ void OslMutexFacade::release()
+ {
+ m_rMutex.release();
+ }
+
+ //==============================================================================================================
+ //= UndoManagerMethodGuard
+ //==============================================================================================================
+ /** guard for public UNO methods of the UndoManager
+ */
+ class UndoManagerMethodGuard : public ::framework::IMutexGuard
+ {
+ public:
+ UndoManagerMethodGuard( UndoManager_Impl& i_impl )
+ :m_aGuard( i_impl.rMutex )
+ ,m_aMutexFacade( i_impl.rMutex )
+ {
+ // throw if the instance is already disposed
+ if ( i_impl.bDisposed )
+ throw DisposedException( ::rtl::OUString(), i_impl.getThis() );
+ }
+ virtual ~UndoManagerMethodGuard()
+ {
+ }
+
+ // IMutexGuard
+ virtual ::framework::IMutex& getGuardedMutex();
+
+ // IGuard
+ virtual void clear();
+ virtual void reset();
+
+ private:
+ ::osl::ResettableMutexGuard m_aGuard;
+ OslMutexFacade m_aMutexFacade;
+ };
+
+ //--------------------------------------------------------------------------------------------------------------
+ ::framework::IMutex& UndoManagerMethodGuard::getGuardedMutex()
+ {
+ return m_aMutexFacade;
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ void UndoManagerMethodGuard::clear()
+ {
+ m_aGuard.clear();
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ void UndoManagerMethodGuard::reset()
+ {
+ m_aGuard.reset();
+ }
+
+ //==================================================================================================================
+ //= UndoManager
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ UndoManager::UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ :m_pImpl( new UndoManager_Impl( *this, i_parent, i_mutex ) )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ UndoManager::~UndoManager()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ SfxUndoManager& UndoManager::GetSfxUndoManager() const
+ {
+ return m_pImpl->aUndoManager;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::acquire( ) throw ()
+ {
+ m_pImpl->rParent.acquire();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::release( ) throw ()
+ {
+ m_pImpl->rParent.release();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UndoManager::disposing()
+ {
+ {
+ ::osl::MutexGuard aGuard( m_pImpl->rMutex );
+ m_pImpl->bDisposed = true;
+ }
+ m_pImpl->aUndoHelper.disposing();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::enterUndoContext( const ::rtl::OUString& i_title ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.enterUndoContext( i_title, aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::enterHiddenUndoContext( ) throw (EmptyUndoStackException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.enterHiddenUndoContext( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::leaveUndoContext( ) throw (InvalidStateException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.leaveUndoContext( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::addUndoAction( const Reference< XUndoAction >& i_action ) throw (IllegalArgumentException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.addUndoAction( i_action, aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::undo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException)
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ // (all our UndoActions work directly on VCL code, usually, so ...)
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.undo( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::redo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException)
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ // (all our UndoActions work directly on VCL code, usually, so ...)
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.redo( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL UndoManager::isUndoPossible( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.isUndoPossible();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL UndoManager::isRedoPossible( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.isRedoPossible();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL UndoManager::getCurrentUndoActionTitle( ) throw (EmptyUndoStackException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.getCurrentUndoActionTitle();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL UndoManager::getCurrentRedoActionTitle( ) throw (EmptyUndoStackException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.getCurrentRedoActionTitle();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL UndoManager::getAllUndoActionTitles( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.getAllUndoActionTitles();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL UndoManager::getAllRedoActionTitles( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.getAllRedoActionTitles();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::clear( ) throw (UndoContextNotClosedException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.clear( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::clearRedo( ) throw (UndoContextNotClosedException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.clearRedo( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::reset( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.reset( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.addUndoManagerListener( i_listener );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::removeUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.removeUndoManagerListener( i_listener );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::lock( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.lock();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::unlock( ) throw (NotLockedException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.unlock();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL UndoManager::isLocked( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.isLocked();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL UndoManager::getParent( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return *&m_pImpl->rParent;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::setParent( const Reference< XInterface >& i_parent ) throw (NoSupportException, RuntimeException)
+ {
+ (void)i_parent;
+ throw NoSupportException( ::rtl::OUString(), m_pImpl->getThis() );
+ }
+
+//......................................................................................................................
+} // namespace dbaui
+//......................................................................................................................
diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
new file mode 100644
index 000000000000..eb1b34710ff8
--- /dev/null
+++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
@@ -0,0 +1,672 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "browserids.hxx"
+#include "commontypes.hxx"
+#include "dataview.hxx"
+#include "dbu_misc.hrc"
+#include "dbustrings.hrc"
+#include "moduledbu.hxx"
+#include "dbsubcomponentcontroller.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <toolkit/unohlp.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/msgbox.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::util::XNumberFormatter;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::sdbc::XDataSource;
+ using ::com::sun::star::util::XNumberFormatter;
+ using ::com::sun::star::util::XNumberFormatsSupplier;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::sdb::XOfficeDatabaseDocument;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::sdb::XDocumentDataSource;
+ using ::com::sun::star::document::XEmbeddedScripts;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::frame::XUntitledNumbers;
+ using ::com::sun::star::beans::PropertyVetoException;
+ /** === end UNO using === **/
+
+ class DataSourceHolder
+ {
+ public:
+ DataSourceHolder()
+ {
+ }
+
+ DataSourceHolder( const Reference< XDataSource >& _rxDataSource )
+ {
+ m_xDataSource = _rxDataSource;
+ Reference< XDocumentDataSource > xDocDS( m_xDataSource, UNO_QUERY );
+ if ( xDocDS.is() )
+ m_xDocument = xDocDS->getDatabaseDocument();
+
+ m_xDataSourceProps.set( m_xDataSource, UNO_QUERY );
+ }
+
+ const Reference< XDataSource >& getDataSource() const { return m_xDataSource; }
+ const Reference< XPropertySet >& getDataSourceProps() const { return m_xDataSourceProps; }
+ const Reference< XOfficeDatabaseDocument > getDatabaseDocument() const { return m_xDocument; }
+
+ bool is() const { return m_xDataSource.is(); }
+
+ void clear()
+ {
+ m_xDataSource.clear();
+ m_xDocument.clear();
+ }
+
+ private:
+ Reference< XDataSource > m_xDataSource;
+ Reference< XPropertySet > m_xDataSourceProps;
+ Reference< XOfficeDatabaseDocument > m_xDocument;
+ };
+
+ struct DBSubComponentController_Impl
+ {
+ private:
+ ::boost::optional< bool > m_aDocScriptSupport;
+
+ public:
+ OModuleClient m_aModuleClient;
+ ::dbtools::SQLExceptionInfo m_aCurrentError;
+
+ ::cppu::OInterfaceContainerHelper
+ m_aModifyListeners;
+
+ // <properties>
+ SharedConnection m_xConnection;
+ ::dbtools::DatabaseMetaData m_aSdbMetaData;
+ // </properties>
+ ::rtl::OUString m_sDataSourceName; // the data source we're working for
+ DataSourceHolder m_aDataSource;
+ Reference< XModel > m_xDocument;
+ Reference< XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
+ sal_Int32 m_nDocStartNumber;
+ sal_Bool m_bSuspended; // is true when the controller was already suspended
+ sal_Bool m_bEditable; // is the control readonly or not
+ sal_Bool m_bModified; // is the data modified
+ bool m_bNotAttached;
+
+ DBSubComponentController_Impl( ::osl::Mutex& i_rMutex )
+ :m_aDocScriptSupport()
+ ,m_aModifyListeners( i_rMutex )
+ ,m_nDocStartNumber(0)
+ ,m_bSuspended( sal_False )
+ ,m_bEditable(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bNotAttached(true)
+ {
+ }
+
+ bool documentHasScriptSupport() const
+ {
+ OSL_PRECOND( !!m_aDocScriptSupport,
+ "DBSubComponentController_Impl::documentHasScriptSupport: not completely initialized, yet - don't know!?" );
+ return !!m_aDocScriptSupport && *m_aDocScriptSupport;
+ }
+
+ void setDocumentScriptSupport( const bool _bSupport )
+ {
+ OSL_PRECOND( !m_aDocScriptSupport,
+ "DBSubComponentController_Impl::setDocumentScriptSupport: already initialized!" );
+ m_aDocScriptSupport = ::boost::optional< bool >( _bSupport );
+ }
+ };
+
+ //====================================================================
+ //= DBSubComponentController
+ //====================================================================
+ //--------------------------------------------------------------------
+ DBSubComponentController::DBSubComponentController(const Reference< XMultiServiceFactory >& _rxORB)
+ :DBSubComponentController_Base( _rxORB )
+ ,m_pImpl( new DBSubComponentController_Impl( getMutex() ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DBSubComponentController::~DBSubComponentController()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::impl_initialize()
+ {
+ OGenericUnoController::impl_initialize();
+
+ const ::comphelper::NamedValueCollection& rArguments( getInitParams() );
+
+ Reference< XConnection > xConnection;
+ xConnection = rArguments.getOrDefault( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, xConnection );
+
+ if ( !xConnection.is() )
+ ::dbtools::isEmbeddedInDatabase( getModel(), xConnection );
+
+ if ( xConnection.is() )
+ initializeConnection( xConnection );
+
+ bool bShowError = true;
+ if ( !isConnected() )
+ {
+ reconnect( sal_False );
+ bShowError = false;
+ }
+ if ( !isConnected() )
+ {
+ if ( bShowError )
+ connectionLostMessage();
+ throw IllegalArgumentException();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL DBSubComponentController::queryInterface(const Type& _rType) throw (RuntimeException)
+ {
+ if ( _rType.equals( XScriptInvocationContext::static_type() ) )
+ {
+ if ( m_pImpl->documentHasScriptSupport() )
+ return makeAny( Reference< XScriptInvocationContext >( this ) );
+ return Any();
+ }
+
+ return DBSubComponentController_Base::queryInterface( _rType );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Type > SAL_CALL DBSubComponentController::getTypes( ) throw (RuntimeException)
+ {
+ Sequence< Type > aTypes( DBSubComponentController_Base::getTypes() );
+ if ( !m_pImpl->documentHasScriptSupport() )
+ {
+ Sequence< Type > aStrippedTypes( aTypes.getLength() - 1 );
+ ::std::remove_copy_if(
+ aTypes.getConstArray(),
+ aTypes.getConstArray() + aTypes.getLength(),
+ aStrippedTypes.getArray(),
+ ::std::bind2nd( ::std::equal_to< Type >(), XScriptInvocationContext::static_type() )
+ );
+ aTypes = aStrippedTypes;
+ }
+ return aTypes;
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::initializeConnection( const Reference< XConnection >& _rxForeignConn )
+ {
+ DBG_ASSERT( !isConnected(), "DBSubComponentController::initializeConnection: not to be called when already connected!" );
+ // usually this gets called from within initialize of derived classes ...
+ if ( isConnected() )
+ disconnect();
+
+ m_pImpl->m_xConnection.reset( _rxForeignConn, SharedConnection::NoTakeOwnership );
+ m_pImpl->m_aSdbMetaData.reset( m_pImpl->m_xConnection );
+ startConnectionListening( m_pImpl->m_xConnection );
+
+ // get the data source the connection belongs to
+ try
+ {
+ // determine our data source
+ OSL_PRECOND( !m_pImpl->m_aDataSource.is(), "DBSubComponentController::initializeConnection: already a data source in this phase?" );
+ {
+ Reference< XChild > xConnAsChild( m_pImpl->m_xConnection, UNO_QUERY );
+ Reference< XDataSource > xDS;
+ if ( xConnAsChild.is() )
+ xDS = Reference< XDataSource >( xConnAsChild->getParent(), UNO_QUERY );
+
+ // (take the indirection through XDataSource to ensure we have a correct object ....)
+ m_pImpl->m_aDataSource = xDS;
+ }
+ OSL_POSTCOND( m_pImpl->m_aDataSource.is(), "DBSubComponentController::initializeConnection: unable to obtain the data source object!" );
+
+ if ( m_pImpl->m_bNotAttached )
+ {
+ Reference< XUntitledNumbers > xUntitledProvider( getDatabaseDocument(), UNO_QUERY );
+ m_pImpl->m_nDocStartNumber = 1;
+ if ( xUntitledProvider.is() )
+ m_pImpl->m_nDocStartNumber = xUntitledProvider->leaseNumber( static_cast< XWeak* >( this ) );
+ }
+
+ // determine the availability of script support in our document. Our own XScriptInvocationContext
+ // interface depends on this
+ m_pImpl->setDocumentScriptSupport( Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY ).is() );
+
+ // get a number formatter
+ Reference< XPropertySet > xDataSourceProps( m_pImpl->m_aDataSource.getDataSourceProps(), UNO_SET_THROW );
+ xDataSourceProps->getPropertyValue( PROPERTY_NAME ) >>= m_pImpl->m_sDataSourceName;
+ DBG_ASSERT( m_pImpl->m_sDataSourceName.getLength(), "DBSubComponentController::initializeConnection: invalid data source name!" );
+ Reference< XNumberFormatsSupplier> xSupplier = ::dbtools::getNumberFormats(m_pImpl->m_xConnection);
+ if(xSupplier.is())
+ {
+ m_pImpl->m_xFormatter = Reference< XNumberFormatter >(getORB()
+ ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY);
+ m_pImpl->m_xFormatter->attachNumberFormatsSupplier(xSupplier);
+ }
+ OSL_ENSURE(m_pImpl->m_xFormatter.is(),"No NumberFormatter!");
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::reconnect( sal_Bool _bUI )
+ {
+ OSL_ENSURE(!m_pImpl->m_bSuspended, "Cannot reconnect while suspended!");
+
+ stopConnectionListening( m_pImpl->m_xConnection );
+ m_pImpl->m_aSdbMetaData.reset( NULL );
+ m_pImpl->m_xConnection.clear();
+
+ // reconnect
+ sal_Bool bReConnect = sal_True;
+ if ( _bUI )
+ {
+ QueryBox aQuery( getView(), ModuleRes(QUERY_CONNECTION_LOST) );
+ bReConnect = ( RET_YES == aQuery.Execute() );
+ }
+
+ // now really reconnect ...
+ if ( bReConnect )
+ {
+ m_pImpl->m_xConnection.reset( connect( m_pImpl->m_aDataSource.getDataSource(), NULL ), SharedConnection::TakeOwnership );
+ m_pImpl->m_aSdbMetaData.reset( m_pImpl->m_xConnection );
+ }
+
+ // invalidate all slots
+ InvalidateAll();
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::disconnect()
+ {
+ stopConnectionListening(m_pImpl->m_xConnection);
+ m_pImpl->m_aSdbMetaData.reset( NULL );
+ m_pImpl->m_xConnection.clear();
+
+ InvalidateAll();
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::losingConnection()
+ {
+ // our connection was disposed so we need a new one
+ reconnect( sal_True );
+ InvalidateAll();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::disposing()
+ {
+ DBSubComponentController_Base::disposing();
+
+ disconnect();
+
+ attachFrame( Reference < XFrame >() );
+
+ m_pImpl->m_aDataSource.clear();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::disposing(const EventObject& _rSource) throw( RuntimeException )
+ {
+ if ( _rSource.Source == getConnection() )
+ {
+ if ( !m_pImpl->m_bSuspended // when already suspended then we don't have to reconnect
+ && !getBroadcastHelper().bInDispose
+ && !getBroadcastHelper().bDisposed
+ && isConnected()
+ )
+ {
+ losingConnection();
+ }
+ else
+ {
+ m_pImpl->m_xConnection.reset( m_pImpl->m_xConnection, SharedConnection::NoTakeOwnership );
+ // this prevents the "disposeComponent" call in disconnect
+ disconnect();
+ }
+ }
+ else
+ DBSubComponentController_Base::disposing( _rSource );
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::appendError( const ::rtl::OUString& _rErrorMessage, const ::dbtools::StandardSQLState _eSQLState,
+ const sal_Int32 _nErrorCode )
+ {
+ m_pImpl->m_aCurrentError.append( ::dbtools::SQLExceptionInfo::SQL_EXCEPTION, _rErrorMessage, getStandardSQLStateAscii( _eSQLState ),
+ _nErrorCode );
+ }
+ //--------------------------------------------------------------------
+ void DBSubComponentController::clearError()
+ {
+ m_pImpl->m_aCurrentError = ::dbtools::SQLExceptionInfo();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool DBSubComponentController::hasError() const
+ {
+ return m_pImpl->m_aCurrentError.isValid();
+ }
+
+ //--------------------------------------------------------------------
+ const ::dbtools::SQLExceptionInfo& DBSubComponentController::getError() const
+ {
+ return m_pImpl->m_aCurrentError;
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::displayError()
+ {
+ showError( m_pImpl->m_aCurrentError );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL DBSubComponentController::suspend(sal_Bool bSuspend) throw( RuntimeException )
+ {
+ m_pImpl->m_bSuspended = bSuspend;
+ if ( !bSuspend && !isConnected() )
+ reconnect(sal_True);
+
+
+ return sal_True;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool SAL_CALL DBSubComponentController::attachModel( const Reference< XModel > & _rxModel) throw( RuntimeException )
+ {
+ if ( !_rxModel.is() )
+ return sal_False;
+ if ( !DBSubComponentController_Base::attachModel( _rxModel ) )
+ return sal_False;
+
+ m_pImpl->m_bNotAttached = false;
+ if ( m_pImpl->m_nDocStartNumber == 1 )
+ releaseNumberForComponent();
+
+ Reference< XUntitledNumbers > xUntitledProvider( _rxModel, UNO_QUERY );
+ m_pImpl->m_nDocStartNumber = 1;
+ if ( xUntitledProvider.is() )
+ m_pImpl->m_nDocStartNumber = xUntitledProvider->leaseNumber( static_cast< XWeak* >( this ) );
+
+ return sal_True;
+ }
+
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& _rArgs)
+ {
+ if ( _nId == ID_BROWSER_CLOSE )
+ {
+ closeTask();
+ return;
+ }
+
+ DBSubComponentController_Base::Execute( _nId, _rArgs );
+ InvalidateFeature( _nId );
+ }
+
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString DBSubComponentController::getDataSourceName() const
+ {
+ ::rtl::OUString sName;
+ Reference< XPropertySet > xDataSourceProps( m_pImpl->m_aDataSource.getDataSourceProps() );
+ if ( xDataSourceProps.is() )
+ xDataSourceProps->getPropertyValue(PROPERTY_NAME) >>= sName;
+ return sName;
+ }
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::connectionLostMessage() const
+ {
+ String aMessage(ModuleRes(RID_STR_CONNECTION_LOST));
+ Reference< XWindow > xWindow = getTopMostContainerWindow();
+ Window* pWin = NULL;
+ if ( xWindow.is() )
+ pWin = VCLUnoHelper::GetWindow(xWindow);
+ if ( !pWin )
+ pWin = getView()->Window::GetParent();
+
+ InfoBox(pWin, aMessage).Execute();
+ }
+ // -----------------------------------------------------------------------------
+ const Reference< XConnection >& DBSubComponentController::getConnection() const
+ {
+ return m_pImpl->m_xConnection;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::isReadOnly() const
+ {
+ return !m_pImpl->m_bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::isEditable() const
+ {
+ return m_pImpl->m_bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::setEditable(sal_Bool _bEditable)
+ {
+ m_pImpl->m_bEditable = _bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ const ::dbtools::DatabaseMetaData& DBSubComponentController::getSdbMetaData() const
+ {
+ return m_pImpl->m_aSdbMetaData;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::isConnected() const
+ {
+ return m_pImpl->m_xConnection.is();
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XDatabaseMetaData > DBSubComponentController::getMetaData( ) const
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ try
+ {
+ if ( isConnected() )
+ xMeta.set( m_pImpl->m_xConnection->getMetaData(), UNO_SET_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xMeta;
+ }
+
+ // -----------------------------------------------------------------------------
+ const Reference< XPropertySet >& DBSubComponentController::getDataSource() const
+ {
+ return m_pImpl->m_aDataSource.getDataSourceProps();
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::haveDataSource() const
+ {
+ return m_pImpl->m_aDataSource.is();
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XModel > DBSubComponentController::getDatabaseDocument() const
+ {
+ return Reference< XModel >( m_pImpl->m_aDataSource.getDatabaseDocument(), UNO_QUERY );
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XNumberFormatter > DBSubComponentController::getNumberFormatter() const
+ {
+ return m_pImpl->m_xFormatter;
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XModel > DBSubComponentController::getPrivateModel() const
+ {
+ return getDatabaseDocument();
+ }
+ // -----------------------------------------------------------------------------
+ // XTitle
+ ::rtl::OUString SAL_CALL DBSubComponentController::getTitle()
+ throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( m_bExternalTitle )
+ return impl_getTitleHelper_throw()->getTitle ();
+
+ ::rtl::OUStringBuffer sTitle;
+ Reference< XTitle > xTitle(getPrivateModel(),UNO_QUERY);
+ if ( xTitle.is() )
+ {
+ sTitle.append( xTitle->getTitle() );
+ sTitle.appendAscii(" : ");
+ }
+ sTitle.append( getPrivateTitle() );
+ return sTitle.makeStringAndClear();
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Int32 DBSubComponentController::getCurrentStartNumber() const
+ {
+ return m_pImpl->m_nDocStartNumber;
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XEmbeddedScripts > SAL_CALL DBSubComponentController::getScriptContainer() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( !m_pImpl->documentHasScriptSupport() )
+ return NULL;
+
+ return Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY_THROW );
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::addModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ m_pImpl->m_aModifyListeners.addInterface( i_Listener );
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::removeModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ m_pImpl->m_aModifyListeners.removeInterface( i_Listener );
+ }
+
+ // -----------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DBSubComponentController::isModified( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ return impl_isModified();
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::setModified( ::sal_Bool i_bModified ) throw (PropertyVetoException, RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( getMutex() );
+
+ if ( m_pImpl->m_bModified == i_bModified )
+ return;
+
+ m_pImpl->m_bModified = i_bModified;
+ impl_onModifyChanged();
+
+ EventObject aEvent( *this );
+ aGuard.clear();
+ m_pImpl->m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent );
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::impl_isModified() const
+ {
+ return m_pImpl->m_bModified;
+ }
+
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::impl_onModifyChanged()
+ {
+ InvalidateFeature( ID_BROWSER_SAVEDOC );
+ if ( isFeatureSupported( ID_BROWSER_SAVEASDOC ) )
+ InvalidateFeature( ID_BROWSER_SAVEASDOC );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/dbumiscres.hrc b/dbaccess/source/ui/misc/dbumiscres.hrc
new file mode 100644
index 000000000000..81b72e5dda87
--- /dev/null
+++ b/dbaccess/source/ui/misc/dbumiscres.hrc
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_MISCRES_HRC_
+#define _DBU_MISCRES_HRC_
+
+//========================================================================
+// string ids (relative to other resources, that's why not unique)
+
+#define STR_MYSQL_ODBC 1
+#define STR_MYSQL_JDBC 2
+#define STR_ADABAS 3
+#define STR_ORACLE_JDBC 4
+#define STR_JDBC 5
+#define STR_ODBC 6
+#define STR_DBASE 7
+#define STR_MSACCESS 8
+#define STR_MSACCESS2007 9
+#define STR_ADO 10
+#define STR_FLAT 11
+#define STR_CALC 12
+#define STR_MOZILLA 13
+#define STR_LDAP 14
+#define STR_OUTLOOK 15
+#define STR_OUTLOOKEXP 16
+#define STR_EVOLUTION 17
+#define STR_EVOLUTION_GROUPWISE 18
+#define STR_EVOLUTION_LDAP 19
+#define STR_KAB 20
+#define STR_MACAB 21
+#define STR_EMBEDDED_HSQLDB 22
+#define STR_THUNDERBIRD 23
+#define STR_MYSQL_NATIVE 24
+
+#define STR_END STR_MYSQL_NATIVE + 1
+
+#endif // _DBU_MISCRES_HRC_
+
diff --git a/dbaccess/source/ui/misc/dbumiscres.src b/dbaccess/source/ui/misc/dbumiscres.src
new file mode 100644
index 000000000000..22bc80670cf6
--- /dev/null
+++ b/dbaccess/source/ui/misc/dbumiscres.src
@@ -0,0 +1,100 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+
+
+Resource RSC_CHARSETS
+{
+ String 1
+ {
+ Text [ en-US ] = "System";
+ };
+};
+
+String STR_ERROR_DURING_CREATION
+{
+ Text [ en-US ] = "Error during creation";
+};
+
+String STR_UNEXPECTED_ERROR
+{
+ Text [ en-US ] = "An unexpected error occurred. The operation could not be performed.";
+};
+
+String STR_COULDNOTOPEN_LINKEDDOC
+{
+ Text [ en-US ] = "The document \"$file$\" could not be opened.";
+};
+
+String STR_MISSING_TABLES_XDROP
+{
+ Text [ en-US ] = "The table cannot be deleted because the database connection does not support this.";
+};
+
+String STR_BUTTON_TEXT_ALL
+{
+ Text [ en-US ] = "~All";
+
+};
+
+String STR_UNDO_COLON
+{
+ Text [ en-US ] = "Undo:";
+};
+
+String STR_REDO_COLON
+{
+ Text [ en-US ] = "Redo:";
+};
+
+String STR_UNKNOWN_TYPE_FOUND
+{
+ Text [ en-US ] = "No corresponding column type could be found for column '#1'." ;
+};
+
+String STR_FILE_DOES_NOT_EXIST
+{
+ Text[ en-US ] = "The file \"$file$\" does not exist.";
+};
+
+String STR_WARNINGS_DURING_CONNECT
+{
+ Text [ en-US ] = "Warnings were encountered while connecting to the data source. Press \"$buttontext$\" to view them.";
+};
+
+String STR_NAMED_OBJECT_ALREADY_EXISTS
+{
+ Text [ en-US ] = "The name '$#$' already exists.\nPlease enter another name." ;
+};
+String RID_STR_EXTENSION_NOT_PRESENT
+{
+ // #i96130# use hard coded name
+ Text [ en-US ] = "The report, \"$file$\", requires the extension Oracle Report Builder.";
+};
diff --git a/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx
new file mode 100644
index 000000000000..a354e916fc1c
--- /dev/null
+++ b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx
@@ -0,0 +1,232 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_SOURCE_UI_MISC_DEFAULTOBJECTNAMECHECK_HXX
+#include "defaultobjectnamecheck.hxx"
+#endif
+
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XCONNECTIONTOOLS_HPP_
+#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef CONNECTIVITY_INC_CONNECTIVITY_DBMETADATA_HXX
+#include <connectivity/dbmetadata.hxx>
+#endif
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+
+#include <vector>
+#include <boost/shared_ptr.hpp>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::container::XHierarchicalNameAccess;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::sdbcx::XTablesSupplier;
+ using ::com::sun::star::sdb::XQueriesSupplier;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::sdb::tools::XObjectNames;
+ using ::com::sun::star::sdb::tools::XConnectionTools;
+ using ::com::sun::star::uno::UNO_QUERY;
+ /** === end UNO using === **/
+
+ using namespace dbtools;
+
+ namespace CommandType = ::com::sun::star::sdb::CommandType;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ void lcl_fillNameExistsError( const ::rtl::OUString& _rObjectName, SQLExceptionInfo& _out_rErrorToDisplay )
+ {
+ String sErrorMessage = String( ModuleRes( STR_NAMED_OBJECT_ALREADY_EXISTS ) );
+ sErrorMessage.SearchAndReplaceAllAscii( "$#$", _rObjectName );
+ SQLException aError;
+ aError.Message = sErrorMessage;
+ _out_rErrorToDisplay = aError;
+ }
+
+ }
+
+ //====================================================================
+ //= HierarchicalNameCheck_Impl
+ //====================================================================
+ struct HierarchicalNameCheck_Impl
+ {
+ Reference< XHierarchicalNameAccess > xHierarchicalNames;
+ ::rtl::OUString sRelativeRoot;
+ };
+
+ //====================================================================
+ //= HierarchicalNameCheck
+ //====================================================================
+ //--------------------------------------------------------------------
+ HierarchicalNameCheck::HierarchicalNameCheck( const Reference< XHierarchicalNameAccess >& _rxNames, const ::rtl::OUString& _rRelativeRoot )
+ :m_pImpl( new HierarchicalNameCheck_Impl )
+ {
+ m_pImpl->xHierarchicalNames = _rxNames;
+ m_pImpl->sRelativeRoot = _rRelativeRoot;
+
+ if ( !m_pImpl->xHierarchicalNames.is() )
+ throw IllegalArgumentException();
+ }
+
+ //--------------------------------------------------------------------
+ HierarchicalNameCheck::~HierarchicalNameCheck()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool HierarchicalNameCheck::isNameValid( const ::rtl::OUString& _rObjectName, SQLExceptionInfo& _out_rErrorToDisplay ) const
+ {
+ try
+ {
+ ::rtl::OUStringBuffer aCompleteName;
+ if ( m_pImpl->sRelativeRoot.getLength() )
+ {
+ aCompleteName.append( m_pImpl->sRelativeRoot );
+ aCompleteName.appendAscii( "/" );
+ }
+ aCompleteName.append( _rObjectName );
+
+ ::rtl::OUString sCompleteName( aCompleteName.makeStringAndClear() );
+ if ( !m_pImpl->xHierarchicalNames->hasByHierarchicalName( sCompleteName ) )
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ lcl_fillNameExistsError( _rObjectName, _out_rErrorToDisplay );
+ return false;
+ }
+
+ //====================================================================
+ //= DynamicTableOrQueryNameCheck_Impl
+ //====================================================================
+ struct DynamicTableOrQueryNameCheck_Impl
+ {
+ sal_Int32 nCommandType;
+ Reference< XObjectNames > xObjectNames;
+ };
+
+ //====================================================================
+ //= DynamicTableOrQueryNameCheck
+ //====================================================================
+ //--------------------------------------------------------------------
+ DynamicTableOrQueryNameCheck::DynamicTableOrQueryNameCheck( const Reference< XConnection >& _rxSdbLevelConnection, sal_Int32 _nCommandType )
+ :m_pImpl( new DynamicTableOrQueryNameCheck_Impl )
+ {
+ Reference< XConnectionTools > xConnTools( _rxSdbLevelConnection, UNO_QUERY );
+ if ( xConnTools.is() )
+ m_pImpl->xObjectNames.set( xConnTools->getObjectNames() );
+ if ( !m_pImpl->xObjectNames.is() )
+ throw IllegalArgumentException();
+
+ if ( ( _nCommandType != CommandType::QUERY ) && ( _nCommandType != CommandType::TABLE ) )
+ throw IllegalArgumentException();
+ m_pImpl->nCommandType = _nCommandType;
+ }
+
+ //--------------------------------------------------------------------
+ DynamicTableOrQueryNameCheck::~DynamicTableOrQueryNameCheck()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool DynamicTableOrQueryNameCheck::isNameValid( const ::rtl::OUString& _rObjectName, ::dbtools::SQLExceptionInfo& _out_rErrorToDisplay ) const
+ {
+ try
+ {
+ m_pImpl->xObjectNames->checkNameForCreate( m_pImpl->nCommandType, _rObjectName );
+ return true;
+ }
+ catch( const SQLException& )
+ {
+ _out_rErrorToDisplay = ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() );
+ }
+ return false;
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/dsmeta.cxx b/dbaccess/source/ui/misc/dsmeta.cxx
new file mode 100644
index 000000000000..052d013f47a4
--- /dev/null
+++ b/dbaccess/source/ui/misc/dsmeta.cxx
@@ -0,0 +1,214 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "dsmeta.hxx"
+#include <connectivity/DriversConfig.hxx>
+#include "dsntypes.hxx"
+#include <comphelper/processfactory.hxx>
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <map>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using namespace dbaccess;
+ using namespace ::com::sun::star;
+ /** === end UNO using === **/
+
+ struct FeatureSupport
+ {
+ // authentication mode of the data source
+ AuthenticationMode eAuthentication;
+
+ FeatureSupport()
+ :eAuthentication( AuthUserPwd )
+ {
+ }
+
+ FeatureSupport( AuthenticationMode _Auth )
+ :eAuthentication( _Auth )
+ {
+ }
+ };
+
+ struct FeatureMapping
+ {
+ /// one of the items from dsitems.hxx
+ ItemID nItemID;
+ const sal_Char* pAsciiFeatureName;
+ };
+
+ //====================================================================
+ //= global tables
+ //====================================================================
+ //--------------------------------------------------------------------
+ static const FeatureMapping* lcl_getFeatureMappings()
+ {
+ static const FeatureMapping s_aMappings[] = {
+ { DSID_AUTORETRIEVEENABLED, "GeneratedValues" },
+ { DSID_AUTOINCREMENTVALUE, "GeneratedValues" },
+ { DSID_AUTORETRIEVEVALUE, "GeneratedValues" },
+ { DSID_SQL92CHECK, "UseSQL92NamingConstraints" },
+ { DSID_APPEND_TABLE_ALIAS, "AppendTableAliasInSelect" },
+ { DSID_AS_BEFORE_CORRNAME, "UseKeywordAsBeforeAlias" },
+ { DSID_ENABLEOUTERJOIN, "UseBracketedOuterJoinSyntax" },
+ { DSID_IGNOREDRIVER_PRIV, "IgnoreDriverPrivileges" },
+ { DSID_PARAMETERNAMESUBST, "ParameterNameSubstitution" },
+ { DSID_SUPPRESSVERSIONCL, "DisplayVersionColumns" },
+ { DSID_CATALOG, "UseCatalogInSelect" },
+ { DSID_SCHEMA, "UseSchemaInSelect" },
+ { DSID_INDEXAPPENDIX, "UseIndexDirectionKeyword" },
+ { DSID_DOSLINEENDS, "UseDOSLineEnds" },
+ { DSID_BOOLEANCOMPARISON, "BooleanComparisonMode" },
+ { DSID_CHECK_REQUIRED_FIELDS, "FormsCheckRequiredFields" },
+ { DSID_IGNORECURRENCY, "IgnoreCurrency" },
+ { DSID_ESCAPE_DATETIME, "EscapeDateTime" },
+ { DSID_PRIMARY_KEY_SUPPORT, "PrimaryKeySupport" },
+ { DSID_MAX_ROW_SCAN, "MaxRowScan" },
+ { 0, NULL }
+ };
+ return s_aMappings;
+ }
+
+ //--------------------------------------------------------------------
+ static const FeatureSet& lcl_getFeatureSet( const ::rtl::OUString _rURL )
+ {
+ typedef ::std::map< ::rtl::OUString, FeatureSet, ::comphelper::UStringLess > FeatureSets;
+ static FeatureSets s_aFeatureSets;
+ if ( s_aFeatureSets.empty() )
+ {
+ ::connectivity::DriversConfig aDriverConfig( ::comphelper::getProcessServiceFactory() );
+ const uno::Sequence< ::rtl::OUString > aPatterns = aDriverConfig.getURLs();
+ for ( const ::rtl::OUString* pattern = aPatterns.getConstArray();
+ pattern != aPatterns.getConstArray() + aPatterns.getLength();
+ ++pattern
+ )
+ {
+ FeatureSet aCurrentSet;
+ const ::comphelper::NamedValueCollection aCurrentFeatures( aDriverConfig.getFeatures( *pattern ).getNamedValues() );
+
+ const FeatureMapping* pFeatureMapping = lcl_getFeatureMappings();
+ while ( pFeatureMapping->pAsciiFeatureName )
+ {
+ if ( aCurrentFeatures.has( pFeatureMapping->pAsciiFeatureName ) )
+ aCurrentSet.put( pFeatureMapping->nItemID );
+ ++pFeatureMapping;
+ }
+
+ s_aFeatureSets[ *pattern ] = aCurrentSet;
+ }
+ }
+
+ OSL_ENSURE( s_aFeatureSets.find( _rURL ) != s_aFeatureSets.end(), "invalid URL/pattern!" );
+ return s_aFeatureSets[ _rURL ];
+ }
+
+ //--------------------------------------------------------------------
+ static AuthenticationMode getAuthenticationMode( const ::rtl::OUString& _sURL )
+ {
+ DECLARE_STL_USTRINGACCESS_MAP( FeatureSupport, Supported);
+ static Supported s_aSupport;
+ if ( s_aSupport.empty() )
+ {
+ ::connectivity::DriversConfig aDriverConfig(::comphelper::getProcessServiceFactory());
+ const uno::Sequence< ::rtl::OUString > aURLs = aDriverConfig.getURLs();
+ const ::rtl::OUString* pIter = aURLs.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aURLs.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ FeatureSupport aInit( AuthNone );
+ const ::comphelper::NamedValueCollection& aMetaData = aDriverConfig.getMetaData(*pIter);
+ if ( aMetaData.has("Authentication") )
+ {
+ ::rtl::OUString sAuth;
+ aMetaData.get("Authentication") >>= sAuth;
+ if ( sAuth.equalsAscii("UserPassword") )
+ aInit = AuthUserPwd;
+ else if ( sAuth.equalsAscii("Password") )
+ aInit = AuthPwd;
+ }
+ s_aSupport.insert(Supported::value_type(*pIter,aInit));
+ }
+ }
+ OSL_ENSURE(s_aSupport.find(_sURL) != s_aSupport.end(),"Illegal URL!");
+ return s_aSupport[ _sURL ].eAuthentication;
+ }
+
+ //====================================================================
+ //= DataSourceMetaData_Impl
+ //====================================================================
+ class DataSourceMetaData_Impl
+ {
+ public:
+ DataSourceMetaData_Impl( const ::rtl::OUString& _sURL );
+
+ inline ::rtl::OUString getType() const { return m_sURL; }
+
+ private:
+ const ::rtl::OUString m_sURL;
+ };
+
+ //--------------------------------------------------------------------
+ DataSourceMetaData_Impl::DataSourceMetaData_Impl( const ::rtl::OUString& _sURL )
+ :m_sURL( _sURL )
+ {
+ }
+
+ //====================================================================
+ //= DataSourceMetaData
+ //====================================================================
+ //--------------------------------------------------------------------
+ DataSourceMetaData::DataSourceMetaData( const ::rtl::OUString& _sURL )
+ :m_pImpl( new DataSourceMetaData_Impl( _sURL ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DataSourceMetaData::~DataSourceMetaData()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ const FeatureSet& DataSourceMetaData::getFeatureSet() const
+ {
+ return lcl_getFeatureSet( m_pImpl->getType() );
+ }
+
+ //--------------------------------------------------------------------
+ AuthenticationMode DataSourceMetaData::getAuthentication( const ::rtl::OUString& _sURL )
+ {
+ return getAuthenticationMode( _sURL );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
diff --git a/dbaccess/source/ui/misc/imageprovider.cxx b/dbaccess/source/ui/misc/imageprovider.cxx
new file mode 100644
index 000000000000..ffeb18583ea9
--- /dev/null
+++ b/dbaccess/source/ui/misc/imageprovider.cxx
@@ -0,0 +1,261 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "imageprovider.hxx"
+#include "dbu_resource.hrc"
+#include "moduledbu.hxx"
+#include "dbustrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/graphic/GraphicColorMode.hpp>
+#include <com/sun/star/sdb/application/XTableUIProvider.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::graphic::XGraphic;
+ using ::com::sun::star::sdb::application::XTableUIProvider;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::sdbcx::XViewsSupplier;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ /** === end UNO using === **/
+ namespace GraphicColorMode = ::com::sun::star::graphic::GraphicColorMode;
+
+ //====================================================================
+ //= ImageProvider_Data
+ //====================================================================
+ struct ImageProvider_Data
+ {
+ /// the connection we work with
+ Reference< XConnection > xConnection;
+ /// the views of the connection, if the DB supports views
+ Reference< XNameAccess > xViews;
+ /// interface for providing table's UI
+ Reference< XTableUIProvider > xTableUI;
+ };
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //................................................................
+ static void lcl_getConnectionProvidedTableIcon_nothrow( const ImageProvider_Data& _rData,
+ const ::rtl::OUString& _rName, Reference< XGraphic >& _out_rxGraphic, Reference< XGraphic >& _out_rxGraphicHC )
+ {
+ try
+ {
+ if ( _rData.xTableUI.is() )
+ {
+ _out_rxGraphic = _rData.xTableUI->getTableIcon( _rName, GraphicColorMode::NORMAL );
+ _out_rxGraphicHC = _rData.xTableUI->getTableIcon( _rName, GraphicColorMode::HIGH_CONTRAST );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //................................................................
+ static void lcl_getTableImageResourceID_nothrow( const ImageProvider_Data& _rData, const ::rtl::OUString& _rName,
+ sal_uInt16& _out_rResourceID, sal_uInt16& _out_rResourceID_HC )
+ {
+ _out_rResourceID = _out_rResourceID_HC = 0;
+ try
+ {
+ bool bIsView = _rData.xViews.is() && _rData.xViews->hasByName( _rName );
+ if ( bIsView )
+ {
+ _out_rResourceID = VIEW_TREE_ICON;
+ _out_rResourceID_HC = VIEW_TREE_ICON_SCH;
+ }
+ else
+ {
+ _out_rResourceID = TABLE_TREE_ICON;
+ _out_rResourceID_HC = TABLE_TREE_ICON_SCH;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ //====================================================================
+ //= ImageProvider
+ //====================================================================
+ //--------------------------------------------------------------------
+ ImageProvider::ImageProvider()
+ :m_pData( new ImageProvider_Data )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ImageProvider::ImageProvider( const Reference< XConnection >& _rxConnection )
+ :m_pData( new ImageProvider_Data )
+ {
+ m_pData->xConnection = _rxConnection;
+ try
+ {
+ Reference< XViewsSupplier > xSuppViews( m_pData->xConnection, UNO_QUERY );
+ if ( xSuppViews.is() )
+ m_pData->xViews.set( xSuppViews->getViews(), UNO_SET_THROW );
+
+ m_pData->xTableUI.set( _rxConnection, UNO_QUERY );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ImageProvider::getImages( const String& _rName, const sal_Int32 _nDatabaseObjectType, Image& _out_rImage, Image& _out_rImageHC )
+ {
+ if ( _nDatabaseObjectType != DatabaseObject::TABLE )
+ {
+ // for types other than tables, the icon does not depend on the concrete object
+ _out_rImage = getDefaultImage( _nDatabaseObjectType, false );
+ _out_rImageHC = getDefaultImage( _nDatabaseObjectType, true );
+ }
+ else
+ {
+ // check whether the connection can give us an icon
+ Reference< XGraphic > xGraphic;
+ Reference< XGraphic > xGraphicHC;
+ lcl_getConnectionProvidedTableIcon_nothrow( *m_pData, _rName, xGraphic, xGraphicHC );
+ if ( xGraphic.is() )
+ _out_rImage = Image( xGraphic );
+ if ( xGraphicHC.is() )
+ _out_rImageHC = Image( xGraphicHC );
+
+ if ( !_out_rImage || !_out_rImageHC )
+ {
+ // no -> determine by type
+ sal_uInt16 nImageResourceID = 0;
+ sal_uInt16 nImageResourceID_HC = 0;
+ lcl_getTableImageResourceID_nothrow( *m_pData, _rName, nImageResourceID, nImageResourceID_HC );
+
+ if ( nImageResourceID && !_out_rImage )
+ _out_rImage = Image( ModuleRes( nImageResourceID ) );
+ if ( nImageResourceID_HC && !_out_rImageHC )
+ _out_rImageHC = Image( ModuleRes( nImageResourceID_HC ) );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Image ImageProvider::getDefaultImage( sal_Int32 _nDatabaseObjectType, bool _bHighContrast )
+ {
+ Image aObjectImage;
+ sal_uInt16 nImageResourceID( getDefaultImageResourceID( _nDatabaseObjectType, _bHighContrast ) );
+ if ( nImageResourceID )
+ aObjectImage = Image( ModuleRes( nImageResourceID ) );
+ return aObjectImage;
+ }
+
+ //--------------------------------------------------------------------
+ sal_uInt16 ImageProvider::getDefaultImageResourceID( sal_Int32 _nDatabaseObjectType, bool _bHighContrast )
+ {
+ sal_uInt16 nImageResourceID( 0 );
+ switch ( _nDatabaseObjectType )
+ {
+ case DatabaseObject::QUERY:
+ nImageResourceID = _bHighContrast ? QUERY_TREE_ICON_SCH : QUERY_TREE_ICON;
+ break;
+ case DatabaseObject::FORM:
+ nImageResourceID = _bHighContrast ? FORM_TREE_ICON_SCH : FORM_TREE_ICON;
+ break;
+ case DatabaseObject::REPORT:
+ nImageResourceID = _bHighContrast ? REPORT_TREE_ICON_SCH : REPORT_TREE_ICON;
+ break;
+ case DatabaseObject::TABLE:
+ nImageResourceID = _bHighContrast ? TABLE_TREE_ICON_SCH : TABLE_TREE_ICON;
+ break;
+ default:
+ OSL_ENSURE( false, "ImageProvider::getDefaultImage: invalid database object type!" );
+ break;
+ }
+ return nImageResourceID;
+ }
+
+ //--------------------------------------------------------------------
+ Image ImageProvider::getFolderImage( sal_Int32 _nDatabaseObjectType, bool _bHighContrast )
+ {
+ sal_uInt16 nImageResourceID( 0 );
+ switch ( _nDatabaseObjectType )
+ {
+ case DatabaseObject::QUERY:
+ nImageResourceID = _bHighContrast ? QUERYFOLDER_TREE_ICON_SCH : QUERYFOLDER_TREE_ICON;
+ break;
+ case DatabaseObject::FORM:
+ nImageResourceID = _bHighContrast ? FORMFOLDER_TREE_ICON_SCH : FORMFOLDER_TREE_ICON;
+ break;
+ case DatabaseObject::REPORT:
+ nImageResourceID = _bHighContrast ? REPORTFOLDER_TREE_ICON_SCH : REPORTFOLDER_TREE_ICON;
+ break;
+ case DatabaseObject::TABLE:
+ nImageResourceID = _bHighContrast ? TABLEFOLDER_TREE_ICON_SCH : TABLEFOLDER_TREE_ICON;
+ break;
+ default:
+ OSL_ENSURE( false, "ImageProvider::getDefaultImage: invalid database object type!" );
+ break;
+ }
+
+ Image aFolderImage;
+ if ( nImageResourceID )
+ aFolderImage = Image( ModuleRes( nImageResourceID ) );
+ return aFolderImage;
+ }
+
+ //--------------------------------------------------------------------
+ Image ImageProvider::getDatabaseImage( bool _bHighContrast )
+ {
+ return Image( ModuleRes( _bHighContrast ? DATABASE_TREE_ICON_SCH : DATABASE_TREE_ICON ) );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/indexcollection.cxx b/dbaccess/source/ui/misc/indexcollection.cxx
new file mode 100644
index 000000000000..038a9ea034ca
--- /dev/null
+++ b/dbaccess/source/ui/misc/indexcollection.cxx
@@ -0,0 +1,424 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_INDEXCOLLECTION_HXX_
+#include "indexcollection.hxx"
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::sdbc;
+
+ //==================================================================
+ //= OIndexCollection
+ //==================================================================
+ //------------------------------------------------------------------
+ OIndexCollection::OIndexCollection()
+ {
+ }
+
+ //------------------------------------------------------------------
+ OIndexCollection::OIndexCollection(const OIndexCollection& _rSource)
+ {
+ *this = _rSource;
+ }
+
+ //------------------------------------------------------------------
+// OIndexCollection::OIndexCollection(const Reference< XNameAccess >& _rxIndexes)
+// {
+// implConstructFrom(_rxIndexes);
+// }
+
+ //------------------------------------------------------------------
+ const OIndexCollection& OIndexCollection::operator=(const OIndexCollection& _rSource)
+ {
+ detach();
+ m_xIndexes = _rSource.m_xIndexes;
+ m_aIndexes = _rSource.m_aIndexes;
+ return *this;
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::attach(const Reference< XNameAccess >& _rxIndexes)
+ {
+ implConstructFrom(_rxIndexes);
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::detach()
+ {
+ m_xIndexes.clear();
+ m_aIndexes.clear();
+ }
+
+ //------------------------------------------------------------------
+ Indexes::const_iterator OIndexCollection::find(const String& _rName) const
+ {
+ ::rtl::OUString sNameCompare(_rName);
+
+ // loop'n'compare
+ Indexes::const_iterator aSearch = m_aIndexes.begin();
+ Indexes::const_iterator aEnd = m_aIndexes.end();
+ for (; aSearch != aEnd; ++aSearch)
+ if (aSearch->sName == sNameCompare)
+ break;
+
+ return aSearch;
+ }
+
+ //------------------------------------------------------------------
+ Indexes::iterator OIndexCollection::find(const String& _rName)
+ {
+ ::rtl::OUString sNameCompare(_rName);
+
+ // loop'n'compare
+ Indexes::iterator aSearch = m_aIndexes.begin();
+ Indexes::iterator aEnd = m_aIndexes.end();
+ for (; aSearch != aEnd; ++aSearch)
+ if (aSearch->sName == sNameCompare)
+ break;
+
+ return aSearch;
+ }
+
+ //------------------------------------------------------------------
+ Indexes::const_iterator OIndexCollection::findOriginal(const String& _rName) const
+ {
+ ::rtl::OUString sNameCompare(_rName);
+
+ // loop'n'compare
+ Indexes::const_iterator aSearch = m_aIndexes.begin();
+ Indexes::const_iterator aEnd = m_aIndexes.end();
+ for (; aSearch != aEnd; ++aSearch)
+ if (aSearch->getOriginalName() == sNameCompare)
+ break;
+
+ return aSearch;
+ }
+
+ //------------------------------------------------------------------
+ Indexes::iterator OIndexCollection::findOriginal(const String& _rName)
+ {
+ ::rtl::OUString sNameCompare(_rName);
+
+ // loop'n'compare
+ Indexes::iterator aSearch = m_aIndexes.begin();
+ Indexes::iterator aEnd = m_aIndexes.end();
+ for (; aSearch != aEnd; ++aSearch)
+ if (aSearch->getOriginalName() == sNameCompare)
+ break;
+
+ return aSearch;
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::commitNewIndex(const Indexes::iterator& _rPos) SAL_THROW((SQLException))
+ {
+ OSL_ENSURE(_rPos->isNew(), "OIndexCollection::commitNewIndex: index must be new!");
+
+ try
+ {
+ Reference< XDataDescriptorFactory > xIndexFactory(m_xIndexes, UNO_QUERY);
+ Reference< XAppend > xAppendIndex(xIndexFactory, UNO_QUERY);
+ if (!xAppendIndex.is())
+ {
+ OSL_ENSURE(sal_False, "OIndexCollection::commitNewIndex: missing an interface of the index container!");
+ return;
+ }
+
+ Reference< XPropertySet > xIndexDescriptor = xIndexFactory->createDataDescriptor();
+ Reference< XColumnsSupplier > xColsSupp(xIndexDescriptor, UNO_QUERY);
+ Reference< XNameAccess > xCols;
+ if (xColsSupp.is())
+ xCols = xColsSupp->getColumns();
+
+ Reference< XDataDescriptorFactory > xColumnFactory(xCols, UNO_QUERY);
+ Reference< XAppend > xAppendCols(xColumnFactory, UNO_QUERY);
+ if (!xAppendCols.is())
+ {
+ OSL_ENSURE(sal_False, "OIndexCollection::commitNewIndex: invalid index descriptor returned!");
+ return;
+ }
+
+ // set the properties
+ static const ::rtl::OUString s_sUniquePropertyName = ::rtl::OUString::createFromAscii("IsUnique");
+ static const ::rtl::OUString s_sSortPropertyName = ::rtl::OUString::createFromAscii("IsAscending");
+ static const ::rtl::OUString s_sNamePropertyName = ::rtl::OUString::createFromAscii("Name");
+ // the index' own props
+ xIndexDescriptor->setPropertyValue(s_sUniquePropertyName, ::cppu::bool2any(_rPos->bUnique));
+ xIndexDescriptor->setPropertyValue(s_sNamePropertyName, makeAny(_rPos->sName));
+
+ // the fields
+ for ( ConstIndexFieldsIterator aFieldLoop = _rPos->aFields.begin();
+ aFieldLoop != _rPos->aFields.end();
+ ++aFieldLoop
+ )
+ {
+ OSL_ENSURE(!xCols->hasByName(aFieldLoop->sFieldName), "OIndexCollection::commitNewIndex: double column name (need to prevent this outside)!");
+
+ Reference< XPropertySet > xColDescriptor = xColumnFactory->createDataDescriptor();
+ OSL_ENSURE(xColDescriptor.is(), "OIndexCollection::commitNewIndex: invalid column descriptor!");
+ if (xColDescriptor.is())
+ {
+ xColDescriptor->setPropertyValue(s_sSortPropertyName, ::cppu::bool2any(aFieldLoop->bSortAscending));
+ xColDescriptor->setPropertyValue(s_sNamePropertyName, makeAny(::rtl::OUString(aFieldLoop->sFieldName)));
+ xAppendCols->appendByDescriptor(xColDescriptor);
+ }
+ }
+
+ xAppendIndex->appendByDescriptor(xIndexDescriptor);
+
+ _rPos->flagAsCommitted(GrantIndexAccess());
+ _rPos->clearModified();
+ }
+ catch(SQLException&)
+ { // allowed to pass
+ throw;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OIndexCollection::dropNoRemove(const Indexes::iterator& _rPos) SAL_THROW((SQLException))
+ {
+ try
+ {
+ OSL_ENSURE(m_xIndexes->hasByName(_rPos->getOriginalName()), "OIndexCollection::drop: invalid name!");
+
+ Reference< XDrop > xDropIndex(m_xIndexes, UNO_QUERY);
+ if (!xDropIndex.is())
+ {
+ OSL_ENSURE(sal_False, "OIndexCollection::drop: no XDrop interface!");
+ return sal_False;
+ }
+
+ xDropIndex->dropByName(_rPos->getOriginalName());
+ }
+ catch(SQLException&)
+ { // allowed to pass
+ throw;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return sal_False;
+ }
+
+ // adjust the OIndex structure
+ Indexes::iterator aDropped = findOriginal(_rPos->getOriginalName());
+ OSL_ENSURE(aDropped != m_aIndexes.end(), "OIndexCollection::drop: invalid original name, but successfull commit?!");
+ aDropped->flagAsNew(GrantIndexAccess());
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OIndexCollection::drop(const Indexes::iterator& _rPos) SAL_THROW((SQLException))
+ {
+ OSL_ENSURE((_rPos >= m_aIndexes.begin()) && (_rPos < m_aIndexes.end()),
+ "OIndexCollection::drop: invalid position (fasten your seatbelt .... this will crash)!");
+
+ if (!_rPos->isNew())
+ if (!dropNoRemove(_rPos))
+ return sal_False;
+
+ // adjust the index array
+ m_aIndexes.erase(_rPos);
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::implFillIndexInfo(OIndex& _rIndex) SAL_THROW((Exception))
+ {
+ // get the UNO descriptor for the index
+ Reference< XPropertySet > xIndex;
+ m_xIndexes->getByName(_rIndex.getOriginalName()) >>= xIndex;
+ if (!xIndex.is())
+ {
+ OSL_ENSURE(sal_False, "OIndexCollection::implFillIndexInfo: got an invalid index object!");
+ }
+ else
+ implFillIndexInfo(_rIndex, xIndex);
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::implFillIndexInfo(OIndex& _rIndex, Reference< XPropertySet > _rxDescriptor) SAL_THROW((Exception))
+ {
+ static const ::rtl::OUString s_sPrimaryIndexPropertyName = ::rtl::OUString::createFromAscii("IsPrimaryKeyIndex");
+ static const ::rtl::OUString s_sUniquePropertyName = ::rtl::OUString::createFromAscii("IsUnique");
+ static const ::rtl::OUString s_sSortPropertyName = ::rtl::OUString::createFromAscii("IsAscending");
+ static const ::rtl::OUString s_sCatalogPropertyName = ::rtl::OUString::createFromAscii("Catalog");
+
+ _rIndex.bPrimaryKey = ::cppu::any2bool(_rxDescriptor->getPropertyValue(s_sPrimaryIndexPropertyName));
+ _rIndex.bUnique = ::cppu::any2bool(_rxDescriptor->getPropertyValue(s_sUniquePropertyName));
+ _rxDescriptor->getPropertyValue(s_sCatalogPropertyName) >>= _rIndex.sDescription;
+
+ // the columns
+ Reference< XColumnsSupplier > xSuppCols(_rxDescriptor, UNO_QUERY);
+ Reference< XNameAccess > xCols;
+ if (xSuppCols.is())
+ xCols = xSuppCols->getColumns();
+ OSL_ENSURE(xCols.is(), "OIndexCollection::implFillIndexInfo: the index does not have columns!");
+ if (xCols.is())
+ {
+ Sequence< ::rtl::OUString > aFieldNames = xCols->getElementNames();
+ _rIndex.aFields.resize(aFieldNames.getLength());
+
+ const ::rtl::OUString* pFieldNames = aFieldNames.getConstArray();
+ const ::rtl::OUString* pFieldNamesEnd = pFieldNames + aFieldNames.getLength();
+ IndexFields::iterator aCopyTo = _rIndex.aFields.begin();
+
+ Reference< XPropertySet > xIndexColumn;
+ for (;pFieldNames < pFieldNamesEnd; ++pFieldNames, ++aCopyTo)
+ {
+ // extract the column
+ xIndexColumn.clear();
+ xCols->getByName(*pFieldNames) >>= xIndexColumn;
+ if (!xIndexColumn.is())
+ {
+ OSL_ENSURE(sal_False, "OIndexCollection::implFillIndexInfo: invalid index column!");
+ --aCopyTo;
+ continue;
+ }
+
+ // get the relevant properties
+ aCopyTo->sFieldName = *pFieldNames;
+ aCopyTo->bSortAscending = ::cppu::any2bool(xIndexColumn->getPropertyValue(s_sSortPropertyName));
+ }
+
+ _rIndex.aFields.resize(aCopyTo - _rIndex.aFields.begin());
+ // (just in case some fields were invalid ...)
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::resetIndex(const Indexes::iterator& _rPos) SAL_THROW((SQLException))
+ {
+ OSL_ENSURE(_rPos >= m_aIndexes.begin() && _rPos < m_aIndexes.end(),
+ "OIndexCollection::resetIndex: invalid position!");
+
+ try
+ {
+ _rPos->sName = _rPos->getOriginalName();
+ implFillIndexInfo(*_rPos);
+
+ _rPos->clearModified();
+ _rPos->flagAsCommitted(GrantIndexAccess());
+ }
+ catch(SQLException&)
+ { // allowed to pass
+ throw;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------
+ Indexes::iterator OIndexCollection::insert(const String& _rName)
+ {
+ OSL_ENSURE(end() == find(_rName), "OIndexCollection::insert: invalid new name!");
+ String tmpName;
+ OIndex aNewIndex(tmpName); // the empty string indicates the index is a new one
+ aNewIndex.sName = _rName;
+ m_aIndexes.push_back(aNewIndex);
+ return m_aIndexes.end() - 1; // the last element is the new one ...
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::implConstructFrom(const Reference< XNameAccess >& _rxIndexes)
+ {
+ detach();
+
+ m_xIndexes = _rxIndexes;
+ if (m_xIndexes.is())
+ {
+ // loop through all the indexes
+ Sequence< ::rtl::OUString > aNames = m_xIndexes->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pNames + aNames.getLength();
+ for (; pNames < pEnd; ++pNames)
+ {
+ // extract the index object
+ Reference< XPropertySet > xIndex;
+ m_xIndexes->getByName(*pNames) >>= xIndex;
+ if (!xIndex.is())
+ {
+ OSL_ENSURE(sal_False, "OIndexCollection::implConstructFrom: got an invalid index object ... ignoring!");
+ continue;
+ }
+
+ // fill the OIndex structure
+ OIndex aCurrentIndex(*pNames);
+ implFillIndexInfo(aCurrentIndex);
+ m_aIndexes.push_back(aCurrentIndex);
+ }
+ }
+ }
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
diff --git a/dbaccess/source/ui/misc/linkeddocuments.cxx b/dbaccess/source/ui/misc/linkeddocuments.cxx
new file mode 100644
index 000000000000..fb1c3d390a05
--- /dev/null
+++ b/dbaccess/source/ui/misc/linkeddocuments.cxx
@@ -0,0 +1,476 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_LINKEDDOCUMENTS_HXX_
+#include "linkeddocuments.hxx"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#include <tools/diagnose_ex.h>
+#include <unotools/confignode.hxx>
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#include <comphelper/classids.hxx>
+#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
+#include <comphelper/namedvaluecollection.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
+#include <com/sun/star/util/URL.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_OPENCOMMANDARGUMENT_HPP_
+#include <com/sun/star/ucb/OpenCommandArgument.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_OPENMODE_HPP_
+#include <com/sun/star/ucb/OpenMode.hpp>
+#endif
+#ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_
+#include <com/sun/star/task/XJobExecutor.hpp>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _UCBHELPER_CONTENT_HXX
+#include <ucbhelper/content.hxx>
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX_
+#include <svl/filenotation.hxx>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _SFXNEW_HXX
+#include <sfx2/new.hxx>
+#endif
+#ifndef _SVTOOLS_TEMPLDLG_HXX
+#include <svtools/templdlg.hxx>
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+// -----------------
+// for calling basic
+#ifndef _SFXAPP_HXX
+#include <sfx2/app.hxx>
+#endif
+#ifndef _SBXCLASS_HXX
+#include <basic/sbx.hxx>
+#endif
+#ifndef _SB_SBUNO_HXX
+#include <basic/sbuno.hxx>
+#endif
+#ifndef _EHDL_HXX
+#include <svtools/ehdl.hxx>
+#endif
+#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
+#include <svx/dataaccessdescriptor.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMECONTAINER_HPP_
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#endif
+#ifndef _SV_WAITOBJ_HXX
+#include <vcl/waitobj.hxx>
+#endif
+#ifndef _COMPHELPER_MIMECONFIGHELPER_HXX_
+#include <comphelper/mimeconfighelper.hxx>
+#endif
+
+#include <cppuhelper/exc_hlp.hxx>
+#include <connectivity/dbtools.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <com/sun/star/io/WrongFormatException.hpp>
+#include "com/sun/star/sdb/RowSetVetoException.hpp"
+
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::ucb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb::application;
+ using namespace ::com::sun::star::task;
+ using namespace ::svt;
+
+ namespace
+ {
+ Sequence< sal_Int8 > lcl_GetSequenceClassID( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
+ sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
+ sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 )
+ {
+ Sequence< sal_Int8 > aResult( 16 );
+ aResult[0] = static_cast<sal_Int8>(n1 >> 24);
+ aResult[1] = static_cast<sal_Int8>(( n1 << 8 ) >> 24);
+ aResult[2] = static_cast<sal_Int8>(( n1 << 16 ) >> 24);
+ aResult[3] = static_cast<sal_Int8>(( n1 << 24 ) >> 24);
+ aResult[4] = static_cast<sal_Int8>(n2 >> 8);
+ aResult[5] = static_cast<sal_Int8>(( n2 << 8 ) >> 8);
+ aResult[6] = static_cast<sal_Int8>(n3 >> 8);
+ aResult[7] = static_cast<sal_Int8>(( n3 << 8 ) >> 8);
+ aResult[8] = b8;
+ aResult[9] = b9;
+ aResult[10] = b10;
+ aResult[11] = b11;
+ aResult[12] = b12;
+ aResult[13] = b13;
+ aResult[14] = b14;
+ aResult[15] = b15;
+
+ return aResult;
+ }
+ }
+
+
+ //==================================================================
+ //= OLinkedDocumentsAccess
+ //==================================================================
+ DBG_NAME(OLinkedDocumentsAccess)
+ //------------------------------------------------------------------
+ OLinkedDocumentsAccess::OLinkedDocumentsAccess( Window* _pDialogParent, const Reference< XDatabaseDocumentUI >& i_rDocumentUI,
+ const Reference< XMultiServiceFactory >& _rxORB, const Reference< XNameAccess >& _rxContainer,
+ const Reference< XConnection>& _xConnection, const ::rtl::OUString& _sDataSourceName )
+ :m_xORB(_rxORB)
+ ,m_xDocumentContainer(_rxContainer)
+ ,m_xConnection(_xConnection)
+ ,m_xDocumentUI( i_rDocumentUI )
+ ,m_pDialogParent(_pDialogParent)
+ ,m_sDataSourceName(_sDataSourceName)
+ {
+ DBG_CTOR(OLinkedDocumentsAccess,NULL);
+ OSL_ENSURE(m_xORB.is(), "OLinkedDocumentsAccess::OLinkedDocumentsAccess: invalid service factory!");
+ OSL_ENSURE(m_pDialogParent, "OLinkedDocumentsAccess::OLinkedDocumentsAccess: really need a dialog parent!");
+ }
+ //------------------------------------------------------------------
+ OLinkedDocumentsAccess::~OLinkedDocumentsAccess()
+ {
+ DBG_DTOR(OLinkedDocumentsAccess,NULL);
+ }
+ //------------------------------------------------------------------
+ Reference< XComponent> OLinkedDocumentsAccess::impl_open( const ::rtl::OUString& _rLinkName, Reference< XComponent >& _xDefinition,
+ ElementOpenMode _eOpenMode, const ::comphelper::NamedValueCollection& _rAdditionalArgs )
+ {
+ Reference< XComponent> xRet;
+ OSL_ENSURE(m_xDocumentContainer.is(), "OLinkedDocumentsAccess::OLinkedDocumentsAccess: invalid document container!");
+ Reference< XComponentLoader > xComponentLoader(m_xDocumentContainer,UNO_QUERY);
+ if ( !xComponentLoader.is() )
+ return xRet;
+
+ WaitObject aWaitCursor( m_pDialogParent );
+
+ ::comphelper::NamedValueCollection aArguments;
+ ::rtl::OUString sOpenMode;
+ switch ( _eOpenMode )
+ {
+ case E_OPEN_NORMAL:
+ sOpenMode = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) );
+ break;
+
+ case E_OPEN_FOR_MAIL:
+ aArguments.put( "Hidden", true );
+ // fall through
+
+ case E_OPEN_DESIGN:
+ sOpenMode = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "openDesign" ) );
+ break;
+
+ default:
+ OSL_ENSURE( false, "OLinkedDocumentsAccess::implOpen: invalid open mode!" );
+ break;
+ }
+ aArguments.put( "OpenMode", sOpenMode );
+
+ aArguments.put( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, m_xConnection );
+ try
+ {
+ Reference<XHierarchicalNameContainer> xHier(m_xDocumentContainer,UNO_QUERY);
+ if ( xHier.is() && xHier->hasByHierarchicalName(_rLinkName) )
+ {
+ _xDefinition.set(xHier->getByHierarchicalName(_rLinkName),UNO_QUERY);
+ }
+
+ aArguments.merge( _rAdditionalArgs, true );
+
+ xRet = xComponentLoader->loadComponentFromURL( _rLinkName, ::rtl::OUString(), 0, aArguments.getPropertyValues() );
+ }
+ catch(Exception& e)
+ {
+ (void)e;
+ throw;
+ }
+
+ return xRet;
+ }
+ //------------------------------------------------------------------
+ void OLinkedDocumentsAccess::impl_newWithPilot( const char* _pWizardService,
+ const sal_Int32 _nCommandType, const ::rtl::OUString& _rObjectName )
+ {
+ try
+ {
+ ::comphelper::NamedValueCollection aArgs;
+ aArgs.put( "DataSourceName", m_sDataSourceName );
+
+ if ( m_xConnection.is() )
+ aArgs.put( "ActiveConnection", m_xConnection );
+
+ if ( _rObjectName.getLength() && ( _nCommandType != -1 ) )
+ {
+ aArgs.put( "CommandType", _nCommandType );
+ aArgs.put( "Command", _rObjectName );
+ }
+
+ aArgs.put( "DocumentUI", m_xDocumentUI );
+
+ Reference< XJobExecutor > xWizard;
+ {
+ WaitObject aWaitCursor( m_pDialogParent );
+ xWizard.set( m_xORB->createInstanceWithArguments(
+ ::rtl::OUString::createFromAscii( _pWizardService ),
+ aArgs.getWrappedPropertyValues()
+ ), UNO_QUERY_THROW );
+ }
+
+ xWizard->trigger( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "start" ) ) );
+ ::comphelper::disposeComponent( xWizard );
+ }
+ catch(const Exception& e)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ //------------------------------------------------------------------
+ void OLinkedDocumentsAccess::newFormWithPilot( const sal_Int32 _nCommandType,const ::rtl::OUString& _rObjectName )
+ {
+ impl_newWithPilot( "com.sun.star.wizards.form.CallFormWizard", _nCommandType, _rObjectName );
+ }
+
+ //------------------------------------------------------------------
+ void OLinkedDocumentsAccess::newReportWithPilot( const sal_Int32 _nCommandType, const ::rtl::OUString& _rObjectName )
+ {
+ impl_newWithPilot( "com.sun.star.wizards.report.CallReportWizard", _nCommandType, _rObjectName );
+ }
+ //------------------------------------------------------------------
+ void OLinkedDocumentsAccess::newTableWithPilot()
+ {
+ impl_newWithPilot( "com.sun.star.wizards.table.CallTableWizard", -1, ::rtl::OUString() );
+ }
+ //------------------------------------------------------------------
+ void OLinkedDocumentsAccess::newQueryWithPilot()
+ {
+ impl_newWithPilot( "com.sun.star.wizards.query.CallQueryWizard", -1, ::rtl::OUString() );
+ }
+ //------------------------------------------------------------------
+ Reference< XComponent > OLinkedDocumentsAccess::newDocument( sal_Int32 i_nActionID,
+ const ::comphelper::NamedValueCollection& i_rCreationArgs, Reference< XComponent >& o_rDefinition )
+ {
+ OSL_ENSURE(m_xDocumentContainer.is(), "OLinkedDocumentsAccess::newDocument: invalid document container!");
+ // determine the class ID to use for the new document
+ Sequence<sal_Int8> aClassId;
+ if ( !i_rCreationArgs.has( "ClassID" )
+ && !i_rCreationArgs.has( "MediaType" )
+ && !i_rCreationArgs.has( "DocumentServiceName" )
+ )
+ {
+ switch ( i_nActionID )
+ {
+ case ID_FORM_NEW_TEXT:
+ aClassId = lcl_GetSequenceClassID(SO3_SW_CLASSID);
+ OSL_ENSURE(aClassId == comphelper::MimeConfigurationHelper::GetSequenceClassID(SO3_SW_CLASSID),"Not equal");
+ break;
+
+ case ID_FORM_NEW_CALC:
+ aClassId = lcl_GetSequenceClassID(SO3_SC_CLASSID);
+ break;
+
+ case ID_FORM_NEW_IMPRESS:
+ aClassId = lcl_GetSequenceClassID(SO3_SIMPRESS_CLASSID);
+ break;
+
+ case ID_REPORT_NEW_TEXT:
+ aClassId = comphelper::MimeConfigurationHelper::GetSequenceClassID(SO3_RPT_CLASSID_90);
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "OLinkedDocumentsAccess::newDocument: please use newFormWithPilot!" );
+ return Reference< XComponent >();
+
+ }
+ }
+
+ // load the document as template
+ Reference< XComponent > xNewDocument;
+ try
+ { // get the desktop object
+
+ Reference<XMultiServiceFactory> xORB(m_xDocumentContainer,UNO_QUERY);
+ if ( xORB.is() )
+ {
+ ::comphelper::NamedValueCollection aCreationArgs( i_rCreationArgs );
+ if ( aClassId.getLength() )
+ aCreationArgs.put( "ClassID", aClassId );
+ aCreationArgs.put( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, m_xConnection );
+
+ // separate values which are real creation args from args relevant for opening the doc
+ ::comphelper::NamedValueCollection aCommandArgs;
+ if ( aCreationArgs.has( "Hidden" ) )
+ {
+ aCommandArgs.put( "Hidden", aCreationArgs.get( "Hidden" ) );
+ aCreationArgs.remove( "Hidden" );
+ }
+
+ Reference< XCommandProcessor > xContent( xORB->createInstanceWithArguments(
+ SERVICE_SDB_DOCUMENTDEFINITION,
+ aCreationArgs.getWrappedPropertyValues()
+ ),
+ UNO_QUERY_THROW
+ );
+ o_rDefinition.set( xContent, UNO_QUERY );
+
+ // put the OpenMode into the OpenArgs
+ OpenCommandArgument aOpenModeArg;
+ aOpenModeArg.Mode = OpenMode::DOCUMENT;
+ aCommandArgs.put( "OpenMode", aOpenModeArg );
+
+ Command aCommand;
+ aCommand.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "openDesign" ) );
+ aCommand.Argument <<= aCommandArgs.getPropertyValues();
+ WaitObject aWaitCursor( m_pDialogParent );
+ xNewDocument.set( xContent->execute( aCommand, xContent->createCommandIdentifier(), NULL ), UNO_QUERY );
+ }
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xNewDocument;
+ }
+
+ //------------------------------------------------------------------
+ Reference< XComponent > OLinkedDocumentsAccess::open( const ::rtl::OUString& _rLinkName, Reference< XComponent >& _xDefinition,
+ ElementOpenMode _eOpenMode, const ::comphelper::NamedValueCollection& _rAdditionalArgs )
+ {
+ dbtools::SQLExceptionInfo aInfo;
+ Reference< XComponent > xRet;
+ try
+ {
+ xRet = impl_open( _rLinkName, _xDefinition, _eOpenMode, _rAdditionalArgs );
+ if ( !xRet.is() )
+ {
+ String sMessage = String(ModuleRes(STR_COULDNOTOPEN_LINKEDDOC));
+ sMessage.SearchAndReplaceAscii("$file$",_rLinkName);
+
+ com::sun::star::sdbc::SQLException aSQLException;
+ aSQLException.Message = sMessage;
+ // aSQLException.Context = e.Context;
+ aInfo = dbtools::SQLExceptionInfo(aSQLException);
+ }
+ return xRet;
+ }
+ catch (com::sun::star::io::WrongFormatException e)
+ {
+ com::sun::star::sdbc::SQLException aSQLException;
+ aSQLException.Message = e.Message;
+ aSQLException.Context = e.Context;
+ aInfo = dbtools::SQLExceptionInfo(aSQLException);
+
+ // more like a hack, insert an empty message
+ String sText( ModuleRes( RID_STR_EXTENSION_NOT_PRESENT ) );
+ sText.SearchAndReplaceAscii("$file$",_rLinkName);
+ aInfo.prepend(sText);
+
+ String sMessage = String(ModuleRes(STR_COULDNOTOPEN_LINKEDDOC));
+ sMessage.SearchAndReplaceAscii("$file$",_rLinkName);
+ aInfo.prepend(sMessage);
+ }
+ catch(Exception& e)
+ {
+ Any aAny = ::cppu::getCaughtException();
+ com::sun::star::sdbc::SQLException a;
+ if ( !(aAny >>= a) || (a.ErrorCode != dbtools::ParameterInteractionCancelled) )
+ {
+ com::sun::star::sdbc::SQLException aSQLException;
+ aSQLException.Message = e.Message;
+ aSQLException.Context = e.Context;
+ aInfo = dbtools::SQLExceptionInfo(aSQLException);
+
+ // more like a hack, insert an empty message
+ aInfo.prepend(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" \n")));
+
+ String sMessage = String(ModuleRes(STR_COULDNOTOPEN_LINKEDDOC));
+ sMessage.SearchAndReplaceAscii("$file$",_rLinkName);
+ aInfo.prepend(sMessage);
+ }
+ }
+ if (aInfo.isValid())
+ {
+ showError(aInfo, VCLUnoHelper::GetInterface(m_pDialogParent), m_xORB );
+ }
+ return xRet;
+ }
+
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
diff --git a/dbaccess/source/ui/misc/makefile.mk b/dbaccess/source/ui/misc/makefile.mk
new file mode 100644
index 000000000000..534d90e3995c
--- /dev/null
+++ b/dbaccess/source/ui/misc/makefile.mk
@@ -0,0 +1,88 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=../../..
+PRJINC=$(PRJ)/source
+PRJNAME=dbaccess
+TARGET=uimisc
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)/util/makefile.pmk
+
+# --- Files -------------------------------------
+
+# ... resource files ............................
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ dbumiscres.src \
+ WizardPages.src
+
+# ... object files ............................
+
+SLOFILES= \
+ $(SLO)/asyncmodaldialog.obj \
+ $(SLO)/imageprovider.obj \
+ $(SLO)/singledoccontroller.obj \
+ $(SLO)/dbsubcomponentcontroller.obj \
+ $(SLO)/datasourceconnector.obj \
+ $(SLO)/linkeddocuments.obj \
+ $(SLO)/indexcollection.obj \
+ $(SLO)/UITools.obj \
+ $(SLO)/WCPage.obj \
+ $(SLO)/WCopyTable.obj \
+ $(SLO)/WTypeSelect.obj \
+ $(SLO)/TokenWriter.obj \
+ $(SLO)/HtmlReader.obj \
+ $(SLO)/RtfReader.obj \
+ $(SLO)/propertysetitem.obj \
+ $(SLO)/databaseobjectview.obj \
+ $(SLO)/DExport.obj \
+ $(SLO)/uiservices.obj \
+ $(SLO)/RowSetDrop.obj \
+ $(SLO)/TableCopyHelper.obj \
+ $(SLO)/moduledbu.obj \
+ $(SLO)/WColumnSelect.obj \
+ $(SLO)/WExtendPages.obj \
+ $(SLO)/WNameMatch.obj \
+ $(SLO)/ToolBoxHelper.obj \
+ $(SLO)/stringlistitem.obj \
+ $(SLO)/charsets.obj \
+ $(SLO)/defaultobjectnamecheck.obj \
+ $(SLO)/dsmeta.obj \
+ $(SLO)/controllerframe.obj \
+ $(SLO)/propertystorage.obj \
+ $(SLO)/dbaundomanager.obj \
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/ui/misc/moduledbu.cxx b/dbaccess/source/ui/misc/moduledbu.cxx
new file mode 100644
index 000000000000..536821f6e26e
--- /dev/null
+++ b/dbaccess/source/ui/misc/moduledbu.cxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+
+#ifndef _TOOLS_RESMGR_HXX
+#include <tools/resmgr.hxx>
+#endif
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#define ENTER_MOD_METHOD() \
+ ::osl::MutexGuard aGuard(s_aMutex); \
+ ensureImpl()
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//=========================================================================
+//= OModuleImpl
+//=========================================================================
+/** implementation for <type>OModule</type>. not threadsafe, has to be guarded by it's owner
+*/
+class OModuleImpl
+{
+ ResMgr* m_pRessources;
+
+public:
+ /// ctor
+ OModuleImpl();
+ ~OModuleImpl();
+
+ /// get the manager for the ressources of the module
+ ResMgr* getResManager();
+};
+
+DBG_NAME(OModuleImpl)
+//-------------------------------------------------------------------------
+OModuleImpl::OModuleImpl()
+ :m_pRessources(NULL)
+{
+ DBG_CTOR(OModuleImpl,NULL);
+
+}
+
+//-------------------------------------------------------------------------
+OModuleImpl::~OModuleImpl()
+{
+ if (m_pRessources)
+ delete m_pRessources;
+
+ DBG_DTOR(OModuleImpl,NULL);
+}
+
+//-------------------------------------------------------------------------
+ResMgr* OModuleImpl::getResManager()
+{
+ // note that this method is not threadsafe, which counts for the whole class !
+
+ if (!m_pRessources)
+ {
+ // create a manager with a fixed prefix
+ ByteString aMgrName = ByteString( "dbu" );
+ m_pRessources = ResMgr::CreateResMgr(aMgrName.GetBuffer());
+ }
+ return m_pRessources;
+}
+
+//=========================================================================
+//= OModule
+//=========================================================================
+::osl::Mutex OModule::s_aMutex;
+sal_Int32 OModule::s_nClients = 0;
+OModuleImpl* OModule::s_pImpl = NULL;
+//-------------------------------------------------------------------------
+ResMgr* OModule::getResManager()
+{
+ ENTER_MOD_METHOD();
+ return s_pImpl->getResManager();
+}
+
+//-------------------------------------------------------------------------
+void OModule::registerClient()
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ++s_nClients;
+}
+
+//-------------------------------------------------------------------------
+void OModule::revokeClient()
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ if (!--s_nClients && s_pImpl)
+ {
+ delete s_pImpl;
+ s_pImpl = NULL;
+ }
+}
+
+//-------------------------------------------------------------------------
+void OModule::ensureImpl()
+{
+ if (s_pImpl)
+ return;
+ s_pImpl = new OModuleImpl();
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/misc/propertysetitem.cxx b/dbaccess/source/ui/misc/propertysetitem.cxx
new file mode 100644
index 000000000000..89672d194765
--- /dev/null
+++ b/dbaccess/source/ui/misc/propertysetitem.cxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_PROPERTYSETITEM_HXX_
+#include "propertysetitem.hxx"
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+
+ //=========================================================================
+ //= OPropertySetItem
+ //=========================================================================
+ TYPEINIT1(OPropertySetItem, SfxPoolItem);
+ //-------------------------------------------------------------------------
+ OPropertySetItem::OPropertySetItem(sal_Int16 _nWhich)
+ :SfxPoolItem(_nWhich)
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ OPropertySetItem::OPropertySetItem(sal_Int16 _nWhich, const Reference< XPropertySet >& _rxSet)
+ :SfxPoolItem(_nWhich)
+ ,m_xSet(_rxSet)
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ OPropertySetItem::OPropertySetItem(const OPropertySetItem& _rSource)
+ :SfxPoolItem(_rSource)
+ ,m_xSet(_rSource.m_xSet)
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ int OPropertySetItem::operator==(const SfxPoolItem& _rItem) const
+ {
+ const OPropertySetItem* pCompare = PTR_CAST(OPropertySetItem, &_rItem);
+ if ((!pCompare) || (pCompare->m_xSet.get() != m_xSet.get()))
+ return 0;
+
+ return 1;
+ }
+
+ //-------------------------------------------------------------------------
+ SfxPoolItem* OPropertySetItem::Clone(SfxItemPool* /* _pPool */) const
+ {
+ return new OPropertySetItem(*this);
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/misc/propertystorage.cxx b/dbaccess/source/ui/misc/propertystorage.cxx
new file mode 100644
index 000000000000..83ac5d36bd30
--- /dev/null
+++ b/dbaccess/source/ui/misc/propertystorage.cxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "propertystorage.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <svl/itemset.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= PropertyStorage
+ //====================================================================
+ //--------------------------------------------------------------------
+ PropertyStorage::~PropertyStorage()
+ {
+ }
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ //----------------------------------------------------------------
+ template < class ITEMTYPE, class UNOTYPE >
+ class ItemAdapter
+ {
+ public:
+ static bool trySet( SfxItemSet& _rSet, ItemId _nItemId, const Any& _rValue )
+ {
+ const SfxPoolItem& rItem( _rSet.Get( _nItemId ) );
+ const ITEMTYPE* pTypedItem = dynamic_cast< const ITEMTYPE* >( &rItem );
+ if ( !pTypedItem )
+ return false;
+
+ UNOTYPE aValue( pTypedItem->GetValue() );
+ OSL_VERIFY( _rValue >>= aValue );
+ // TODO: one could throw an IllegalArgumentException here - finally, this method
+ // is (to be) used from within an XPropertySet::setPropertyValue implementation,
+ // where this would be the appropriate reaction on wrong value types
+ ::std::auto_ptr< ITEMTYPE > pClone( dynamic_cast< ITEMTYPE* >( pTypedItem->Clone() ) );
+ pClone->SetValue( aValue );
+ _rSet.Put( *pClone );
+ return true;
+ }
+
+ static bool tryGet( const SfxPoolItem& _rItem, Any& _out_rValue )
+ {
+ const ITEMTYPE* pTypedItem = dynamic_cast< const ITEMTYPE* >( &_rItem );
+ if ( !pTypedItem )
+ return false;
+
+ _out_rValue <<= UNOTYPE( pTypedItem->GetValue() );
+ return true;
+ }
+ };
+ }
+
+ //====================================================================
+ //= SetItemPropertyStorage
+ //====================================================================
+ //--------------------------------------------------------------------
+ void SetItemPropertyStorage::getPropertyValue( Any& _out_rValue ) const
+ {
+ const SfxPoolItem& rItem( m_rItemSet.Get( m_nItemID ) );
+
+ // try some known item types
+ if ( ItemAdapter< SfxBoolItem, sal_Bool >::tryGet( rItem, _out_rValue )
+ || ItemAdapter< SfxStringItem, ::rtl::OUString >::tryGet( rItem, _out_rValue )
+ )
+ return;
+
+ OSL_ENSURE( false, "SetItemPropertyStorage::getPropertyValue: unsupported item type!" );
+ }
+
+ //--------------------------------------------------------------------
+ void SetItemPropertyStorage::setPropertyValue( const Any& _rValue )
+ {
+ // try some known item types
+ if ( ItemAdapter< SfxBoolItem, sal_Bool >::trySet( m_rItemSet, m_nItemID, _rValue )
+ || ItemAdapter< SfxStringItem, ::rtl::OUString >::trySet( m_rItemSet, m_nItemID, _rValue )
+ )
+ return;
+
+ OSL_ENSURE( false, "SetItemPropertyStorage::setPropertyValue: unsupported item type!" );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
diff --git a/dbaccess/source/ui/misc/singledoccontroller.cxx b/dbaccess/source/ui/misc/singledoccontroller.cxx
new file mode 100755
index 000000000000..2e8c002a2097
--- /dev/null
+++ b/dbaccess/source/ui/misc/singledoccontroller.cxx
@@ -0,0 +1,200 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_dbaccess.hxx"
+
+#include "dbaundomanager.hxx"
+#include "singledoccontroller.hxx"
+#include "browserids.hxx"
+#include "dbu_misc.hrc"
+#include "dbustrings.hrc"
+#include "moduledbu.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <svl/undo.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+//......................................................................................................................
+namespace dbaui
+{
+//......................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::document::XUndoManager;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::lang::EventObject;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= OSingleDocumentController_Data
+ //==================================================================================================================
+ struct OSingleDocumentController_Data
+ {
+ ::boost::scoped_ptr< UndoManager > m_pUndoManager;
+
+ OSingleDocumentController_Data( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ :m_pUndoManager( new UndoManager( i_parent, i_mutex ) )
+ {
+ }
+ };
+
+ //==================================================================================================================
+ //= OSingleDocumentController
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ OSingleDocumentController::OSingleDocumentController( const Reference< XMultiServiceFactory >& _rxORB )
+ :OSingleDocumentController_Base( _rxORB )
+ ,m_pData( new OSingleDocumentController_Data( *this, getMutex() ) )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ OSingleDocumentController::~OSingleDocumentController()
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OSingleDocumentController::disposing()
+ {
+ OSingleDocumentController_Base::disposing();
+ ClearUndoManager();
+ m_pData->m_pUndoManager->disposing();
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OSingleDocumentController::disposing( const EventObject& i_event ) throw( RuntimeException )
+ {
+ // simply disambiguate
+ OSingleDocumentController_Base::disposing( i_event );
+ }
+
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::ClearUndoManager()
+ {
+ GetUndoManager().Clear();
+ }
+
+ // -----------------------------------------------------------------------------
+ SfxUndoManager& OSingleDocumentController::GetUndoManager() const
+ {
+ return m_pData->m_pUndoManager->GetSfxUndoManager();
+ }
+
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::addUndoActionAndInvalidate(SfxUndoAction *_pAction)
+ {
+ // add undo action
+ GetUndoManager().AddUndoAction( _pAction );
+
+ // when we add an undo action the controller was modified
+ setModified( sal_True );
+
+ // now inform me that or states changed
+ InvalidateFeature( ID_BROWSER_UNDO );
+ InvalidateFeature( ID_BROWSER_REDO );
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XUndoManager > SAL_CALL OSingleDocumentController::getUndoManager( ) throw (RuntimeException)
+ {
+ return m_pData->m_pUndoManager.get();
+ }
+
+ // -----------------------------------------------------------------------------
+ FeatureState OSingleDocumentController::GetState(sal_uInt16 _nId) const
+ {
+ FeatureState aReturn;
+ switch ( _nId )
+ {
+ case ID_BROWSER_UNDO:
+ aReturn.bEnabled = isEditable() && GetUndoManager().GetUndoActionCount() != 0;
+ if ( aReturn.bEnabled )
+ {
+ String sUndo(ModuleRes(STR_UNDO_COLON));
+ sUndo += String(RTL_CONSTASCII_USTRINGPARAM(" "));
+ sUndo += GetUndoManager().GetUndoActionComment();
+ aReturn.sTitle = sUndo;
+ }
+ break;
+
+ case ID_BROWSER_REDO:
+ aReturn.bEnabled = isEditable() && GetUndoManager().GetRedoActionCount() != 0;
+ if ( aReturn.bEnabled )
+ {
+ String sRedo(ModuleRes(STR_REDO_COLON));
+ sRedo += String(RTL_CONSTASCII_USTRINGPARAM(" "));
+ sRedo += GetUndoManager().GetRedoActionComment();
+ aReturn.sTitle = sRedo;
+ }
+ break;
+
+ default:
+ aReturn = OSingleDocumentController_Base::GetState(_nId);
+ }
+ return aReturn;
+ }
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::Execute( sal_uInt16 _nId, const Sequence< PropertyValue >& _rArgs )
+ {
+ switch ( _nId )
+ {
+ case ID_BROWSER_UNDO:
+ GetUndoManager().Undo();
+ InvalidateFeature( ID_BROWSER_UNDO );
+ InvalidateFeature( ID_BROWSER_REDO );
+ break;
+
+ case ID_BROWSER_REDO:
+ GetUndoManager().Redo();
+ InvalidateFeature( ID_BROWSER_UNDO );
+ InvalidateFeature( ID_BROWSER_REDO );
+ break;
+
+ default:
+ OSingleDocumentController_Base::Execute( _nId, _rArgs );
+ break;
+ }
+ InvalidateFeature(_nId);
+ }
+
+//......................................................................................................................
+} // namespace dbaui
+//......................................................................................................................
diff --git a/dbaccess/source/ui/misc/stringlistitem.cxx b/dbaccess/source/ui/misc/stringlistitem.cxx
new file mode 100644
index 000000000000..6fd6d0c4b9d1
--- /dev/null
+++ b/dbaccess/source/ui/misc/stringlistitem.cxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_STRINGLISTITEM_HXX_
+#include "stringlistitem.hxx"
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+using namespace ::com::sun::star::uno;
+
+//=========================================================================
+//= OStringListItem
+//=========================================================================
+TYPEINIT1(OStringListItem, SfxPoolItem);
+//-------------------------------------------------------------------------
+OStringListItem::OStringListItem(sal_Int16 _nWhich, const Sequence< ::rtl::OUString >& _rList)
+ :SfxPoolItem(_nWhich)
+ ,m_aList(_rList)
+{
+}
+
+//-------------------------------------------------------------------------
+OStringListItem::OStringListItem(const OStringListItem& _rSource)
+ :SfxPoolItem(_rSource)
+ ,m_aList(_rSource.m_aList)
+{
+}
+
+//-------------------------------------------------------------------------
+int OStringListItem::operator==(const SfxPoolItem& _rItem) const
+{
+ const OStringListItem* pCompare = PTR_CAST(OStringListItem, &_rItem);
+ if ((!pCompare) || (pCompare->m_aList.getLength() != m_aList.getLength()))
+ return 0;
+
+ // compare all strings individually
+ const ::rtl::OUString* pMyStrings = m_aList.getConstArray();
+ const ::rtl::OUString* pCompareStrings = pCompare->m_aList.getConstArray();
+
+ for (sal_Int32 i=0; i<m_aList.getLength(); ++i, ++pMyStrings, ++pCompareStrings)
+ if (!pMyStrings->equals(*pCompareStrings))
+ return 0;
+
+ return 1;
+}
+
+//-------------------------------------------------------------------------
+SfxPoolItem* OStringListItem::Clone(SfxItemPool* /* _pPool */) const
+{
+ return new OStringListItem(*this);
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/misc/uiservices.cxx b/dbaccess/source/ui/misc/uiservices.cxx
new file mode 100644
index 000000000000..0c5a37e31378
--- /dev/null
+++ b/dbaccess/source/ui/misc/uiservices.cxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _CPPUHELPER_FACTORY_HXX_
+#include <cppuhelper/factory.hxx>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef INCLUDED_DBACCESSDLLAPI_H
+#include "dbaccessdllapi.h"
+#endif
+
+/********************************************************************************************/
+
+using namespace ::dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+//***************************************************************************************
+//
+// registry functions
+extern "C" void SAL_CALL createRegistryInfo_OTableFilterDialog();
+extern "C" void SAL_CALL createRegistryInfo_ODataSourcePropertyDialog();
+extern "C" void SAL_CALL createRegistryInfo_OSQLMessageDialog();
+extern "C" void SAL_CALL createRegistryInfo_OBrowser();
+extern "C" void SAL_CALL createRegistryInfo_OFormGridView();
+extern "C" void SAL_CALL createRegistryInfo_DBContentLoader();
+extern "C" void SAL_CALL writeDBLoaderInfo(void* pRegistryKey);
+extern "C" void SAL_CALL createRegistryInfo_OInteractionHandler();
+extern "C" void SAL_CALL createRegistryInfo_SbaXGridControl();
+extern "C" void SAL_CALL createRegistryInfo_OQueryControl();
+extern "C" void SAL_CALL createRegistryInfo_OViewControl();
+extern "C" void SAL_CALL createRegistryInfo_OTableControl();
+extern "C" void SAL_CALL createRegistryInfo_ORelationControl();
+extern "C" void SAL_CALL createRegistryInfo_ComposerDialogs();
+extern "C" void SAL_CALL createRegistryInfo_ODBApplication();
+extern "C" void SAL_CALL createRegistryInfo_ODirectSQLDialog();
+extern "C" void SAL_CALL createRegistryInfo_OAdvancedSettingsDialog();
+extern "C" void SAL_CALL createRegistryInfo_ODBTypeWizDialog();
+extern "C" void SAL_CALL createRegistryInfo_OUserSettingsDialog();
+extern "C" void SAL_CALL createRegistryInfo_ODBTypeWizDialogSetup();
+extern "C" void SAL_CALL createRegistryInfo_OColumnControlModel();
+extern "C" void SAL_CALL createRegistryInfo_OColumnControl();
+extern "C" void SAL_CALL createRegistryInfo_OToolboxController();
+extern "C" void SAL_CALL createRegistryInfo_OStatusbarController();
+extern "C" void SAL_CALL createRegistryInfo_CopyTableWizard();
+extern "C" void SAL_CALL createRegistryInfo_OTextConnectionSettingsDialog();
+
+//***************************************************************************************
+extern "C" void SAL_CALL createRegistryInfo_DBU()
+{
+ static sal_Bool bInit = sal_False;
+ if (!bInit)
+ {
+ createRegistryInfo_OTableFilterDialog();
+ createRegistryInfo_ODataSourcePropertyDialog();
+ createRegistryInfo_OSQLMessageDialog();
+ createRegistryInfo_OBrowser();
+ createRegistryInfo_OFormGridView();
+ createRegistryInfo_DBContentLoader();
+ createRegistryInfo_OInteractionHandler();
+ createRegistryInfo_SbaXGridControl();
+ createRegistryInfo_OQueryControl();
+ createRegistryInfo_OViewControl();
+ createRegistryInfo_OTableControl();
+ createRegistryInfo_ORelationControl();
+ createRegistryInfo_ComposerDialogs();
+ createRegistryInfo_ODBApplication();
+ createRegistryInfo_ODirectSQLDialog();
+ createRegistryInfo_OAdvancedSettingsDialog();
+ createRegistryInfo_ODBTypeWizDialog();
+ createRegistryInfo_ODBTypeWizDialogSetup();
+ createRegistryInfo_OUserSettingsDialog();
+ createRegistryInfo_OColumnControlModel();
+ createRegistryInfo_OColumnControl();
+ createRegistryInfo_OToolboxController();
+ createRegistryInfo_OStatusbarController();
+ createRegistryInfo_CopyTableWizard();
+ createRegistryInfo_OTextConnectionSettingsDialog();
+ bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" DBACCESS_DLLPUBLIC void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **
+ )
+{
+ createRegistryInfo_DBU();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" DBACCESS_DLLPUBLIC void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::dbaui::OModuleRegistration::getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};