2000-09-18 15:18:56 +00:00
/*************************************************************************
*
* $ RCSfile : datman . cxx , v $
*
2002-01-30 16:14:44 +00:00
* $ Revision : 1.25 $
2000-09-18 15:18:56 +00:00
*
2002-01-30 16:14:44 +00:00
* last change : $ Author : fs $ $ Date : 2002 - 01 - 30 17 : 14 : 44 $
2000-09-18 15:18:56 +00:00
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc . , October , 2000
*
* GNU Lesser General Public License Version 2.1
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* Copyright 2000 by Sun Microsystems , Inc .
* 901 San Antonio Road , Palo Alto , CA 94303 , USA
*
* This library is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 , as published by the Free Software Foundation .
*
* This library 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 for more details .
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place , Suite 330 , Boston ,
* MA 02111 - 1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 ( 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.openoffice.org/license.html.
*
* Software provided under this License is provided on an " AS IS " basis ,
* WITHOUT WARRANTY OF ANY KIND , EITHER EXPRESSED OR IMPLIED , INCLUDING ,
* WITHOUT LIMITATION , WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS ,
* MERCHANTABLE , FIT FOR A PARTICULAR PURPOSE , OR NON - INFRINGING .
* See the License for the specific provisions governing your rights and
* obligations concerning the Software .
*
* The Initial Developer of the Original Code is : Sun Microsystems , Inc .
*
* Copyright : 2000 by Sun Microsystems , Inc .
*
* All Rights Reserved .
*
* Contributor ( s ) : _______________________________________
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# ifndef _OSL_MUTEX_HXX_
# include <osl/mutex.hxx>
# endif
# ifndef _URLOBJ_HXX
# include <tools/urlobj.hxx>
# endif
2000-11-14 10:06:35 +00:00
# ifndef _COMPHELPER_PROCESSFACTORY_HXX_
# include <comphelper/processfactory.hxx>
2000-09-18 15:18:56 +00:00
# endif
# ifndef _COM_SUN_STAR_IO_XPERSISTOBJECT_HPP_
# include <com/sun/star/io/XPersistObject.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_
# include <com/sun/star/sdbc/ResultSetType.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_
# include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_
# include <com/sun/star/sdbc/XResultSetUpdate.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBCX_XROWLOCATE_HPP_
# include <com/sun/star/sdbcx/XRowLocate.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
# include <com/sun/star/sdbc/DataType.hpp>
# endif
# ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
# include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
# include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
# endif
# ifndef _COM_SUN_STAR_SDB_XDATABASEENVIRONMENT_HPP_
# include <com/sun/star/sdb/XDatabaseEnvironment.hpp>
# endif
# ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
# include <com/sun/star/uno/XNamingService.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
# include <com/sun/star/sdbc/XDataSource.hpp>
# endif
# ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
# include <com/sun/star/sdb/CommandType.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
# include <com/sun/star/sdbcx/XTablesSupplier.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
# include <com/sun/star/sdbc/XConnection.hpp>
# endif
2000-11-14 07:43:41 +00:00
# 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
2000-09-18 15:18:56 +00:00
# ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_
# include <com/sun/star/form/XLoadable.hpp>
# endif
# ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
# include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
# endif
# ifndef _COM_SUN_STAR_FORM_XGRIDCOLUMNFACTORY_HPP_
# include <com/sun/star/form/XGridColumnFactory.hpp>
# endif
# ifndef _COM_SUN_STAR_IO_XDATAINPUTSTREAM_HPP_
# include <com/sun/star/io/XDataInputStream.hpp>
# endif
# ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
# include <com/sun/star/container/XNameContainer.hpp>
# endif
# ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDER_HPP_
# include <com/sun/star/ucb/XContentProvider.hpp>
# endif
# ifndef _COM_SUN_STAR_UCB_XCONTENTACCESS_HPP_
# include <com/sun/star/ucb/XContentAccess.hpp>
# endif
# ifndef _UCBHELPER_CONTENTBROKER_HXX
# include <ucbhelper/contentbroker.hxx>
# endif
# ifndef _UCBHELPER_CONTENT_HXX
# include <ucbhelper/content.hxx>
# endif
# ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX
# include <ucbhelper/contentidentifier.hxx>
# endif
2001-10-22 06:31:42 +00:00
# ifndef _COMPHELPER_CONTAINER_HXX_
# include <comphelper/container.hxx>
# endif
2000-09-18 15:18:56 +00:00
# ifndef SVTOOLS_URIHELPER_HXX
# include <svtools/urihelper.hxx>
# endif
# ifndef _SVTABBX_HXX
# include <svtools/svtabbx.hxx>
# endif
# ifndef _HEADBAR_HXX
# include <svtools/headbar.hxx>
# endif
# ifndef _SV_DIALOG_HXX
# include <vcl/dialog.hxx>
# endif
# ifndef _SV_BUTTON_HXX
# include <vcl/button.hxx>
# endif
# ifndef _SV_LSTBOX_HXX
# include <vcl/lstbox.hxx>
# endif
# ifndef _SV_FIXED_HXX
# include <vcl/fixed.hxx>
# endif
# ifndef _SV_GROUP_HXX
# include <vcl/group.hxx>
# endif
# ifndef _SV_LSTBOX_HXX //autogen wg. form::component::ListBox
# include <vcl/lstbox.hxx>
# endif
# ifndef _SV_EDIT_HXX //autogen wg. Edit
# include <vcl/edit.hxx>
# endif
# ifndef _SV_MSGBOX_HXX
# include <vcl/msgbox.hxx>
# endif
# ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT
# include <tools/debug.hxx>
# endif
# ifndef _BIB_DATMAN_HXX
# include "datman.hxx"
# endif
# ifndef ADRRESID_HXX
# include "bibresid.hxx"
# endif
2000-11-13 10:41:26 +00:00
# ifndef BIBMOD_HXX
2000-09-18 15:18:56 +00:00
# include "bibmod.hxx"
# endif
# ifndef _BIB_VIEW_HXX
# include "bibview.hxx"
# endif
# ifndef _BIB_FMPROP_HRC
# include "bibprop.hrc"
# endif
# ifndef _BIB_TOOLBAR_HXX
# include "toolbar.hxx"
# endif
2000-11-13 10:41:26 +00:00
# ifndef _BIBCONFIG_HXX
# include "bibconfig.hxx"
# endif
2000-09-18 15:18:56 +00:00
# ifndef ADRBEAM_HXX
# include "bibbeam.hxx"
# endif
# ifndef BIB_HRC
# include "bib.hrc"
# endif
# include "datman.hrc"
# ifndef __EXTENSIONS_INC_EXTENSIO_HRC__
# include "extensio.hrc"
# endif
using namespace : : com : : sun : : star ;
using namespace : : com : : sun : : star : : beans ;
using namespace : : com : : sun : : star : : container ;
using namespace : : com : : sun : : star : : uno ;
using namespace : : com : : sun : : star : : sdb ;
using namespace : : com : : sun : : star : : sdbc ;
2001-10-22 06:31:42 +00:00
using namespace : : com : : sun : : star : : sdbcx ;
2000-09-18 15:18:56 +00:00
using namespace : : com : : sun : : star : : form ;
using namespace : : com : : sun : : star : : frame ;
using namespace : : com : : sun : : star : : ucb ;
2000-11-14 14:10:26 +00:00
using namespace : : com : : sun : : star : : lang ;
2000-09-18 15:18:56 +00:00
using namespace : : rtl ;
using namespace : : ucb ;
# define C2U(cChar) OUString::createFromAscii(cChar)
# define C2S(cChar) String::CreateFromAscii(cChar)
# define MAP_TOKEN ';'
# define PAIR_TOKEN ':'
/* -----------------17.01.00 14:38-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2001-10-22 06:31:42 +00:00
Reference < XConnection > getConnection ( const rtl : : OUString & _rURL )
2000-09-18 15:18:56 +00:00
{
// first get the sdb::DataSource corresponding to the url
2001-10-22 06:31:42 +00:00
Reference < XDataSource > xDataSource ;
2000-09-18 15:18:56 +00:00
// is it a favorite title ?
2001-10-22 06:31:42 +00:00
Reference < XMultiServiceFactory > xMgr = comphelper : : getProcessServiceFactory ( ) ;
2000-11-14 07:43:41 +00:00
Reference < XInterface > xNamingContextIfc = xMgr - > createInstance ( C2U ( " com.sun.star.sdb.DatabaseContext " ) ) ;
Reference < XNameAccess > xNamingContext ( xNamingContextIfc , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
if ( xNamingContext . is ( ) & & xNamingContext - > hasByName ( _rURL ) )
{
2000-11-14 07:43:41 +00:00
DBG_ASSERT ( Reference < XNamingService > ( xNamingContext , UNO_QUERY ) . is ( ) , " ::getDataSource : no NamingService interface on the sdb::DatabaseAccessContext ! " ) ;
2001-10-22 06:31:42 +00:00
xDataSource = Reference < XDataSource > ( Reference < XNamingService > ( xNamingContext , UNO_QUERY ) - > getRegisteredObject ( _rURL ) , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
}
// build the connection from the data source
2001-10-22 06:31:42 +00:00
Reference < XConnection > xConn ;
2000-09-18 15:18:56 +00:00
if ( xDataSource . is ( ) )
{
// need user/pwd for this
rtl : : OUString sUser , sPwd ;
2000-11-14 07:43:41 +00:00
Reference < XPropertySet > xDataSourceProps ( xDataSource , UNO_QUERY ) ;
Reference < XCompletedConnection > xComplConn ( xDataSource , UNO_QUERY ) ;
/* Reference< XPropertySetInfo > xInfo = xDataSourceProps.is() ? xDataSourceProps->getPropertySetInfo() : Reference< XPropertySetInfo > ();
2000-09-18 15:18:56 +00:00
if ( xInfo . is ( ) & & xInfo - > hasPropertyByName ( C2U ( " User " ) ) )
xDataSourceProps - > getPropertyValue ( C2U ( " User " ) ) > > = sUser ;
if ( xInfo . is ( ) & & xInfo - > hasPropertyByName ( C2U ( " Password " ) ) )
xDataSourceProps - > getPropertyValue ( C2U ( " Password " ) ) > > = sPwd ;
2000-11-14 07:43:41 +00:00
*/
2000-09-18 15:18:56 +00:00
try
{
2000-11-14 07:43:41 +00:00
Reference < XInterface > xHdl = xMgr - > createInstance ( C2U ( " com.sun.star.sdb.InteractionHandler " ) ) ;
Reference < task : : XInteractionHandler > xIHdl ( xHdl , UNO_QUERY ) ;
xConn = xComplConn - > connectWithCompletion ( xIHdl ) ;
// xConn = xDataSource->getConnection(sUser, sPwd);
2000-09-18 15:18:56 +00:00
}
2001-10-22 06:31:42 +00:00
catch ( SQLException & )
2000-09-18 15:18:56 +00:00
{
// TODO : a real error handling
}
2000-11-14 07:43:41 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
}
}
return xConn ;
}
/* -----------------17.01.00 14:46-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2001-10-22 06:31:42 +00:00
Reference < XConnection > getConnection ( const Reference < XInterface > & xRowSet )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
Reference < XConnection > xConn ;
2000-09-18 15:18:56 +00:00
try
{
2000-11-14 07:43:41 +00:00
Reference < XPropertySet > xFormProps ( xRowSet , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
if ( ! xFormProps . is ( ) )
return xConn ;
2001-10-22 06:31:42 +00:00
xConn = Reference < XConnection > ( * ( Reference < XInterface > * ) xFormProps - > getPropertyValue ( C2U ( " ActiveConnection " ) ) . getValue ( ) , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
if ( ! xConn . is ( ) )
{
2000-11-14 14:10:26 +00:00
DBG_ERROR ( " no active connection " )
2000-09-18 15:18:56 +00:00
}
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " exception in getConnection " ) ;
}
return xConn ;
}
/* -----------------17.01.00 16:07-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2001-10-22 06:31:42 +00:00
Reference < XNameAccess > getColumns ( const Reference < XForm > & _rxForm )
2000-09-18 15:18:56 +00:00
{
2000-11-14 07:43:41 +00:00
Reference < XNameAccess > xReturn ;
2000-09-18 15:18:56 +00:00
// check if the form is alive
2001-10-22 06:31:42 +00:00
Reference < XColumnsSupplier > xSupplyCols ( _rxForm , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
if ( xSupplyCols . is ( ) )
xReturn = xSupplyCols - > getColumns ( ) ;
if ( ! xReturn . is ( ) | | ( xReturn - > getElementNames ( ) . getLength ( ) = = 0 ) )
{ // no ....
xReturn = NULL ;
// -> get the table the form is bound to and ask it for their columns
2001-10-22 06:31:42 +00:00
Reference < XTablesSupplier > xSupplyTables ( getConnection ( _rxForm ) , UNO_QUERY ) ;
Reference < XPropertySet > xFormProps ( _rxForm , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
if ( xFormProps . is ( ) & & xSupplyTables . is ( ) )
{
try
{
DBG_ASSERT ( ( * ( sal_Int32 * ) xFormProps - > getPropertyValue ( C2U ( " CommandType " ) ) . getValue ( ) ) = = CommandType : : TABLE ,
" ::getColumns : invalid form (has no table as data source) ! " ) ;
rtl : : OUString sTable ;
xFormProps - > getPropertyValue ( C2U ( " Command " ) ) > > = sTable ;
2000-11-14 07:43:41 +00:00
Reference < XNameAccess > xTables = xSupplyTables - > getTables ( ) ;
2000-09-18 15:18:56 +00:00
if ( xTables . is ( ) & & xTables - > hasByName ( sTable ) )
2001-10-22 06:31:42 +00:00
xSupplyCols = Reference < XColumnsSupplier > (
2000-11-14 07:43:41 +00:00
* ( Reference < XInterface > * ) xTables - > getByName ( sTable ) . getValue ( ) , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
if ( xSupplyCols . is ( ) )
xReturn = xSupplyCols - > getColumns ( ) ;
}
# ifdef DBG_UTIL
catch ( Exception & e )
# else
catch ( Exception & )
# endif
{
# ifdef DBG_UTIL
String sMsg ( String : : CreateFromAscii ( " ::getColumns : catched an exception ( " ) ) ;
sMsg + = String ( e . Message ) ;
sMsg . AppendAscii ( " ) ... " ) ;
DBG_ERROR ( ByteString ( sMsg , RTL_TEXTENCODING_ASCII_US ) . GetBuffer ( ) ) ;
# endif
}
}
}
return xReturn ;
}
/* -----------------11.11.99 15:54-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
class MappingDialog_Impl : public ModalDialog
{
2001-06-26 09:16:25 +00:00
FixedLine aMapGB ;
2000-09-18 15:18:56 +00:00
FixedText aIdentifierFT ;
ListBox aIdentifierLB ;
FixedText aAuthorityTypeFT ;
ListBox aAuthorityTypeLB ;
FixedText aAuthorFT ;
ListBox aAuthorLB ;
FixedText aTitleFT ;
ListBox aTitleLB ;
FixedText aMonthFT ;
ListBox aMonthLB ;
FixedText aYearFT ;
ListBox aYearLB ;
FixedText aISBNFT ;
ListBox aISBNLB ;
FixedText aBooktitleFT ;
ListBox aBooktitleLB ;
FixedText aChapterFT ;
ListBox aChapterLB ;
FixedText aEditionFT ;
ListBox aEditionLB ;
FixedText aEditorFT ;
ListBox aEditorLB ;
FixedText aHowpublishedFT ;
ListBox aHowpublishedLB ;
FixedText aInstitutionFT ;
ListBox aInstitutionLB ;
FixedText aJournalFT ;
ListBox aJournalLB ;
FixedText aNoteFT ;
ListBox aNoteLB ;
FixedText aAnnoteFT ;
ListBox aAnnoteLB ;
FixedText aNumberFT ;
ListBox aNumberLB ;
FixedText aOrganizationsFT ;
ListBox aOrganizationsLB ;
FixedText aPagesFT ;
ListBox aPagesLB ;
FixedText aPublisherFT ;
ListBox aPublisherLB ;
FixedText aAddressFT ;
ListBox aAddressLB ;
FixedText aSchoolFT ;
ListBox aSchoolLB ;
FixedText aSeriesFT ;
ListBox aSeriesLB ;
FixedText aReportTypeFT ;
ListBox aReportTypeLB ;
FixedText aVolumeFT ;
ListBox aVolumeLB ;
FixedText aURLFT ;
ListBox aURLLB ;
FixedText aCustom1FT ;
ListBox aCustom1LB ;
FixedText aCustom2FT ;
ListBox aCustom2LB ;
FixedText aCustom3FT ;
ListBox aCustom3LB ;
FixedText aCustom4FT ;
ListBox aCustom4LB ;
FixedText aCustom5FT ;
ListBox aCustom5LB ;
2001-08-02 11:23:58 +00:00
OKButton aOKBT ;
CancelButton aCancelBT ;
HelpButton aHelpBT ;
2000-09-18 15:18:56 +00:00
ListBox * aListBoxes [ COLUMN_COUNT ] ;
String sNone ;
2000-12-15 10:09:31 +00:00
sal_Bool bModified ;
2000-09-18 15:18:56 +00:00
BibDataManager * pDatMan ;
DECL_LINK ( OkHdl , OKButton * ) ;
DECL_LINK ( ListBoxSelectHdl , ListBox * ) ;
public :
MappingDialog_Impl ( Window * pParent , BibDataManager * pDatMan ) ;
~ MappingDialog_Impl ( ) ;
2000-12-15 10:09:31 +00:00
void SetModified ( ) { bModified = TRUE ; }
2000-09-18 15:18:56 +00:00
} ;
/* -----------------11.11.99 16:42-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2000-11-13 10:41:26 +00:00
sal_uInt16 lcl_FindLogicalName ( BibConfig * pConfig ,
const OUString & rLogicalColumnName )
2000-09-18 15:18:56 +00:00
{
for ( sal_uInt16 i = 0 ; i < COLUMN_COUNT ; i + + )
{
2000-11-13 10:41:26 +00:00
if ( rLogicalColumnName = = pConfig - > GetDefColumnName ( i ) )
2000-09-18 15:18:56 +00:00
return i ;
}
return USHRT_MAX ;
}
//-----------------------------------------------------------------------------
MappingDialog_Impl : : MappingDialog_Impl ( Window * pParent , BibDataManager * pMan ) :
ModalDialog ( pParent , BibResId ( RID_DLG_MAPPING ) ) ,
pDatMan ( pMan ) ,
aOKBT ( this , ResId ( BT_OK ) ) ,
aCancelBT ( this , ResId ( BT_CANCEL ) ) ,
aHelpBT ( this , ResId ( BT_HELP ) ) ,
aMapGB ( this , ResId ( GB_MAPPING ) ) ,
aIdentifierFT ( this , ResId ( FT_IDENTIFIER ) ) ,
aIdentifierLB ( this , ResId ( LB_IDENTIFIER ) ) ,
aAuthorityTypeFT ( this , ResId ( FT_AUTHORITYTYPE ) ) ,
aAuthorityTypeLB ( this , ResId ( LB_AUTHORITYTYPE ) ) ,
aAuthorFT ( this , ResId ( FT_AUTHOR ) ) ,
aAuthorLB ( this , ResId ( LB_AUTHOR ) ) ,
aTitleFT ( this , ResId ( FT_TITLE ) ) ,
aTitleLB ( this , ResId ( LB_TITLE ) ) ,
aMonthFT ( this , ResId ( FT_MONTH ) ) ,
aMonthLB ( this , ResId ( LB_MONTH ) ) ,
aYearFT ( this , ResId ( FT_YEAR ) ) ,
aYearLB ( this , ResId ( LB_YEAR ) ) ,
aISBNFT ( this , ResId ( FT_ISBN ) ) ,
aISBNLB ( this , ResId ( LB_ISBN ) ) ,
aBooktitleFT ( this , ResId ( FT_BOOKTITLE ) ) ,
aBooktitleLB ( this , ResId ( LB_BOOKTITLE ) ) ,
aChapterFT ( this , ResId ( FT_CHAPTER ) ) ,
aChapterLB ( this , ResId ( LB_CHAPTER ) ) ,
aEditionFT ( this , ResId ( FT_EDITION ) ) ,
aEditionLB ( this , ResId ( LB_EDITION ) ) ,
aEditorFT ( this , ResId ( FT_EDITOR ) ) ,
aEditorLB ( this , ResId ( LB_EDITOR ) ) ,
aHowpublishedFT ( this , ResId ( FT_HOWPUBLISHED ) ) ,
aHowpublishedLB ( this , ResId ( LB_HOWPUBLISHED ) ) ,
aInstitutionFT ( this , ResId ( FT_INSTITUTION ) ) ,
aInstitutionLB ( this , ResId ( LB_INSTITUTION ) ) ,
aJournalFT ( this , ResId ( FT_JOURNAL ) ) ,
aJournalLB ( this , ResId ( LB_JOURNAL ) ) ,
aNoteFT ( this , ResId ( FT_NOTE ) ) ,
aNoteLB ( this , ResId ( LB_NOTE ) ) ,
aAnnoteFT ( this , ResId ( FT_ANNOTE ) ) ,
aAnnoteLB ( this , ResId ( LB_ANNOTE ) ) ,
aNumberFT ( this , ResId ( FT_NUMBER ) ) ,
aNumberLB ( this , ResId ( LB_NUMBER ) ) ,
aOrganizationsFT ( this , ResId ( FT_ORGANIZATIONS ) ) ,
aOrganizationsLB ( this , ResId ( LB_ORGANIZATIONS ) ) ,
aPagesFT ( this , ResId ( FT_PAGES ) ) ,
aPagesLB ( this , ResId ( LB_PAGES ) ) ,
aPublisherFT ( this , ResId ( FT_PUBLISHER ) ) ,
aPublisherLB ( this , ResId ( LB_PUBLISHER ) ) ,
aAddressFT ( this , ResId ( FT_ADDRESS ) ) ,
aAddressLB ( this , ResId ( LB_ADDRESS ) ) ,
aSchoolFT ( this , ResId ( FT_SCHOOL ) ) ,
aSchoolLB ( this , ResId ( LB_SCHOOL ) ) ,
aSeriesFT ( this , ResId ( FT_SERIES ) ) ,
aSeriesLB ( this , ResId ( LB_SERIES ) ) ,
aReportTypeFT ( this , ResId ( FT_REPORTTYPE ) ) ,
aReportTypeLB ( this , ResId ( LB_REPORTTYPE ) ) ,
aVolumeFT ( this , ResId ( FT_VOLUME ) ) ,
aVolumeLB ( this , ResId ( LB_VOLUME ) ) ,
aURLFT ( this , ResId ( FT_URL ) ) ,
aURLLB ( this , ResId ( LB_URL ) ) ,
aCustom1FT ( this , ResId ( FT_CUSTOM1 ) ) ,
aCustom1LB ( this , ResId ( LB_CUSTOM1 ) ) ,
aCustom2FT ( this , ResId ( FT_CUSTOM2 ) ) ,
aCustom2LB ( this , ResId ( LB_CUSTOM2 ) ) ,
aCustom3FT ( this , ResId ( FT_CUSTOM3 ) ) ,
aCustom3LB ( this , ResId ( LB_CUSTOM3 ) ) ,
aCustom4FT ( this , ResId ( FT_CUSTOM4 ) ) ,
aCustom4LB ( this , ResId ( LB_CUSTOM4 ) ) ,
aCustom5FT ( this , ResId ( FT_CUSTOM5 ) ) ,
aCustom5LB ( this , ResId ( LB_CUSTOM5 ) ) ,
2000-12-15 10:09:31 +00:00
sNone ( ResId ( ST_NONE ) ) ,
bModified ( sal_False )
2000-09-18 15:18:56 +00:00
{
FreeResource ( ) ;
2001-07-11 06:53:41 +00:00
aIdentifierFT . SetText ( String ( BibResId ( ST_IDENTIFIER ) ) ) ;
aAuthorityTypeFT . SetText ( String ( BibResId ( ST_AUTHTYPE ) ) ) ;
aAuthorFT . SetText ( String ( BibResId ( ST_AUTHOR ) ) ) ;
aTitleFT . SetText ( String ( BibResId ( ST_TITLE ) ) ) ;
aMonthFT . SetText ( String ( BibResId ( ST_MONTH ) ) ) ;
aYearFT . SetText ( String ( BibResId ( ST_YEAR ) ) ) ;
aISBNFT . SetText ( String ( BibResId ( ST_ISBN ) ) ) ;
aBooktitleFT . SetText ( String ( BibResId ( ST_BOOKTITLE ) ) ) ;
aChapterFT . SetText ( String ( BibResId ( ST_CHAPTER ) ) ) ;
aEditionFT . SetText ( String ( BibResId ( ST_EDITION ) ) ) ;
aEditorFT . SetText ( String ( BibResId ( ST_EDITOR ) ) ) ;
aHowpublishedFT . SetText ( String ( BibResId ( ST_HOWPUBLISHED ) ) ) ;
aInstitutionFT . SetText ( String ( BibResId ( ST_INSTITUTION ) ) ) ;
aJournalFT . SetText ( String ( BibResId ( ST_JOURNAL ) ) ) ;
aNoteFT . SetText ( String ( BibResId ( ST_NOTE ) ) ) ;
aAnnoteFT . SetText ( String ( BibResId ( ST_ANNOTE ) ) ) ;
aNumberFT . SetText ( String ( BibResId ( ST_NUMBER ) ) ) ;
aOrganizationsFT . SetText ( String ( BibResId ( ST_ORGANIZATION ) ) ) ;
aPagesFT . SetText ( String ( BibResId ( ST_PAGE ) ) ) ;
aPublisherFT . SetText ( String ( BibResId ( ST_PUBLISHER ) ) ) ;
aAddressFT . SetText ( String ( BibResId ( ST_ADDRESS ) ) ) ;
aSchoolFT . SetText ( String ( BibResId ( ST_SCHOOL ) ) ) ;
aSeriesFT . SetText ( String ( BibResId ( ST_SERIES ) ) ) ;
aReportTypeFT . SetText ( String ( BibResId ( ST_REPORT ) ) ) ;
aVolumeFT . SetText ( String ( BibResId ( ST_VOLUME ) ) ) ;
aURLFT . SetText ( String ( BibResId ( ST_URL ) ) ) ;
aCustom1FT . SetText ( String ( BibResId ( ST_CUSTOM1 ) ) ) ;
aCustom2FT . SetText ( String ( BibResId ( ST_CUSTOM2 ) ) ) ;
aCustom3FT . SetText ( String ( BibResId ( ST_CUSTOM3 ) ) ) ;
aCustom4FT . SetText ( String ( BibResId ( ST_CUSTOM4 ) ) ) ;
aCustom5FT . SetText ( String ( BibResId ( ST_CUSTOM5 ) ) ) ;
2000-09-18 15:18:56 +00:00
aOKBT . SetClickHdl ( LINK ( this , MappingDialog_Impl , OkHdl ) ) ;
String sTitle = GetText ( ) ;
sTitle . SearchAndReplace ( C2S ( " %1 " ) , pDatMan - > getActiveDataTable ( ) , 0 ) ;
SetText ( sTitle ) ;
aListBoxes [ 0 ] = & aIdentifierLB ;
aListBoxes [ 1 ] = & aAuthorityTypeLB ;
aListBoxes [ 2 ] = & aAuthorLB ;
aListBoxes [ 3 ] = & aTitleLB ;
aListBoxes [ 4 ] = & aYearLB ;
aListBoxes [ 5 ] = & aISBNLB ;
aListBoxes [ 6 ] = & aBooktitleLB ;
aListBoxes [ 7 ] = & aChapterLB ;
aListBoxes [ 8 ] = & aEditionLB ;
aListBoxes [ 9 ] = & aEditorLB ;
aListBoxes [ 10 ] = & aHowpublishedLB ;
aListBoxes [ 11 ] = & aInstitutionLB ;
aListBoxes [ 12 ] = & aJournalLB ;
aListBoxes [ 13 ] = & aMonthLB ;
aListBoxes [ 14 ] = & aNoteLB ;
aListBoxes [ 15 ] = & aAnnoteLB ;
aListBoxes [ 16 ] = & aNumberLB ;
aListBoxes [ 17 ] = & aOrganizationsLB ;
aListBoxes [ 18 ] = & aPagesLB ;
aListBoxes [ 19 ] = & aPublisherLB ;
aListBoxes [ 20 ] = & aAddressLB ;
aListBoxes [ 21 ] = & aSchoolLB ;
aListBoxes [ 22 ] = & aSeriesLB ;
aListBoxes [ 23 ] = & aReportTypeLB ;
aListBoxes [ 24 ] = & aVolumeLB ;
aListBoxes [ 25 ] = & aURLLB ;
aListBoxes [ 26 ] = & aCustom1LB ;
aListBoxes [ 27 ] = & aCustom2LB ;
aListBoxes [ 28 ] = & aCustom3LB ;
aListBoxes [ 29 ] = & aCustom4LB ;
aListBoxes [ 30 ] = & aCustom5LB ;
aListBoxes [ 0 ] - > InsertEntry ( sNone ) ;
2001-10-22 06:31:42 +00:00
Reference < XNameAccess > xFields = getColumns ( pDatMan - > getForm ( ) ) ;
2000-09-18 15:18:56 +00:00
DBG_ASSERT ( xFields . is ( ) , " MappingDialog_Impl::MappingDialog_Impl : gave me an invalid form ! " ) ;
2000-11-14 07:43:41 +00:00
Sequence < rtl : : OUString > aNames = xFields - > getElementNames ( ) ;
2000-09-18 15:18:56 +00:00
sal_Int32 nFieldsCount = aNames . getLength ( ) ;
const rtl : : OUString * pNames = aNames . getConstArray ( ) ;
for ( sal_Int32 nField = 0 ; nField < nFieldsCount ; nField + + )
aListBoxes [ 0 ] - > InsertEntry ( pNames [ nField ] ) ;
Link aLnk = LINK ( this , MappingDialog_Impl , ListBoxSelectHdl ) ;
aListBoxes [ 0 ] - > SelectEntryPos ( 0 ) ;
aListBoxes [ 0 ] - > SetSelectHdl ( aLnk ) ;
for ( sal_uInt16 i = 1 ; i < COLUMN_COUNT ; i + + )
{
for ( sal_uInt16 j = 0 ; j < aListBoxes [ 0 ] - > GetEntryCount ( ) ; j + + )
aListBoxes [ i ] - > InsertEntry ( aListBoxes [ 0 ] - > GetEntry ( j ) ) ;
aListBoxes [ i ] - > SelectEntryPos ( 0 ) ;
aListBoxes [ i ] - > SetSelectHdl ( aLnk ) ;
}
2000-11-13 10:41:26 +00:00
BibConfig * pConfig = BibModul : : GetConfig ( ) ;
BibDBDescriptor aDesc ;
aDesc . sDataSource = pDatMan - > getActiveDataSource ( ) ;
aDesc . sTableOrQuery = pDatMan - > getActiveDataTable ( ) ;
aDesc . nCommandType = CommandType : : TABLE ;
const Mapping * pMapping = pConfig - > GetMapping ( aDesc ) ;
2000-09-18 15:18:56 +00:00
if ( pMapping )
{
for ( sal_uInt16 nEntry = 0 ; nEntry < COLUMN_COUNT ; nEntry + + )
{
2000-11-13 10:41:26 +00:00
sal_uInt16 nListBoxIndex = lcl_FindLogicalName ( pConfig , pMapping - > aColumnPairs [ nEntry ] . sLogicalColumnName ) ;
2000-09-18 15:18:56 +00:00
if ( nListBoxIndex < COLUMN_COUNT )
{
aListBoxes [ nListBoxIndex ] - > SelectEntry ( pMapping - > aColumnPairs [ nEntry ] . sRealColumnName ) ;
}
}
}
}
/* -----------------11.11.99 16:44-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
MappingDialog_Impl : : ~ MappingDialog_Impl ( )
{ }
/* -----------------15.11.99 10:38-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
IMPL_LINK ( MappingDialog_Impl , ListBoxSelectHdl , ListBox * , pListBox )
{
sal_uInt16 nEntryPos = pListBox - > GetSelectEntryPos ( ) ;
if ( 0 < nEntryPos )
{
for ( sal_uInt16 i = 0 ; i < COLUMN_COUNT ; i + + )
{
if ( pListBox ! = aListBoxes [ i ] & & aListBoxes [ i ] - > GetSelectEntryPos ( ) = = nEntryPos )
aListBoxes [ i ] - > SelectEntryPos ( 0 ) ;
}
}
2000-12-15 10:09:31 +00:00
SetModified ( ) ;
2000-09-18 15:18:56 +00:00
return 0 ;
}
/* -----------------12.11.99 14:50-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
IMPL_LINK ( MappingDialog_Impl , OkHdl , OKButton * , EMPTYARG )
{
2000-12-15 10:09:31 +00:00
if ( bModified )
2000-09-18 15:18:56 +00:00
{
2000-12-15 10:09:31 +00:00
Mapping aNew ;
aNew . sTableName = String ( pDatMan - > getActiveDataTable ( ) ) ;
aNew . sURL = String ( pDatMan - > getActiveDataSource ( ) ) ;
sal_uInt16 nWriteIndex = 0 ;
BibConfig * pConfig = BibModul : : GetConfig ( ) ;
for ( sal_uInt16 nEntry = 0 ; nEntry < COLUMN_COUNT ; nEntry + + )
2000-09-18 15:18:56 +00:00
{
2000-12-15 10:09:31 +00:00
String sSel = aListBoxes [ nEntry ] - > GetSelectEntry ( ) ;
if ( sSel ! = sNone )
{
aNew . aColumnPairs [ nWriteIndex ] . sRealColumnName = sSel ;
aNew . aColumnPairs [ nWriteIndex ] . sLogicalColumnName = pConfig - > GetDefColumnName ( nEntry ) ;
nWriteIndex + + ;
}
2000-09-18 15:18:56 +00:00
}
2000-12-15 10:09:31 +00:00
BibDBDescriptor aDesc ;
aDesc . sDataSource = pDatMan - > getActiveDataSource ( ) ;
aDesc . sTableOrQuery = pDatMan - > getActiveDataTable ( ) ;
aDesc . nCommandType = CommandType : : TABLE ;
pDatMan - > ResetIdentifierMapping ( ) ;
pConfig - > SetMapping ( aDesc , & aNew ) ;
2000-09-18 15:18:56 +00:00
}
2000-12-15 10:09:31 +00:00
EndDialog ( bModified ? RET_OK : RET_CANCEL ) ;
2000-09-18 15:18:56 +00:00
return 0 ;
}
/* -----------------18.11.99 10:23-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
class DBChangeDialog_Impl : public ModalDialog
{
2001-06-26 09:16:25 +00:00
FixedLine aSelectionGB ;
2000-09-18 15:18:56 +00:00
SvTabListBox aSelectionLB ;
HeaderBar aSelectionHB ;
2001-08-02 11:23:58 +00:00
OKButton aOKBT ;
CancelButton aCancelBT ;
HelpButton aHelpBT ;
2000-11-20 11:23:38 +00:00
DBChangeDialogConfig_Impl aConfig ;
2000-09-18 15:18:56 +00:00
String aEntryST ;
String aURLST ;
BibDataManager * pDatMan ;
2000-11-20 11:23:38 +00:00
// DECL_LINK(EndDragHdl, HeaderBar*);
2000-09-18 15:18:56 +00:00
DECL_LINK ( DoubleClickHdl , SvTabListBox * ) ;
public :
DBChangeDialog_Impl ( Window * pParent , BibDataManager * pMan ) ;
~ DBChangeDialog_Impl ( ) ;
String GetCurrentURL ( ) const ;
} ;
/*-- 18.11.99 10:35:20---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
DBChangeDialog_Impl : : DBChangeDialog_Impl ( Window * pParent , BibDataManager * pMan ) :
ModalDialog ( pParent , BibResId ( RID_DLG_DBCHANGE ) ) ,
aOKBT ( this , ResId ( BT_OK ) ) ,
aCancelBT ( this , ResId ( BT_CANCEL ) ) ,
aHelpBT ( this , ResId ( BT_HELP ) ) ,
aSelectionGB ( this , ResId ( GB_SELECTION ) ) ,
aSelectionLB ( this , ResId ( LB_SELECTION ) ) ,
aSelectionHB ( this , ResId ( HB_SELECTION ) ) ,
aEntryST ( ResId ( ST_ENTRY ) ) ,
aURLST ( ResId ( ST_URL ) ) ,
pDatMan ( pMan )
{
FreeResource ( ) ;
aSelectionLB . SetDoubleClickHdl ( LINK ( this , DBChangeDialog_Impl , DoubleClickHdl ) ) ;
try
{
2001-10-22 06:31:42 +00:00
Reference < XMultiServiceFactory > xMgr = comphelper : : getProcessServiceFactory ( ) ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
: : Size aSize = aSelectionHB . GetSizePixel ( ) ;
2000-11-20 11:23:38 +00:00
long nTabs [ 2 ] ;
nTabs [ 0 ] = 1 ; // Number of Tabs
nTabs [ 1 ] = aSize . Width ( ) / 4 ;
2000-09-18 15:18:56 +00:00
aSelectionHB . SetStyle ( aSelectionHB . GetStyle ( ) | WB_STDHEADERBAR ) ;
2000-11-20 11:23:38 +00:00
aSelectionHB . InsertItem ( 1 , aEntryST , aSize . Width ( ) ) ;
2000-09-18 15:18:56 +00:00
aSelectionHB . SetSizePixel ( aSelectionHB . CalcWindowSizePixel ( ) ) ;
aSelectionHB . Show ( ) ;
aSelectionLB . SetHelpId ( HID_SELECTION_TLB ) ;
aSelectionLB . SetTabs ( & nTabs [ 0 ] , MAP_PIXEL ) ;
aSelectionLB . SetWindowBits ( WB_CLIPCHILDREN | WB_SORT ) ;
aSelectionLB . GetModel ( ) - > SetSortMode ( SortAscending ) ;
2000-11-20 11:23:38 +00:00
OUString sActiveSource = pDatMan - > getActiveDataSource ( ) ;
const Sequence < OUString > & rSources = aConfig . GetDataSourceNames ( ) ;
const OUString * pSourceNames = rSources . getConstArray ( ) ;
for ( int i = 0 ; i < rSources . getLength ( ) ; i + + )
{
SvLBoxEntry * pEntry = aSelectionLB . InsertEntry ( pSourceNames [ i ] ) ;
if ( pSourceNames [ i ] = = sActiveSource )
{
aSelectionLB . Select ( pEntry ) ;
}
}
aSelectionLB . GetModel ( ) - > Resort ( ) ;
2000-09-18 15:18:56 +00:00
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " Exception in BibDataManager::DBChangeDialog_Impl::DBChangeDialog_Impl " )
}
}
/* -----------------06.12.99 12:09-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
IMPL_LINK ( DBChangeDialog_Impl , DoubleClickHdl , SvTabListBox * , pLB )
{
EndDialog ( RET_OK ) ;
return 0 ;
}
/* -----------------18.11.99 11:17-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2000-11-20 11:23:38 +00:00
/*IMPL_LINK(DBChangeDialog_Impl, EndDragHdl, HeaderBar*, pHB)
2000-09-18 15:18:56 +00:00
{
long nTabs [ 3 ] ;
nTabs [ 0 ] = 2 ; // Number of Tabs
nTabs [ 1 ] = 0 ;
nTabs [ 2 ] = pHB - > GetItemSize ( 1 ) ;
aSelectionLB . SetTabs ( & nTabs [ 0 ] , MAP_PIXEL ) ;
return 0 ;
2000-11-20 11:23:38 +00:00
} ; */
2000-09-18 15:18:56 +00:00
/*-- 18.11.99 10:35:20---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
DBChangeDialog_Impl : : ~ DBChangeDialog_Impl ( )
{
}
/* -----------------18.11.99 12:36-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
String DBChangeDialog_Impl : : GetCurrentURL ( ) const
{
String sRet ;
SvLBoxEntry * pEntry = aSelectionLB . FirstSelected ( ) ;
if ( pEntry )
{
2000-11-20 11:23:38 +00:00
sRet = aSelectionLB . GetEntryText ( pEntry , 0 ) ;
2000-09-18 15:18:56 +00:00
}
return sRet ;
}
//-----------------------------------------------------------------------------
# define STR_UID "uid"
rtl : : OUString gGridName ( C2U ( " theGrid " ) ) ;
rtl : : OUString gViewName ( C2U ( " theView " ) ) ;
rtl : : OUString gGlobalName ( C2U ( " theGlobals " ) ) ;
rtl : : OUString gBeamerSize ( C2U ( " theBeamerSize " ) ) ;
rtl : : OUString gViewSize ( C2U ( " theViewSize " ) ) ;
2001-10-22 06:31:42 +00:00
BibDataManager : : BibDataManager ( )
: BibDataManager_Base ( GetMutex ( ) )
, pToolbar ( 0 )
, pBibView ( NULL )
, m_aLoadListeners ( m_aMutex )
2000-09-18 15:18:56 +00:00
{
}
/* --------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
BibDataManager : : ~ BibDataManager ( )
{
2001-10-22 06:31:42 +00:00
Reference < XLoadable > xLoad ( m_xForm , UNO_QUERY ) ;
Reference < XPropertySet > xPrSet ( m_xForm , UNO_QUERY ) ;
Reference < XComponent > xComp ( m_xForm , UNO_QUERY ) ;
if ( m_xForm . is ( ) )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
Reference < XComponent > xConnection ;
2000-11-14 14:10:26 +00:00
xPrSet - > getPropertyValue ( C2U ( " ActiveConnection " ) ) > > = xConnection ;
2000-09-18 15:18:56 +00:00
RemoveMeAsUidListener ( ) ;
if ( xLoad . is ( ) )
xLoad - > unload ( ) ;
if ( xComp . is ( ) )
xComp - > dispose ( ) ;
2000-11-14 14:10:26 +00:00
if ( xConnection . is ( ) )
xConnection - > dispose ( ) ;
2001-10-22 06:31:42 +00:00
m_xForm = NULL ;
2000-09-18 15:18:56 +00:00
}
}
//------------------------------------------------------------------------
2001-10-22 06:31:42 +00:00
void BibDataManager : : InsertFields ( const Reference < XFormComponent > & _rxGrid )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
if ( ! _rxGrid . is ( ) )
2000-09-18 15:18:56 +00:00
return ;
2001-10-22 06:31:42 +00:00
try
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
Reference < XNameContainer > xColContainer ( _rxGrid , UNO_QUERY ) ;
// remove the old fields
if ( xColContainer - > hasElements ( ) )
2001-02-12 07:35:59 +00:00
{
2001-10-22 06:31:42 +00:00
Sequence < : : rtl : : OUString > aNames = xColContainer - > getElementNames ( ) ;
const : : rtl : : OUString * pNames = aNames . getConstArray ( ) ;
const : : rtl : : OUString * pNamesEnd = pNames + aNames . getLength ( ) ;
for ( ; pNames ! = pNamesEnd ; + + pNames )
xColContainer - > removeByName ( * pNames ) ;
2001-02-12 07:35:59 +00:00
}
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
Reference < XNameAccess > xFields = getColumns ( m_xForm ) ;
if ( ! xFields . is ( ) )
return ;
Reference < XGridColumnFactory > xColFactory ( _rxGrid , UNO_QUERY ) ;
Reference < XPropertySet > xField ;
Sequence < rtl : : OUString > aFields ( xFields - > getElementNames ( ) ) ;
const rtl : : OUString * pFields = aFields . getConstArray ( ) ;
const rtl : : OUString * pFieldsEnd = pFields + aFields . getLength ( ) ;
for ( ; pFields ! = pFieldsEnd ; + + pFields )
2001-02-12 07:35:59 +00:00
{
2001-10-22 06:31:42 +00:00
xFields - > getByName ( * pFields ) > > = xField ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
OUString sCurrentModelType ;
const OUString sType ( C2U ( " Type " ) ) ;
sal_Int32 nType = 0 ;
sal_Bool bIsFormatted = sal_False ;
sal_Bool bFormattedIsNumeric = sal_True ;
xField - > getPropertyValue ( sType ) > > = nType ;
switch ( nType )
{
case DataType : : BIT :
sCurrentModelType = C2U ( " CheckBox " ) ;
break ;
case DataType : : BINARY :
case DataType : : VARBINARY :
case DataType : : LONGVARBINARY :
sCurrentModelType = C2U ( " TextField " ) ;
break ;
case DataType : : VARCHAR :
case DataType : : LONGVARCHAR :
case DataType : : CHAR :
bFormattedIsNumeric = sal_False ;
// _NO_ break !
default :
sCurrentModelType = C2U ( " FormattedField " ) ;
bIsFormatted = sal_True ;
break ;
}
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
Reference < XPropertySet > xCurrentCol = xColFactory - > createColumn ( sCurrentModelType ) ;
if ( bIsFormatted )
{
OUString sFormatKey ( C2U ( " FormatKey " ) ) ;
xCurrentCol - > setPropertyValue ( sFormatKey , xField - > getPropertyValue ( sFormatKey ) ) ;
Any aFormatted ( & bFormattedIsNumeric , : : getBooleanCppuType ( ) ) ;
xCurrentCol - > setPropertyValue ( C2U ( " TreatAsNumber " ) , aFormatted ) ;
}
Any aColName = makeAny ( * pFields ) ;
xCurrentCol - > setPropertyValue ( FM_PROP_CONTROLSOURCE , aColName ) ;
xCurrentCol - > setPropertyValue ( FM_PROP_LABEL , aColName ) ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
xColContainer - > insertByName ( * pFields , makeAny ( xCurrentCol ) ) ;
}
}
catch ( Exception & e )
{
e ; // make compiler happy
DBG_ERROR ( " Exception in BibDataManager::InsertFields " )
}
2000-09-18 15:18:56 +00:00
}
/* --------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2001-10-23 10:51:16 +00:00
Reference < awt : : XControlModel > BibDataManager : : updateGridModel ( )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
return updateGridModel ( m_xForm ) ;
2000-09-18 15:18:56 +00:00
}
/* --------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2001-10-23 10:51:16 +00:00
Reference < awt : : XControlModel > BibDataManager : : updateGridModel ( const Reference < XForm > & xDbForm )
2000-09-18 15:18:56 +00:00
{
try
{
2000-11-14 07:43:41 +00:00
Reference < XPropertySet > aFormPropSet ( xDbForm , UNO_QUERY ) ;
2001-10-22 06:31:42 +00:00
rtl : : OUString sName ;
aFormPropSet - > getPropertyValue ( C2U ( " Command " ) ) > > = sName ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
if ( ! m_xGridModel . is ( ) )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
m_xGridModel = createGridModel ( gGridName ) ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
Reference < XNameContainer > xNameCont ( xDbForm , UNO_QUERY ) ;
// if (xNameCont->hasByName(sName))
// xNameCont->removeByName(sName);
//
xNameCont - > insertByName ( sName , makeAny ( m_xGridModel ) ) ;
}
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
// insert the fields
Reference < XFormComponent > xFormComp ( m_xGridModel , UNO_QUERY ) ;
InsertFields ( xFormComp ) ;
2000-09-18 15:18:56 +00:00
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2001-10-22 06:31:42 +00:00
DBG_ERROR ( " ::updateGridModel: something went wrong ! " ) ;
2000-09-18 15:18:56 +00:00
}
2001-10-22 06:31:42 +00:00
return m_xGridModel ;
2000-09-18 15:18:56 +00:00
}
/* --------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2000-11-14 07:43:41 +00:00
Reference < XForm > BibDataManager : : createDatabaseForm ( BibDBDescriptor & rDesc )
2000-09-18 15:18:56 +00:00
{
2000-11-14 07:43:41 +00:00
Reference < XForm > xResult ;
2000-09-18 15:18:56 +00:00
try
{
2001-10-22 06:31:42 +00:00
Reference < XMultiServiceFactory > xMgr = comphelper : : getProcessServiceFactory ( ) ;
m_xForm = Reference < XForm > ( xMgr - > createInstance ( C2U ( " com.sun.star.form.component.Form " ) ) , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
Reference < XPropertySet > aPropertySet ( m_xForm , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
2000-11-13 10:41:26 +00:00
aDataSourceURL = rDesc . sDataSource ;
2000-09-18 15:18:56 +00:00
if ( aPropertySet . is ( ) )
{
2000-11-14 14:10:26 +00:00
Any aVal ;
2001-10-22 06:31:42 +00:00
aVal < < = ( sal_Int32 ) ResultSetType : : SCROLL_INSENSITIVE ;
2000-09-18 15:18:56 +00:00
aPropertySet - > setPropertyValue ( C2U ( " ResultSetType " ) , aVal ) ;
2001-10-22 06:31:42 +00:00
aVal < < = ( sal_Int32 ) ResultSetConcurrency : : READ_ONLY ;
2000-09-18 15:18:56 +00:00
aPropertySet - > setPropertyValue ( C2U ( " ResultSetConcurrency " ) , aVal ) ;
//Caching for Performance
aVal < < = ( sal_Int32 ) 50 ;
aPropertySet - > setPropertyValue ( C2U ( " FetchSize " ) , aVal ) ;
2001-10-22 06:31:42 +00:00
Reference < XConnection > xConnection = getConnection ( rDesc . sDataSource ) ;
2000-11-14 14:10:26 +00:00
aVal < < = xConnection ;
aPropertySet - > setPropertyValue ( C2U ( " ActiveConnection " ) , aVal ) ;
2001-10-22 06:31:42 +00:00
Reference < XTablesSupplier > xSupplyTables ( xConnection , UNO_QUERY ) ;
2000-11-14 07:43:41 +00:00
Reference < XNameAccess > xTables = xSupplyTables . is ( ) ?
xSupplyTables - > getTables ( ) : Reference < XNameAccess > ( ) ;
2000-09-18 15:18:56 +00:00
2000-11-14 07:43:41 +00:00
Sequence < rtl : : OUString > aTableNameSeq ;
2000-09-18 15:18:56 +00:00
if ( xTables . is ( ) )
aTableNameSeq = xTables - > getElementNames ( ) ;
if ( aTableNameSeq . getLength ( ) > 0 )
{
const rtl : : OUString * pTableNames = aTableNameSeq . getConstArray ( ) ;
2000-11-13 10:41:26 +00:00
if ( rDesc . sTableOrQuery . getLength ( ) )
aActiveDataTable = rDesc . sTableOrQuery ;
2000-09-18 15:18:56 +00:00
else
2000-11-13 10:41:26 +00:00
{
rDesc . sTableOrQuery = aActiveDataTable = pTableNames [ 0 ] ;
rDesc . nCommandType = CommandType : : TABLE ;
}
2000-09-18 15:18:56 +00:00
aVal < < = aActiveDataTable ;
aPropertySet - > setPropertyValue ( C2U ( " Command " ) , aVal ) ;
2000-11-13 10:41:26 +00:00
aVal < < = rDesc . nCommandType ;
2000-09-18 15:18:56 +00:00
aPropertySet - > setPropertyValue ( C2U ( " CommandType " ) , aVal ) ;
2001-10-22 06:31:42 +00:00
Reference < XDatabaseMetaData > xMetaData = xConnection - > getMetaData ( ) ;
2000-09-18 15:18:56 +00:00
aQuoteChar = xMetaData - > getIdentifierQuoteString ( ) ;
2000-11-14 07:43:41 +00:00
Reference < sdb : : XSQLQueryComposerFactory > xFactory ( xConnection , UNO_QUERY ) ;
2001-10-22 06:31:42 +00:00
m_xParser = xFactory - > createQueryComposer ( ) ;
2000-09-18 15:18:56 +00:00
rtl : : OUString aString ( C2U ( " SELECT * FROM " ) ) ;
aString + = aQuoteChar ;
aString + = aActiveDataTable ;
aString + = aQuoteChar ;
2001-10-22 06:31:42 +00:00
m_xParser - > setQuery ( aString ) ;
2000-12-01 11:46:59 +00:00
BibConfig * pConfig = BibModul : : GetConfig ( ) ;
pConfig - > setQueryField ( getQueryField ( ) ) ;
startQueryWith ( pConfig - > getQueryText ( ) ) ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
xResult = m_xForm ;
2000-09-18 15:18:56 +00:00
}
}
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " ::createDatabaseForm: something went wrong ! " ) ;
}
return xResult ;
}
//------------------------------------------------------------------------
2000-11-14 07:43:41 +00:00
Sequence < rtl : : OUString > BibDataManager : : getDataSources ( )
2000-09-18 15:18:56 +00:00
{
2000-11-14 07:43:41 +00:00
Sequence < rtl : : OUString > aTableNameSeq ;
2000-09-18 15:18:56 +00:00
try
{
2001-10-22 06:31:42 +00:00
Reference < XTablesSupplier > xSupplyTables ( getConnection ( m_xForm ) , UNO_QUERY ) ;
2000-11-14 07:43:41 +00:00
Reference < XNameAccess > xTables ;
2000-09-18 15:18:56 +00:00
if ( xSupplyTables . is ( ) )
xTables = xSupplyTables - > getTables ( ) ;
if ( xTables . is ( ) )
aTableNameSeq = xTables - > getElementNames ( ) ;
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " ::getDataSources: something went wrong ! " ) ;
}
return aTableNameSeq ;
}
//------------------------------------------------------------------------
rtl : : OUString BibDataManager : : getActiveDataTable ( )
{
return aActiveDataTable ;
}
//------------------------------------------------------------------------
void BibDataManager : : setFilter ( const rtl : : OUString & rQuery )
{
try
{
2001-10-22 06:31:42 +00:00
m_xParser - > setFilter ( rQuery ) ;
rtl : : OUString aQuery = m_xParser - > getFilter ( ) ;
Reference < XPropertySet > aPropertySet ( m_xForm , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
Any aVal ; aVal < < = aQuery ;
aPropertySet - > setPropertyValue ( C2U ( " Filter " ) , aVal ) ;
BOOL bVal = sal_True ;
aVal . setValue ( & bVal , : : getBooleanCppuType ( ) ) ;
aPropertySet - > setPropertyValue ( C2U ( " ApplyFilter " ) , aVal ) ;
2001-10-22 06:31:42 +00:00
reload ( ) ;
2000-09-18 15:18:56 +00:00
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " ::setFilterOnActiveDataSource: something went wrong ! " ) ;
}
}
//------------------------------------------------------------------------
rtl : : OUString BibDataManager : : getFilter ( )
{
rtl : : OUString aQueryString ;
try
{
2001-10-22 06:31:42 +00:00
Reference < XPropertySet > aPropertySet ( m_xForm , UNO_QUERY ) ;
2000-11-14 07:43:41 +00:00
Any aQuery = aPropertySet - > getPropertyValue ( C2U ( " Filter " ) ) ;
2000-09-18 15:18:56 +00:00
if ( aQuery . getValueType ( ) = = : : getCppuType ( ( OUString * ) 0 ) )
{
aQueryString = * ( OUString * ) aQuery . getValue ( ) ;
}
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " ::getFilterOnActiveDataSource: something went wrong ! " ) ;
}
return aQueryString ;
}
//------------------------------------------------------------------------
2000-11-14 07:43:41 +00:00
Sequence < rtl : : OUString > BibDataManager : : getQueryFields ( )
2000-09-18 15:18:56 +00:00
{
2000-11-14 07:43:41 +00:00
Sequence < rtl : : OUString > aFieldSeq ;
2001-10-22 06:31:42 +00:00
Reference < XNameAccess > xFields = getColumns ( m_xForm ) ;
2000-09-18 15:18:56 +00:00
if ( xFields . is ( ) )
aFieldSeq = xFields - > getElementNames ( ) ;
return aFieldSeq ;
}
//------------------------------------------------------------------------
rtl : : OUString BibDataManager : : getQueryField ( )
{
2000-12-01 11:46:59 +00:00
BibConfig * pConfig = BibModul : : GetConfig ( ) ;
OUString aFieldString = pConfig - > getQueryField ( ) ;
if ( ! aFieldString . getLength ( ) )
2000-09-18 15:18:56 +00:00
{
2000-12-01 11:46:59 +00:00
Sequence < rtl : : OUString > aSeq = getQueryFields ( ) ;
const rtl : : OUString * pFields = aSeq . getConstArray ( ) ;
if ( aSeq . getLength ( ) > 0 )
2000-09-18 15:18:56 +00:00
{
2000-12-01 11:46:59 +00:00
aFieldString = pFields [ 0 ] ;
2000-09-18 15:18:56 +00:00
}
}
return aFieldString ;
}
//------------------------------------------------------------------------
void BibDataManager : : startQueryWith ( const OUString & rQuery )
{
2000-12-01 11:46:59 +00:00
BibConfig * pConfig = BibModul : : GetConfig ( ) ;
pConfig - > setQueryText ( rQuery ) ;
2000-11-27 13:15:21 +00:00
2000-09-18 15:18:56 +00:00
rtl : : OUString aQueryString ;
2001-05-11 09:26:36 +00:00
if ( rQuery . getLength ( ) > 0 )
2000-09-18 15:18:56 +00:00
{
2000-12-01 11:46:59 +00:00
aQueryString = aQuoteChar ;
aQueryString + = getQueryField ( ) ;
aQueryString + = aQuoteChar ;
aQueryString + = C2U ( " like ' " ) ;
String sQuery ( rQuery ) ;
sQuery . SearchAndReplaceAll ( ' ? ' , ' _ ' ) ;
sQuery . SearchAndReplaceAll ( ' * ' , ' % ' ) ;
aQueryString + = sQuery ;
aQueryString + = C2U ( " %' " ) ;
2000-11-27 13:15:21 +00:00
}
2000-12-01 11:46:59 +00:00
setFilter ( aQueryString ) ;
2000-09-18 15:18:56 +00:00
}
/* -----------------03.12.99 15:05-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void BibDataManager : : setActiveDataSource ( const rtl : : OUString & rURL )
{
rtl : : OUString uTable ;
2001-05-04 12:57:24 +00:00
rtl : : OUString sTmp ( aDataSourceURL ) ;
2000-09-18 15:18:56 +00:00
aDataSourceURL = rURL ;
2001-10-22 06:31:42 +00:00
Reference < XPropertySet > aPropertySet ( m_xForm , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
if ( aPropertySet . is ( ) )
{
2001-10-22 06:31:42 +00:00
unload ( ) ;
2000-11-14 14:10:26 +00:00
Reference < XComponent > xOldConnection ;
aPropertySet - > getPropertyValue ( C2U ( " ActiveConnection " ) ) > > = xOldConnection ;
2001-10-22 06:31:42 +00:00
Reference < XConnection > xConnection = getConnection ( rURL ) ;
2001-05-04 12:57:24 +00:00
if ( ! xConnection . is ( ) )
{
aDataSourceURL = sTmp ;
return ;
}
2000-11-14 14:10:26 +00:00
Any aVal ; aVal < < = xConnection ;
aPropertySet - > setPropertyValue ( C2U ( " ActiveConnection " ) , aVal ) ;
2000-11-20 11:23:38 +00:00
Reference < sdb : : XSQLQueryComposerFactory > xFactory ( xConnection , UNO_QUERY ) ;
2001-10-22 06:31:42 +00:00
m_xParser = xFactory - > createQueryComposer ( ) ;
2000-11-20 11:23:38 +00:00
if ( xOldConnection . is ( ) )
xOldConnection - > dispose ( ) ;
2000-11-14 14:10:26 +00:00
2000-11-14 07:43:41 +00:00
Sequence < rtl : : OUString > aTableNameSeq ;
2001-10-22 06:31:42 +00:00
Reference < XTablesSupplier > xSupplyTables ( xConnection , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
if ( xSupplyTables . is ( ) )
{
2000-11-14 07:43:41 +00:00
Reference < XNameAccess > xAccess = xSupplyTables - > getTables ( ) ;
2000-09-18 15:18:56 +00:00
aTableNameSeq = xAccess - > getElementNames ( ) ;
}
if ( aTableNameSeq . getLength ( ) > 0 )
{
const rtl : : OUString * pTableNames = aTableNameSeq . getConstArray ( ) ;
aActiveDataTable = pTableNames [ 0 ] ;
aVal < < = aActiveDataTable ;
aPropertySet - > setPropertyValue ( C2U ( " Command " ) , aVal ) ;
rtl : : OUString aString ( C2U ( " SELECT * FROM " ) ) ;
aString + = aQuoteChar ;
aString + = aActiveDataTable ;
aString + = aQuoteChar ;
2001-10-22 06:31:42 +00:00
m_xParser - > setQuery ( aString ) ;
2000-12-01 11:46:59 +00:00
BibConfig * pConfig = BibModul : : GetConfig ( ) ;
pConfig - > setQueryField ( getQueryField ( ) ) ;
startQueryWith ( pConfig - > getQueryText ( ) ) ;
2000-09-18 15:18:56 +00:00
setActiveDataTable ( aActiveDataTable ) ;
}
FeatureStateEvent aEvent ;
util : : URL aURL ;
aEvent . IsEnabled = sal_True ;
aEvent . Requery = sal_False ;
aEvent . FeatureDescriptor = getActiveDataTable ( ) ;
2001-10-22 06:31:42 +00:00
aEvent . State = makeAny ( getDataSources ( ) ) ;
2000-09-18 15:18:56 +00:00
if ( pToolbar )
{
aURL . Complete = C2U ( " .uno:Bib/source " ) ;
aEvent . FeatureURL = aURL ;
pToolbar - > statusChanged ( aEvent ) ;
}
2001-10-22 06:31:42 +00:00
load ( ) ;
2000-09-18 15:18:56 +00:00
}
}
2001-10-22 06:31:42 +00:00
2000-09-18 15:18:56 +00:00
/* --------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void BibDataManager : : setActiveDataTable ( const rtl : : OUString & rTable )
{
ResetIdentifierMapping ( ) ;
try
{
2001-10-22 06:31:42 +00:00
Reference < XPropertySet > aPropertySet ( m_xForm , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
if ( aPropertySet . is ( ) )
{
2001-10-22 06:31:42 +00:00
Reference < XConnection > xConnection = getConnection ( m_xForm ) ;
Reference < XTablesSupplier > xSupplyTables ( xConnection , UNO_QUERY ) ;
Reference < XNameAccess > xAccess = xSupplyTables - > getTables ( ) ;
2000-11-14 07:43:41 +00:00
Sequence < rtl : : OUString > aTableNameSeq = xAccess - > getElementNames ( ) ;
2000-09-18 15:18:56 +00:00
sal_uInt32 nCount = aTableNameSeq . getLength ( ) ;
2001-10-22 06:31:42 +00:00
2000-09-18 15:18:56 +00:00
const rtl : : OUString * pTableNames = aTableNameSeq . getConstArray ( ) ;
2001-10-22 06:31:42 +00:00
const rtl : : OUString * pTableNamesEnd = pTableNames + nCount ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
for ( ; pTableNames ! = pTableNamesEnd ; + + pTableNames )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
if ( rTable = = * pTableNames )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
aActiveDataTable = rTable ;
2000-09-18 15:18:56 +00:00
Any aVal ; aVal < < = rTable ;
2001-10-22 06:31:42 +00:00
aPropertySet - > setPropertyValue ( C2U ( " Command " ) , aVal ) ;
2000-09-18 15:18:56 +00:00
break ;
}
}
2001-10-22 06:31:42 +00:00
if ( pTableNames ! = pTableNamesEnd )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
Reference < XDatabaseMetaData > xMetaData = xConnection - > getMetaData ( ) ;
2000-09-18 15:18:56 +00:00
aQuoteChar = xMetaData - > getIdentifierQuoteString ( ) ;
2000-11-14 07:43:41 +00:00
Reference < sdb : : XSQLQueryComposerFactory > xFactory ( xConnection , UNO_QUERY ) ;
2001-10-22 06:31:42 +00:00
m_xParser = xFactory - > createQueryComposer ( ) ;
2000-09-18 15:18:56 +00:00
rtl : : OUString aString ( C2U ( " SELECT * FROM " ) ) ;
aString + = aQuoteChar ;
aString + = aActiveDataTable ;
aString + = aQuoteChar ;
2001-10-22 06:31:42 +00:00
m_xParser - > setQuery ( aString ) ;
2000-09-18 15:18:56 +00:00
2000-12-01 11:46:59 +00:00
BibConfig * pConfig = BibModul : : GetConfig ( ) ;
pConfig - > setQueryField ( getQueryField ( ) ) ;
startQueryWith ( pConfig - > getQueryText ( ) ) ;
2000-09-18 15:18:56 +00:00
2000-11-13 10:41:26 +00:00
BibDBDescriptor aDesc ;
aDesc . sDataSource = aDataSourceURL ;
aDesc . sTableOrQuery = aActiveDataTable ;
aDesc . nCommandType = CommandType : : TABLE ;
BibModul : : GetConfig ( ) - > SetBibliographyURL ( aDesc ) ;
2000-09-18 15:18:56 +00:00
}
}
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " ::setActiveDataTable: something went wrong ! " ) ;
}
}
2001-10-22 06:31:42 +00:00
2000-09-18 15:18:56 +00:00
//------------------------------------------------------------------------
2001-10-22 06:31:42 +00:00
void SAL_CALL BibDataManager : : load ( ) throw ( RuntimeException )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
if ( isLoaded ( ) )
// nothing to do
return ;
Reference < XLoadable > xFormAsLoadable ( m_xForm , UNO_QUERY ) ;
DBG_ASSERT ( xFormAsLoadable . is ( ) | | ! m_xForm . is ( ) , " BibDataManager::load: invalid form! " ) ;
if ( xFormAsLoadable . is ( ) )
2000-09-18 15:18:56 +00:00
{
xFormAsLoadable - > load ( ) ;
SetMeAsUidListener ( ) ;
2001-10-22 06:31:42 +00:00
EventObject aEvt ( static_cast < XWeak * > ( this ) ) ;
NOTIFY_LISTENERS ( m_aLoadListeners , XLoadListener , loaded , aEvt ) ;
2000-09-18 15:18:56 +00:00
}
}
2001-10-22 06:31:42 +00:00
2000-09-18 15:18:56 +00:00
//------------------------------------------------------------------------
2001-10-22 06:31:42 +00:00
void SAL_CALL BibDataManager : : unload ( ) throw ( RuntimeException )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
if ( ! isLoaded ( ) )
// nothing to do
return ;
Reference < XLoadable > xFormAsLoadable ( m_xForm , UNO_QUERY ) ;
DBG_ASSERT ( xFormAsLoadable . is ( ) | | ! m_xForm . is ( ) , " BibDataManager::unload: invalid form! " ) ;
if ( xFormAsLoadable . is ( ) )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
EventObject aEvt ( static_cast < XWeak * > ( this ) ) ;
{
NOTIFY_LISTENERS ( m_aLoadListeners , XLoadListener , unloading , aEvt ) ;
}
2000-09-18 15:18:56 +00:00
RemoveMeAsUidListener ( ) ;
xFormAsLoadable - > unload ( ) ;
2001-10-22 06:31:42 +00:00
{
NOTIFY_LISTENERS ( m_aLoadListeners , XLoadListener , unloaded , aEvt ) ;
}
}
}
//------------------------------------------------------------------------
void SAL_CALL BibDataManager : : reload ( ) throw ( RuntimeException )
{
if ( ! isLoaded ( ) )
// nothing to do
return ;
Reference < XLoadable > xFormAsLoadable ( m_xForm , UNO_QUERY ) ;
DBG_ASSERT ( xFormAsLoadable . is ( ) | | ! m_xForm . is ( ) , " BibDataManager::unload: invalid form! " ) ;
if ( xFormAsLoadable . is ( ) )
{
EventObject aEvt ( static_cast < XWeak * > ( this ) ) ;
{
NOTIFY_LISTENERS ( m_aLoadListeners , XLoadListener , reloading , aEvt ) ;
}
xFormAsLoadable - > reload ( ) ;
{
NOTIFY_LISTENERS ( m_aLoadListeners , XLoadListener , reloaded , aEvt ) ;
}
2000-09-18 15:18:56 +00:00
}
}
2001-10-22 06:31:42 +00:00
//------------------------------------------------------------------------
sal_Bool SAL_CALL BibDataManager : : isLoaded ( ) throw ( RuntimeException )
{
Reference < XLoadable > xFormAsLoadable ( m_xForm , UNO_QUERY ) ;
DBG_ASSERT ( xFormAsLoadable . is ( ) | | ! m_xForm . is ( ) , " BibDataManager::isLoaded: invalid form! " ) ;
sal_Bool bLoaded = sal_False ;
if ( xFormAsLoadable . is ( ) )
bLoaded = xFormAsLoadable - > isLoaded ( ) ;
return bLoaded ;
}
//------------------------------------------------------------------------
void SAL_CALL BibDataManager : : addLoadListener ( const Reference < XLoadListener > & aListener ) throw ( RuntimeException )
{
m_aLoadListeners . addInterface ( aListener ) ;
}
//------------------------------------------------------------------------
void SAL_CALL BibDataManager : : removeLoadListener ( const Reference < XLoadListener > & aListener ) throw ( RuntimeException )
{
m_aLoadListeners . removeInterface ( aListener ) ;
}
2000-09-18 15:18:56 +00:00
//------------------------------------------------------------------------
2001-10-23 10:51:16 +00:00
Reference < awt : : XControlModel > BibDataManager : : createGridModel ( const rtl : : OUString & rName )
2000-09-18 15:18:56 +00:00
{
2001-10-23 10:51:16 +00:00
Reference < awt : : XControlModel > xModel ;
2000-09-18 15:18:56 +00:00
try
{
2001-10-22 06:31:42 +00:00
// create the control model
Reference < XMultiServiceFactory > xMgr = : : comphelper : : getProcessServiceFactory ( ) ;
2000-11-14 07:43:41 +00:00
Reference < XInterface > xObject = xMgr - > createInstance ( C2U ( " com.sun.star.form.component.GridControl " ) ) ;
2001-10-23 10:51:16 +00:00
xModel = Reference < awt : : XControlModel > ( xObject , UNO_QUERY ) ;
2001-10-22 06:31:42 +00:00
// set the
Reference < XPropertySet > xPropSet ( xModel , UNO_QUERY ) ;
xPropSet - > setPropertyValue ( C2U ( " Name " ) , makeAny ( rName ) ) ;
// set the name of the to-be-created control
2001-04-19 10:54:03 +00:00
rtl : : OUString aControlName ( C2U ( " com.sun.star.form.control.InteractionGridControl " ) ) ;
2000-11-14 07:43:41 +00:00
Any aAny ; aAny < < = aControlName ;
2000-09-18 15:18:56 +00:00
xPropSet - > setPropertyValue ( C2U ( " DefaultControl " ) , aAny ) ;
2001-10-22 06:31:42 +00:00
// the the helpURL
2000-09-18 15:18:56 +00:00
rtl : : OUString uProp ( C2U ( " HelpURL " ) ) ;
2001-10-22 06:31:42 +00:00
Reference < XPropertySetInfo > xPropInfo = xPropSet - > getPropertySetInfo ( ) ;
if ( xPropInfo - > hasPropertyByName ( uProp ) )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
: : rtl : : OUString sId = : : rtl : : OUString : : createFromAscii ( " HID: " ) ;
sId + = : : rtl : : OUString : : valueOf ( ( sal_Int32 ) HID_BIB_DB_GRIDCTRL ) ;
xPropSet - > setPropertyValue ( uProp , makeAny ( : : rtl : : OUString ( sId ) ) ) ;
2000-09-18 15:18:56 +00:00
}
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2001-10-22 06:31:42 +00:00
DBG_ERROR ( " ::createGridModel: something went wrong ! " ) ;
2000-09-18 15:18:56 +00:00
}
return xModel ;
}
//------------------------------------------------------------------------
rtl : : OUString BibDataManager : : getControlName ( sal_Int32 nFormatKey )
{
rtl : : OUString aResStr ;
switch ( nFormatKey )
{
case DataType : : BIT :
aResStr = C2U ( " CheckBox " ) ;
break ;
case DataType : : TINYINT :
case DataType : : SMALLINT :
case DataType : : INTEGER :
aResStr = C2U ( " NumericField " ) ; ;
break ;
case DataType : : REAL :
case DataType : : DOUBLE :
case DataType : : NUMERIC :
case DataType : : DECIMAL :
aResStr = C2U ( " FormattedField " ) ;
break ;
case DataType : : TIMESTAMP :
aResStr = C2U ( " FormattedField " ) ;
break ;
case DataType : : DATE :
aResStr = C2U ( " DateField " ) ;
break ;
case DataType : : TIME :
aResStr = C2U ( " TimeField " ) ;
break ;
case DataType : : CHAR :
case DataType : : VARCHAR :
case DataType : : LONGVARCHAR :
default :
aResStr = C2U ( " TextField " ) ;
break ;
}
return aResStr ;
}
//------------------------------------------------------------------------
2001-10-23 10:51:16 +00:00
Reference < awt : : XControlModel > BibDataManager : : loadControlModel (
2000-12-01 11:46:59 +00:00
const rtl : : OUString & rName , sal_Bool bForceListBox )
2000-09-18 15:18:56 +00:00
{
2001-10-23 10:51:16 +00:00
Reference < awt : : XControlModel > xModel ;
2000-09-18 15:18:56 +00:00
rtl : : OUString aName ( C2U ( " View_ " ) ) ;
2000-12-01 11:46:59 +00:00
aName + = rName ;
2000-09-18 15:18:56 +00:00
try
{
2001-10-22 06:31:42 +00:00
Reference < XNameAccess > xFields = getColumns ( m_xForm ) ;
2000-12-01 11:46:59 +00:00
if ( ! xFields . is ( ) )
return xModel ;
Reference < XPropertySet > xField ;
2000-09-18 15:18:56 +00:00
2000-12-01 11:46:59 +00:00
Any aElement ;
2000-09-18 15:18:56 +00:00
2000-12-01 11:46:59 +00:00
if ( xFields - > hasByName ( rName ) )
{
aElement = xFields - > getByName ( rName ) ;
2001-02-19 13:04:13 +00:00
aElement > > = xField ;
2000-12-01 11:46:59 +00:00
Reference < XPropertySetInfo > xInfo = xField . is ( ) ? xField - > getPropertySetInfo ( ) : Reference < XPropertySetInfo > ( ) ;
2001-02-19 13:04:13 +00:00
OUString sCurrentModelType ;
const OUString sType ( C2U ( " Type " ) ) ;
2000-12-01 11:46:59 +00:00
sal_Int32 nFormatKey = 0 ;
2001-02-19 13:04:13 +00:00
sal_Bool bIsFormatted = sal_False ;
sal_Bool bFormattedIsNumeric = sal_True ;
xField - > getPropertyValue ( sType ) > > = nFormatKey ;
2000-09-18 15:18:56 +00:00
2000-12-01 11:46:59 +00:00
rtl : : OUString aInstanceName ( C2U ( " com.sun.star.form.component. " ) ) ;
2000-09-18 15:18:56 +00:00
2000-12-01 11:46:59 +00:00
if ( bForceListBox )
aInstanceName + = C2U ( " ListBox " ) ;
else
aInstanceName + = getControlName ( nFormatKey ) ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
Reference < XMultiServiceFactory > xMgr = comphelper : : getProcessServiceFactory ( ) ;
2000-12-01 11:46:59 +00:00
Reference < XInterface > xObject = xMgr - > createInstance ( aInstanceName ) ;
2001-10-23 10:51:16 +00:00
xModel = Reference < awt : : XControlModel > ( xObject , UNO_QUERY ) ;
2000-12-01 11:46:59 +00:00
Reference < XPropertySet > xPropSet ( xModel , UNO_QUERY ) ;
Any aFieldName ; aFieldName < < = aName ;
xPropSet - > setPropertyValue ( FM_PROP_NAME , aFieldName ) ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
xPropSet - > setPropertyValue ( FM_PROP_CONTROLSOURCE , makeAny ( rName ) ) ;
2000-09-18 15:18:56 +00:00
2000-12-01 11:46:59 +00:00
Reference < XFormComponent > aFormComp ( xModel , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
Reference < XNameContainer > xNameCont ( m_xForm , UNO_QUERY ) ;
2002-01-30 16:14:44 +00:00
xNameCont - > insertByName ( aName , makeAny ( aFormComp ) ) ;
// now if the form where we inserted the new model is already loaded, notify the model of this
// Note that this implementation below is a HACK as it relies on the fact that the model adds itself
// as load listener to it's parent, which is an implementation detail of the model.
//
// the better solution would be the following:
// in the current scenario, we insert a control model into a form. This results in the control model
// adding itself as load listener to the form. Now, the form should realize that it's already loaded
// and notify the model (which it knows as XLoadListener only) immediately. This seems to make sense.
// (as an anologon to the XStatusListener semantics).
//
// But this would be way too risky for this last-day fix here.
// 97140 - 30.01.2002 - fs@openoffice.org
Reference < XLoadable > xLoad ( m_xForm , UNO_QUERY ) ;
if ( xLoad . is ( ) & & xLoad - > isLoaded ( ) )
{
Reference < XLoadListener > xListener ( aFormComp , UNO_QUERY ) ;
if ( xListener . is ( ) )
{
EventObject aLoadSource ;
aLoadSource . Source = xLoad ;
xListener - > loaded ( aLoadSource ) ;
}
}
2000-09-18 15:18:56 +00:00
}
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " ::loadControlModel: something went wrong ! " ) ;
}
return xModel ;
}
//------------------------------------------------------------------------
2001-10-23 10:51:16 +00:00
void BibDataManager : : saveCtrModel ( const rtl : : OUString & rName , const Reference < awt : : XControlModel > & rCtrModel )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
if ( m_xSourceProps . is ( ) )
2000-09-18 15:18:56 +00:00
{
2000-11-27 13:15:21 +00:00
try
{
rtl : : OUString aName ( C2U ( " View_ " ) ) ;
aName + = rName ;
2000-09-18 15:18:56 +00:00
2000-11-27 13:15:21 +00:00
Reference < io : : XPersistObject > aPersistObject ( rCtrModel , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
2000-11-27 13:15:21 +00:00
Any aModel ( & aPersistObject , : : getCppuType ( ( Reference < io : : XPersistObject > * ) 0 ) ) ;
2000-09-18 15:18:56 +00:00
2001-10-22 06:31:42 +00:00
m_xSourceProps - > setPropertyValue ( aName , aModel ) ;
2000-11-27 13:15:21 +00:00
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-11-27 13:15:21 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-11-27 13:15:21 +00:00
DBG_ERROR ( " ::saveCtrModel: something went wrong ! " ) ;
}
2000-09-18 15:18:56 +00:00
}
}
//------------------------------------------------------------------------
2001-10-22 06:31:42 +00:00
void BibDataManager : : disposing ( const EventObject & Source ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
2000-09-18 15:18:56 +00:00
{
2001-10-22 06:31:42 +00:00
// not interested in
2000-09-18 15:18:56 +00:00
}
2001-10-22 06:31:42 +00:00
2000-09-18 15:18:56 +00:00
//------------------------------------------------------------------------
2000-11-14 07:43:41 +00:00
void BibDataManager : : propertyChange ( const beans : : PropertyChangeEvent & evt ) throw ( RuntimeException )
2000-09-18 15:18:56 +00:00
{
try
{
sal_Bool bFlag = sal_False ;
if ( evt . PropertyName = = FM_PROP_VALUE )
{
if ( evt . NewValue . getValueType ( ) = = : : getCppuType ( ( Reference < io : : XInputStream > * ) 0 ) )
{
2000-11-14 07:43:41 +00:00
Reference < io : : XDataInputStream > xStream (
* ( const Reference < io : : XInputStream > * ) evt . NewValue . getValue ( ) , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
aUID < < = xStream - > readUTF ( ) ;
}
else
aUID = evt . NewValue ;
2001-10-22 06:31:42 +00:00
Reference < XRowLocate > xLocate ( xBibCursor , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
DBG_ASSERT ( xLocate . is ( ) , " BibDataManager::propertyChange : invalid cursor ! " ) ;
bFlag = xLocate - > moveToBookmark ( aUID ) ;
}
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " ::propertyChange: something went wrong ! " ) ;
}
}
//------------------------------------------------------------------------
void BibDataManager : : SetMeAsUidListener ( )
{
try
{
2001-10-22 06:31:42 +00:00
Reference < XNameAccess > xFields = getColumns ( m_xForm ) ;
2000-09-18 15:18:56 +00:00
if ( ! xFields . is ( ) )
return ;
2000-11-14 07:43:41 +00:00
Sequence < rtl : : OUString > aFields ( xFields - > getElementNames ( ) ) ;
2000-09-18 15:18:56 +00:00
const rtl : : OUString * pFields = aFields . getConstArray ( ) ;
sal_Int32 nCount = aFields . getLength ( ) ;
String StrUID ( C2S ( STR_UID ) ) ;
rtl : : OUString theFieldName ;
for ( sal_Int32 i = 0 ; i < nCount ; i + + )
{
String aName = pFields [ i ] ;
if ( aName . EqualsIgnoreCaseAscii ( StrUID ) )
{
theFieldName = pFields [ i ] ;
break ;
}
}
2001-05-11 09:26:36 +00:00
if ( theFieldName . getLength ( ) > 0 )
2000-09-18 15:18:56 +00:00
{
2000-11-14 07:43:41 +00:00
Reference < XPropertySet > xPropSet ;
Any aElement ;
2000-09-18 15:18:56 +00:00
aElement = xFields - > getByName ( theFieldName ) ;
2000-11-14 07:43:41 +00:00
xPropSet = * ( Reference < XPropertySet > * ) aElement . getValue ( ) ;
2000-09-18 15:18:56 +00:00
xPropSet - > addPropertyChangeListener ( FM_PROP_VALUE , this ) ;
}
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " Exception in BibDataManager::SetMeAsUidListener " )
}
}
//------------------------------------------------------------------------
void BibDataManager : : RemoveMeAsUidListener ( )
{
try
{
2001-10-22 06:31:42 +00:00
Reference < XNameAccess > xFields = getColumns ( m_xForm ) ;
2000-09-18 15:18:56 +00:00
if ( ! xFields . is ( ) )
return ;
2000-11-14 07:43:41 +00:00
Sequence < rtl : : OUString > aFields ( xFields - > getElementNames ( ) ) ;
2000-09-18 15:18:56 +00:00
const rtl : : OUString * pFields = aFields . getConstArray ( ) ;
sal_Int32 nCount = aFields . getLength ( ) ;
String StrUID ( C2S ( STR_UID ) ) ;
rtl : : OUString theFieldName ;
for ( sal_Int32 i = 0 ; i < nCount ; i + + )
{
String aName = pFields [ i ] ;
if ( aName . EqualsIgnoreCaseAscii ( StrUID ) )
{
theFieldName = pFields [ i ] ;
break ;
}
}
2001-05-11 09:26:36 +00:00
if ( theFieldName . getLength ( ) > 0 )
2000-09-18 15:18:56 +00:00
{
2000-11-14 07:43:41 +00:00
Reference < XPropertySet > xPropSet ;
Any aElement ;
2000-09-18 15:18:56 +00:00
aElement = xFields - > getByName ( theFieldName ) ;
2000-11-14 07:43:41 +00:00
xPropSet = * ( Reference < XPropertySet > * ) aElement . getValue ( ) ;
2000-09-18 15:18:56 +00:00
xPropSet - > removePropertyChangeListener ( FM_PROP_VALUE , this ) ;
}
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " Exception in BibDataManager::RemoveMeAsUidListener " )
}
}
/* -----------------02.11.99 16:11-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
sal_Bool BibDataManager : : moveRelative ( sal_Int32 nCount )
{
sal_Bool bRet = sal_False ;
try
{
2001-10-22 06:31:42 +00:00
Reference < XResultSet > xCursor ( m_xForm , UNO_QUERY ) ;
Reference < XResultSetUpdate > xCursorUpdate ( m_xForm , UNO_QUERY ) ;
2000-09-18 15:18:56 +00:00
if ( xCursor . is ( ) & & xCursorUpdate . is ( ) )
{
bRet = xCursor - > relative ( nCount ) ;
if ( xCursor - > isAfterLast ( ) )
xCursorUpdate - > moveToInsertRow ( ) ;
}
}
2001-08-17 08:23:32 +00:00
catch ( Exception & e )
2000-09-18 15:18:56 +00:00
{
2001-08-17 08:23:32 +00:00
e ; // make compiler happy
2000-09-18 15:18:56 +00:00
DBG_ERROR ( " Exception in BibDataManager::moveRelative " )
}
return bRet ;
}
/* -----------------11.11.99 15:51-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void BibDataManager : : CreateMappingDialog ( Window * pParent )
{
MappingDialog_Impl * pDlg = new MappingDialog_Impl ( pParent , this ) ;
if ( RET_OK = = pDlg - > Execute ( ) & & pBibView )
{
2001-10-22 06:31:42 +00:00
reload ( ) ;
// unload();
// pBibView->UpdatePages();
// load();
2000-09-18 15:18:56 +00:00
}
delete pDlg ;
}
/* --------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
rtl : : OUString BibDataManager : : CreateDBChangeDialog ( Window * pParent )
{
rtl : : OUString uRet ;
DBChangeDialog_Impl * pDlg = new DBChangeDialog_Impl ( pParent , this ) ;
if ( RET_OK = = pDlg - > Execute ( ) )
{
String sNewURL = pDlg - > GetCurrentURL ( ) ;
if ( sNewURL ! = String ( getActiveDataSource ( ) ) )
{
uRet = sNewURL ;
}
}
delete pDlg ;
return uRet ;
}
/* -----------------06.12.99 15:11-------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2000-11-13 10:41:26 +00:00
const OUString & BibDataManager : : GetIdentifierMapping ( )
2000-09-18 15:18:56 +00:00
{
2000-11-13 10:41:26 +00:00
if ( ! sIdentifierMapping . getLength ( ) )
{
BibConfig * pConfig = BibModul : : GetConfig ( ) ;
BibDBDescriptor aDesc ;
aDesc . sDataSource = getActiveDataSource ( ) ;
aDesc . sTableOrQuery = getActiveDataTable ( ) ;
aDesc . nCommandType = CommandType : : TABLE ;
const Mapping * pMapping = pConfig - > GetMapping ( aDesc ) ;
sIdentifierMapping = pConfig - > GetDefColumnName ( IDENTIFIER_POS ) ;
2000-09-18 15:18:56 +00:00
if ( pMapping )
{
for ( sal_uInt16 nEntry = 0 ; nEntry < COLUMN_COUNT ; nEntry + + )
{
if ( pMapping - > aColumnPairs [ nEntry ] . sLogicalColumnName = = sIdentifierMapping )
{
sIdentifierMapping = pMapping - > aColumnPairs [ nEntry ] . sRealColumnName ;
break ;
}
}
}
}
return sIdentifierMapping ;
}
2000-11-20 11:23:38 +00:00
/* -----------------------------20.11.00 10:31--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void BibDataManager : : SetToolbar ( BibToolBar * pSet )
{
pToolbar = pSet ;
if ( pToolbar )
pToolbar - > SetDatMan ( * this ) ;
}
2000-09-18 15:18:56 +00:00