Branch data 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 "composerdialogs.hxx"
22 : :
23 : : #include "dbu_reghelper.hxx"
24 : : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
25 : : #include "dbustrings.hrc"
26 : : #include "queryfilter.hxx"
27 : : #include "queryorder.hxx"
28 : : #include <connectivity/dbtools.hxx>
29 : : #include <tools/diagnose_ex.h>
30 : : #include <osl/diagnose.h>
31 : :
32 : 8 : extern "C" void SAL_CALL createRegistryInfo_ComposerDialogs()
33 : : {
34 [ + - ][ + - ]: 8 : static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::RowsetOrderDialog > aOrderDialogRegistration;
[ + - ][ # # ]
35 [ + - ][ + - ]: 8 : static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::RowsetFilterDialog > aFilterDialogRegistration;
[ + - ][ # # ]
36 : 8 : }
37 : :
38 : : //.........................................................................
39 : : namespace dbaui
40 : : {
41 : : //.........................................................................
42 : :
43 : : #define PROPERTY_ID_QUERYCOMPOSER 100
44 : : #define PROPERTY_ID_ROWSET 101
45 : :
46 : : IMPLEMENT_CONSTASCII_USTRING( PROPERTY_QUERYCOMPOSER, "QueryComposer" );
47 : : IMPLEMENT_CONSTASCII_USTRING( PROPERTY_ROWSET, "RowSet" );
48 : :
49 : : using namespace ::com::sun::star::uno;
50 : : using namespace ::com::sun::star::lang;
51 : : using namespace ::com::sun::star::beans;
52 : : using namespace ::com::sun::star::container;
53 : : using namespace ::com::sun::star::sdbcx;
54 : : using namespace ::com::sun::star::sdbc;
55 : : using namespace ::com::sun::star::sdb;
56 : :
57 : : //=====================================================================
58 : : //= ComposerDialog
59 : : //=====================================================================
60 : : DBG_NAME(ComposerDialog)
61 : : //---------------------------------------------------------------------
62 : 0 : ComposerDialog::ComposerDialog(const Reference< XMultiServiceFactory >& _rxORB)
63 [ # # ][ # # ]: 0 : :ComposerDialog_BASE( _rxORB )
64 : : {
65 : : DBG_CTOR(ComposerDialog,NULL);
66 : :
67 : : registerProperty( PROPERTY_QUERYCOMPOSER, PROPERTY_ID_QUERYCOMPOSER, PropertyAttribute::TRANSIENT,
68 [ # # ][ # # ]: 0 : &m_xComposer, ::getCppuType( &m_xComposer ) );
[ # # ]
69 : : registerProperty( PROPERTY_ROWSET, PROPERTY_ID_ROWSET, PropertyAttribute::TRANSIENT,
70 [ # # ][ # # ]: 0 : &m_xRowSet, ::getCppuType( &m_xRowSet ) );
[ # # ]
71 : 0 : }
72 : :
73 : : //---------------------------------------------------------------------
74 [ # # ][ # # ]: 0 : ComposerDialog::~ComposerDialog()
75 : : {
76 : :
77 : : DBG_DTOR(ComposerDialog,NULL);
78 [ # # ]: 0 : }
79 : :
80 : : //---------------------------------------------------------------------
81 [ # # ][ # # ]: 0 : IMPLEMENT_IMPLEMENTATION_ID( ComposerDialog )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
82 : :
83 : : //---------------------------------------------------------------------
84 [ # # ][ # # ]: 0 : IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ComposerDialog )
[ # # ][ # # ]
85 : :
86 : : //---------------------------------------------------------------------
87 : 0 : Dialog* ComposerDialog::createDialog(Window* _pParent)
88 : : {
89 : : // obtain all the objects needed for the dialog
90 : 0 : Reference< XConnection > xConnection;
91 : 0 : Reference< XNameAccess > xColumns;
92 : : try
93 : : {
94 : : // the connection the row set is working with
95 [ # # ][ # # ]: 0 : if ( !::dbtools::isEmbeddedInDatabase( m_xRowSet, xConnection ) )
96 : : {
97 [ # # ]: 0 : Reference< XPropertySet > xRowsetProps( m_xRowSet, UNO_QUERY );
98 [ # # ]: 0 : if ( xRowsetProps.is() )
99 [ # # ][ # # ]: 0 : xRowsetProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection;
[ # # ][ # # ]
100 : : }
101 : :
102 : : // fallback: if there is a connection and thus a row set, but no composer, create one
103 [ # # ][ # # ]: 0 : if ( xConnection.is() && !m_xComposer.is() )
[ # # ]
104 [ # # ][ # # ]: 0 : m_xComposer = ::dbtools::getCurrentSettingsComposer( Reference< XPropertySet >( m_xRowSet, UNO_QUERY ), m_aContext.getLegacyServiceFactory() );
[ # # ][ # # ]
105 : :
106 : : // the columns of the row set
107 [ # # ]: 0 : Reference< XColumnsSupplier > xSuppColumns( m_xRowSet, UNO_QUERY );
108 [ # # ]: 0 : if ( xSuppColumns.is() )
109 [ # # ][ # # ]: 0 : xColumns = xSuppColumns->getColumns();
[ # # ]
110 : :
111 [ # # ][ # # ]: 0 : if ( !xColumns.is() || !xColumns->hasElements() )
[ # # ][ # # ]
[ # # ]
112 : : { // perhaps the composer can supply us with columns? This is necessary for cases
113 : : // where the dialog is invoked for a rowset which is not yet loaded
114 : : // #i22878#
115 [ # # ][ # # ]: 0 : xSuppColumns = xSuppColumns.query( m_xComposer );
116 [ # # ]: 0 : if ( xSuppColumns.is() )
117 [ # # ][ # # ]: 0 : xColumns = xSuppColumns->getColumns();
[ # # ]
118 : : }
119 : :
120 [ # # ]: 0 : OSL_ENSURE( xColumns.is() && xColumns->hasElements(), "ComposerDialog::createDialog: not much fun without any columns!" );
121 : : }
122 [ # # ]: 0 : catch( const Exception& )
123 : : {
124 : : DBG_UNHANDLED_EXCEPTION();
125 : : }
126 : :
127 [ # # ][ # # ]: 0 : if ( !xConnection.is() || !xColumns.is() || !m_xComposer.is() )
[ # # ][ # # ]
128 : : // can't create the dialog if I have improper settings
129 : 0 : return NULL;
130 : :
131 [ # # ]: 0 : return createComposerDialog( _pParent, xConnection, xColumns );
132 : : }
133 : :
134 : : //=====================================================================
135 : : //= RowsetFilterDialog
136 : : //=====================================================================
137 : : //---------------------------------------------------------------------
138 : 0 : RowsetFilterDialog::RowsetFilterDialog( const Reference< XMultiServiceFactory >& _rxORB )
139 : 0 : :ComposerDialog( _rxORB )
140 : : {
141 : 0 : }
142 : :
143 : : //---------------------------------------------------------------------
144 [ # # ][ # # ]: 24 : IMPLEMENT_SERVICE_INFO1_STATIC( RowsetFilterDialog, "com.sun.star.uno.comp.sdb.RowsetFilterDialog", "com.sun.star.sdb.FilterDialog" )
[ + - ][ # # ]
[ # # ][ # # ]
[ # # ]
145 : :
146 : : //---------------------------------------------------------------------
147 : 0 : Dialog* RowsetFilterDialog::createComposerDialog( Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns )
148 : : {
149 [ # # ][ # # ]: 0 : return new DlgFilterCrit( _pParent, m_aContext.getLegacyServiceFactory(), _rxConnection, m_xComposer, _rxColumns );
150 : : }
151 : :
152 : : //---------------------------------------------------------------------
153 : 0 : void RowsetFilterDialog::executedDialog( sal_Int16 _nExecutionResult )
154 : : {
155 : 0 : ComposerDialog::executedDialog( _nExecutionResult );
156 : :
157 [ # # ][ # # ]: 0 : if ( _nExecutionResult && m_pDialog )
158 : 0 : static_cast< DlgFilterCrit* >( m_pDialog )->BuildWherePart();
159 : 0 : }
160 : :
161 : : //=====================================================================
162 : : //= RowsetOrderDialog
163 : : //=====================================================================
164 : : //---------------------------------------------------------------------
165 : 0 : RowsetOrderDialog::RowsetOrderDialog( const Reference< XMultiServiceFactory >& _rxORB )
166 : 0 : :ComposerDialog( _rxORB )
167 : : {
168 : 0 : }
169 : :
170 : : //---------------------------------------------------------------------
171 [ # # ][ # # ]: 24 : IMPLEMENT_SERVICE_INFO1_STATIC( RowsetOrderDialog, "com.sun.star.uno.comp.sdb.RowsetOrderDialog", "com.sun.star.sdb.OrderDialog" )
[ + - ][ # # ]
[ # # ][ # # ]
[ # # ]
172 : :
173 : : //---------------------------------------------------------------------
174 : 0 : Dialog* RowsetOrderDialog::createComposerDialog( Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns )
175 : : {
176 [ # # ]: 0 : return new DlgOrderCrit( _pParent, _rxConnection, m_xComposer, _rxColumns );
177 : : }
178 : :
179 : : //---------------------------------------------------------------------
180 : 0 : void RowsetOrderDialog::executedDialog( sal_Int16 _nExecutionResult )
181 : : {
182 : 0 : ComposerDialog::executedDialog( _nExecutionResult );
183 : :
184 [ # # ]: 0 : if ( !m_pDialog )
185 : 0 : return;
186 : :
187 [ # # ]: 0 : if ( _nExecutionResult )
188 : 0 : static_cast< DlgOrderCrit* >( m_pDialog )->BuildOrderPart();
189 [ # # ]: 0 : else if ( m_xComposer.is() )
190 [ # # ]: 0 : m_xComposer->setOrder( static_cast< DlgOrderCrit* >( m_pDialog )->GetOrignalOrder() );
191 : : }
192 : :
193 : : //.........................................................................
194 : : } // namespace dbaui
195 : : //.........................................................................
196 : :
197 : :
198 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|