2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-14 17:39:53 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2001-02-23 14:07:41 +00:00
|
|
|
|
2017-10-23 22:42:52 +02:00
|
|
|
#include <UITools.hxx>
|
2004-10-27 12:07:06 +00:00
|
|
|
#include <sfx2/docfilt.hxx>
|
2017-10-23 22:42:52 +02:00
|
|
|
#include <callbacks.hxx>
|
|
|
|
#include <core_resource.hxx>
|
|
|
|
#include <stringconstants.hxx>
|
|
|
|
#include <dbu_pageids.hxx>
|
|
|
|
#include <dlgsave.hxx>
|
|
|
|
#include <dbtreelistbox.hxx>
|
|
|
|
#include <defaultobjectnamecheck.hxx>
|
2001-03-15 07:29:16 +00:00
|
|
|
#include <comphelper/extract.hxx>
|
2012-09-18 09:46:34 +02:00
|
|
|
#include <com/sun/star/sdb/DatabaseContext.hpp>
|
2006-07-10 14:36:22 +00:00
|
|
|
#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
|
2001-02-23 14:07:41 +00:00
|
|
|
#include <com/sun/star/sdb/XCompletedConnection.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XDataSource.hpp>
|
2001-02-28 09:11:33 +00:00
|
|
|
#include <com/sun/star/sdb/SQLContext.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
|
2004-08-02 15:06:20 +00:00
|
|
|
#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XAppend.hpp>
|
2001-07-02 09:31:49 +00:00
|
|
|
#include <com/sun/star/sdbc/XRow.hpp>
|
2005-09-23 11:38:33 +00:00
|
|
|
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
|
2009-04-23 10:42:05 +00:00
|
|
|
#include <com/sun/star/sdbc/ColumnValue.hpp>
|
2012-10-02 15:03:12 +02:00
|
|
|
#include <com/sun/star/task/InteractionHandler.hpp>
|
2004-08-02 15:06:20 +00:00
|
|
|
#include <com/sun/star/ucb/XContent.hpp>
|
2001-06-15 08:55:48 +00:00
|
|
|
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
|
2001-02-23 14:07:41 +00:00
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
2001-02-28 09:11:33 +00:00
|
|
|
#include <com/sun/star/container/XIndexAccess.hpp>
|
2004-08-02 15:06:20 +00:00
|
|
|
#include <com/sun/star/container/XNameContainer.hpp>
|
2005-01-21 16:19:59 +00:00
|
|
|
#include <com/sun/star/ucb/InteractiveIOException.hpp>
|
2005-03-10 15:52:07 +00:00
|
|
|
#include <com/sun/star/sdb/XDocumentDataSource.hpp>
|
2005-01-21 16:19:59 +00:00
|
|
|
#include <com/sun/star/ucb/IOErrorCode.hpp>
|
2001-02-23 14:07:41 +00:00
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
|
|
|
#include <toolkit/awt/vclxwindow.hxx>
|
2001-03-02 16:05:26 +00:00
|
|
|
#include <vcl/stdtext.hxx>
|
2014-01-02 23:52:37 +01:00
|
|
|
#include <vcl/settings.hxx>
|
2001-06-29 10:56:58 +00:00
|
|
|
#include <com/sun/star/beans/XPropertySetInfo.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
2004-08-02 15:06:20 +00:00
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#include <com/sun/star/container/XContainer.hpp>
|
|
|
|
#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
|
2001-06-29 10:56:58 +00:00
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
2001-09-20 11:59:25 +00:00
|
|
|
#include <com/sun/star/awt/TextAlign.hpp>
|
2001-09-20 12:36:09 +00:00
|
|
|
#include <com/sun/star/awt/FontDescriptor.hpp>
|
|
|
|
#include <com/sun/star/awt/FontWeight.hpp>
|
|
|
|
#include <com/sun/star/awt/FontRelief.hpp>
|
|
|
|
#include <com/sun/star/awt/FontWidth.hpp>
|
2017-10-23 22:42:52 +02:00
|
|
|
#include <TypeInfo.hxx>
|
|
|
|
#include <FieldDescriptions.hxx>
|
2012-09-14 18:08:57 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2001-10-18 11:04:12 +00:00
|
|
|
#include <comphelper/stl_types.hxx>
|
2017-07-25 09:34:01 +02:00
|
|
|
#include <comphelper/propertysequence.hxx>
|
2001-02-23 14:07:41 +00:00
|
|
|
|
2001-09-27 05:25:19 +00:00
|
|
|
#include <svx/svxids.hrc>
|
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/itempool.hxx>
|
2017-10-23 22:42:52 +02:00
|
|
|
#include <helpids.h>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/itemset.hxx>
|
2017-10-23 22:42:52 +02:00
|
|
|
#include <sbagrid.hrc>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/rngitem.hxx>
|
|
|
|
#include <svl/intitem.hxx>
|
2001-09-27 05:25:19 +00:00
|
|
|
#include <svx/algitem.hxx>
|
|
|
|
#include <svx/numinf.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/zforlist.hxx>
|
2017-10-23 22:42:52 +02:00
|
|
|
#include <dlgattr.hxx>
|
2001-09-27 05:25:19 +00:00
|
|
|
#include <vcl/msgbox.hxx>
|
2001-11-12 09:34:55 +00:00
|
|
|
#include <com/sun/star/container/XChild.hpp>
|
2012-08-29 09:32:55 +02:00
|
|
|
#include <com/sun/star/util/NumberFormatter.hpp>
|
2002-09-26 09:49:09 +00:00
|
|
|
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
|
|
|
|
#include <com/sun/star/util/XNumberFormatter.hpp>
|
2017-10-23 22:42:52 +02:00
|
|
|
#include <strings.hrc>
|
|
|
|
#include <sqlmessage.hxx>
|
2001-11-15 10:39:29 +00:00
|
|
|
#include <com/sun/star/util/NumberFormat.hpp>
|
2002-08-26 06:50:55 +00:00
|
|
|
#include <com/sun/star/util/URL.hpp>
|
2002-04-29 07:01:49 +00:00
|
|
|
#include <vcl/toolbox.hxx>
|
2017-10-23 22:42:52 +02:00
|
|
|
#include <dlgsize.hxx>
|
2002-05-24 11:46:46 +00:00
|
|
|
#include <svtools/editbrowsebox.hxx>
|
2002-08-26 06:50:55 +00:00
|
|
|
#include <unotools/configmgr.hxx>
|
|
|
|
#include <svtools/helpopt.hxx>
|
|
|
|
#include <ucbhelper/content.hxx>
|
|
|
|
#include <tools/urlobj.hxx>
|
2006-07-10 14:36:22 +00:00
|
|
|
#include <tools/diagnose_ex.h>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/numuno.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/pathoptions.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/filenotation.hxx>
|
2004-08-02 15:06:20 +00:00
|
|
|
#include <svtools/fileview.hxx>
|
2005-09-23 11:38:33 +00:00
|
|
|
#include <connectivity/FValue.hxx>
|
|
|
|
|
2010-10-05 11:18:24 -04:00
|
|
|
#include <editeng/justifyitem.hxx>
|
2015-11-10 13:36:34 +02:00
|
|
|
#include <memory>
|
2005-09-23 11:38:33 +00:00
|
|
|
|
2001-02-23 14:07:41 +00:00
|
|
|
namespace dbaui
|
|
|
|
{
|
|
|
|
using namespace ::dbtools;
|
2001-06-29 10:56:58 +00:00
|
|
|
using namespace ::comphelper;
|
2012-08-29 09:32:55 +02:00
|
|
|
using namespace ::com::sun::star;
|
2001-02-23 14:07:41 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::task;
|
2001-02-28 09:11:33 +00:00
|
|
|
using namespace ::com::sun::star::sdbcx;
|
2001-02-23 14:07:41 +00:00
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
2004-08-02 15:06:20 +00:00
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
using namespace ::com::sun::star::ucb;
|
2001-02-23 14:07:41 +00:00
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::lang;
|
2001-06-15 08:55:48 +00:00
|
|
|
using namespace ::com::sun::star::ui::dialogs;
|
2004-08-02 15:06:20 +00:00
|
|
|
using namespace ::svt;
|
2005-01-21 16:19:59 +00:00
|
|
|
using ::com::sun::star::ucb::InteractiveIOException;
|
|
|
|
using ::com::sun::star::ucb::IOErrorCode_NO_FILE;
|
|
|
|
using ::com::sun::star::ucb::IOErrorCode_NOT_EXISTING;
|
2001-06-29 10:56:58 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
SQLExceptionInfo createConnection( const OUString& _rsDataSourceName,
|
2015-08-03 09:14:58 +02:00
|
|
|
const Reference< css::container::XNameAccess >& _xDatabaseContext,
|
|
|
|
const Reference< css::uno::XComponentContext >& _rxContext,
|
2017-07-31 12:26:12 +02:00
|
|
|
Reference< css::lang::XEventListener> const & _rEvtLst,
|
2015-08-03 09:14:58 +02:00
|
|
|
Reference< css::sdbc::XConnection>& _rOUTConnection )
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2004-08-02 15:06:20 +00:00
|
|
|
Reference<XPropertySet> xProp;
|
2001-02-23 14:07:41 +00:00
|
|
|
try
|
|
|
|
{
|
2004-08-02 15:06:20 +00:00
|
|
|
xProp.set(_xDatabaseContext->getByName(_rsDataSourceName),UNO_QUERY);
|
2001-02-23 14:07:41 +00:00
|
|
|
}
|
2011-04-13 09:40:26 +01:00
|
|
|
catch(const Exception&)
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
SQLExceptionInfo aInfo;
|
2004-08-02 15:06:20 +00:00
|
|
|
|
2012-10-02 15:03:12 +02:00
|
|
|
return createConnection(xProp,_rxContext,_rEvtLst,_rOUTConnection);
|
2004-08-02 15:06:20 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2015-08-03 09:14:58 +02:00
|
|
|
SQLExceptionInfo createConnection( const Reference< css::beans::XPropertySet>& _xDataSource,
|
|
|
|
const Reference< css::uno::XComponentContext >& _rxContext,
|
2017-07-31 12:26:12 +02:00
|
|
|
Reference< css::lang::XEventListener> const & _rEvtLst,
|
2015-08-03 09:14:58 +02:00
|
|
|
Reference< css::sdbc::XConnection>& _rOUTConnection )
|
2004-08-02 15:06:20 +00:00
|
|
|
{
|
|
|
|
SQLExceptionInfo aInfo;
|
|
|
|
if ( !_xDataSource.is() )
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2015-06-23 09:58:19 +02:00
|
|
|
SAL_WARN("dbaccess.ui", "createConnection: could not retrieve the data source!");
|
2001-02-23 14:07:41 +00:00
|
|
|
return aInfo;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sPwd, sUser;
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bPwdReq = false;
|
2001-02-23 14:07:41 +00:00
|
|
|
try
|
|
|
|
{
|
2004-08-02 15:06:20 +00:00
|
|
|
_xDataSource->getPropertyValue(PROPERTY_PASSWORD) >>= sPwd;
|
|
|
|
bPwdReq = ::cppu::any2bool(_xDataSource->getPropertyValue(PROPERTY_ISPASSWORDREQUIRED));
|
|
|
|
_xDataSource->getPropertyValue(PROPERTY_USER) >>= sUser;
|
2001-02-23 14:07:41 +00:00
|
|
|
}
|
2011-04-13 09:40:26 +01:00
|
|
|
catch(const Exception&)
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2013-03-30 04:57:16 +01:00
|
|
|
SAL_WARN("dbaccess.ui", "createConnection: error while retrieving data source properties!");
|
2001-02-23 14:07:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
if(bPwdReq && sPwd.isEmpty())
|
2001-02-23 14:07:41 +00:00
|
|
|
{ // password required, but empty -> connect using an interaction handler
|
2004-08-02 15:06:20 +00:00
|
|
|
Reference<XCompletedConnection> xConnectionCompletion(_xDataSource, UNO_QUERY);
|
2001-02-23 14:07:41 +00:00
|
|
|
if (!xConnectionCompletion.is())
|
|
|
|
{
|
2013-03-30 04:57:16 +01:00
|
|
|
SAL_WARN("dbaccess.ui", "createConnection: missing an interface ... need an error message here!");
|
2001-02-23 14:07:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // instantiate the default SDB interaction handler
|
2015-11-10 10:13:39 +01:00
|
|
|
Reference< XInteractionHandler > xHandler( InteractionHandler::createWithParent(_rxContext, nullptr), UNO_QUERY);
|
2012-10-02 15:03:12 +02:00
|
|
|
_rOUTConnection = xConnectionCompletion->connectWithCompletion(xHandler);
|
2001-02-23 14:07:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-08-02 15:06:20 +00:00
|
|
|
Reference<XDataSource> xDataSource(_xDataSource,UNO_QUERY);
|
2001-02-23 14:07:41 +00:00
|
|
|
_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);
|
|
|
|
}
|
2011-04-13 12:04:28 +01:00
|
|
|
catch(const SQLContext& e) { aInfo = SQLExceptionInfo(e); }
|
|
|
|
catch(const SQLWarning& e) { aInfo = SQLExceptionInfo(e); }
|
|
|
|
catch(const SQLException& e) { aInfo = SQLExceptionInfo(e); }
|
2013-03-30 04:57:16 +01:00
|
|
|
catch(const Exception&) { SAL_WARN("dbaccess.ui", "SbaTableQueryBrowser::OnExpandEntry: could not connect - unknown exception!"); }
|
2001-02-23 14:07:41 +00:00
|
|
|
|
|
|
|
return aInfo;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
Reference< XDataSource > getDataSourceByName( const OUString& _rDataSourceName,
|
2016-04-12 11:16:51 +02:00
|
|
|
vcl::Window* _pErrorMessageParent, const Reference< XComponentContext >& _rxContext, ::dbtools::SQLExceptionInfo* _pErrorInfo )
|
2005-01-21 16:19:59 +00:00
|
|
|
{
|
2012-12-06 14:15:55 +02:00
|
|
|
Reference< XDatabaseContext > xDatabaseContext = DatabaseContext::create(_rxContext);
|
2005-01-21 16:19:59 +00:00
|
|
|
|
|
|
|
Reference< XDataSource > xDatasource;
|
|
|
|
Any aError;
|
|
|
|
SQLExceptionInfo aSQLError;
|
|
|
|
try
|
|
|
|
{
|
2008-03-06 17:27:48 +00:00
|
|
|
xDatabaseContext->getByName( _rDataSourceName ) >>= xDatasource;
|
2005-01-21 16:19:59 +00:00
|
|
|
}
|
|
|
|
catch(const WrappedTargetException& e)
|
|
|
|
{
|
|
|
|
InteractiveIOException aIOException;
|
|
|
|
if ( ( e.TargetException >>= aIOException )
|
|
|
|
&& ( ( aIOException.Code == IOErrorCode_NO_FILE )
|
|
|
|
|| ( aIOException.Code == IOErrorCode_NOT_EXISTING )
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
2017-06-11 20:56:30 +01:00
|
|
|
OUString sErrorMessage( DBA_RES( STR_FILE_DOES_NOT_EXIST ) );
|
2005-01-21 16:19:59 +00:00
|
|
|
OFileNotation aTransformer( e.Message );
|
2013-09-26 12:17:53 +02:00
|
|
|
sErrorMessage = sErrorMessage.replaceFirst( "$file$", aTransformer.get( OFileNotation::N_SYSTEM ) );
|
2005-01-21 16:19:59 +00:00
|
|
|
aSQLError = SQLExceptionInfo( sErrorMessage ).get();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aSQLError = SQLExceptionInfo( e.TargetException );
|
|
|
|
if ( !aSQLError.isValid() )
|
|
|
|
aError = e.TargetException;
|
|
|
|
}
|
|
|
|
}
|
2008-05-05 15:00:36 +00:00
|
|
|
catch( const Exception& )
|
2005-01-21 16:19:59 +00:00
|
|
|
{
|
2008-05-05 15:00:36 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2005-01-21 16:19:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( xDatasource.is() )
|
2005-03-10 15:52:07 +00:00
|
|
|
return xDatasource;
|
2005-01-21 16:19:59 +00:00
|
|
|
|
2008-12-01 12:31:27 +00:00
|
|
|
if ( aSQLError.isValid() )
|
2005-01-21 16:19:59 +00:00
|
|
|
{
|
2008-12-01 12:31:27 +00:00
|
|
|
if ( _pErrorInfo )
|
|
|
|
{
|
|
|
|
*_pErrorInfo = aSQLError;
|
|
|
|
}
|
2005-01-21 16:19:59 +00:00
|
|
|
else
|
|
|
|
{
|
2012-12-06 14:15:55 +02:00
|
|
|
showError( aSQLError, _pErrorMessageParent, _rxContext );
|
2005-01-21 16:19:59 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-01 12:31:27 +00:00
|
|
|
|
2005-03-10 15:52:07 +00:00
|
|
|
return Reference<XDataSource>();
|
2005-01-21 16:19:59 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2005-03-10 15:52:07 +00:00
|
|
|
Reference< XInterface > getDataSourceOrModel(const Reference< XInterface >& _xObject)
|
|
|
|
{
|
|
|
|
Reference< XInterface > xRet;
|
|
|
|
Reference<XDocumentDataSource> xDocumentDataSource(_xObject,UNO_QUERY);
|
|
|
|
if ( xDocumentDataSource.is() )
|
|
|
|
xRet = xDocumentDataSource->getDatabaseDocument();
|
2005-01-21 16:19:59 +00:00
|
|
|
|
2005-03-10 15:52:07 +00:00
|
|
|
if ( !xRet.is() )
|
|
|
|
{
|
|
|
|
Reference<XOfficeDatabaseDocument> xOfficeDoc(_xObject,UNO_QUERY);
|
|
|
|
if ( xOfficeDoc.is() )
|
|
|
|
xRet = xOfficeDoc->getDataSource();
|
|
|
|
}
|
|
|
|
|
|
|
|
return xRet;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
void showError(const SQLExceptionInfo& _rInfo, vcl::Window* _pParent,const Reference< XComponentContext >& _rxContext)
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2001-04-24 07:41:46 +00:00
|
|
|
OSL_ENSURE(_pParent,"showError: Parent window must be NOT NULL!");
|
2012-12-06 14:15:55 +02:00
|
|
|
::dbtools::showError(_rInfo,VCLUnoHelper::GetInterface(_pParent), _rxContext);
|
2001-02-23 14:07:41 +00:00
|
|
|
}
|
2005-01-21 16:19:59 +00:00
|
|
|
|
2003-03-19 16:57:12 +00:00
|
|
|
TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
|
2001-06-29 10:56:58 +00:00
|
|
|
sal_Int32 _nType,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& _sTypeName,
|
|
|
|
const OUString& _sCreateParams,
|
2001-06-29 10:56:58 +00:00
|
|
|
sal_Int32 _nPrecision,
|
|
|
|
sal_Int32 _nScale,
|
2014-04-17 11:16:55 +02:00
|
|
|
bool _bAutoIncrement,
|
|
|
|
bool& _brForceToType)
|
2001-06-29 10:56:58 +00:00
|
|
|
{
|
2003-03-19 16:57:12 +00:00
|
|
|
TOTypeInfoSP pTypeInfo;
|
2014-04-17 11:16:55 +02:00
|
|
|
_brForceToType = false;
|
2001-06-29 10:56:58 +00:00
|
|
|
// search for type
|
2017-02-17 19:06:24 +02:00
|
|
|
std::pair<OTypeInfoMap::const_iterator, OTypeInfoMap::const_iterator> aPair = _rTypeInfo.equal_range(_nType);
|
2001-06-29 10:56:58 +00:00
|
|
|
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
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sDBTypeName = aIter->second->aTypeName; (void)sDBTypeName;
|
2001-06-29 10:56:58 +00:00
|
|
|
#endif
|
2004-08-02 15:06:20 +00:00
|
|
|
if ( (
|
2011-12-19 18:10:37 -02:00
|
|
|
_sTypeName.isEmpty()
|
2001-07-05 11:19:25 +00:00
|
|
|
|| (aIter->second->aTypeName.equalsIgnoreAsciiCase(_sTypeName))
|
2001-06-29 10:56:58 +00:00
|
|
|
)
|
2004-08-02 15:06:20 +00:00
|
|
|
&& (
|
|
|
|
(
|
|
|
|
!aIter->second->aCreateParams.getLength()
|
2011-12-19 18:10:37 -02:00
|
|
|
&& _sCreateParams.isEmpty()
|
2004-08-02 15:06:20 +00:00
|
|
|
)
|
|
|
|
|| (
|
|
|
|
(aIter->second->nPrecision >= _nPrecision)
|
|
|
|
&& (aIter->second->nMaximumScale >= _nScale)
|
2006-09-25 08:42:48 +00:00
|
|
|
&& ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
|
2004-08-02 15:06:20 +00:00
|
|
|
)
|
|
|
|
)
|
2001-06-29 10:56:58 +00:00
|
|
|
)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aIter == aPair.second)
|
|
|
|
{
|
|
|
|
for(aIter = aPair.first; aIter != aPair.second; ++aIter)
|
|
|
|
{
|
2003-03-19 16:57:12 +00:00
|
|
|
sal_Int32 nPrec = aIter->second->nPrecision;
|
|
|
|
sal_Int32 nScale = aIter->second->nMaximumScale;
|
2001-06-29 10:56:58 +00:00
|
|
|
// search the best matching type (now comparing the local names)
|
2001-07-05 11:19:25 +00:00
|
|
|
if ( (aIter->second->aLocalTypeName.equalsIgnoreAsciiCase(_sTypeName))
|
2003-03-19 16:57:12 +00:00
|
|
|
&& (nPrec >= _nPrecision)
|
|
|
|
&& (nScale >= _nScale)
|
2006-09-25 08:42:48 +00:00
|
|
|
&& ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
|
2001-06-29 10:56:58 +00:00
|
|
|
)
|
|
|
|
{
|
2013-03-30 04:57:16 +01:00
|
|
|
SAL_WARN("dbaccess.ui", "getTypeInfoFromType: assuming column type " <<
|
|
|
|
aIter->second->aTypeName << "\" (expected type name " <<
|
|
|
|
_sTypeName << " matches the type's local name).");
|
2001-06-29 10:56:58 +00:00
|
|
|
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)
|
|
|
|
|
2003-03-19 16:57:12 +00:00
|
|
|
for(aIter = aPair.first; aIter != aPair.second; ++aIter)
|
|
|
|
{
|
|
|
|
// search the best matching type (now comparing the local names)
|
|
|
|
sal_Int32 nPrec = aIter->second->nPrecision;
|
|
|
|
sal_Int32 nScale = aIter->second->nMaximumScale;
|
|
|
|
if ( (nPrec >= _nPrecision)
|
|
|
|
&& (nScale >= _nScale)
|
2006-09-25 08:42:48 +00:00
|
|
|
&& ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
|
2003-03-19 16:57:12 +00:00
|
|
|
)
|
|
|
|
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)
|
|
|
|
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,
|
2004-08-02 15:06:20 +00:00
|
|
|
_sCreateParams,
|
2003-03-19 16:57:12 +00:00
|
|
|
_nPrecision,
|
|
|
|
_nScale,
|
2014-04-17 11:16:55 +02:00
|
|
|
false,
|
2003-03-19 16:57:12 +00:00
|
|
|
_brForceToType);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pTypeInfo = aIter->second;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pTypeInfo = aPair.first->second;
|
2014-04-17 11:16:55 +02:00
|
|
|
_brForceToType = true;
|
2003-03-19 16:57:12 +00:00
|
|
|
}
|
2001-06-29 10:56:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
pTypeInfo = aIter->second;
|
|
|
|
}
|
|
|
|
else
|
2001-10-18 11:04:12 +00:00
|
|
|
{
|
2014-02-16 22:51:15 +01:00
|
|
|
::comphelper::UStringMixEqual aCase(false);
|
2001-10-18 11:04:12 +00:00
|
|
|
// search for typeinfo where the typename is equal _sTypeName
|
2006-06-20 02:21:13 +00:00
|
|
|
OTypeInfoMap::const_iterator typeInfoLoop = _rTypeInfo.begin();
|
|
|
|
OTypeInfoMap::const_iterator typeInfoEnd = _rTypeInfo.end();
|
|
|
|
for (; typeInfoLoop != typeInfoEnd; ++typeInfoLoop)
|
2003-03-19 16:57:12 +00:00
|
|
|
{
|
2006-06-20 02:21:13 +00:00
|
|
|
if ( aCase( typeInfoLoop->second->getDBName() , _sTypeName ) )
|
|
|
|
{
|
|
|
|
pTypeInfo = typeInfoLoop->second;
|
2003-03-19 16:57:12 +00:00
|
|
|
break;
|
2006-06-20 02:21:13 +00:00
|
|
|
}
|
2003-03-19 16:57:12 +00:00
|
|
|
}
|
2001-10-18 11:04:12 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 02:21:13 +00:00
|
|
|
OSL_ENSURE(pTypeInfo, "getTypeInfoFromType: no type info found for this type!");
|
2001-06-29 10:56:58 +00:00
|
|
|
return pTypeInfo;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2015-08-03 09:14:58 +02:00
|
|
|
void fillTypeInfo( const Reference< css::sdbc::XConnection>& _rxConnection,
|
2013-09-26 12:17:53 +02:00
|
|
|
const OUString& _rsTypeNames,
|
2001-07-02 09:31:49 +00:00
|
|
|
OTypeInfoMap& _rTypeInfoMap,
|
2017-02-17 19:06:24 +02:00
|
|
|
std::vector<OTypeInfoMap::iterator>& _rTypeInfoIters)
|
2001-07-02 09:31:49 +00:00
|
|
|
{
|
|
|
|
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())
|
|
|
|
{
|
2005-09-23 11:38:33 +00:00
|
|
|
Reference<XResultSetMetaData> xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(xRs,UNO_QUERY)->getMetaData();
|
|
|
|
::connectivity::ORowSetValue aValue;
|
2017-02-17 19:06:24 +02:00
|
|
|
std::vector<sal_Int32> aTypes;
|
2018-01-21 18:28:03 +02:00
|
|
|
std::vector<bool> aNullable;
|
2001-07-02 09:31:49 +00:00
|
|
|
// Loop on the result set until we reach end of file
|
|
|
|
while (xRs->next())
|
|
|
|
{
|
2003-03-19 16:57:12 +00:00
|
|
|
TOTypeInfoSP pInfo(new OTypeInfo());
|
2005-09-23 11:38:33 +00:00
|
|
|
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);
|
2016-04-20 17:16:13 +02:00
|
|
|
aNullable.push_back(false);
|
2005-09-23 11:38:33 +00:00
|
|
|
for (sal_Int32 j = 1; j <= nCount ; ++j)
|
2009-04-23 10:42:05 +00:00
|
|
|
{
|
2005-09-23 11:38:33 +00:00
|
|
|
aTypes.push_back(xResultSetMetaData->getColumnType(j));
|
2009-04-23 10:42:05 +00:00
|
|
|
aNullable.push_back(xResultSetMetaData->isNullable(j) != ColumnValue::NO_NULLS);
|
|
|
|
}
|
2005-09-23 11:38:33 +00:00
|
|
|
}
|
|
|
|
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2005-09-23 11:38:33 +00:00
|
|
|
pInfo->aTypeName = aValue;
|
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2005-09-23 11:38:33 +00:00
|
|
|
pInfo->nType = aValue;
|
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2005-09-23 11:38:33 +00:00
|
|
|
pInfo->nPrecision = aValue;
|
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2005-09-23 11:38:33 +00:00
|
|
|
pInfo->aLiteralPrefix = aValue;
|
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2005-09-23 11:38:33 +00:00
|
|
|
pInfo->aLiteralSuffix = aValue;
|
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2005-09-23 11:38:33 +00:00
|
|
|
pInfo->aCreateParams = aValue;
|
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2018-01-12 20:25:56 +01:00
|
|
|
pInfo->bNullable = static_cast<sal_Int32>(aValue) == ColumnValue::NULLABLE;
|
2005-09-23 11:38:33 +00:00
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2017-07-04 11:40:31 +02:00
|
|
|
// bCaseSensitive
|
2005-09-23 11:38:33 +00:00
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2005-09-23 11:38:33 +00:00
|
|
|
pInfo->nSearchType = aValue;
|
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2017-07-04 11:40:31 +02:00
|
|
|
// bUnsigned
|
2005-09-23 11:38:33 +00:00
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2018-01-12 20:25:56 +01:00
|
|
|
pInfo->bCurrency = static_cast<bool>(aValue);
|
2005-09-23 11:38:33 +00:00
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2018-01-12 20:25:56 +01:00
|
|
|
pInfo->bAutoIncrement = static_cast<bool>(aValue);
|
2005-09-23 11:38:33 +00:00
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2005-09-23 11:38:33 +00:00
|
|
|
pInfo->aLocalTypeName = aValue;
|
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2005-09-23 11:38:33 +00:00
|
|
|
pInfo->nMinimumScale = aValue;
|
|
|
|
++nPos;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2005-09-23 11:38:33 +00:00
|
|
|
pInfo->nMaximumScale = aValue;
|
2013-11-05 18:37:50 +01:00
|
|
|
assert(nPos == 15);
|
|
|
|
// 16 and 17 are unused
|
2005-09-23 11:38:33 +00:00
|
|
|
nPos = 18;
|
2009-04-23 10:42:05 +00:00
|
|
|
aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
|
2013-11-05 18:37:50 +01:00
|
|
|
pInfo->nNumPrecRadix = aValue;
|
2005-09-23 11:38:33 +00:00
|
|
|
|
2001-12-04 13:32:50 +00:00
|
|
|
// 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;
|
2013-11-05 18:37:50 +01:00
|
|
|
if( pInfo->nNumPrecRadix <= 1)
|
|
|
|
pInfo->nNumPrecRadix = 10;
|
2001-07-02 09:31:49 +00:00
|
|
|
|
2013-09-26 12:17:53 +02:00
|
|
|
OUString aName;
|
2001-07-02 09:31:49 +00:00
|
|
|
switch(pInfo->nType)
|
|
|
|
{
|
|
|
|
case DataType::CHAR:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_CHAR, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::VARCHAR:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_TEXT, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::DECIMAL:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_DECIMAL, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::NUMERIC:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_NUMERIC, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::BIGINT:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_BIGINT, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::FLOAT:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_FLOAT, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::DOUBLE:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_DOUBLE, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::LONGVARCHAR:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_MEMO, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::LONGVARBINARY:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_IMAGE, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::DATE:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_DATE, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::TIME:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_TIME, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::TIMESTAMP:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_DATETIME, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::BIT:
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( !pInfo->aCreateParams.isEmpty() )
|
2009-11-11 14:03:52 +01:00
|
|
|
{
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_BIT, ';');
|
2009-11-11 14:03:52 +01:00
|
|
|
break;
|
|
|
|
}
|
2016-05-10 16:42:16 +02:00
|
|
|
SAL_FALLTHROUGH;
|
2005-02-17 10:08:41 +00:00
|
|
|
case DataType::BOOLEAN:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_BOOL, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::TINYINT:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_TINYINT, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::SMALLINT:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_SMALLINT, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::INTEGER:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_INTEGER, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::REAL:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_REAL, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::BINARY:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_BINARY, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::VARBINARY:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_VARBINARY, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::SQLNULL:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_SQLNULL, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::OBJECT:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_OBJECT, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::DISTINCT:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_DISTINCT, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::STRUCT:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_STRUCT, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::ARRAY:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_ARRAY, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::BLOB:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_BLOB, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::CLOB:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_CLOB, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::REF:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_REF, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case DataType::OTHER:
|
2013-09-26 12:17:53 +02:00
|
|
|
aName = _rsTypeNames.getToken(TYPE_OTHER, ';');
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-09-26 12:17:53 +02:00
|
|
|
if ( !aName.isEmpty() )
|
2004-11-09 11:35:50 +00:00
|
|
|
{
|
2013-10-01 20:12:42 +01:00
|
|
|
pInfo->aUIName = aName;
|
2016-11-04 12:29:35 +02:00
|
|
|
pInfo->aUIName += " [ ";
|
2004-11-09 11:35:50 +00:00
|
|
|
}
|
2001-07-02 09:31:49 +00:00
|
|
|
pInfo->aUIName += pInfo->aTypeName;
|
2013-09-26 12:17:53 +02:00
|
|
|
if ( !aName.isEmpty() )
|
2016-11-04 12:29:35 +02:00
|
|
|
pInfo->aUIName += " ]";
|
2001-07-02 09:31:49 +00:00
|
|
|
// Now that we have the type info, save it in the multimap
|
2017-08-10 16:43:55 +02:00
|
|
|
_rTypeInfoMap.emplace(pInfo->nType,pInfo);
|
2001-07-02 09:31:49 +00:00
|
|
|
}
|
|
|
|
// for a faster index access
|
2001-08-27 05:57:24 +00:00
|
|
|
_rTypeInfoIters.reserve(_rTypeInfoMap.size());
|
|
|
|
|
2001-07-02 09:31:49 +00:00
|
|
|
OTypeInfoMap::iterator aIter = _rTypeInfoMap.begin();
|
2016-03-28 19:17:45 +02:00
|
|
|
OTypeInfoMap::const_iterator aEnd = _rTypeInfoMap.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-07-02 09:31:49 +00:00
|
|
|
_rTypeInfoIters.push_back(aIter);
|
|
|
|
|
|
|
|
// Close the result set/statement.
|
|
|
|
|
|
|
|
::comphelper::disposeComponent(xRs);
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-07-02 09:31:49 +00:00
|
|
|
void setColumnProperties(const Reference<XPropertySet>& _rxColumn,const OFieldDescription* _pFieldDesc)
|
|
|
|
{
|
|
|
|
_rxColumn->setPropertyValue(PROPERTY_NAME,makeAny(_pFieldDesc->GetName()));
|
|
|
|
_rxColumn->setPropertyValue(PROPERTY_TYPENAME,makeAny(_pFieldDesc->getTypeInfo()->aTypeName));
|
2002-11-29 11:29:59 +00:00
|
|
|
_rxColumn->setPropertyValue(PROPERTY_TYPE,makeAny(_pFieldDesc->GetType()));
|
2001-07-02 09:31:49 +00:00
|
|
|
_rxColumn->setPropertyValue(PROPERTY_PRECISION,makeAny(_pFieldDesc->GetPrecision()));
|
|
|
|
_rxColumn->setPropertyValue(PROPERTY_SCALE,makeAny(_pFieldDesc->GetScale()));
|
|
|
|
_rxColumn->setPropertyValue(PROPERTY_ISNULLABLE, makeAny(_pFieldDesc->GetIsNullable()));
|
2014-02-22 18:24:10 +01:00
|
|
|
_rxColumn->setPropertyValue(PROPERTY_ISAUTOINCREMENT, css::uno::makeAny(_pFieldDesc->IsAutoIncrement()));
|
2010-01-13 08:44:34 +01:00
|
|
|
_rxColumn->setPropertyValue(PROPERTY_DESCRIPTION,makeAny(_pFieldDesc->GetDescription()));
|
2002-07-11 06:19:41 +00:00
|
|
|
if ( _rxColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISCURRENCY) && _pFieldDesc->IsCurrency() )
|
2014-02-22 18:24:10 +01:00
|
|
|
_rxColumn->setPropertyValue(PROPERTY_ISCURRENCY, css::uno::makeAny(_pFieldDesc->IsCurrency()));
|
2002-07-25 05:55:23 +00:00
|
|
|
// set autoincrement value when available
|
2004-08-02 15:06:20 +00:00
|
|
|
// and only set when the entry is not empty, that lets the value in the column untouched
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( _pFieldDesc->IsAutoIncrement() && !_pFieldDesc->GetAutoIncrementValue().isEmpty() && _rxColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) )
|
2002-07-25 05:55:23 +00:00
|
|
|
_rxColumn->setPropertyValue(PROPERTY_AUTOINCREMENTCREATION,makeAny(_pFieldDesc->GetAutoIncrementValue()));
|
2001-07-02 09:31:49 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString createDefaultName(const Reference< XDatabaseMetaData>& _xMetaData,const Reference<XNameAccess>& _xTables,const OUString& _sName)
|
2001-07-16 06:53:20 +00:00
|
|
|
{
|
|
|
|
OSL_ENSURE(_xMetaData.is(),"No MetaData!");
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sDefaultName = _sName;
|
2001-07-16 06:53:20 +00:00
|
|
|
try
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sCatalog,sSchema,sCompsedName;
|
2001-07-16 06:53:20 +00:00
|
|
|
if(_xMetaData->supportsCatalogsInTableDefinitions())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2003-09-04 07:33:25 +00:00
|
|
|
Reference< XConnection> xCon = _xMetaData->getConnection();
|
|
|
|
if ( xCon.is() )
|
|
|
|
sCatalog = xCon->getCatalog();
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( sCatalog.isEmpty() )
|
2001-07-16 06:53:20 +00:00
|
|
|
{
|
2003-09-04 07:33:25 +00:00
|
|
|
Reference<XResultSet> xRes = _xMetaData->getCatalogs();
|
|
|
|
Reference<XRow> xRow(xRes,UNO_QUERY);
|
|
|
|
while(xRes.is() && xRes->next())
|
|
|
|
{
|
|
|
|
sCatalog = xRow->getString(1);
|
|
|
|
if(!xRow->wasNull())
|
|
|
|
break;
|
|
|
|
}
|
2001-07-16 06:53:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(const SQLException&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(_xMetaData->supportsSchemasInTableDefinitions())
|
|
|
|
{
|
|
|
|
sSchema = _xMetaData->getUserName();
|
|
|
|
}
|
2016-02-25 09:38:09 +02:00
|
|
|
sCompsedName = ::dbtools::composeTableName( _xMetaData, sCatalog, sSchema, _sName, false, ::dbtools::EComposeRule::InDataManipulation );
|
2001-07-16 06:53:20 +00:00
|
|
|
sDefaultName = ::dbtools::createUniqueName(_xTables,sCompsedName);
|
|
|
|
}
|
|
|
|
catch(const SQLException&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return sDefaultName;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2015-08-03 09:14:58 +02:00
|
|
|
bool checkDataSourceAvailable(const OUString& _sDataSourceName,const Reference< css::uno::XComponentContext >& _xContext)
|
2001-07-18 07:51:19 +00:00
|
|
|
{
|
2012-09-18 09:46:34 +02:00
|
|
|
Reference< XDatabaseContext > xDataBaseContext = DatabaseContext::create(_xContext);
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bRet = xDataBaseContext->hasByName(_sDataSourceName);
|
2012-09-18 09:46:34 +02:00
|
|
|
if ( !bRet )
|
|
|
|
{ // try if this one is a URL
|
|
|
|
try
|
|
|
|
{
|
|
|
|
bRet = xDataBaseContext->getByName(_sDataSourceName).hasValue();
|
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
2004-08-02 15:06:20 +00:00
|
|
|
}
|
|
|
|
}
|
2001-07-18 07:51:19 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-09-20 11:59:25 +00:00
|
|
|
sal_Int32 mapTextAllign(const SvxCellHorJustify& _eAlignment)
|
|
|
|
{
|
2015-08-03 09:14:58 +02:00
|
|
|
sal_Int32 nAlignment = css::awt::TextAlign::LEFT;
|
2001-09-20 11:59:25 +00:00
|
|
|
switch (_eAlignment)
|
|
|
|
{
|
2017-03-08 12:39:34 +02:00
|
|
|
case SvxCellHorJustify::Standard:
|
|
|
|
case SvxCellHorJustify::Left: nAlignment = css::awt::TextAlign::LEFT; break;
|
|
|
|
case SvxCellHorJustify::Center: nAlignment = css::awt::TextAlign::CENTER; break;
|
|
|
|
case SvxCellHorJustify::Right: nAlignment = css::awt::TextAlign::RIGHT; break;
|
2001-09-20 11:59:25 +00:00
|
|
|
default:
|
2013-03-30 04:57:16 +01:00
|
|
|
SAL_WARN("dbaccess.ui", "Invalid TextAlign!");
|
2001-09-20 11:59:25 +00:00
|
|
|
}
|
|
|
|
return nAlignment;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2016-05-05 09:46:12 +02:00
|
|
|
SvxCellHorJustify mapTextJustify(sal_Int32 _nAlignment)
|
2002-09-24 08:48:22 +00:00
|
|
|
{
|
2017-03-08 12:39:34 +02:00
|
|
|
SvxCellHorJustify eJustify = SvxCellHorJustify::Left;
|
2002-09-24 08:48:22 +00:00
|
|
|
switch (_nAlignment)
|
|
|
|
{
|
2017-03-08 12:39:34 +02:00
|
|
|
case css::awt::TextAlign::LEFT : eJustify = SvxCellHorJustify::Left; break;
|
|
|
|
case css::awt::TextAlign::CENTER : eJustify = SvxCellHorJustify::Center; break;
|
|
|
|
case css::awt::TextAlign::RIGHT : eJustify = SvxCellHorJustify::Right; break;
|
2002-09-24 08:48:22 +00:00
|
|
|
default:
|
2013-03-30 04:57:16 +01:00
|
|
|
SAL_WARN("dbaccess.ui", "Invalid TextAlign!");
|
2002-09-24 08:48:22 +00:00
|
|
|
}
|
|
|
|
return eJustify;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-09-27 05:25:19 +00:00
|
|
|
void callColumnFormatDialog(const Reference<XPropertySet>& xAffectedCol,
|
|
|
|
const Reference<XPropertySet>& xField,
|
|
|
|
SvNumberFormatter* _pFormatter,
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* _pParent)
|
2001-09-27 05:25:19 +00:00
|
|
|
{
|
|
|
|
if (xAffectedCol.is() && xField.is())
|
|
|
|
{
|
2002-02-25 11:22:39 +00:00
|
|
|
try
|
2001-09-27 05:25:19 +00:00
|
|
|
{
|
2002-02-25 11:22:39 +00:00
|
|
|
Reference< XPropertySetInfo > xInfo = xAffectedCol->getPropertySetInfo();
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bHasFormat = xInfo->hasPropertyByName(PROPERTY_FORMATKEY);
|
2002-02-25 11:22:39 +00:00
|
|
|
sal_Int32 nDataType = ::comphelper::getINT32(xField->getPropertyValue(PROPERTY_TYPE));
|
|
|
|
|
2017-03-08 12:39:34 +02:00
|
|
|
SvxCellHorJustify eJustify(SvxCellHorJustify::Standard);
|
2002-02-25 11:22:39 +00:00
|
|
|
Any aAlignment = xAffectedCol->getPropertyValue(PROPERTY_ALIGN);
|
|
|
|
if (aAlignment.hasValue())
|
2002-09-24 08:48:22 +00:00
|
|
|
eJustify = dbaui::mapTextJustify(::comphelper::getINT16(aAlignment));
|
2002-02-25 11:22:39 +00:00
|
|
|
sal_Int32 nFormatKey = 0;
|
|
|
|
if ( bHasFormat )
|
|
|
|
nFormatKey = ::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY));
|
|
|
|
|
2014-01-17 14:06:13 +00:00
|
|
|
if(callColumnFormatDialog(_pParent,_pFormatter,nDataType,nFormatKey,eJustify,bHasFormat))
|
2001-09-27 05:25:19 +00:00
|
|
|
{
|
2018-01-12 20:25:56 +01:00
|
|
|
xAffectedCol->setPropertyValue(PROPERTY_ALIGN, makeAny(static_cast<sal_Int16>(dbaui::mapTextAllign(eJustify))));
|
2014-01-17 14:06:13 +00:00
|
|
|
if (bHasFormat)
|
2001-09-27 05:25:19 +00:00
|
|
|
xAffectedCol->setPropertyValue(PROPERTY_FORMATKEY, makeAny(nFormatKey));
|
|
|
|
|
2002-02-25 11:22:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
2008-05-05 15:00:36 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2001-09-27 05:25:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
bool callColumnFormatDialog(vcl::Window* _pParent,
|
2001-09-27 05:25:19 +00:00
|
|
|
SvNumberFormatter* _pFormatter,
|
|
|
|
sal_Int32 _nDataType,
|
|
|
|
sal_Int32& _nFormatKey,
|
|
|
|
SvxCellHorJustify& _eJustify,
|
2014-04-17 11:16:55 +02:00
|
|
|
bool _bHasFormat)
|
2001-09-27 05:25:19 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bRet = false;
|
2001-09-27 05:25:19 +00:00
|
|
|
|
|
|
|
// UNO->ItemSet
|
|
|
|
static SfxItemInfo aItemInfos[] =
|
|
|
|
{
|
2016-03-09 09:47:35 +02:00
|
|
|
{ 0, false },
|
|
|
|
{ SID_ATTR_NUMBERFORMAT_VALUE, true },
|
|
|
|
{ SID_ATTR_ALIGN_HOR_JUSTIFY, true },
|
|
|
|
{ SID_ATTR_NUMBERFORMAT_ONE_AREA, true },
|
|
|
|
{ SID_ATTR_NUMBERFORMAT_INFO, true }
|
2001-09-27 05:25:19 +00:00
|
|
|
};
|
2013-07-24 21:11:30 +09:00
|
|
|
static const sal_uInt16 aAttrMap[] =
|
2001-09-27 05:25:19 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2016-12-23 16:03:53 +02:00
|
|
|
std::vector<SfxPoolItem*> pDefaults
|
2001-09-27 05:25:19 +00:00
|
|
|
{
|
|
|
|
new SfxRangeItem(SBA_DEF_RANGEFORMAT, SBA_DEF_FMTVALUE, SBA_ATTR_ALIGN_HOR_JUSTIFY),
|
|
|
|
new SfxUInt32Item(SBA_DEF_FMTVALUE),
|
2017-03-08 12:39:34 +02:00
|
|
|
new SvxHorJustifyItem(SvxCellHorJustify::Standard, SBA_ATTR_ALIGN_HOR_JUSTIFY),
|
2014-01-28 20:02:35 +01:00
|
|
|
new SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, false),
|
2001-09-27 05:25:19 +00:00
|
|
|
new SvxNumberInfoItem(SID_ATTR_NUMBERFORMAT_INFO)
|
|
|
|
};
|
|
|
|
|
2017-01-30 16:38:54 +02:00
|
|
|
SfxItemPool* pPool = new SfxItemPool("GridBrowserProperties", SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, aItemInfos, &pDefaults);
|
2016-09-20 16:41:39 +02:00
|
|
|
pPool->SetDefaultMetric( MapUnit::MapTwip ); // ripped, don't understand why
|
2001-09-27 05:25:19 +00:00
|
|
|
pPool->FreezeIdRanges(); // the same
|
|
|
|
|
2015-11-10 13:36:34 +02:00
|
|
|
std::unique_ptr<SfxItemSet> pFormatDescriptor(new SfxItemSet(*pPool, aAttrMap));
|
2001-09-27 05:25:19 +00:00
|
|
|
// fill it
|
|
|
|
pFormatDescriptor->Put(SvxHorJustifyItem(_eJustify, SBA_ATTR_ALIGN_HOR_JUSTIFY));
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bText = false;
|
2001-09-27 05:25:19 +00:00
|
|
|
if (_bHasFormat)
|
|
|
|
{
|
|
|
|
// if the col is bound to a text field we have to disallow all non-text formats
|
2009-11-11 14:03:52 +01:00
|
|
|
if ((DataType::CHAR == _nDataType) || (DataType::VARCHAR == _nDataType) || (DataType::LONGVARCHAR == _nDataType) || (DataType::CLOB == _nDataType))
|
2001-09-27 05:25:19 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bText = true;
|
2014-01-28 20:02:35 +01:00
|
|
|
pFormatDescriptor->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, true));
|
2001-09-27 05:25:19 +00:00
|
|
|
if (!_pFormatter->IsTextFormat(_nFormatKey))
|
|
|
|
// text fields can only have text formats
|
2017-12-03 21:46:37 +02:00
|
|
|
_nFormatKey = _pFormatter->GetStandardFormat(SvNumFormatType::TEXT,_pParent->GetSettings().GetLanguageTag().getLanguageType());
|
2001-09-27 05:25:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pFormatDescriptor->Put(SfxUInt32Item(SBA_DEF_FMTVALUE, _nFormatKey));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bText)
|
|
|
|
{
|
2017-06-22 16:05:11 +02:00
|
|
|
SvxNumberInfoItem aFormatter(_pFormatter, 1234.56789, SID_ATTR_NUMBERFORMAT_INFO);
|
2001-09-27 05:25:19 +00:00
|
|
|
pFormatDescriptor->Put(aFormatter);
|
|
|
|
}
|
|
|
|
|
|
|
|
{ // want the dialog to be destroyed before our set
|
2015-11-10 13:36:34 +02:00
|
|
|
ScopedVclPtrInstance< SbaSbAttrDlg > aDlg(_pParent, pFormatDescriptor.get(), _pFormatter, _bHasFormat);
|
2015-02-11 14:42:23 +02:00
|
|
|
if (RET_OK == aDlg->Execute())
|
2001-09-27 05:25:19 +00:00
|
|
|
{
|
|
|
|
// ItemSet->UNO
|
|
|
|
// UNO-properties
|
2015-02-11 14:42:23 +02:00
|
|
|
const SfxItemSet* pSet = aDlg->GetExampleSet();
|
2001-09-27 05:25:19 +00:00
|
|
|
// (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
|
2015-10-19 07:18:39 +02:00
|
|
|
const SvxHorJustifyItem* pHorJustify = pSet->GetItem<SvxHorJustifyItem>(SBA_ATTR_ALIGN_HOR_JUSTIFY);
|
2001-09-27 05:25:19 +00:00
|
|
|
|
2017-09-14 13:59:33 +02:00
|
|
|
_eJustify = pHorJustify->GetValue();
|
2001-09-27 05:25:19 +00:00
|
|
|
|
|
|
|
// format key
|
2014-01-17 14:06:13 +00:00
|
|
|
if (_bHasFormat)
|
2001-09-27 05:25:19 +00:00
|
|
|
{
|
2015-10-19 07:18:39 +02:00
|
|
|
const SfxUInt32Item* pFormat = pSet->GetItem<SfxUInt32Item>(SBA_DEF_FMTVALUE);
|
2018-01-12 20:25:56 +01:00
|
|
|
_nFormatKey = static_cast<sal_Int32>(pFormat->GetValue());
|
2001-09-27 05:25:19 +00:00
|
|
|
}
|
2014-04-17 11:16:55 +02:00
|
|
|
bRet = true;
|
2001-09-27 05:25:19 +00:00
|
|
|
}
|
|
|
|
// deleted formats
|
2015-02-11 14:42:23 +02:00
|
|
|
const SfxItemSet* pResult = aDlg->GetOutputItemSet();
|
2001-09-27 05:25:19 +00:00
|
|
|
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();
|
|
|
|
|
2017-12-17 23:00:24 +03:00
|
|
|
for (sal_uInt32 i=0; i< pInfoItem->GetDelCount(); ++i)
|
|
|
|
_pFormatter->DeleteEntry(pDeletedKeys[i]);
|
2001-09-27 05:25:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-30 10:08:22 +02:00
|
|
|
pFormatDescriptor.reset();
|
CWS-TOOLING: integrate CWS aw063
2009-02-12 13:10:24 +0100 aw r267649 : #i99123# when a primitive is invisible, it is not sufficient to produce no output when decomposing, but to add invisible data using HitTestPrimitive2D. This is needed for the slideshow which relies on geometry data in MetaFiles when painting invisible objects
2009-02-12 13:08:39 +0100 aw r267648 : #i99123# do not ignore HitTestPrimitive2D, but draw empty rectangles instead. This is needed since Slideshow is based on getting MetaFile content when painting invisible objects
2009-02-11 16:04:28 +0100 aw r267620 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:04:10 +0100 aw r267619 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:03:56 +0100 aw r267618 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:03:39 +0100 aw r267617 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:03:21 +0100 aw r267615 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:02:48 +0100 aw r267614 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:02:24 +0100 aw r267613 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:02:01 +0100 aw r267612 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:01:32 +0100 aw r267611 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:01:05 +0100 aw r267610 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:00:15 +0100 aw r267608 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 11:27:33 +0100 aw r267585 : #i98788# added missing include for STL
2009-02-10 17:46:50 +0100 aw r267570 : #i98788# added reaction on pool destruction
2009-02-10 17:11:58 +0100 aw r267562 : #i98788# added messaging mechanism to register for pool destruction
2009-02-10 13:35:35 +0100 aw r267549 : #i98788# removing changes, too complicated and risky for 3.1
2009-02-10 12:13:48 +0100 aw r267546 : #i98788# 4th round
2009-02-10 12:13:37 +0100 aw r267545 : #i98788# 4th round
2009-02-10 12:13:26 +0100 aw r267544 : #i98788# 4th round
2009-02-10 12:13:14 +0100 aw r267543 : #i98788# 4th round
2009-02-10 12:13:03 +0100 aw r267542 : #i98788# 4th round
2009-02-10 12:12:50 +0100 aw r267541 : #i98788# 4th round
2009-02-10 12:12:37 +0100 aw r267540 : #i98788# 4th round
2009-02-08 14:38:22 +0100 aw r267495 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:38:06 +0100 aw r267494 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:37:48 +0100 aw r267493 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:37:17 +0100 aw r267492 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:56 +0100 aw r267491 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:44 +0100 aw r267490 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:29 +0100 aw r267489 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:16 +0100 aw r267488 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:02 +0100 aw r267487 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:35:46 +0100 aw r267486 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-05 12:20:39 +0100 aw r267415 : #i98788# 2nd batch of adaptions for SfxItemPoolHolder addition
2009-02-04 15:12:54 +0100 aw r267385 : #i98788# added newline at EOF
2009-02-04 13:26:04 +0100 aw r267379 : #i98788# make SfxItemPool holdable
2009-02-04 13:25:40 +0100 aw r267378 : #i98788# make SfxItemPool holdable
2009-02-04 13:25:08 +0100 aw r267377 : #i98788# make SfxItemPool holdable
2009-02-04 13:24:42 +0100 aw r267376 : #i98788# make SfxItemPool holdable
2009-02-04 13:23:14 +0100 aw r267375 : #i98788# make SfxItemPool holdable
2009-02-04 13:23:02 +0100 aw r267374 : #i98788# make SfxItemPool holdable
2009-01-29 17:08:31 +0100 aw r267159 : #i97628# completed the fix
2009-01-29 17:08:15 +0100 aw r267158 : #i97628# completed the fix
2009-01-29 14:09:07 +0100 aw r267132 : #i97628# Corrected usage of ParagraphData in headers
2009-01-29 14:06:58 +0100 iha r267131 : #i98344# incorrect font size in charts
2009-01-29 12:13:46 +0100 aw r267115 : #i97628# back to old state; triggers too many errors in other modules
2009-01-29 12:03:51 +0100 aw r267114 : #i97628# enabled exceptions due to STL vector include
2009-01-29 11:21:37 +0100 aw r267107 : #i97628# added needed include
2009-01-28 17:58:29 +0100 aw r267077 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-28 17:58:12 +0100 aw r267076 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-28 17:57:51 +0100 aw r267074 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-28 17:57:21 +0100 aw r267073 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-27 17:07:33 +0100 aw r267011 : #i98402# added support for ViewRange when exporting MetaFiles in ObjectContactOfPageView::DoProcessDisplay to avoid to paint too much
2009-01-27 11:45:48 +0100 aw r266973 : #i98404# Added a warning to a place where a conversion to rectangle should not be copied from
2009-01-26 21:44:36 +0100 iha r266949 : #i98497# 3D charts are rendered with wrong size
2009-01-26 20:47:07 +0100 aw r266947 : #i98404# handle BackgroundColorPrimitive2D directly in PixelRenderers and avoid AA under all circumstances
2009-01-26 14:50:36 +0100 aw r266926 : #i98386# secured cloning of SdrObject in IMapUserData by boost::shared_prt usage
2009-01-26 12:51:30 +0100 aw r266916 : #i96581# added separated FontStretching and fallback for small X!=Y scale differences
2009-01-23 16:14:55 +0100 aw r266834 : #i96475# added missing implementation of TextDecoratedPortionPrimitive2D::getB2DRange
2009-01-23 15:24:34 +0100 aw r266826 : #i98405# fixed fallback to DrawAlphaRect to use the correctly sized rectangle
2009-01-23 13:34:43 +0100 aw r266813 : #i96474# fixed impSplitSingleWords for an unexpected case
2009-01-23 10:47:31 +0100 aw r266786 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:47:20 +0100 aw r266785 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:47:09 +0100 aw r266783 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:46:58 +0100 aw r266782 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:46:48 +0100 aw r266781 : #i98289#,#i96474# tooling and new flags for tasks
2009-03-04 14:16:02 +00:00
|
|
|
SfxItemPool::Free(pPool);
|
2016-04-25 10:56:28 +02:00
|
|
|
for (SfxPoolItem* pDefault : pDefaults)
|
|
|
|
delete pDefault;
|
2001-09-27 05:25:19 +00:00
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
2004-10-27 12:07:06 +00:00
|
|
|
|
2016-03-11 06:43:06 +01:00
|
|
|
std::shared_ptr<const SfxFilter> getStandardDatabaseFilter()
|
2004-10-27 12:07:06 +00:00
|
|
|
{
|
2016-03-11 06:43:06 +01:00
|
|
|
std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)");
|
2004-10-27 12:07:06 +00:00
|
|
|
OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
|
|
|
|
return pFilter;
|
|
|
|
}
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool appendToFilter(const Reference<XConnection>& _xConnection,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& _sName,
|
2012-09-18 09:46:34 +02:00
|
|
|
const Reference< XComponentContext >& _rxContext,
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* _pParent)
|
2001-11-12 09:34:55 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bRet = false;
|
2001-11-12 09:34:55 +00:00
|
|
|
Reference< XChild> xChild(_xConnection,UNO_QUERY);
|
|
|
|
if(xChild.is())
|
|
|
|
{
|
|
|
|
Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY);
|
|
|
|
if(xProp.is())
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > aFilter;
|
2001-11-12 09:34:55 +00:00
|
|
|
xProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= aFilter;
|
|
|
|
// first check if we have something like SCHEMA.%
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bHasToInsert = true;
|
2017-12-17 23:00:24 +03:00
|
|
|
for (const OUString& rItem : aFilter)
|
2001-11-12 09:34:55 +00:00
|
|
|
{
|
2017-12-17 23:00:24 +03:00
|
|
|
if(rItem.indexOf('%') != -1)
|
2001-11-12 09:34:55 +00:00
|
|
|
{
|
|
|
|
sal_Int32 nLen;
|
2017-12-17 23:00:24 +03:00
|
|
|
if((nLen = rItem.lastIndexOf('.')) != -1 && !rItem.compareTo(_sName,nLen))
|
2014-04-17 11:16:55 +02:00
|
|
|
bHasToInsert = false;
|
2017-12-17 23:00:24 +03:00
|
|
|
else if(rItem.getLength() == 1)
|
2014-04-17 11:16:55 +02:00
|
|
|
bHasToInsert = false;
|
2001-11-12 09:34:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bRet = true;
|
2001-11-12 09:34:55 +00:00
|
|
|
if(bHasToInsert)
|
|
|
|
{
|
2012-09-18 09:46:34 +02:00
|
|
|
if(! ::dbaui::checkDataSourceAvailable(::comphelper::getString(xProp->getPropertyValue(PROPERTY_NAME)),_rxContext))
|
2001-11-12 09:34:55 +00:00
|
|
|
{
|
2017-06-11 20:56:30 +01:00
|
|
|
OUString aMessage(DBA_RES(STR_TABLEDESIGN_DATASOURCE_DELETED));
|
2016-07-26 10:21:41 +01:00
|
|
|
ScopedVclPtrInstance<OSQLWarningBox>(_pParent, aMessage)->Execute();
|
2014-04-17 11:16:55 +02:00
|
|
|
bRet = false;
|
2001-11-12 09:34:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aFilter.realloc(aFilter.getLength()+1);
|
|
|
|
aFilter.getArray()[aFilter.getLength()-1] = _sName;
|
|
|
|
xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aFilter));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2017-07-31 12:26:12 +02:00
|
|
|
void notifySystemWindow(vcl::Window const * _pWindow, vcl::Window* _pToRegister, const ::comphelper::mem_fun1_t<TaskPaneList,vcl::Window*>& _rMemFunc)
|
2002-04-29 07:01:49 +00:00
|
|
|
{
|
|
|
|
OSL_ENSURE(_pWindow,"Window can not be null!");
|
2015-11-10 10:13:39 +01:00
|
|
|
SystemWindow* pSystemWindow = _pWindow ? _pWindow->GetSystemWindow() : nullptr;
|
2004-10-22 11:07:19 +00:00
|
|
|
if ( pSystemWindow )
|
2002-04-29 07:01:49 +00:00
|
|
|
{
|
2004-10-22 11:07:19 +00:00
|
|
|
_rMemFunc( pSystemWindow->GetTaskPaneList(), _pToRegister );
|
2002-04-29 07:01:49 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-04-29 07:01:49 +00:00
|
|
|
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();
|
2008-12-11 07:05:03 +00:00
|
|
|
if ( (aSize.Width() && aSize.Width() != aTbSize.Width()) ||
|
|
|
|
(aSize.Height() && aSize.Height() != aTbSize.Height()) )
|
2002-04-29 07:01:49 +00:00
|
|
|
{
|
|
|
|
_pToolBox->SetPosSizePixel( _pToolBox->GetPosPixel(), aSize );
|
|
|
|
_pToolBox->Invalidate();
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-05-24 11:46:46 +00:00
|
|
|
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 ) )
|
|
|
|
{
|
2016-09-20 16:41:39 +02:00
|
|
|
Size aSizeMM = _pBox->PixelToLogic( Size( _pBox->GetColumnWidth( _nColId ), 0 ), MapMode( MapUnit::MapMM ) );
|
2002-05-24 11:46:46 +00:00
|
|
|
nColSize = aSizeMM.Width() * 10;
|
|
|
|
}
|
|
|
|
|
2016-09-20 16:41:39 +02:00
|
|
|
Size aDefaultMM = _pBox->PixelToLogic( Size( nDefaultWidth, 0 ), MapMode( MapUnit::MapMM ) );
|
2002-05-24 11:46:46 +00:00
|
|
|
|
2015-03-31 23:04:14 +01:00
|
|
|
ScopedVclPtrInstance< DlgSize > aColumnSizeDlg( _pBox, nColSize, false, aDefaultMM.Width() * 10 );
|
2015-02-11 14:42:23 +02:00
|
|
|
if ( aColumnSizeDlg->Execute() )
|
2002-05-24 11:46:46 +00:00
|
|
|
{
|
2015-02-11 14:42:23 +02:00
|
|
|
sal_Int32 nValue = aColumnSizeDlg->GetValue();
|
2002-05-24 11:46:46 +00:00
|
|
|
if ( -1 == nValue )
|
|
|
|
{ // default width
|
|
|
|
nValue = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Size aSizeMM( nValue / 10, 0 );
|
2016-09-20 16:41:39 +02:00
|
|
|
nValue = _pBox->LogicToPixel( aSizeMM, MapMode( MapUnit::MapMM ) ).Width();
|
2002-05-24 11:46:46 +00:00
|
|
|
}
|
|
|
|
_pBox->SetColumnWidth( _nColId, nValue );
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-07-09 11:48:40 +00:00
|
|
|
// check if SQL92 name checking is enabled
|
2014-04-17 11:16:55 +02:00
|
|
|
bool isSQL92CheckEnabled(const Reference<XConnection>& _xConnection)
|
2002-07-09 11:48:40 +00:00
|
|
|
{
|
2013-04-25 10:56:02 +02:00
|
|
|
return ::dbtools::getBooleanDataSourceSetting( _xConnection, PROPERTY_ENABLESQL92CHECK );
|
2003-09-04 07:33:25 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool isAppendTableAliasEnabled(const Reference<XConnection>& _xConnection)
|
2003-09-04 07:33:25 +00:00
|
|
|
{
|
2013-04-25 10:56:02 +02:00
|
|
|
return ::dbtools::getBooleanDataSourceSetting( _xConnection, INFO_APPEND_TABLE_ALIAS );
|
2006-12-13 15:53:01 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool generateAsBeforeTableAlias(const Reference<XConnection>& _xConnection)
|
2006-12-13 15:53:01 +00:00
|
|
|
{
|
2013-04-25 10:56:02 +02:00
|
|
|
return ::dbtools::getBooleanDataSourceSetting( _xConnection, INFO_AS_BEFORE_CORRELATION_NAME );
|
2002-07-09 11:48:40 +00:00
|
|
|
}
|
2004-08-02 15:06:20 +00:00
|
|
|
|
2002-07-25 05:55:23 +00:00
|
|
|
void fillAutoIncrementValue(const Reference<XPropertySet>& _xDatasource,
|
2014-04-17 11:16:55 +02:00
|
|
|
bool& _rAutoIncrementValueEnabled,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString& _rsAutoIncrementValue)
|
2002-07-25 05:55:23 +00:00
|
|
|
{
|
|
|
|
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
|
2017-07-05 13:27:30 +02:00
|
|
|
const PropertyValue* pValue =std::find_if(aInfo.begin(), aInfo.end(),
|
2017-07-05 01:32:48 +02:00
|
|
|
[](const PropertyValue& lhs)
|
2017-07-11 13:56:33 +02:00
|
|
|
{return lhs.Name == PROPERTY_AUTOINCREMENTCREATION;} );
|
2017-07-05 01:32:48 +02:00
|
|
|
|
2017-07-06 19:36:34 +02:00
|
|
|
if ( pValue != aInfo.end() )
|
2002-07-25 05:55:23 +00:00
|
|
|
pValue->Value >>= _rsAutoIncrementValue;
|
2017-07-05 13:27:30 +02:00
|
|
|
pValue =std::find_if(aInfo.begin(), aInfo.end(),
|
2017-07-05 01:32:48 +02:00
|
|
|
[](const PropertyValue& lhs)
|
2017-07-11 13:56:33 +02:00
|
|
|
{return lhs.Name == "IsAutoRetrievingEnabled";} );
|
2017-07-05 01:32:48 +02:00
|
|
|
|
2017-07-06 19:36:34 +02:00
|
|
|
if ( pValue != aInfo.end() )
|
2002-07-25 05:55:23 +00:00
|
|
|
pValue->Value >>= _rAutoIncrementValueEnabled;
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-07-25 05:55:23 +00:00
|
|
|
void fillAutoIncrementValue(const Reference<XConnection>& _xConnection,
|
2014-04-17 11:16:55 +02:00
|
|
|
bool& _rAutoIncrementValueEnabled,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString& _rsAutoIncrementValue)
|
2002-07-25 05:55:23 +00:00
|
|
|
{
|
|
|
|
Reference< XChild> xChild(_xConnection,UNO_QUERY);
|
|
|
|
if(xChild.is())
|
|
|
|
{
|
|
|
|
Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY);
|
|
|
|
fillAutoIncrementValue(xProp,_rAutoIncrementValueEnabled,_rsAutoIncrementValue);
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString getStrippedDatabaseName(const Reference<XPropertySet>& _xDataSource,OUString& _rsDatabaseName)
|
2004-08-02 15:06:20 +00:00
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( _rsDatabaseName.isEmpty() && _xDataSource.is() )
|
2004-08-02 15:06:20 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
_xDataSource->getPropertyValue(PROPERTY_NAME) >>= _rsDatabaseName;
|
|
|
|
}
|
2008-12-01 12:31:27 +00:00
|
|
|
catch(const Exception& )
|
2004-08-02 15:06:20 +00:00
|
|
|
{
|
2008-12-01 12:31:27 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-08-02 15:06:20 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sName = _rsDatabaseName;
|
2004-08-02 15:06:20 +00:00
|
|
|
INetURLObject aURL(sName);
|
2015-04-02 18:32:36 +02:00
|
|
|
if ( aURL.GetProtocol() != INetProtocol::NotValid )
|
2016-12-05 08:47:18 +02:00
|
|
|
sName = aURL.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DecodeMechanism::Unambiguous);
|
2004-08-02 15:06:20 +00:00
|
|
|
return sName;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2017-07-31 12:26:12 +02:00
|
|
|
void setEvalDateFormatForFormatter(Reference< css::util::XNumberFormatter > const & _rxFormatter)
|
2002-09-26 09:49:09 +00:00
|
|
|
{
|
2007-07-06 07:34:20 +00:00
|
|
|
OSL_ENSURE( _rxFormatter.is(),"setEvalDateFormatForFormatter: Formatter is NULL!");
|
|
|
|
if ( _rxFormatter.is() )
|
|
|
|
{
|
2015-08-03 09:14:58 +02:00
|
|
|
Reference< css::util::XNumberFormatsSupplier > xSupplier = _rxFormatter->getNumberFormatsSupplier();
|
2002-09-26 09:49:09 +00:00
|
|
|
|
2007-07-06 07:34:20 +00:00
|
|
|
Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
|
|
|
|
SvNumberFormatsSupplierObj* pSupplierImpl = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
|
|
|
|
OSL_ENSURE(pSupplierImpl,"No Supplier!");
|
2002-09-26 09:49:09 +00:00
|
|
|
|
2007-07-06 07:34:20 +00:00
|
|
|
if ( pSupplierImpl )
|
|
|
|
{
|
|
|
|
SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter();
|
|
|
|
pFormatter->SetEvalDateFormat(NF_EVALDATEFORMAT_FORMAT);
|
|
|
|
}
|
2002-09-26 09:49:09 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2003-03-19 16:57:12 +00:00
|
|
|
TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap& _rTypeInfo)
|
2002-11-14 06:58:31 +00:00
|
|
|
{
|
2003-03-19 16:57:12 +00:00
|
|
|
TOTypeInfoSP pTypeInfo;
|
2002-11-14 06:58:31 +00:00
|
|
|
// 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
|
2014-04-29 19:05:05 +00:00
|
|
|
// because we don't have the possibility to know how to create
|
2002-11-14 06:58:31 +00:00
|
|
|
// such auto increment column later on
|
|
|
|
// so until we know how to do it, we create a column without autoincrement
|
2017-09-30 19:35:09 +02:00
|
|
|
// therefore we have searched
|
|
|
|
if ( aIter->second->nType == DataType::INTEGER )
|
|
|
|
{
|
|
|
|
pTypeInfo = aIter->second; // alternative
|
|
|
|
break;
|
2002-11-14 06:58:31 +00:00
|
|
|
}
|
2017-09-30 19:35:09 +02:00
|
|
|
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
|
2002-11-14 06:58:31 +00:00
|
|
|
}
|
2003-03-19 16:57:12 +00:00
|
|
|
if ( !pTypeInfo.get() ) // just a fallback
|
2002-11-14 06:58:31 +00:00
|
|
|
pTypeInfo = queryTypeInfoByType(DataType::VARCHAR,_rTypeInfo);
|
|
|
|
|
2018-01-15 09:09:57 +01:00
|
|
|
OSL_ENSURE(pTypeInfo.get(),"checkColumns: can't find a type which is usable as a key!");
|
2002-11-14 06:58:31 +00:00
|
|
|
return pTypeInfo;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2003-03-19 16:57:12 +00:00
|
|
|
TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rTypeInfo)
|
2002-11-14 06:58:31 +00:00
|
|
|
{
|
|
|
|
OTypeInfoMap::const_iterator aIter = _rTypeInfo.find(_nDataType);
|
|
|
|
if(aIter != _rTypeInfo.end())
|
|
|
|
return aIter->second;
|
2006-01-16 14:29:39 +00:00
|
|
|
// fall back if the type is unknown
|
|
|
|
TOTypeInfoSP pTypeInfo;
|
|
|
|
switch(_nDataType)
|
|
|
|
{
|
|
|
|
case DataType::TINYINT:
|
2012-04-23 21:25:38 +03:00
|
|
|
if( (pTypeInfo = queryTypeInfoByType(DataType::SMALLINT,_rTypeInfo) ) )
|
2006-01-16 14:29:39 +00:00
|
|
|
break;
|
2016-05-10 16:42:16 +02:00
|
|
|
SAL_FALLTHROUGH;
|
2006-01-16 14:29:39 +00:00
|
|
|
case DataType::SMALLINT:
|
2012-04-23 21:25:38 +03:00
|
|
|
if( (pTypeInfo = queryTypeInfoByType(DataType::INTEGER,_rTypeInfo) ) )
|
2006-01-16 14:29:39 +00:00
|
|
|
break;
|
2016-05-10 16:42:16 +02:00
|
|
|
SAL_FALLTHROUGH;
|
2006-01-16 14:29:39 +00:00
|
|
|
case DataType::INTEGER:
|
2012-04-23 21:25:38 +03:00
|
|
|
if( (pTypeInfo = queryTypeInfoByType(DataType::FLOAT,_rTypeInfo) ) )
|
2006-01-16 14:29:39 +00:00
|
|
|
break;
|
2016-05-10 16:42:16 +02:00
|
|
|
SAL_FALLTHROUGH;
|
2006-01-16 14:29:39 +00:00
|
|
|
case DataType::FLOAT:
|
2012-04-23 21:25:38 +03:00
|
|
|
if( (pTypeInfo = queryTypeInfoByType(DataType::REAL,_rTypeInfo) ) )
|
2006-01-16 14:29:39 +00:00
|
|
|
break;
|
2016-05-10 16:42:16 +02:00
|
|
|
SAL_FALLTHROUGH;
|
2006-01-16 14:29:39 +00:00
|
|
|
case DataType::DATE:
|
|
|
|
case DataType::TIME:
|
|
|
|
if( DataType::DATE == _nDataType || DataType::TIME == _nDataType )
|
|
|
|
{
|
2012-04-23 21:25:38 +03:00
|
|
|
if( (pTypeInfo = queryTypeInfoByType(DataType::TIMESTAMP,_rTypeInfo) ) )
|
2006-01-16 14:29:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-10 16:42:16 +02:00
|
|
|
SAL_FALLTHROUGH;
|
2006-01-16 14:29:39 +00:00
|
|
|
case DataType::TIMESTAMP:
|
|
|
|
case DataType::REAL:
|
|
|
|
case DataType::BIGINT:
|
2012-04-23 21:25:38 +03:00
|
|
|
if ( (pTypeInfo = queryTypeInfoByType(DataType::DOUBLE,_rTypeInfo) ) )
|
2006-01-16 14:29:39 +00:00
|
|
|
break;
|
2016-05-10 16:42:16 +02:00
|
|
|
SAL_FALLTHROUGH;
|
2006-01-16 14:29:39 +00:00
|
|
|
case DataType::DOUBLE:
|
2012-04-23 21:25:38 +03:00
|
|
|
if ( (pTypeInfo = queryTypeInfoByType(DataType::NUMERIC,_rTypeInfo) ) )
|
2006-01-16 14:29:39 +00:00
|
|
|
break;
|
2016-05-10 16:42:16 +02:00
|
|
|
SAL_FALLTHROUGH;
|
2006-01-16 14:29:39 +00:00
|
|
|
case DataType::NUMERIC:
|
|
|
|
pTypeInfo = queryTypeInfoByType(DataType::DECIMAL,_rTypeInfo);
|
|
|
|
break;
|
|
|
|
case DataType::DECIMAL:
|
2012-04-23 21:25:38 +03:00
|
|
|
if ( (pTypeInfo = queryTypeInfoByType(DataType::NUMERIC,_rTypeInfo) ) )
|
2006-01-16 14:29:39 +00:00
|
|
|
break;
|
2012-04-23 21:25:38 +03:00
|
|
|
if ( (pTypeInfo = queryTypeInfoByType(DataType::DOUBLE,_rTypeInfo) ) )
|
2006-01-16 14:29:39 +00:00
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DataType::VARCHAR:
|
2012-04-23 21:25:38 +03:00
|
|
|
if ( (pTypeInfo = queryTypeInfoByType(DataType::LONGVARCHAR,_rTypeInfo) ) )
|
2006-01-16 14:29:39 +00:00
|
|
|
break;
|
|
|
|
break;
|
2009-11-11 14:03:52 +01:00
|
|
|
case DataType::LONGVARCHAR:
|
2012-04-23 21:25:38 +03:00
|
|
|
if ( (pTypeInfo = queryTypeInfoByType(DataType::CLOB,_rTypeInfo) ) )
|
2009-11-11 14:03:52 +01:00
|
|
|
break;
|
|
|
|
break;
|
2006-01-16 14:29:39 +00:00
|
|
|
default:
|
|
|
|
;
|
2010-11-23 23:33:20 +00:00
|
|
|
}
|
2006-01-16 14:29:39 +00:00
|
|
|
if ( !pTypeInfo )
|
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bForce = true;
|
2017-07-13 11:46:54 +02:00
|
|
|
pTypeInfo = ::dbaui::getTypeInfoFromType(_rTypeInfo,DataType::VARCHAR,OUString(),"x",50,0,false,bForce);
|
2010-11-23 23:33:20 +00:00
|
|
|
}
|
2006-01-16 14:29:39 +00:00
|
|
|
OSL_ENSURE(pTypeInfo,"Wrong DataType supplied!");
|
|
|
|
return pTypeInfo;
|
2002-11-14 06:58:31 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2017-06-11 20:56:30 +01:00
|
|
|
sal_Int32 askForUserAction(vcl::Window* _pParent, const char* pTitle, const char* pText, bool _bAll, const OUString& _sName)
|
2004-08-02 15:06:20 +00:00
|
|
|
{
|
2010-10-13 01:38:41 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2017-06-11 20:56:30 +01:00
|
|
|
OUString aMsg = DBA_RES(pText);
|
2013-09-26 12:17:53 +02:00
|
|
|
aMsg = aMsg.replaceFirst("%1", _sName);
|
2017-08-22 11:11:44 +02:00
|
|
|
ScopedVclPtrInstance<OSQLMessageBox> aAsk(_pParent, DBA_RES(pTitle), aMsg,MessBoxStyle::YesNo | MessBoxStyle::DefaultYes,OSQLMessageBox::Query);
|
2004-08-02 15:06:20 +00:00
|
|
|
if ( _bAll )
|
|
|
|
{
|
2017-06-11 20:56:30 +01:00
|
|
|
aAsk->AddButton(DBA_RES(STR_BUTTON_TEXT_ALL), RET_ALL);
|
2015-02-11 14:42:23 +02:00
|
|
|
aAsk->GetPushButton(RET_ALL)->SetHelpId(HID_CONFIRM_DROP_BUTTON_ALL);
|
2004-08-02 15:06:20 +00:00
|
|
|
}
|
2015-02-11 14:42:23 +02:00
|
|
|
return aAsk->Execute();
|
2004-08-02 15:06:20 +00:00
|
|
|
}
|
2006-07-10 14:36:22 +00:00
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2016-03-31 08:40:23 +02:00
|
|
|
OUString lcl_createSDBCLevelStatement( const OUString& _rStatement, const Reference< XConnection >& _rxConnection )
|
2006-07-10 14:36:22 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sSDBCLevelStatement( _rStatement );
|
2006-07-10 14:36:22 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
Reference< XPropertySet > createView( const OUString& _rName, const Reference< XConnection >& _rxConnection,
|
|
|
|
const OUString& _rCommand )
|
2004-08-02 15:06:20 +00:00
|
|
|
{
|
2008-01-30 07:51:13 +00:00
|
|
|
Reference<XViewsSupplier> xSup(_rxConnection,UNO_QUERY);
|
2004-08-02 15:06:20 +00:00
|
|
|
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())
|
2015-11-10 10:13:39 +01:00
|
|
|
return nullptr;
|
2004-08-02 15:06:20 +00:00
|
|
|
|
|
|
|
Reference<XPropertySet> xView = xFact->createDataDescriptor();
|
|
|
|
if ( !xView.is() )
|
2015-11-10 10:13:39 +01:00
|
|
|
return nullptr;
|
2004-08-02 15:06:20 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sCatalog,sSchema,sTable;
|
2008-01-30 07:51:13 +00:00
|
|
|
::dbtools::qualifiedNameComponents(_rxConnection->getMetaData(),
|
|
|
|
_rName,
|
2004-08-02 15:06:20 +00:00
|
|
|
sCatalog,
|
|
|
|
sSchema,
|
|
|
|
sTable,
|
2016-02-25 09:38:09 +02:00
|
|
|
::dbtools::EComposeRule::InDataManipulation);
|
2004-08-02 15:06:20 +00:00
|
|
|
|
|
|
|
xView->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog));
|
|
|
|
xView->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema));
|
|
|
|
xView->setPropertyValue(PROPERTY_NAME,makeAny(sTable));
|
|
|
|
|
2008-01-30 07:51:13 +00:00
|
|
|
xView->setPropertyValue( PROPERTY_COMMAND, makeAny( _rCommand ) );
|
2004-08-02 15:06:20 +00:00
|
|
|
|
|
|
|
Reference<XAppend> xAppend(xViews,UNO_QUERY);
|
|
|
|
if(xAppend.is())
|
|
|
|
xAppend->appendByDescriptor(xView);
|
|
|
|
|
2015-11-10 10:13:39 +01:00
|
|
|
xView = nullptr;
|
2014-11-10 15:05:25 +01:00
|
|
|
// we need to reget the view because after appending it, it is no longer valid
|
2004-08-02 15:06:20 +00:00
|
|
|
// but this time it isn't a view object it is a table object with type "VIEW"
|
2008-01-30 07:51:13 +00:00
|
|
|
Reference<XTablesSupplier> xTabSup(_rxConnection,UNO_QUERY);
|
2004-08-02 15:06:20 +00:00
|
|
|
Reference< XNameAccess > xTables;
|
|
|
|
if ( xTabSup.is() )
|
|
|
|
{
|
|
|
|
xTables = xTabSup->getTables();
|
2008-01-30 07:51:13 +00:00
|
|
|
if ( xTables.is() && xTables->hasByName( _rName ) )
|
|
|
|
xTables->getByName( _rName ) >>= xView;
|
2004-08-02 15:06:20 +00:00
|
|
|
}
|
2003-03-19 16:57:12 +00:00
|
|
|
|
2004-08-02 15:06:20 +00:00
|
|
|
return xView;
|
|
|
|
}
|
2008-01-30 07:51:13 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
Reference<XPropertySet> createView( const OUString& _rName, const Reference< XConnection >& _rxConnection
|
2008-01-30 07:51:13 +00:00
|
|
|
,const Reference<XPropertySet>& _rxSourceObject)
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sCommand;
|
2008-01-30 07:51:13 +00:00
|
|
|
Reference< XPropertySetInfo > xPSI( _rxSourceObject->getPropertySetInfo(), UNO_SET_THROW );
|
|
|
|
if ( xPSI->hasPropertyByName( PROPERTY_COMMAND ) )
|
|
|
|
{
|
|
|
|
_rxSourceObject->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bEscapeProcessing( false );
|
2008-01-30 07:51:13 +00:00
|
|
|
OSL_VERIFY( _rxSourceObject->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bEscapeProcessing );
|
|
|
|
if ( bEscapeProcessing )
|
|
|
|
sCommand = lcl_createSDBCLevelStatement( sCommand, _rxConnection );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-04 13:33:17 +02:00
|
|
|
sCommand = "SELECT * FROM " + composeTableNameForSelect( _rxConnection, _rxSourceObject );
|
2008-01-30 07:51:13 +00:00
|
|
|
}
|
|
|
|
return createView( _rName, _rxConnection, sCommand );
|
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
bool insertHierachyElement( vcl::Window* _pParent, const Reference< XComponentContext >& _rxContext,
|
2006-07-10 14:36:22 +00:00
|
|
|
const Reference<XHierarchicalNameContainer>& _xNames,
|
2013-09-26 12:17:53 +02:00
|
|
|
const OUString& _sParentFolder,
|
2014-04-17 11:16:55 +02:00
|
|
|
bool _bForm,
|
|
|
|
bool _bCollection,
|
2006-07-10 14:36:22 +00:00
|
|
|
const Reference<XContent>& _xContent,
|
2014-04-17 11:16:55 +02:00
|
|
|
bool _bMove)
|
2004-08-02 15:06:20 +00:00
|
|
|
{
|
2006-07-10 14:36:22 +00:00
|
|
|
OSL_ENSURE( _xNames.is(), "insertHierachyElement: illegal name container!" );
|
|
|
|
if ( !_xNames.is() )
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2006-07-10 14:36:22 +00:00
|
|
|
|
|
|
|
Reference<XNameAccess> xNameAccess( _xNames, UNO_QUERY );
|
2016-04-12 16:39:03 +02:00
|
|
|
if ( _xNames->hasByHierarchicalName(_sParentFolder) )
|
2004-08-02 15:06:20 +00:00
|
|
|
{
|
2016-04-12 16:39:03 +02:00
|
|
|
Reference<XChild> xChild(_xNames->getByHierarchicalName(_sParentFolder),UNO_QUERY);
|
2006-07-10 14:36:22 +00:00
|
|
|
xNameAccess.set(xChild,UNO_QUERY);
|
|
|
|
if ( !xNameAccess.is() && xChild.is() )
|
|
|
|
xNameAccess.set(xChild->getParent(),UNO_QUERY);
|
|
|
|
}
|
2004-08-02 15:06:20 +00:00
|
|
|
|
2006-07-10 14:36:22 +00:00
|
|
|
OSL_ENSURE( xNameAccess.is(), "insertHierachyElement: could not find the proper name container!" );
|
|
|
|
if ( !xNameAccess.is() )
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2004-08-02 15:06:20 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sNewName;
|
2006-07-10 14:36:22 +00:00
|
|
|
Reference<XPropertySet> xProp(_xContent,UNO_QUERY);
|
|
|
|
if ( xProp.is() )
|
|
|
|
xProp->getPropertyValue(PROPERTY_NAME) >>= sNewName;
|
2004-08-02 15:06:20 +00:00
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( !_bMove || sNewName.isEmpty() )
|
2006-07-10 14:36:22 +00:00
|
|
|
{
|
2013-09-26 12:17:53 +02:00
|
|
|
OUString sTargetName,sLabel;
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( sNewName.isEmpty() || xNameAccess->hasByName(sNewName) )
|
2006-07-10 14:36:22 +00:00
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( !sNewName.isEmpty() )
|
2006-07-10 14:36:22 +00:00
|
|
|
sTargetName = sNewName;
|
|
|
|
else
|
2017-06-11 20:56:30 +01:00
|
|
|
sTargetName = DBA_RES( _bCollection ? STR_NEW_FOLDER : ((_bForm) ? RID_STR_FORM : RID_STR_REPORT));
|
|
|
|
sLabel = DBA_RES( _bCollection ? STR_FOLDER_LABEL : ((_bForm) ? STR_FRM_LABEL : STR_RPT_LABEL));
|
2006-07-10 14:36:22 +00:00
|
|
|
sTargetName = ::dbtools::createUniqueName(xNameAccess,sTargetName);
|
|
|
|
|
|
|
|
// here we have everything needed to create a new query object ...
|
2016-04-12 16:39:03 +02:00
|
|
|
HierarchicalNameCheck aNameChecker( _xNames.get(), _sParentFolder );
|
2006-07-10 14:36:22 +00:00
|
|
|
// ... ehm, except a new name
|
2015-03-31 20:57:16 +01:00
|
|
|
ScopedVclPtrInstance<OSaveAsDlg> aAskForName(
|
|
|
|
_pParent,
|
2012-12-06 14:15:55 +02:00
|
|
|
_rxContext,
|
2006-07-10 14:36:22 +00:00
|
|
|
sTargetName,
|
|
|
|
sLabel,
|
|
|
|
aNameChecker,
|
2016-11-23 10:23:47 +02:00
|
|
|
SADFlags::AdditionalDescription | SADFlags::TitlePasteAs );
|
2015-02-11 14:42:23 +02:00
|
|
|
if ( RET_OK != aAskForName->Execute() )
|
2006-07-10 14:36:22 +00:00
|
|
|
// cancelled by the user
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2006-07-10 14:36:22 +00:00
|
|
|
|
2015-02-11 14:42:23 +02:00
|
|
|
sNewName = aAskForName->getName();
|
2004-08-02 15:06:20 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-10 14:36:22 +00:00
|
|
|
else if ( xNameAccess->hasByName(sNewName) )
|
|
|
|
{
|
2017-06-11 20:56:30 +01:00
|
|
|
OUString sError(DBA_RES(STR_NAME_ALREADY_EXISTS));
|
2013-09-26 12:17:53 +02:00
|
|
|
sError = sError.replaceFirst("#",sNewName);
|
2017-01-30 16:38:54 +02:00
|
|
|
throw SQLException(sError,nullptr,"S1000",0,Any());
|
2006-07-10 14:36:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2007-05-10 09:34:31 +00:00
|
|
|
Reference<XMultiServiceFactory> xORB( xNameAccess, UNO_QUERY_THROW );
|
2017-07-25 09:34:01 +02:00
|
|
|
uno::Sequence<uno::Any> aArguments(comphelper::InitAnyPropertySequence(
|
|
|
|
{
|
|
|
|
{"Name", uno::Any(sNewName)}, // set as folder
|
|
|
|
{"Parent", uno::Any(xNameAccess)},
|
|
|
|
{PROPERTY_EMBEDDEDOBJECT, uno::Any(_xContent)},
|
|
|
|
}));
|
2017-11-22 14:12:34 +01:00
|
|
|
OUString sServiceName(_bCollection ? (_bForm ? OUString(SERVICE_NAME_FORM_COLLECTION) : OUString(SERVICE_NAME_REPORT_COLLECTION)) : OUString(SERVICE_SDB_DOCUMENTDEFINITION));
|
2007-05-10 09:34:31 +00:00
|
|
|
|
|
|
|
Reference<XContent > xNew( xORB->createInstanceWithArguments( sServiceName, aArguments ), UNO_QUERY_THROW );
|
|
|
|
Reference< XNameContainer > xNameContainer( xNameAccess, UNO_QUERY_THROW );
|
|
|
|
xNameContainer->insertByName( sNewName, makeAny( xNew ) );
|
2006-07-10 14:36:22 +00:00
|
|
|
}
|
2007-05-10 09:34:31 +00:00
|
|
|
catch( const IllegalArgumentException& e )
|
|
|
|
{
|
|
|
|
::dbtools::throwGenericSQLException( e.Message, e.Context );
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
2006-07-10 14:36:22 +00:00
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2006-07-10 14:36:22 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
return true;
|
2004-08-02 15:06:20 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2015-08-03 09:14:58 +02:00
|
|
|
Reference< XNumberFormatter > getNumberFormatter(const Reference< XConnection >& _rxConnection, const Reference< css::uno::XComponentContext >& _rxContext )
|
2005-01-21 16:19:59 +00:00
|
|
|
{
|
|
|
|
// create a formatter working with the connections format supplier
|
|
|
|
Reference< XNumberFormatter > xFormatter;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2015-08-03 09:14:58 +02:00
|
|
|
Reference< css::util::XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(_rxConnection, true, _rxContext));
|
2005-01-21 16:19:59 +00:00
|
|
|
|
|
|
|
if ( xSupplier.is() )
|
|
|
|
{
|
|
|
|
// create a new formatter
|
2015-10-30 11:29:18 +02:00
|
|
|
xFormatter.set(util::NumberFormatter::create( _rxContext ), UNO_QUERY_THROW);
|
2012-08-29 09:32:55 +02:00
|
|
|
xFormatter->attachNumberFormatsSupplier(xSupplier);
|
2005-01-21 16:19:59 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-05 15:00:36 +00:00
|
|
|
catch(const Exception&)
|
2005-01-21 16:19:59 +00:00
|
|
|
{
|
2008-05-05 15:00:36 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2005-01-21 16:19:59 +00:00
|
|
|
}
|
|
|
|
return xFormatter;
|
|
|
|
}
|
|
|
|
|
2004-08-02 15:06:20 +00:00
|
|
|
} // dbaui
|
2010-10-12 15:59:03 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|