Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "unoDirectSql.hxx"
22 : #include "dbu_reghelper.hxx"
23 : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
24 : #include <com/sun/star/container/XNameAccess.hpp>
25 : #include <com/sun/star/connection/XConnection.hpp>
26 : #include <com/sun/star/container/XNamed.hpp>
27 : #include "directsql.hxx"
28 : #include "dbustrings.hrc"
29 : #include "datasourceconnector.hxx"
30 : #include <tools/diagnose_ex.h>
31 : #include <comphelper/processfactory.hxx>
32 :
33 :
34 4 : extern "C" void SAL_CALL createRegistryInfo_ODirectSQLDialog()
35 : {
36 4 : static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::ODirectSQLDialog > aAutoRegistration;
37 4 : }
38 :
39 : //.........................................................................
40 : namespace dbaui
41 : {
42 : //.........................................................................
43 :
44 : using namespace ::com::sun::star::uno;
45 : using namespace ::com::sun::star::lang;
46 : using namespace ::com::sun::star::beans;
47 : using namespace ::com::sun::star::container;
48 : using namespace ::com::sun::star::sdbcx;
49 : using namespace ::com::sun::star::sdbc;
50 : using namespace ::com::sun::star::sdb;
51 :
52 : //=====================================================================
53 : //= ODirectSQLDialog
54 : //=====================================================================
55 : DBG_NAME(ODirectSQLDialog)
56 : //---------------------------------------------------------------------
57 0 : ODirectSQLDialog::ODirectSQLDialog(const Reference< XComponentContext >& _rxORB)
58 0 : :ODirectSQLDialog_BASE( _rxORB )
59 : {
60 : DBG_CTOR(ODirectSQLDialog,NULL);
61 :
62 0 : }
63 :
64 : //---------------------------------------------------------------------
65 0 : ODirectSQLDialog::~ODirectSQLDialog()
66 : {
67 :
68 : DBG_DTOR(ODirectSQLDialog,NULL);
69 0 : }
70 :
71 : //---------------------------------------------------------------------
72 0 : IMPLEMENT_IMPLEMENTATION_ID( ODirectSQLDialog )
73 :
74 : //---------------------------------------------------------------------
75 8 : IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(ODirectSQLDialog, "com.sun.star.comp.sdb.DirectSQLDialog")
76 0 : IMPLEMENT_SERVICE_INFO_SUPPORTS(ODirectSQLDialog)
77 4 : IMPLEMENT_SERVICE_INFO_GETSUPPORTED1_STATIC(ODirectSQLDialog, SERVICE_SDB_DIRECTSQLDIALOG)
78 :
79 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
80 0 : SAL_CALL ODirectSQLDialog::Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB)
81 : {
82 0 : return static_cast< XServiceInfo* >(new ODirectSQLDialog( comphelper::getComponentContext(_rxORB)));
83 : }
84 :
85 : //---------------------------------------------------------------------
86 0 : IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ODirectSQLDialog )
87 :
88 : //---------------------------------------------------------------------
89 0 : Dialog* ODirectSQLDialog::createDialog(Window* _pParent)
90 : {
91 : // obtain all the objects needed for the dialog
92 0 : Reference< XConnection > xConnection = m_xActiveConnection;
93 0 : if ( !xConnection.is() )
94 : {
95 : try
96 : {
97 : // the connection the row set is working with
98 0 : ODatasourceConnector aDSConnector(m_aContext, _pParent);
99 0 : xConnection = aDSConnector.connect( m_sInitialSelection, NULL );
100 : }
101 0 : catch( const Exception& )
102 : {
103 : DBG_UNHANDLED_EXCEPTION();
104 : }
105 : }
106 0 : if ( !xConnection.is() )
107 : // can't create the dialog if I have improper settings
108 0 : return NULL;
109 :
110 0 : return new DirectSQLDialog( _pParent, xConnection);
111 : }
112 : //---------------------------------------------------------------------
113 0 : void ODirectSQLDialog::implInitialize(const Any& _rValue)
114 : {
115 0 : PropertyValue aProperty;
116 0 : if (_rValue >>= aProperty)
117 : {
118 0 : if (0 == aProperty.Name.compareToAscii("InitialSelection"))
119 : {
120 0 : OSL_VERIFY( aProperty.Value >>= m_sInitialSelection );
121 0 : return;
122 : }
123 0 : else if (0 == aProperty.Name.compareToAscii("ActiveConnection"))
124 : {
125 0 : m_xActiveConnection.set( aProperty.Value, UNO_QUERY );
126 : OSL_ENSURE( m_xActiveConnection.is(), "ODirectSQLDialog::implInitialize: invalid connection!" );
127 0 : return;
128 : }
129 : }
130 0 : ODirectSQLDialog_BASE::implInitialize(_rValue);
131 : }
132 : //.........................................................................
133 12 : } // namespace dbaui
134 : //.........................................................................
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|