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 : #include "unoDirectSql.hxx"
21 : #include "dbu_reghelper.hxx"
22 : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
23 : #include <com/sun/star/container/XNameAccess.hpp>
24 : #include <com/sun/star/connection/XConnection.hpp>
25 : #include <com/sun/star/container/XNamed.hpp>
26 : #include "directsql.hxx"
27 : #include "dbustrings.hrc"
28 : #include "datasourceconnector.hxx"
29 : #include <tools/diagnose_ex.h>
30 : #include <comphelper/processfactory.hxx>
31 :
32 0 : extern "C" void SAL_CALL createRegistryInfo_ODirectSQLDialog()
33 : {
34 0 : static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::ODirectSQLDialog > aAutoRegistration;
35 0 : }
36 :
37 : namespace dbaui
38 : {
39 :
40 : using namespace ::com::sun::star::uno;
41 : using namespace ::com::sun::star::lang;
42 : using namespace ::com::sun::star::beans;
43 : using namespace ::com::sun::star::container;
44 : using namespace ::com::sun::star::sdbcx;
45 : using namespace ::com::sun::star::sdbc;
46 : using namespace ::com::sun::star::sdb;
47 :
48 : // ODirectSQLDialog
49 0 : ODirectSQLDialog::ODirectSQLDialog(const Reference< XComponentContext >& _rxORB)
50 0 : :ODirectSQLDialog_BASE( _rxORB )
51 : {
52 :
53 0 : }
54 :
55 0 : ODirectSQLDialog::~ODirectSQLDialog()
56 : {
57 :
58 0 : }
59 :
60 0 : css::uno::Sequence<sal_Int8> ODirectSQLDialog::getImplementationId()
61 : throw (css::uno::RuntimeException, std::exception)
62 : {
63 0 : return css::uno::Sequence<sal_Int8>();
64 : }
65 :
66 0 : IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(ODirectSQLDialog, "com.sun.star.comp.sdb.DirectSQLDialog")
67 0 : IMPLEMENT_SERVICE_INFO_SUPPORTS(ODirectSQLDialog)
68 0 : IMPLEMENT_SERVICE_INFO_GETSUPPORTED1_STATIC(ODirectSQLDialog, SERVICE_SDB_DIRECTSQLDIALOG)
69 :
70 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
71 0 : SAL_CALL ODirectSQLDialog::Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB)
72 : {
73 0 : return static_cast< XServiceInfo* >(new ODirectSQLDialog( comphelper::getComponentContext(_rxORB)));
74 : }
75 :
76 0 : IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ODirectSQLDialog )
77 :
78 0 : Dialog* ODirectSQLDialog::createDialog(Window* _pParent)
79 : {
80 : // obtain all the objects needed for the dialog
81 0 : Reference< XConnection > xConnection = m_xActiveConnection;
82 0 : if ( !xConnection.is() )
83 : {
84 : try
85 : {
86 : // the connection the row set is working with
87 0 : ODatasourceConnector aDSConnector(m_aContext, _pParent);
88 0 : xConnection = aDSConnector.connect( m_sInitialSelection, NULL );
89 : }
90 0 : catch( const Exception& )
91 : {
92 : DBG_UNHANDLED_EXCEPTION();
93 : }
94 : }
95 0 : if ( !xConnection.is() )
96 : // can't create the dialog if I have improper settings
97 0 : return NULL;
98 :
99 0 : return new DirectSQLDialog( _pParent, xConnection);
100 : }
101 0 : void ODirectSQLDialog::implInitialize(const Any& _rValue)
102 : {
103 0 : PropertyValue aProperty;
104 0 : if (_rValue >>= aProperty)
105 : {
106 0 : if (aProperty.Name.equalsAscii("InitialSelection"))
107 : {
108 0 : OSL_VERIFY( aProperty.Value >>= m_sInitialSelection );
109 0 : return;
110 : }
111 0 : else if (aProperty.Name.equalsAscii("ActiveConnection"))
112 : {
113 0 : m_xActiveConnection.set( aProperty.Value, UNO_QUERY );
114 : OSL_ENSURE( m_xActiveConnection.is(), "ODirectSQLDialog::implInitialize: invalid connection!" );
115 0 : return;
116 : }
117 : }
118 0 : ODirectSQLDialog_BASE::implInitialize(_rValue);
119 : }
120 : } // namespace dbaui
121 :
122 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|