1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoDirectSql.cxx,v $
10 * $Revision: 1.7.142.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #ifndef DBAUI_UNODIRECTSQL_HXX
35 #include "unoDirectSql.hxx"
37 #ifndef _DBU_REGHELPER_HXX_
38 #include "dbu_reghelper.hxx"
40 #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
41 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
43 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
44 #include <com/sun/star/container/XNameAccess.hpp>
46 #ifndef _COM_SUN_STAR_CONNECTION_XCONNECTION_HPP_
47 #include <com/sun/star/connection/XConnection.hpp>
49 #ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
50 #include <com/sun/star/container/XNamed.hpp>
52 #ifndef _DBACCESS_UI_DIRECTSQL_HXX_
53 #include "directsql.hxx"
55 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
56 #include "dbustrings.hrc"
58 #ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
59 #include "datasourceconnector.hxx"
61 #ifndef TOOLS_DIAGNOSE_EX_H
62 #include <tools/diagnose_ex.h>
66 extern "C" void SAL_CALL
createRegistryInfo_ODirectSQLDialog()
68 static ::dbaui::OMultiInstanceAutoRegistration
< ::dbaui::ODirectSQLDialog
> aAutoRegistration
;
71 //.........................................................................
74 //.........................................................................
76 using namespace ::com::sun::star::uno
;
77 using namespace ::com::sun::star::lang
;
78 using namespace ::com::sun::star::beans
;
79 using namespace ::com::sun::star::container
;
80 using namespace ::com::sun::star::sdbcx
;
81 using namespace ::com::sun::star::sdbc
;
82 using namespace ::com::sun::star::sdb
;
84 //=====================================================================
86 //=====================================================================
87 DBG_NAME(ODirectSQLDialog
)
88 //---------------------------------------------------------------------
89 ODirectSQLDialog::ODirectSQLDialog(const Reference
< XMultiServiceFactory
>& _rxORB
)
90 :ODirectSQLDialog_BASE( _rxORB
)
92 DBG_CTOR(ODirectSQLDialog
,NULL
);
96 //---------------------------------------------------------------------
97 ODirectSQLDialog::~ODirectSQLDialog()
100 DBG_DTOR(ODirectSQLDialog
,NULL
);
103 //---------------------------------------------------------------------
104 IMPLEMENT_IMPLEMENTATION_ID( ODirectSQLDialog
)
106 //---------------------------------------------------------------------
107 IMPLEMENT_SERVICE_INFO1_STATIC( ODirectSQLDialog
, "com.sun.star.comp.sdb.DirectSQLDialog", SERVICE_SDB_DIRECTSQLDIALOG
)
109 //---------------------------------------------------------------------
110 IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ODirectSQLDialog
)
112 //---------------------------------------------------------------------
113 Dialog
* ODirectSQLDialog::createDialog(Window
* _pParent
)
115 // obtain all the objects needed for the dialog
116 Reference
< XConnection
> xConnection
= m_xActiveConnection
;
117 if ( !xConnection
.is() )
121 // the connection the row set is working with
122 ODatasourceConnector
aDSConnector(m_aContext
.getLegacyServiceFactory(),_pParent
);
123 xConnection
= aDSConnector
.connect( m_sInitialSelection
, NULL
);
125 catch( const Exception
& )
127 DBG_UNHANDLED_EXCEPTION();
130 if ( !xConnection
.is() )
131 // can't create the dialog if I have improper settings
134 return new DirectSQLDialog( _pParent
, xConnection
);
136 //---------------------------------------------------------------------
137 void ODirectSQLDialog::implInitialize(const Any
& _rValue
)
139 PropertyValue aProperty
;
140 if (_rValue
>>= aProperty
)
142 if (0 == aProperty
.Name
.compareToAscii("InitialSelection"))
144 OSL_VERIFY( aProperty
.Value
>>= m_sInitialSelection
);
147 else if (0 == aProperty
.Name
.compareToAscii("ActiveConnection"))
149 m_xActiveConnection
.set( aProperty
.Value
, UNO_QUERY
);
150 OSL_ENSURE( m_xActiveConnection
.is(), "ODirectSQLDialog::implInitialize: invalid connection!" );
154 ODirectSQLDialog_BASE::implInitialize(_rValue
);
156 //.........................................................................
158 //.........................................................................